1
/***************************************************************************
4
--------------------------------------------------------------------
5
Copyright : (C) 2006 by Ion Vasilief,
6
Tilman Hoener zu Siederdissen,
8
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net,
10
Description : MDI window widget
12
***************************************************************************/
14
/***************************************************************************
16
* This program is free software; you can redistribute it and/or modify *
17
* it under the terms of the GNU General Public License as published by *
18
* the Free Software Foundation; either version 2 of the License, or *
19
* (at your option) any later version. *
21
* This program is distributed in the hope that it will be useful, *
22
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
24
* GNU General Public License for more details. *
26
* You should have received a copy of the GNU General Public License *
27
* along with this program; if not, write to the Free Software *
28
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
29
* Boston, MA 02110-1301 USA *
31
***************************************************************************/
42
* \brief Base class of all MDI client windows.
44
* These are the main objects of every Qtiplot project.
45
* All content (apart from the directory structure) is managed by subclasses of MyWidget.
47
* \section future Future Plans
48
* Rename to MDIWindow or View (or some yet-to-find better name; ideas anyone?).
50
* \sa Folder, ApplicationWindow
52
class MyWidget: public QWidget
60
* \param label window label
61
* \param parent parent widget
62
* \param name window name
63
* \param f window flags
64
* \sa setCaptionPolicy(), captionPolicy()
66
MyWidget(const QString& label = QString(), QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0);
68
enum CaptionPolicy{Name = 0, Label = 1, Both = 2};
69
enum Status{Hidden = -1, Normal = 0, Minimized = 1, Maximized = 2};
71
//! Return the window label
72
QString windowLabel(){return QString(w_label);};
73
//! Set the window label
74
void setWindowLabel(const QString& s) { w_label = s; updateCaption();};
76
//! Return the window name
77
QString name(){return objectName();};
78
//! Set the window name
79
void setName(const QString& s){setObjectName(s); updateCaption();};
81
//! Return the caption policy
82
CaptionPolicy captionPolicy(){return caption_policy;};
83
//! Set the caption policy
85
* The caption policy can be
86
* Name -> caption determined by the window name
87
* Label -> caption detemined by the window label
88
* Both -> caption = "name - label"
90
void setCaptionPolicy(CaptionPolicy policy) { caption_policy = policy; updateCaption(); }
91
//! Set the widget's name
92
void setName(const char *newname) { QWidget::setName(newname); updateCaption(); }
94
//! Return the creation date
95
QString birthDate(){return birthdate;};
96
//! Set the creation date
97
void setBirthDate(const QString& s){birthdate = s;};
99
//! Return the window status as a string
101
//! Return the window status flag (hidden, normal, minimized or maximized)
102
Status status(){return w_status;};
103
//! Set the window status flag (hidden, normal, minimized or maximized)
104
void setStatus(Status s);
106
virtual QString saveAsTemplate(const QString& ){return QString();};
108
//! Not implemented yet
109
virtual void restore(const QStringList& ){};
111
virtual void print(){};
112
virtual void exportPDF(const QString&){};
114
virtual QString saveToString(const QString &){return QString();};
116
// TODO: make this return something useful
117
//! Size of the widget as a string
118
virtual QString sizeToString();
120
//!Notifies that a window was hidden by a direct user action
121
virtual void setHidden();
124
//! Close event handler
126
* Ask the user "delete, hide, or cancel?" if the
127
* "ask on close" flag is set.
129
void closeEvent( QCloseEvent *);
130
//! Toggle the "ask on close" flag
131
void askOnCloseEvent(bool ask){askOnClose = ask;};
132
//! Filters other object's events (customizes title bar's context menu)
133
bool eventFilter(QObject *object, QEvent *e);
135
//! Returns the pointer to the parent folder of the window
136
Folder* folder(){return parentFolder;};
138
//! Initializes the pointer to the parent folder of the window
139
void setFolder(Folder* f){parentFolder = f;};
141
//! Notifies the main application that the window has been modified
142
void notifyChanges(){emit modifiedWindow(this);};
144
static double stringToDouble(const QString& s);
151
//! Emitted when the window was closed
152
void closedWindow(MyWidget *);
153
//! Emitted when the window was hidden
154
void hiddenWindow(MyWidget *);
155
void modifiedWindow(QWidget *);
156
void resizedWindow(QWidget *);
157
//! Emitted when the window status changed
158
void statusChanged(MyWidget *);
159
//! Emitted when the title bar recieves a QContextMenuEvent
160
void showTitleBarMenu();
163
//! Catches parent changes (in order to gain access to the title bar)
164
virtual void changeEvent(QEvent *event);
165
//! Title bar of this MDI window if it currently belongs to a QWorkspace, NULL else
169
//! Set caption according to current CaptionPolicy, name and label
170
void updateCaption();
172
//!Pointer to the parent folder of the window
173
Folder *parentFolder;
176
* \sa setWindowLabel(), windowLabel(), setCaptionPolicy()
179
//! The creation date
181
//! The window status
183
//! The caption policy
185
* \sa setCaptionPolicy(), captionPolicy()
187
CaptionPolicy caption_policy;
188
//! Toggle on/off: Ask the user "delete, hide, or cancel?" on a close event