delete button for rows

This commit is contained in:
mrbesen 2021-12-21 16:21:34 +01:00
parent 93709ff3fd
commit 89564c70ce
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
3 changed files with 12 additions and 1 deletions

View File

@ -33,10 +33,11 @@ public:
const static int TYPE = 1000; const static int TYPE = 1000;
virtual bool hasRemove() const;
virtual bool hasMoveUp() const; virtual bool hasMoveUp() const;
virtual bool hasMoveDown() const; virtual bool hasMoveDown() const;
virtual void remove();
virtual void moveUp(); virtual void moveUp();
virtual void moveDown(); virtual void moveDown();

View File

@ -41,7 +41,9 @@ void ButtonManager::editButton() {
} }
void ButtonManager::deleteButton() { void ButtonManager::deleteButton() {
QTreeWidgetItem* currentSelectedItem = getSelectedItem();
perform<&ButtonManagerItem::remove>(); perform<&ButtonManagerItem::remove>();
delete currentSelectedItem;
} }
void ButtonManager::upButton() { void ButtonManager::upButton() {

View File

@ -67,6 +67,10 @@ RowItem::RowItem(QTreeWidgetItem* parent, uint8_t rownr, Config::RootConfig& con
} }
} }
bool RowItem::hasRemove() const {
return true;
}
bool RowItem::hasMoveUp() const { bool RowItem::hasMoveUp() const {
return pos > 0; return pos > 0;
} }
@ -75,6 +79,10 @@ bool RowItem::hasMoveDown() const {
return pos < conf.buttons.size()-1; return pos < conf.buttons.size()-1;
} }
void RowItem::remove() {
conf.buttons.erase(conf.buttons.begin() + pos);
}
void RowItem::moveUp() { void RowItem::moveUp() {
//apply change to config //apply change to config
conf.buttons.at(pos-1).swap(conf.buttons.at(pos)); conf.buttons.at(pos-1).swap(conf.buttons.at(pos));