QtiPlot  0.9.8.2
MdiSubWindow.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : MdiSubWindow.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2006 by Ion Vasilief, Knut Franke
6  Email (use @ for *) : ion_vasilief*yahoo.fr, knut.franke*gmx.de
7  Description : MDI sub window
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef MdiSubWindow_H
30 #define MdiSubWindow_H
31 
32 #include <QMdiSubWindow>
33 
34 class QEvent;
35 class QCloseEvent;
36 class QString;
37 class Folder;
38 class ApplicationWindow;
39 
51 class MdiSubWindow: public QMdiSubWindow
52 {
53  Q_OBJECT
54 
55 public:
56 
58 
65  MdiSubWindow(const QString& label = QString(), ApplicationWindow *app = 0, const QString& name = QString(), 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 
77 
79  QString windowLabel(){return QString(d_label);};
81  void setWindowLabel(const QString& s) { d_label = s; updateCaption();};
82 
84  QString name(){return objectName();};
86  void setName(const QString& s){setObjectName(s); updateCaption();};
87 
92 
94  QString birthDate(){return d_birthdate;};
96  void setBirthDate(const QString& s){d_birthdate = s;};
97 
99  QString aspect();
101  Status status(){return d_status;};
103  void setStatus(Status s);
104 
105  // TODO:
107  virtual void restore(const QStringList& ){};
108  virtual void save(const QString&, const QString &, bool = false){};
109  virtual void exportPDF(const QString&){};
110 
111  // TODO: make this return something useful
113  virtual QString sizeToString();
114 
116  virtual void setHidden();
117 
118  //event handlers
120 
124  void closeEvent( QCloseEvent *);
125  void resizeEvent( QResizeEvent* );
126 
128  void askOnCloseEvent(bool ask){d_confirm_close = ask;};
130  bool eventFilter(QObject *object, QEvent *e);
132  Folder* folder(){return d_folder;};
133 
135  void setFolder(Folder* f){d_folder = f;};
136 
137  void setNormal();
138  void setMinimized();
139  void setMaximized();
140 
142  void restoreWindow();
143 
146 
148  /*
149  * It counts the number of valid rows to be imported and the number of first lines to be ignored.
150  * It creates a temporary file with '\n' terminated lines which can be correctly read by QTextStream
151  * and returnes a path to this file.
152  */
153  static QString parseAsciiFile(const QString& fname, const QString &commentString, int endLine,
154  int ignoreFirstLines, int maxRows, int& rows);
155 
156 public slots:
157  virtual void print(){};
158  virtual void print(QPrinter *){};
160  void notifyChanges(){emit modifiedWindow(this);};
161 
162 signals:
164  void closedWindow(MdiSubWindow *);
166  void hiddenWindow(MdiSubWindow *);
168  void resizedWindow(MdiSubWindow *);
170  void statusChanged(MdiSubWindow *);
172  void showContextMenu();
173 
174 protected:
176  virtual void changeEvent(QEvent *event);
177 
178 private:
180  static QString parseMacAsciiFile(const QString& fname, const QString &commentString,
181  int ignoreFirstLines, int maxRows, int& rows);
183  void updateCaption();
189 
192  QString d_label;
196 
203  QString d_birthdate;
206 };
207 
208 #endif
void restoreWindow()
Show window making sure that layers in MultiLayer windows are not resized.
Definition: MdiSubWindow.cpp:214
void setMinimized()
Definition: MdiSubWindow.cpp:249
void closeEvent(QCloseEvent *)
Close event handler.
Definition: MdiSubWindow.cpp:99
void resizedWindow(MdiSubWindow *)
Folder * d_folder
Pointer to the parent folder of the window.
Definition: MdiSubWindow.h:187
Definition: MdiSubWindow.h:73
virtual void changeEvent(QEvent *event)
Catches status changes.
Definition: MdiSubWindow.cpp:153
void setBirthDate(const QString &s)
Set the creation date.
Definition: MdiSubWindow.h:96
Folder * folder()
Returns the pointer to the parent folder of the window.
Definition: MdiSubWindow.h:132
Status d_status
The window status.
Definition: MdiSubWindow.h:194
void updateCaption()
Set caption according to current CaptionPolicy, name and label.
Definition: MdiSubWindow.cpp:67
virtual void setHidden()
Notifies that a window was hidden by a direct user action.
Definition: MdiSubWindow.cpp:207
virtual QString sizeToString()
Size of the widget as a string.
Definition: MdiSubWindow.cpp:148
QString d_label
The window label.
Definition: MdiSubWindow.h:192
bool d_confirm_close
Toggle on/off: Ask the user &quot;delete, hide, or cancel?&quot; on a close event.
Definition: MdiSubWindow.h:201
void askOnCloseEvent(bool ask)
Toggle the &quot;ask on close&quot; flag.
Definition: MdiSubWindow.h:128
void setFolder(Folder *f)
Initializes the pointer to the parent folder of the window.
Definition: MdiSubWindow.h:135
void notifyChanges()
Notifies the main application that the window has been modified.
Definition: MdiSubWindow.h:160
QString d_birthdate
The creation date.
Definition: MdiSubWindow.h:203
QString aspect()
Return the window status as a string.
Definition: MdiSubWindow.cpp:125
ApplicationWindow * applicationWindow()
Returns a pointer to the parent application.
Definition: MdiSubWindow.h:76
QSize minRestoreSize()
Returns the size the window had before a change state event to minimized.
Definition: MdiSubWindow.h:145
static QString parseAsciiFile(const QString &fname, const QString &commentString, int endLine, int ignoreFirstLines, int maxRows, int &rows)
Static function used as a workaround for ASCII files having end line char != &#39; &#39;. ...
Definition: MdiSubWindow.cpp:267
void setWindowLabel(const QString &s)
Set the window label.
Definition: MdiSubWindow.h:81
caption determined by the window name
Definition: MdiSubWindow.h:69
Definition: MdiSubWindow.h:73
void resizeEvent(QResizeEvent *)
Definition: MdiSubWindow.cpp:93
Folder for the project explorer.
Definition: Folder.h:53
QString birthDate()
Return the creation date.
Definition: MdiSubWindow.h:94
Definition: MdiSubWindow.h:73
void setCaptionPolicy(CaptionPolicy policy)
Set the caption policy.
Definition: MdiSubWindow.h:91
caption = &quot;name - label&quot;
Definition: MdiSubWindow.h:71
void hiddenWindow(MdiSubWindow *)
Emitted when the window was hidden.
virtual void save(const QString &, const QString &, bool=false)
Definition: MdiSubWindow.h:108
QtiPlot&#39;s main window.
Definition: ApplicationWindow.h:133
CaptionPolicy d_caption_policy
The caption policy.
Definition: MdiSubWindow.h:199
virtual void restore(const QStringList &)
Not implemented yet.
Definition: MdiSubWindow.h:107
ApplicationWindow * d_app
Pointer to the application window.
Definition: MdiSubWindow.h:185
QString windowLabel()
Return the window label.
Definition: MdiSubWindow.h:79
Definition: MdiSubWindow.h:73
void statusChanged(MdiSubWindow *)
Emitted when the window status changed.
QSize d_min_restore_size
Stores the size the window had before a change state event to minimized.
Definition: MdiSubWindow.h:205
caption detemined by the window label
Definition: MdiSubWindow.h:70
MdiSubWindow(const QString &label=QString(), ApplicationWindow *app=0, const QString &name=QString(), Qt::WFlags f=0)
Constructor.
Definition: MdiSubWindow.cpp:49
Status
Definition: MdiSubWindow.h:73
bool eventFilter(QObject *object, QEvent *e)
Filters other object&#39;s events (customizes title bar&#39;s context menu)
Definition: MdiSubWindow.cpp:173
void showContextMenu()
Show the context menu.
virtual void exportPDF(const QString &)
Definition: MdiSubWindow.h:109
void setMaximized()
Definition: MdiSubWindow.cpp:256
void setName(const QString &s)
Set the window name.
Definition: MdiSubWindow.h:86
CaptionPolicy
Possible window captions.
Definition: MdiSubWindow.h:68
Base class of all MDI client windows.
Definition: MdiSubWindow.h:51
CaptionPolicy captionPolicy()
Return the caption policy.
Definition: MdiSubWindow.h:89
void setStatus(Status s)
Set the window status flag (hidden, normal, minimized or maximized)
Definition: MdiSubWindow.cpp:198
virtual void print(QPrinter *)
Definition: MdiSubWindow.h:158
Status status()
Return the window status flag (hidden, normal, minimized or maximized)
Definition: MdiSubWindow.h:101
static QString parseMacAsciiFile(const QString &fname, const QString &commentString, int ignoreFirstLines, int maxRows, int &rows)
Used to parse ASCII files with carriage return (&#39;&#39;) endline.
Definition: MdiSubWindow.cpp:324
void closedWindow(MdiSubWindow *)
Emitted when the window was closed.
void modifiedWindow(MdiSubWindow *)
QString name()
Return the window name.
Definition: MdiSubWindow.h:84
void setNormal()
Definition: MdiSubWindow.cpp:242
virtual void print()
Definition: MdiSubWindow.h:157