aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickicon.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-05-09 16:44:08 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-05-10 16:19:57 +0000
commit6c2a24a4f2695ae5565b9a5a42b04c9b68833866 (patch)
tree5373f36a6d5c54ce6c2caf386113142ed5e9fa89 /src/quicktemplates2/qquickicon.cpp
parent9947c815ea54c781bc1a9c95e26e2af1e6eebb87 (diff)
Make QQuickIcon a value type
QQuickIcon no longer inherits QObject, but becomes a light-weight implicitly shared Q_GADGET-type, that is passed by value the same way fonts and colors are. Before: SUB: OS: Fedora 25 (Workstation Edition) SUB: QPA: xcb SUB: GL_VENDOR: Intel Open Source Technology Center SUB: GL_RENDERER: Mesa DRI Intel(R) Haswell Desktop SUB: GL_VERSION: 3.0 Mesa 13.0.4 SUB: running: benchmarks/auto/creation/controls/delegates_buttoncontrol2.qml SUB: 110 frames SUB: 109 frames SUB: 109 frames SUB: 109 frames SUB: 109 frames SUB: Average: SUB: 109.2 frames; using samples; MedianAll=109; StdDev=0.447214, CoV=0.00409536 After: [...] SUB: running: benchmarks/auto/creation/controls/delegates_buttoncontrol2.qml SUB: 123 frames SUB: 124 frames SUB: 124 frames SUB: 122 frames SUB: 125 frames SUB: Average: SUB: 123.6 frames; using samples; MedianAll=124; StdDev=1.14018, CoV=0.00922472 Change-Id: I604532204fb94fc0726d0c9b8b6097f9ebc265e8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickicon.cpp')
-rw-r--r--src/quicktemplates2/qquickicon.cpp75
1 files changed, 38 insertions, 37 deletions
diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp
index 38d0b2af..0b0127d3 100644
--- a/src/quicktemplates2/qquickicon.cpp
+++ b/src/quicktemplates2/qquickicon.cpp
@@ -34,15 +34,12 @@
**
****************************************************************************/
-#include <QtCore/private/qobject_p.h>
#include "qquickicon_p.h"
QT_BEGIN_NAMESPACE
-class QQuickIconPrivate : public QObjectPrivate
+class QQuickIconPrivate : public QSharedData
{
- Q_DECLARE_PUBLIC(QQuickIcon)
-
public:
QQuickIconPrivate()
: width(0),
@@ -58,94 +55,98 @@ public:
QColor color;
};
-QQuickIcon::QQuickIcon(QObject *parent)
- : QObject(*(new QQuickIconPrivate), parent)
+QQuickIcon::QQuickIcon()
+ : d(new QQuickIconPrivate)
+{
+}
+
+QQuickIcon::QQuickIcon(const QQuickIcon &other)
+ : d(other.d)
+{
+}
+
+QQuickIcon::~QQuickIcon()
+{
+}
+
+QQuickIcon &QQuickIcon::operator=(const QQuickIcon &other)
+{
+ d = other.d;
+ return *this;
+}
+
+bool QQuickIcon::operator==(const QQuickIcon &other) const
+{
+ return d == other.d || (d->name == other.d->name
+ && d->source == other.d->source
+ && d->width == other.d->width
+ && d->height == other.d->height
+ && d->color == other.d->color);
+}
+
+bool QQuickIcon::operator!=(const QQuickIcon &other) const
+{
+ return !(*this == other);
+}
+
+bool QQuickIcon::isEmpty() const
{
+ return d->name.isEmpty() && d->source.isEmpty();
}
QString QQuickIcon::name() const
{
- Q_D(const QQuickIcon);
return d->name;
}
void QQuickIcon::setName(const QString &name)
{
- Q_D(QQuickIcon);
- if (name == d->name)
- return;
-
d->name = name;
- emit nameChanged(name);
}
QUrl QQuickIcon::source() const
{
- Q_D(const QQuickIcon);
return d->source;
}
void QQuickIcon::setSource(const QUrl &source)
{
- Q_D(QQuickIcon);
- if (source == d->source)
- return;
-
d->source = source;
- emit sourceChanged(source);
}
int QQuickIcon::width() const
{
- Q_D(const QQuickIcon);
return d->width;
}
void QQuickIcon::setWidth(int width)
{
- Q_D(QQuickIcon);
- if (width == d->width)
- return;
-
d->width = width;
- emit widthChanged(width);
}
int QQuickIcon::height() const
{
- Q_D(const QQuickIcon);
return d->height;
}
void QQuickIcon::setHeight(int height)
{
- Q_D(QQuickIcon);
- if (height == d->height)
- return;
-
d->height = height;
- emit heightChanged(height);
}
QColor QQuickIcon::color() const
{
- Q_D(const QQuickIcon);
return d->color;
}
void QQuickIcon::setColor(const QColor &color)
{
- Q_D(QQuickIcon);
- if (color == d->color)
- return;
-
d->color = color;
- emit colorChanged(color);
}
void QQuickIcon::resetColor()
{
- setColor(Qt::transparent);
+ d->color = Qt::transparent;
}
QT_END_NAMESPACE