mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 02:42:50 +00:00
kcontrol: use tree widget for metadata plugins in kmetainfoconfig module
to make it look and feel like the service manager control module Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
fda21652d7
commit
c91f87861d
3 changed files with 39 additions and 41 deletions
|
@ -52,9 +52,15 @@ KCMMetaInfo::KCMMetaInfo(QWidget* parent, const QVariantList& args)
|
|||
|
||||
setButtons(KCModule::Help | KCModule::Apply);
|
||||
|
||||
connect(pluginstable, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(slotPluginItemChanged(QTableWidgetItem*)));
|
||||
connect(
|
||||
pluginstree, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
|
||||
this, SLOT(slotPluginItemChanged(QTreeWidgetItem*,int))
|
||||
);
|
||||
|
||||
connect(metainfolist, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotMetaItemChanged(QListWidgetItem*)));
|
||||
connect(
|
||||
metainfolist, SIGNAL(itemChanged(QListWidgetItem*)),
|
||||
this, SLOT(slotMetaItemChanged(QListWidgetItem*))
|
||||
);
|
||||
|
||||
load();
|
||||
}
|
||||
|
@ -67,31 +73,23 @@ void KCMMetaInfo::load()
|
|||
{
|
||||
{
|
||||
KConfig config("kmetainformationrc", KConfig::NoGlobals);
|
||||
pluginstable->clearContents();
|
||||
pluginstable->setRowCount(0);
|
||||
int rowcount = 0;
|
||||
pluginstree->clear();
|
||||
KConfigGroup pluginsgroup = config.group("Plugins");
|
||||
const KService::List kfmdplugins = KServiceTypeTrader::self()->query("KFileMetaData/Plugin");
|
||||
foreach (const KService::Ptr &kfmdplugin, kfmdplugins) {
|
||||
const QString key = kfmdplugin->desktopEntryName();
|
||||
|
||||
pluginstable->setRowCount(rowcount + 1);
|
||||
|
||||
QTableWidgetItem* nameitem = new QTableWidgetItem();
|
||||
nameitem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
|
||||
nameitem->setText(kfmdplugin->genericName());
|
||||
nameitem->setData(Qt::UserRole, key);
|
||||
const bool enable = pluginsgroup.readEntry(key, true);
|
||||
nameitem->setCheckState(enable ? Qt::Checked : Qt::Unchecked);
|
||||
pluginstable->setItem(rowcount, 0, nameitem);
|
||||
|
||||
QTableWidgetItem* descitem = new QTableWidgetItem();
|
||||
descitem->setFlags(Qt::ItemIsEnabled);
|
||||
descitem->setText(kfmdplugin->comment());
|
||||
pluginstable->setItem(rowcount, 1, descitem);
|
||||
|
||||
rowcount++;
|
||||
QTreeWidgetItem* pluginitem = new QTreeWidgetItem();
|
||||
pluginitem->setData(0, Qt::UserRole, key);
|
||||
pluginitem->setCheckState(0, enable ? Qt::Checked : Qt::Unchecked);
|
||||
pluginitem->setText(1, kfmdplugin->genericName());
|
||||
pluginitem->setText(2, kfmdplugin->comment());
|
||||
pluginstree->addTopLevelItem(pluginitem);
|
||||
}
|
||||
pluginstree->resizeColumnToContents(0);
|
||||
pluginstree->resizeColumnToContents(1);
|
||||
pluginstree->resizeColumnToContents(2);
|
||||
}
|
||||
|
||||
loadMetaInfo();
|
||||
|
@ -104,10 +102,10 @@ void KCMMetaInfo::save()
|
|||
{
|
||||
KConfig config("kmetainformationrc", KConfig::NoGlobals);
|
||||
KConfigGroup pluginsgroup = config.group("Plugins");
|
||||
for (int i = 0; i < pluginstable->rowCount(); ++i) {
|
||||
QTableWidgetItem* item = pluginstable->item(i, 0);
|
||||
const bool enable = (item->checkState() == Qt::Checked);
|
||||
const QString key = item->data(Qt::UserRole).toString();
|
||||
for (int i = 0; i < pluginstree->topLevelItemCount(); ++i) {
|
||||
QTreeWidgetItem* item = pluginstree->topLevelItem(i);
|
||||
const bool enable = (item->checkState(0) == Qt::Checked);
|
||||
const QString key = item->data(0, Qt::UserRole).toString();
|
||||
pluginsgroup.writeEntry(key, enable);
|
||||
}
|
||||
|
||||
|
@ -125,9 +123,10 @@ void KCMMetaInfo::save()
|
|||
loadMetaInfo();
|
||||
}
|
||||
|
||||
void KCMMetaInfo::slotPluginItemChanged(QTableWidgetItem *item)
|
||||
void KCMMetaInfo::slotPluginItemChanged(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
Q_UNUSED(item);
|
||||
Q_UNUSED(column);
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
void save() final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotPluginItemChanged(QTableWidgetItem *item);
|
||||
void slotPluginItemChanged(QTreeWidgetItem *item, int column);
|
||||
void slotMetaItemChanged(QListWidgetItem *item);
|
||||
|
||||
private:
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Meta information shown in tooltips and properties dialogs.</p></body></html></string>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
|
@ -40,22 +40,21 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="pluginstable">
|
||||
<widget class="QTreeWidget" name="pluginstree">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Disabling undesired plugins can reduce the disk I/O during directory listing</p></body></html></string>
|
||||
<string><html><head/><body><p>Disabling undesired plugins can reduce the disk I/O during directory listing.</p></body></html></string>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">Use</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Plugin</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue