]> Shamusworld >> Repos - architektonas/blob - src/layerwidget.cpp
33221206a456172f62d28cebfb9b7a3374d1a941
[architektonas] / src / layerwidget.cpp
1 // layerwidget.cpp: Layer add/remove/use widget
2 //
3 // Part of the Architektonas Project
4 // (C) 2011 Underground Software
5 // See the README and GPLv3 files for licensing and warranty information
6 //
7 // JLH = James Hammons <jlhamm@acm.org>
8 //
9 // WHO  WHEN        WHAT
10 // ---  ----------  ------------------------------------------------------------
11 // JLH  07/11/2013  Created this file
12 //
13
14 #include "layerwidget.h"
15 #include "layeritemwidget.h"
16
17
18 LayerWidget::LayerWidget(void): QWidget(),
19         list(new QListWidget)
20 {
21         LayerItemWidget * liw = new LayerItemWidget("Background");
22         QListWidgetItem * qlwi = new QListWidgetItem(list);
23         list->setItemWidget(qlwi, liw);
24
25 #if 0
26         QPushButton * pb1 = new QPushButton("+");
27         QPushButton * pb2 = new QPushButton("-");
28         QPushButton * pb3 = new QPushButton("Edit");
29         QPushButton * pb4 = new QPushButton("^");
30         QPushButton * pb5 = new QPushButton("v");
31 #else
32         QToolButton * pb1 = new QToolButton;
33         QToolButton * pb2 = new QToolButton;
34         QToolButton * pb3 = new QToolButton;
35         QToolButton * pb4 = new QToolButton;
36         QToolButton * pb5 = new QToolButton;
37
38         pb1->setIcon(QIcon(":/res/layer-add.png"));
39         pb2->setIcon(QIcon(":/res/layer-delete.png"));
40         pb3->setIcon(QIcon(":/res/layer-edit.png"));
41         pb4->setIcon(QIcon(":/res/layer-up.png"));
42         pb5->setIcon(QIcon(":/res/layer-down.png"));
43
44         pb1->setToolTip(tr("Add layer"));
45         pb2->setToolTip(tr("Remove layer"));
46         pb3->setToolTip(tr("Edit layer"));
47         pb4->setToolTip(tr("Move layer up"));
48         pb5->setToolTip(tr("Move layer down"));
49 #endif
50
51         QHBoxLayout * hbox1 = new QHBoxLayout;
52         hbox1->addWidget(pb1);
53         hbox1->addWidget(pb2);
54         hbox1->addWidget(pb3);
55         hbox1->addWidget(pb4);
56         hbox1->addWidget(pb5);
57         hbox1->addStretch();
58
59         QVBoxLayout * mainLayout = new QVBoxLayout;
60         mainLayout->addWidget(list);
61         mainLayout->addLayout(hbox1);
62
63         setLayout(mainLayout);
64
65         connect(list, SIGNAL(currentRowChanged(int)), this, SLOT(HandleLayerSelected(int)));
66         list->setCurrentRow(4);
67         connect(pb1, SIGNAL(clicked()), this, SLOT(AddLayer()));
68         connect(pb2, SIGNAL(clicked()), this, SLOT(DeleteLayer()));
69         connect(pb3, SIGNAL(clicked()), this, SLOT(EditLayer()));
70         connect(pb4, SIGNAL(clicked()), this, SLOT(MoveLayerUp()));
71         connect(pb5, SIGNAL(clicked()), this, SLOT(MoveLayerDown()));
72 }
73
74
75 LayerWidget::~LayerWidget()
76 {
77 }
78
79
80 void LayerWidget::HandleLayerSelected(int currentRow)
81 {
82 //printf("LayerWidget::HandleLayerSelected(): currentRow = %i\n", currentRow);
83         emit(LayerSelected(currentRow));
84 }
85
86
87 void LayerWidget::AddLayer(void)
88 {
89         int count = list->count();
90         QString text = QString("Layer #%1").arg(count);
91         LayerItemWidget * liw = new LayerItemWidget(text);
92         QListWidgetItem * qlwi = new QListWidgetItem();
93         list->insertItem(0, qlwi);
94         list->setItemWidget(qlwi, liw);
95 }
96
97
98 void LayerWidget::DeleteLayer(void)
99 {
100 }
101
102
103 void LayerWidget::EditLayer(void)
104 {
105 }
106
107
108 void LayerWidget::MoveLayerUp(void)
109 {
110 }
111
112
113 void LayerWidget::MoveLayerDown(void)
114 {
115 }
116