]> git.lyx.org Git - features.git/commitdiff
Cleanup Toc dialog and GuiView interaction. The toc models are now part of GuiView...
authorAbdelrazak Younes <younes@lyx.org>
Fri, 2 May 2008 12:09:51 +0000 (12:09 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 2 May 2008 12:09:51 +0000 (12:09 +0000)
* GuiView::tocModel(): new method to access the toc models.
* TocModels: new class with code transferred from GuiToc.
* TocWidget: only needs a TocModels reference.

Thoughts:
- We should find a way to get rid of GuiToc.{c,h}
- tocModels() should perhaps be transferred to GuiWorkArea instead of GuiView in order to have Buffer dependent navigators.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24578 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiToc.cpp
src/frontends/qt4/GuiToc.h
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h
src/frontends/qt4/TocModel.cpp
src/frontends/qt4/TocModel.h
src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/TocWidget.h

index 8daf610285374050cc3045f0d91494f1c3acecc2..67f1cce5667a48ba122a980950cc8f1433a53451 100644 (file)
 #include "GuiView.h"
 #include "DockView.h"
 #include "TocWidget.h"
-#include "FuncRequest.h"
-
-#include "insets/InsetCommand.h"
-
-#include "TocModel.h"
 #include "qt_helpers.h"
 
 #include "Buffer.h"
 #include "BufferView.h"
 #include "BufferParams.h"
-#include "FloatList.h"
 #include "FuncRequest.h"
-#include "TextClass.h"
 
-#include "support/convert.h"
 #include "support/debug.h"
 #include "support/gettext.h"
-
 #include "support/lassert.h"
 
-#include <algorithm>
-
 using namespace std;
 
 namespace lyx {
@@ -46,217 +35,38 @@ namespace frontend {
 GuiToc::GuiToc(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
        : DockView(parent, "toc", qt_("Outline"), area, flags)
 {
-       widget_ = new TocWidget(*this, &parent);
+       widget_ = new TocWidget(parent.tocModels(), &parent);
        setWidget(widget_);
 }
 
 
 GuiToc::~GuiToc()
 {
-       clearTocModels();
        delete widget_;
 }
 
 
-void GuiToc::clearTocModels()
-{
-       const unsigned int size = toc_models_.size();
-       for (unsigned int i = 0; i < size; ++i) {
-               delete toc_models_[i];
-       }
-       toc_models_.clear();
-}
-
-
-int GuiToc::getTocDepth(int type)
-{
-       if (type < 0)
-               return 0;
-       return toc_models_[type]->modelDepth();
-}
-
-
-QStandardItemModel * GuiToc::tocModel(int type)
-{
-       if (type < 0)
-               return 0;
-
-       if (toc_models_.empty()) {
-               LYXERR(Debug::GUI, "GuiToc::tocModel(): no types available ");
-               return 0;
-       }
-
-       LYXERR(Debug::GUI, "GuiToc: type " << type
-               << "  toc_models_.size() " << toc_models_.size());
-
-       LASSERT(type >= 0 && type < int(toc_models_.size()), /**/);
-       return toc_models_[type];
-}
-
-
-QModelIndex GuiToc::currentIndex(int type) const
-{
-       if (type < 0)
-               return QModelIndex();
-
-       return toc_models_[type]->modelIndex(currentTocItem(type));
-}
-
-
-void GuiToc::goTo(int type, QModelIndex const & index)
-{
-       if (type < 0 || !index.isValid()
-               || index.model() != toc_models_[type]) {
-               LYXERR(Debug::GUI, "GuiToc::goTo(): QModelIndex is invalid!");
-               return;
-       }
-
-       LASSERT(type >= 0 && type < int(toc_models_.size()), /**/);
-
-       TocIterator const it = toc_models_[type]->tocIterator(index);
-
-       LYXERR(Debug::GUI, "GuiToc::goTo " << to_utf8(it->str()));
-
-       string const tmp = convert<string>(it->id());
-       dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
-}
-
-
 void GuiToc::updateView()
 {
        widget_->updateView();
 }
 
 
-TocList const & GuiToc::tocs() const
-{
-       return buffer().masterBuffer()->tocBackend().tocs();
-}
-
-
 bool GuiToc::initialiseParams(string const & data)
 {
-       LYXERR(Debug::GUI, data);
-       types_.clear();
-       type_names_.clear();
-       clearTocModels();
-       if (!bufferview())
-               // Nothing to show here.
-               return true;
-
-       QString str = toqstr(data);
-       QString new_type;
-       if (str.contains("tableofcontents")) {
-               new_type = "tableofcontents";
-       } else if (str.contains("floatlist")) {
-               if (str.contains("\"figure"))
-                       new_type = "figure";
-               else if (str.contains("\"table"))
-                       new_type = "table";
-               else if (str.contains("\"algorithm"))
-                       new_type = "algorithm";
-       } else if (!str.isEmpty()) {
-               new_type = str;
-       } else {
-               // Default to Outliner.
-               new_type = "tableofcontents";
-       }
-
-       TocList const & tocs = buffer().masterBuffer()->tocBackend().tocs();
-       TocList::const_iterator it = tocs.begin();
-       TocList::const_iterator end = tocs.end();
-       for (; it != end; ++it) {
-               types_.push_back(toqstr(it->first));
-               type_names_.push_back(toqstr(guiName(it->first)));
-               toc_models_.push_back(new TocModel(it->second));
-       }
-
-       widget_->updateGui(types_.indexOf(new_type));
-
+       widget_->init(toqstr(data));
        return true;
 }
 
 
-bool GuiToc::canOutline(int type) const
-{
-       return types_[type] == "tableofcontents";
-}
-
-
-void GuiToc::outlineUp()
-{
-       dispatch(FuncRequest(LFUN_OUTLINE_UP));
-}
-
-
-void GuiToc::outlineDown()
-{
-       dispatch(FuncRequest(LFUN_OUTLINE_DOWN));
-}
-
-
-void GuiToc::outlineIn()
-{
-       dispatch(FuncRequest(LFUN_OUTLINE_IN));
-}
-
-
-void GuiToc::outlineOut()
-{
-       dispatch(FuncRequest(LFUN_OUTLINE_OUT));
-}
-
-
-void GuiToc::updateBackend()
-{
-       buffer().masterBuffer()->tocBackend().update();
-       buffer().structureChanged();
-}
-
-
-TocIterator GuiToc::currentTocItem(int type) const
-{
-       LASSERT(bufferview(), /**/);
-       ParConstIterator it(bufferview()->cursor());
-       return buffer().masterBuffer()->tocBackend().item(fromqstr(types_[type]), it);
-}
-
-
-docstring GuiToc::guiName(string const & type) const
+void GuiToc::dispatchParams()
 {
-       if (type == "tableofcontents")
-               return _("Table of Contents");
-       if (type == "child")
-               return _("Child Documents");
-       if (type == "graphics")
-               return _("List of Graphics");
-       if (type == "equation")
-               return _("List of Equations");
-       if (type == "footnote")
-               return _("List of Footnotes");
-       if (type == "listing")
-               return _("List of Listings");
-       if (type == "index")
-               return _("List of Indexes");
-       if (type == "marginalnote")
-               return _("List of Marginal notes");
-       if (type == "note")
-               return _("List of Notes");
-       if (type == "citation")
-               return _("List of Citations");
-       if (type == "label")
-               return _("Labels and References");
-
-       FloatList const & floats = buffer().params().documentClass().floats();
-       if (floats.typeExist(type))
-               return _(floats.getType(type).listName());
-
-       return _(type);
 }
 
 
-void GuiToc::dispatchParams()
+void GuiToc::enableView(bool enable)
 {
+       widget_->setEnabled(enable);
 }
 
 
index 9621f3e8207efc8afd7663ef1e439f4ce9c2b6be..2031465613b8aa5854c527ed181a67df3139d681 100644 (file)
@@ -46,57 +46,10 @@ public:
 
        ///
        bool initialiseParams(std::string const & data);
-       ///
        void updateView();
-       /// Test if outlining operation is possible
-       bool canOutline(int type) const;
-
-       QStandardItemModel * tocModel(int type);
-       ///
-       QModelIndex currentIndex(int type) const;
-       ///
-       void goTo(int type, QModelIndex const & index);
-       ///
-       int getType();
-       ///
-       int getTocDepth(int type);
-
-Q_SIGNALS:
-       /// Signal that the internal toc_models_ has been reset.
-       void modelReset();
-
-private:
-       ///
-       TocWidget * widget_;
-       ///
-       std::vector<TocModel *> toc_models_;
-       ///             
-       void clearTocModels();
+       void enableView(bool enable);
 
 public:
-       ///
-       TocList const & tocs() const;
-
-       /// Return the list of types available
-       QStringList const & typeNames() const { return type_names_; }
-
-       /// Return the first TocItem before the cursor
-       TocIterator currentTocItem(int type) const;
-
-       /// Apply the selected outlining operation
-       void outlineUp();
-       ///
-       void outlineDown();
-       ///
-       void outlineIn();
-       ///
-       void outlineOut();
-       ///
-       void updateBackend();
-
-       /// Return the guiname from a given cmdName of the TOC param
-       docstring guiName(std::string const & type) const;
-
        /// clean-up on hide.
        void clearParams() {}
        ///
@@ -104,10 +57,9 @@ public:
        ///
        bool isBufferDependent() const { return true; }
 
+private:
        ///
-       QStringList types_;
-       ///
-       QStringList type_names_;
+       TocWidget * widget_;
 };
 
 } // namespace frontend
index 29cbd5b4f12cb062fdf5b42454c6a4dee6726444..398d80475f7ed97dccda6c4c13833843ef505677 100644 (file)
@@ -24,6 +24,7 @@
 #include "GuiToolbar.h"
 #include "GuiToolbars.h"
 #include "Menus.h"
+#include "TocModel.h"
 
 #include "qt_helpers.h"
 
@@ -270,6 +271,9 @@ public:
        Timeout autosave_timeout_;
        /// flag against a race condition due to multiclicks, see bug #1119
        bool in_show_;
+
+       ///
+       TocModels toc_models_;
 };
 
 
@@ -346,6 +350,12 @@ GuiView::~GuiView()
 }
 
 
