From 2e52bea24a65cf70380c4e13c2f9f1238f023e91 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 6 Sep 2012 00:31:19 +0200 Subject: some black magic involving templates which doesn't even work, pushing so I can work on it at home --- lsseteditor.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lsseteditor.cpp (limited to 'lsseteditor.cpp') diff --git a/lsseteditor.cpp b/lsseteditor.cpp new file mode 100644 index 0000000..bc63476 --- /dev/null +++ b/lsseteditor.cpp @@ -0,0 +1,60 @@ +#include "lsseteditor.h" +#include +#include + +_LSSetEditorBase::_LSSetEditorBase(int maxEntries, QWidget *parent) : + QWidget(parent) { + + m_maxEntries = maxEntries; + m_loadingThings = 0; +} + + +void _LSSetEditorBase::handleEntrySelected(int index) { + if (!m_loadingThings) + showEntry(index); +} + + +void _LSSetEditorBase::handleEntryCountChanged(int count) { + if (!m_loadingThings) { + int oldCount = m_chooser->count(); + if (oldCount == count) + return; + + changeEntryCountTo(count); + resizeDataListTo(count); + + // moving from 0 to something...? + if (oldCount == 0) { + m_chooser->setCurrentIndex(0); + showEntry(0); + } + + emit dataEdited(); + } +} + + +void _LSSetEditorBase::setup(QWidget *eWidget) { + m_loadingThings++; + + m_entryCount = new QSpinBox(this); + m_entryCount->setRange(0, m_maxEntries); + connect(m_entryCount, SIGNAL(valueChanged(int)), SLOT(handleEntryCountChanged(int))); + + m_chooser = new QComboBox(this); + connect(m_chooser, SIGNAL(currentIndexChanged(int)), SLOT(handleEntrySelected(int))); + + QGridLayout *layout = new QGridLayout(this); + + layout->addWidget(new QLabel("Count:", this), 0, 0, 1, 1); + layout->addWidget(m_entryCount, 0, 1, 1, 1); + layout->setColumnMinimumWidth(2, 10); + layout->addWidget(m_chooser, 0, 3, 1, 1); + layout->setColumnStretch(3, 1); + + layout->addWidget(eWidget, 1, 0, 1, 4); + + m_loadingThings--; +} -- cgit v1.2.3