From 02974ff2a9f32c1870e41b4eee9f37ae3ff0d04f Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 30 Mar 2019 11:32:06 +0100 Subject: [PATCH] GuiSelectionManager: properly handle de-selecting items When an item is de-selected with the mouse, and thus no item selected anymore, disable add, up, down and delete buttons. --- src/frontends/qt4/GuiSelectionManager.cpp | 13 +++++++++++++ src/frontends/qt4/GuiSelectionManager.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/frontends/qt4/GuiSelectionManager.cpp b/src/frontends/qt4/GuiSelectionManager.cpp index 3b802081b6..ed2c640e4f 100644 --- a/src/frontends/qt4/GuiSelectionManager.cpp +++ b/src/frontends/qt4/GuiSelectionManager.cpp @@ -71,9 +71,15 @@ GuiSelectionManager::GuiSelectionManager(QObject * parent, connect(availableLV->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(availableChanged(QItemSelection, QItemSelection))); + connect(availableLV->selectionModel(), + SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, SLOT(updateButtons())); connect(selectedLV->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectedChanged(QItemSelection, QItemSelection))); + connect(selectedLV->selectionModel(), + SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, SLOT(updateButtons())); connect(selectedLV->itemDelegate(), SIGNAL(commitData(QWidget*)), this, SLOT(selectedEdited())); connect(addPB, SIGNAL(clicked()), @@ -101,6 +107,13 @@ void GuiSelectionManager::update() } +void GuiSelectionManager::updateButtons() +{ + update(); + updateHook(); +} + + QModelIndex GuiSelectionManager::getSelectedIndex(int const c) const { QModelIndexList avail = availableLV->selectionModel()->selectedIndexes(); diff --git a/src/frontends/qt4/GuiSelectionManager.h b/src/frontends/qt4/GuiSelectionManager.h index 68339ff162..c0b4ccc4c0 100644 --- a/src/frontends/qt4/GuiSelectionManager.h +++ b/src/frontends/qt4/GuiSelectionManager.h @@ -132,6 +132,8 @@ protected Q_SLOTS: void availableLV_doubleClicked(const QModelIndex &); /// bool eventFilter(QObject *, QEvent *); + /// + void updateButtons(); private: /// -- 2.39.5