diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-03-16 15:39:07 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-18 19:06:34 +0000 |
commit | a33c1b62814c59ba3ec647a09cddce2c672a0245 (patch) | |
tree | 9dc5fbee02f13c24b2e53622b733ec237647415b | |
parent | 5cb6c63a10e815169be397ac48475036b96836a9 (diff) |
Qt Designer: Port code to use size() instead of count() of Qt containers
count() will be deprecated.
Fix some integer types in loops and modernize code
in changed lines.
Change-Id: Ibfd7012f04254d34aa2657d697460092fe093d1f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit e0649aadf3ed27344627144164d43c60699500f4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
28 files changed, 86 insertions, 95 deletions
diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp index dda88489f..4d8c1a638 100644 --- a/src/designer/src/components/formeditor/formwindow.cpp +++ b/src/designer/src/components/formeditor/formwindow.cpp @@ -2711,7 +2711,7 @@ bool FormWindow::blockSelectionChanged(bool b) void FormWindow::editContents() { const QWidgetList sel = selectedWidgets(); - if (sel.count() == 1) { + if (sel.size() == 1) { QWidget *widget = sel.first(); if (QAction *a = preferredEditAction(core(), widget)) diff --git a/src/designer/src/components/formeditor/formwindow.h b/src/designer/src/components/formeditor/formwindow.h index a2d16fe5f..1e64e88b5 100644 --- a/src/designer/src/components/formeditor/formwindow.h +++ b/src/designer/src/components/formeditor/formwindow.h @@ -148,7 +148,7 @@ public: void raiseSelection(QWidget *w); inline const QWidgetList& widgets() const { return m_widgets; } - inline int widgetCount() const { return m_widgets.count(); } + inline int widgetCount() const { return m_widgets.size(); } inline QWidget *widgetAt(int index) const { return m_widgets.at(index); } QWidgetList widgets(QWidget *widget) const; diff --git a/src/designer/src/components/formeditor/formwindow_widgetstack.cpp b/src/designer/src/components/formeditor/formwindow_widgetstack.cpp index da6512211..1d2db8218 100644 --- a/src/designer/src/components/formeditor/formwindow_widgetstack.cpp +++ b/src/designer/src/components/formeditor/formwindow_widgetstack.cpp @@ -68,7 +68,7 @@ FormWindowWidgetStack::~FormWindowWidgetStack() = default; int FormWindowWidgetStack::count() const { - return m_tools.count(); + return m_tools.size(); } QDesignerFormWindowToolInterface *FormWindowWidgetStack::currentTool() const diff --git a/src/designer/src/components/formeditor/formwindowcursor.cpp b/src/designer/src/components/formeditor/formwindowcursor.cpp index 31dcdfebb..8375ce32f 100644 --- a/src/designer/src/components/formeditor/formwindowcursor.cpp +++ b/src/designer/src/components/formeditor/formwindowcursor.cpp @@ -122,7 +122,7 @@ bool FormWindowCursor::hasSelection() const int FormWindowCursor::selectedWidgetCount() const { - int N = m_formWindow->selectedWidgets().count(); + int N = m_formWindow->selectedWidgets().size(); return N ? N : 1; } diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp index c0f84061a..c7c0ff0db 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.cpp +++ b/src/designer/src/components/formeditor/formwindowmanager.cpp @@ -811,7 +811,7 @@ void FormWindowManager::slotUpdateActions() bool canMorphIntoHBoxLayout = false; bool canMorphIntoGridLayout = false; bool canMorphIntoFormLayout = false; - int selectedWidgetCount = 0; + bool hasSelectedWidgets = false; int laidoutWidgetCount = 0; int unlaidoutWidgetCount = 0; #if QT_CONFIG(clipboard) @@ -831,7 +831,7 @@ void FormWindowManager::slotUpdateActions() QWidgetList simplifiedSelection = m_activeFormWindow->selectedWidgets(); - selectedWidgetCount = simplifiedSelection.count(); + hasSelectedWidgets = !simplifiedSelection.isEmpty(); #if QT_CONFIG(clipboard) pasteAvailable = qApp->clipboard()->mimeData() && qApp->clipboard()->mimeData()->hasText(); #endif @@ -854,7 +854,7 @@ void FormWindowManager::slotUpdateActions() } // Figure out layouts: Looking at a group of dangling widgets - if (simplifiedSelection.count() != 1) { + if (simplifiedSelection.size() != 1) { layoutAvailable = unlaidoutWidgetCount > 1; //breakAvailable = false; break; @@ -903,13 +903,13 @@ void FormWindowManager::slotUpdateActions() } while(false); #if QT_CONFIG(clipboard) - m_actionCut->setEnabled(selectedWidgetCount > 0); - m_actionCopy->setEnabled(selectedWidgetCount > 0); + m_actionCut->setEnabled(hasSelectedWidgets); + m_actionCopy->setEnabled(hasSelectedWidgets); m_actionPaste->setEnabled(pasteAvailable); #endif - m_actionDelete->setEnabled(selectedWidgetCount > 0); - m_actionLower->setEnabled(canChangeZOrder && selectedWidgetCount > 0); - m_actionRaise->setEnabled(canChangeZOrder && selectedWidgetCount > 0); + m_actionDelete->setEnabled(hasSelectedWidgets); + m_actionLower->setEnabled(canChangeZOrder && hasSelectedWidgets); + m_actionRaise->setEnabled(canChangeZOrder && hasSelectedWidgets); m_actionSelectAll->setEnabled(m_activeFormWindow != nullptr); diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index e46a01bfa..50042c3ca 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -1273,7 +1273,7 @@ DomTabStops *QDesignerResource::saveTabStops() tabStops.append(widget->objectName()); } - if (tabStops.count()) { + if (!tabStops.isEmpty()) { DomTabStops *dom = new DomTabStops; dom->setElementTabStop(tabStops); return dom; @@ -1940,7 +1940,7 @@ QList<DomProperty*> QDesignerResource::computeProperties(QObject *object) } } if (compressSpacings) { - if (spacingProperties.count() == 2) { + if (spacingProperties.size() == 2) { DomProperty *spacingProperty = spacingProperties.at(0); spacingProperty->setAttributeName(QStringLiteral("spacing")); properties.append(spacingProperty); diff --git a/src/designer/src/components/formeditor/qmainwindow_container.cpp b/src/designer/src/components/formeditor/qmainwindow_container.cpp index 8bed2911b..6d4b889e5 100644 --- a/src/designer/src/components/formeditor/qmainwindow_container.cpp +++ b/src/designer/src/components/formeditor/qmainwindow_container.cpp @@ -50,7 +50,7 @@ QMainWindowContainer::QMainWindowContainer(QMainWindow *widget, QObject *parent) int QMainWindowContainer::count() const { - return m_widgets.count(); + return m_widgets.size(); } QWidget *QMainWindowContainer::widget(int index) const diff --git a/src/designer/src/components/formeditor/qmdiarea_container.cpp b/src/designer/src/components/formeditor/qmdiarea_container.cpp index 03fe667a3..30781d67b 100644 --- a/src/designer/src/components/formeditor/qmdiarea_container.cpp +++ b/src/designer/src/components/formeditor/qmdiarea_container.cpp @@ -49,7 +49,7 @@ QMdiAreaContainer::QMdiAreaContainer(QMdiArea *widget, QObject *parent) int QMdiAreaContainer::count() const { - return m_mdiArea->subWindowList(QMdiArea::CreationOrder).count(); + return m_mdiArea->subWindowList(QMdiArea::CreationOrder).size(); } QWidget *QMdiAreaContainer::widget(int index) const diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index d65d5deeb..60bb459e0 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -1015,10 +1015,10 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (QtProperty *flagProperty = m_flagToProperty.value(property, 0)) { const auto subFlags = m_propertyToFlags.value(flagProperty); - const int subFlagCount = subFlags.count(); + const qsizetype subFlagCount = subFlags.size(); // flag changed const bool subValue = variantProperty(property)->value().toBool(); - const int subIndex = subFlags.indexOf(property); + const qsizetype subIndex = subFlags.indexOf(property); if (subIndex < 0) return; @@ -1030,21 +1030,21 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari const auto values = data.values; // Compute new value, without including (additional) supermasks if (values.at(subIndex) == 0) { - for (int i = 0; i < subFlagCount; ++i) { + for (qsizetype i = 0; i < subFlagCount; ++i) { QtVariantProperty *subFlag = variantProperty(subFlags.at(i)); subFlag->setValue(i == subIndex); } } else { if (subValue) newValue = values.at(subIndex); // value mask of subValue - for (int i = 0; i < subFlagCount; ++i) { + for (qsizetype i = 0; i < subFlagCount; ++i) { QtVariantProperty *subFlag = variantProperty(subFlags.at(i)); if (subFlag->value().toBool() && bitCount(values.at(i)) == 1) newValue |= values.at(i); } if (newValue == 0) { // Uncheck all items except 0-mask - for (int i = 0; i < subFlagCount; ++i) { + for (qsizetype i = 0; i < subFlagCount; ++i) { QtVariantProperty *subFlag = variantProperty(subFlags.at(i)); subFlag->setValue(values.at(i) == 0); } @@ -1055,7 +1055,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari } } else { // Make sure 0-mask is not selected - for (int i = 0; i < subFlagCount; ++i) { + for (qsizetype i = 0; i < subFlagCount; ++i) { QtVariantProperty *subFlag = variantProperty(subFlags.at(i)); if (values.at(i) == 0) subFlag->setValue(false); @@ -1063,7 +1063,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari // Check/uncheck proper masks if (subValue) { // Make sure submasks and supermasks are selected - for (int i = 0; i < subFlagCount; ++i) { + for (qsizetype i = 0; i < subFlagCount; ++i) { QtVariantProperty *subFlag = variantProperty(subFlags.at(i)); const uint vi = values.at(i); if ((vi != 0) && ((vi & newValue) == vi) && !subFlag->value().toBool()) @@ -1071,7 +1071,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari } } else { // Make sure supermasks are not selected if they're no longer valid - for (int i = 0; i < subFlagCount; ++i) { + for (qsizetype i = 0; i < subFlagCount; ++i) { QtVariantProperty *subFlag = variantProperty(subFlags.at(i)); const uint vi = values.at(i); if (subFlag->value().toBool() && ((vi & newValue) != vi)) @@ -1777,15 +1777,15 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val const auto values = data.values; const auto subFlags = m_propertyToFlags.value(property); - const int subFlagCount = subFlags.count(); - for (int i = 0; i < subFlagCount; ++i) { + const qsizetype subFlagCount = subFlags.size(); + for (qsizetype i = 0; i < subFlagCount; ++i) { QtVariantProperty *subFlag = variantProperty(subFlags.at(i)); const uint val = values.at(i); const bool checked = (val == 0) ? (v == 0) : ((val & v) == val); subFlag->setValue(checked); } - for (int i = 0; i < subFlagCount; ++i) { + for (qsizetype i = 0; i < subFlagCount; ++i) { QtVariantProperty *subFlag = variantProperty(subFlags.at(i)); const uint val = values.at(i); const bool checked = (val == 0) ? (v == 0) : ((val & v) == val); @@ -1796,7 +1796,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val } else if (bitCount(val) > 1) { // Disabled if all flags contained in the mask are checked uint currentMask = 0; - for (int j = 0; j < subFlagCount; ++j) { + for (qsizetype j = 0; j < subFlagCount; ++j) { QtVariantProperty *subFlag = variantProperty(subFlags.at(j)); if (bitCount(values.at(j)) == 1) currentMask |= subFlag->value().toBool() ? values.at(j) : 0; diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp index c80cf794c..4a30c5c3c 100644 --- a/src/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp @@ -214,20 +214,12 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare m_buttonAction(new QAction(tr("Drop Down Button View"), this)), m_classLabel(new ElidingLabel) { - QList<QColor> colors; - colors.reserve(6); - colors.push_back(QColor(255, 230, 191)); - colors.push_back(QColor(255, 255, 191)); - colors.push_back(QColor(191, 255, 191)); - colors.push_back(QColor(199, 255, 255)); - colors.push_back(QColor(234, 191, 255)); - colors.push_back(QColor(255, 191, 239)); - m_colors.reserve(colors.count()); + const QColor colors[] = {{255, 230, 191}, {255, 255, 191}, {191, 255, 191}, + {199, 255, 255}, {234, 191, 255}, {255, 191, 239}}; const int darknessFactor = 250; - for (int i = 0; i < colors.count(); i++) { - const QColor &c = colors.at(i); + m_colors.reserve(std::size(colors)); + for (const QColor &c : colors) m_colors.push_back(qMakePair(c, c.darker(darknessFactor))); - } QColor dynamicColor(191, 207, 255); QColor layoutColor(255, 191, 191); m_dynamicColor = qMakePair(dynamicColor, dynamicColor.darker(darknessFactor)); diff --git a/src/designer/src/designer/qdesigner_settings.cpp b/src/designer/src/designer/qdesigner_settings.cpp index e8ac4be54..ded5760bb 100644 --- a/src/designer/src/designer/qdesigner_settings.cpp +++ b/src/designer/src/designer/qdesigner_settings.cpp @@ -186,8 +186,8 @@ QMap<QString, QString> QDesignerSettings::backup() const const QStringList bak = settings()->value(QLatin1String(backupBakListKey), QStringList()).toStringList(); QMap<QString, QString> map; - const int orgCount = org.count(); - for (int i = 0; i < orgCount; ++i) + const qsizetype orgCount = org.size(); + for (qsizetype i = 0; i < orgCount; ++i) map.insert(org.at(i), bak.at(i)); return map; diff --git a/src/designer/src/designer/qdesigner_workbench.cpp b/src/designer/src/designer/qdesigner_workbench.cpp index f94aa98bd..43afbf3fd 100644 --- a/src/designer/src/designer/qdesigner_workbench.cpp +++ b/src/designer/src/designer/qdesigner_workbench.cpp @@ -537,7 +537,7 @@ QDesignerFormEditorInterface *QDesignerWorkbench::core() const int QDesignerWorkbench::toolWindowCount() const { - return m_toolWindows.count(); + return m_toolWindows.size(); } QDesignerToolWindow *QDesignerWorkbench::toolWindow(int index) const @@ -547,7 +547,7 @@ QDesignerToolWindow *QDesignerWorkbench::toolWindow(int index) const int QDesignerWorkbench::formWindowCount() const { - return m_formWindows.count(); + return m_formWindows.size(); } QDesignerFormWindow *QDesignerWorkbench::formWindow(int index) const diff --git a/src/designer/src/lib/sdk/abstractwidgetdatabase.cpp b/src/designer/src/lib/sdk/abstractwidgetdatabase.cpp index a348580ea..0449920ba 100644 --- a/src/designer/src/lib/sdk/abstractwidgetdatabase.cpp +++ b/src/designer/src/lib/sdk/abstractwidgetdatabase.cpp @@ -65,7 +65,7 @@ QDesignerWidgetDataBaseInterface::~QDesignerWidgetDataBaseInterface() */ int QDesignerWidgetDataBaseInterface::count() const { - return m_items.count(); + return m_items.size(); } /*! diff --git a/src/designer/src/lib/shared/actionprovider_p.h b/src/designer/src/lib/shared/actionprovider_p.h index 63d902951..a608781c3 100644 --- a/src/designer/src/lib/shared/actionprovider_p.h +++ b/src/designer/src/lib/shared/actionprovider_p.h @@ -67,15 +67,14 @@ template <class Widget> int actionIndexAt(const Widget *w, const QPoint &pos, Qt::Orientation orientation) { const auto actions = w->actions(); - const int actionCount = actions.count(); - if (actionCount == 0) + if (actions.isEmpty()) return -1; // actionGeometry() can be wrong sometimes; it returns a geometry that // stretches to the end of the toolbar/menu bar. So, check from the beginning // in the case of a horizontal right-to-left orientation. const bool checkTopRight = orientation == Qt::Horizontal && w->layoutDirection() == Qt::RightToLeft; const QPoint topRight = QPoint(w->rect().width(), 0); - for (int index = 0; index < actionCount; ++index) { + for (qsizetype index = 0, actionCount = actions.size(); index < actionCount; ++index) { QRect g = w->actionGeometry(actions.at(index)); if (checkTopRight) g.setTopRight(topRight); @@ -83,7 +82,7 @@ template <class Widget> g.setTopLeft(QPoint(0, 0)); if (g.contains(pos)) - return index; + return int(index); } return -1; } diff --git a/src/designer/src/lib/shared/formwindowbase.cpp b/src/designer/src/lib/shared/formwindowbase.cpp index 8a126c1a1..963c0217d 100644 --- a/src/designer/src/lib/shared/formwindowbase.cpp +++ b/src/designer/src/lib/shared/formwindowbase.cpp @@ -163,7 +163,7 @@ void FormWindowBase::addReloadableProperty(QDesignerPropertySheet *sheet, int in void FormWindowBase::removeReloadableProperty(QDesignerPropertySheet *sheet, int index) { m_d->m_reloadableResources[sheet].remove(index); - if (!m_d->m_reloadableResources[sheet].count()) { + if (m_d->m_reloadableResources[sheet].isEmpty()) { m_d->m_reloadableResources.remove(sheet); disconnectSheet(sheet); } diff --git a/src/designer/src/lib/shared/grid.cpp b/src/designer/src/lib/shared/grid.cpp index 9f9ff7d65..180bb78ce 100644 --- a/src/designer/src/lib/shared/grid.cpp +++ b/src/designer/src/lib/shared/grid.cpp @@ -135,7 +135,7 @@ void Grid::paint(QPainter &p, const QWidget *widget, QPaintEvent *e) const points.reserve((yend - ystart) / m_deltaY + 1); for (int y = ystart; y <= yend; y += m_deltaY) points.push_back(QPointF(x, y)); - p.drawPoints( &(*points.begin()), points.count()); + p.drawPoints( &(*points.begin()), points.size()); points.clear(); } } diff --git a/src/designer/src/lib/shared/iconselector.cpp b/src/designer/src/lib/shared/iconselector.cpp index 7b3c7a6b0..fa3f86708 100644 --- a/src/designer/src/lib/shared/iconselector.cpp +++ b/src/designer/src/lib/shared/iconselector.cpp @@ -333,8 +333,8 @@ static QString imageFilter() QString filter = QApplication::translate("IconSelector", "All Pixmaps ("); const auto supportedImageFormats = QImageReader::supportedImageFormats(); const QString jpeg = QStringLiteral("JPEG"); - const int count = supportedImageFormats.count(); - for (int i = 0; i< count; ++i) { + const qsizetype count = supportedImageFormats.size(); + for (qsizetype i = 0; i < count; ++i) { if (i) filter += QLatin1Char(' '); filter += QStringLiteral("*."); diff --git a/src/designer/src/lib/shared/layout.cpp b/src/designer/src/lib/shared/layout.cpp index ce2351d65..daa559d20 100644 --- a/src/designer/src/lib/shared/layout.cpp +++ b/src/designer/src/lib/shared/layout.cpp @@ -153,7 +153,7 @@ void Layout::setup() QWidgetList lastList; const QWidgetList &parents = lists.keys(); for (QWidget *p : parents) { - if (lists.count(p) > lastList.count()) + if (lists.count(p) > lastList.size()) lastList = lists.values(p); } @@ -162,7 +162,7 @@ void Layout::setup() // best list has only one entry and we do not layout a container, // we leave here. QDesignerWidgetDataBaseInterface *widgetDataBase = m_formWindow->core()->widgetDataBase(); - if (lastList.count() < 2 && + if (lastList.size() < 2 && (!m_layoutBase || (!widgetDataBase->isContainer(m_layoutBase, false) && m_layoutBase != m_formWindow->mainContainer())) @@ -319,7 +319,7 @@ void Layout::finishLayout(bool needMove, QLayout *layout) void Layout::undoLayout() { - if (!m_widgets.count()) + if (m_widgets.isEmpty()) return; m_formWindow->selectWidget(m_layoutBase, false); diff --git a/src/designer/src/lib/shared/orderdialog.cpp b/src/designer/src/lib/shared/orderdialog.cpp index 51389a974..923ab48d1 100644 --- a/src/designer/src/lib/shared/orderdialog.cpp +++ b/src/designer/src/lib/shared/orderdialog.cpp @@ -79,9 +79,9 @@ void OrderDialog::setPageList(const QWidgetList &pages) // The old index is set as user data on the item instead of the QWidget* // because DnD is enabled which requires the user data to serializable m_orderMap.clear(); - const int count = pages.count(); - for (int i=0; i < count; ++i) - m_orderMap.insert(i, pages.at(i)); + const qsizetype count = pages.size(); + for (qsizetype i = 0; i < count; ++i) + m_orderMap.insert(int(i), pages.at(i)); buildList(); } diff --git a/src/designer/src/lib/shared/qdesigner_command.cpp b/src/designer/src/lib/shared/qdesigner_command.cpp index d6a6416ae..8fb723126 100644 --- a/src/designer/src/lib/shared/qdesigner_command.cpp +++ b/src/designer/src/lib/shared/qdesigner_command.cpp @@ -266,8 +266,8 @@ void ChangeZOrderCommand::init(QWidget *widget) setText(QApplication::translate("Command", "Change Z-order of '%1'").arg(widget->objectName())); m_oldParentZOrder = qvariant_cast<QWidgetList>(widget->parentWidget()->property("_q_zOrder")); - const int index = m_oldParentZOrder.indexOf(m_widget); - if (index != -1 && index + 1 < m_oldParentZOrder.count()) + const qsizetype index = m_oldParentZOrder.indexOf(m_widget); + if (index != -1 && index + 1 < m_oldParentZOrder.size()) m_oldPreceding = m_oldParentZOrder.at(index + 1); } @@ -2528,7 +2528,7 @@ void TreeWidgetContents::applyToTreeWidget(QTreeWidget *treeWidget, DesignerIcon { treeWidget->clear(); - treeWidget->setColumnCount(m_headerItem.m_items.count()); + treeWidget->setColumnCount(m_headerItem.m_items.size()); treeWidget->setHeaderItem(m_headerItem.createTreeItem(iconCache)); for (const ItemContents &ic : m_rootItems) treeWidget->addTopLevelItem(ic.createTreeItem(iconCache, editor)); diff --git a/src/designer/src/lib/shared/qdesigner_menu.cpp b/src/designer/src/lib/shared/qdesigner_menu.cpp index 35a116bae..a098c757c 100644 --- a/src/designer/src/lib/shared/qdesigner_menu.cpp +++ b/src/designer/src/lib/shared/qdesigner_menu.cpp @@ -224,7 +224,7 @@ bool QDesignerMenu::handleKeyPressEvent(QWidget * /*widget*/, QKeyEvent *e) break; case Qt::Key_PageDown: - m_currentIndex = actions().count() - 1; + m_currentIndex = actions().size() - 1; break; case Qt::Key_Enter: @@ -794,7 +794,7 @@ void QDesignerMenu::dropEvent(QDropEvent *event) if (action && checkAction(action) == AcceptActionDrag) { event->acceptProposedAction(); int index = findAction(event->position().toPoint()); - index = qMin(index, actions().count() - 1); + index = qMin(index, actions().size() - 1); fw->beginCommand(tr("Insert action")); InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); @@ -924,7 +924,7 @@ void QDesignerMenu::moveUp(bool ctrl) void QDesignerMenu::moveDown(bool ctrl) { - if (m_currentIndex == actions().count() - 1) { + if (m_currentIndex == actions().size() - 1) { return; } @@ -932,7 +932,7 @@ void QDesignerMenu::moveDown(bool ctrl) (void) swap(m_currentIndex + 1, m_currentIndex); ++m_currentIndex; - m_currentIndex = qMin(actions().count() - 1, m_currentIndex); + m_currentIndex = qMin(actions().size() - 1, m_currentIndex); update(); if (!ctrl) selectCurrentAction(); @@ -940,7 +940,7 @@ void QDesignerMenu::moveDown(bool ctrl) QAction *QDesignerMenu::currentAction() const { - if (m_currentIndex < 0 || m_currentIndex >= actions().count()) + if (m_currentIndex < 0 || m_currentIndex >= actions().size()) return nullptr; return safeActionAt(m_currentIndex); @@ -948,7 +948,7 @@ QAction *QDesignerMenu::currentAction() const int QDesignerMenu::realActionCount() const { - return actions().count() - 2; // 2 fake actions + return actions().size() - 2; // 2 fake actions } void QDesignerMenu::selectCurrentAction() @@ -1299,7 +1299,7 @@ bool QDesignerMenu::swap(int a, int b) QAction *QDesignerMenu::safeActionAt(int index) const { - if (index < 0 || index >= actions().count()) + if (index < 0 || index >= actions().size()) return nullptr; return actions().at(index); diff --git a/src/designer/src/lib/shared/qdesigner_menubar.cpp b/src/designer/src/lib/shared/qdesigner_menubar.cpp index 51bab619e..9cfe11ed3 100644 --- a/src/designer/src/lib/shared/qdesigner_menubar.cpp +++ b/src/designer/src/lib/shared/qdesigner_menubar.cpp @@ -223,7 +223,7 @@ bool QDesignerMenuBar::handleKeyPressEvent(QWidget *, QKeyEvent *e) break; case Qt::Key_PageDown: - m_currentIndex = actions().count() - 1; + m_currentIndex = actions().size() - 1; break; case Qt::Key_Enter: @@ -365,7 +365,7 @@ bool QDesignerMenuBar::handleMouseMoveEvent(QWidget *, QMouseEvent *event) return true; const int index = actionIndexAt(this, m_startPosition, Qt::Horizontal); - if (index < actions().count()) { + if (index < actions().size()) { hideMenu(index); update(); } @@ -667,7 +667,7 @@ void QDesignerMenuBar::dropEvent(QDropEvent *event) if (checkAction(action) == AcceptActionDrag) { event->acceptProposedAction(); int index = findAction(event->position().toPoint()); - index = qMin(index, actions().count() - 1); + index = qMin(index, actions().size() - 1); QDesignerFormWindowInterface *fw = formWindow(); InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); @@ -705,7 +705,7 @@ QDesignerActionProviderExtension *QDesignerMenuBar::actionProvider() QAction *QDesignerMenuBar::currentAction() const { - if (m_currentIndex < 0 || m_currentIndex >= actions().count()) + if (m_currentIndex < 0 || m_currentIndex >= actions().size()) return nullptr; return safeActionAt(m_currentIndex); @@ -713,7 +713,7 @@ QAction *QDesignerMenuBar::currentAction() const int QDesignerMenuBar::realActionCount() const { - return actions().count() - 1; // 1 fake actions + return actions().size() - 1; // 1 fake actions } bool QDesignerMenuBar::dragging() const @@ -753,7 +753,7 @@ void QDesignerMenuBar::movePrevious(bool ctrl) void QDesignerMenuBar::moveNext(bool ctrl) { const bool swapped = ctrl && swapActions(m_currentIndex + 1, m_currentIndex); - const int newIndex = qMin(actions().count() - 1, m_currentIndex + 1); + const int newIndex = qMin(actions().size() - 1, m_currentIndex + 1); if (swapped || newIndex != m_currentIndex) { m_currentIndex = newIndex; updateCurrentAction(!ctrl); @@ -858,7 +858,7 @@ void QDesignerMenuBar::showMenu(int index) QAction *QDesignerMenuBar::safeActionAt(int index) const { - if (index < 0 || index >= actions().count()) + if (index < 0 || index >= actions().size()) return nullptr; return actions().at(index); diff --git a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp index 209582b1e..10865514f 100644 --- a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -183,7 +183,7 @@ public: explicit QDesignerPropertySheetPrivate(QDesignerPropertySheet *sheetPublic, QObject *object, QObject *sheetParent); bool invalidIndex(const char *functionName, int index) const; - inline int count() const { return m_meta->propertyCount() + m_addProperties.count(); } + inline int count() const { return m_meta->propertyCount() + m_addProperties.size(); } PropertyType propertyType(int index) const; QString transformLayoutPropertyName(int index) const; diff --git a/src/designer/src/lib/shared/qdesigner_toolbar.cpp b/src/designer/src/lib/shared/qdesigner_toolbar.cpp index 5e8eeccdd..f441f1fe2 100644 --- a/src/designer/src/lib/shared/qdesigner_toolbar.cpp +++ b/src/designer/src/lib/shared/qdesigner_toolbar.cpp @@ -195,7 +195,7 @@ void ToolBarEventFilter::slotRemoveSelectedAction() const ActionList actions = m_toolBar->actions(); const int pos = actions.indexOf(a); QAction *action_before = nullptr; - if (pos != -1 && actions.count() > pos + 1) + if (pos != -1 && actions.size() > pos + 1) action_before = actions.at(pos + 1); RemoveActionFromCommand *cmd = new RemoveActionFromCommand(fw); diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp index a8c253117..7b6882391 100644 --- a/src/designer/src/lib/shared/qdesigner_utils.cpp +++ b/src/designer/src/lib/shared/qdesigner_utils.cpp @@ -772,14 +772,14 @@ namespace qdesigner_internal Q_ASSERT(qname.isEmpty() == false); - if (qname.count() > 1 && qname.at(1).isUpper()) { + if (qname.size() > 1 && qname.at(1).isUpper()) { const QChar first = qname.at(0); if (first == QLatin1Char('Q') || first == QLatin1Char('K')) qname.remove(0, 1); } - const int len = qname.count(); - for (int i = 0; i < len && qname.at(i).isUpper(); i++) + const qsizetype len = qname.size(); + for (qsizetype i = 0; i < len && qname.at(i).isUpper(); ++i) qname[i] = qname.at(i).toLower(); return qname; diff --git a/src/designer/src/lib/shared/qtresourceeditordialog.cpp b/src/designer/src/lib/shared/qtresourceeditordialog.cpp index 613c5d0c9..54016fd5a 100644 --- a/src/designer/src/lib/shared/qtresourceeditordialog.cpp +++ b/src/designer/src/lib/shared/qtresourceeditordialog.cpp @@ -1543,7 +1543,7 @@ void QtResourceEditorDialogPrivate::slotAddFiles() QtResourceFile *nextResourceFile = m_qrcManager->nextResourceFile(currentResourceFile); if (!currentResourceFile) { const auto resourceFiles = currentResourcePrefix->resourceFiles(); - if (resourceFiles.count() > 0) + if (!resourceFiles.isEmpty()) nextResourceFile = resourceFiles.first(); } @@ -2072,9 +2072,9 @@ QString QtResourceEditorDialog::selectedResource() const if (resourceEnding.startsWith(slash)) resourceEnding = resourceEnding.mid(1); else if (resourceEnding.startsWith(dotSlash)) - resourceEnding = resourceEnding.mid(dotSlash.count()); + resourceEnding = resourceEnding.mid(dotSlash.size()); else if (resourceEnding.startsWith(dotDotSlash)) - resourceEnding = resourceEnding.mid(dotDotSlash.count()); + resourceEnding = resourceEnding.mid(dotDotSlash.size()); else break; } diff --git a/src/designer/src/lib/shared/qtresourcemodel.cpp b/src/designer/src/lib/shared/qtresourcemodel.cpp index 391cf49a3..fae199886 100644 --- a/src/designer/src/lib/shared/qtresourcemodel.cpp +++ b/src/designer/src/lib/shared/qtresourcemodel.cpp @@ -378,7 +378,7 @@ void QtResourceModelPrivate::removeOldPaths(QtResourceSet *resourceSet, const QS const int idx = itRemove.value().indexOf(resourceSet); if (idx >= 0) itRemove.value().removeAt(idx); - if (itRemove.value().count() == 0) { + if (itRemove.value().isEmpty()) { PathDataMap::iterator it = m_pathToData.find(oldPath); if (it != m_pathToData.end()) deleteResource(it.value()); diff --git a/src/designer/src/lib/uilib/abstractformbuilder.cpp b/src/designer/src/lib/uilib/abstractformbuilder.cpp index d460c013c..a22c2ede2 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/src/designer/src/lib/uilib/abstractformbuilder.cpp @@ -2076,10 +2076,10 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags"); const auto &columns = ui_widget->elementColumn(); - if (columns.count() > 0) - treeWidget->setColumnCount(columns.count()); + if (!columns.isEmpty()) + treeWidget->setColumnCount(columns.size()); - for (int i = 0; i<columns.count(); ++i) { + for (qsizetype i = 0, size = columns.size(); i < size; ++i) { const DomColumn *c = columns.at(i); const DomPropertyHash properties = propertyMap(c->elementProperty()); @@ -2179,9 +2179,9 @@ void QAbstractFormBuilder::loadTableWidgetExtraInfo(DomWidget *ui_widget, QTable Q_UNUSED(parentWidget); const auto &columns = ui_widget->elementColumn(); - if (columns.count() > 0) - tableWidget->setColumnCount(columns.count()); - for (int i = 0; i< columns.count(); i++) { + if (!columns.isEmpty()) + tableWidget->setColumnCount(columns.size()); + for (qsizetype i = 0, size = columns.size(); i < size; ++i) { DomColumn *c = columns.at(i); const DomPropertyHash properties = propertyMap(c->elementProperty()); @@ -2193,9 +2193,9 @@ void QAbstractFormBuilder::loadTableWidgetExtraInfo(DomWidget *ui_widget, QTable } const auto &rows = ui_widget->elementRow(); - if (rows.count() > 0) - tableWidget->setRowCount(rows.count()); - for (int i = 0; i< rows.count(); i++) { + if (!rows.isEmpty()) + tableWidget->setRowCount(rows.size()); + for (qsizetype i = 0, size = rows.size(); i < size; ++i) { const DomRow *r = rows.at(i); const DomPropertyHash properties = propertyMap(r->elementProperty()); @@ -2460,7 +2460,7 @@ DomAction *QAbstractFormBuilder::createDom(QAction *action) DomButtonGroup *QAbstractFormBuilder::createDom(QButtonGroup *buttonGroup) { - if (buttonGroup->buttons().count() == 0) // Empty group left over on form? + if (buttonGroup->buttons().isEmpty()) // Empty group left over on form? return nullptr; DomButtonGroup *domButtonGroup = new DomButtonGroup; domButtonGroup->setAttributeName(buttonGroup->objectName()); |