put the current containment actions in a ConfigModel

This commit is contained in:
Marco Martin 2013-08-23 16:31:09 +02:00
parent d025f583b2
commit 0502f8f972
3 changed files with 25 additions and 12 deletions

View File

@ -41,6 +41,7 @@ ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow
m_containment(cont),
m_wallpaperConfigModel(0),
m_containmentActionConfigModel(0),
m_currentContainmentActionConfigModel(0),
m_currentWallpaperConfig(0),
m_ownWallpaperConfig(0)
{
@ -89,18 +90,24 @@ ConfigModel *ContainmentConfigView::containmentActionConfigModel()
return m_containmentActionConfigModel;
}
QVariantMap ContainmentConfigView::currentContainmentActions() const
ConfigModel *ContainmentConfigView::currentContainmentActionConfigModel()
{
QHash<QString, Plasma::ContainmentActions*> actions = m_containment->containmentActions();
if (!m_currentContainmentActionConfigModel) {
m_currentContainmentActionConfigModel = new ConfigModel(this);
QVariantMap actionsMap;
QHash<QString, Plasma::ContainmentActions*> actions = m_containment->containmentActions();
QHash<QString, Plasma::ContainmentActions*>::const_iterator i = actions.constBegin();
while (i != actions.constEnd()) {
actionsMap[i.key()] = i.value()->pluginInfo().name();
QHashIterator<QString, Plasma::ContainmentActions*> i(actions);
while (i.hasNext()) {
i.next();
ConfigCategory *cat = new ConfigCategory(m_currentContainmentActionConfigModel);
cat->setName(i.key());
cat->setPluginName(i.value()->pluginInfo().name());
m_currentContainmentActionConfigModel->appendCategory(cat);
}
}
return actionsMap;
return m_currentContainmentActionConfigModel;
}
ConfigModel *ContainmentConfigView::wallpaperConfigModel()

View File

@ -34,7 +34,7 @@ class ContainmentConfigView : public ConfigView
{
Q_OBJECT
Q_PROPERTY(ConfigModel *containmentActionConfigModel READ containmentActionConfigModel CONSTANT)
Q_PROPERTY(QVariantMap currentContainmentActions READ currentContainmentActions NOTIFY currentContainmentActionsChanged)
Q_PROPERTY(ConfigModel *currentContainmentActionConfigModel READ currentContainmentActionConfigModel CONSTANT)
Q_PROPERTY(ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT)
Q_PROPERTY(ConfigPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged)
Q_PROPERTY(QString currentWallpaper READ currentWallpaper WRITE setCurrentWallpaper NOTIFY currentWallpaperChanged)
@ -46,7 +46,7 @@ public:
virtual void init();
ConfigModel *containmentActionConfigModel();
QVariantMap currentContainmentActions() const;
ConfigModel *currentContainmentActionConfigModel();
ConfigModel *wallpaperConfigModel();
QString currentWallpaper() const;
void setCurrentWallpaper(const QString &wallpaper);
@ -57,7 +57,6 @@ public:
Q_SIGNALS:
void currentWallpaperChanged();
void wallpaperConfigurationChanged();
void currentContainmentActionsChanged();
protected:
void syncWallpaperObjects();
@ -66,6 +65,7 @@ private:
Plasma::Containment *m_containment;
ConfigModel *m_wallpaperConfigModel;
ConfigModel *m_containmentActionConfigModel;
ConfigModel *m_currentContainmentActionConfigModel;
QString m_currentWallpaper;
ConfigPropertyMap *m_currentWallpaperConfig;
ConfigPropertyMap *m_ownWallpaperConfig;

View File

@ -31,7 +31,7 @@ Item {
anchors.centerIn: parent
Repeater {
model: 3
model: configDialog.currentContainmentActionConfigModel
delegate: RowLayout {
width: root.width * 0.8
QtControls.Button {
@ -58,6 +58,12 @@ Item {
}
QtControls.Button {
text: "Add Action"
onClicked: {
for (var i in configDialog.currentContainmentActions) {
print("AAA"+i+configDialog.currentContainmentActions[i])
}
print(configDialog.currentContainmentActions)
}
}
}