1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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"
|