lyx_mirror/src/frontends/qt4/GuiToolbar.h

128 lines
2.4 KiB
C
Raw Normal View History

// -*- C++ -*-
/**
* \file GuiToolbar.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bj<EFBFBD>nnes
* \author John Levon
* \author Jean-Marc Lasgouttes
* \author Angus Leeming
* \author Abdelrazak Younes
*
* Full author contact details are available in file CREDITS.
*/
#ifndef GUITOOLBAR_H
#define GUITOOLBAR_H
#include "Session.h"
#include <QList>
#include <QToolBar>
#include <QComboBox>
class QStandardItemModel;
namespace lyx {
Fix bug 4037 and related problems. The patch has been cleaned up a bit from the one posted to the list. The basic idea has two parts. First, we hard code an "empty layout" (called PlainLayout, for want of a better name) in TextClass and read it before doing anything else. It can therefore be customized by classes, if they want---say, to make it left-aligned. Second, InsetText's are divided into three types: (i) normal ones, that use the "default" layout defined by the text class; (ii) highly restrictive ones, such as ERT and (not quite an inset) table cells, which demand the empty layout; (iii) middling ones, which default to an empty layout and use the empty layout in place of the default. (This is so we don't get the same problem we had with ERT in e.g. footnotes.) The type of inset is signaled by new methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout(). (The latter might better be called: useEmptyLayoutInsteadOfDefault(), but that's silly.) The old InsetText::forceDefaultParagraphs() has been split into these, plus a new method InsetText::allowParagraphCustomization(). A lot of the changes just adapt to this change. The other big change is in GuiToolbar: We want to show LyXDefault and the "default" layout only when they're active. There are a handful of places where I'm not entirely sure whether we should be using forceEmptyLayout or !allowParagraphCustomization() or both. The InsetCaption is one of these. These places, and some others, are marked with FIXMEs, so I'd appreciate it if people would search through the patch and let me know whether these need changing. If they don't, the FIXMEs can be deleted. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
class Inset;
class DocumentClass;
class ToolbarItem;
namespace frontend {
class FilterItemDelegate;
class GuiCommandBuffer;
class GuiFilterProxyModel;
class GuiView;
class Action;
class GuiLayoutBox : public QComboBox
{
Q_OBJECT
public:
GuiLayoutBox(GuiView &);
/// select the right layout in the combobox.
void set(docstring const & layout);
/// Populate the layout combobox.
void updateContents(bool reset);
/// Add Item to Layout box according to sorting settings from preferences
void addItemSort(docstring const & item, bool sorted);
///
void showPopup();
///
bool eventFilter(QObject * o, QEvent * e);
///
QString const & filter() { return filter_; }
private Q_SLOTS:
///
void selected(int index);
private:
///
void resetFilter();
///
void setFilter(QString const & s);
///
GuiView & owner_;
///
DocumentClass const * text_class_;
///
Fix bug 4037 and related problems. The patch has been cleaned up a bit from the one posted to the list. The basic idea has two parts. First, we hard code an "empty layout" (called PlainLayout, for want of a better name) in TextClass and read it before doing anything else. It can therefore be customized by classes, if they want---say, to make it left-aligned. Second, InsetText's are divided into three types: (i) normal ones, that use the "default" layout defined by the text class; (ii) highly restrictive ones, such as ERT and (not quite an inset) table cells, which demand the empty layout; (iii) middling ones, which default to an empty layout and use the empty layout in place of the default. (This is so we don't get the same problem we had with ERT in e.g. footnotes.) The type of inset is signaled by new methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout(). (The latter might better be called: useEmptyLayoutInsteadOfDefault(), but that's silly.) The old InsetText::forceDefaultParagraphs() has been split into these, plus a new method InsetText::allowParagraphCustomization(). A lot of the changes just adapt to this change. The other big change is in GuiToolbar: We want to show LyXDefault and the "default" layout only when they're active. There are a handful of places where I'm not entirely sure whether we should be using forceEmptyLayout or !allowParagraphCustomization() or both. The InsetCaption is one of these. These places, and some others, are marked with FIXMEs, so I'd appreciate it if people would search through the patch and let me know whether these need changing. If they don't, the FIXMEs can be deleted. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
Inset const * inset_;
/// the layout model: 1st column translated, 2nd column raw layout name
QStandardItemModel * model_;
/// the proxy model filtering \c model_
GuiFilterProxyModel * filterModel_;
/// the (model-) index of the last successful selection
int lastSel_;
/// the character filter
QString filter_;
///
FilterItemDelegate * filterItemDelegate_;
};
class GuiToolbar : public QToolBar
{
Q_OBJECT
public:
GuiToolbar(ToolbarInfo const &, GuiView &);
/// Add a button to the bar.
void add(ToolbarItem const & item);
/** update toolbar information
* ToolbarInfo will then be saved by session
*/
void saveInfo(ToolbarSection::ToolbarInfo & info);
/// Refresh the contents of the bar.
void updateContents();
///
GuiCommandBuffer * commandBuffer() { return command_buffer_; }
Action * addItem(ToolbarItem const & item);
Q_SIGNALS:
void updated();
private:
QList<Action *> actions_;
GuiView & owner_;
GuiLayoutBox * layout_;
GuiCommandBuffer * command_buffer_;
};
} // namespace frontend
} // namespace lyx
#endif // GUITOOLBAR_H