forked from MrBesen/soundboard
add empty row, fixed bug in delete row
This commit is contained in:
parent
87985abaa0
commit
3c0648f435
|
@ -40,6 +40,10 @@ void ButtonManager::addButton() {
|
|||
AddNewWhat::ReturnCode type = whatshouldbeadded.returnCode;
|
||||
if(type == AddNewWhat::ReturnCode::Row) {
|
||||
// create new row
|
||||
//TODO: when a row is selected: add after the selected row
|
||||
workingConfig.buttons.push_back({}); // create a empty vector
|
||||
RowItem* row = new RowItem(ui->buttonTreeWidget->invisibleRootItem(), workingConfig.buttons.size()-1, workingConfig);
|
||||
|
||||
return;
|
||||
}
|
||||
if(type == AddNewWhat::ReturnCode::Button) {
|
||||
|
|
|
@ -74,14 +74,20 @@ bool RowItem::hasMoveDown() const {
|
|||
|
||||
void RowItem::remove() {
|
||||
conf.buttons.erase(conf.buttons.begin() + pos);
|
||||
|
||||
for(uint8_t i = pos+1; i <= conf.buttons.size(); ++i) {
|
||||
RowItem* item = dynamic_cast<RowItem*>(mparent->child(i));
|
||||
if(item) {
|
||||
item->pos--;
|
||||
item->updatePosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RowItem::moveUp() {
|
||||
//apply change to config
|
||||
conf.buttons.at(pos-1).swap(conf.buttons.at(pos));
|
||||
|
||||
Log::trace << "rows swapped in config";
|
||||
|
||||
// apply change in GUI
|
||||
|
||||
//get Child above
|
||||
|
|
Loading…
Reference in New Issue