28 #include "../structuresmanager.h"
29 #include "../structtool.h"
31 #include <KFileDialog>
32 #include <KStandardDirs>
33 #include <KIO/NetAccess>
34 #include <KMessageBox>
35 #include <KPluginSelector>
36 #include <KConfigDialogManager>
37 #include <KPluginInfo>
38 #include <KPushButton>
41 #include <KNS3/KNewStuffButton>
43 #include <QtGui/QListWidgetItem>
44 #include <QtGui/QLayout>
45 #include <QtGui/QSizePolicy>
51 :
QWidget(parent), mTool(tool), mStructuresSelector(0), mRebuildingPluginsList(false)
53 KConfigDialogManager::changedMap()->insert(QLatin1String(
"StructuresManagerView"), SIGNAL(
changed(QStringList)));
54 setObjectName(QLatin1String(
"kcfg_LoadedStructures"));
57 QVBoxLayout* pageLayout =
new QVBoxLayout();
58 setLayout(pageLayout);
60 rebuildPluginSelectorEntries();
63 QHBoxLayout* buttonsLayout =
new QHBoxLayout();
64 pageLayout->addLayout(buttonsLayout);
66 mGetNewStructuresButton =
new KNS3::Button(i18n(
"Get New Structures..."),
67 QLatin1String(
"okteta-structures.knsrc"),
this);
68 connect(mGetNewStructuresButton, SIGNAL(dialogFinished(KNS3::Entry::List)),
70 buttonsLayout->addWidget(mGetNewStructuresButton);
72 mAdvancedSelectionButton =
new KPushButton(KIcon(QLatin1String(
"configure")), i18n(
"Advanced Selection..."),
this);
74 buttonsLayout->addWidget(mAdvancedSelectionButton);
79 foreach (
const KNS3::Entry& e, changedEntries)
81 kDebug() <<
"Changed Entry: " << e.name();
82 if (e.status() == KNS3::Entry::Installed)
85 kDebug() <<
"installed files:" << e.installedFiles();
87 if (e.status() == KNS3::Entry::Deleted)
90 kDebug() <<
"deleted files:" << e.uninstalledFiles();
93 if (!changedEntries.isEmpty())
95 kDebug() <<
"installed structures changed -> rebuilding list of installed structures";
97 rebuildPluginSelectorEntries();
103 return mSelectedStructures;
110 QPointer<KDialog> dlg =
new KDialog(
this);
111 dlg->setMainWidget(advancedSelectionWidget);
112 if (dlg->exec() == QDialog::Accepted) {
113 QStringList newVals = advancedSelectionWidget->
values();
114 if (newVals != mSelectedStructures) {
115 kDebug() <<
"selection changed from " << mSelectedStructures <<
"to" << newVals;
116 mSelectedStructures = newVals;
125 if (mRebuildingPluginsList)
127 kDebug() <<
"pluginselector changed: " << change;
130 mStructuresSelector->save();
131 reloadSelectedItems();
134 void StructuresManagerView::reloadSelectedItems() {
139 if (info.isPluginEnabled())
140 newVals.append(QString(QLatin1String(
"\'%1\':\'*\'")).arg(info.pluginName()));
142 if (newVals != mSelectedStructures) {
143 kDebug() <<
"selection changed from " << mSelectedStructures <<
"to" << newVals;
144 mSelectedStructures = newVals;
148 kDebug() <<
"no change:" << mSelectedStructures;
152 void StructuresManagerView::rebuildPluginSelectorEntries()
154 mRebuildingPluginsList =
true;
156 KPluginInfo::List plugins;
157 KPluginInfo::List dynamicPlugins;
161 if (info.category() == QLatin1String(
"structure"))
162 plugins.append(info);
163 else if (info.category() == QLatin1String(
"structure/js"))
164 dynamicPlugins.append(info);
168 QBoxLayout* layoutObj = qobject_cast<QBoxLayout*>(layout());
169 Q_CHECK_PTR(layoutObj);
170 if (mStructuresSelector)
172 layoutObj->removeWidget(mStructuresSelector);
173 delete mStructuresSelector;
175 mStructuresSelector =
new KPluginSelector(
this);
176 connect(mStructuresSelector, SIGNAL(
changed(
bool)),
178 layoutObj->insertWidget(0, mStructuresSelector);
180 mStructuresSelector->addPlugins(plugins, KPluginSelector::ReadConfigFile, i18n(
181 "Structure Definitions"), QLatin1String(
"structure"), mTool->
manager()->
config());
182 mStructuresSelector->addPlugins(dynamicPlugins, KPluginSelector::ReadConfigFile,
183 i18n(
"Dynamic Structure Definitions"), QLatin1String(
"structure/js"),
185 mStructuresSelector->load();
186 mStructuresSelector->updatePluginsState();
187 mRebuildingPluginsList =
false;
188 reloadSelectedItems();
void onPluginSelectorChange(bool change)
This class takes care of all the XML parsing and stores the result.
static const int FileNameRole
const QList< StructureDefinitionFile * > structureDefs() const
void onGetNewStructuresClicked(const KNS3::Entry::List &changedEntries)
StructuresManagerView(Kasten2::StructTool *manager, QWidget *parent=0)
void changed(QStringList newValues)
virtual ~StructuresManagerView()
KSharedConfig::Ptr config() const
static QStringList loadedStructures()
Get LoadedStructures.
const KPluginInfo & pluginInfo() const