]> git.lyx.org Git - features.git/commitdiff
Code simplification.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 30 May 2008 11:59:57 +0000 (11:59 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 30 May 2008 11:59:57 +0000 (11:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25006 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/TocWidget.h

index c1984975b238043f524c1531a187c3d69cc29258..823de4de23541690c64c21b14191198141a76dbb 100644 (file)
@@ -126,10 +126,7 @@ void TocWidget::setTreeDepth(int depth)
        int size = indices.size();
        for (int i = 0; i < size; i++) {
                QModelIndex index = indices[i];
-               if (getIndexDepth(index) < depth_)
-                       tocTV->expand(index);
-               else
-                       tocTV->collapse(index);
+               tocTV->setExpanded(index, getIndexDepth(index) < depth_);
        }
 }
 
@@ -140,54 +137,40 @@ void TocWidget::on_typeCO_currentIndexChanged(int value)
 }
 
 
-void TocWidget::on_moveUpTB_clicked()
+void TocWidget::outline(int func_code)
 {
        enableControls(false);
        QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
-       if (!list.isEmpty()) {
-               enableControls(false);
-               goTo(list[0]);
-               dispatch(FuncRequest(LFUN_OUTLINE_UP));
-               enableControls(true);
-       }
+       if (list.isEmpty())
+               return;
+       enableControls(false);
+       goTo(list[0]);
+       dispatch(FuncRequest(static_cast<FuncCode>(func_code)));
+       enableControls(true);
+}
+
+
+void TocWidget::on_moveUpTB_clicked()
+{
+       outline(LFUN_OUTLINE_UP);
 }
 
 
 void TocWidget::on_moveDownTB_clicked()
 {
-       enableControls(false);
-       QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
-       if (!list.isEmpty()) {
-               enableControls(false);
-               goTo(list[0]);
-               dispatch(FuncRequest(LFUN_OUTLINE_DOWN));
-               enableControls(true);
-       }
+       outline(LFUN_OUTLINE_DOWN);
 }
 
 
 void TocWidget::on_moveInTB_clicked()
 {
-       enableControls(false);
-       QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
-       if (!list.isEmpty()) {
-               enableControls(false);
-               goTo(list[0]);
-               dispatch(FuncRequest(LFUN_OUTLINE_IN));
-               enableControls(true);
-       }
+       outline(LFUN_OUTLINE_IN);
 }
 
 
 void TocWidget::on_moveOutTB_clicked()
 {
-       QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
-       if (!list.isEmpty()) {
-               enableControls(false);
-               goTo(list[0]);
-               dispatch(FuncRequest(LFUN_OUTLINE_OUT));
-               enableControls(true);
-       }
+       outline(LFUN_OUTLINE_OUT);
 }
 
 
index 076fbb201da430e925e7c3ef321a4ebc284ca255..80d6d3f152a489a30e6734f9bb155bd947d71442 100644 (file)
@@ -64,6 +64,8 @@ private:
        int getIndexDepth(QModelIndex const & index, int depth = -1);
        ///
        void setTreeDepth(int depth);
+       ///
+       void outline(int func_code);
 
        /// depth of list shown
        int depth_;