]> git.lyx.org Git - features.git/commitdiff
Restore docked outline widget. Warning: still instable!
authorAbdelrazak Younes <younes@lyx.org>
Sat, 8 Sep 2007 17:28:14 +0000 (17:28 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 8 Sep 2007 17:28:14 +0000 (17:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20147 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiToc.cpp
src/frontends/qt4/GuiToc.h
src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/TocWidget.h

index 05bcc8ed818863fc1ccb0f58dc2bade15b646aed..ff0bc0aea33af5547c2d024183482304398b8209 100644 (file)
@@ -193,7 +193,9 @@ Dialog * Dialogs::build(string const & name)
                dialog = new GuiThesaurusDialog(lyxview_);
 #endif
        } else if (name == "toc") {
-               dialog = new GuiToc(lyxview_);
+               // On Mac show as a drawer at the right
+               dialog = new DockView<GuiToc, TocWidget>(
+                       guiview, name, Qt::RightDockWidgetArea, Qt::Drawer);
        } else if (name == "url") {
                dialog = new GuiURLDialog(lyxview_);
        } else if (name == "vspace") {
index 8715d1bcad5538c06224ea733769f035d61e3cf9..4a909b9f851f38ef3db4ada120b836aeea19483e 100644 (file)
@@ -32,11 +32,9 @@ namespace lyx {
 namespace frontend {
 
 
-GuiToc::GuiToc(LyXView & lv)
-       : GuiDialog(lv, "toc")
+GuiToc::GuiToc(Dialog & dialog)
+       : ControlToc(dialog)
 {
-       setViewTitle(_("Outline"));
-       setController(new ControlToc(*this));
 #ifdef Q_WS_MACX
                // On Mac show as a drawer at the right
        //setView(new DockView<GuiToc, TocWidget>(
@@ -45,13 +43,6 @@ GuiToc::GuiToc(LyXView & lv)
        //setView(new DockView<GuiToc, TocWidget>(
 //                     *dialog, qtoc, &gui_view, _("Outline")));
 #endif
-       bc().setPolicy(ButtonPolicy::OkCancelPolicy);
-}
-
-
-ControlToc & GuiToc::controller() const
-{
-       return static_cast<ControlToc &>(Dialog::controller());
 }
 
 
@@ -60,7 +51,7 @@ bool GuiToc::canOutline(int type) const
        if (type < 0)
                return false;
 
-       return controller().canOutline(type);
+       return canOutline(type);
 }
 
 
@@ -103,7 +94,7 @@ QModelIndex const GuiToc::getCurrentIndex(int type) const
        if(!canOutline(type))
                return QModelIndex();
 
-       return toc_models_[type]->modelIndex(controller().getCurrentTocItem(type));
+       return toc_models_[type]->modelIndex(getCurrentTocItem(type));
 }
 
 
@@ -123,13 +114,13 @@ void GuiToc::goTo(int type, QModelIndex const & index)
 
        LYXERR(Debug::GUI) << "GuiToc::goTo " << to_utf8(it->str()) << endl;
 
-       controller().goTo(*it);
+       ControlToc::goTo(*it);
 }
 
 
 bool GuiToc::initialiseParams(std::string const & data)
 {
-       if (!controller().initialiseParams(data))
+       if (!ControlToc::initialiseParams(data))
                return false;
        updateView();
        modelReset();
@@ -140,8 +131,8 @@ bool GuiToc::initialiseParams(std::string const & data)
 void GuiToc::updateView()
 {
        toc_models_.clear();
-       TocList::const_iterator it = controller().tocs().begin();
-       TocList::const_iterator end = controller().tocs().end();
+       TocList::const_iterator it = tocs().begin();
+       TocList::const_iterator end = tocs().end();
        for (; it != end; ++it)
                toc_models_.push_back(new TocModel(it->second));
 }
index 027910e5746cd10b2b564178a4faa77a861212af..ac40c2fdae8c3c3ba755ca426dc8e292d1b0718f 100644 (file)
@@ -14,7 +14,6 @@
 #ifndef GUITOC_H
 #define GUITOC_H
 
-#include "GuiDialog.h"
 #include "ControlToc.h"
 
 #include <QObject>
@@ -26,13 +25,13 @@ namespace frontend {
 
 class TocModel;
 
-class GuiToc : public GuiDialog
+class GuiToc : public QObject, public ControlToc
 {
        Q_OBJECT
 
 public:
        ///
-       GuiToc(LyXView & lv);
+       GuiToc(Dialog &);
 
        /// \c ControlToc inherited method.
        virtual bool initialiseParams(std::string const & data);
@@ -51,8 +50,6 @@ public:
        ///
        int getTocDepth(int type);
 
-       ControlToc & controller() const;
-
 Q_SIGNALS:
        /// Signal that the internal toc_models_ has been reset.
        void modelReset();
index 1fa781058b2834077bd406c18edebd7a3a95fb92..63c6fe4d08b9adfeb77003cbf5f61d03c40c9f68 100644 (file)
@@ -42,13 +42,13 @@ using support::libFileSearch;
 
 namespace frontend {
 
-TocWidget::TocWidget(GuiToc * form, QWidget * parent)
-       : QWidget(parent), depth_(0)
+TocWidget::TocWidget(GuiToc & form, QWidget * parent)
+       : QWidget(parent), depth_(0), form_(form)
 {
        setupUi(this);
-       form_ = form;
+       setWindowTitle(qt_("Outline"));
 
-       connect(form_, SIGNAL(modelReset()), SLOT(updateGui()));
+       connect(&form_, SIGNAL(modelReset()), SLOT(updateGui()));
 
        FileName icon_path = libFileSearch("images", "promote.png");
        moveOutTB->setIcon(QIcon(toqstr(icon_path.absFilename())));
@@ -85,7 +85,7 @@ void TocWidget::selectionChanged(const QModelIndex & current,
                << ", " << current.column()
                << endl;
 
-       form_->goTo(typeCO->currentIndex(), current);
+       form_.goTo(typeCO->currentIndex(), current);
 }
 
 
@@ -94,7 +94,7 @@ void TocWidget::on_updateTB_clicked()
        // The backend update can take some time so we disable
        // the controls while waiting.
        enableControls(false);
-       form_->controller().updateBackend();
+       form_.updateBackend();
 }
 
 /* FIXME (Ugras 17/11/06):
@@ -153,8 +153,8 @@ void TocWidget::on_moveUpTB_clicked()
        QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
        if (!list.isEmpty()) {
                enableControls(false);
-               form_->goTo(typeCO->currentIndex(), list[0]);
-               form_->controller().outlineUp();
+               form_.goTo(typeCO->currentIndex(), list[0]);
+               form_.outlineUp();
                enableControls(true);
        }
 }
@@ -166,8 +166,8 @@ void TocWidget::on_moveDownTB_clicked()
        QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
        if (!list.isEmpty()) {
                enableControls(false);
-               form_->goTo(typeCO->currentIndex(), list[0]);
-               form_->controller().outlineDown();
+               form_.goTo(typeCO->currentIndex(), list[0]);
+               form_.outlineDown();
                enableControls(true);
        }
 }
@@ -179,8 +179,8 @@ void TocWidget::on_moveInTB_clicked()
        QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
        if (!list.isEmpty()) {
                enableControls(false);
-               form_->goTo(typeCO->currentIndex(), list[0]);
-               form_->controller().outlineIn();
+               form_.goTo(typeCO->currentIndex(), list[0]);
+               form_.outlineIn();
                enableControls(true);
        }
 }
@@ -191,8 +191,8 @@ void TocWidget::on_moveOutTB_clicked()
        QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
        if (!list.isEmpty()) {
                enableControls(false);
-               form_->goTo(typeCO->currentIndex(), list[0]);
-               form_->controller().outlineOut();
+               form_.goTo(typeCO->currentIndex(), list[0]);
+               form_.outlineOut();
                enableControls(true);
        }
 }
@@ -217,7 +217,7 @@ void TocWidget::enableControls(bool enable)
 {
        updateTB->setEnabled(enable);
 
-       if (!form_->canOutline(typeCO->currentIndex()))
+       if (!form_.canOutline(typeCO->currentIndex()))
                enable = false;
 
        moveUpTB->setEnabled(enable);
@@ -229,17 +229,16 @@ void TocWidget::enableControls(bool enable)
 }
 
 
-void TocWidget::update()
+void TocWidget::updateView()
 {
        LYXERR(Debug::GUI) << "In TocWidget::updateView()" << endl;
-       select(form_->getCurrentIndex(typeCO->currentIndex()));
-       QWidget::update();
+       select(form_.getCurrentIndex(typeCO->currentIndex()));
 }
 
 
 void TocWidget::updateGui()
 {
-       vector<docstring> const & type_names = form_->controller().typeNames();
+       vector<docstring> const & type_names = form_.typeNames();
        if (type_names.empty()) {
                enableControls(false);
                typeCO->clear();
@@ -262,7 +261,7 @@ void TocWidget::updateGui()
        if (current_type != -1)
                typeCO->setCurrentIndex(current_type);
        else
-               typeCO->setCurrentIndex(form_->controller().selectedType());
+               typeCO->setCurrentIndex(form_.selectedType());
        typeCO->blockSignals(false);
 
        setTocModel(typeCO->currentIndex());
@@ -272,7 +271,7 @@ void TocWidget::updateGui()
 void TocWidget::setTocModel(size_t type)
 {
        bool controls_enabled = false;
-       QStandardItemModel * toc_model = form_->tocModel(type);
+       QStandardItemModel * toc_model = form_.tocModel(type);
        if (toc_model) {
                controls_enabled = toc_model->rowCount() > 0;
                tocTV->setModel(toc_model);
@@ -284,13 +283,13 @@ void TocWidget::setTocModel(size_t type)
        reconnectSelectionModel();
 
        if (controls_enabled) {
-               depthSL->setMaximum(form_->getTocDepth(type));
+               depthSL->setMaximum(form_.getTocDepth(type));
                depthSL->setValue(depth_);
        }
 
        LYXERR(Debug::GUI) << "In TocWidget::updateGui()" << endl;
 
-       select(form_->getCurrentIndex(typeCO->currentIndex()));
+       select(form_.getCurrentIndex(typeCO->currentIndex()));
 
        if (toc_model) {
                LYXERR(Debug::GUI)
index c426534de0effc513a8cd581f1d24c02d8b84168..830c0b1d4eeaa34acfd9c234d50778346e57be36 100644 (file)
@@ -27,10 +27,10 @@ class TocWidget : public QWidget, public Ui::TocUi
 {
        Q_OBJECT
 public:
-       TocWidget(GuiToc * form, QWidget * parent);
+       TocWidget(GuiToc & form, QWidget * parent = 0);
 
        /// Update the display of the dialog whilst it is still visible.
-       void update();
+       void updateView();
 
 protected Q_SLOTS:
        /// Update Gui of the display.
@@ -69,7 +69,7 @@ private:
        /// depth of list shown
        int depth_;
        ///
-       GuiToc * form_;
+       GuiToc & form_;
 };
 
 } // namespace frontend