1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
Copyright (C) 2000-2004 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __ko_main_window_h__
#define __ko_main_window_h__
#include <tdeparts/mainwindow.h>
#include <tdefiledialog.h>
#include <koffice_export.h>
#include "KoDocument.h"
class TQLabel;
class KoView;
class KoMainWindowPrivate;
class KURL;
class KRecentFilesAction;
class KoFilterManager;
class DCOPObject;
namespace KParts
{
class PartManager;
}
/**
* @brief Main window for a KOffice application
*
* This class is used to represent a main window
* of a KOffice component. Each main window contains
* a menubar and some toolbars.
*
* @note This class does NOT need to be subclassed in your application.
*/
class KOFFICECORE_EXPORT KoMainWindow : public KParts::MainWindow
{
Q_OBJECT
public:
/**
* Constructor.
*
* Initializes a KOffice main window (with its basic GUI etc.).
*/
KoMainWindow( TDEInstance *instance, const char *_name = 0 );
/**
* Destructor.
*/
~KoMainWindow();
/**
* Called when a document is assigned to this mainwindow.
* This creates a view for this document, makes it the active part, etc.
*/
virtual void setRootDocument( KoDocument *doc );
/**
* This is used to handle the document used at start up before it actually
* added as root document.
*/
void setDocToOpen( KoDocument *doc );
/**
* Update caption from document info - call when document info
* (title in the about page) changes.
*/
virtual void updateCaption();
/**
* Retrieves the document that is displayed in the mainwindow.
*/
virtual KoDocument* rootDocument() const;
virtual KoView *rootView() const;
virtual KParts::PartManager *partManager();
/**
* Prints the document
* @param quick whether the print setup dialog is to be displayed
**/
void print(bool quick);
/**
* The application should call this to show or hide a toolbar.
* It also takes care of the corresponding action in the settings menu.
*/
void showToolbar( const char * tbName, bool shown );
/**
* @return TRUE if the toolbar @p tbName is visible
*/
bool toolbarIsVisible(const char *tbName);
/**
* Get hold of the label in the statusbar, to write messages to it.
* You can also insert other items in the status bar by using TQStatusBar::addWidget.
*/
TQLabel * statusBarLabel();
/**
* Sets the maximum number of recent documents entries.
*/
void setMaxRecentItems(uint _number);
/**
* The document opened a URL -> store into recent documents list.
*/
void addRecentURL( const KURL& url );
/**
* Load the desired document and show it.
* @param url the URL to open
*
* @return TRUE on success.
*/
virtual bool openDocument( const KURL & url );
/**
* Load the URL into this document (and make it root doc after loading)
*
* Special method for KoApplication::start, don't use.
*/
bool openDocument( KoDocument *newdoc, const KURL & url );
virtual DCOPObject * dcopObject();
/**
* Reloads the recent documents list.
*/
void reloadRecentFileList();
/**
* Updates the window caption based on the document info and path.
*/
virtual void updateCaption( const TQString caption, bool mod );
void updateReloadFileAction(KoDocument *doc);
void updateVersionsFileAction(KoDocument *doc);
signals:
/**
* This signal is emitted if the document has been saved successfully.
*/
void documentSaved();
/// This signals is emmitted before the save dialog is shown
void saveDialogShown();
public slots:
/**
* Slot for eMailing the document using KMail
*
* This is a very simple extension that will allow any document
* that is currently being edited to be emailed using KMail.
*/
void slotEmailFile();
/**
* Slot for opening a new document.
*
* If the current document is empty, the new document replaces it.
* If not, a new shell will be opened for showing the document.
*/
virtual void slotFileNew();
/**
* Slot for opening a saved file.
*
* If the current document is empty, the opened document replaces it.
* If not a new shell will be opened for showing the opened file.
*/
virtual void slotFileOpen();
/**
* Slot for opening a file among the recently opened files.
*
* If the current document is empty, the opened document replaces it.
* If not a new shell will be opened for showing the opened file.
*/
virtual void slotFileOpenRecent( const KURL & );
/**
* Saves the current document with the current name.
*/
virtual void slotFileSave();
/**
* Saves the current document with a new name.
*/
virtual void slotFileSaveAs();
/**
* Prints the actual document.
*/
virtual void slotFilePrint();
/**
* Show a print preview
*/
void slotFilePrintPreview(); // make virtual later
/**
* Show a dialog with author and document information.
*/
virtual void slotDocumentInfo();
/**
* Closes the document.
*/
virtual void slotFileClose();
/**
* Closes the shell.
*/
virtual void slotFileQuit();
/**
* Configure key bindings.
*/
virtual void slotConfigureKeys();
/**
* Configure toolbars.
*/
virtual void slotConfigureToolbars();
/**
* Post toolbar config.
* (Plug action lists back in, etc.)
*/
virtual void slotNewToolbarConfig();
/**
* Shows or hides a toolbar
*/
virtual void slotToolbarToggled( bool toggle );
/**
* View splitting stuff
*/
virtual void slotSplitView();
virtual void slotRemoveView();
virtual void slotSetOrientation();
/**
* Close all views
*/
virtual void slotCloseAllViews();
/**
* Reload file
*/
void slotReloadFile();
/**
* This will call a dialogbox to add version to list of files
*/
void slotVersionsFile();
/**
* File --> Import
*
* This will call slotFileOpen(). To differentiate this from an ordinary
* call to slotFileOpen() call @ref isImporting().
*/
void slotImportFile();
/**
* File --> Export
*
* This will call slotFileSaveAs(). To differentiate this from an ordinary
* call to slotFileSaveAs() call @ref isExporting().
*/
void slotExportFile();
protected: // protected methods are mostly for koshell, it's the only one deriving from KoMainWindow
/// Helper method for slotFileNew and slotFileClose
void chooseNewDocument( int /*KoDocument::InitDocFlags*/ initDocFlags );
/**
* Special method for KOShell, to allow switching the root
* document (and its views) among a set of them.
*/
void setRootDocumentDirect( KoDocument *doc, const TQPtrList<KoView> & views );
/**
* Create a new empty document.
*/
virtual KoDocument* createDoc() const;
/**
* Saves the document, asking for a filename if necessary.
*
* @param saveas if set to TRUE the user is always prompted for a filename
*
* @param silent if set to TRUE rootDocument()->setTitleModified will not be called.
*
* @return TRUE on success, false on error or cancel
* (don't display anything in this case, the error dialog box is also implemented here
* but restore the original URL in slotFileSaveAs)
*/
virtual bool saveDocument( bool saveas = false, bool silent = false );
virtual void closeEvent( TQCloseEvent * e );
virtual void resizeEvent( TQResizeEvent * e );
/**
* Ask user about saving changes to the document upon exit.
*/
virtual bool queryClose();
virtual bool openDocumentInternal( const KURL & url, KoDocument * newdoc = 0L );
/**
* Returns whether or not the current slotFileSave[As]() or saveDocument()
* call is actually an export operation (like File --> Export).
*
* If this is true, you must call KoDocument::export() instead of
* KoDocument::save() or KoDocument::saveAs(), in any reimplementation of
* saveDocument().
*/
bool isExporting() const;
/**
* Returns whether or not the current slotFileOpen() or openDocument()
* call is actually an import operation (like File --> Import).
*
* If this is true, you must call KoDocument::import() instead of
* KoDocument::openURL(), in any reimplementation of openDocument() or
* openDocumentInternal().
*/
bool isImporting() const;
/**
* Save the list of recent files.
*/
void saveRecentFiles();
KRecentFilesAction *recentAction() const { return m_recent; }
private:
/**
* Asks the user if they really want to save the document.
* Called only if outputFormat != nativeFormat.
*
* @return true if the document should be saved
*/
bool exportConfirmation( const TQCString &outputFormat );
void saveWindowSettings();
KRecentFilesAction *m_recent;
protected slots:
virtual void slotActivePartChanged( KParts::Part *newPart );
private slots:
void slotProgress(int value);
void slotLoadCompleted();
void slotLoadCanceled (const TQString &);
void slotSaveCompleted();
void slotSaveCanceled(const TQString &);
private:
KoMainWindowPrivate *d;
};
#endif
|