+TocModels & GuiView::tocModels()
+{
+       return d.toc_models_;
+}
+
+
 void GuiView::setFocus()
 {
        if (d.current_work_area_)
@@ -918,6 +928,7 @@ void GuiView::errors(string const & error_type)
 
 void GuiView::structureChanged()
 {
+       d.toc_models_.reset(view());
        updateDialog("toc", "");
 }
 
index 8aeefcf7085c4f380c85b9ed95b4b9286d6f24e3..ad95e4d677b4248d0d4b159b5b902e92f0382076 100644 (file)
@@ -41,6 +41,7 @@ class GuiLayoutBox;
 class GuiToolbar;
 class GuiWorkArea;
 class TabWorkArea;
+class TocModels;
 
 /**
  * GuiView - Qt4 implementation of LyXView
@@ -106,6 +107,9 @@ public:
        void errors(std::string const &);
        void structureChanged();
        ///@}
+
+       ///
+       TocModels & tocModels();
        
        /// called on timeout
        void autoSave();
index 324be635bc9e0855917b54014e5ae7f84aa60238..670cb5541dab474d4f626077631397a506db1e10 100644 (file)
 
 #include "TocModel.h"
 
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "BufferView.h"
+#include "Cursor.h"
+#include "FloatList.h"
+#include "FuncRequest.h"
+#include "LyXFunc.h"
+#include "ParIterator.h"
+#include "TextClass.h"
+
+#include "support/convert.h"
 #include "support/debug.h"
-
 #include "support/lassert.h"
+
 #include <climits>
 
 using namespace std;
@@ -146,6 +157,165 @@ int TocModel::modelDepth() const
        return maxdepth_ - mindepth_;
 }
 
+
+///////////////////////////////////////////////////////////////////////////////
+// TocModels implementation.
+///////////////////////////////////////////////////////////////////////////////
+void TocModels::clear()        
+{
+       types_.clear();
+       type_names_.clear();
+       const unsigned int size = models_.size();
+       for (unsigned int i = 0; i < size; ++i) {
+               delete models_[i];
+       }
+       models_.clear();
+}
+
+
+int TocModels::depth(int type)
+{
+       if (type < 0)
+               return 0;
+       return models_[type]->modelDepth();
+}
+
+
+QStandardItemModel * TocModels::model(int type)
+{
+       if (type < 0)
+               return 0;
+
+       if (models_.empty()) {
+               LYXERR(Debug::GUI, "TocModels::tocModel(): no types available ");
+               return 0;
+       }
+
+       LYXERR(Debug::GUI, "TocModels: type " << type
+               << "  models_.size() " << models_.size());
+
+       LASSERT(type >= 0 && type < int(models_.size()), /**/);
+       return models_[type];
+}
+
+
+QModelIndex TocModels::currentIndex(int type) const
+{
+       if (type < 0 || !bv_)
+               return QModelIndex();
+
+       ParConstIterator it(bv_->cursor());
+       return models_[type]->modelIndex(bv_->buffer().masterBuffer()->
+               tocBackend().item(fromqstr(types_[type]), it));
+}
+
+
+void TocModels::goTo(int type, QModelIndex const & index) const
+{
+       if (type < 0 || !index.isValid()
+               || index.model() != models_[type]) {
+               LYXERR(Debug::GUI, "TocModels::goTo(): QModelIndex is invalid!");
+               return;
+       }
+
+       LASSERT(type >= 0 && type < int(models_.size()), /**/);
+
+       TocIterator const it = models_[type]->tocIterator(index);
+
+       LYXERR(Debug::GUI, "TocModels::goTo " << it->str());
+
+       string const tmp = convert<string>(it->id());
+       dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
+}
+
+
+void TocModels::updateBackend() const
+{
+       bv_->buffer().masterBuffer()->tocBackend().update();
+       bv_->buffer().structureChanged();
+}
+
+
+QString TocModels::guiName(string const & type) const
+{
+       if (type == "tableofcontents")
+               return qt_("Table of Contents");
+       if (type == "child")
+               return qt_("Child Documents");
+       if (type == "graphics")
+               return qt_("List of Graphics");
+       if (type == "equation")
+               return qt_("List of Equations");
+       if (type == "footnote")
+               return qt_("List of Footnotes");
+       if (type == "listing")
+               return qt_("List of Listings");
+       if (type == "index")
+               return qt_("List of Indexes");
+       if (type == "marginalnote")
+               return qt_("List of Marginal notes");
+       if (type == "note")
+               return qt_("List of Notes");
+       if (type == "citation")
+               return qt_("List of Citations");
+       if (type == "label")
+               return qt_("Labels and References");
+
+       FloatList const & floats = bv_->buffer().params().documentClass().floats();
+       if (floats.typeExist(type))
+               return qt_(floats.getType(type).listName());
+
+       return qt_(type);
+}
+
+
+void TocModels::reset(BufferView const * bv)
+{
+       bv_ = bv;
+       clear();
+       if (!bv_)
+               return;
+
+       TocList const & tocs = bv_->buffer().masterBuffer()->tocBackend().tocs();
+       TocList::const_iterator it = tocs.begin();
+       TocList::const_iterator end = tocs.end();
+       for (; it != end; ++it) {
+               types_.push_back(toqstr(it->first));
+               type_names_.push_back(guiName(it->first));
+               models_.push_back(new TocModel(it->second));
+       }
+}
+
+
+bool TocModels::canOutline(int type) const
+{
+       if (type < 0 || type >= types_.size())
+               return false;
+       return types_[type] == "tableofcontents";
+}
+
+
+int TocModels::decodeType(QString const & str) const
+{
+       QString new_type;
+       if (str.contains("tableofcontents")) {
+               new_type = "tableofcontents";
+       } else if (str.contains("floatlist")) {
+               if (str.contains("\"figure"))
+                       new_type = "figure";
+               else if (str.contains("\"table"))
+                       new_type = "table";
+               else if (str.contains("\"algorithm"))
+                       new_type = "algorithm";
+       } else if (!str.isEmpty()) {
+               new_type = str;
+       } else {
+               // Default to Outliner.
+               new_type = "tableofcontents";
+       }
+       return types_.indexOf(new_type);
+}
+
 } // namespace frontend
 } // namespace lyx
 
