From: Shamus Hammons Date: Mon, 15 Jul 2013 17:08:06 +0000 (-0500) Subject: Initial work on BlockWidget. X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=architektonas;a=commitdiff_plain;h=8ab4e08bd78cb5b07f069e3e6c5bf76944cb14fa Initial work on BlockWidget. --- diff --git a/architektonas.pro b/architektonas.pro index 65afe20..108fba7 100644 --- a/architektonas.pro +++ b/architektonas.pro @@ -45,6 +45,7 @@ HEADERS = \ src/action.h \ src/applicationwindow.h \ src/arc.h \ + src/blockitemwidget.h \ src/blockwidget.h \ src/circle.h \ src/connection.h \ @@ -74,6 +75,7 @@ SOURCES = \ src/action.cpp \ src/applicationwindow.cpp \ src/arc.cpp \ + src/blockitemwidget.cpp \ src/blockwidget.cpp \ src/circle.cpp \ src/connection.cpp \ diff --git a/src/applicationwindow.cpp b/src/applicationwindow.cpp index 3bbbade..efd661c 100644 --- a/src/applicationwindow.cpp +++ b/src/applicationwindow.cpp @@ -61,8 +61,8 @@ ApplicationWindow::ApplicationWindow(): settings("Underground Software", "Archit dock1->setWidget(lw); addDockWidget(Qt::RightDockWidgetArea, dock1); QDockWidget * dock2 = new QDockWidget(tr("Blocks"), this); -// BlockWidget * bw = new BlockWidget; -// dock2->setWidget(bw); + BlockWidget * bw = new BlockWidget; + dock2->setWidget(bw); addDockWidget(Qt::RightDockWidgetArea, dock2); // Needed for saveState() dock1->setObjectName("Layers"); diff --git a/src/blockitemwidget.cpp b/src/blockitemwidget.cpp new file mode 100644 index 0000000..ea786f9 --- /dev/null +++ b/src/blockitemwidget.cpp @@ -0,0 +1,49 @@ +// layeritemwidget.cpp: Layer item widget +// +// Part of the Architektonas Project +// (C) 2011 Underground Software +// See the README and GPLv3 files for licensing and warranty information +// +// JLH = James Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 07/13/2013 Created this file +// + +#include "blockitemwidget.h" + + +BlockItemWidget::BlockItemWidget(QString s, QPixmap * i/*=0*/): + QWidget(), + name(new QLabel(s)), + image(new QLabel) +{ + QHBoxLayout * mainLayout = new QHBoxLayout; + mainLayout->setContentsMargins(0, 0, 0, 0); // This is required, otherwise the layout engine puts too much space around this widget. :-/ + + if (i == 0) + { + i = new QPixmap(36, 32); + i->fill(); // Fills pixmap with white + QPainter p(i); + p.setPen(Qt::black); + p.drawLine(0, 0, 31, 31); + p.drawLine(0, 31, 31, 0); + } + + image->setPixmap(*i); + + mainLayout->addWidget(image); + mainLayout->addWidget(name); + mainLayout->addStretch(); + setLayout(mainLayout); +QSize size = mainLayout->sizeHint(); +printf("BlockItemWidget: size. w=%i, h=%i\n", size.width(), size.height()); +} + + +BlockItemWidget::~BlockItemWidget() +{ +} + diff --git a/src/blockitemwidget.h b/src/blockitemwidget.h new file mode 100644 index 0000000..f703fbf --- /dev/null +++ b/src/blockitemwidget.h @@ -0,0 +1,19 @@ +#ifndef __BLOCKITEMWIDGET_H__ +#define __BLOCKITEMWIDGET_H__ + +#include + +class BlockItemWidget: public QWidget +{ + Q_OBJECT + + public: + BlockItemWidget(QString, QPixmap * i = 0); + ~BlockItemWidget(); + + public: + QLabel * name; + QLabel * image; +}; + +#endif // __BLOCKITEMWIDGET_H__ diff --git a/src/blockwidget.cpp b/src/blockwidget.cpp index 3e1e4d8..cd08070 100644 --- a/src/blockwidget.cpp +++ b/src/blockwidget.cpp @@ -8,7 +8,61 @@ // // WHO WHEN WHAT // --- ---------- ------------------------------------------------------------ -// JLH 07/11/2013 Created this file +// JLH 07/15/2013 Created this file // #include "blockwidget.h" +#include "blockitemwidget.h" + + +BlockWidget::BlockWidget(void): QWidget() +{ + BlockItemWidget * biw1 = new BlockItemWidget("2x4"); + BlockItemWidget * biw2 = new BlockItemWidget("2x6"); + BlockItemWidget * biw3 = new BlockItemWidget("36\" door RHS"); + BlockItemWidget * biw4 = new BlockItemWidget("36\" door LHS"); + BlockItemWidget * biw5 = new BlockItemWidget("Person"); + + QListWidget * qlw = new QListWidget; + QListWidgetItem * qli1 = new QListWidgetItem(qlw); + QListWidgetItem * qli2 = new QListWidgetItem(qlw); + QListWidgetItem * qli3 = new QListWidgetItem(qlw); + QListWidgetItem * qli4 = new QListWidgetItem(qlw); + QListWidgetItem * qli5 = new QListWidgetItem(qlw); + qli1->setSizeHint(biw1->sizeHint()); + qli2->setSizeHint(biw2->sizeHint()); + qli3->setSizeHint(biw3->sizeHint()); + qli4->setSizeHint(biw4->sizeHint()); + qli5->setSizeHint(biw5->sizeHint()); + qlw->setItemWidget(qli1, biw1); + qlw->setItemWidget(qli2, biw2); + qlw->setItemWidget(qli3, biw3); + qlw->setItemWidget(qli4, biw4); + qlw->setItemWidget(qli5, biw5); + + QPushButton * pb1 = new QPushButton("+"); + QPushButton * pb2 = new QPushButton("-"); + QPushButton * pb3 = new QPushButton("Edit"); + QPushButton * pb4 = new QPushButton("Import"); +// QPushButton * pb5 = new QPushButton("v"); + + 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; + mainLayout->addWidget(qlw); + mainLayout->addLayout(hbox1); + + setLayout(mainLayout); +} + + +BlockWidget::~BlockWidget() +{ +} + diff --git a/src/blockwidget.h b/src/blockwidget.h index e69de29..ce53b9b 100644 --- a/src/blockwidget.h +++ b/src/blockwidget.h @@ -0,0 +1,16 @@ +#ifndef __BLOCKWIDGET_H__ +#define __BLOCKWIDGET_H__ + +#include + +class BlockWidget: public QWidget +{ + Q_OBJECT + + public: + BlockWidget(void); + ~BlockWidget(); + +}; + +#endif // __BLOCKWIDGET_H__