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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/applets/kickoff
From:       Christian Loose <christian.loose () hamburg ! de>
Date:       2009-03-14 11:39:10
Message-ID: 1237030750.723445.28954.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 939224 by cloose:

Add support for separators to the ApplicationModel and the classic menu style variant \
of kickoff (simpleapplet).

REVIEWED: http://reviewboard.kde.org/r/293/
BUG: 187014



 M  +15 -6     core/applicationmodel.cpp  
 M  +1 -1      core/applicationmodel.h  
 M  +3 -1      core/models.h  
 M  +2 -0      simpleapplet/menuview.cpp  
 M  +1 -1      simpleapplet/simpleapplet.cpp  


--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/core/applicationmodel.cpp \
#939223:939224 @@ -72,6 +72,7 @@
         : parent(0),
           fetched(false),
           isDir(false),
+          isSeparator(false),
           subTitleMandatory(false)
     {
     }
@@ -92,18 +93,20 @@
     AppNode *parent;
     bool fetched;
     bool isDir;
+    bool isSeparator;
     bool subTitleMandatory;
 };
 
 class ApplicationModelPrivate
 {
 public:
-    ApplicationModelPrivate(ApplicationModel *qq)
+    ApplicationModelPrivate(ApplicationModel *qq, bool _allowSeparators)
             : q(qq),
               root(new AppNode()),
               duplicatePolicy(ApplicationModel::ShowDuplicatesPolicy),
               systemApplicationPolicy(ApplicationModel::ShowSystemOnlyPolicy),
-              primaryNamePolicy(ApplicationModel::GenericNamePrimary)
+              primaryNamePolicy(ApplicationModel::GenericNamePrimary),
+              allowSeparators(_allowSeparators)
     {
         systemApplications = Kickoff::systemApplicationList();
     }
@@ -121,6 +124,7 @@
     ApplicationModel::DuplicatePolicy duplicatePolicy;
     ApplicationModel::SystemApplicationPolicy systemApplicationPolicy;
     ApplicationModel::PrimaryNamePolicy primaryNamePolicy;
+    bool allowSeparators;
     QStringList systemApplications;
 };
 
@@ -134,7 +138,7 @@
 
     const KServiceGroup::List list = root->entries(true /* sorted */,
                                                    true /* exclude no display \
                entries */,
-                                                   false /* allow separators */,
+                                                   allowSeparators /* allow \
                separators */,
                                                    primaryNamePolicy == \
ApplicationModel::GenericNamePrimary /* sort by generic name */);  
     // application name <-> service map for detecting duplicate entries
@@ -150,6 +154,7 @@
         QString relPath = _relPath;
         QString desktopEntry;
         bool isDir = false;
+        bool isSeparator = false;
         const KSycocaEntry::Ptr p = (*it);
 
         if (p->isType(KST_KService)) {
@@ -216,7 +221,7 @@
             appName = serviceGroup->comment();
             isDir = true;
         } else if (p->isType(KST_KServiceSeparator)) {
-            // TODO: implement seaparators
+            isSeparator = true;
         } else {
             kWarning(250) << "KServiceGroup: Unexpected object in list!";
             continue;
@@ -229,6 +234,7 @@
         newnode->relPath = relPath;
         newnode->desktopEntry = desktopEntry;
         newnode->isDir = isDir;
+        newnode->isSeparator = isSeparator;
         newnode->parent = node;
         node->children.append(newnode);
 
@@ -252,8 +258,8 @@
     }
 }
 
-ApplicationModel::ApplicationModel(QObject *parent)
-        : KickoffAbstractModel(parent), d(new ApplicationModelPrivate(this))
+ApplicationModel::ApplicationModel(QObject *parent, bool allowSeparators)
+        : KickoffAbstractModel(parent), d(new ApplicationModelPrivate(this, \
allowSeparators))  {
     QDBusConnection dbus = QDBusConnection::sessionBus();
     (void)new KickoffAdaptor(this);
@@ -309,6 +315,9 @@
     case Kickoff::SubTitleMandatoryRole:
         return node->subTitleMandatory;
         break;
+    case Kickoff::SeparatorRole:
+        return node->isSeparator;
+        break;
     case Qt::DecorationRole:
         return node->icon;
         break;
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/core/applicationmodel.h \
#939223:939224 @@ -38,7 +38,7 @@
     Q_OBJECT
 
 public:
-    ApplicationModel(QObject *parent = 0);
+    ApplicationModel(QObject *parent = 0, bool allowSeparators = false);
     virtual ~ApplicationModel();
 
     /**
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/core/models.h #939223:939224
@@ -69,7 +69,9 @@
     /** The amount of free space (in Kilobytes) for items which represent storage. \
*/  DiskFreeSpaceRole = Qt::UserRole + 5,
     SubTitleMandatoryRole = Qt::UserRole + 6,
-    LastDataRole = SubTitleMandatoryRole
+    /** Is item a separator. **/
+    SeparatorRole = Qt::UserRole + 7,
+    LastDataRole = SeparatorRole
 };
 
 /**
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/simpleapplet/menuview.cpp \
#939223:939224 @@ -113,6 +113,7 @@
 
 void MenuView::updateAction(QAbstractItemModel *model, QAction *action, const \
QModelIndex& index)  {
+    bool isSeparator = index.data(Kickoff::SeparatorRole).value<bool>();
     QString text = index.data(Qt::DisplayRole).value<QString>().replace("&", "&&"); \
// describing text, e.g. "Spreadsheet" or "Rekall" (right, sometimes the text is also \
used for the generic app-name)  QString name = \
index.data(Kickoff::SubTitleRole).value<QString>().replace("&", "&&"); // the generic \
name, e.g. "kspread" or "OpenOffice.org Spreadsheet" or just "" (right, it's a mess \
                too)
     if (action->menu() != 0) { // if it is an item with sub-menuitems, we probably \
like to thread them another way... @@ -149,6 +150,7 @@
         }
     }
 
+    action->setSeparator(isSeparator);
     action->setIcon(index.data(Qt::DecorationRole).value<QIcon>());
 
     // we map modelindex and action together
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/simpleapplet/simpleapplet.cpp \
#939223:939224 @@ -492,7 +492,7 @@
         //Kickoff::MenuView::ModelOptions options = d->viewtypes.count() < 2 ? \
Kickoff::MenuView::MergeFirstLevel : Kickoff::MenuView::None;  foreach(QString \
vtname, d->viewtypes) {  if(vtname == "Applications") {
-                Kickoff::ApplicationModel *appModel = new \
Kickoff::ApplicationModel(d->menuview); +                Kickoff::ApplicationModel \
                *appModel = new Kickoff::ApplicationModel(d->menuview, true /*allow \
                separators*/);
                 appModel->setDuplicatePolicy(Kickoff::ApplicationModel::ShowLatestOnlyPolicy);
                
                 if (d->formattype == Name || d->formattype == NameDescription || \
                d->formattype == NameDashDescription)
                     \
appModel->setPrimaryNamePolicy(Kickoff::ApplicationModel::AppNamePrimary);


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

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