summaryrefslogtreecommitdiffstats
path: root/kolf/editor.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitc90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch)
tree6d8391395bce9eaea4ad78958617edb20c6a7573 /kolf/editor.cpp
downloadtdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz
tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kolf/editor.cpp')
-rw-r--r--kolf/editor.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/kolf/editor.cpp b/kolf/editor.cpp
new file mode 100644
index 00000000..4cf6e61a
--- /dev/null
+++ b/kolf/editor.cpp
@@ -0,0 +1,60 @@
+#include <kdialog.h>
+#include <klistbox.h>
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qwidget.h>
+#include <qframe.h>
+
+#include "editor.h"
+#include "game.h"
+
+Editor::Editor(ObjectList *list, QWidget *parent, const char *name)
+ : QWidget(parent, name)
+{
+ this->list = list;
+ config = 0;
+
+ hlayout = new QHBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
+
+ QVBoxLayout *vlayout = new QVBoxLayout(hlayout, KDialog::spacingHint());
+ vlayout->addWidget(new QLabel(i18n("Add object:"), this));
+ listbox = new KListBox(this, "Listbox");
+ vlayout->addWidget(listbox);
+ hlayout->setStretchFactor(vlayout, 2);
+
+ QStringList items;
+ Object *obj = 0;
+ for (obj = list->first(); obj; obj = list->next())
+ items.append(obj->name());
+
+ listbox->insertStringList(items);
+
+ connect(listbox, SIGNAL(executed(QListBoxItem *)), SLOT(listboxExecuted(QListBoxItem *)));
+}
+
+void Editor::listboxExecuted(QListBoxItem * /*item*/)
+{
+ int curItem = listbox->currentItem();
+ if (curItem < 0)
+ return;
+
+ emit addNewItem(list->at(curItem));
+}
+
+void Editor::setItem(CanvasItem *item)
+{
+ delete config;
+ config = item->config(this);
+ if (!config)
+ return;
+ config->ctorDone();
+ hlayout->addWidget(config);
+ hlayout->setStretchFactor(config, 2);
+ config->setFrameStyle(QFrame::Box | QFrame::Raised);
+ config->setLineWidth(1);
+ config->show();
+ connect(config, SIGNAL(modified()), this, SIGNAL(changed()));
+}
+
+#include "editor.moc"