]> git.lyx.org Git - lyx.git/commitdiff
GuiSelectionManager: properly handle de-selecting items
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 30 Mar 2019 10:32:06 +0000 (11:32 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 30 Mar 2019 10:36:47 +0000 (11:36 +0100)
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
src/frontends/qt4/GuiSelectionManager.h

index 3b802081b6979443be9a5ecf20a683c0af313c86..ed2c640e4ffed720456784e50ffadd15e36eec0c 100644 (file)
@@ -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();
index 68339ff1620686d0d147039416575b13e77cf972..c0b4ccc4c03f63da126d7d39018fb68df9f49347 100644 (file)
@@ -132,6 +132,8 @@ protected Q_SLOTS:
        void availableLV_doubleClicked(const QModelIndex &);
        ///
        bool eventFilter(QObject *, QEvent *);
+       ///
+       void updateButtons();
 
 private:
        ///