2006-03-05 17:24:44 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
|
* \file GuiToolbar.h
|
2006-03-05 17:24:44 +00:00
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
|
#ifndef GUITOOLBAR_H
|
|
|
|
|
#define GUITOOLBAR_H
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-08-14 09:54:59 +00:00
|
|
|
|
#include "Session.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
|
#include <QAbstractProxyModel>
|
|
|
|
|
#include <QComboBox>
|
2007-09-28 22:53:00 +00:00
|
|
|
|
#include <QList>
|
2006-09-10 11:03:21 +00:00
|
|
|
|
#include <QToolBar>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
|
class QSortFilterProxyModel;
|
2008-03-04 09:46:35 +00:00
|
|
|
|
class QStandardItemModel;
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
namespace lyx {
|
2007-08-31 05:53:55 +00:00
|
|
|
|
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
class DocumentClass;
|
2008-03-10 13:02:57 +00:00
|
|
|
|
class Inset;
|
2007-08-31 05:53:55 +00:00
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
|
class Action;
|
2007-10-15 22:43:55 +00:00
|
|
|
|
class GuiCommandBuffer;
|
2008-03-10 13:02:57 +00:00
|
|
|
|
class GuiLayoutFilterModel;
|
2008-05-25 08:30:06 +00:00
|
|
|
|
class GuiToolbar;
|
2007-11-05 13:52:37 +00:00
|
|
|
|
class GuiView;
|
2008-03-10 13:02:57 +00:00
|
|
|
|
class LayoutItemDelegate;
|
2008-05-25 08:30:06 +00:00
|
|
|
|
class ToolbarInfo;
|
|
|
|
|
class ToolbarItem;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-10-01 21:26:25 +00:00
|
|
|
|
class GuiLayoutBox : public QComboBox
|
2007-09-05 20:33:29 +00:00
|
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2008-03-14 16:39:34 +00:00
|
|
|
|
GuiLayoutBox(GuiToolbar * bar, GuiView &);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-28 21:41:56 +00:00
|
|
|
|
/// select the right layout in the combobox.
|
2007-07-11 13:39:08 +00:00
|
|
|
|
void set(docstring const & layout);
|
2007-10-15 22:43:55 +00:00
|
|
|
|
/// Populate the layout combobox.
|
2007-11-20 22:03:56 +00:00
|
|
|
|
void updateContents(bool reset);
|
2007-11-10 00:21:42 +00:00
|
|
|
|
/// Add Item to Layout box according to sorting settings from preferences
|
2008-03-10 13:02:57 +00:00
|
|
|
|
void addItemSort(docstring const & item, docstring const & category,
|
|
|
|
|
bool sorted, bool sortedByCat);
|
2008-03-04 09:46:35 +00:00
|
|
|
|
|
2008-03-05 16:02:18 +00:00
|
|
|
|
///
|
|
|
|
|
void showPopup();
|
|
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
|
///
|
2008-03-04 09:46:49 +00:00
|
|
|
|
bool eventFilter(QObject * o, QEvent * e);
|
2008-03-04 09:46:35 +00:00
|
|
|
|
///
|
|
|
|
|
QString const & filter() { return filter_; }
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-06-30 14:37:33 +00:00
|
|
|
|
private Q_SLOTS:
|
2008-03-04 09:46:35 +00:00
|
|
|
|
///
|
|
|
|
|
void selected(int index);
|
2008-03-14 16:39:34 +00:00
|
|
|
|
///
|
|
|
|
|
void setIconSize(QSize size);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2008-03-10 13:02:57 +00:00
|
|
|
|
friend class LayoutItemDelegate;
|
|
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
|
///
|
|
|
|
|
void resetFilter();
|
|
|
|
|
///
|
|
|
|
|
void setFilter(QString const & s);
|
2008-03-10 13:02:57 +00:00
|
|
|
|
///
|
|
|
|
|
QString charFilterRegExp(QString const & filter);
|
|
|
|
|
///
|
|
|
|
|
void countCategories();
|
|
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
|
///
|
2007-11-05 13:52:37 +00:00
|
|
|
|
GuiView & owner_;
|
2008-03-04 09:46:35 +00:00
|
|
|
|
///
|
2008-03-14 16:39:34 +00:00
|
|
|
|
GuiToolbar * bar_;
|
|
|
|
|
///
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
DocumentClass const * text_class_;
|
2008-03-04 09:46:35 +00:00
|
|
|
|
///
|
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_;
|
2008-03-04 09:46:35 +00:00
|
|
|
|
|
|
|
|
|
/// the layout model: 1st column translated, 2nd column raw layout name
|
|
|
|
|
QStandardItemModel * model_;
|
|
|
|
|
/// the proxy model filtering \c model_
|
2008-03-10 13:02:57 +00:00
|
|
|
|
GuiLayoutFilterModel * filterModel_;
|
2008-03-04 09:46:35 +00:00
|
|
|
|
/// the (model-) index of the last successful selection
|
|
|
|
|
int lastSel_;
|
|
|
|
|
/// the character filter
|
|
|
|
|
QString filter_;
|
2008-03-05 12:00:56 +00:00
|
|
|
|
///
|
2008-03-10 13:02:57 +00:00
|
|
|
|
LayoutItemDelegate * layoutItemDelegate_;
|
|
|
|
|
///
|
|
|
|
|
unsigned visibleCategories_;
|
|
|
|
|
///
|
|
|
|
|
bool inShowPopup_;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2007-10-01 20:45:50 +00:00
|
|
|
|
class GuiToolbar : public QToolBar
|
2007-09-05 20:33:29 +00:00
|
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2007-11-05 13:52:37 +00:00
|
|
|
|
GuiToolbar(ToolbarInfo const &, GuiView &);
|
2006-04-05 23:56:29 +00:00
|
|
|
|
|
2007-10-01 20:45:50 +00:00
|
|
|
|
/// Add a button to the bar.
|
2007-04-19 19:43:15 +00:00
|
|
|
|
void add(ToolbarItem const & item);
|
2007-10-01 20:45:50 +00:00
|
|
|
|
/** update toolbar information
|
|
|
|
|
* ToolbarInfo will then be saved by session
|
|
|
|
|
*/
|
2006-11-02 16:01:36 +00:00
|
|
|
|
void saveInfo(ToolbarSection::ToolbarInfo & info);
|
2007-10-01 20:45:50 +00:00
|
|
|
|
/// Refresh the contents of the bar.
|
|
|
|
|
void updateContents();
|
2007-10-02 06:59:02 +00:00
|
|
|
|
///
|
|
|
|
|
GuiCommandBuffer * commandBuffer() { return command_buffer_; }
|
2006-09-10 11:03:21 +00:00
|
|
|
|
|
2008-03-14 16:39:34 +00:00
|
|
|
|
///
|
2008-01-16 18:27:24 +00:00
|
|
|
|
Action * addItem(ToolbarItem const & item);
|
|
|
|
|
|
2006-06-30 14:37:33 +00:00
|
|
|
|
Q_SIGNALS:
|
2008-03-14 16:39:34 +00:00
|
|
|
|
///
|
2006-05-31 12:53:05 +00:00
|
|
|
|
void updated();
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
private:
|
2008-03-14 16:39:34 +00:00
|
|
|
|
///
|
2007-09-28 22:53:00 +00:00
|
|
|
|
QList<Action *> actions_;
|
2008-03-14 16:39:34 +00:00
|
|
|
|
///
|
2007-11-05 13:52:37 +00:00
|
|
|
|
GuiView & owner_;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2008-03-14 16:39:34 +00:00
|
|
|
|
///
|
2007-09-28 22:53:00 +00:00
|
|
|
|
GuiLayoutBox * layout_;
|
2008-03-14 16:39:34 +00:00
|
|
|
|
///
|
2007-09-28 22:53:00 +00:00
|
|
|
|
GuiCommandBuffer * command_buffer_;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
|
#endif // GUITOOLBAR_H
|