]> git.lyx.org Git - features.git/commitdiff
* LyXView.h:
authorAbdelrazak Younes <younes@lyx.org>
Sun, 10 Sep 2006 11:03:21 +0000 (11:03 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 10 Sep 2006 11:03:21 +0000 (11:03 +0000)
  - makeToolbar(): new pure virtual method

* qt4/GuiView.h:
  - makeToolbar(): new method transferred from QLToolbar

* qt4/QLToolbar: derive from QToolBar instead of owning a QToolBar member.

* Toolbars.h: remove make_toolbar() prototype (use LyXView::makeToolbar instead).

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

src/frontends/LyXView.h
src/frontends/Toolbars.C
src/frontends/Toolbars.h
src/frontends/gtk/GView.C
src/frontends/gtk/GView.h
src/frontends/qt3/QtView.C
src/frontends/qt3/QtView.h
src/frontends/qt4/GuiView.C
src/frontends/qt4/GuiView.h
src/frontends/qt4/QLToolbar.C
src/frontends/qt4/QLToolbar.h

index 104e0ed771425f2161e63be7f8d9a8ee82f79f1f..726175f249ce722c858d40de5c9f362e5941ca1e 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef LYXVIEW_H
 #define LYXVIEW_H
 
+#include "frontends/Toolbars.h"
+
 #include <boost/scoped_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/signal.hpp>
@@ -20,7 +22,6 @@
 #include <boost/utility.hpp>
 
 class Buffer;
-class Toolbars;
 class InsetBase;
 class Intl;
 class Menubar;
@@ -73,6 +74,8 @@ public:
        /// show busy cursor
        virtual void busy(bool) const = 0;
 
+       virtual Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb) = 0;
+
        //@{ generic accessor functions
 
        /** return the current buffer view
index 7ca15c0afc48140e60906cad39b2f6c008538387..3d1bf5e1f0f04a0432597f1a666ad428eb4bbf3e 100644 (file)
@@ -116,7 +116,7 @@ void Toolbars::clearLayoutList()
 
 void Toolbars::add(ToolbarBackend::Toolbar const & tbb)
 {
-       ToolbarPtr tb_ptr = make_toolbar(tbb, owner_);
+       ToolbarPtr tb_ptr = owner_.makeToolbar(tbb);
        toolbars_[tbb.name] = tb_ptr;
 
        if (tbb.flags & ToolbarBackend::ON)
index 83cd71807f75b78ee1552d63fb88d6ef47afd668..8dc8bc7794213146294336f3e04eae8f76c91c24 100644 (file)
@@ -131,8 +131,4 @@ private:
 /// Set the layout in the kernel when an entry has been selected
 void layoutSelected(LyXView & lv, std::string const & name);
 
-/** Each GUI frontend should provide its own version of this.
- */
-Toolbars::ToolbarPtr make_toolbar(ToolbarBackend::Toolbar const &, LyXView &);
-
 #endif // NOT TOOLBARS_H
index d00842b3b5d4fd9cce384535613ce14156f9d410..83fe0fc5572a4c05f9b491aeccd1492833845302 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "GView.h"
 #include "GMenubar.h"
+#include "GToolbar.h"
 #include "GMiniBuffer.h"
 
 #include "BufferView.h"
@@ -219,5 +220,10 @@ bool GView::hasFocus() const
 }
 
 
+Toolbars::ToolbarPtr GView::makeToolbar(ToolbarBackend::Toolbar const & tbb)
+{
+       return make_toolbar(tbb, *this);
+}
+
 } // namespace frontend
 } // namespace lyx
index ea05f84a1c816b0c3c08996fb1472dcc48a7dcab..e22204903690da2e223feda70472b5877985a389 100644 (file)
@@ -50,6 +50,10 @@ public:
 
        /// show busy cursor
        virtual void busy(bool) const;
+
+       ///
+       Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
+
        /// clear any temporary message and replace with current status
        virtual void clearMessage();
 
index e9b57f8d68c2cda2aa6780802691f533cdfac446..f8bc508b1ceb21280aca87eeced85ee8133739bc 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "QtView.h"
 #include "QLMenubar.h"
+#include "QLToolbar.h"
 #include "qfont_loader.h"
 #include "QCommandBuffer.h"
 #include "qt_helpers.h"
@@ -222,6 +223,12 @@ void QtView::busy(bool yes) const
                QApplication::restoreOverrideCursor();
 }
 
+
+Toolbars::ToolbarPtr QtView::makeToolbar(ToolbarBackend::Toolbar const & tbb)
+{
+       return make_toolbar(tbb, *this);
+}
+
 } // namespace frontend
 } // namespace lyx
 
index f79ee1ae4a76dadca8a8e3f9a5fe3623db1d7279..ca0dc1e97df2294222a6dac35ab513975e6de7fe 100644 (file)
@@ -49,6 +49,9 @@ public:
        /// show busy cursor
        virtual void busy(bool) const;
 
