summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-11-29 17:02:53 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-12-06 13:19:01 +0100
commitb89284922538eb5c912519469479ec02d2864e6c (patch)
treea2a6e5ad4d4bd7a94b922e99486b4a543a440dfb
parent3548d4f932020aa0b9c995c34cf2423d414b0264 (diff)
Qt Designer: Use new comparison helpers for equality
Task-number: QTBUG-103757 Change-Id: I4b7c55e10c6fa2b09b1e6a0db9570022119f4ddc Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
-rw-r--r--src/designer/src/components/formeditor/formwindowsettings.cpp38
-rw-r--r--src/designer/src/components/objectinspector/objectinspectormodel_p.h10
-rw-r--r--src/designer/src/designer/qdesigner_appearanceoptions.cpp5
-rw-r--r--src/designer/src/designer/qdesigner_appearanceoptions.h23
-rw-r--r--src/designer/src/designer/qdesigner_toolwindow.cpp8
-rw-r--r--src/designer/src/designer/qdesigner_toolwindow.h25
-rw-r--r--src/designer/src/lib/shared/deviceprofile.cpp4
-rw-r--r--src/designer/src/lib/shared/deviceprofile_p.h15
-rw-r--r--src/designer/src/lib/shared/grid.cpp8
-rw-r--r--src/designer/src/lib/shared/grid_p.h13
-rw-r--r--src/designer/src/lib/shared/newactiondialog_p.h10
-rw-r--r--src/designer/src/lib/shared/qdesigner_command.cpp29
-rw-r--r--src/designer/src/lib/shared/qdesigner_command_p.h44
-rw-r--r--src/designer/src/lib/shared/qdesigner_utils.cpp24
-rw-r--r--src/designer/src/lib/shared/qdesigner_utils_p.h49
-rw-r--r--src/designer/src/lib/shared/qtresourceeditordialog.cpp37
16 files changed, 176 insertions, 166 deletions
diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp
index 3b64c2f8a..df3fa01c2 100644
--- a/src/designer/src/components/formeditor/formwindowsettings.cpp
+++ b/src/designer/src/components/formeditor/formwindowsettings.cpp
@@ -9,6 +9,7 @@
#include <QtWidgets/qstyle.h>
+#include <QtCore/qcompare.h>
#include <QtCore/qregularexpression.h>
#include <QtCore/qdebug.h>
@@ -22,8 +23,6 @@ namespace qdesigner_internal {
// Data structure containing form dialog data providing comparison
struct FormWindowData {
- bool equals(const FormWindowData&) const;
-
void fromFormWindow(FormWindowBase* fw);
void applyToFormWindow(FormWindowBase* fw) const;
@@ -45,10 +44,11 @@ struct FormWindowData {
Grid grid;
bool idBasedTranslations{false};
bool connectSlotsByName{true};
-};
-inline bool operator==(const FormWindowData &fd1, const FormWindowData &fd2) { return fd1.equals(fd2); }
-inline bool operator!=(const FormWindowData &fd1, const FormWindowData &fd2) { return !fd1.equals(fd2); }
+ friend bool comparesEqual(const FormWindowData &lhs,
+ const FormWindowData &rhs) noexcept;
+ Q_DECLARE_EQUALITY_COMPARABLE(FormWindowData)
+};
QDebug operator<<(QDebug str, const FormWindowData &d)
{
@@ -63,21 +63,21 @@ QDebug operator<<(QDebug str, const FormWindowData &d)
return str;
}
-bool FormWindowData::equals(const FormWindowData &rhs) const
+bool comparesEqual(const FormWindowData &lhs, const FormWindowData &rhs) noexcept
{
- return layoutDefaultEnabled == rhs.layoutDefaultEnabled &&
- defaultMargin == rhs.defaultMargin &&
- defaultSpacing == rhs.defaultSpacing &&
- layoutFunctionsEnabled == rhs.layoutFunctionsEnabled &&
- marginFunction == rhs.marginFunction &&
- spacingFunction == rhs.spacingFunction &&
- pixFunction == rhs.pixFunction &&
- author == rhs.author &&
- includeHints == rhs.includeHints &&
- hasFormGrid == rhs.hasFormGrid &&
- grid == rhs.grid &&
- idBasedTranslations == rhs.idBasedTranslations &&
- connectSlotsByName == rhs.connectSlotsByName;
+ return lhs.layoutDefaultEnabled == rhs.layoutDefaultEnabled &&
+ lhs.defaultMargin == rhs.defaultMargin &&
+ lhs.defaultSpacing == rhs.defaultSpacing &&
+ lhs.layoutFunctionsEnabled == rhs.layoutFunctionsEnabled &&
+ lhs.marginFunction == rhs.marginFunction &&
+ lhs.spacingFunction == rhs.spacingFunction &&
+ lhs.pixFunction == rhs.pixFunction &&
+ lhs.author == rhs.author &&
+ lhs.includeHints == rhs.includeHints &&
+ lhs.hasFormGrid == rhs.hasFormGrid &&
+ lhs.grid == rhs.grid &&
+ lhs.idBasedTranslations == rhs.idBasedTranslations &&
+ lhs.connectSlotsByName == rhs.connectSlotsByName;
}
void FormWindowData::fromFormWindow(FormWindowBase* fw)
diff --git a/src/designer/src/components/objectinspector/objectinspectormodel_p.h b/src/designer/src/components/objectinspector/objectinspectormodel_p.h
index 4a377fc21..5ba4b83d3 100644
--- a/src/designer/src/components/objectinspector/objectinspectormodel_p.h
+++ b/src/designer/src/components/objectinspector/objectinspectormodel_p.h
@@ -19,6 +19,7 @@
#include <QtGui/qstandarditemmodel.h>
#include <QtGui/qicon.h>
+#include <QtCore/qcompare.h>
#include <QtCore/qstring.h>
#include <QtCore/qlist.h>
#include <QtCore/qmap.h>
@@ -74,6 +75,12 @@ namespace qdesigner_internal {
void setItemsDisplayData(const StandardItemList &row, const ObjectInspectorIcons &icons, unsigned mask) const;
private:
+ friend bool comparesEqual(const ObjectData &lhs, const ObjectData &rhs) noexcept
+ {
+ return lhs.m_parent == rhs.m_parent && lhs.m_object == rhs.m_object;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(ObjectData)
+
void initObject(const ModelRecursionContext &ctx);
void initWidget(QWidget *w, const ModelRecursionContext &ctx);
@@ -86,9 +93,6 @@ namespace qdesigner_internal {
LayoutInfo::Type m_managedLayoutType = LayoutInfo::NoLayout;
};
- inline bool operator==(const ObjectData &e1, const ObjectData &e2) { return e1.equals(e2); }
- inline bool operator!=(const ObjectData &e1, const ObjectData &e2) { return !e1.equals(e2); }
-
using ObjectModel = QList<ObjectData>;
// QStandardItemModel for ObjectInspector. Uses ObjectData/ObjectModel
diff --git a/src/designer/src/designer/qdesigner_appearanceoptions.cpp b/src/designer/src/designer/qdesigner_appearanceoptions.cpp
index 0ed239a7d..4c68a4445 100644
--- a/src/designer/src/designer/qdesigner_appearanceoptions.cpp
+++ b/src/designer/src/designer/qdesigner_appearanceoptions.cpp
@@ -14,11 +14,6 @@
QT_BEGIN_NAMESPACE
// ---------------- AppearanceOptions
-bool AppearanceOptions::equals(const AppearanceOptions &rhs) const
-{
- return uiMode == rhs.uiMode && toolWindowFontSettings == rhs.toolWindowFontSettings;
-}
-
void AppearanceOptions::toSettings(QDesignerSettings &settings) const
{
settings.setUiMode(uiMode);
diff --git a/src/designer/src/designer/qdesigner_appearanceoptions.h b/src/designer/src/designer/qdesigner_appearanceoptions.h
index 247cef379..1b37750c6 100644
--- a/src/designer/src/designer/qdesigner_appearanceoptions.h
+++ b/src/designer/src/designer/qdesigner_appearanceoptions.h
@@ -9,6 +9,7 @@
#include <QtDesigner/abstractoptionspage.h>
+#include <QtCore/qcompare.h>
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>
#include <QtWidgets/qwidget.h>
@@ -23,24 +24,22 @@ namespace Ui {
}
/* AppearanceOptions data */
-struct AppearanceOptions {
- bool equals(const AppearanceOptions&) const;
+struct AppearanceOptions
+{
void toSettings(QDesignerSettings &) const;
void fromSettings(const QDesignerSettings &);
UIMode uiMode{DockedMode};
ToolWindowFontSettings toolWindowFontSettings;
-};
-
-inline bool operator==(const AppearanceOptions &ao1, const AppearanceOptions &ao2)
-{
- return ao1.equals(ao2);
-}
-inline bool operator!=(const AppearanceOptions &ao1, const AppearanceOptions &ao2)
-{
- return !ao1.equals(ao2);
-}
+ friend bool comparesEqual(const AppearanceOptions &lhs,
+ const AppearanceOptions &rhs) noexcept
+ {
+ return lhs.uiMode == rhs.uiMode
+ && lhs.toolWindowFontSettings == rhs.toolWindowFontSettings;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(AppearanceOptions)
+};
/* QDesignerAppearanceOptionsWidget: Let the user edit AppearanceOptions */
class QDesignerAppearanceOptionsWidget : public QWidget
diff --git a/src/designer/src/designer/qdesigner_toolwindow.cpp b/src/designer/src/designer/qdesigner_toolwindow.cpp
index dc65a8f46..9b63423aa 100644
--- a/src/designer/src/designer/qdesigner_toolwindow.cpp
+++ b/src/designer/src/designer/qdesigner_toolwindow.cpp
@@ -24,14 +24,6 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
-// ---------------- QDesignerToolWindowFontSettings
-bool ToolWindowFontSettings::equals(const ToolWindowFontSettings &rhs) const
-{
- return m_useFont == rhs.m_useFont &&
- m_writingSystem == rhs.m_writingSystem &&
- m_font == rhs.m_font;
-}
-
// ---------------- QDesignerToolWindow
QDesignerToolWindow::QDesignerToolWindow(QDesignerWorkbench *workbench,
QWidget *w,
diff --git a/src/designer/src/designer/qdesigner_toolwindow.h b/src/designer/src/designer/qdesigner_toolwindow.h
index 07424c544..1ba732d00 100644
--- a/src/designer/src/designer/qdesigner_toolwindow.h
+++ b/src/designer/src/designer/qdesigner_toolwindow.h
@@ -6,29 +6,28 @@
#include "mainwindow.h"
+#include <QtCore/qcompare.h>
#include <QtCore/qpointer.h>
#include <QtGui/qfontdatabase.h>
#include <QtWidgets/qmainwindow.h>
QT_BEGIN_NAMESPACE
-struct ToolWindowFontSettings {
- bool equals(const ToolWindowFontSettings &) const;
-
+struct ToolWindowFontSettings
+{
QFont m_font;
QFontDatabase::WritingSystem m_writingSystem{QFontDatabase::Any};
bool m_useFont{false};
-};
-inline bool operator==(const ToolWindowFontSettings &tw1, const ToolWindowFontSettings &tw2)
-{
- return tw1.equals(tw2);
-}
-
-inline bool operator!=(const ToolWindowFontSettings &tw1, const ToolWindowFontSettings &tw2)
-{
- return !tw1.equals(tw2);
-}
+ friend bool comparesEqual(const ToolWindowFontSettings &lhs,
+ const ToolWindowFontSettings &rhs) noexcept
+ {
+ return lhs.m_useFont == rhs.m_useFont
+ && lhs.m_writingSystem == rhs.m_writingSystem
+ && lhs.m_font == rhs.m_font;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(ToolWindowFontSettings)
+};
class QDesignerWorkbench;
diff --git a/src/designer/src/lib/shared/deviceprofile.cpp b/src/designer/src/lib/shared/deviceprofile.cpp
index 42fa9cdec..e5fdc8570 100644
--- a/src/designer/src/lib/shared/deviceprofile.cpp
+++ b/src/designer/src/lib/shared/deviceprofile.cpp
@@ -261,9 +261,9 @@ void DeviceProfile::apply(const QDesignerFormEditorInterface *core, QWidget *wid
}
}
-bool DeviceProfile::equals(const DeviceProfile& rhs) const
+bool comparesEqual(const DeviceProfile &lhs, const DeviceProfile &rhs) noexcept
{
- const DeviceProfileData &d = *m_d;
+ const DeviceProfileData &d = *lhs.m_d;
const DeviceProfileData &rhs_d = *rhs.m_d;
return d.m_fontPointSize == rhs_d.m_fontPointSize &&
d.m_dpiX == rhs_d.m_dpiX && d.m_dpiY == rhs_d.m_dpiY && d.m_fontFamily == rhs_d.m_fontFamily &&
diff --git a/src/designer/src/lib/shared/deviceprofile_p.h b/src/designer/src/lib/shared/deviceprofile_p.h
index 9d74b4a07..273a1a1a2 100644
--- a/src/designer/src/lib/shared/deviceprofile_p.h
+++ b/src/designer/src/lib/shared/deviceprofile_p.h
@@ -17,6 +17,7 @@
#include "shared_global_p.h"
+#include <QtCore/qcompare.h>
#include <QtCore/qstring.h>
#include <QtCore/qshareddata.h>
@@ -76,8 +77,6 @@ public:
static void systemResolution(int *dpiX, int *dpiY);
static void widgetResolution(const QWidget *w, int *dpiX, int *dpiY);
- bool equals(const DeviceProfile& rhs) const;
-
// Apply to form/preview (using font inheritance)
enum ApplyMode {
/* Pre-Apply to parent widget of form being edited: Apply font
@@ -98,16 +97,14 @@ public:
bool fromXml(const QString &xml, QString *errorMessage);
private:
+ friend QDESIGNER_SHARED_EXPORT bool comparesEqual(const DeviceProfile &lhs,
+ const DeviceProfile &rhs) noexcept;
+ Q_DECLARE_EQUALITY_COMPARABLE(DeviceProfile)
+
QSharedDataPointer<DeviceProfileData> m_d;
};
-inline bool operator==(const DeviceProfile &s1, const DeviceProfile &s2)
- { return s1.equals(s2); }
-inline bool operator!=(const DeviceProfile &s1, const DeviceProfile &s2)
- { return !s1.equals(s2); }
-
-}
-
+} // namespace qdesigner_internal
QT_END_NAMESPACE
diff --git a/src/designer/src/lib/shared/grid.cpp b/src/designer/src/lib/shared/grid.cpp
index 8d8fe8585..f4906a113 100644
--- a/src/designer/src/lib/shared/grid.cpp
+++ b/src/designer/src/lib/shared/grid.cpp
@@ -147,14 +147,6 @@ int Grid::widgetHandleAdjustY(int y) const
return m_snapY ? (y / m_deltaY) * m_deltaY + 1 : y;
}
-bool Grid::equals(const Grid &rhs) const
-{
- return m_visible == rhs.m_visible &&
- m_snapX == rhs.m_snapX &&
- m_snapY == rhs.m_snapY &&
- m_deltaX == rhs.m_deltaX &&
- m_deltaY == rhs.m_deltaY;
-}
}
QT_END_NAMESPACE
diff --git a/src/designer/src/lib/shared/grid_p.h b/src/designer/src/lib/shared/grid_p.h
index 9ff654710..606732884 100644
--- a/src/designer/src/lib/shared/grid_p.h
+++ b/src/designer/src/lib/shared/grid_p.h
@@ -17,6 +17,7 @@
#include "shared_global_p.h"
+#include <QtCore/qcompare.h>
#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE
@@ -61,11 +62,15 @@ public:
int widgetHandleAdjustX(int x) const;
int widgetHandleAdjustY(int y) const;
- inline bool operator==(const Grid &rhs) const { return equals(rhs); }
- inline bool operator!=(const Grid &rhs) const { return !equals(rhs); }
-
private:
- bool equals(const Grid &rhs) const;
+ friend bool comparesEqual(const Grid &lhs, const Grid &rhs) noexcept
+ {
+ return lhs.m_visible == rhs.m_visible
+ && lhs.m_snapX == rhs.m_snapX && lhs.m_snapY == rhs.m_snapY
+ && lhs.m_deltaX == rhs.m_deltaX && lhs.m_deltaY == rhs.m_deltaY;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(Grid)
+
int snapValue(int value, int grid) const;
bool m_visible;
bool m_snapX;
diff --git a/src/designer/src/lib/shared/newactiondialog_p.h b/src/designer/src/lib/shared/newactiondialog_p.h
index 8065c9b39..de42d16f0 100644
--- a/src/designer/src/lib/shared/newactiondialog_p.h
+++ b/src/designer/src/lib/shared/newactiondialog_p.h
@@ -19,6 +19,7 @@
#include <QtWidgets/qdialog.h>
#include <QtGui/qkeysequence.h>
+#include <QtCore/qcompare.h>
QT_BEGIN_NAMESPACE
@@ -48,10 +49,13 @@ struct ActionData {
bool checkable{false};
PropertySheetKeySequenceValue keysequence;
PropertySheetFlagValue menuRole;
-};
-inline bool operator==(const ActionData &a1, const ActionData &a2) { return a1.compare(a2) == 0u; }
-inline bool operator!=(const ActionData &a1, const ActionData &a2) { return a1.compare(a2) != 0u; }
+ friend bool comparesEqual(const ActionData &lhs, const ActionData &rhs) noexcept
+ {
+ return lhs.compare(rhs) == 0;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(ActionData)
+};
class NewActionDialog: public QDialog
{
diff --git a/src/designer/src/lib/shared/qdesigner_command.cpp b/src/designer/src/lib/shared/qdesigner_command.cpp
index c82755d12..04e100394 100644
--- a/src/designer/src/lib/shared/qdesigner_command.cpp
+++ b/src/designer/src/lib/shared/qdesigner_command.cpp
@@ -2391,14 +2391,13 @@ void TableWidgetContents::applyToTableWidget(QTableWidget *tableWidget, Designer
}
}
-bool TableWidgetContents::operator==(const TableWidgetContents &rhs) const
+bool comparesEqual(const TableWidgetContents &lhs,
+ const TableWidgetContents &rhs) noexcept
{
- if (m_columnCount != rhs.m_columnCount || m_rowCount != rhs.m_rowCount)
- return false;
-
- return m_horizontalHeader.m_items == rhs.m_horizontalHeader.m_items &&
- m_verticalHeader.m_items == rhs.m_verticalHeader.m_items &&
- m_items == rhs.m_items;
+ return lhs.m_columnCount == rhs.m_columnCount && lhs.m_rowCount == rhs.m_rowCount &&
+ lhs.m_horizontalHeader.m_items == rhs.m_horizontalHeader.m_items &&
+ lhs.m_verticalHeader.m_items == rhs.m_verticalHeader.m_items &&
+ lhs.m_items == rhs.m_items;
}
// ---- ChangeTableContentsCommand ----
@@ -2468,12 +2467,11 @@ QTreeWidgetItem *TreeWidgetContents::ItemContents::createTreeItem(DesignerIconCa
return item;
}
-bool TreeWidgetContents::ItemContents::operator==(const TreeWidgetContents::ItemContents &rhs) const
+bool comparesEqual(const TreeWidgetContents::ItemContents &lhs,
+ const TreeWidgetContents::ItemContents &rhs) noexcept
{
- return
- m_itemFlags == rhs.m_itemFlags &&
- m_items == rhs.m_items &&
- m_children == rhs.m_children;
+ return lhs.m_itemFlags == rhs.m_itemFlags && lhs.m_items == rhs.m_items
+ && lhs.m_children == rhs.m_children;
}
void TreeWidgetContents::clear()
@@ -2501,13 +2499,6 @@ void TreeWidgetContents::applyToTreeWidget(QTreeWidget *treeWidget, DesignerIcon
treeWidget->expandAll();
}
-bool TreeWidgetContents::operator==(const TreeWidgetContents &rhs) const
-{
- return
- m_headerItem == rhs.m_headerItem &&
- m_rootItems == rhs.m_rootItems;
-}
-
// ---- ChangeTreeContentsCommand ----
ChangeTreeContentsCommand::ChangeTreeContentsCommand(QDesignerFormWindowInterface *formWindow)
: QDesignerFormWindowCommand(QApplication::translate("Command", "Change Tree Contents"), formWindow),
diff --git a/src/designer/src/lib/shared/qdesigner_command_p.h b/src/designer/src/lib/shared/qdesigner_command_p.h
index 19c003946..40520f4b8 100644
--- a/src/designer/src/lib/shared/qdesigner_command_p.h
+++ b/src/designer/src/lib/shared/qdesigner_command_p.h
@@ -26,6 +26,7 @@
#include <QtGui/qicon.h>
+#include <QtCore/qcompare.h>
#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
#include <QtCore/qmap.h>
@@ -827,10 +828,14 @@ struct QDESIGNER_SHARED_EXPORT ItemData {
void fillTreeItemColumn(QTreeWidgetItem *item, int column, DesignerIconCache *iconCache) const;
bool isValid() const { return !m_properties.isEmpty(); }
- bool operator==(const ItemData &rhs) const { return m_properties == rhs.m_properties; }
- bool operator!=(const ItemData &rhs) const { return m_properties != rhs.m_properties; }
QHash<int, QVariant> m_properties;
+
+ friend bool comparesEqual(const ItemData &lhs, const ItemData &rhs) noexcept
+ {
+ return lhs.m_properties == rhs.m_properties;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(ItemData)
};
struct QDESIGNER_SHARED_EXPORT ListContents {
@@ -846,10 +851,13 @@ struct QDESIGNER_SHARED_EXPORT ListContents {
void createFromComboBox(const QComboBox *listWidget);
void applyToComboBox(QComboBox *listWidget, DesignerIconCache *iconCache) const;
- bool operator==(const ListContents &rhs) const { return m_items == rhs.m_items; }
- bool operator!=(const ListContents &rhs) const { return m_items != rhs.m_items; }
-
QList<ItemData> m_items;
+
+ friend bool comparesEqual(const ListContents &lhs, const ListContents &rhs) noexcept
+ {
+ return lhs.m_items == rhs.m_items;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(ListContents)
};
// Data structure representing the contents of a QTableWidget with
@@ -864,9 +872,6 @@ struct QDESIGNER_SHARED_EXPORT TableWidgetContents {
void fromTableWidget(const QTableWidget *tableWidget, bool editor);
void applyToTableWidget(QTableWidget *tableWidget, DesignerIconCache *iconCache, bool editor) const;
- bool operator==(const TableWidgetContents &rhs) const;
- bool operator!=(const TableWidgetContents &rhs) const { return !(*this == rhs); }
-
static bool nonEmpty(const QTableWidgetItem *item, int headerColumn);
static QString defaultHeaderText(int i);
static void insertHeaderItem(const QTableWidgetItem *item, int i, ListContents *header, bool editor);
@@ -876,6 +881,11 @@ struct QDESIGNER_SHARED_EXPORT TableWidgetContents {
ListContents m_horizontalHeader;
ListContents m_verticalHeader;
QMap<CellRowColumnAddress, ItemData> m_items;
+
+ friend QDESIGNER_SHARED_EXPORT
+ bool comparesEqual(const TableWidgetContents &lhs,
+ const TableWidgetContents &rhs) noexcept;
+ Q_DECLARE_EQUALITY_COMPARABLE(TableWidgetContents)
};
class QDESIGNER_SHARED_EXPORT ChangeTableContentsCommand: public QDesignerFormWindowCommand
@@ -903,14 +913,16 @@ struct QDESIGNER_SHARED_EXPORT TreeWidgetContents {
ItemContents(const QTreeWidgetItem *item, bool editor);
QTreeWidgetItem *createTreeItem(DesignerIconCache *iconCache, bool editor) const;
- bool operator==(const ItemContents &rhs) const;
- bool operator!=(const ItemContents &rhs) const { return !(*this == rhs); }
-
int m_itemFlags = -1;
//bool m_firstColumnSpanned:1;
//bool m_hidden:1;
//bool m_expanded:1;
QList<ItemContents> m_children;
+
+ friend QDESIGNER_SHARED_EXPORT
+ bool comparesEqual(const ItemContents &lhs,
+ const ItemContents &rhs) noexcept;
+ Q_DECLARE_EQUALITY_COMPARABLE(ItemContents)
};
void clear();
@@ -918,11 +930,15 @@ struct QDESIGNER_SHARED_EXPORT TreeWidgetContents {
void fromTreeWidget(const QTreeWidget *treeWidget, bool editor);
void applyToTreeWidget(QTreeWidget *treeWidget, DesignerIconCache *iconCache, bool editor) const;
- bool operator==(const TreeWidgetContents &rhs) const;
- bool operator!=(const TreeWidgetContents &rhs) const { return !(*this == rhs); }
-
ListContents m_headerItem;
QList<ItemContents> m_rootItems;
+
+ friend bool comparesEqual(const TreeWidgetContents &lhs,
+ const TreeWidgetContents &rhs) noexcept
+ {
+ return lhs.m_headerItem == rhs.m_headerItem && lhs.m_rootItems == rhs.m_rootItems;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(TreeWidgetContents)
};
class QDESIGNER_SHARED_EXPORT ChangeTreeContentsCommand: public QDesignerFormWindowCommand
diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp
index f22452231..42d2dc97a 100644
--- a/src/designer/src/lib/shared/qdesigner_utils.cpp
+++ b/src/designer/src/lib/shared/qdesigner_utils.cpp
@@ -447,14 +447,6 @@ namespace qdesigner_internal
PropertySheetTranslatableData::PropertySheetTranslatableData(bool translatable, const QString &disambiguation, const QString &comment) :
m_translatable(translatable), m_disambiguation(disambiguation), m_comment(comment) { }
- bool PropertySheetTranslatableData::equals(const PropertySheetTranslatableData &rhs) const
- {
- return m_translatable == rhs.m_translatable
- && m_disambiguation == rhs.m_disambiguation
- && m_comment == rhs.m_comment
- && m_id == rhs.m_id;
- }
-
PropertySheetStringValue::PropertySheetStringValue(const QString &value,
bool translatable, const QString &disambiguation, const QString &comment) :
PropertySheetTranslatableData(translatable, disambiguation, comment), m_value(value) {}
@@ -469,11 +461,6 @@ namespace qdesigner_internal
m_value = value;
}
- bool PropertySheetStringValue::equals(const PropertySheetStringValue &rhs) const
- {
- return m_value == rhs.m_value && PropertySheetTranslatableData::equals(rhs);
- }
-
PropertySheetStringListValue::PropertySheetStringListValue(const QStringList &value,
bool translatable,
const QString &disambiguation,
@@ -492,11 +479,6 @@ namespace qdesigner_internal
m_value = value;
}
- bool PropertySheetStringListValue::equals(const PropertySheetStringListValue &rhs) const
- {
- return m_value == rhs.m_value && PropertySheetTranslatableData::equals(rhs);
- }
-
QStringList m_value;
@@ -537,12 +519,6 @@ namespace qdesigner_internal
return m_standardKey != QKeySequence::UnknownKey;
}
- bool PropertySheetKeySequenceValue::equals(const PropertySheetKeySequenceValue &rhs) const
- {
- return m_value == rhs.m_value && m_standardKey == rhs.m_standardKey
- && PropertySheetTranslatableData::equals(rhs);
- }
-
/* IconSubPropertyMask: Assign each icon sub-property (pixmaps for the
* various states/modes and the theme) a flag bit (see QFont) so that they
* can be handled individually when assigning property values to
diff --git a/src/designer/src/lib/shared/qdesigner_utils_p.h b/src/designer/src/lib/shared/qdesigner_utils_p.h
index 0c1793e5d..a6d172b48 100644
--- a/src/designer/src/lib/shared/qdesigner_utils_p.h
+++ b/src/designer/src/lib/shared/qdesigner_utils_p.h
@@ -19,6 +19,7 @@
#include <QtDesigner/abstractformwindow.h>
+#include <QtCore/qcompare.h>
#include <QtCore/qvariant.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qmap.h>
@@ -302,7 +303,6 @@ protected:
PropertySheetTranslatableData(bool translatable = true,
const QString &disambiguation = QString(),
const QString &comment = QString());
- bool equals(const PropertySheetTranslatableData &rhs) const;
public:
bool translatable() const { return m_translatable; }
@@ -315,6 +315,16 @@ public:
void setId(const QString &id) { m_id = id; }
private:
+ friend bool comparesEqual(const PropertySheetTranslatableData &lhs,
+ const PropertySheetTranslatableData &rhs) noexcept
+ {
+ return lhs.m_translatable == rhs.m_translatable
+ && lhs.m_disambiguation == rhs.m_disambiguation
+ && lhs.m_comment == rhs.m_comment
+ && lhs.m_id == rhs.m_id;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetTranslatableData)
+
bool m_translatable;
QString m_disambiguation;
QString m_comment;
@@ -328,14 +338,18 @@ public:
PropertySheetStringValue(const QString &value = QString(), bool translatable = true,
const QString &disambiguation = QString(), const QString &comment = QString());
- bool operator==(const PropertySheetStringValue &other) const { return equals(other); }
- bool operator!=(const PropertySheetStringValue &other) const { return !equals(other); }
-
QString value() const;
void setValue(const QString &value);
private:
- bool equals(const PropertySheetStringValue &rhs) const;
+ friend bool comparesEqual(const PropertySheetStringValue &lhs,
+ const PropertySheetStringValue &rhs) noexcept
+ {
+ const PropertySheetTranslatableData &upLhs = lhs;
+ const PropertySheetTranslatableData &upRhs = rhs;
+ return lhs.m_value == rhs.m_value && upLhs == upRhs;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetStringValue)
QString m_value;
};
@@ -349,14 +363,18 @@ public:
const QString &disambiguation = QString(),
const QString &comment = QString());
- bool operator==(const PropertySheetStringListValue &other) const { return equals(other); }
- bool operator!=(const PropertySheetStringListValue &other) const { return !equals(other); }
-
QStringList value() const;
void setValue(const QStringList &value);
private:
- bool equals(const PropertySheetStringListValue &rhs) const;
+ friend bool comparesEqual(const PropertySheetStringListValue &lhs,
+ const PropertySheetStringListValue &rhs) noexcept
+ {
+ const PropertySheetTranslatableData &upLhs = lhs;
+ const PropertySheetTranslatableData &upRhs = rhs;
+ return lhs.m_value == rhs.m_value && upLhs == upRhs;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetStringListValue)
QStringList m_value;
};
@@ -374,9 +392,6 @@ public:
const QString &disambiguation = QString(),
const QString &comment = QString());
- bool operator==(const PropertySheetKeySequenceValue &other) const { return equals(other); }
- bool operator!=(const PropertySheetKeySequenceValue &other) const { return !equals(other); }
-
QKeySequence value() const;
void setValue(const QKeySequence &value);
QKeySequence::StandardKey standardKey() const;
@@ -384,7 +399,15 @@ public:
bool isStandardKey() const;
private:
- bool equals(const PropertySheetKeySequenceValue &rhs) const;
+ friend bool comparesEqual(const PropertySheetKeySequenceValue &lhs,
+ const PropertySheetKeySequenceValue &rhs) noexcept
+ {
+ const PropertySheetTranslatableData &upLhs = lhs;
+ const PropertySheetTranslatableData &upRhs = rhs;
+ return lhs.m_value == rhs.m_value && lhs.m_standardKey == rhs.m_standardKey
+ && upLhs == upRhs;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetKeySequenceValue)
QKeySequence m_value;
QKeySequence::StandardKey m_standardKey;
diff --git a/src/designer/src/lib/shared/qtresourceeditordialog.cpp b/src/designer/src/lib/shared/qtresourceeditordialog.cpp
index 836e49e57..d0ac616f4 100644
--- a/src/designer/src/lib/shared/qtresourceeditordialog.cpp
+++ b/src/designer/src/lib/shared/qtresourceeditordialog.cpp
@@ -11,6 +11,7 @@
#include <QtDesigner/abstractsettings.h>
#include <QtDesigner/abstractformeditor.h>
+#include <QtCore/qcompare.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
#include <QtCore/qcoreapplication.h>
@@ -49,29 +50,45 @@ static QString msgTagMismatch(const QString &got, const QString &expected)
namespace qdesigner_internal {
// below 3 data classes should be derived from QSharedData and made implicit shared class
-struct QtResourceFileData {
+struct QtResourceFileData
+{
QString path;
QString alias;
- bool operator==(const QtResourceFileData &other) const
- { return path == other.path && alias == other.alias; }
+
+ friend bool comparesEqual(const QtResourceFileData &lhs,
+ const QtResourceFileData &rhs) noexcept
+ {
+ return lhs.path == rhs.path && lhs.alias == rhs.alias;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(QtResourceFileData)
};
-struct QtResourcePrefixData {
+struct QtResourcePrefixData
+{
QString prefix;
QString language;
QList<QtResourceFileData> resourceFileList;
- bool operator==(const QtResourcePrefixData &other) const
+
+ friend bool comparesEqual(const QtResourcePrefixData &lhs,
+ const QtResourcePrefixData &rhs) noexcept
{
- return prefix == other.prefix && language == other.language
- && resourceFileList == other.resourceFileList;
+ return lhs.prefix == rhs.prefix && lhs.language == rhs.language
+ && lhs.resourceFileList == rhs.resourceFileList;
}
+ Q_DECLARE_EQUALITY_COMPARABLE(QtResourcePrefixData)
};
-struct QtQrcFileData {
+struct QtQrcFileData
+{
QString qrcPath;
QList<QtResourcePrefixData> resourceList;
- bool operator==(const QtQrcFileData &other) const
- { return qrcPath == other.qrcPath && resourceList == other.resourceList; }
+
+ friend bool comparesEqual(const QtQrcFileData &lhs,
+ const QtQrcFileData &rhs) noexcept
+ {
+ return lhs.qrcPath == rhs.qrcPath && lhs.resourceList == rhs.resourceList;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(QtQrcFileData)
};
} // namespace qdesigner_internal