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; diff --git a/declarativeimports/core/datasource.cpp b/declarativeimports/core/datasource.cpp index 0cd5a73b7..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())); } @@ -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); @@ -145,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); } } @@ -157,12 +160,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); + } } } 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) } diff --git a/scriptengines/javascript/plasmoid/appletinterface.cpp b/scriptengines/javascript/plasmoid/appletinterface.cpp index 588f03f10..f712d220d 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(newStatus(Plasma::ItemStatus)), this, SIGNAL(statusChanged())); } AppletInterface::~AppletInterface() @@ -383,6 +384,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..9f9181515 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) @@ -128,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, @@ -220,6 +230,7 @@ enum IntervalAlignment { AlignToMinute, AlignToHour }; + //------------------------------------------------------------------- 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(); protected: AbstractJsAppletScript *m_appletScriptEngine;