X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiSelectionManager.cpp;h=825115cb3a368fff67470dc774a2269ff427bd25;hb=39d569661a3f4411d4501f9a8db9c7360ef5d568;hp=19d0f78300a8670a796b2a9e1fae4eb6643664de;hpb=ebb24e51e16e55df18f19ebf9828c7674aebf3e1;p=lyx.git diff --git a/src/frontends/qt4/GuiSelectionManager.cpp b/src/frontends/qt4/GuiSelectionManager.cpp index 19d0f78300..825115cb3a 100644 --- a/src/frontends/qt4/GuiSelectionManager.cpp +++ b/src/frontends/qt4/GuiSelectionManager.cpp @@ -32,6 +32,10 @@ #undef ControlModifier #endif +#ifdef FocusIn +#undef FocusIn +#endif + namespace lyx { namespace frontend { @@ -45,15 +49,10 @@ GuiSelectionManager::GuiSelectionManager( QPushButton * down, QAbstractListModel * amod, QAbstractListModel * smod) + : availableLV(avail), selectedLV(sel), addPB(add), deletePB(del), + upPB(up), downPB(down), availableModel(amod), selectedModel(smod), + selectedHasFocus_(false) { - availableLV = avail; - selectedLV = sel; - addPB = add; - deletePB = del; - upPB = up; - downPB = down; - availableModel = amod; - selectedModel = smod; selectedLV->setModel(smod); availableLV->setModel(amod); @@ -68,7 +67,7 @@ GuiSelectionManager::GuiSelectionManager( SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(availableChanged(QItemSelection, QItemSelection))); connect(selectedLV->selectionModel(), - SIGNAL(currentChanged(QItemSelection, QItemSelection)), + SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectedChanged(QItemSelection, QItemSelection))); connect(addPB, SIGNAL(clicked()), this, SLOT(addPB_clicked())); @@ -225,8 +224,10 @@ void GuiSelectionManager::selectedChanged(const QModelIndex & idx, const QModelI bool GuiSelectionManager::insertRowToSelected(int i, QMap const & itemData) { - if (i <= -1 || i > selectedModel->rowCount()) - return false; + if (i <= -1) + i = 0; + if (i > selectedModel->rowCount()) + i = selectedModel->rowCount(); if (!selectedModel->insertRow(i)) return false; return selectedModel->setItemData(selectedModel->index(i), itemData); @@ -281,7 +282,11 @@ void GuiSelectionManager::deletePB_clicked() void GuiSelectionManager::upPB_clicked() { - QModelIndex idx = selectedLV->currentIndex(); + QModelIndexList selIdx = + selectedLV->selectionModel()->selectedIndexes(); + if (selIdx.isEmpty()) + return; + QModelIndex idx = selIdx.first(); int const pos = idx.row(); if (pos <= 0) @@ -302,7 +307,11 @@ void GuiSelectionManager::upPB_clicked() void GuiSelectionManager::downPB_clicked() { - QModelIndex idx = selectedLV->currentIndex(); + QModelIndexList selIdx = + selectedLV->selectionModel()->selectedIndexes(); + if (selIdx.isEmpty()) + return; + QModelIndex idx = selIdx.first(); int const pos = idx.row(); if (pos >= selectedModel->rowCount() - 1)