SciDAVis  1.D4
MyWidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : MyWidget.h
3  Project : SciDAVis
4  Description : MDI window widget
5  --------------------------------------------------------------------
6  Copyright : (C) 2006-2009 Knut Franke (knut.franke*gmx.de)
7  Copyright : (C) 2006-2009 Tilman Benkert (thzs*gmx.net)
8  Copyright : (C) 2006-2007 by Ion Vasilief (ion_vasilief*yahoo.fr)
9  (replace * with @ in the email address)
10 
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  * This program is distributed in the hope that it will be useful, *
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
23  * GNU General Public License for more details. *
24  * *
25  * You should have received a copy of the GNU General Public License *
26  * along with this program; if not, write to the Free Software *
27  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
28  * Boston, MA 02110-1301 USA *
29  * *
30  ***************************************************************************/
31 #ifndef WIDGET_H
32 #define WIDGET_H
33 
34 #include <QWidget>
35 class QEvent;
36 class QCloseEvent;
37 class QString;
38 class Folder;
39 
51 class MyWidget: public QWidget
52 {
53  Q_OBJECT
54 
55 public:
56 
58 
65  MyWidget(const QString& label = QString(), QWidget * parent = 0, const QString name = 0, Qt::WFlags f = 0);
66 
69  Name = 0,
70  Label = 1,
71  Both = 2
72  };
73  enum Status{Hidden = -1, Normal = 0, Minimized = 1, Maximized = 2};
74 
76  virtual QString windowLabel(){return QString(w_label);};
78  virtual void setWindowLabel(const QString& s) { w_label = s; updateCaption();};
79 
81  virtual QString name(){return objectName();};
83  virtual void setName(const QString& s){setObjectName(s); updateCaption();};
84 
88  virtual void setCaptionPolicy(CaptionPolicy policy) { caption_policy = policy; updateCaption(); }
89 
91  virtual QString birthDate(){return birthdate;};
93  virtual void setBirthDate(const QString& s){birthdate = s;};
94 
96  QString aspect();
98  Status status(){return w_status;};
100  void setStatus(Status s);
101 
102  virtual QString saveAsTemplate(const QString& ){return QString();};
103  // TODO:
105  virtual void restore(const QStringList& ){};
106 
107  virtual void print(){};
108  virtual void exportPDF(const QString&){};
109 
110  virtual QString saveToString(const QString &){return QString();};
111 
113  virtual void setHidden();
114 
115  //event handlers
117 
121  void closeEvent( QCloseEvent *);
123  void askOnCloseEvent(bool ask){askOnClose = ask;};
125  bool eventFilter(QObject *object, QEvent *e);
126 
129 
131  void setFolder(Folder* f){parentFolder = f;};
132 
134  void notifyChanges(){emit modifiedWindow(this);};
135 
136  void setNormal();
137  void setMinimized();
138  void setMaximized();
139 
140 signals:
142  void closedWindow(MyWidget *);
144  void hiddenWindow(MyWidget *);
145  void modifiedWindow(QWidget *);
146  void resizedWindow(QWidget *);
148  void statusChanged(MyWidget *);
150  void showTitleBarMenu();
151 
152 protected slots:
154  void updateCaption();
155 
156 protected:
158  virtual void changeEvent(QEvent *event);
160  QWidget *titleBar;
161 
165 
168  QString w_label;
170  QString birthdate;
174 
180 };
181 
182 #endif