From: Juergen Spitzmueller Date: Sat, 30 Mar 2019 10:32:06 +0000 (+0100) Subject: GuiSelectionManager: properly handle de-selecting items X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b34b364a3c50c25b9145fa2a64e7d6ab7b6703d0;p=features.git 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. --- 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: ///