Changeset View
Changeset View
Standalone View
Standalone View
kcms/componentchooser/componentchooser.cpp
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 72 | void CfgComponent::load(KConfig *cfg) { | |||
---|---|---|---|---|---|
75 | m_lookupDict.clear(); | 75 | m_lookupDict.clear(); | ||
76 | m_revLookupDict.clear(); | 76 | m_revLookupDict.clear(); | ||
77 | 77 | | |||
78 | const KConfigGroup mainGroup = cfg->group(QByteArray()); | 78 | const KConfigGroup mainGroup = cfg->group(QByteArray()); | ||
79 | const QString serviceTypeToConfigure = mainGroup.readEntry("ServiceTypeToConfigure"); | 79 | const QString serviceTypeToConfigure = mainGroup.readEntry("ServiceTypeToConfigure"); | ||
80 | 80 | | |||
81 | const KService::List offers = KServiceTypeTrader::self()->query(serviceTypeToConfigure); | 81 | const KService::List offers = KServiceTypeTrader::self()->query(serviceTypeToConfigure); | ||
82 | 82 | | |||
83 | for (KService::List::const_iterator tit = offers.begin(); tit != offers.end(); ++tit) { | 83 | for (const auto &service: offers) { | ||
84 | ComponentSelector->addItem((*tit)->name()); | 84 | ComponentSelector->addItem(service->name()); | ||
85 | m_lookupDict.insert((*tit)->name(), (*tit)->desktopEntryName()); | 85 | m_lookupDict.insert(service->name(), service->desktopEntryName()); | ||
86 | m_revLookupDict.insert((*tit)->desktopEntryName(), (*tit)->name()); | 86 | m_revLookupDict.insert(service->desktopEntryName(), service->name()); | ||
ervin: Indentation looks wrong | |||||
87 | } | 87 | } | ||
88 | 88 | | |||
89 | KConfig store(mainGroup.readPathEntry("storeInFile",QStringLiteral("null"))); | 89 | KConfig store(mainGroup.readPathEntry("storeInFile",QStringLiteral("null"))); | ||
90 | const KConfigGroup group(&store, mainGroup.readEntry("valueSection")); | 90 | const KConfigGroup group(&store, mainGroup.readEntry("valueSection")); | ||
91 | QString setting = group.readEntry(mainGroup.readEntry("valueName","kcm_componenchooser_null"), QString()); | 91 | QString setting = group.readEntry(mainGroup.readEntry("valueName","kcm_componenchooser_null"), QString()); | ||
92 | 92 | | |||
93 | if (setting.isEmpty()) | 93 | if (setting.isEmpty()) | ||
94 | setting = mainGroup.readEntry("defaultImplementation", QString()); | 94 | setting = mainGroup.readEntry("defaultImplementation", QString()); | ||
Show All 22 Lines | |||||
117 | 117 | | |||
118 | 118 | | |||
119 | ComponentChooser::ComponentChooser(QWidget *parent): | 119 | ComponentChooser::ComponentChooser(QWidget *parent): | ||
120 | QWidget(parent), Ui::ComponentChooser_UI(), somethingChanged(false), configWidget(nullptr) | 120 | QWidget(parent), Ui::ComponentChooser_UI(), somethingChanged(false), configWidget(nullptr) | ||
121 | { | 121 | { | ||
122 | setupUi(this); | 122 | setupUi(this); | ||
123 | static_cast<QGridLayout*>(layout())->setRowStretch(1, 1); | 123 | static_cast<QGridLayout*>(layout())->setRowStretch(1, 1); | ||
124 | 124 | | |||
125 | const QStringList services=KGlobal::dirs()->findAllResources( "data",QStringLiteral("kcm_componentchooser/*.desktop"), | 125 | const QStringList directories = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kcm_componentchooser"), QStandardPaths::LocateDirectory); | ||
126 | KStandardDirs::NoDuplicates); | 126 | QStringList services; | ||
127 | for (QStringList::const_iterator it=services.constBegin(); it!=services.constEnd(); ++it) | 127 | for(const QString &directory : directories) { | ||
ervin: Space before & not after | |||||
128 | const QDir dir(directory); | ||||
129 | for(const QString &f: dir.entryList(QStringList("*.desktop"))) { | ||||
ervin: Space before & not after | |||||
130 | services += dir.absoluteFilePath(f); | ||||
131 | } | ||||
132 | } | ||||
133 | | ||||
134 | for (const QString &service : qAsConst(services)) | ||||
ervin: Indentation looks wrong | |||||
128 | { | 135 | { | ||
129 | KConfig cfg(*it, KConfig::SimpleConfig); | 136 | KConfig cfg(service, KConfig::SimpleConfig); | ||
130 | KConfigGroup cg = cfg.group(QByteArray()); | 137 | KConfigGroup cg = cfg.group(QByteArray()); | ||
131 | QListWidgetItem *item = new QListWidgetItem( | 138 | QListWidgetItem *item = new QListWidgetItem( | ||
132 | QIcon::fromTheme(cg.readEntry("Icon",QStringLiteral("preferences-desktop-default-applications"))), | 139 | QIcon::fromTheme(cg.readEntry("Icon",QStringLiteral("preferences-desktop-default-applications"))), | ||
133 | cg.readEntry("Name",i18n("Unknown"))); | 140 | cg.readEntry("Name",i18n("Unknown"))); | ||
134 | item->setData(Qt::UserRole, (*it)); | 141 | item->setData(Qt::UserRole, service); | ||
135 | ServiceChooser->addItem(item); | 142 | ServiceChooser->addItem(item); | ||
136 | loadConfigWidget((*it), cfg.group(QByteArray()).readEntry("configurationType"), item->text()); | 143 | loadConfigWidget(service, cfg.group(QByteArray()).readEntry("configurationType"), item->text()); | ||
137 | } | 144 | } | ||
138 | ServiceChooser->setFixedWidth(ServiceChooser->sizeHintForColumn(0) + 20); | 145 | ServiceChooser->setFixedWidth(ServiceChooser->sizeHintForColumn(0) + 20); | ||
139 | ServiceChooser->sortItems(); | 146 | ServiceChooser->sortItems(); | ||
140 | connect(ServiceChooser,&QListWidget::currentItemChanged,this,&ComponentChooser::slotServiceSelected); | 147 | connect(ServiceChooser,&QListWidget::currentItemChanged,this,&ComponentChooser::slotServiceSelected); | ||
141 | ServiceChooser->setCurrentRow(0); | 148 | ServiceChooser->setCurrentRow(0); | ||
142 | } | 149 | } | ||
143 | 150 | | |||
144 | void ComponentChooser::loadConfigWidget(const QString &service, const QString &cfgType, const QString &name) | 151 | void ComponentChooser::loadConfigWidget(const QString &service, const QString &cfgType, const QString &name) | ||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |
Indentation looks wrong