diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-08-03 15:02:03 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-03 10:19:26 +0000 |
commit | 53094d904447abf2c720dbec1bf8d6e63d53af14 (patch) | |
tree | 9c7099bbf252b9b928007f5c2f0d879fde6e85c6 /src | |
parent | 72c8cc1b4dd0cc77d074a4cee1d698b8fb69e503 (diff) |
Qt Designer: Fix some remaining clang-tidy warnings
- Use QHash instead of QMap for pointer type keys
- Use const ref to avoid copies
- Fix C-style casts
- Add parentheses to macro parameters
Change-Id: I74c060fc32c6f7761582d81d219455b1e58c6ff9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src')
11 files changed, 26 insertions, 25 deletions
diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index 82116ec2f..c840bf35f 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -1027,11 +1027,10 @@ void QDesignerResource::applyProperties(QObject *o, const QList<DomProperty*> &p QWidget *QDesignerResource::createWidget(const QString &widgetName, QWidget *parentWidget, const QString &_name) { QString name = _name; - QString className = widgetName; if (m_isMainWidget) m_isMainWidget = false; - QWidget *w = core()->widgetFactory()->createWidget(className, parentWidget); + QWidget *w = core()->widgetFactory()->createWidget(widgetName, parentWidget); if (!w) return 0; diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index f954962f6..2027481e8 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -437,13 +437,11 @@ void TextEditor::buttonClicked() newText = dlg.text(); } break; - case ValidationURL: { - QString oldPath = oldText; - if (oldPath.isEmpty() || oldPath.startsWith(QStringLiteral("qrc:"))) + case ValidationURL: + if (oldText.isEmpty() || oldText.startsWith(QStringLiteral("qrc:"))) resourceActionActivated(); else fileActionActivated(); - } return; default: return; @@ -1548,7 +1546,7 @@ QString DesignerPropertyManager::valueText(const QtProperty *property) const const QString theme = icon.theme(); if (!theme.isEmpty() && QIcon::hasThemeIcon(theme)) return tr("[Theme] %1").arg(theme); - const PropertySheetIconValue::ModeStateToPixmapMap paths = icon.paths(); + const auto &paths = icon.paths(); const PropertySheetIconValue::ModeStateToPixmapMap::const_iterator it = paths.constFind(qMakePair(QIcon::Normal, QIcon::Off)); if (it == paths.constEnd()) return QString(); @@ -1604,7 +1602,7 @@ void DesignerPropertyManager::reloadResourceProperties() DesignerIconCache *iconCache = 0; for (auto itIcon = m_iconValues.cbegin(), end = m_iconValues.cend(); itIcon!= end; ++itIcon) { QtProperty *property = itIcon.key(); - PropertySheetIconValue icon = itIcon.value(); + const PropertySheetIconValue &icon = itIcon.value(); QIcon defaultIcon = m_defaultIcons.value(property); if (!icon.paths().isEmpty()) { @@ -1864,7 +1862,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val defaultIcon = fwb->iconCache()->icon(icon); } - QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> iconPaths = icon.paths(); + const auto &iconPaths = icon.paths(); QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> subProperties = m_propertyToIconSubProperties.value(property); for (auto itSub = subProperties.cbegin(), end = subProperties.cend(); itSub != end; ++itSub) { diff --git a/src/designer/src/components/propertyeditor/paletteeditor.cpp b/src/designer/src/components/propertyeditor/paletteeditor.cpp index 9bb045bd2..c701c5369 100644 --- a/src/designer/src/components/propertyeditor/paletteeditor.cpp +++ b/src/designer/src/components/propertyeditor/paletteeditor.cpp @@ -180,7 +180,7 @@ void PaletteEditor::updatePreviewPalette() QPalette previewPalette; for (int i = QPalette::WindowText; i < QPalette::NColorRoles; i++) { const QPalette::ColorRole r = static_cast<QPalette::ColorRole>(i); - const QBrush br = currentPalette.brush(g, r); + const QBrush &br = currentPalette.brush(g, r); previewPalette.setBrush(QPalette::Active, r, br); previewPalette.setBrush(QPalette::Inactive, r, br); previewPalette.setBrush(QPalette::Disabled, r, br); diff --git a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp index 6620c73c3..323432fab 100644 --- a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp +++ b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp @@ -106,7 +106,7 @@ WidgetBoxTreeWidget::WidgetBoxTreeWidget(QDesignerFormEditorInterface *core, QWi this, &WidgetBoxTreeWidget::handleMousePress); } -QIcon WidgetBoxTreeWidget::iconForWidget(QString iconName) const +QIcon WidgetBoxTreeWidget::iconForWidget(const QString &iconName) const { if (iconName.isEmpty()) return qdesigner_internal::qtLogoIcon(); diff --git a/src/designer/src/components/widgetbox/widgetboxtreewidget.h b/src/designer/src/components/widgetbox/widgetboxtreewidget.h index 6800d7c61..47204897e 100644 --- a/src/designer/src/components/widgetbox/widgetboxtreewidget.h +++ b/src/designer/src/components/widgetbox/widgetboxtreewidget.h @@ -79,7 +79,7 @@ public: bool load(QDesignerWidgetBox::LoadMode loadMode); bool loadContents(const QString &contents); bool save(); - QIcon iconForWidget(QString iconName) const; + QIcon iconForWidget(const QString &iconName) const; signals: void pressed(const QString name, const QString dom_xml, const QPoint &global_mouse_pos); diff --git a/src/designer/src/lib/shared/connectionedit_p.h b/src/designer/src/lib/shared/connectionedit_p.h index a3f1b8bf4..1b9e37dba 100644 --- a/src/designer/src/lib/shared/connectionedit_p.h +++ b/src/designer/src/lib/shared/connectionedit_p.h @@ -43,7 +43,7 @@ #include "shared_global_p.h" -#include <QtCore/qmap.h> +#include <QtCore/qhash.h> #include <QtCore/qlist.h> #include <QtCore/qpointer.h> @@ -68,8 +68,8 @@ class QDESIGNER_SHARED_EXPORT CETypes { public: typedef QList<Connection*> ConnectionList; - typedef QMap<Connection*, Connection*> ConnectionSet; - typedef QMap<QWidget*, QWidget*> WidgetSet; + typedef QHash<Connection*, Connection*> ConnectionSet; + typedef QHash<QWidget*, QWidget*> WidgetSet; class EndPoint { public: diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp index 5adab88a4..7c2868c56 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -169,7 +169,8 @@ enum KeySequenceSubPropertyMask { SubPropertyKeySequenceValue = 1, SubPropertyKe enum CommonSubPropertyMask { SubPropertyAll = 0xFFFFFFFF }; // Set the mask flag in mask if the properties do not match. -#define COMPARE_SUBPROPERTY(object1, object2, getter, mask, maskFlag) if (object1.getter() != object2.getter()) mask |= maskFlag; +#define COMPARE_SUBPROPERTY(object1, object2, getter, mask, maskFlag) \ + if (object1.getter() != object2.getter()) (mask) |= (maskFlag); // find changed subproperties of a rectangle unsigned compareSubProperties(const QRect & r1, const QRect & r2) @@ -360,7 +361,8 @@ unsigned compareSubProperties(const QVariant & q1, const QVariant & q2, qdesigne } // Apply the sub property if mask flag is set in mask -#define SET_SUBPROPERTY(rc, newValue, getter, setter, mask, maskFlag) if (mask & maskFlag) rc.setter(newValue.getter()); +#define SET_SUBPROPERTY(rc, newValue, getter, setter, mask, maskFlag) \ + if ((mask) & (maskFlag)) rc.setter((newValue).getter()); // apply changed subproperties to a rectangle QRect applyRectSubProperty(const QRect &oldValue, const QRect &newValue, unsigned mask) diff --git a/src/designer/src/lib/shared/qlayout_widget.cpp b/src/designer/src/lib/shared/qlayout_widget.cpp index 2cfa7e513..60abbd72a 100644 --- a/src/designer/src/lib/shared/qlayout_widget.cpp +++ b/src/designer/src/lib/shared/qlayout_widget.cpp @@ -701,7 +701,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const void GridLayoutState::applyToLayout(const QDesignerFormEditorInterface *core, QWidget *w) const { - typedef QMap<QLayoutItem *, QRect> LayoutItemRectMap; + typedef QHash<QLayoutItem *, QRect> LayoutItemRectMap; QGridLayout *grid = qobject_cast<QGridLayout *>(LayoutInfo::managedLayout(core, w)); Q_ASSERT(grid); if (debugLayout) diff --git a/src/designer/src/lib/shared/selectsignaldialog.cpp b/src/designer/src/lib/shared/selectsignaldialog.cpp index 2c0d2d46c..884ddb4d6 100644 --- a/src/designer/src/lib/shared/selectsignaldialog.cpp +++ b/src/designer/src/lib/shared/selectsignaldialog.cpp @@ -143,7 +143,8 @@ static inline QString msgNoSignals() return QCoreApplication::translate("QDesignerTaskMenu", "no signals available"); } -void SelectSignalDialog::populate(QDesignerFormEditorInterface *core, QObject *object, QString defaultSignal) +void SelectSignalDialog::populate(QDesignerFormEditorInterface *core, QObject *object, + const QString &defaultSignal) { m_okButton->setEnabled(false); diff --git a/src/designer/src/lib/shared/selectsignaldialog_p.h b/src/designer/src/lib/shared/selectsignaldialog_p.h index 47cf8e862..6d2a0d1ac 100644 --- a/src/designer/src/lib/shared/selectsignaldialog_p.h +++ b/src/designer/src/lib/shared/selectsignaldialog_p.h @@ -73,7 +73,8 @@ public: Method selectedMethod() const; - void populate(QDesignerFormEditorInterface *core, QObject *object, QString defaultSignal); + void populate(QDesignerFormEditorInterface *core, QObject *object, + const QString &defaultSignal); private slots: void currentChanged(const QModelIndex &, const QModelIndex &); diff --git a/src/designer/src/lib/uilib/abstractformbuilder.cpp b/src/designer/src/lib/uilib/abstractformbuilder.cpp index 004992511..04e1ebe39 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/src/designer/src/lib/uilib/abstractformbuilder.cpp @@ -995,7 +995,7 @@ DomColorGroup *QAbstractFormBuilder::saveColorGroup(const QPalette &palette) const uint mask = palette.resolve(); for (int role = QPalette::WindowText; role < QPalette::NColorRoles; ++role) { if (mask & (1 << role)) { - QBrush br = palette.brush(QPalette::ColorRole(role)); + const QBrush &br = palette.brush(QPalette::ColorRole(role)); DomColorRole *colorRole = new DomColorRole(); colorRole->setElementBrush(saveBrush(br)); @@ -1112,20 +1112,20 @@ DomBrush *QAbstractFormBuilder::saveBrush(const QBrush &br) } gradient->setElementGradientStop(stops); if (type == QGradient::LinearGradient) { - const QLinearGradient *lgr = (const QLinearGradient *)(gr); + auto lgr = static_cast<const QLinearGradient *>(gr); gradient->setAttributeStartX(lgr->start().x()); gradient->setAttributeStartY(lgr->start().y()); gradient->setAttributeEndX(lgr->finalStop().x()); gradient->setAttributeEndY(lgr->finalStop().y()); } else if (type == QGradient::RadialGradient) { - const QRadialGradient *rgr = (const QRadialGradient *)(gr); + auto rgr = static_cast<const QRadialGradient *>(gr); gradient->setAttributeCentralX(rgr->center().x()); gradient->setAttributeCentralY(rgr->center().y()); gradient->setAttributeFocalX(rgr->focalPoint().x()); gradient->setAttributeFocalY(rgr->focalPoint().y()); gradient->setAttributeRadius(rgr->radius()); } else if (type == QGradient::ConicalGradient) { - const QConicalGradient *cgr = (const QConicalGradient *)(gr); + auto cgr = static_cast<const QConicalGradient *>(gr); gradient->setAttributeCentralX(cgr->center().x()); gradient->setAttributeCentralY(cgr->center().y()); gradient->setAttributeAngle(cgr->angle()); @@ -1140,7 +1140,7 @@ DomBrush *QAbstractFormBuilder::saveBrush(const QBrush &br) brush->setElementTexture(p); } } else { - QColor c = br.color(); + const QColor &c = br.color(); DomColor *color = new DomColor(); color->setElementRed(c.red()); color->setElementGreen(c.green()); |