]> Shamusworld >> Repos - architektonas/commitdiff
Initial work on BlockWidget.
authorShamus Hammons <jlhamm@acm.org>
Mon, 15 Jul 2013 17:08:06 +0000 (12:08 -0500)
committerShamus Hammons <jlhamm@acm.org>
Mon, 15 Jul 2013 17:08:06 +0000 (12:08 -0500)
architektonas.pro
src/applicationwindow.cpp
src/blockitemwidget.cpp [new file with mode: 0644]
src/blockitemwidget.h [new file with mode: 0644]
src/blockwidget.cpp
src/blockwidget.h

index 65afe20edbd673fffd69ecd6a034aec577de8007..108fba74736dd8bff77163fc9c75c3fe651ff93f 100644 (file)
@@ -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 \
index 3bbbade8e8474bd31e03cdc89e11f02efd00fc46..efd661c82d2f066a00d9ff12b1561a9d93b02e42 100644 (file)
@@ -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 (file)
index 0000000..ea786f9
--- /dev/null
@@ -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 <jlhamm@acm.org>
+//
+// 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 (file)
index 0000000..f703fbf
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef __BLOCKITEMWIDGET_H__
+#define __BLOCKITEMWIDGET_H__
+
+#include <QtGui>
+
+class BlockItemWidget: public QWidget
+{
+       Q_OBJECT
+
+       public:
+               BlockItemWidget(QString, QPixmap * i = 0);
+               ~BlockItemWidget();
+
+       public:
+               QLabel * name;
+               QLabel * image;
+};
+
+#endif // __BLOCKITEMWIDGET_H__
index 3e1e4d88a399670190469b1efe9c82f6d7a4dec0..cd08070570717f6b8542f55eb2ced6ffdcbd1c25 100644 (file)
@@ -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()
+{
+}
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ce53b9b87a2cf46db5c1f5da1e62d9438683e526 100644 (file)
@@ -0,0 +1,16 @@
+#ifndef __BLOCKWIDGET_H__
+#define __BLOCKWIDGET_H__
+
+#include <QtGui>
+
+class BlockWidget: public QWidget
+{
+       Q_OBJECT
+
+       public:
+               BlockWidget(void);
+               ~BlockWidget();
+
+};
+
+#endif // __BLOCKWIDGET_H__