+       ///
+       Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
+
        /// display a status message
        virtual void message(std::string const & str);
 
index 749a6b58bcb7000919c5229262ddb7a059c37bbb..8eba2f2545fb1f2835151af06320d81636d77e5c 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "debug.h"
 
-#include "frontends/Toolbars.h"
 #include "frontends/WorkArea.h"
 #include "support/filetools.h"
 #include "support/convert.h"
@@ -36,6 +35,7 @@
 
 #include "GuiView.h"
 #include "QLMenubar.h"
+#include "QLToolbar.h"
 #include "FontLoader.h"
 #include "QCommandBuffer.h"
 #include "qt_helpers.h"
@@ -245,6 +245,32 @@ void GuiView::busy(bool yes) const
                QApplication::restoreOverrideCursor();
 }
 
+
+Toolbars::ToolbarPtr GuiView::makeToolbar(ToolbarBackend::Toolbar const & tbb)
+{
+       QLToolbar * Tb = new QLToolbar(tbb, *this);
+       static QLToolbar * lastTb = 0;
+
+       if (tbb.flags & ToolbarBackend::TOP) {
+                       addToolBar(Qt::TopToolBarArea, Tb);
+                       addToolBarBreak(Qt::TopToolBarArea);
+       }
+       if (tbb.flags & ToolbarBackend::BOTTOM) {
+               addToolBar(Qt::BottomToolBarArea, Tb);
+               if (lastTb)
+                       insertToolBarBreak(lastTb);
+               lastTb = Tb;
+       }
+       if (tbb.flags & ToolbarBackend::LEFT) {
+               addToolBar(Qt::LeftToolBarArea, Tb);
+       }
+       if (tbb.flags & ToolbarBackend::RIGHT) {
+               addToolBar(Qt::RightToolBarArea, Tb);
+       }
+
+       return Toolbars::ToolbarPtr(Tb);
+}
+
 } // namespace frontend
 } // namespace lyx
 
index 3c53ed0c5d386ed58a9dda20d3c1dbc64e027c08..e72ad8bde7f87cdeba5c70436e2e8b1a723255ea 100644 (file)
@@ -60,6 +60,8 @@ public:
        /// show busy cursor
        virtual void busy(bool) const;
 
+       Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
+
        /// display a status message
        virtual void message(std::string const & str);
 
index 2d82643a22aae9fbc5f587663a0d7b5e97e2b37c..8941be22fac2450fd572d1ad9dde7247f2462d48 100644 (file)
@@ -47,34 +47,6 @@ LyXTextClass const & getTextClass(LyXView const & lv)
        return lv.buffer()->params().getLyXTextClass();
 }
 
-/*
-/// \todo Remove Qt::Dock getPosition(ToolbarBackend::Flags const & flags) if not needed anymore
-Qt::Dock getPosition(ToolbarBackend::Flags const & flags)
-{
-       if (flags & ToolbarBackend::TOP)
-               return Qt::DockTop;
-       if (flags & ToolbarBackend::BOTTOM)
-               return Qt::DockBottom;
-       if (flags & ToolbarBackend::LEFT)
-               return Qt::DockLeft;
-       if (flags & ToolbarBackend::RIGHT)
-               return Qt::DockRight;
-       return Qt::DockTop;
-}
-*/
-
-Qt::ToolBarArea getToolBarPosition(ToolbarBackend::Flags const & flags)
-{
-       if (flags & ToolbarBackend::TOP)
-               return Qt::TopToolBarArea;
-       if (flags & ToolbarBackend::BOTTOM)
-               return Qt::BottomToolBarArea;
-       if (flags & ToolbarBackend::LEFT)
-               return Qt::LeftToolBarArea;
-       if (flags & ToolbarBackend::RIGHT)
-               return Qt::RightToolBarArea;
-       return Qt::TopToolBarArea;
-}
 
 } // namespace anon
 
@@ -173,48 +145,17 @@ void QLayoutBox::selected(const QString & str)
        layoutSelected(owner_, sel);
 }
 
