diff options
Diffstat (limited to 'src/editexecutablesdialog.cpp')
| -rw-r--r-- | src/editexecutablesdialog.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index 96f4660a..9747a86f 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -348,6 +348,44 @@ void EditExecutablesDialog::save() } } +void EditExecutablesDialog::moveSelection(int by) +{ + auto* item = selectedItem(); + if (!item) { + return; + } + + // moving down the list + while (by > 0) { + const auto row = ui->list->row(item); + + if (row >= (ui->list->count() - 1)) { + break; + } + + ui->list->takeItem(row); + ui->list->insertItem(row + 1, item); + item->setSelected(true); + + --by; + } + + // moving up the list + while (by < 0) { + const auto row = ui->list->row(item); + + if (row <= 0) { + break; + } + + ui->list->takeItem(row); + ui->list->insertItem(row - 1, item); + item->setSelected(true); + + ++by; + } +} + void EditExecutablesDialog::on_list_itemSelectionChanged() { updateUI(selectedExe()); @@ -408,6 +446,16 @@ void EditExecutablesDialog::on_remove_clicked() } } +void EditExecutablesDialog::on_up_clicked() +{ + moveSelection(-1); +} + +void EditExecutablesDialog::on_down_clicked() +{ + moveSelection(+1); +} + bool EditExecutablesDialog::isTitleConflicting(const QString& s) { for (const auto& exe : m_executablesList) { |
