* LyXView.h:

- 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
This commit is contained in:
Abdelrazak Younes 2006-09-10 11:03:21 +00:00
parent 42a7588f32
commit c9c47c6464
11 changed files with 72 additions and 86 deletions

View 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

View 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)

View 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

View 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

View 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();

View 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

View 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);

View 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

View 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);

View 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)
QLToolbar::QLToolbar(ToolbarBackend::Toolbar const & tbb, GuiView & owner)
: owner_(owner),
QToolBar(qt_(tbb.gui_name), &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)))
{
/// \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();
}

View File

@ -19,11 +19,10 @@
#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