From 273f5bfe1369f8857e6fed2bf558353a323ac356 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 12 Apr 2011 22:12:17 +0200 Subject: [PATCH 01/10] minor ws clean --- declarativeimports/core/datasource_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/declarativeimports/core/datasource_p.h b/declarativeimports/core/datasource_p.h index 2d2cb137d..f61a5689d 100644 --- a/declarativeimports/core/datasource_p.h +++ b/declarativeimports/core/datasource_p.h @@ -108,7 +108,7 @@ private: QStringList m_oldSources; QStringList m_newSources; Changes m_changes; - QHash m_services; + QHash m_services; }; Q_DECLARE_OPERATORS_FOR_FLAGS(DataSource::Changes) } From 3a72217fe306edb5326f45805070e093c5e5bdcd Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 12 Apr 2011 22:12:48 +0200 Subject: [PATCH 02/10] delete service objects --- declarativeimports/core/datasource.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/declarativeimports/core/datasource.cpp b/declarativeimports/core/datasource.cpp index 0cd5a73b7..a8d0ebf11 100644 --- a/declarativeimports/core/datasource.cpp +++ b/declarativeimports/core/datasource.cpp @@ -96,7 +96,8 @@ void DataSource::setupData() m_dataEngine->disconnectSource(source, this); } } - //FIXME: delete all? + + qDeleteAll(m_services); m_services.clear(); m_dataEngine = dataEngine(m_engine); @@ -157,12 +158,17 @@ void DataSource::removeSource(const QString &source) emit sourceDisconnected(source); emit connectedSourcesChanged(); } + if (m_dataEngine) { m_connectedSources.removeAll(source); m_newSources.removeAll(source); m_oldSources.removeAll(source); - //TODO: delete it? - m_services.remove(source); + + QHash::iterator it = m_services.find(source); + if (it != m_services.end()) { + delete it.value(); + m_services.erase(it); + } } } From 85bfb715ee452c6808eaaa3e3e86b16647ae1cad Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 12 Apr 2011 22:12:53 +0200 Subject: [PATCH 03/10] disconnect sources we get data for but don't have a connected vis to --- declarativeimports/core/datasource.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/declarativeimports/core/datasource.cpp b/declarativeimports/core/datasource.cpp index a8d0ebf11..eee2a9eb2 100644 --- a/declarativeimports/core/datasource.cpp +++ b/declarativeimports/core/datasource.cpp @@ -146,6 +146,8 @@ void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine emit dataChanged(); emit newData(sourceName, data); + } else if (m_dataEngine) { + m_dataEngine->disconnectSource(sourceName, this); } } From ef1ff5403eb8eb4a77adb2b179ee7f3e30380127 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 14 Apr 2011 16:35:38 +0200 Subject: [PATCH 04/10] FEATURE:bind Applet::status() --- .../javascript/plasmoid/appletinterface.cpp | 10 ++++++++++ .../javascript/plasmoid/appletinterface.h | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/scriptengines/javascript/plasmoid/appletinterface.cpp b/scriptengines/javascript/plasmoid/appletinterface.cpp index 588f03f10..239aeea9a 100644 --- a/scriptengines/javascript/plasmoid/appletinterface.cpp +++ b/scriptengines/javascript/plasmoid/appletinterface.cpp @@ -383,6 +383,16 @@ QString AppletInterface::associatedApplication() const return applet()->associatedApplication(); } +void AppletInterface::setStatus(const AppletInterface::ItemStatus &status) +{ + applet()->setStatus((Plasma::ItemStatus)status); +} + +AppletInterface::ItemStatus AppletInterface::status() const +{ + return (AppletInterface::ItemStatus)((int)(applet()->status())); +} + void AppletInterface::gc() { QTimer::singleShot(0, m_appletScriptEngine, SLOT(collectGarbage())); diff --git a/scriptengines/javascript/plasmoid/appletinterface.h b/scriptengines/javascript/plasmoid/appletinterface.h index 5d80ec117..aee42f99d 100644 --- a/scriptengines/javascript/plasmoid/appletinterface.h +++ b/scriptengines/javascript/plasmoid/appletinterface.h @@ -64,6 +64,7 @@ class AppletInterface : public QObject Q_ENUMS(AnimationDirection) Q_ENUMS(IntervalAlignment) Q_ENUMS(ThemeColors) + Q_ENUMS(ItemStatus) Q_PROPERTY(AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode) Q_PROPERTY(FormFactor formFactor READ formFactor NOTIFY formFactorChanged) Q_PROPERTY(Location location READ location NOTIFY locationChanged) @@ -75,6 +76,7 @@ class AppletInterface : public QObject Q_PROPERTY(bool immutable READ immutable NOTIFY immutableChanged) Q_PROPERTY(bool userConfiguring READ userConfiguring) // @since 4.5 Q_PROPERTY(int apiVersion READ apiVersion CONSTANT) + Q_PROPERTY(ItemStatus status READ status WRITE setStatus NOTIFY statusChanged) Q_PROPERTY(QRectF rect READ rect) Q_PROPERTY(QSizeF size READ size) Q_PROPERTY(QString associatedApplication WRITE setAssociatedApplication READ associatedApplication) @@ -220,6 +222,15 @@ enum IntervalAlignment { AlignToMinute, AlignToHour }; + +enum ItemStatus { + UnknownStatus = 0, /**< The status is unknown **/ + PassiveStatus = 1, /**< The Item is passive **/ + ActiveStatus = 2, /**< The Item is active **/ + NeedsAttentionStatus = 3, /**< The Item needs attention **/ + AcceptingInputStatus = 4 /**< The Item is accepting input **/ +}; + //------------------------------------------------------------------- Q_INVOKABLE void gc(); @@ -289,6 +300,9 @@ enum IntervalAlignment { void setAssociatedApplication(const QString &string); QString associatedApplication() const; + void setStatus(const ItemStatus &status); + ItemStatus status() const; + Q_SIGNALS: void releaseVisualFocus(); void configNeedsSaving(); @@ -297,6 +311,7 @@ Q_SIGNALS: void locationChanged(); void contextChanged(); void immutableChanged(); + void statusChanged(ItemStatus status); protected: AbstractJsAppletScript *m_appletScriptEngine; From 2fc39865e3afee5a04a04b51eaf10ad5246ac471 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 14 Apr 2011 16:46:13 +0200 Subject: [PATCH 05/10] forward the statusChanged() signal --- scriptengines/javascript/plasmoid/appletinterface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/scriptengines/javascript/plasmoid/appletinterface.cpp b/scriptengines/javascript/plasmoid/appletinterface.cpp index 239aeea9a..402686035 100644 --- a/scriptengines/javascript/plasmoid/appletinterface.cpp +++ b/scriptengines/javascript/plasmoid/appletinterface.cpp @@ -48,6 +48,7 @@ AppletInterface::AppletInterface(AbstractJsAppletScript *parent) connect(this, SIGNAL(releaseVisualFocus()), applet(), SIGNAL(releaseVisualFocus())); connect(this, SIGNAL(configNeedsSaving()), applet(), SIGNAL(configNeedsSaving())); connect(applet(), SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, SIGNAL(immutableChanged())); + connect(applet(), SIGNAL(statusChanged(Plasma::ItemStatus)), this, SIGNAL(statusChanged(ItemStatus))); } AppletInterface::~AppletInterface() From 06f753173a0288292d6e500fb9444304d1792932 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 14 Apr 2011 17:08:11 +0200 Subject: [PATCH 06/10] n Applet the signal is newStatus --- scriptengines/javascript/plasmoid/appletinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scriptengines/javascript/plasmoid/appletinterface.cpp b/scriptengines/javascript/plasmoid/appletinterface.cpp index 402686035..882b24dd5 100644 --- a/scriptengines/javascript/plasmoid/appletinterface.cpp +++ b/scriptengines/javascript/plasmoid/appletinterface.cpp @@ -48,7 +48,7 @@ AppletInterface::AppletInterface(AbstractJsAppletScript *parent) connect(this, SIGNAL(releaseVisualFocus()), applet(), SIGNAL(releaseVisualFocus())); connect(this, SIGNAL(configNeedsSaving()), applet(), SIGNAL(configNeedsSaving())); connect(applet(), SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, SIGNAL(immutableChanged())); - connect(applet(), SIGNAL(statusChanged(Plasma::ItemStatus)), this, SIGNAL(statusChanged(ItemStatus))); + connect(applet(), SIGNAL(newStatus(Plasma::ItemStatus)), this, SIGNAL(statusChanged(ItemStatus))); } AppletInterface::~AppletInterface() From 469f2076dd56b799cdec0da6a4d9e1a689c2879f Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 14 Apr 2011 19:50:57 +0200 Subject: [PATCH 07/10] reorder together the other Plasma enums --- .../javascript/plasmoid/appletinterface.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scriptengines/javascript/plasmoid/appletinterface.h b/scriptengines/javascript/plasmoid/appletinterface.h index aee42f99d..66db892a2 100644 --- a/scriptengines/javascript/plasmoid/appletinterface.h +++ b/scriptengines/javascript/plasmoid/appletinterface.h @@ -130,6 +130,14 @@ enum AspectRatioMode { FixedSize = 4 /** The applet cannot be resized */ }; +enum ItemStatus { + UnknownStatus = 0, /**< The status is unknown **/ + PassiveStatus = 1, /**< The Item is passive **/ + ActiveStatus = 2, /**< The Item is active **/ + NeedsAttentionStatus = 3, /**< The Item needs attention **/ + AcceptingInputStatus = 4 /**< The Item is accepting input **/ +}; + //From Qt namespace enum QtModifiers { QtNoModifier = Qt::NoModifier, @@ -223,14 +231,6 @@ enum IntervalAlignment { AlignToHour }; -enum ItemStatus { - UnknownStatus = 0, /**< The status is unknown **/ - PassiveStatus = 1, /**< The Item is passive **/ - ActiveStatus = 2, /**< The Item is active **/ - NeedsAttentionStatus = 3, /**< The Item needs attention **/ - AcceptingInputStatus = 4 /**< The Item is accepting input **/ -}; - //------------------------------------------------------------------- Q_INVOKABLE void gc(); From 388d61203f01a3c96fe9641fa361299743866384 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 14 Apr 2011 22:49:13 +0200 Subject: [PATCH 08/10] compatible signature in connect --- scriptengines/javascript/plasmoid/appletinterface.cpp | 2 +- scriptengines/javascript/plasmoid/appletinterface.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scriptengines/javascript/plasmoid/appletinterface.cpp b/scriptengines/javascript/plasmoid/appletinterface.cpp index 882b24dd5..f712d220d 100644 --- a/scriptengines/javascript/plasmoid/appletinterface.cpp +++ b/scriptengines/javascript/plasmoid/appletinterface.cpp @@ -48,7 +48,7 @@ AppletInterface::AppletInterface(AbstractJsAppletScript *parent) connect(this, SIGNAL(releaseVisualFocus()), applet(), SIGNAL(releaseVisualFocus())); connect(this, SIGNAL(configNeedsSaving()), applet(), SIGNAL(configNeedsSaving())); connect(applet(), SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, SIGNAL(immutableChanged())); - connect(applet(), SIGNAL(newStatus(Plasma::ItemStatus)), this, SIGNAL(statusChanged(ItemStatus))); + connect(applet(), SIGNAL(newStatus(Plasma::ItemStatus)), this, SIGNAL(statusChanged())); } AppletInterface::~AppletInterface() diff --git a/scriptengines/javascript/plasmoid/appletinterface.h b/scriptengines/javascript/plasmoid/appletinterface.h index 66db892a2..9f9181515 100644 --- a/scriptengines/javascript/plasmoid/appletinterface.h +++ b/scriptengines/javascript/plasmoid/appletinterface.h @@ -311,7 +311,7 @@ Q_SIGNALS: void locationChanged(); void contextChanged(); void immutableChanged(); - void statusChanged(ItemStatus status); + void statusChanged(); protected: AbstractJsAppletScript *m_appletScriptEngine; From 96fdce66c1648a85e493ddb869b30e4b00056f2e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sun, 17 Apr 2011 20:01:45 +0200 Subject: [PATCH 09/10] make connection to connectedSourcesChanged queued Changing to Qt::QueuedConnection delays setupData(). this makes the dataChanged() signal arrive to qml only when the full batch of setData has been done. this in turn doesn't let incomplete data arrive to the model, making an incomplete role mapping. should fix the QML version of Lionmail CCMAIL:sebas@kde.org --- declarativeimports/core/datasource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/declarativeimports/core/datasource.cpp b/declarativeimports/core/datasource.cpp index eee2a9eb2..9d5a914f6 100644 --- a/declarativeimports/core/datasource.cpp +++ b/declarativeimports/core/datasource.cpp @@ -40,7 +40,7 @@ DataSource::DataSource(QObject* parent) connect(this, SIGNAL(engineChanged()), this, SLOT(setupData())); connect(this, SIGNAL(connectedSourcesChanged()), - this, SLOT(setupData())); + this, SLOT(setupData()), Qt::QueuedConnection); connect(this, SIGNAL(intervalChanged()), this, SLOT(setupData())); } From 2abb2956955d19bb02ed4618f6051263d07c984f Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sun, 17 Apr 2011 20:46:36 +0200 Subject: [PATCH 10/10] revert old deferred role update hack --- declarativeimports/core/datamodel.cpp | 10 ---------- declarativeimports/core/datamodel.h | 2 -- 2 files changed, 12 deletions(-) diff --git a/declarativeimports/core/datamodel.cpp b/declarativeimports/core/datamodel.cpp index d5922b557..14d7f1fad 100644 --- a/declarativeimports/core/datamodel.cpp +++ b/declarativeimports/core/datamodel.cpp @@ -142,11 +142,6 @@ DataModel::DataModel(QObject* parent) this, SIGNAL(countChanged())); connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged())); - - m_roleNamesTimer = new QTimer(this); - m_roleNamesTimer->setSingleShot(true); - connect(m_roleNamesTimer, SIGNAL(timeout()), - this, SLOT(syncRoleNames())); } DataModel::~DataModel() @@ -285,11 +280,6 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list) setRoleNames(m_roleNames); } - m_roleNamesTimer->start(0); -} - -void DataModel::syncRoleNames() -{ setRoleNames(m_roleNames); //make the declarative view reload everything, diff --git a/declarativeimports/core/datamodel.h b/declarativeimports/core/datamodel.h index bf17190b7..e74ffd5b7 100644 --- a/declarativeimports/core/datamodel.h +++ b/declarativeimports/core/datamodel.h @@ -137,13 +137,11 @@ Q_SIGNALS: private Q_SLOTS: void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data); void removeSource(const QString &sourceName); - void syncRoleNames(); private: DataSource *m_dataSource; QString m_keyRoleFilter; QString m_sourceFilter; - QTimer *m_roleNamesTimer; QMap > m_items; QHash m_roleNames; QHash m_roleIds;