]> cloud.milkyroute.net Git - dolphin.git/commitdiff
only add the service to the list, if there is no other service using the same name
authorPeter Penz <peter.penz19@gmail.com>
Tue, 3 Mar 2009 19:39:36 +0000 (19:39 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 3 Mar 2009 19:39:36 +0000 (19:39 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=934788

src/settings/servicessettingspage.cpp
src/settings/servicessettingspage.h

index 57e91e5dd55288a88f1a08b6cf80c46bb86884e2..18f93dfa39b8c7498cbc81aa3874b1b2d2186a2a 100644 (file)
@@ -102,11 +102,15 @@ void ServicesSettingsPage::loadServices()
                                     KDesktopFileActions::userDefinedServices(file, true);
 
         foreach (const KServiceAction& action, serviceActions) {
                                     KDesktopFileActions::userDefinedServices(file, true);
 
         foreach (const KServiceAction& action, serviceActions) {
-            if (!action.noDisplay() && !action.isSeparator()) {
+            const QString service = action.name();
+            const bool addService = !action.noDisplay()
+                                    && !action.isSeparator()
+                                    && !isInServicesList(service);
+
+            if (addService) {
                 QListWidgetItem* item = new QListWidgetItem(KIcon(action.icon()),
                                                             action.text(),
                                                             m_servicesList);
                 QListWidgetItem* item = new QListWidgetItem(KIcon(action.icon()),
                                                             action.text(),
                                                             m_servicesList);
-                const QString service = action.name();
                 item->setData(Qt::UserRole, service);
                 const bool show = showGroup.readEntry(service, true);
                 item->setCheckState(show ? Qt::Checked : Qt::Unchecked);
                 item->setData(Qt::UserRole, service);
                 const bool show = showGroup.readEntry(service, true);
                 item->setCheckState(show ? Qt::Checked : Qt::Unchecked);
@@ -115,4 +119,16 @@ void ServicesSettingsPage::loadServices()
     }
 }
 
     }
 }
 
+bool ServicesSettingsPage::isInServicesList(const QString& service) const
+{
+    const int count = m_servicesList->count();
+    for (int i = 0; i < count; ++i) {
+        QListWidgetItem* item = m_servicesList->item(i);
+        if (item->data(Qt::UserRole).toString() == service) {
+            return true;
+        }
+    }
+    return false;
+}
+
 #include "servicessettingspage.moc"
 #include "servicessettingspage.moc"
index ee1b16264ab42a0a8440e2e28c5bd95a6c2ef2d1..2e8a6b9e06466321574323bc69c9dad1a7339a86 100644 (file)
@@ -45,6 +45,7 @@ protected:
 
 private slots:
     void loadServices();
 
 private slots:
     void loadServices();
+    bool isInServicesList(const QString& service) const;
 
 private:
     bool m_initialized;
 
 private:
     bool m_initialized;