forked from qt-creator/qt-creator
ProjectExplorer: Modernize
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using modernize-use-default-member-init modernize-use-equals-default modernize-use-transparent-functors Change-Id: Iebed22caa2e733d292f334e956e3d16b844e14e3 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -66,7 +66,7 @@ static QIcon createCenteredIcon(const QIcon &icon, const QIcon &overlay)
|
||||
{
|
||||
QPixmap targetPixmap;
|
||||
const qreal appDevicePixelRatio = qApp->devicePixelRatio();
|
||||
const int deviceSpaceIconSize = static_cast<int>(Core::Constants::MODEBAR_ICON_SIZE * appDevicePixelRatio);
|
||||
const auto deviceSpaceIconSize = static_cast<int>(Core::Constants::MODEBAR_ICON_SIZE * appDevicePixelRatio);
|
||||
targetPixmap = QPixmap(deviceSpaceIconSize, deviceSpaceIconSize);
|
||||
targetPixmap.setDevicePixelRatio(appDevicePixelRatio);
|
||||
targetPixmap.fill(Qt::transparent);
|
||||
@@ -107,10 +107,10 @@ class TargetSelectorDelegate : public QItemDelegate
|
||||
public:
|
||||
TargetSelectorDelegate(ListWidget *parent) : QItemDelegate(parent), m_listWidget(parent) { }
|
||||
private:
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void paint(QPainter *painter,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
const QModelIndex &index) const override;
|
||||
ListWidget *m_listWidget;
|
||||
};
|
||||
|
||||
@@ -227,8 +227,8 @@ void ListWidget::setOptimalWidth(int width)
|
||||
int ListWidget::padding()
|
||||
{
|
||||
// there needs to be enough extra pixels to show a scrollbar
|
||||
return 2 * style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, this)
|
||||
+ style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, this)
|
||||
return 2 * style()->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, this)
|
||||
+ style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, this)
|
||||
+ 10;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ void ProjectListWidget::addProject(Project *project)
|
||||
|
||||
int pos = count();
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
if (projectLesserThan(project, p)) {
|
||||
pos = i;
|
||||
break;
|
||||
@@ -281,7 +281,7 @@ void ProjectListWidget::addProject(Project *project)
|
||||
|
||||
bool useFullName = false;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
if (p->displayName() == project->displayName()) {
|
||||
useFullName = true;
|
||||
item(i)->setText(fullName(p));
|
||||
@@ -289,7 +289,7 @@ void ProjectListWidget::addProject(Project *project)
|
||||
}
|
||||
|
||||
QString displayName = useFullName ? fullName(project) : project->displayName();
|
||||
QListWidgetItem *item = new QListWidgetItem();
|
||||
auto *item = new QListWidgetItem();
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(project));
|
||||
item->setText(displayName);
|
||||
insertItem(pos, item);
|
||||
@@ -317,14 +317,14 @@ void ProjectListWidget::removeProject(Project *project)
|
||||
int countDisplayName = 0;
|
||||
int otherIndex = -1;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
Project *p = item(i)->data(Qt::UserRole).value<Project *>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<Project *>();
|
||||
if (p->displayName() == name) {
|
||||
++countDisplayName;
|
||||
otherIndex = i;
|
||||
}
|
||||
}
|
||||
if (countDisplayName == 1) {
|
||||
Project *p = item(otherIndex)->data(Qt::UserRole).value<Project *>();
|
||||
auto *p = item(otherIndex)->data(Qt::UserRole).value<Project *>();
|
||||
item(otherIndex)->setText(p->displayName());
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ void ProjectListWidget::projectDisplayNameChanged(Project *project)
|
||||
int oldPos = 0;
|
||||
bool useFullName = false;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
if (p == project) {
|
||||
oldPos = i;
|
||||
} else if (p->displayName() == project->displayName()) {
|
||||
@@ -360,7 +360,7 @@ void ProjectListWidget::projectDisplayNameChanged(Project *project)
|
||||
|
||||
int pos = count();
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
if (projectLesserThan(project, p)) {
|
||||
pos = i;
|
||||
break;
|
||||
@@ -389,7 +389,7 @@ void ProjectListWidget::setProject(int index)
|
||||
return;
|
||||
if (index < 0)
|
||||
return;
|
||||
Project *p = item(index)->data(Qt::UserRole).value<Project *>();
|
||||
auto *p = item(index)->data(Qt::UserRole).value<Project *>();
|
||||
SessionManager::setStartupProject(p);
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ void GenericListWidget::setProjectConfigurations(const QList<ProjectConfiguratio
|
||||
clear();
|
||||
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
disconnect(p, &ProjectConfiguration::displayNameChanged,
|
||||
this, &GenericListWidget::displayNameChanged);
|
||||
}
|
||||
@@ -450,7 +450,7 @@ void GenericListWidget::addProjectConfiguration(ProjectConfiguration *pc)
|
||||
// Figure out pos
|
||||
int pos = count();
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
if (caseFriendlyCompare(pc->displayName(), p->displayName()) < 0) {
|
||||
pos = i;
|
||||
break;
|
||||
@@ -480,7 +480,7 @@ void GenericListWidget::removeProjectConfiguration(ProjectConfiguration *pc)
|
||||
QFontMetrics fn(font());
|
||||
int width = 0;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
width = qMax(width, fn.width(p->displayName()) + padding());
|
||||
}
|
||||
setOptimalWidth(width);
|
||||
@@ -504,7 +504,7 @@ void GenericListWidget::displayNameChanged()
|
||||
if (currentItem())
|
||||
activeProjectConfiguration = currentItem()->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
|
||||
ProjectConfiguration *pc = qobject_cast<ProjectConfiguration *>(sender());
|
||||
auto *pc = qobject_cast<ProjectConfiguration *>(sender());
|
||||
int index = -1;
|
||||
int i = 0;
|
||||
for (; i < count(); ++i) {
|
||||
@@ -520,7 +520,7 @@ void GenericListWidget::displayNameChanged()
|
||||
lwi->setText(pc->displayName());
|
||||
int pos = count();
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
if (caseFriendlyCompare(pc->displayName(), p->displayName()) < 0) {
|
||||
pos = i;
|
||||
break;
|
||||
@@ -533,7 +533,7 @@ void GenericListWidget::displayNameChanged()
|
||||
QFontMetrics fn(font());
|
||||
int width = 0;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
width = qMax(width, fn.width(p->displayName()) + padding());
|
||||
}
|
||||
setOptimalWidth(width);
|
||||
@@ -543,7 +543,7 @@ void GenericListWidget::displayNameChanged()
|
||||
|
||||
void GenericListWidget::toolTipChanged()
|
||||
{
|
||||
ProjectConfiguration *pc = qobject_cast<ProjectConfiguration *>(sender());
|
||||
auto *pc = qobject_cast<ProjectConfiguration *>(sender());
|
||||
if (QListWidgetItem *lwi = itemForProjectConfiguration(pc)) {
|
||||
lwi->setData(Qt::ToolTipRole, pc->toolTip());
|
||||
lwi->setData(Qt::UserRole + 1, pc->toolTip());
|
||||
@@ -646,9 +646,9 @@ void KitAreaWidget::updateKit(Kit *k)
|
||||
|
||||
QWidget *MiniProjectTargetSelector::createTitleLabel(const QString &text)
|
||||
{
|
||||
StyledBar *bar = new StyledBar(this);
|
||||
auto *bar = new StyledBar(this);
|
||||
bar->setSingleRow(true);
|
||||
QVBoxLayout *toolLayout = new QVBoxLayout(bar);
|
||||
auto *toolLayout = new QVBoxLayout(bar);
|
||||
toolLayout->setContentsMargins(6, 0, 6, 0);
|
||||
toolLayout->setSpacing(0);
|
||||
|
||||
@@ -864,7 +864,7 @@ void MiniProjectTargetSelector::doLayout(bool keepSize)
|
||||
// if there's a configured project in the seesion
|
||||
// that could be improved
|
||||
static QStatusBar *statusBar = Core::ICore::statusBar();
|
||||
static QWidget *actionBar = Core::ICore::mainWindow()->findChild<QWidget*>(QLatin1String("actionbar"));
|
||||
static auto *actionBar = Core::ICore::mainWindow()->findChild<QWidget*>(QLatin1String("actionbar"));
|
||||
Q_ASSERT(actionBar);
|
||||
|
||||
m_kitAreaWidget->move(0, 0);
|
||||
@@ -1407,7 +1407,7 @@ void MiniProjectTargetSelector::nextOrShow()
|
||||
} else {
|
||||
m_hideOnRelease = true;
|
||||
m_earliestHidetime = QDateTime::currentDateTime().addMSecs(800);
|
||||
if (ListWidget *lw = qobject_cast<ListWidget *>(focusWidget())) {
|
||||
if (auto *lw = qobject_cast<ListWidget *>(focusWidget())) {
|
||||
if (lw->currentRow() < lw->count() -1)
|
||||
lw->setCurrentRow(lw->currentRow() + 1);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user