MdiSubWindow.h
Go to the documentation of this file.
/***************************************************************************
File : MdiSubWindow.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 by Ion Vasilief, Knut Franke
Email (use @ for *) : ion_vasilief*yahoo.fr, knut.franke*gmx.de
Description : MDI sub window
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef MdiSubWindow_H
#define MdiSubWindow_H
#include <QMdiSubWindow>
class QEvent;
class QCloseEvent;
class QString;
class Folder;
class ApplicationWindow;
class MdiSubWindow: public QMdiSubWindow
{
Q_OBJECT
public:
MdiSubWindow(const QString& label = QString(), ApplicationWindow *app = 0, const QString& name = QString(), Qt::WFlags f = 0);
enum CaptionPolicy{
Name = 0,
Label = 1,
Both = 2
};
enum Status{Hidden = -1, Normal = 0, Minimized = 1, Maximized = 2};
ApplicationWindow *applicationWindow(){return d_app;};
QString windowLabel(){return QString(d_label);};
void setWindowLabel(const QString& s) { d_label = s; updateCaption();};
QString name(){return objectName();};
void setName(const QString& s){setObjectName(s); updateCaption();};
CaptionPolicy captionPolicy(){return d_caption_policy;};
void setCaptionPolicy(CaptionPolicy policy) { d_caption_policy = policy; updateCaption(); }
QString birthDate(){return d_birthdate;};
void setBirthDate(const QString& s){d_birthdate = s;};
QString aspect();
Status status(){return d_status;};
void setStatus(Status s);
// TODO:
virtual void restore(const QStringList& ){};
virtual void save(const QString&, const QString &, bool = false){};
virtual void exportPDF(const QString&){};
// TODO: make this return something useful
virtual QString sizeToString();
virtual void setHidden();
//event handlers
void closeEvent( QCloseEvent *);
void resizeEvent( QResizeEvent* );
void askOnCloseEvent(bool ask){d_confirm_close = ask;};
bool eventFilter(QObject *object, QEvent *e);
Folder* folder(){return d_folder;};
void setFolder(Folder* f){d_folder = f;};
void setNormal();
void setMinimized();
void setMaximized();
void restoreWindow();
QSize minRestoreSize(){return d_min_restore_size;};
/*
* It counts the number of valid rows to be imported and the number of first lines to be ignored.
* It creates a temporary file with '\n' terminated lines which can be correctly read by QTextStream
* and returnes a path to this file.
*/
static QString parseAsciiFile(const QString& fname, const QString &commentString, int endLine,
int ignoreFirstLines, int maxRows, int& rows);
public slots:
virtual void print(){};
virtual void print(QPrinter *){};
void notifyChanges(){emit modifiedWindow(this);};
signals:
void closedWindow(MdiSubWindow *);
void hiddenWindow(MdiSubWindow *);
void modifiedWindow(MdiSubWindow *);
void resizedWindow(MdiSubWindow *);
void statusChanged(MdiSubWindow *);
void showContextMenu();
protected:
virtual void changeEvent(QEvent *event);
private:
static QString parseMacAsciiFile(const QString& fname, const QString &commentString,
int ignoreFirstLines, int maxRows, int& rows);
void updateCaption();
ApplicationWindow *d_app;
Folder *d_folder;
QString d_label;
Status d_status;
CaptionPolicy d_caption_policy;
bool d_confirm_close;
QString d_birthdate;
QSize d_min_restore_size;
};
#endif
MdiSubWindow::restoreWindow
void restoreWindow()
Show window making sure that layers in MultiLayer windows are not resized.
Definition: MdiSubWindow.cpp:214
MdiSubWindow::setMinimized
void setMinimized()
Definition: MdiSubWindow.cpp:249
MdiSubWindow::closeEvent
void closeEvent(QCloseEvent *)
Close event handler.
Definition: MdiSubWindow.cpp:99
MdiSubWindow::resizedWindow
void resizedWindow(MdiSubWindow *)
MdiSubWindow::d_folder
Folder * d_folder
Pointer to the parent folder of the window.
Definition: MdiSubWindow.h:187
MdiSubWindow::Normal
Definition: MdiSubWindow.h:73
MdiSubWindow::changeEvent
virtual void changeEvent(QEvent *event)
Catches status changes.
Definition: MdiSubWindow.cpp:153
MdiSubWindow::setBirthDate
void setBirthDate(const QString &s)
Set the creation date.
Definition: MdiSubWindow.h:96
MdiSubWindow::folder
Folder * folder()
Returns the pointer to the parent folder of the window.
Definition: MdiSubWindow.h:132
MdiSubWindow::d_status
Status d_status
The window status.
Definition: MdiSubWindow.h:194
MdiSubWindow::updateCaption
void updateCaption()
Set caption according to current CaptionPolicy, name and label.
Definition: MdiSubWindow.cpp:67
MdiSubWindow::setHidden
virtual void setHidden()
Notifies that a window was hidden by a direct user action.
Definition: MdiSubWindow.cpp:207
MdiSubWindow::sizeToString
virtual QString sizeToString()
Size of the widget as a string.
Definition: MdiSubWindow.cpp:148
MdiSubWindow::d_label
QString d_label
The window label.
Definition: MdiSubWindow.h:192
MdiSubWindow::d_confirm_close
bool d_confirm_close
Toggle on/off: Ask the user &quot;delete, hide, or cancel?&quot; on a close event.
Definition: MdiSubWindow.h:201
MdiSubWindow::askOnCloseEvent
void askOnCloseEvent(bool ask)
Toggle the &quot;ask on close&quot; flag.
Definition: MdiSubWindow.h:128
MdiSubWindow::setFolder
void setFolder(Folder *f)
Initializes the pointer to the parent folder of the window.
Definition: MdiSubWindow.h:135
MdiSubWindow::notifyChanges
void notifyChanges()
Notifies the main application that the window has been modified.
Definition: MdiSubWindow.h:160
MdiSubWindow::d_birthdate
QString d_birthdate
The creation date.
Definition: MdiSubWindow.h:203
MdiSubWindow::aspect
QString aspect()
Return the window status as a string.
Definition: MdiSubWindow.cpp:125
MdiSubWindow::applicationWindow
ApplicationWindow * applicationWindow()
Returns a pointer to the parent application.
Definition: MdiSubWindow.h:76
MdiSubWindow::minRestoreSize
QSize minRestoreSize()
Returns the size the window had before a change state event to minimized.
Definition: MdiSubWindow.h:145
MdiSubWindow::parseAsciiFile
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
MdiSubWindow::setWindowLabel
void setWindowLabel(const QString &s)
Set the window label.
Definition: MdiSubWindow.h:81
MdiSubWindow::Name
caption determined by the window name
Definition: MdiSubWindow.h:69
MdiSubWindow::Hidden
Definition: MdiSubWindow.h:73
MdiSubWindow::resizeEvent
void resizeEvent(QResizeEvent *)
Definition: MdiSubWindow.cpp:93
Folder
Folder for the project explorer.
Definition: Folder.h:53
MdiSubWindow::birthDate
QString birthDate()
Return the creation date.
Definition: MdiSubWindow.h:94
MdiSubWindow::Minimized
Definition: MdiSubWindow.h:73
MdiSubWindow::setCaptionPolicy
void setCaptionPolicy(CaptionPolicy policy)
Set the caption policy.
Definition: MdiSubWindow.h:91
MdiSubWindow::Both
caption = &quot;name - label&quot;
Definition: MdiSubWindow.h:71
MdiSubWindow::hiddenWindow
void hiddenWindow(MdiSubWindow *)
Emitted when the window was hidden.
MdiSubWindow::save
virtual void save(const QString &, const QString &, bool=false)
Definition: MdiSubWindow.h:108
ApplicationWindow
QtiPlot&#39;s main window.
Definition: ApplicationWindow.h:133
MdiSubWindow::d_caption_policy
CaptionPolicy d_caption_policy
The caption policy.
Definition: MdiSubWindow.h:199
MdiSubWindow::restore
virtual void restore(const QStringList &)
Not implemented yet.
Definition: MdiSubWindow.h:107
MdiSubWindow::d_app
ApplicationWindow * d_app
Pointer to the application window.
Definition: MdiSubWindow.h:185
MdiSubWindow::windowLabel
QString windowLabel()
Return the window label.
Definition: MdiSubWindow.h:79
MdiSubWindow::Maximized
Definition: MdiSubWindow.h:73
MdiSubWindow::statusChanged
void statusChanged(MdiSubWindow *)
Emitted when the window status changed.
MdiSubWindow::d_min_restore_size
QSize d_min_restore_size
Stores the size the window had before a change state event to minimized.
Definition: MdiSubWindow.h:205
MdiSubWindow::Label
caption detemined by the window label
Definition: MdiSubWindow.h:70
MdiSubWindow::MdiSubWindow
MdiSubWindow(const QString &label=QString(), ApplicationWindow *app=0, const QString &name=QString(), Qt::WFlags f=0)
Constructor.
Definition: MdiSubWindow.cpp:49
MdiSubWindow::Status
Status
Definition: MdiSubWindow.h:73
MdiSubWindow::eventFilter
bool eventFilter(QObject *object, QEvent *e)
Filters other object&#39;s events (customizes title bar&#39;s context menu)
Definition: MdiSubWindow.cpp:173
MdiSubWindow::showContextMenu
void showContextMenu()
Show the context menu.
MdiSubWindow::exportPDF
virtual void exportPDF(const QString &)
Definition: MdiSubWindow.h:109
MdiSubWindow::setMaximized
void setMaximized()
Definition: MdiSubWindow.cpp:256
MdiSubWindow::setName
void setName(const QString &s)
Set the window name.
Definition: MdiSubWindow.h:86
MdiSubWindow::CaptionPolicy
CaptionPolicy
Possible window captions.
Definition: MdiSubWindow.h:68
MdiSubWindow
Base class of all MDI client windows.
Definition: MdiSubWindow.h:51
MdiSubWindow::captionPolicy
CaptionPolicy captionPolicy()
Return the caption policy.
Definition: MdiSubWindow.h:89
MdiSubWindow::setStatus
void setStatus(Status s)
Set the window status flag (hidden, normal, minimized or maximized)
Definition: MdiSubWindow.cpp:198
MdiSubWindow::print
virtual void print(QPrinter *)
Definition: MdiSubWindow.h:158
MdiSubWindow::status
Status status()
Return the window status flag (hidden, normal, minimized or maximized)
Definition: MdiSubWindow.h:101
MdiSubWindow::parseMacAsciiFile
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
MdiSubWindow::closedWindow
void closedWindow(MdiSubWindow *)
Emitted when the window was closed.
MdiSubWindow::modifiedWindow
void modifiedWindow(MdiSubWindow *)
MdiSubWindow::name
QString name()
Return the window name.
Definition: MdiSubWindow.h:84
MdiSubWindow::setNormal
void setNormal()
Definition: MdiSubWindow.cpp:242
MdiSubWindow::print
virtual void print()
Definition: MdiSubWindow.h:157