From 655f6966124f09407f58cf297e54975fdabf8b91 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 30 May 2008 11:33:24 +0000 Subject: [PATCH] set the focus on the work area after clicking on a navigator item. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25005 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiToc.cpp | 2 +- src/frontends/qt4/TocWidget.cpp | 27 ++++++++++++++------------- src/frontends/qt4/TocWidget.h | 12 +++++++----- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index 67f1cce566..7443e17c33 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -35,7 +35,7 @@ namespace frontend { GuiToc::GuiToc(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags) : DockView(parent, "toc", qt_("Outline"), area, flags) { - widget_ = new TocWidget(parent.tocModels(), &parent); + widget_ = new TocWidget(parent, this); setWidget(widget_); } diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index 53b572effb..c1984975b2 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -13,8 +13,9 @@ #include "TocWidget.h" -#include "TocModel.h" +#include "GuiView.h" #include "qt_helpers.h" +#include "TocModel.h" #include "FuncRequest.h" #include "LyXFunc.h" @@ -31,8 +32,8 @@ using namespace std; namespace lyx { namespace frontend { -TocWidget::TocWidget(TocModels & models, QWidget * parent) - : QWidget(parent), depth_(0), models_(models) +TocWidget::TocWidget(GuiView & gui_view, QWidget * parent) + : QWidget(parent), depth_(0), gui_view_(gui_view) { setupUi(this); @@ -67,8 +68,7 @@ void TocWidget::on_tocTV_activated(QModelIndex const & index) void TocWidget::on_tocTV_clicked(QModelIndex const & index) { goTo(index); - // FIXME: It would be nice to return the focus to the work area in this - // case. But we need access to the GuiView! + gui_view_.setFocus(); } @@ -77,7 +77,7 @@ void TocWidget::goTo(QModelIndex const & index) LYXERR(Debug::GUI, "goto " << index.row() << ", " << index.column()); - models_.goTo(typeCO->currentIndex(), index); + gui_view_.tocModels().goTo(typeCO->currentIndex(), index); } @@ -86,7 +86,7 @@ void TocWidget::on_updateTB_clicked() // The backend update can take some time so we disable // the controls while waiting. enableControls(false); - models_.updateBackend(); + gui_view_.tocModels().updateBackend(); } /* FIXME (Ugras 17/11/06): @@ -133,6 +133,7 @@ void TocWidget::setTreeDepth(int depth) } } + void TocWidget::on_typeCO_currentIndexChanged(int value) { setTocModel(value); @@ -207,7 +208,7 @@ void TocWidget::enableControls(bool enable) { updateTB->setEnabled(enable); - if (!models_.canOutline(typeCO->currentIndex())) + if (!gui_view_.tocModels().canOutline(typeCO->currentIndex())) enable = false; moveUpTB->setEnabled(enable); @@ -223,13 +224,13 @@ void TocWidget::updateView() { LYXERR(Debug::GUI, "In TocWidget::updateView()"); setTreeDepth(depth_); - select(models_.currentIndex(typeCO->currentIndex())); + select(gui_view_.tocModels().currentIndex(typeCO->currentIndex())); } void TocWidget::init(QString const & str) { - QStringList const & type_names = models_.typeNames(); + QStringList const & type_names = gui_view_.tocModels().typeNames(); if (type_names.isEmpty()) { enableControls(false); typeCO->clear(); @@ -238,7 +239,7 @@ void TocWidget::init(QString const & str) return; } - int selected_type = models_.decodeType(str); + int selected_type = gui_view_.tocModels().decodeType(str); QString const current_text = typeCO->currentText(); typeCO->blockSignals(true); @@ -264,7 +265,7 @@ void TocWidget::init(QString const & str) void TocWidget::setTocModel(size_t type) { bool controls_enabled = false; - QStandardItemModel * toc_model = models_.model(type); + QStandardItemModel * toc_model = gui_view_.tocModels().model(type); if (toc_model) { controls_enabled = toc_model->rowCount() > 0; tocTV->setModel(toc_model); @@ -278,7 +279,7 @@ void TocWidget::setTocModel(size_t type) enableControls(controls_enabled); if (controls_enabled) { - depthSL->setMaximum(models_.depth(type)); + depthSL->setMaximum(gui_view_.tocModels().depth(type)); depthSL->setValue(depth_); } diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index fbf32a6a83..076fbb201d 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -13,22 +13,24 @@ #ifndef TOC_WIDGET_H #define TOC_WIDGET_H -#include "GuiDialog.h" -#include "GuiToc.h" #include "ui_TocUi.h" +#include + +class QModelIndex; class QString; namespace lyx { namespace frontend { -class TocModels; +class GuiView; class TocWidget : public QWidget, public Ui::TocUi { Q_OBJECT public: - TocWidget(TocModels & models, QWidget * parent = 0); + /// + TocWidget(GuiView & gui_view, QWidget * parent = 0); /// Initialise GUI. void init(QString const & str); @@ -66,7 +68,7 @@ private: /// depth of list shown int depth_; /// - TocModels & models_; + GuiView & gui_view_; }; } // namespace frontend -- 2.39.2