-} // namespace frontend
-} // namespace lyx
-
-Toolbars::ToolbarPtr make_toolbar(ToolbarBackend::Toolbar const & tbb,
-                                 LyXView & owner)
-{
-       using lyx::frontend::QLToolbar;
-       return Toolbars::ToolbarPtr(new QLToolbar(tbb, owner));
-}
-
-namespace lyx {
-namespace frontend {
 
-QLToolbar::QLToolbar(ToolbarBackend::Toolbar const & tbb, LyXView & owner)
-       : owner_(dynamic_cast<GuiView &>(owner)),
-         toolbar_(new QToolBar(qt_(tbb.gui_name), (QWidget*) &owner_)) //, getPosition(tbb.flags)))
+QLToolbar::QLToolbar(ToolbarBackend::Toolbar const & tbb, GuiView & owner)
+       : owner_(owner),
+         QToolBar(qt_(tbb.gui_name), &owner)
 {
-       /// \toto Move \a addToolBar call into QView because, in Qt4,
-       /// the ToolBars placement is the duty of QMainWindow (aka QView)
-       Qt::ToolBarArea tba = getToolBarPosition(tbb.flags);
-       switch(tba) {
-       case Qt::TopToolBarArea:
-               owner_.addToolBar(tba, toolbar_);
-               owner_.addToolBarBreak(tba);
-               break;
-//     case Qt::BottomToolBarArea:
-               //bottomToolbarVector.push_back(toolbar_);
-//             owner_.addToolBar(tba, toolbar_);
-//             //if owner_.insertToolBarBreak(toolbar_);
-               break;
-       default:
-               owner_.addToolBar(Qt::TopToolBarArea, toolbar_);
-               owner_.addToolBarBreak(Qt::TopToolBarArea);
-               break;
-       }
-
        // give visual separation between adjacent toolbars
-       toolbar_->addSeparator();
+       addSeparator();
 
        // allowing the toolbars to tear off is too easily done,
        // and we don't save their orientation anyway. Disable the handle.
-       toolbar_->setMovable(false);
+       setMovable(false);
 
        ToolbarBackend::item_iterator it = tbb.items.begin();
        ToolbarBackend::item_iterator end = tbb.items.end();
@@ -227,15 +168,15 @@ void QLToolbar::add(FuncRequest const & func, string const & tooltip)
 {
        switch (func.action) {
        case ToolbarBackend::SEPARATOR:
-               toolbar_->addSeparator();
+               addSeparator();
                break;
        case ToolbarBackend::LAYOUTS:
-               layout_.reset(new QLayoutBox(toolbar_, owner_));
+               layout_.reset(new QLayoutBox(this, owner_));
                break;
        case ToolbarBackend::MINIBUFFER:
-               owner_.addCommandBuffer(toolbar_);
+               owner_.addCommandBuffer(this);
                /// \todo find a Qt4 equivalent to setHorizontalStretchable(true);
-               //toolbar_->setHorizontalStretchable(true);
+               //setHorizontalStretchable(true);
                break;
        case LFUN_TABULAR_INSERT: {
                QToolButton * tb = new QToolButton;
@@ -247,7 +188,7 @@ void QLToolbar::add(FuncRequest const & func, string const & tooltip)
                connect(tb, SIGNAL(toggled(bool)), iv, SLOT(show(bool)));
                connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
                connect(this, SIGNAL(updated()), iv, SLOT(updateParent()));
-               toolbar_->addWidget(tb);
+               addWidget(tb);
                break;
                }
        default: {
@@ -255,7 +196,7 @@ void QLToolbar::add(FuncRequest const & func, string const & tooltip)
                        break;
 
                Action * action = new Action(owner_, toolbarbackend.getIcon(func), "", func, tooltip);
-               toolbar_->addAction(action);
+               addAction(action);
                ActionVector.push_back(action);
                break;
                }
@@ -265,13 +206,13 @@ void QLToolbar::add(FuncRequest const & func, string const & tooltip)
 
 void QLToolbar::hide(bool)
 {
-       toolbar_->hide();
+       QToolBar::hide();
 }
 
 
 void QLToolbar::show(bool)
 {
-       toolbar_->show();
+       QToolBar::show();
 }
 
 
index 3557ff07d58e811e6a54c2de9bab17933b949854..da09a9b5a458353445d4e8a71671dab171a20da2 100644 (file)
 #include "frontends/Toolbars.h"
 #include <boost/scoped_ptr.hpp>
 
-#include <QObject>
+#include <QToolBar>
 #include <vector>
 
 class QComboBox;
-class QToolBar;
 
 namespace lyx {
 namespace frontend {
@@ -58,10 +57,10 @@ private:
 };
 
 
-class QLToolbar : public QObject, public Toolbar {
+class QLToolbar : public QToolBar, public Toolbar {
        Q_OBJECT
 public:
-       QLToolbar(ToolbarBackend::Toolbar const &, LyXView &);
+       QLToolbar(ToolbarBackend::Toolbar const &, GuiView &);
 
        //~QLToolbar();
 
@@ -71,6 +70,8 @@ public:
        void update();
        LayoutBox * layout() const { return layout_.get(); }
 
+
+
 Q_SIGNALS:
        void updated();
 
@@ -78,11 +79,8 @@ private:
 
        std::vector<Action *> ActionVector;
        GuiView & owner_;
-       QToolBar * toolbar_;
 
        boost::scoped_ptr<QLayoutBox> layout_;
-
-       Qt::ToolBarArea tba;
 };
 
 } // namespace frontend