MdiSubWindow.h

Go to the documentation of this file.
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     virtual QString saveAsTemplate(const QString& ){return QString();};
00106     // TODO:
00108     virtual void restore(const QStringList& ){};
00109 
00110     virtual void exportPDF(const QString&){};
00111 
00112     virtual QString saveToString(const QString &, bool = false){return QString();};
00113 
00114     // TODO: make this return something useful
00116     virtual QString sizeToString();
00117 
00119     virtual void setHidden();
00120 
00121     //event handlers
00123 
00127     void closeEvent( QCloseEvent *);
00128     void resizeEvent( QResizeEvent* );
00129 
00131     void askOnCloseEvent(bool ask){d_confirm_close = ask;};
00133     bool eventFilter(QObject *object, QEvent *e);
00135     Folder* folder(){return d_folder;};
00136 
00138     void setFolder(Folder* f){d_folder = f;};
00139 
00141     void notifyChanges(){emit modifiedWindow(this);};
00142 
00143     void setNormal();
00144     void setMinimized();
00145     void setMaximized();
00146 
00148     QSize minRestoreSize(){return d_min_restore_size;};
00149 
00151     /*
00152      * It counts the number of valid rows to be imported and the number of first lines to be ignored.
00153      * It creates a temporary file with '\n' terminated lines which can be correctly read by QTextStream
00154      * and returnes a path to this file.
00155      */
00156     static QString parseAsciiFile(const QString& fname, const QString &commentString, int endLine,
00157                                   int ignoreFirstLines, int maxRows, int& rows);
00158 
00159 public slots:
00160     virtual void print(){};
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

Generated on Tue Jun 17 08:36:12 2008 for QtiPlot by  doxygen 1.5.5