index 2003fedbc81858114b32a20a15857e31929ec5c8..8ebbc8d9f4bfcfba4f02304c666074dd4ffb42a5 100644 (file)
 #include <map>
 
 namespace lyx {
+
+class BufferView;
+
 namespace frontend {
 
 class TocModel : public QStandardItemModel
 {
-       Q_OBJECT
-
 public:
        ///
        TocModel() {}
@@ -60,6 +61,55 @@ private:
        int mindepth_;
 };
 
+
+class TocModels: public QObject
+{
+       Q_OBJECT
+public:
+       ///
+       TocModels(): bv_(0) {}
+       ///
+       TocModels::~TocModels() { clear(); }
+       ///
+       void reset(BufferView const * bv);
+       ///
+       int depth(int type);
+       ///
+       QStandardItemModel * model(int type);
+       ///
+       QModelIndex TocModels::currentIndex(int type) const;
+       ///
+       void goTo(int type, QModelIndex const & index) const;
+       ///
+       void TocModels::init(Buffer const & buffer);
+       /// Test if outlining operation is possible
+       bool canOutline(int type) const;
+       /// Return the list of types available
+       QStringList const & typeNames() const { return type_names_; }
+       ///
+       void updateBackend() const;
+       ///
+       int decodeType(QString const & str) const;
+
+Q_SIGNALS:
+       /// Signal that the internal toc_models_ has been reset.
+       void modelReset();
+
+private:
+       ///
+       void clear();
+       /// Return the guiname from a given cmdName of the TOC param
+       QString guiName(std::string const & type) const;
+       ///
+       BufferView const * bv_;
+       ///
+       std::vector<TocModel *> models_;
+       ///
+       QStringList types_;
+       ///
+       QStringList type_names_;
+};
+
 } // namespace frontend
 } // namespace lyx
 
