improved button manager basics
This commit is contained in:
parent
f9d0c36402
commit
baa5ddb98b
|
@ -1,6 +1,11 @@
|
|||
#include "buttonmanager.h"
|
||||
#include "ui_buttonmanager.h"
|
||||
|
||||
// itemtypes
|
||||
const static int ROWTYPE = 1000;
|
||||
const static int BUTTONTYPE = 1001;
|
||||
const static int SAMPLETYPE = 1002;
|
||||
|
||||
ButtonManager::ButtonManager(const Config& conf, QWidget *parent) : QDialog(parent), ui(new Ui::ButtonManager), mainConfig(conf) {
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -8,13 +13,13 @@ ButtonManager::ButtonManager(const Config& conf, QWidget *parent) : QDialog(pare
|
|||
QList<QTreeWidgetItem*> items;
|
||||
for(uint8_t rownr = 0; rownr < conf.rootConfig.buttons.size(); ++rownr) {
|
||||
const std::vector<Config::ButtonConfig>& btnrow = conf.rootConfig.buttons.at(rownr);
|
||||
QTreeWidgetItem* row = new QTreeWidgetItem(1000);
|
||||
QTreeWidgetItem* row = new QTreeWidgetItem(ROWTYPE);
|
||||
row->setData(0, 0, QVariant((int) rownr+1));
|
||||
items.push_back(row);
|
||||
|
||||
// iterate buttons in a row
|
||||
for(const Config::ButtonConfig& btn : btnrow) {
|
||||
QTreeWidgetItem* qbtn = new QTreeWidgetItem(1001);
|
||||
QTreeWidgetItem* qbtn = new QTreeWidgetItem(BUTTONTYPE);
|
||||
qbtn->setData(1, 0, QVariant(QString::fromStdString(btn.name)));
|
||||
qbtn->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
||||
row->addChild(qbtn);
|
||||
|
@ -22,8 +27,9 @@ ButtonManager::ButtonManager(const Config& conf, QWidget *parent) : QDialog(pare
|
|||
// iterate samples in a button
|
||||
for(uint8_t samplenr = 0; samplenr < btn.samples.size(); ++samplenr) {
|
||||
const Config::SampleConfig& sample = btn.samples.at(samplenr);
|
||||
QTreeWidgetItem* qsample = new QTreeWidgetItem(1002);
|
||||
QTreeWidgetItem* qsample = new QTreeWidgetItem(SAMPLETYPE);
|
||||
qsample->setData(2, 0, QVariant((int) samplenr+1));
|
||||
qsample->setData(3, 0, QVariant(QString::fromStdString(sample.file)));
|
||||
qbtn->addChild(qsample);
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +39,7 @@ ButtonManager::ButtonManager(const Config& conf, QWidget *parent) : QDialog(pare
|
|||
labels.push_back("Row");
|
||||
labels.push_back("Button");
|
||||
labels.push_back("Sample");
|
||||
labels.push_back("File");
|
||||
|
||||
ui->buttonTreeWidget->addTopLevelItems(items);
|
||||
ui->buttonTreeWidget->setHeaderLabels(labels);
|
||||
|
|
|
@ -6,33 +6,78 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>888</width>
|
||||
<height>744</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Button Manager</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="deleteButton">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="moveDownButton">
|
||||
<property name="text">
|
||||
<string>Down</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="moveUpButton">
|
||||
<property name="text">
|
||||
<string>Up</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="6">
|
||||
<widget class="QTreeWidget" name="buttonTreeWidget">
|
||||
<property name="columnCount">
|
||||
<number>1</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">2</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">3</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="editButton">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue