/**
- * \file qt2/QLToolbar.C
+ * \file qt4/QLToolbar.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
#include "gettext.h"
#include "lyxfunc.h"
-#include "QtView.h"
+#include "GuiView.h"
#include "QLToolbar.h"
-#include "QLAction.h"
+#include "Action.h"
#include "qt_helpers.h"
+#include "InsertTableWidget.h"
#include <QComboBox>
#include <QToolBar>
#include <QToolButton>
#include <QAction>
-//Added by qt3to4:
#include <QPixmap>
using std::endl;
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
-QLayoutBox::QLayoutBox(QToolBar * toolbar, QtView & owner)
+QLayoutBox::QLayoutBox(QToolBar * toolbar, GuiView & owner)
: owner_(owner)
{
- QSizePolicy p(QSizePolicy::Minimum, QSizePolicy::Fixed);
combo_ = new QComboBox;
- combo_->setSizePolicy(p);
+ combo_->setSizeAdjustPolicy(QComboBox::AdjustToContents);
combo_->setFocusPolicy(Qt::ClickFocus);
combo_->setMinimumWidth(combo_->sizeHint().width());
-
- // QAction * action = new QAction(combo_, tr("Layout"), this);
-// action->setToolTip(toqstr(tooltip));
-// action->setStatusTip(toqstr(tooltip));
+ combo_->setMaxVisibleItems(100);
QObject::connect(combo_, SIGNAL(activated(const QString &)),
this, SLOT(selected(const QString &)));
int i = 0;
for (; i < combo_->count(); ++i) {
- if (name == combo_->text(i))
+ if (name == combo_->itemText(i))
break;
}
return;
}
- combo_->setCurrentItem(i);
+ combo_->setCurrentIndex(i);
}
for (; it != end; ++it) {
// ignore obsolete entries
if ((*it)->obsoleted_by().empty())
- combo_->insertItem(qt_((*it)->name()));
+ combo_->addItem(qt_((*it)->name()));
}
// needed to recalculate size hint
void QLayoutBox::open()
{
- combo_->popup();
+ combo_->showPopup();
}
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)
+ : QToolBar(qt_(tbb.gui_name), &owner), owner_(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<QtView &>(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();
{
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;
+ tb->setCheckable(true);
+ tb->setIcon(QPixmap(toqstr(toolbarbackend.getIcon(func))));
+ tb->setToolTip(toqstr(tooltip));
+ tb->setFocusPolicy(Qt::NoFocus);
+ InsertTableWidget * iv = new InsertTableWidget(owner_, tb);
+ 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()));
+ addWidget(tb);
+ break;
+ }
default: {
if (owner_.getLyXFunc().getStatus(func).unknown())
break;
-
- QLAction * action = new QLAction(owner_, toolbarbackend.getIcon(func), "", func, tooltip);
- toolbar_->addAction(action);
- ActionVector.push_back(action);
+ Action * action = new Action(owner_, toolbarbackend.getIcon(func), "", func, tooltip);
+ addAction(action);
+ ActionVector.push_back(action);
break;
- }
+ }
}
}
void QLToolbar::hide(bool)
{
- toolbar_->hide();
+ QToolBar::hide();
}
void QLToolbar::show(bool)
{
- toolbar_->show();
+ QToolBar::show();
}
{
for (size_t i=0; i<ActionVector.size(); ++i)
ActionVector[i]->update();
+
+ // emit signal
+ updated();
}
} // namespace frontend
} // namespace lyx
+
+#include "QLToolbar_moc.cpp"