Code simplification.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25006 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-05-30 11:59:57 +00:00
parent 655f696612
commit 1d3fcde7f7
2 changed files with 19 additions and 34 deletions

View File

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

View File

@ -64,6 +64,8 @@ private:
int getIndexDepth(QModelIndex const & index, int depth = -1); int getIndexDepth(QModelIndex const & index, int depth = -1);
/// ///
void setTreeDepth(int depth); void setTreeDepth(int depth);
///
void outline(int func_code);
/// depth of list shown /// depth of list shown
int depth_; int depth_;