]> git.lyx.org Git - lyx.git/commitdiff
More cleanup for forthcoming patch. Also fix a copy-paste error.
authorRichard Heck <rgheck@comcast.net>
Tue, 14 Oct 2008 17:14:25 +0000 (17:14 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 14 Oct 2008 17:14:25 +0000 (17:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26904 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiDocument.cpp

index 329a263eabb27109ca2b047591cda250401b74a9..62b269af32cea154b8c3abbf061d67588e07b1c1 100644 (file)
@@ -336,20 +336,14 @@ void ModuleSelectionManager::updateDownPB()
                downPB->setEnabled(false);
                return;
        }
-       QModelIndexList const selSels = 
-                       selectedLV->selectionModel()->selectedIndexes();
-       // disable if empty or last item is selected
-       if (selSels.empty() || selSels.first().row() == srows - 1) {
-               downPB->setEnabled(false);
-               return;
-       }
-       // determine whether immediately succeding element requires this one
        QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
-       int curRow = curIdx.row();
-       if (curRow < 0 || curRow >= srows - 1) { //this shouldn't happen...
+       int const curRow = curIdx.row();
+       if (curRow < 0 || curRow >= srows - 1) { // invalid or last item
                downPB->setEnabled(false);
                return;
        }
+
+       // determine whether immediately succeding element requires this one
        string const curModName = getSelectedModel()->getIDString(curRow);
        string const nextModName = getSelectedModel()->getIDString(curRow + 1);
 
@@ -375,19 +369,12 @@ void ModuleSelectionManager::updateUpPB()
                upPB->setEnabled(false);
                return;
        }
-       QModelIndexList const selSels = 
-                       selectedLV->selectionModel()->selectedIndexes();
-       //disable if empty or first item is selected
-       if (selSels.empty() || selSels.first().row() == 0) {
-               upPB->setEnabled(false);
-               return;
-       }
 
        // determine whether immediately preceding element is required by this one
        QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
        int curRow = curIdx.row();
-       if (curRow <= -1 || curRow > srows - 1) { //sanity check
-               downPB->setEnabled(false);
+       if (curRow <= 0 || curRow > srows - 1) { // first item or invalid
+               upPB->setEnabled(false);
                return;
        }
        string const curModName = getSelectedModel()->getIDString(curRow);
@@ -414,24 +401,18 @@ void ModuleSelectionManager::updateDelPB()
                deletePB->setEnabled(false);
                return;
        }
-       QModelIndexList const selSels = 
-                       selectedLV->selectionModel()->selectedIndexes();
-       if (selSels.empty() || selSels.first().row() < 0) {
-               deletePB->setEnabled(false);
-               return;
-       }
        
-       // determine whether some LATER module requires this one
-       // NOTE Things are arranged so that this is the only way there
-       // can be a problem. At least, we hope so.
        QModelIndex const & curIdx = 
                selectedLV->selectionModel()->currentIndex();
        int const curRow = curIdx.row();
-       if (curRow < 0 || curRow >= srows) { // this shouldn't happen
+       if (curRow < 0 || curRow >= srows) { // invalid index?
                deletePB->setEnabled(false);
                return;
        }
                
+       // determine whether some LATER module requires this one
+       // NOTE Things are arranged so that this is the only way there
+       // can be a problem. At least, we hope so.
        QString const curModName = curIdx.data().toString();
        
        // We're looking here for a reason NOT to enable the button. If we