]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSelectionManager.cpp
Fix the tab ordering of PanelStack and PrefsUi.
[lyx.git] / src / frontends / qt4 / GuiSelectionManager.cpp
index 19d0f78300a8670a796b2a9e1fae4eb6643664de..825115cb3a368fff67470dc774a2269ff427bd25 100644 (file)
 #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<int, QVariant> 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)