From: Abdelrazak Younes Date: Fri, 30 May 2008 11:59:57 +0000 (+0000) Subject: Code simplification. X-Git-Tag: 1.6.10~4618 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1d3fcde7f753db099a446ac74d7fb3f970770dbb;p=features.git Code simplification. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25006 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index c1984975b2..823de4de23 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -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(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); } diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index 076fbb201d..80d6d3f152 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -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_;