LibEngsas
ewidget.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  MA 02110-1301 USA.
18 */
19 
20 
21 #ifndef EWIDGET_H
22 #define EWIDGET_H
23 
24 #include "eglobal.h"
25 #include <QWidget>
26 
27 #include "eobject.h"
28 
29 class ESettingsWidget;
30 
31 class QMenu;
32 class QAction;
33 class QToolBar;
34 class QDockWidget;
35 class QFile;
36 
37 #include <QPointer>
38 
48 class E_CORE_EXPORT EWidget : public QWidget
49 {
50  Q_OBJECT
51 
52  public:
53  inline EWidget ( QWidget *parent = 0, Qt::WindowFlags flags = 0 ) : QWidget(parent, flags) {}
57  virtual ~EWidget();
63  void setWindowTitle ( const QString &title );
69  void connectByPass(QObject *object){ EObject::connectByPass(this, object); }
70 
71  public slots:
77  virtual EngSaS::AvailableActions enableActions(){ return 0; }
87  virtual QString fileFilters(EngSaS::FileFilter reason);
94  virtual bool load(QFile *file, QString &error);
102  virtual bool save(QFile *file, QString &error);
107  virtual bool fileNew(QString &error);
112  virtual bool print(QString &error);
117  virtual bool undo(QString &error);
122  virtual bool redo(QString &error);
127  virtual bool cut(QString &error);
132  virtual bool copy(QString &error);
137  virtual bool paste(QString &error);
142  virtual bool reload(QString &error);
157  virtual inline void reloadSettings(){ emit doReloadSettings(); }
158 
159  protected slots:
164  virtual inline void errorByPass(const QString &message){ emit error(message); }
168  virtual inline void warningByPass(const QString &message){ emit warning(message); }
172  virtual inline void informationByPass(const QString &message){ emit information(message); }
176  virtual inline void reloadEnableActionsByPass(){ emit reloadEnableActions(); }
180  virtual inline void addMenuByPass(QMenu* newMenu, const QString &parent, QString before = QString()){ emit addMenu(newMenu, parent, before); }
184  virtual inline void addActionByPass(QAction* newAction, const QString &parent, QString before = QString()){ emit addAction(newAction, parent, before); }
188  virtual inline void addToolBarByPass(QToolBar* newToolBar, Qt::ToolBarArea area = Qt::TopToolBarArea){ emit addToolBar(newToolBar, area); }
192  virtual inline void addNewDockWidgetByPass(QDockWidget *widget, const Qt::DockWidgetArea &area){ emit addNewDockWidget(widget, area); }
196  virtual inline void setCentralWidgetByPass(QWidget *centralWidget){ emit setCentralWidget(centralWidget); }
200  virtual inline void showSettingsByPass(){ emit showSettings(); }
204  virtual inline void showHelpByPass(const QString &page){ emit showHelp(page); }
208  virtual inline void showStatusWidgetByPass(QWidget* widget){ emit showStatusWidget(widget); }
215  virtual inline void reloadSettingsRequestByPass(){ emit reloadSettingsRequest(); }
216 
217  protected:
227  void addManagedDockWidget(QDockWidget *widget, const Qt::DockWidgetArea &area,
228  QString actionLabel = QString(), QString actionParent = QString());
229 
230  private:
231  QList<QPointer<QDockWidget> > dockWidgets;
232  QList<QPointer<QAction> > dockActions;
233 
234  signals:
241  void error(const QString &message);
248  void warning(const QString &message);
255  void information(const QString &message);
259  void reloadEnableActions();
266  void addMenu(QMenu* newMenu, const QString &parent, QString before = QString());
273  void addAction(QAction* newAction, const QString &parent, QString before = QString());
280  void addToolBar(QToolBar* newToolBar, Qt::ToolBarArea area = Qt::TopToolBarArea);
288  void addNewDockWidget(QDockWidget *widget, const Qt::DockWidgetArea &area);
294  void setCentralWidget(QWidget *centralWidget);
299  void showSettings();
304  void showHelp(const QString &page);
309  void showStatusWidget(QWidget* widget);
321  void reloadSettingsRequest();
329  void doReloadSettings();
330 };
331 
332 #endif // EWIDGET_H