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