#include "layeritemwidget.h"
-LayerItemWidget::LayerItemWidget(QString s, bool invisible/*=false*/, bool locked/*=false*/):
+LayerItemWidget::LayerItemWidget(QString s, bool i/*=false*/, bool l/*=false*/, QListWidgetItem * p/*=null*/):
QWidget(),
name(new QLabel(s)),
- visibility(new QPushButton),
- editibility(new QPushButton)
+ invisible(new QPushButton),
+ locked(new QPushButton),
+ parent(p)
{
QIcon visibleIcon(":/res/eye-open.png");
visibleIcon.addFile(":/res/eye-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On);
QSize buttonSize(20, 20);
QHBoxLayout * mainLayout = new QHBoxLayout;
- mainLayout->setContentsMargins(0, 0, 0, 0); // This is required, otherwise the layout engine puts too much space around this widget. :-/
-
- visibility->setFlat(true);
- visibility->setIcon(visibleIcon);
- visibility->setCheckable(true);
- visibility->setMaximumSize(buttonSize);
- visibility->setChecked(invisible);
-
- editibility->setFlat(true);
- editibility->setIcon(lockedIcon);
- editibility->setCheckable(true);
- editibility->setMaximumSize(buttonSize);
- editibility->setChecked(locked);
-
- mainLayout->addWidget(visibility);
- mainLayout->addWidget(editibility);
+ // This is required, otherwise the layout engine puts too much space around
+ // this widget. :-/
+ mainLayout->setContentsMargins(0, 0, 0, 0);
+
+ invisible->setFlat(true);
+ invisible->setIcon(visibleIcon);
+ invisible->setCheckable(true);
+ invisible->setMaximumSize(buttonSize);
+ invisible->setChecked(i);
+
+ locked->setFlat(true);
+ locked->setIcon(lockedIcon);
+ locked->setCheckable(true);
+ locked->setMaximumSize(buttonSize);
+ locked->setChecked(l);
+
+ mainLayout->addWidget(invisible);
+ mainLayout->addWidget(locked);
mainLayout->addWidget(name);
setLayout(mainLayout);
+
+ connect(invisible, SIGNAL(clicked(bool)), this, SLOT(HandleHideToggle(bool)));
+ connect(locked, SIGNAL(clicked(bool)), this, SLOT(HandleLockToggle(bool)));
}
{
}
+
+void LayerItemWidget::HandleHideToggle(bool state)
+{
+// printf("Eye is: %s\n", !state ? "OPEN" : "closed");
+ emit HideToggled(parent, state);
+}
+
+
+void LayerItemWidget::HandleLockToggle(bool state)
+{
+// printf("Lock is: %s\n", !state ? "OPEN" : "closed");
+ emit LockToggled(parent, state);
+}
+