index 6912c8795b752e7f48907801f3d38ee2d030a09a..6e8a476a94cd54ff73031c5de1b1e43029fcacca 100644 (file)
 
 #include "TocWidget.h"
 
-#include "GuiToc.h"
+#include "TocModel.h"
 #include "qt_helpers.h"
 
+#include "FuncRequest.h"
+#include "LyXFunc.h"
+
 #include "support/debug.h"
 
 #include <QHeaderView>
@@ -28,8 +31,8 @@ using namespace std;
 namespace lyx {
 namespace frontend {
 
-TocWidget::TocWidget(GuiToc & form, QWidget * parent)
-       : QWidget(parent), depth_(0), form_(form)
+TocWidget::TocWidget(TocModels & models, QWidget * parent)
+       : QWidget(parent), depth_(0), models_(models)
 {
        setupUi(this);
 
@@ -61,7 +64,7 @@ void TocWidget::selectionChanged(const QModelIndex & current,
        LYXERR(Debug::GUI, "selectionChanged index " << current.row()
                << ", " << current.column());
 
-       form_.goTo(typeCO->currentIndex(), current);
+       models_.goTo(typeCO->currentIndex(), current);
 }
 
 
@@ -70,7 +73,7 @@ void TocWidget::on_updateTB_clicked()
        // The backend update can take some time so we disable
        // the controls while waiting.
        enableControls(false);
-       form_.updateBackend();
+       models_.updateBackend();
 }
 
 /* FIXME (Ugras 17/11/06):
@@ -129,8 +132,8 @@ void TocWidget::on_moveUpTB_clicked()
        QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
        if (!list.isEmpty()) {
                enableControls(false);
-               form_.goTo(typeCO->currentIndex(), list[0]);
-               form_.outlineUp();
+               models_.goTo(typeCO->currentIndex(), list[0]);
+               dispatch(FuncRequest(LFUN_OUTLINE_UP));
                enableControls(true);
        }
 }
@@ -142,8 +145,8 @@ void TocWidget::on_moveDownTB_clicked()
        QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
        if (!list.isEmpty()) {
                enableControls(false);
-               form_.goTo(typeCO->currentIndex(), list[0]);
-               form_.outlineDown();
+               models_.goTo(typeCO->currentIndex(), list[0]);
+               dispatch(FuncRequest(LFUN_OUTLINE_DOWN));
                enableControls(true);
        }
 }
@@ -155,8 +158,8 @@ void TocWidget::on_moveInTB_clicked()
        QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
        if (!list.isEmpty()) {
                enableControls(false);
-               form_.goTo(typeCO->currentIndex(), list[0]);
-               form_.outlineIn();
+               models_.goTo(typeCO->currentIndex(), list[0]);
+               dispatch(FuncRequest(LFUN_OUTLINE_IN));
                enableControls(true);
        }
 }
@@ -167,8 +170,8 @@ void TocWidget::on_moveOutTB_clicked()
        QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
        if (!list.isEmpty()) {
                enableControls(false);
-               form_.goTo(typeCO->currentIndex(), list[0]);
-               form_.outlineOut();
+               models_.goTo(typeCO->currentIndex(), list[0]);
+               dispatch(FuncRequest(LFUN_OUTLINE_OUT));
                enableControls(true);
        }
 }
@@ -192,7 +195,7 @@ void TocWidget::enableControls(bool enable)
 {
        updateTB->setEnabled(enable);
 
-       if (!form_.canOutline(typeCO->currentIndex()))
+       if (!models_.canOutline(typeCO->currentIndex()))
                enable = false;
 
        moveUpTB->setEnabled(enable);
@@ -208,13 +211,13 @@ void TocWidget::updateView()
 {
        LYXERR(Debug::GUI, "In TocWidget::updateView()");
        setTreeDepth();
-       select(form_.currentIndex(typeCO->currentIndex()));
+       select(models_.currentIndex(typeCO->currentIndex()));
 }
 
 
-void TocWidget::updateGui(int selected_type)
+void TocWidget::init(QString const & str)
 {
-       QStringList const & type_names = form_.typeNames();
+       QStringList const & type_names = models_.typeNames();
        if (type_names.isEmpty()) {
                enableControls(false);
                typeCO->clear();
@@ -223,17 +226,21 @@ void TocWidget::updateGui(int selected_type)
                return;
        }
 
+       int selected_type = models_.decodeType(str);
+
        QString const current_text = typeCO->currentText();
        typeCO->blockSignals(true);
        typeCO->clear();
        for (int i = 0; i != type_names.size(); ++i)
                typeCO->addItem(type_names[i]);
-       if (selected_type != -1)
+       if (!str.isEmpty())
                typeCO->setCurrentIndex(selected_type);
        else {
                int const new_index = typeCO->findText(current_text);
                if (new_index != -1)
                        typeCO->setCurrentIndex(new_index);
+               else
+                       typeCO->setCurrentIndex(selected_type);
        }
 
        typeCO->blockSignals(false);
@@ -249,7 +256,7 @@ void TocWidget::updateGui(int selected_type)
 void TocWidget::setTocModel(size_t type)
 {
        bool controls_enabled = false;
-       QStandardItemModel * toc_model = form_.tocModel(type);
+       QStandardItemModel * toc_model = models_.model(type);
        if (toc_model) {
                controls_enabled = toc_model->rowCount() > 0;
                tocTV->setModel(toc_model);
@@ -261,13 +268,13 @@ void TocWidget::setTocModel(size_t type)
        reconnectSelectionModel();
 
        if (controls_enabled) {
-               depthSL->setMaximum(form_.getTocDepth(type));
+               depthSL->setMaximum(models_.depth(type));
                depthSL->setValue(depth_);
        }
 
        LYXERR(Debug::GUI, "In TocWidget::updateGui()");
 
-       select(form_.currentIndex(typeCO->currentIndex()));
+       select(models_.currentIndex(typeCO->currentIndex()));
 
        if (toc_model) {
                LYXERR(Debug::GUI, "tocModel()->rowCount "
@@ -280,14 +287,12 @@ void TocWidget::setTocModel(size_t type)
 
 void TocWidget::reconnectSelectionModel()
 {
-       connect(tocTV->selectionModel(),
-               SIGNAL(currentChanged(const QModelIndex &,
-                      const QModelIndex &)),
-               this,
-               SLOT(selectionChanged(const QModelIndex &,
-                    const QModelIndex &)));
+       connect(tocTV->selectionModel(), SIGNAL(
+               currentChanged(const QModelIndex &, const QModelIndex &)),
+               this, SLOT(selectionChanged(const QModelIndex &, const QModelIndex &)));
 }
 
+
 void TocWidget::disconnectSelectionModel()
 {
        disconnect(tocTV->selectionModel(),
index e3d3bf071056669e2c5cfec977424409a6179c80..c5d680890444731b9b898db461bd12eb11f24b3c 100644 (file)
 #include "GuiToc.h"
 #include "ui_TocUi.h"
 
+class QString;
 
 namespace lyx {
 namespace frontend {
 
-class GuiToc;
+class TocModels;
 
 class TocWidget : public QWidget, public Ui::TocUi
 {
        Q_OBJECT
 public:
-       TocWidget(GuiToc & form, QWidget * parent = 0);
+       TocWidget(TocModels & models, QWidget * parent = 0);
+
+       /// Initialise GUI.
+       void init(QString const & str);
 
 public Q_SLOTS:
        /// Update the display of the dialog whilst it is still visible.
        void updateView();
 
-       /// Update Gui of the display.
-       void updateGui(int selected_type);
-
 protected Q_SLOTS:
        ///
        void setTocModel(size_t type);
@@ -54,15 +55,13 @@ protected Q_SLOTS:
        void on_moveOutTB_clicked();
        void setTreeDepth() { setTreeDepth(depth_); }
 
-protected:
+private:
        ///
        void enableControls(bool enable = true);
        ///
        int getIndexDepth(QModelIndex const & index, int depth = -1);
        ///
        void setTreeDepth(int depth);
-
-private:
        /// Reconnects the selection model change signal when TOC changed.
        void reconnectSelectionModel();
        /// Disconnects the selection model.
@@ -72,7 +71,7 @@ private:
        /// depth of list shown
        int depth_;
        ///
-       GuiToc & form_;
+       TocModels & models_;
 };
 
 } // namespace frontend