Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-updates-src > by-pkgid > 83ecf8f3cf39318860f0dc9917c84068 > files > 38

kdebase4-workspace-4.6.5-1.4.mga1.src.rpm

commit 403e71ad862e74d03910248c9645e434b4123c6d
Author: Aaron Seigo <aseigo@kde.org>
Date:   Tue Oct 25 14:37:22 2011 +0200

    fix name display
    
    patch by Luc Menut
    REVIEW:102820
    BUG:249501

diff --git a/plasma/desktop/applets/kickoff/simpleapplet/menuview.cpp b/plasma/desktop/applets/kickoff/simpleapplet/menuview.cpp
index fce0fab..963c18b 100644
--- a/plasma/desktop/applets/kickoff/simpleapplet/menuview.cpp
+++ b/plasma/desktop/applets/kickoff/simpleapplet/menuview.cpp
@@ -180,40 +180,43 @@ QAction *MenuView::createLeafAction(const QModelIndex &index, QObject *parent)
 void MenuView::updateAction(QAbstractItemModel *model, QAction *action, const QModelIndex& index)
 {
     bool isSeparator = index.data(Kickoff::SeparatorRole).value<bool>();
-    QString name = index.data(Qt::DisplayRole).value<QString>().replace('&', "&&"); // the generic name, e.g. "kspread" or "OpenOffice.org Spreadsheet" or just "" (right, it's a mess too)
-    QString text = index.data(Kickoff::SubTitleRole).value<QString>().replace('&', "&&"); // describing text, e.g. "Spreadsheet" or "Rekall" (right, sometimes the text is also used for the generic app-name)
+
+    // if Description or DescriptionName -> displayOrder = Kickoff::NameAfterDescription
+    //    Qt::DisplayRole returns genericName, the generic name e.g. "Advanced Text Editor" or "Spreadsheet" or just "" (right, it's a mess too)
+    //    Kickoff::SubTitleRole returns appName, the name  e.g. "Kate" or "OpenOffice.org Calc" (right, sometimes the text is also used for the generic app-name)
+    //
+    // if Name or NameDescription or NameDashDescription -> displayOrder = Kickoff::NameBeforeDescription
+    //    Qt::DisplayRole returns appName,
+    //    Kickoff::SubTitleRole returns genericName.
+
+    QString mainText = index.data(Qt::DisplayRole).value<QString>().replace('&', "&&");
+    QString altText = index.data(Kickoff::SubTitleRole).value<QString>().replace('&', "&&");
     if (action->menu() != 0) { // if it is an item with sub-menuitems, we probably like to thread them another way...
-        action->setText(name);
+        action->setText(mainText);
     } else {
         switch (d->formattype) {
-        case Name: {
-
-            action->setText(name.isEmpty() ? text : name);
-            action->setToolTip(text);
-        } break;
+        case Name:
         case Description: {
-            action->setText(name.contains(text, Qt::CaseInsensitive) ? name : text);
-            action->setToolTip(name);
+            action->setText(mainText);
+            action->setToolTip(altText);
         } break;
         case NameDescription: // fall through
         case NameDashDescription: // fall through
         case DescriptionName: {
-            if (!name.isEmpty()) { // seems we have a program, but some of them don't define a name at all
-                if (text.contains(name, Qt::CaseInsensitive)) { // sometimes the description contains also the name
-                    action->setText(text);
-                } else if (name.contains(text, Qt::CaseInsensitive)) { // and sometimes the name also contains the description
-                    action->setText(name);
+            if (!mainText.isEmpty()) { // seems we have a program, but some of them don't define a name at all
+                if (mainText.contains(altText, Qt::CaseInsensitive)) { // sometimes the description contains also the name
+                    action->setText(mainText);
+                } else if (altText.contains(mainText, Qt::CaseInsensitive)) { // and sometimes the name also contains the description
+                    action->setText(altText);
                 } else { // seems we have a perfect desktop-file (likely a KDE one, heh) and name+description are clear separated
-                    if (d->formattype == NameDescription) {
-                        action->setText(QString("%1 (%2)").arg(name).arg(text));
-                    } else if (d->formattype == NameDashDescription) {
-                        action->setText(QString("%1 - %2").arg(name).arg(text));
+                    if (d->formattype == NameDashDescription) {
+                        action->setText(QString("%1 - %2").arg(mainText).arg(altText));
                     } else {
-                        action->setText(QString("%1 (%2)").arg(text).arg(name));
+                        action->setText(QString("%1 (%2)").arg(mainText).arg(altText));
                     }
                 }
             } else { // if there is no name, let's just use the describing text
-                action->setText(text);
+                action->setText(altText);
             }
         } break;
         }
diff --git a/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.cpp b/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.cpp
index 9e0448e..28fba18 100644
--- a/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.cpp
+++ b/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.cpp
@@ -611,11 +611,11 @@ void MenuLauncherApplet::showMenu(bool pressed)
             if(vtname == "Applications") {
                 Kickoff::ApplicationModel *appModel = new Kickoff::ApplicationModel(menuview, true /*allow separators*/);
 
-                appModel->setNameDisplayOrder(Kickoff::NameBeforeDescription);
-
                 appModel->setDuplicatePolicy(Kickoff::ApplicationModel::ShowLatestOnlyPolicy);
-                if (d->formattype == Name || d->formattype == NameDescription || d->formattype == NameDashDescription)
+                if (d->formattype == Name || d->formattype == NameDescription || d->formattype == NameDashDescription) {
+                    appModel->setNameDisplayOrder(Kickoff::NameBeforeDescription);
                     appModel->setPrimaryNamePolicy(Kickoff::ApplicationModel::AppNamePrimary);
+                }
                 appModel->setSystemApplicationPolicy(Kickoff::ApplicationModel::ShowApplicationAndSystemPolicy);
 
                 menuview->addModel(appModel, Kickoff::MenuView::None, d->relativePath);
@@ -629,14 +629,25 @@ void MenuLauncherApplet::showMenu(bool pressed)
                     }
                 }
             } else if(vtname == "Favorites") {
-                d->addModel(new Kickoff::FavoritesModel(menuview), Favorites);
+                Kickoff::FavoritesModel *favoritesModel = new Kickoff::FavoritesModel(menuview);
+                if (d->formattype == Name || d->formattype == NameDescription || d->formattype == NameDashDescription) {
+                    favoritesModel->setNameDisplayOrder(Kickoff::NameBeforeDescription);
+                }
+                d->addModel(favoritesModel, Favorites);
             } else if(vtname == "Computer") {
                 d->addModel(new Kickoff::SystemModel(menuview), Computer);
             } else if(vtname == "RecentlyUsed") {
-                d->addModel(new Kickoff::RecentlyUsedModel(menuview), RecentlyUsed);
+                Kickoff::RecentlyUsedModel *recentModel = new Kickoff::RecentlyUsedModel(menuview);
+                if (d->formattype == Name || d->formattype == NameDescription || d->formattype == NameDashDescription) {
+                    recentModel->setNameDisplayOrder(Kickoff::NameBeforeDescription);
+                }
+                d->addModel(recentModel, RecentlyUsed);
             } else if(vtname == "RecentlyUsedApplications") {
                 if (d->maxRecentApps > 0) {
                     Kickoff::RecentlyUsedModel *recentModel = new Kickoff::RecentlyUsedModel(menuview, Kickoff::RecentlyUsedModel::ApplicationsOnly, d->maxRecentApps);
+                    if (d->formattype == Name || d->formattype == NameDescription || d->formattype == NameDashDescription) {
+                        recentModel->setNameDisplayOrder(Kickoff::NameBeforeDescription);
+                    }
                     menuview->addModel(recentModel, Kickoff::MenuView::MergeFirstLevel);
 
                     if (d->showMenuTitles) {