]> Shamusworld >> Repos - architektonas/blob - src/layerwidget.cpp
Added layer attribute to load/save code.
[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/generic-tool.png"));
39         pb2->setIcon(QIcon(":/res/generic-tool.png"));
40         pb3->setIcon(QIcon(":/res/generic-tool.png"));
41         pb4->setIcon(QIcon(":/res/generic-tool.png"));
42         pb5->setIcon(QIcon(":/res/generic-tool.png"));
43 #endif
44
45         QHBoxLayout * hbox1 = new QHBoxLayout;
46         hbox1->addWidget(pb1);
47         hbox1->addWidget(pb2);
48         hbox1->addWidget(pb3);
49         hbox1->addWidget(pb4);
50         hbox1->addWidget(pb5);
51         hbox1->addStretch();
52
53         QVBoxLayout * mainLayout = new QVBoxLayout;
54         mainLayout->addWidget(list);
55         mainLayout->addLayout(hbox1);
56
57         setLayout(mainLayout);
58
59         connect(list, SIGNAL(currentRowChanged(int)), this, SLOT(HandleLayerSelected(int)));
60         list->setCurrentRow(4);
61         connect(pb1, SIGNAL(clicked()), this, SLOT(AddLayer()));
62         connect(pb2, SIGNAL(clicked()), this, SLOT(DeleteLayer()));
63         connect(pb3, SIGNAL(clicked()), this, SLOT(EditLayer()));
64         connect(pb4, SIGNAL(clicked()), this, SLOT(MoveLayerUp()));
65         connect(pb5, SIGNAL(clicked()), this, SLOT(MoveLayerDown()));
66 }
67
68
69 LayerWidget::~LayerWidget()
70 {
71 }
72
73
74 void LayerWidget::HandleLayerSelected(int currentRow)
75 {
76 //printf("LayerWidget::HandleLayerSelected(): currentRow = %i\n", currentRow);
77         emit(LayerSelected(currentRow));
78 }
79
80
81 void LayerWidget::AddLayer(void)
82 {
83         int count = list->count();
84         QString text = QString("Layer #%1").arg(count);
85         LayerItemWidget * liw = new LayerItemWidget(text);
86         QListWidgetItem * qlwi = new QListWidgetItem();
87         list->insertItem(0, qlwi);
88         list->setItemWidget(qlwi, liw);
89 }
90
91
92 void LayerWidget::DeleteLayer(void)
93 {
94 }
95
96
97 void LayerWidget::EditLayer(void)
98 {
99 }
100
101
102 void LayerWidget::MoveLayerUp(void)
103 {
104 }
105
106
107 void LayerWidget::MoveLayerDown(void)
108 {
109 }
110