34 #include <QtCore/QFile>
35 #include <QtGui/QCheckBox>
36 #include <QtCore/QStack>
55 d->components = components;
64 d_func()->staticlistview = !selection;
69 return !d_func()->staticlistview;
75 d->arguments = arguments;
81 d->componentBlacklist = blacklist;
87 for (KPluginInfo::List::ConstIterator it = plugininfos.begin();
88 it != plugininfos.end(); ++it ) {
89 d->registeredComponents.append(it->pluginName());
90 if (it->kcmServices().isEmpty()) {
110 d->plugininfos = plugininfos;
115 return d_func()->plugininfos;
122 setUpdatesEnabled(
false);
123 d->kcmInfos += d->instanceServices();
124 if (!d->components.isEmpty()) {
125 d->kcmInfos += d->parentComponentsServices(d->components);
127 d->createDialogFromServices();
128 d->firstshow =
false;
129 setUpdatesEnabled(
true);
135 : staticlistview(true), firstshow(true), pluginStateDirty(0)
142 QString componentName = KGlobal::mainComponent().componentName();
149 if( service && service->isValid() )
153 for( KServiceGroup::List::ConstIterator it = list.begin();
154 it != list.end(); ++it )
156 KSycocaEntry::Ptr p = (*it);
157 if( p->isType( KST_KService ) )
163 kWarning( 700 ) <<
"KServiceGroup::childGroup returned"
164 " something else than a KService" << endl;
174 QString constraint = kcdparents.join(
"' in [X-KDE-ParentComponents]) or ('");
175 constraint =
"('" + constraint +
"' in [X-KDE-ParentComponents])";
194 "X-KDE-ParentComponents" ).toStringList();
195 for( QStringList::ConstIterator pcit = parentComponents.begin();
196 pcit != parentComponents.end(); ++pcit )
220 bool DialogPrivate::isPluginImmutable(
const KPluginInfo &pinfo)
const
222 return pinfo.
property(
"X-KDE-PluginInfo-Immutable").toBool();
227 const QString &iconName,
int weight)
232 QCheckBox *checkBox =
new QCheckBox(
i18n(
"Enable component"), page);
235 commentLabel->setTextFormat(Qt::RichText);
236 QVBoxLayout * layout =
new QVBoxLayout(page);
237 layout->addWidget(checkBox);
238 layout->addWidget(iconLabel);
239 layout->addWidget(commentLabel);
240 layout->addStretch();
241 page->setLayout(layout);
245 iconLabel->setPixmap(item->
icon().pixmap(128, 128));
246 item->setProperty(
"_k_weight", weight);
253 const QModelIndex parentIndex = model->
index(parentItem);
254 const int siblingCount = model->
rowCount(parentIndex);
256 for (; row < siblingCount; ++row) {
258 if (siblingItem->property(
"_k_weight").toInt() > weight) {
260 q->insertPage(siblingItem, item);
264 if (row == siblingCount) {
266 q->addSubPage(parentItem, item);
269 const int siblingCount = model->
rowCount();
271 for (; row < siblingCount; ++row) {
273 if (siblingItem->property(
"_k_weight").toInt() > weight) {
275 q->insertPage(siblingItem, item);
279 if (row == siblingCount) {
288 void DialogPrivate::parseGroupFile(
const QString & filename )
292 foreach (
const QString &group, groups) {
293 if (group.isEmpty()) {
298 const QString parentId = conf.readEntry(
"Parent");
301 conf.readEntry(
"Icon"), conf.readEntry(
"Weight", 100));
306 void DialogPrivate::createDialogFromServices()
311 KGlobal::mainComponent().componentName() +
".setdlg" );
312 const QStringList setdlgaddon = KGlobal::dirs()->findAllResources(
"appdata",
313 "ksettingsdialog/*.setdlg" );
314 if (!setdlgpath.isNull()) {
315 parseGroupFile(setdlgpath);
317 if (setdlgaddon.size() > 0) {
318 for (QStringList::ConstIterator it = setdlgaddon.begin(); it != setdlgaddon.end(); ++it) {
326 bool blacklisted =
false;
327 foreach (
const QString &parentComponent, parentComponents) {
340 bool foundPlugin =
false;
346 const int weight = 1000;
363 const bool isEnabled = isPluginForKCMEnabled(&info, pinfo);
364 kDebug(700) <<
"correct KPluginInfo for this KCM";
370 if (plugin != pinfo) {
371 kError(700) <<
"A group contains more than one plugin: '"
373 <<
"'. Now it won't be possible to enable/disable the plugin."
397 for (; it != end; ++it) {
398 const QModelIndex index = model->
index(it.value());
401 if (p.
name()==it.key()) {
406 bool allowEmpty =
false;
408 allowEmpty = pinfo.
property(
"X-KDE-PluginInfo-AllowEmptySettings").toBool();
411 if (!index.child(0, 0).isValid()) {
414 q->removePage(it.value());
436 QObject::connect(q, SIGNAL(configCommitted(QByteArray)), q,
448 checkBox->setVisible(!isPluginImmutable(pinfo));
449 checkBox->setChecked(isEnabled);
451 q->connect(item, SIGNAL(toggled(
bool)), checkBox, SLOT(setChecked(
bool)));
452 q->connect(checkBox, SIGNAL(clicked(
bool)), item, SLOT(setChecked(
bool)));
460 for (; it != endIt; ++it) {
467 emit q->pluginSelectionChanged();
493 q->enableButton(KDialog::Apply,
true);
511 QModelIndex index = model->
index(item);
512 if (!index.isValid()) {
513 kWarning(700) <<
"could not find item in model";
519 kWarning(700) <<
"could not find KPluginInfo in item";
533 QModelIndex firstborn = index.child(0, 0);
534 if (firstborn.isValid()) {
538 QStack<QModelIndex> stack;
539 while (index.isValid()) {
544 firstborn = index.child(0, 0);
545 if (firstborn.isValid()) {
549 index = index.sibling(index.row() + 1, 0);
550 while (!index.isValid() && !stack.isEmpty()) {
552 index = index.sibling(index.row() + 1, 0);
561 #include "dialog.moc"