Navigator:

- some cleanup in TocWidget
- fix Read-only document navigation.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25292 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-06-17 15:44:14 +00:00
parent 56f7a70e48
commit 81bc06db34
3 changed files with 24 additions and 37 deletions

View File

@ -84,7 +84,8 @@ void GuiToc::dispatchParams()
void GuiToc::enableView(bool enable)
{
if (!enable)
widget_->init(QString());
// In the opposite case, updateView() will be called anyway.
widget_->updateView();
}

View File

@ -17,6 +17,7 @@
#include "qt_helpers.h"
#include "TocModel.h"
#include "Buffer.h"
#include "FuncRequest.h"
#include "LyXFunc.h"
@ -216,15 +217,32 @@ void TocWidget::enableControls(bool enable)
moveDownTB->setEnabled(enable);
moveInTB->setEnabled(enable);
moveOutTB->setEnabled(enable);
depthSL->setEnabled(enable);
}
void TocWidget::updateView()
{
LYXERR(Debug::GUI, "In TocWidget::updateView()");
setTocModel();
if (!gui_view_.view()) {
enableControls(false);
typeCO->setEnabled(false);
tocTV->setModel(0);
tocTV->setEnabled(false);
return;
}
typeCO->setEnabled(true);
tocTV->setEnabled(true);
QStandardItemModel * toc_model = gui_view_.tocModels().model(current_type_);
if (tocTV->model() != toc_model) {
tocTV->setModel(toc_model);
tocTV->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
bool controls_enabled = toc_model && toc_model->rowCount() > 0
&& !gui_view_.buffer()->isReadonly();
enableControls(controls_enabled);
depthSL->setMaximum(gui_view_.tocModels().depth(current_type_));
depthSL->setValue(depth_);
setTreeDepth(depth_);
select(gui_view_.tocModels().currentIndex(current_type_));
}
@ -249,17 +267,6 @@ static QString decodeType(QString const & str)
void TocWidget::init(QString const & str)
{
if (!gui_view_.view()) {
enableControls(false);
typeCO->setEnabled(false);
tocTV->setModel(0);
tocTV->setEnabled(false);
return;
}
typeCO->setEnabled(true);
tocTV->setEnabled(true);
typeCO->blockSignals(true);
int new_index;
@ -279,25 +286,6 @@ void TocWidget::init(QString const & str)
typeCO->blockSignals(false);
}
void TocWidget::setTocModel()
{
QStandardItemModel * toc_model = gui_view_.tocModels().model(current_type_);
if (tocTV->model() != toc_model) {
tocTV->setModel(toc_model);
tocTV->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
bool controls_enabled = toc_model && toc_model->rowCount() > 0;;
enableControls(controls_enabled);
if (controls_enabled) {
depthSL->setMaximum(gui_view_.tocModels().depth(current_type_));
depthSL->setValue(depth_);
}
}
} // namespace frontend
} // namespace lyx

View File

@ -40,8 +40,6 @@ public Q_SLOTS:
void updateView();
protected Q_SLOTS:
///
void setTocModel();
///
void select(QModelIndex const & index);
///