add empty row, fixed bug in delete row

This commit is contained in:
mrbesen 2021-12-21 18:18:45 +01:00
parent 87985abaa0
commit 3c0648f435
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
2 changed files with 12 additions and 2 deletions

View File

@ -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) {

View File

@ -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