[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/shells/common
From:       Marco Martin <notmart () gmail ! com>
Date:       2008-12-27 11:33:53
Message-ID: 1230377633.145613.14414.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 902023 by mart:

actually save/update/restore the "widget used before" list
to not pollute the list, all are saved to disk running and not running,
but only the ones no longer running are shown to the user
BUG:172535


 M  +34 -1     plasmaappletitemmodel.cpp  
 M  +2 -0      plasmaappletitemmodel_p.h  


--- trunk/KDE/kdebase/workspace/plasma/shells/common/plasmaappletitemmodel.cpp #902022:902023
@@ -60,6 +60,11 @@
     return data().toMap()["runningCount"].toInt();
 }
 
+bool PlasmaAppletItem::used() const
+{
+    return data().toMap()["used"].toBool();
+}
+
 void PlasmaAppletItem::setFavorite(bool favorite)
 {
     QMap<QString, QVariant> attrs = data().toMap();
@@ -78,6 +83,13 @@
     setData(QVariant(attrs));
 }
 
+void PlasmaAppletItem::setUsed(bool used)
+{
+    QMap<QString, QVariant> attrs = data().toMap();
+    attrs.insert("used", used);
+    setData(QVariant(attrs));
+}
+
 bool PlasmaAppletItem::passesFiltering(
         const KCategorizedItemsViewModels::Filter & filter) const
 {
@@ -149,10 +161,22 @@
     for (int r=0; r<rowCount(); ++r) {
         QStandardItem *i = item(r);
         PlasmaAppletItem *p = dynamic_cast<PlasmaAppletItem *>(i);
+
         if (p) {
-            p->setRunning(apps.value(p->name()));
+            const bool running = apps.value(p->name());
+            const bool used = m_used.contains(p->pluginName());
+
+            p->setRunning(running);
+            //mark just used applets that arent't running
+            p->setUsed(!running && used);
+
+            if (running && !used) {
+                m_used.append(p->pluginName());
+            }
         }
     }
+
+    m_configGroup.writeEntry("used", m_used.join(","));
 }
 
 void PlasmaAppletItemModel::setRunningApplets(const QString &name, int count)
@@ -161,9 +185,18 @@
         QStandardItem *i = item(r);
         PlasmaAppletItem *p = dynamic_cast<PlasmaAppletItem *>(i);
         if (p && p->name() == name) {
+            const bool used = m_used.contains(p->pluginName());
+
             p->setRunning(count);
+            p->setUsed(used && count == 0);
+
+            if (count > 0 && !used) {
+                m_used.append(p->pluginName());
+            }
         }
     }
+
+    m_configGroup.writeEntry("used", m_used.join(","));
 }
 
 QStringList PlasmaAppletItemModel::mimeTypes() const
--- trunk/KDE/kdebase/workspace/plasma/shells/common/plasmaappletitemmodel_p.h #902022:902023
@@ -50,6 +50,8 @@
     QString pluginName() const;
     virtual QString description() const;
     virtual int running() const;
+    virtual bool used() const;
+    virtual void setUsed(bool used);
     virtual void setFavorite(bool favorite);
     //set how many instances of this applet are running
     virtual void setRunning(int count);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic