Using a loop instead is a much tidier way to express this.

Signed-off-by: Robin Burchell <[email protected]>
Signed-off-by: John Brooks <[email protected]>
---
 applicationlist.cpp |   60 +++++++++++++++++++++-----------------------------
 1 files changed, 25 insertions(+), 35 deletions(-)

diff --git a/applicationlist.cpp b/applicationlist.cpp
index 29e6cf1..de79b14 100644
--- a/applicationlist.cpp
+++ b/applicationlist.cpp
@@ -207,7 +207,8 @@ void ApplicationList::AddEntry(QString key, MBDotDesktop 
*mb)
 
 void ApplicationList::ProcessEntry(MBDotDesktop *mb)
 {
-    QString line, exec, onlyshowin, nodisplay;
+    QString line, onlyshowin, nodisplay;
+    QByteArray exec;
     QStringList catlist, matcheslist;
     uint i, j, k;
     bool match = false;
@@ -226,43 +227,32 @@ void ApplicationList::ProcessEntry(MBDotDesktop *mb)
         return;
     }
 
-    exec = (char *)mb_dotdesktop_get_exec(mb);
-
-    if(exec.contains("liveinst", Qt::CaseInsensitive))
-    {
-        AddEntry("Live Install", mb);
-        return;
-    }
-
-    if(exec.contains("Navit", Qt::CaseInsensitive))
-    {
-        AddEntry("Navigation", mb);
-        return;
-    } else if(exec.contains("Fennec", Qt::CaseInsensitive))
-    {
-        AddEntry("Web", mb);
-        return;
-    } else if(exec.contains("meego-handset-people", Qt::CaseInsensitive)||
-              exec.contains("meego-handset-email", Qt::CaseInsensitive))
-    {
-        AddEntry("Connect", mb);
-        return;
-    }else if(exec.contains("meegophotos", Qt::CaseInsensitive))
-    {
-        AddEntry("Photos", mb);
-        return;
-    }else if(exec.contains("meegomusic", Qt::CaseInsensitive))
-    {
-        AddEntry("Music", mb);
-        return;
-    }else if(exec.contains("video", Qt::CaseInsensitive))
+    exec = QByteArray((char *)mb_dotdesktop_get_exec(mb)).toLower();
+
+    // entry mappings is exec key -> entry lookup
+    // exec key must be lowercased.
+    const char *entries[][2] = {
+        { "liveinst", "Live Install" },
+        { "navit", "Navigation" },
+        { "fennec", "Web" },
+        { "meego-handset-people", "Connect" },
+        { "meego-handset-email", "Connect" },
+        { "meegophotos", "Photos" },
+        { "meegomusic", "Music" },
+        { "video", "Video" },
+        { "controlpanel", "Settings" },
+        { 0, 0 }
+
+    };
+
+    for (i = 0; entries[i] != 0; ++i)
     {
-        AddEntry("Video", mb);
-        return;
-    }else if(exec.contains("controlpanel", Qt::CaseInsensitive))
-    {
-        AddEntry("Settings", mb);
-        return;
+        // contains() instead of equality because the Exec key may
+        // contain more than just a binary name.
+        if (exec.contains(entries[i][0]))
+        {
+            AddEntry(entries[i][1], mb);
+        }
     }
 
     line = (char *)mb_dotdesktop_get(mb, "Categories");
-- 
1.7.4.1

_______________________________________________
MeeGo-dev mailing list
[email protected]
http://lists.meego.com/listinfo/meego-dev
http://wiki.meego.com/Mailing_list_guidelines

Reply via email to