QtiPlot 0.9.8.2
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     // 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     QSize minRestoreSize(){return d_min_restore_size;};
00143 
00145     /*
00146      * It counts the number of valid rows to be imported and the number of first lines to be ignored.
00147      * It creates a temporary file with '\n' terminated lines which can be correctly read by QTextStream
00148      * and returnes a path to this file.
00149      */
00150     static QString parseAsciiFile(const QString& fname, const QString &commentString, int endLine,
00151                                   int ignoreFirstLines, int maxRows, int& rows);
00152 
00153 public slots:
00154     virtual void print(){};
00155     virtual void print(QPrinter *){};
00157     void notifyChanges(){emit modifiedWindow(this);};
00158 
00159 signals:
00161     void closedWindow(MdiSubWindow *);
00163     void hiddenWindow(MdiSubWindow *);
00164     void modifiedWindow(MdiSubWindow *);
00165     void resizedWindow(MdiSubWindow *);
00167     void statusChanged(MdiSubWindow *);
00169     void showContextMenu();
00170 
00171 protected:
00173     virtual void changeEvent(QEvent *event);
00174 
00175 private:
00177     static QString parseMacAsciiFile(const QString& fname, const QString &commentString,
00178                              int ignoreFirstLines, int maxRows, int& rows);
00180     void updateCaption();
00182     ApplicationWindow *d_app;
00184     Folder *d_folder;
00186 
00189     QString d_label;
00191     Status d_status;
00193 
00196     CaptionPolicy d_caption_policy;
00198     bool d_confirm_close;
00200     QString d_birthdate;
00202     QSize d_min_restore_size;
00203 };
00204 
00205 #endif