X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flayerwidget.cpp;h=33221206a456172f62d28cebfb9b7a3374d1a941;hb=771113b26ca27707c96fdcd80d79a08e40884268;hp=b45eed6a6da6a2f167ed0d2f3f7914331e4b3e3f;hpb=a7a9909f617d5dbcebfc6d4baa7053dbe3961751;p=architektonas diff --git a/src/layerwidget.cpp b/src/layerwidget.cpp index b45eed6..3322120 100644 --- a/src/layerwidget.cpp +++ b/src/layerwidget.cpp @@ -15,75 +15,60 @@ #include "layeritemwidget.h" -#if 0 -OK, what it seems like we should do here, is instead of deriving from QDockWidget, -we should derive from QWidget (or QScrollArea or somesuch). Then, when creating -the dockwidget in the main window, we add the LayerWidget as the QDockWidget's -main widget. -#endif - -LayerWidget::LayerWidget(void): QWidget() +LayerWidget::LayerWidget(void): QWidget(), + list(new QListWidget) { + LayerItemWidget * liw = new LayerItemWidget("Background"); + QListWidgetItem * qlwi = new QListWidgetItem(list); + list->setItemWidget(qlwi, liw); - // Make a QScrollArea, put in a QVBoxLayout. - // Use line widget (two checkboxes, one label), use setIcon() on the - // checkboxes to change their look (eye open/closed for visibility, - // lock open/closed for layer lock). +#if 0 + QPushButton * pb1 = new QPushButton("+"); + QPushButton * pb2 = new QPushButton("-"); + QPushButton * pb3 = new QPushButton("Edit"); + QPushButton * pb4 = new QPushButton("^"); + QPushButton * pb5 = new QPushButton("v"); +#else + QToolButton * pb1 = new QToolButton; + QToolButton * pb2 = new QToolButton; + QToolButton * pb3 = new QToolButton; + QToolButton * pb4 = new QToolButton; + QToolButton * pb5 = new QToolButton; + + pb1->setIcon(QIcon(":/res/layer-add.png")); + pb2->setIcon(QIcon(":/res/layer-delete.png")); + pb3->setIcon(QIcon(":/res/layer-edit.png")); + pb4->setIcon(QIcon(":/res/layer-up.png")); + pb5->setIcon(QIcon(":/res/layer-down.png")); + + pb1->setToolTip(tr("Add layer")); + pb2->setToolTip(tr("Remove layer")); + pb3->setToolTip(tr("Edit layer")); + pb4->setToolTip(tr("Move layer up")); + pb5->setToolTip(tr("Move layer down")); +#endif - QIcon visible(":/res/eye-open.png"); - visible.addFile(":/res/eye-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On); - QIcon locked(":/res/lock-open.png"); - locked.addFile(":/res/lock-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On); + QHBoxLayout * hbox1 = new QHBoxLayout; + hbox1->addWidget(pb1); + hbox1->addWidget(pb2); + hbox1->addWidget(pb3); + hbox1->addWidget(pb4); + hbox1->addWidget(pb5); + hbox1->addStretch(); QVBoxLayout * mainLayout = new QVBoxLayout; - QHBoxLayout * line1 = new QHBoxLayout; - QHBoxLayout * line2 = new QHBoxLayout; - -// QCheckBox * box1 = new QCheckBox("bleah"); -// box1->setIcon(visible); -// mainLayout->addWidget(box1); - - QPushButton * button1 = new QPushButton; - button1->setFlat(true); - button1->setIcon(visible); - button1->setCheckable(true); - button1->setMaximumSize(QSize(20, 20)); - QPushButton * button2 = new QPushButton; - button2->setFlat(true); - button2->setIcon(locked); - button2->setCheckable(true); - button2->setMaximumSize(QSize(20, 20)); - QLabel * label1 = new QLabel("Background"); - - QPushButton * button3 = new QPushButton; - button3->setFlat(true); - button3->setIcon(visible); - button3->setCheckable(true); - button3->setMaximumSize(QSize(20, 20)); - QPushButton * button4 = new QPushButton; - button4->setFlat(true); - button4->setIcon(locked); - button4->setCheckable(true); - button4->setMaximumSize(QSize(20, 20)); - QLabel * label2 = new QLabel("Guides"); - - line1->addWidget(button1); - line1->addWidget(button2); - line1->addWidget(label1); - - line2->addWidget(button3); - line2->addWidget(button4); - line2->addWidget(label2); - - LayerItemWidget * liw1 = new LayerItemWidget("Floor #1"); - LayerItemWidget * liw2 = new LayerItemWidget("Mechanical"); - - mainLayout->addLayout(line1); - mainLayout->addLayout(line2); - mainLayout->addWidget(liw1); - mainLayout->addWidget(liw2); - mainLayout->addStretch(); + mainLayout->addWidget(list); + mainLayout->addLayout(hbox1); + setLayout(mainLayout); + + connect(list, SIGNAL(currentRowChanged(int)), this, SLOT(HandleLayerSelected(int))); + list->setCurrentRow(4); + connect(pb1, SIGNAL(clicked()), this, SLOT(AddLayer())); + connect(pb2, SIGNAL(clicked()), this, SLOT(DeleteLayer())); + connect(pb3, SIGNAL(clicked()), this, SLOT(EditLayer())); + connect(pb4, SIGNAL(clicked()), this, SLOT(MoveLayerUp())); + connect(pb5, SIGNAL(clicked()), this, SLOT(MoveLayerDown())); } @@ -91,3 +76,41 @@ LayerWidget::~LayerWidget() { } + +void LayerWidget::HandleLayerSelected(int currentRow) +{ +//printf("LayerWidget::HandleLayerSelected(): currentRow = %i\n", currentRow); + emit(LayerSelected(currentRow)); +} + + +void LayerWidget::AddLayer(void) +{ + int count = list->count(); + QString text = QString("Layer #%1").arg(count); + LayerItemWidget * liw = new LayerItemWidget(text); + QListWidgetItem * qlwi = new QListWidgetItem(); + list->insertItem(0, qlwi); + list->setItemWidget(qlwi, liw); +} + + +void LayerWidget::DeleteLayer(void) +{ +} + + +void LayerWidget::EditLayer(void) +{ +} + + +void LayerWidget::MoveLayerUp(void) +{ +} + + +void LayerWidget::MoveLayerDown(void) +{ +} +