QtiPlot 0.9.8.2
|
00001 /*************************************************************************** 00002 File : MdiSubWindow.h 00003 Project : QtiPlot 00004 -------------------------------------------------------------------- 00005 Copyright : (C) 2006 by Ion Vasilief, Knut Franke 00006 Email (use @ for *) : ion_vasilief*yahoo.fr, knut.franke*gmx.de 00007 Description : MDI sub window 00008 00009 ***************************************************************************/ 00010 00011 /*************************************************************************** 00012 * * 00013 * This program is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU General Public License as published by * 00015 * the Free Software Foundation; either version 2 of the License, or * 00016 * (at your option) any later version. * 00017 * * 00018 * This program is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00021 * GNU General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU General Public License * 00024 * along with this program; if not, write to the Free Software * 00025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00026 * Boston, MA 02110-1301 USA * 00027 * * 00028 ***************************************************************************/ 00029 #ifndef MdiSubWindow_H 00030 #define MdiSubWindow_H 00031 00032 #include <QMdiSubWindow> 00033 00034 class QEvent; 00035 class QCloseEvent; 00036 class QString; 00037 class Folder; 00038 class ApplicationWindow; 00039 00051 class MdiSubWindow: public QMdiSubWindow 00052 { 00053 Q_OBJECT 00054 00055 public: 00056 00058 00065 MdiSubWindow(const QString& label = QString(), ApplicationWindow *app = 0, const QString& name = QString(), Qt::WFlags f = 0); 00066 00068 enum CaptionPolicy{ 00069 Name = 0, 00070 Label = 1, 00071 Both = 2 00072 }; 00073 enum Status{Hidden = -1, Normal = 0, Minimized = 1, Maximized = 2}; 00074 00076 ApplicationWindow *applicationWindow(){return d_app;}; 00077 00079 QString windowLabel(){return QString(d_label);}; 00081 void setWindowLabel(const QString& s) { d_label = s; updateCaption();}; 00082 00084 QString name(){return objectName();}; 00086 void setName(const QString& s){setObjectName(s); updateCaption();}; 00087 00089 CaptionPolicy captionPolicy(){return d_caption_policy;}; 00091 void setCaptionPolicy(CaptionPolicy policy) { d_caption_policy = policy; updateCaption(); } 00092 00094 QString birthDate(){return d_birthdate;}; 00096 void setBirthDate(const QString& s){d_birthdate = s;}; 00097 00099 QString aspect(); 00101 Status status(){return d_status;}; 00103 void setStatus(Status s); 00104 00105 // TODO: 00107 virtual void restore(const QStringList& ){}; 00108 virtual void save(const QString&, const QString &, bool = false){}; 00109 virtual void exportPDF(const QString&){}; 00110 00111 // TODO: make this return something useful 00113 virtual QString sizeToString(); 00114 00116 virtual void setHidden(); 00117 00118 //event handlers 00120 00124 void closeEvent( QCloseEvent *); 00125 void resizeEvent( QResizeEvent* ); 00126 00128 void askOnCloseEvent(bool ask){d_confirm_close = ask;}; 00130 bool eventFilter(QObject *object, QEvent *e); 00132 Folder* folder(){return d_folder;}; 00133 00135 void setFolder(Folder* f){d_folder = f;}; 00136 00137 void setNormal(); 00138 void setMinimized(); 00139 void setMaximized(); 00140 00142 void restoreWindow(); 00143 00145 QSize minRestoreSize(){return d_min_restore_size;}; 00146 00148 /* 00149 * It counts the number of valid rows to be imported and the number of first lines to be ignored. 00150 * It creates a temporary file with '\n' terminated lines which can be correctly read by QTextStream 00151 * and returnes a path to this file. 00152 */ 00153 static QString parseAsciiFile(const QString& fname, const QString &commentString, int endLine, 00154 int ignoreFirstLines, int maxRows, int& rows); 00155 00156 public slots: 00157 virtual void print(){}; 00158 virtual void print(QPrinter *){}; 00160 void notifyChanges(){emit modifiedWindow(this);}; 00161 00162 signals: 00164 void closedWindow(MdiSubWindow *); 00166 void hiddenWindow(MdiSubWindow *); 00167 void modifiedWindow(MdiSubWindow *); 00168 void resizedWindow(MdiSubWindow *); 00170 void statusChanged(MdiSubWindow *); 00172 void showContextMenu(); 00173 00174 protected: 00176 virtual void changeEvent(QEvent *event); 00177 00178 private: 00180 static QString parseMacAsciiFile(const QString& fname, const QString &commentString, 00181 int ignoreFirstLines, int maxRows, int& rows); 00183 void updateCaption(); 00185 ApplicationWindow *d_app; 00187 Folder *d_folder; 00189 00192 QString d_label; 00194 Status d_status; 00196 00199 CaptionPolicy d_caption_policy; 00201 bool d_confirm_close; 00203 QString d_birthdate; 00205 QSize d_min_restore_size; 00206 }; 00207 00208 #endif