summaryrefslogtreecommitdiffstats
path: root/sigmodr/StoreUI.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-01-19 15:07:57 -0500
committerBen Boeckel <MathStuf@gmail.com>2009-01-19 15:07:57 -0500
commitf29ead61b6d17aa30b6d2400798e8dd063f6df7a (patch)
treee67a58af6ead4e51e811e991dc83aa893e0b30a6 /sigmodr/StoreUI.cpp
parentf01492862f2055d64b4b0b8cd433a909864eb17d (diff)
downloadsigen-f29ead61b6d17aa30b6d2400798e8dd063f6df7a.tar.gz
sigen-f29ead61b6d17aa30b6d2400798e8dd063f6df7a.tar.xz
sigen-f29ead61b6d17aa30b6d2400798e8dd063f6df7a.zip
Changed Store item editing to use KActionSelector
Diffstat (limited to 'sigmodr/StoreUI.cpp')
-rw-r--r--sigmodr/StoreUI.cpp41
1 files changed, 31 insertions, 10 deletions
diff --git a/sigmodr/StoreUI.cpp b/sigmodr/StoreUI.cpp
index d280d2d3..32642dad 100644
--- a/sigmodr/StoreUI.cpp
+++ b/sigmodr/StoreUI.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
+ * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,9 @@
#include "../sigmod/Sigmod.h"
#include "../sigmod/Store.h"
+// Qt includes
+#include <QtGui/QListWidgetItem>
+
Sigmodr::StoreUI::StoreUI(Sigmod::Store* store, QWidget* parent) :
ObjectUI(parent)
{
@@ -36,25 +39,35 @@ Sigmodr::StoreUI::~StoreUI()
void Sigmodr::StoreUI::refreshGui()
{
- const bool blocked = varItems->blockSignals(true);
- varItems->clear();
+ const bool blockedItems = varItems->blockSignals(true);
+ varItems->availableListWidget()->clear();
+ varItems->selectedListWidget()->clear();
for (int i = 0; i < sigmod()->itemCount(); ++i)
{
const Sigmod::Item* item = sigmod()->item(i);
- QListWidgetItem* widgetItem = new QListWidgetItem(item->name(), varItems);
+ QListWidgetItem* widgetItem = new QListWidgetItem(item->name(), varItems->availableListWidget());
widgetItem->setData(Qt::UserRole, item->id());
}
- varItems->blockSignals(blocked);
+ varItems->blockSignals(blockedItems);
+ varItems->setButtonsEnabled();
}
void Sigmodr::StoreUI::setGui()
{
varName->setText(qobject_cast<Sigmod::Store*>(modified())->name());
- for (int i = 0; i < varItems->count(); ++i)
+ for (int i = 0; i < varItems->availableListWidget()->count(); ++i)
+ {
+ QListWidgetItem* widgetItem = varItems->availableListWidget()->item(i);
+ if (qobject_cast<Sigmod::Store*>(modified())->item(widgetItem->data(Qt::UserRole).toInt()))
+ varItems->selectedListWidget()->addItem(varItems->availableListWidget()->takeItem(i--));
+ }
+ for (int i = 0; i < varItems->selectedListWidget()->count(); ++i)
{
- QListWidgetItem* widgetItem = varItems->item(i);
- widgetItem->setSelected(qobject_cast<Sigmod::Store*>(modified())->item(widgetItem->data(Qt::UserRole).toInt()));
+ QListWidgetItem* widgetItem = varItems->selectedListWidget()->item(i);
+ if (!qobject_cast<Sigmod::Store*>(modified())->item(widgetItem->data(Qt::UserRole).toInt()))
+ varItems->availableListWidget()->addItem(varItems->selectedListWidget()->takeItem(i--));
}
+ varItems->setButtonsEnabled();
}
void Sigmodr::StoreUI::apply()
@@ -77,7 +90,15 @@ void Sigmodr::StoreUI::on_varName_textChanged(const QString& name)
varName->setCursorPosition(cursor);
}
-void Sigmodr::StoreUI::on_varItems_itemClicked(QListWidgetItem* item)
+void Sigmodr::StoreUI::on_varItems_added(QListWidgetItem* item)
{
- qobject_cast<Sigmod::Store*>(modified())->setItem(item->data(Qt::UserRole).toInt(), item->isSelected());
+ qobject_cast<Sigmod::Store*>(modified())->setItem(item->data(Qt::UserRole).toInt(), true);
+ setGui();
}
+
+void Sigmodr::StoreUI::on_varItems_removed(QListWidgetItem* item)
+{
+ qobject_cast<Sigmod::Store*>(modified())->setItem(item->data(Qt::UserRole).toInt(), false);
+ setGui();
+}
+