From: Peter Penz Date: Tue, 3 Mar 2009 19:39:36 +0000 (+0000) Subject: only add the service to the list, if there is no other service using the same name X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/0801e50cfd52720577e40c28e576fe4a9baebc4b?ds=sidebyside only add the service to the list, if there is no other service using the same name svn path=/trunk/KDE/kdebase/apps/; revision=934788 --- diff --git a/src/settings/servicessettingspage.cpp b/src/settings/servicessettingspage.cpp index 57e91e5dd..18f93dfa3 100644 --- a/src/settings/servicessettingspage.cpp +++ b/src/settings/servicessettingspage.cpp @@ -102,11 +102,15 @@ void ServicesSettingsPage::loadServices() 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); - const QString service = action.name(); 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" diff --git a/src/settings/servicessettingspage.h b/src/settings/servicessettingspage.h index ee1b16264..2e8a6b9e0 100644 --- a/src/settings/servicessettingspage.h +++ b/src/settings/servicessettingspage.h @@ -45,6 +45,7 @@ protected: private slots: void loadServices(); + bool isInServicesList(const QString& service) const; private: bool m_initialized;