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
This commit is contained in:
Peter Penz 2009-03-03 19:39:36 +00:00
parent 5ecc19e789
commit 0801e50cfd
2 changed files with 19 additions and 2 deletions

View file

@ -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"

View file

@ -45,6 +45,7 @@ protected:
private slots:
void loadServices();
bool isInServicesList(const QString& service) const;
private:
bool m_initialized;