KoMainWindow.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 Copyright (C) 2000-2006 David Faure <faure@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "KoMainWindow.h"
22#include "KoDocument.h"
23#include "KoView.h"
24#include "KoFilterManager.h"
25#include "KoDocumentInfo.h"
26#include "KoDocumentInfoDlg.h"
27#include "KoQueryTrader.h"
28#include "KoMainWindowIface.h"
29#include "KoFrame.h"
30#include "KoFileDialog.h"
31#include "Koversiondialog.h"
33#include "KoSpeaker.h"
34
35#include <tdeaboutdata.h>
36#include <kprinter.h>
37#include <tdeversion.h>
38#include <kstdaction.h>
39#include <tdeapplication.h>
40#include <tdemessagebox.h>
41#include <kstandarddirs.h>
42#include <tdeio/netaccess.h>
43#include <kkeydialog.h>
44#include <kedittoolbar.h>
45#include <kprogress.h>
46#include <kpushbutton.h>
47#include <kdebug.h>
48#include <tdetempfile.h>
49#include <tderecentdocument.h>
50#include <tdeparts/partmanager.h>
51#include <tdeparts/plugin.h>
52#include <tdeparts/event.h>
53#include <tdelocale.h>
54#include <kstatusbar.h>
55#include <tdeglobalsettings.h>
56#include <ksharedptr.h>
57
58#include <tqobjectlist.h>
59
60#include <unistd.h>
61#include <stdlib.h>
62
63class KoPartManager : public KParts::PartManager
64{
65public:
66 KoPartManager( TQWidget * parent, const char * name = 0L )
67 : KParts::PartManager( parent, name )
68 {
69 setSelectionPolicy( KParts::PartManager::TriState );
70 setAllowNestedParts( true );
71 setIgnoreScrollBars( true );
72 // Allow right-click on embedded objects (without activating them)
73 // But beware: this means right-click on parent, from embedded object,
74 // doesn't make the parent active first...
75 setActivationButtonMask( TQt::LeftButton | TQt::MidButton );
76 }
77 virtual bool eventFilter( TQObject *obj, TQEvent *ev )
78 {
79 if ( !obj->isWidgetType() || ::tqt_cast<KoFrame *>( obj ) )
80 return false;
81 return KParts::PartManager::eventFilter( obj, ev );
82 }
83};
84
85class KoMainWindowPrivate
86{
87public:
88 KoMainWindowPrivate()
89 {
90 m_rootDoc = 0L;
91 m_docToOpen = 0L;
92 m_manager = 0L;
93 bMainWindowGUIBuilt = false;
94 m_forQuit=false;
95 m_splitted=false;
96 m_activePart = 0L;
97 m_activeView = 0L;
98 m_splitter=0L;
99 m_orientation=0L;
100 m_removeView=0L;
101 m_toolbarList.setAutoDelete( true );
102 m_firstTime=true;
103 m_progress=0L;
104 m_paDocInfo = 0;
105 m_paSave = 0;
106 m_paSaveAs = 0;
107 m_paPrint = 0;
108 m_paPrintPreview = 0;
109 statusBarLabel = 0L;
110 m_dcopObject = 0;
111 m_sendfile = 0;
112 m_paCloseFile = 0L;
113 m_reloadfile = 0L;
114 m_versionsfile = 0L;
115 m_importFile = 0;
116 m_exportFile = 0;
117 m_isImporting = false;
118 m_isExporting = false;
119 m_windowSizeDirty = false;
120 m_lastExportSpecialOutputFlag = 0;
121
122 // TTS accessibility enhancement (only if KDE 3.4 or later and KTTSD daemon is installed.)
124 if (kospeaker)
125 m_koSpeaker = kospeaker;
126 else
127 m_koSpeaker = new KoSpeaker();
128 } else
129 m_koSpeaker = 0;
130 }
131 ~KoMainWindowPrivate()
132 {
133 delete m_dcopObject;
134 }
135
136 KoDocument *m_rootDoc;
137 KoDocument *m_docToOpen;
138 TQPtrList<KoView> m_rootViews;
139 KParts::PartManager *m_manager;
140
141 KParts::Part *m_activePart;
142 KoView *m_activeView;
143
144 TQLabel * statusBarLabel;
145 KProgress *m_progress;
146
147 TQPtrList<TDEAction> m_splitViewActionList;
148 // This additional list is needed, because we don't plug
149 // the first list, when an embedded view gets activated (Werner)
150 TQPtrList<TDEAction> m_veryHackyActionList;
151 TQSplitter *m_splitter;
152 TDESelectAction *m_orientation;
153 TDEAction *m_removeView;
154 KoMainWindowIface *m_dcopObject;
155
156 TQPtrList <TDEAction> m_toolbarList;
157
158 bool bMainWindowGUIBuilt;
159 bool m_splitted;
160 bool m_forQuit;
161 bool m_firstTime;
162 bool m_windowSizeDirty;
163
164 TDEAction *m_paDocInfo;
165 TDEAction *m_paSave;
166 TDEAction *m_paSaveAs;
167 TDEAction *m_paPrint;
168 TDEAction *m_paPrintPreview;
169 TDEAction *m_sendfile;
170 TDEAction *m_paCloseFile;
171 TDEAction *m_reloadfile;
172 TDEAction *m_versionsfile;
173 TDEAction *m_importFile;
174 TDEAction *m_exportFile;
175
176 bool m_isImporting;
177 bool m_isExporting;
178
179 KURL m_lastExportURL;
180 TQCString m_lastExportFormat;
181 int m_lastExportSpecialOutputFlag;
182
183 TDESharedPtr<KoSpeaker> m_koSpeaker;
184};
185
186KoMainWindow::KoMainWindow( TDEInstance *instance, const char* name )
187 : KParts::MainWindow( 0, 0L, name )
188{
189 setStandardToolBarMenuEnabled(true); // should there be a check for >= 3.1 ?
190 Q_ASSERT(instance);
191 d = new KoMainWindowPrivate;
192
193 d->m_manager = new KoPartManager( this );
194
195 connect( d->m_manager, TQ_SIGNAL( activePartChanged( KParts::Part * ) ),
196 this, TQ_SLOT( slotActivePartChanged( KParts::Part * ) ) );
197
198 if ( instance )
199 setInstance( instance, false ); // don't load plugins! we don't want
200 // the part's plugins with this shell, even though we are using the
201 // part's instance! (Simon)
202
203 TQString doc;
204 TQStringList allFiles = TDEGlobal::dirs()->findAllResources( "data", "koffice/koffice_shell.rc" );
205 setXMLFile( findMostRecentXMLFile( allFiles, doc ) );
206 setLocalXMLFile( locateLocal( "data", "koffice/koffice_shell.rc" ) );
207
208 KStdAction::openNew( this, TQ_SLOT( slotFileNew() ), actionCollection(), "file_new" );
209 KStdAction::open( this, TQ_SLOT( slotFileOpen() ), actionCollection(), "file_open" );
210 m_recent = KStdAction::openRecent( this, TQ_SLOT(slotFileOpenRecent(const KURL&)), actionCollection() );
211 d->m_paSave = KStdAction::save( this, TQ_SLOT( slotFileSave() ), actionCollection(), "file_save" );
212 d->m_paSaveAs = KStdAction::saveAs( this, TQ_SLOT( slotFileSaveAs() ), actionCollection(), "file_save_as" );
213 d->m_paPrint = KStdAction::print( this, TQ_SLOT( slotFilePrint() ), actionCollection(), "file_print" );
214 d->m_paPrintPreview = KStdAction::printPreview( this, TQ_SLOT( slotFilePrintPreview() ), actionCollection(), "file_print_preview" );
215 d->m_sendfile = KStdAction::mail( this, TQ_SLOT( slotEmailFile() ), actionCollection(), "file_send_file");
216
217 d->m_paCloseFile = KStdAction::close( this, TQ_SLOT( slotFileClose() ), actionCollection(), "file_close" );
218 KStdAction::quit( this, TQ_SLOT( slotFileQuit() ), actionCollection(), "file_quit" );
219
220 d->m_reloadfile = new TDEAction( i18n( "Reload"), 0,
221 this, TQ_SLOT( slotReloadFile() ),
222 actionCollection(), "file_reload_file");
223
224 d->m_versionsfile = new TDEAction( i18n( "Versions..."), 0,
225 this, TQ_SLOT( slotVersionsFile() ),
226 actionCollection(), "file_versions_file");
227
228 d->m_importFile = new TDEAction( i18n( "I&mport..." ), 0, // clashing accel key :(
229 this, TQ_SLOT( slotImportFile() ),
230 actionCollection(), "file_import_file");
231 d->m_exportFile = new TDEAction( i18n( "E&xport..." ), 0,
232 this, TQ_SLOT( slotExportFile() ),
233 actionCollection(), "file_export_file");
234
235 /* The following entry opens the document information dialog. Since the action is named so it
236 intends to show data this entry should not have a trailing ellipses (...). */
237 d->m_paDocInfo = new TDEAction( i18n( "&Document Information" ), "documentinfo", 0,
238 this, TQ_SLOT( slotDocumentInfo() ),
239 actionCollection(), "file_documentinfo" );
240
243
244 d->m_paDocInfo->setEnabled( false );
245 d->m_paSaveAs->setEnabled( false );
246 d->m_reloadfile->setEnabled( false );
247 d->m_versionsfile->setEnabled( false );
248 d->m_importFile->setEnabled( true ); // always enabled like File --> Open
249 d->m_exportFile->setEnabled( false );
250 d->m_paSave->setEnabled( false );
251 d->m_paPrint->setEnabled( false );
252 d->m_paPrintPreview->setEnabled( false );
253 d->m_sendfile->setEnabled( false);
254 d->m_paCloseFile->setEnabled( false);
255
256 d->m_splitter=new TQSplitter(TQt::Vertical, this, "mw-splitter");
257 setCentralWidget( d->m_splitter );
258 // Keyboard accessibility enhancements.
259 new KKbdAccessExtensions(this, "mw-panelSizer");
260 // set up the action "list" for "Close all Views" (hacky :) (Werner)
261 d->m_veryHackyActionList.append(
262 new TDEAction(i18n("&Close All Views"), "window-close",
263 "ctrl+shift+w", this, TQ_SLOT(slotCloseAllViews()),
264 actionCollection(), "view_closeallviews") );
265
266 // set up the action list for the splitter stuff
267 d->m_splitViewActionList.append(new TDEAction(i18n("&Split View"), "view_split", 0,
268 this, TQ_SLOT(slotSplitView()),
269 actionCollection(), "view_split"));
270 d->m_removeView=new TDEAction(i18n("&Remove View"), "view_remove", 0,
271 this, TQ_SLOT(slotRemoveView()),
272 actionCollection(), "view_rm_splitter");
273 d->m_splitViewActionList.append(d->m_removeView);
274 d->m_removeView->setEnabled(false);
275 d->m_orientation=new TDESelectAction(i18n("Splitter &Orientation"), "view_orientation", 0,
276 this, TQ_SLOT(slotSetOrientation()),
277 actionCollection(), "view_splitter_orientation");
278 TQStringList items;
279 items << i18n("&Vertical")
280 << i18n("&Horizontal");
281 d->m_orientation->setItems(items);
282 d->m_orientation->setCurrentItem(static_cast<int>(d->m_splitter->orientation()));
283 d->m_splitViewActionList.append(d->m_orientation);
284 d->m_splitViewActionList.append(new TDEActionSeparator(this));
285
286 // Load list of recent files
287 TDEConfig * config = instance ? instance->config() : TDEGlobal::config();
288 m_recent->loadEntries( config );
289
290 createShellGUI();
291 d->bMainWindowGUIBuilt = true;
292
293 if ( !initialGeometrySet() )
294 {
295 // Default size
296 const int deskWidth = TDEGlobalSettings::desktopGeometry(this).width();
297 if (deskWidth > 1100) // very big desktop ?
298 resize( 1000, 800 );
299 if (deskWidth > 850) // big desktop ?
300 resize( 800, 600 );
301 else // small (800x600, 640x480) desktop
302 resize( 600, 400 );
303 }
304
305 // Saved size
306 config->setGroup( "MainWindow" );
307 //kdDebug(30003) << "KoMainWindow::restoreWindowSize" << endl;
308 restoreWindowSize( config );
309}
310
312{
313 if (!d) {
314 return;
315 }
316
317 // The doc and view might still exist (this is the case when closing the window)
318 if (d->m_rootDoc) {
319 d->m_rootDoc->removeShell(this);
320 }
321
322 if (d->m_docToOpen) {
323 d->m_docToOpen->removeShell(this);
324 delete d->m_docToOpen;
325 d->m_docToOpen=0L;
326 }
327
328 // safety first ;)
329 d->m_manager->setActivePart(0);
330
331 if(d->m_rootViews.findRef(d->m_activeView)==-1) {
332 delete d->m_activeView;
333 d->m_activeView=0L;
334 }
335 d->m_rootViews.setAutoDelete( true );
336 d->m_rootViews.clear();
337
338 // We have to check if this was a root document.
339 // -> We aren't allowed to delete the (embedded) document!
340 // This has to be checked from queryClose, too :)
341 if ( d->m_rootDoc && d->m_rootDoc->viewCount() == 0 &&
342 !d->m_rootDoc->isEmbedded())
343 {
344 //kdDebug(30003) << "Destructor. No more views, deleting old doc " << d->m_rootDoc << endl;
345 delete d->m_rootDoc;
346 d->m_rootDoc=0L;
347 }
348
349 delete d->m_manager;
350 d->m_manager=0L;
351 delete d;
352 d=0L;
353}
354
356{
357 if ( d->m_rootDoc == doc )
358 return;
359
360 if (d->m_docToOpen && d->m_docToOpen != doc) {
361 d->m_docToOpen->removeShell(this);
362 delete d->m_docToOpen;
363 d->m_docToOpen = 0;
364 } else {
365 d->m_docToOpen = 0;
366 }
367
368 //kdDebug(30003) << "KoMainWindow::setRootDocument this = " << this << " doc = " << doc << endl;
369 TQPtrList<KoView> oldRootViews = d->m_rootViews;
370 d->m_rootViews.clear();
371 KoDocument *oldRootDoc = d->m_rootDoc;
372
373 if ( oldRootDoc )
374 oldRootDoc->removeShell( this );
375
376 d->m_rootDoc = doc;
377
378 if ( doc )
379 {
380 doc->setSelectable( false );
381 //d->m_manager->addPart( doc, false ); // done by KoView::setPartManager
382 d->m_rootViews.append( doc->createView( d->m_splitter, "view" /*not unique, but better than unnamed*/ ) );
383 d->m_rootViews.current()->setPartManager( d->m_manager );
384
385 d->m_rootViews.current()->show();
386 // The addShell has been done already if using openURL
387 if ( !d->m_rootDoc->shells().contains( this ) )
388 d->m_rootDoc->addShell( this );
389 d->m_removeView->setEnabled(false);
390 d->m_orientation->setEnabled(false);
391 }
392
393 bool enable = d->m_rootDoc != 0 ? true : false;
394 d->m_paDocInfo->setEnabled( enable );
395 d->m_paSave->setEnabled( enable );
396 d->m_paSaveAs->setEnabled( enable );
397 d->m_importFile->setEnabled( enable );
398 d->m_exportFile->setEnabled( enable );
399 d->m_paPrint->setEnabled( enable );
400 d->m_paPrintPreview->setEnabled( enable );
401 d->m_sendfile->setEnabled( enable);
402 d->m_paCloseFile->setEnabled( enable);
404
405 d->m_manager->setActivePart( d->m_rootDoc, d->m_rootViews.current() );
406
407 oldRootViews.setAutoDelete( true );
408 oldRootViews.clear();
409
410 if ( oldRootDoc && oldRootDoc->viewCount() == 0 )
411 {
412 //kdDebug(30003) << "No more views, deleting old doc " << oldRootDoc << endl;
413 delete oldRootDoc;
414 }
415}
416
417void KoMainWindow::updateReloadFileAction(KoDocument *doc)
418{
419 d->m_reloadfile->setEnabled( doc && !doc->url().isEmpty() );
420}
421
422void KoMainWindow::updateVersionsFileAction(KoDocument *doc)
423{
424 //TODO activate it just when we save it in oasis file format
425 d->m_versionsfile->setEnabled( doc && !doc->url().isEmpty()&&doc->isModified());
426}
427
428
429void KoMainWindow::setRootDocumentDirect( KoDocument *doc, const TQPtrList<KoView> & views )
430{
431 d->m_rootDoc = doc;
432 d->m_rootViews = views;
433 bool enable = d->m_rootDoc != 0 ? true : false;
434 d->m_paDocInfo->setEnabled( enable );
435 d->m_paSave->setEnabled( enable );
436 d->m_paSaveAs->setEnabled( enable );
437 d->m_exportFile->setEnabled( enable );
438 d->m_paPrint->setEnabled( enable );
439 d->m_paPrintPreview->setEnabled( enable );
440 d->m_sendfile->setEnabled( enable);
441 d->m_paCloseFile->setEnabled( enable );
442}
443
444void KoMainWindow::addRecentURL( const KURL& url )
445{
446 kdDebug(30003) << "KoMainWindow::addRecentURL url=" << url.prettyURL() << endl;
447 // Add entry to recent documents list
448 // (call coming from KoDocument because it must work with cmd line, template dlg, file/open, etc.)
449 if ( !url.isEmpty() )
450 {
451 bool ok = true;
452 if ( url.isLocalFile() )
453 {
454 TQString path = url.path( -1 );
455 TQStringList tmpDirs = TDEGlobal::dirs()->resourceDirs( "tmp" );
456 for ( TQStringList::Iterator it = tmpDirs.begin() ; ok && it != tmpDirs.end() ; ++it )
457 if ( path.contains( *it ) )
458 ok = false; // it's in the tmp resource
459 if ( ok )
460 TDERecentDocument::add(path);
461 }
462 else
463 TDERecentDocument::add(url.url(-1), true);
464
465 if ( ok )
466 m_recent->addURL( url );
468 }
469}
470
472{
473 // Save list of recent files
474 TDEConfig * config = instance() ? instance()->config() : TDEGlobal::config();
475 kdDebug(30003) << this << " Saving recent files list into config. instance()=" << instance() << endl;
476 m_recent->saveEntries( config );
477 config->sync();
479 {
480 // Tell all windows to reload their list, after saving
481 // Doesn't work multi-process, but it's a start
482 TDEMainWindow *window = TDEMainWindow::memberList->first();
483 for (; window; window = TDEMainWindow::memberList->next())
484 static_cast<KoMainWindow *>(window)->reloadRecentFileList();
485 }
486}
487
489{
490 TDEConfig * config = instance() ? instance()->config() : TDEGlobal::config();
491 m_recent->loadEntries( config );
492}
493
499
501{
502 //kdDebug(30003) << "KoMainWindow::updateCaption()" << endl;
503 if ( !d->m_rootDoc )
504 setCaption(TQString());
505 else if ( rootDocument()->isCurrent() )
506 {
507 TQString caption;
508 // Get caption from document info (title(), in about page)
509 if ( rootDocument()->documentInfo() )
510 {
511 KoDocumentInfoPage * page = rootDocument()->documentInfo()->page( TQString::fromLatin1("about") );
512 if (page)
513 caption = static_cast<KoDocumentInfoAbout *>(page)->title();
514 }
515 const TQString url = rootDocument()->url().prettyURL( 0, KURL::StripFileProtocol );
516 if ( !caption.isEmpty() && !url.isEmpty() )
517 caption = TQString( "%1 - %2" ).arg( caption ).arg( url );
518 else if ( caption.isEmpty() )
519 caption = url;
520
521 setCaption( caption, rootDocument()->isModified() );
522 if ( !rootDocument()->url().fileName(false).isEmpty() )
523 d->m_paSave->setToolTip( i18n("Save as %1").arg(rootDocument()->url().fileName(false)) );
524 else
525 d->m_paSave->setToolTip( i18n("Save") );
526 }
527}
528
529void KoMainWindow::updateCaption( TQString caption, bool mod )
530{
531 //kdDebug(30003)<<"KoMainWindow::updateCaption("<<caption<<","<<mod<<")"<<endl;
532 setCaption( caption, mod );
533}
534
536{
537 return d->m_rootDoc;
538}
539
540KoView *KoMainWindow::rootView() const
541{
542 if(d->m_rootViews.find(d->m_activeView)!=-1)
543 return d->m_activeView;
544 return d->m_rootViews.first();
545}
546
547KParts::PartManager *KoMainWindow::partManager()
548{
549 return d->m_manager;
550}
551
552bool KoMainWindow::openDocument( const KURL & url )
553{
554 if ( !TDEIO::NetAccess::exists(url,true,0) )
555 {
556 KMessageBox::error(0L, i18n("The file %1 does not exist.").arg(url.url()) );
557 m_recent->removeURL(url); //remove the file from the recent-opened-file-list
559 return false;
560 }
561 return openDocumentInternal( url );
562}
563
564// (not virtual)
565bool KoMainWindow::openDocument( KoDocument *newdoc, const KURL & url )
566{
567 if (!TDEIO::NetAccess::exists(url,true,0) )
568 {
569 if (!newdoc->checkAutoSaveFile())
570 {
571 newdoc->initEmpty(); //create an emtpy document
572 }
573
574 setRootDocument( newdoc );
575 newdoc->setURL(url);
576 TQString mime = KMimeType::findByURL(url)->name();
577 if ( mime.isEmpty() || mime == KMimeType::defaultMimeType() )
578 mime = newdoc->nativeFormatMimeType();
579 if ( url.isLocalFile() ) // workaround for kde<=3.3 tdeparts bug, fixed for 3.4
580 newdoc->setFile(url.path());
581 newdoc->setMimeTypeAfterLoading( mime );
583 return true;
584 }
585 return openDocumentInternal( url, newdoc );
586}
587
588// ## If you modify anything here, please check KoShellWindow::openDocumentInternal
589bool KoMainWindow::openDocumentInternal( const KURL & url, KoDocument *newdoc )
590{
591 //kdDebug(30003) << "KoMainWindow::openDocument " << url.url() << endl;
592
593 if ( !newdoc )
594 newdoc = createDoc();
595 if ( !newdoc )
596 return false;
597
598 d->m_firstTime=true;
599 connect(newdoc, TQ_SIGNAL(sigProgress(int)), this, TQ_SLOT(slotProgress(int)));
600 connect(newdoc, TQ_SIGNAL(completed()), this, TQ_SLOT(slotLoadCompleted()));
601 connect(newdoc, TQ_SIGNAL(canceled( const TQString & )), this, TQ_SLOT(slotLoadCanceled( const TQString & )));
602 newdoc->addShell( this ); // used by openURL
603 bool openRet = (!isImporting ()) ? newdoc->openURL(url) : newdoc->import(url);
604 if(!openRet)
605 {
606 newdoc->removeShell(this);
607 delete newdoc;
608 return false;
609 }
610 updateReloadFileAction(newdoc);
611 updateVersionsFileAction( newdoc );
612 return true;
613}
614
615// Separate from openDocument to handle async loading (remote URLs)
616void KoMainWindow::slotLoadCompleted()
617{
618 kdDebug(30003) << "KoMainWindow::slotLoadCompleted" << endl;
619 KoDocument* doc = rootDocument();
620 KoDocument* newdoc = (KoDocument *)(sender());
621
622 if ( doc && doc->isEmpty() && !doc->isEmbedded() )
623 {
624 // Replace current empty document
625 setRootDocument( newdoc );
626 }
627 else if ( doc && !doc->isEmpty() )
628 {
629 // Open in a new shell
630 // (Note : could create the shell first and the doc next for this
631 // particular case, that would give a better user feedback...)
632 KoMainWindow *s = new KoMainWindow( newdoc->instance() );
633 s->show();
634 newdoc->removeShell( this );
635 s->setRootDocument( newdoc );
636 }
637 else
638 {
639 // We had no document, set the new one
640 setRootDocument( newdoc );
641 }
642 disconnect(newdoc, TQ_SIGNAL(sigProgress(int)), this, TQ_SLOT(slotProgress(int)));
643 disconnect(newdoc, TQ_SIGNAL(completed()), this, TQ_SLOT(slotLoadCompleted()));
644 disconnect(newdoc, TQ_SIGNAL(canceled( const TQString & )), this, TQ_SLOT(slotLoadCanceled( const TQString & )));
645}
646
647void KoMainWindow::slotLoadCanceled( const TQString & errMsg )
648{
649 kdDebug(30003) << "KoMainWindow::slotLoadCanceled" << endl;
650 if ( !errMsg.isEmpty() ) // empty when canceled by user
651 KMessageBox::error( this, errMsg );
652 // ... can't delete the document, it's the one who emitted the signal...
653
654 KoDocument* newdoc = (KoDocument *)(sender());
655 disconnect(newdoc, TQ_SIGNAL(sigProgress(int)), this, TQ_SLOT(slotProgress(int)));
656 disconnect(newdoc, TQ_SIGNAL(completed()), this, TQ_SLOT(slotLoadCompleted()));
657 disconnect(newdoc, TQ_SIGNAL(canceled( const TQString & )), this, TQ_SLOT(slotLoadCanceled( const TQString & )));
658
659 newdoc->removeShell(this);
660 delete newdoc;
661}
662
663void KoMainWindow::slotSaveCanceled( const TQString &errMsg )
664{
665 kdDebug(30003) << "KoMainWindow::slotSaveCanceled" << endl;
666 if ( !errMsg.isEmpty() ) // empty when canceled by user
667 KMessageBox::error( this, errMsg );
668 slotSaveCompleted();
669}
670
671void KoMainWindow::slotSaveCompleted()
672{
673 kdDebug(30003) << "KoMainWindow::slotSaveCompleted" << endl;
674 KoDocument* pDoc = (KoDocument *)(sender());
675 disconnect(pDoc, TQ_SIGNAL(sigProgress(int)), this, TQ_SLOT(slotProgress(int)));
676 disconnect(pDoc, TQ_SIGNAL(completed()), this, TQ_SLOT(slotSaveCompleted()));
677 disconnect(pDoc, TQ_SIGNAL(canceled( const TQString & )),
678 this, TQ_SLOT(slotSaveCanceled( const TQString & )));
679}
680
681// returns true if we should save, false otherwise.
682bool KoMainWindow::exportConfirmation( const TQCString &outputFormat )
683{
684 if (!rootDocument()->wantExportConfirmation()) return true;
685 KMimeType::Ptr mime = KMimeType::mimeType( outputFormat );
686
687 const bool neverHeardOfIt = ( mime->name() == KMimeType::defaultMimeType() );
688 TQString comment = neverHeardOfIt ?
689 i18n( "%1 (unknown file type)" ).arg( outputFormat.data() )
690 : mime->comment();
691
692 // Warn the user
693 int ret;
694 if (!isExporting ()) // File --> Save
695 {
697 (
698 this,
699 i18n( "<qt>Saving as a %1 may result in some loss of formatting."
700 "<p>Do you still want to save in this format?</qt>" )
701 .arg( TQString( "<b>%1</b>" ).arg( comment ) ), // in case we want to remove the bold later
702 i18n( "Confirm Save" ),
703 KStdGuiItem::save (),
704 "NonNativeSaveConfirmation",
705 true
706 );
707 }
708 else // File --> Export
709 {
711 (
712 this,
713 i18n( "<qt>Exporting as a %1 may result in some loss of formatting."
714 "<p>Do you still want to export to this format?</qt>" )
715 .arg( TQString( "<b>%1</b>" ).arg( comment ) ), // in case we want to remove the bold later
716 i18n( "Confirm Export" ),
717 i18n ("Export"),
718 "NonNativeExportConfirmation", // different to the one used for Save (above)
719 true
720 );
721 }
722
723 return (ret == KMessageBox::Continue);
724}
725
726bool KoMainWindow::saveDocument( bool saveas, bool silent )
727{
728 KoDocument* pDoc = rootDocument();
729 if(!pDoc)
730 return true;
731
732 bool reset_url;
733 if ( pDoc->url().isEmpty() )
734 {
735 emit saveDialogShown();
736 reset_url = true;
737 saveas = true;
738 }
739 else
740 reset_url = false;
741
742 connect(pDoc, TQ_SIGNAL(sigProgress(int)), this, TQ_SLOT(slotProgress(int)));
743 connect(pDoc, TQ_SIGNAL(completed()), this, TQ_SLOT(slotSaveCompleted()));
744 connect(pDoc, TQ_SIGNAL(canceled( const TQString & )),
745 this, TQ_SLOT(slotSaveCanceled( const TQString & )));
746
747 KURL oldURL = pDoc->url();
748 TQString oldFile = pDoc->file();
749 TQCString _native_format = pDoc->nativeFormatMimeType();
750 TQCString oldOutputFormat = pDoc->outputMimeType();
751 int oldSpecialOutputFlag = pDoc->specialOutputFlag();
752 KURL suggestedURL = pDoc->url();
753
754 TQStringList mimeFilter = KoFilterManager::mimeFilter( _native_format, KoFilterManager::Export, pDoc->extraNativeMimeTypes() );
755 if (mimeFilter.findIndex (oldOutputFormat) < 0 && !isExporting())
756 {
757 kdDebug(30003) << "KoMainWindow::saveDocument no export filter for '" << oldOutputFormat << "'" << endl;
758
759 // --- don't setOutputMimeType in case the user cancels the Save As
760 // dialog and then tries to just plain Save ---
761
762 // suggest a different filename extension (yes, we fortunately don't all live in a world of magic :))
763 TQString suggestedFilename = suggestedURL.fileName ();
764 if ( !suggestedFilename.isEmpty () ) // ".kwd" looks strange for a name
765 {
766 int c = suggestedFilename.findRev ('.');
767
768 KMimeType::Ptr mime = KMimeType::mimeType( _native_format );
769 TQString ext = mime->property( "X-TDE-NativeExtension" ).toString();
770 if (!ext.isEmpty ())
771 {
772 if (c < 0)
773 suggestedFilename += ext;
774 else
775 suggestedFilename = suggestedFilename.left (c) + ext;
776 }
777 else // current filename extension wrong anyway
778 {
779 if (c > 0)
780 {
781 // this assumes that a . signifies an extension, not just a .
782 suggestedFilename = suggestedFilename.left (c);
783 }
784 }
785
786 suggestedURL.setFileName (suggestedFilename);
787 }
788
789 // force the user to choose outputMimeType
790 saveas = true;
791 }
792
793 bool ret = false;
794
795 if ( pDoc->url().isEmpty() || saveas )
796 {
797 // if you're just File/Save As'ing to change filter options you
798 // don't want to be reminded about overwriting files etc.
799 bool justChangingFilterOptions = false;
800
801 KoFileDialog *dialog = new KoFileDialog( (isExporting() && !d->m_lastExportURL.isEmpty() )? d->m_lastExportURL.url () : suggestedURL.url (),
802 TQString(), this, "file dialog", true);
803
804 if (!isExporting())
805 dialog->setCaption( i18n("Save Document As") );
806 else
807 dialog->setCaption( i18n("Export Document As") );
808
809 dialog->setOperationMode( KFileDialog::Saving );
810 dialog->setSpecialMimeFilter( mimeFilter,
811 isExporting() ? d->m_lastExportFormat : pDoc->mimeType(),
812 isExporting() ? d->m_lastExportSpecialOutputFlag : oldSpecialOutputFlag,
813 _native_format,
814 pDoc->supportedSpecialFormats() );
815
816 KURL newURL;
817 TQCString outputFormat = _native_format;
818 int specialOutputFlag = 0;
819 bool bOk;
820 do {
821 bOk=true;
822 if(dialog->exec()==TQDialog::Accepted) {
823 newURL=dialog->selectedURL();
824 outputFormat=dialog->currentMimeFilter().latin1();
825 specialOutputFlag = dialog->specialEntrySelected();
826 kdDebug(30003) << "KoMainWindow::saveDocument outputFormat = " << outputFormat << endl;
827
828 if (!isExporting())
829 justChangingFilterOptions = (newURL == pDoc->url()) &&
830 (outputFormat == pDoc->mimeType()) &&
831 (specialOutputFlag == oldSpecialOutputFlag);
832 else
833 justChangingFilterOptions = (newURL == d->m_lastExportURL) &&
834 (outputFormat == d->m_lastExportFormat) &&
835 (specialOutputFlag == d->m_lastExportSpecialOutputFlag);
836 }
837 else
838 {
839 bOk = false;
840 break;
841 }
842
843 if ( newURL.isEmpty() )
844 {
845 bOk = false;
846 break;
847 }
848
849 // adjust URL before doing checks on whether the file exists.
850 if ( specialOutputFlag == KoDocument::SaveAsDirectoryStore ) {
851 TQString fileName = newURL.fileName();
852 if ( fileName != "content.xml" ) {
853 newURL.addPath( "content.xml" );
854 }
855 }
856
857 // this file exists and we are not just clicking "Save As" to change filter options
858 // => ask for confirmation
859 if ( TDEIO::NetAccess::exists( newURL, false /*will write*/, this ) && !justChangingFilterOptions )
860 {
861 bOk = KMessageBox::questionYesNo( this,
862 i18n("A document with this name already exists.\n"\
863 "Do you want to overwrite it?"),
864 i18n("Warning") ) == KMessageBox::Yes;
865 }
866 } while ( !bOk );
867
868 delete dialog;
869
870 if (bOk)
871 {
872 bool wantToSave = true;
873
874 // don't change this line unless you know what you're doing :)
875 if (!justChangingFilterOptions || pDoc->confirmNonNativeSave (isExporting ())) {
876 if ( !pDoc->isNativeFormat( outputFormat ) )
877 wantToSave = exportConfirmation( outputFormat );
878 }
879
880 if (wantToSave)
881 {
882 //
883 // Note:
884 // If the user is stupid enough to Export to the current URL,
885 // we do _not_ change this operation into a Save As. Reasons
886 // follow:
887 //
888 // 1. A check like "isExporting() && oldURL == newURL"
889 // doesn't _always_ work on case-insensitive filesystems
890 // and inconsistent behaviour is bad.
891 // 2. It is probably not a good idea to change pDoc->mimeType
892 // and friends because the next time the user File/Save's,
893 // (not Save As) they won't be expecting that they are
894 // using their File/Export settings
895 //
896 // As a bad side-effect of this, the modified flag will not
897 // be updated and it is possible that what is currently on
898 // their screen is not what is stored on disk (through loss
899 // of formatting). But if you are dumb enough to change
900 // mimetype but not the filename, then arguably, _you_ are
901 // the "bug" :)
902 //
903 // - Clarence
904 //
905
906
907 pDoc->setOutputMimeType( outputFormat, specialOutputFlag );
908 if (!isExporting ()) // Save As
909 {
910 ret = pDoc->saveAs( newURL );
911
912 if (ret)
913 {
914 kdDebug(30003) << "Successful Save As!" << endl;
915 addRecentURL( newURL );
916 }
917 else
918 {
919 kdDebug(30003) << "Failed Save As!" << endl;
920 pDoc->setURL( oldURL ), pDoc->setFile( oldFile );
921 pDoc->setOutputMimeType( oldOutputFormat, oldSpecialOutputFlag );
922 }
923 }
924 else // Export
925 {
926 ret = pDoc->exp0rt( newURL );
927
928 if (ret)
929 {
930 // a few file dialog convenience things
931 d->m_lastExportURL = newURL;
932 d->m_lastExportFormat = outputFormat;
933 d->m_lastExportSpecialOutputFlag = specialOutputFlag;
934 }
935
936 // always restore output format
937 pDoc->setOutputMimeType( oldOutputFormat, oldSpecialOutputFlag );
938 }
939 } // if (wantToSave)
940 else
941 ret = false;
942 } // if (bOk)
943 else
944 ret = false;
945 }
946 else { // saving
947 bool needConfirm = pDoc->confirmNonNativeSave( false ) &&
948 !pDoc->isNativeFormat( oldOutputFormat );
949 if (!needConfirm ||
950 (needConfirm && exportConfirmation( oldOutputFormat /* not so old :) */ ))
951 )
952 {
953 // be sure pDoc has the correct outputMimeType!
954 ret = pDoc->save();
955
956 if (!ret)
957 {
958 kdDebug(30003) << "Failed Save!" << endl;
959 pDoc->setURL( oldURL ), pDoc->setFile( oldFile );
960 }
961 }
962 else
963 ret = false;
964 }
965
966// Now that there's a File/Export option, this is no longer necessary.
967// If you continue to use File/Save to export to a foreign format,
968// this signals your intention to continue working in a foreign format.
969// You have already been warned by the DoNotAskAgain exportConfirmation
970// about losing formatting when you first saved so don't set modified
971// here or else it will be reported as a bug by some MSOffice user.
972// You have been warned! Do not click DoNotAskAgain!!!
973#if 0
974 if (ret && !isExporting())
975 {
976 // When exporting to a non-native format, we don't reset modified.
977 // This way the user will be reminded to save it again in the native format,
978 // if he/she doesn't want to lose formatting.
979 if ( wasModified && pDoc->outputMimeType() != _native_format )
980 pDoc->setModified( true );
981 }
982#endif
983
984 if (!ret && reset_url)
985 pDoc->resetURL(); //clean the suggested filename as the save dialog was rejected
986 else if (! silent) // don't let the document change the window caption
987 pDoc->setTitleModified();
988 return ret;
989}
990
991void KoMainWindow::closeEvent(TQCloseEvent *e) {
992 if(queryClose()) {
993 saveWindowSettings();
994 setRootDocument(0L);
996 }
997}
998
999void KoMainWindow::saveWindowSettings()
1000{
1001 if (d->m_windowSizeDirty && rootDocument())
1002 {
1003 // Save window size into the config file of our instance
1004 instance()->config()->setGroup( "MainWindow" );
1005 //kdDebug(30003) << "KoMainWindow::saveWindowSettings" << endl;
1006 saveWindowSize( instance()->config() );
1007 d->m_windowSizeDirty = false;
1008 // Save toolbar position into the config file of the app, under the doc's instance name
1009 //kdDebug(30003) << "KoMainWindow::closeEvent -> saveMainWindowSettings rootdoc's instance=" << rootDocument()->instance()->instanceName() << endl;
1010 saveMainWindowSettings( TDEGlobal::config(), rootDocument()->instance()->instanceName() );
1011 TDEGlobal::config()->sync();
1012 resetAutoSaveSettings(); // Don't let TDEMainWindow override the good stuff we wrote down
1013 }
1014}
1015
1016void KoMainWindow::resizeEvent( TQResizeEvent * e )
1017{
1018 d->m_windowSizeDirty = true;
1019 KParts::MainWindow::resizeEvent( e );
1020}
1021
1023{
1024 if ( rootDocument() == 0 )
1025 return true;
1026 //kdDebug(30003) << "KoMainWindow::queryClose() viewcount=" << rootDocument()->viewCount()
1027 // << " shellcount=" << rootDocument()->shellCount() << endl;
1028 if ( !d->m_forQuit && rootDocument()->shellCount() > 1 )
1029 // there are more open, and we are closing just one, so no problem for closing
1030 return true;
1031
1032 // see DTOR for a descr. of the test
1033 if ( d->m_rootDoc->isEmbedded() )
1034 return true;
1035
1036 // main doc + internally stored child documents
1037 if ( d->m_rootDoc->isModified() )
1038 {
1039 TQString name;
1040 if ( rootDocument()->documentInfo() )
1041 {
1042 name = rootDocument()->documentInfo()->title();
1043 }
1044 if ( name.isEmpty() )
1045 name = rootDocument()->url().fileName();
1046
1047 if ( name.isEmpty() )
1048 name = i18n( "Untitled" );
1049
1050 int res = KMessageBox::warningYesNoCancel( this,
1051 i18n( "<p>The document <b>'%1'</b> has been modified.</p><p>Do you want to save it?</p>" ).arg(name),
1052 TQString(),
1053 KStdGuiItem::save(),
1054 KStdGuiItem::discard());
1055
1056 switch(res) {
1057 case KMessageBox::Yes : {
1058 d->m_rootDoc->setDoNotSaveExtDoc(); // external docs are saved later
1059 bool isNative = ( d->m_rootDoc->outputMimeType() == d->m_rootDoc->nativeFormatMimeType() );
1060 if (! saveDocument( !isNative ) )
1061 return false;
1062 break;
1063 }
1064 case KMessageBox::No :
1066 rootDocument()->setModified( false ); // Now when queryClose() is called by closeEvent it won't do anything.
1067 break;
1068 default : // case KMessageBox::Cancel :
1069 return false;
1070 }
1071 }
1072
1073 if ( d->m_rootDoc->queryCloseExternalChildren() == KMessageBox::Cancel )
1074 {
1075 return false;
1076 }
1077
1078 return true;
1079}
1080
1081// Helper method for slotFileNew and slotFileClose
1082void KoMainWindow::chooseNewDocument( int /*KoDocument::InitDocFlags*/ initDocFlags )
1083{
1084 KoDocument* doc = rootDocument();
1085 KoDocument *newdoc = createDoc();
1086
1087 if ( !newdoc )
1088 return;
1089
1090 //FIXME: This needs to be handled differently
1091 connect(newdoc, TQ_SIGNAL(sigProgress(int)), this, TQ_SLOT(slotProgress(int)));
1092 disconnect(newdoc, TQ_SIGNAL(sigProgress(int)), this, TQ_SLOT(slotProgress(int)));
1093
1094 if ( ( !doc && ( initDocFlags == KoDocument::InitDocFileNew ) ) || ( doc && !doc->isEmpty() ) )
1095 {
1096 KoMainWindow *s = new KoMainWindow( newdoc->instance() );
1097 s->show();
1098 newdoc->addShell( s );
1099 newdoc->showStartUpWidget( s, true /*Always show widget*/ );
1100 return;
1101 }
1102
1103 if( doc ) {
1104 setRootDocument( 0 );
1105 delete d->m_rootDoc;
1106 d->m_rootDoc = 0;
1107 }
1108
1109 newdoc->addShell( this );
1110 newdoc->showStartUpWidget( this, true /*Always show widget*/ );
1111}
1112
1114{
1115 chooseNewDocument( KoDocument::InitDocFileNew );
1116}
1117
1119{
1120 KFileDialog *dialog = new KFileDialog(":OpenDialog", TQString(), this, "file dialog", true);
1121 if (!isImporting())
1122 dialog->setCaption( i18n("Open Document") );
1123 else
1124 dialog->setCaption( i18n("Import Document") );
1125
1126 // The few lines below need to be kept in sync with KoTemplateChooseDia::setupFileDialog
1127 const TQStringList mimeFilter = KoFilterManager::mimeFilter( KoDocument::readNativeFormatMimeType(),
1128 KoFilterManager::Import,
1130 dialog->setMimeFilter( mimeFilter );
1131 if(dialog->exec()!=TQDialog::Accepted) {
1132 delete dialog;
1133 return;
1134 }
1135 KURL url( dialog->selectedURL() );
1136 delete dialog;
1137
1138 if ( url.isEmpty() )
1139 return;
1140
1141 (void) openDocument( url );
1142}
1143
1144void KoMainWindow::slotFileOpenRecent( const KURL & url )
1145{
1146 (void) openDocument( url );
1147}
1148
1150{
1151 if ( saveDocument() )
1152 emit documentSaved();
1153}
1154
1156{
1157 if ( saveDocument( true ) )
1158 emit documentSaved();
1159}
1160
1162{
1163 if ( !rootDocument() )
1164 return;
1165
1166 KoDocumentInfo *docInfo = rootDocument()->documentInfo();
1167
1168 if ( !docInfo )
1169 return;
1170
1171 KoDocumentInfoDlg *dlg = new KoDocumentInfoDlg( docInfo, this, "documentInfoDlg" );
1172 if ( dlg->exec() )
1173 {
1174 dlg->save();
1175 rootDocument()->setModified( true );
1177 }
1178
1179 delete dlg;
1180}
1181
1183{
1184 if (queryClose())
1185 {
1186 saveWindowSettings();
1187 setRootDocument( 0 ); // don't delete this shell when deleting the document
1188 delete d->m_rootDoc;
1189 d->m_rootDoc = 0;
1190 chooseNewDocument( KoDocument::InitDocFileClose );
1191 }
1192}
1193
1195{
1196 close();
1197}
1198
1199void KoMainWindow::print(bool quick) {
1200 if ( !rootView() )
1201 {
1202 kdDebug(30003) << "KoMainWindow::slotFilePrint : No root view!" << endl;
1203 return;
1204 }
1205
1206 KPrinter printer( true /*, TQPrinter::HighResolution*/ );
1207 TQString title = rootView()->koDocument()->documentInfo()->title();
1208 TQString fileName = rootView()->koDocument()->url().fileName();
1209
1210 // strip off the native extension (I don't want foobar.kwd.ps when printing into a file)
1211 KMimeType::Ptr mime = KMimeType::mimeType( rootView()->koDocument()->outputMimeType() );
1212 if ( mime ) {
1213 TQString extension = mime->property( "X-TDE-NativeExtension" ).toString();
1214
1215 if ( fileName.endsWith( extension ) )
1216 fileName.truncate( fileName.length() - extension.length() );
1217 }
1218
1219 if ( title.isEmpty() )
1220 title = fileName;
1221 if ( title.isEmpty() ) {
1222 // #139905 - breaks message freeze though
1223 //const TQString programName = instance()->aboutData() ? instance()->aboutData()->programName() : instance()->instanceName();
1224 //title = i18n("%1 unsaved document (%2)").arg(programName).arg(TDEGlobal::locale()->formatDate(TQDate::currentDate(), true/*short*/));
1225 }
1226 printer.setDocName( title );
1227 printer.setDocFileName( fileName );
1228 printer.setDocDirectory( rootView()->koDocument()->url().directory() );
1229
1230 // ### TODO: apply global koffice settings here
1231
1232 rootView()->setupPrinter( printer );
1233
1234 if ( quick || printer.setup( this ) )
1235 rootView()->print( printer );
1236}
1237
1238
1240{
1241 print(false);
1242}
1243
1245{
1246 if ( !rootView() )
1247 {
1248 kdWarning() << "KoMainWindow::slotFilePrint : No root view!" << endl;
1249 return;
1250 }
1251 KPrinter printer( false );
1252 KTempFile tmpFile;
1253 // The temp file is deleted by KoPrintPreview
1254
1255 // This line has to be before setupPrinter to let the apps decide what to
1256 // print and what not (if they want to :)
1257 printer.setFromTo( printer.minPage(), printer.maxPage() );
1258 printer.setPreviewOnly( true );
1259 rootView()->setupPrinter( printer );
1260
1261 TQString oldFileName = printer.outputFileName();
1262 printer.setOutputFileName( tmpFile.name() );
1263 int oldNumCopies = printer.numCopies();
1264 printer.setNumCopies( 1 );
1265 // Disable tdeprint's own preview, we'd get two. This shows that KPrinter needs
1266 // a "don't use the previous settings" mode. The current way is really too much of a hack.
1267 TQString oldKDEPreview = printer.option( "kde-preview" );
1268 printer.setOption( "kde-preview", "0" );
1269
1270 rootView()->print(printer);
1271 //KoPrintPreview::preview(this, "KoPrintPreviewDialog", tmpFile.name());
1272
1273 // Restore previous values
1274 printer.setOutputFileName( oldFileName );
1275 printer.setNumCopies( oldNumCopies );
1276 printer.setOption( "kde-preview", oldKDEPreview );
1277}
1278
1280{
1281 guiFactory()->configureShortcuts();
1282}
1283
1285{
1286 if (rootDocument())
1287 saveMainWindowSettings( TDEGlobal::config(), rootDocument()->instance()->instanceName() );
1288 KEditToolbar edit(factory(), this);
1289 connect(&edit,TQ_SIGNAL(newToolbarConfig()),this,TQ_SLOT(slotNewToolbarConfig()));
1290 (void) edit.exec();
1291}
1292
1294{
1295 if (rootDocument())
1296 applyMainWindowSettings( TDEGlobal::config(), rootDocument()->instance()->instanceName() );
1297 KXMLGUIFactory *factory = guiFactory();
1298
1299 // Check if there's an active view
1300 if( !d->m_activeView )
1301 return;
1302
1303 // This gets plugged in even for embedded views
1304 factory->plugActionList(d->m_activeView, "view_closeallviews",
1305 d->m_veryHackyActionList);
1306
1307 // This one only for root views
1308 if(d->m_rootViews.findRef(d->m_activeView)!=-1)
1309 factory->plugActionList(d->m_activeView, "view_split",
1310 d->m_splitViewActionList );
1311 plugActionList( "toolbarlist", d->m_toolbarList );
1312}
1313
1315{
1316 //kdDebug(30003) << "KoMainWindow::slotToolbarToggled " << sender()->name() << " toggle=" << true << endl;
1317 // The action (sender) and the toolbar have the same name
1318 TDEToolBar * bar = toolBar( sender()->name() );
1319 if (bar)
1320 {
1321 if (toggle)
1322 bar->show();
1323 else
1324 bar->hide();
1325
1326 if (rootDocument())
1327 saveMainWindowSettings( TDEGlobal::config(), rootDocument()->instance()->instanceName() );
1328 }
1329 else
1330 kdWarning(30003) << "slotToolbarToggled : Toolbar " << sender()->name() << " not found!" << endl;
1331}
1332
1333bool KoMainWindow::toolbarIsVisible(const char *tbName)
1334{
1335 TQWidget *tb = toolBar( tbName);
1336 return !tb->isHidden();
1337}
1338
1339void KoMainWindow::showToolbar( const char * tbName, bool shown )
1340{
1341 TQWidget * tb = toolBar( tbName );
1342 if ( !tb )
1343 {
1344 kdWarning(30003) << "KoMainWindow: toolbar " << tbName << " not found." << endl;
1345 return;
1346 }
1347 if ( shown )
1348 tb->show();
1349 else
1350 tb->hide();
1351
1352 // Update the action appropriately
1353 TQPtrListIterator<TDEAction> it( d->m_toolbarList );
1354 for ( ; it.current() ; ++it )
1355 if ( !strcmp( it.current()->name(), tbName ) )
1356 {
1357 //kdDebug(30003) << "KoMainWindow::showToolbar setChecked " << shown << endl;
1358 static_cast<TDEToggleAction *>(it.current())->setChecked( shown );
1359 break;
1360 }
1361}
1362
1364 d->m_splitted=true;
1365 d->m_rootViews.append(d->m_rootDoc->createView(d->m_splitter, "splitted-view"));
1366 d->m_rootViews.current()->show();
1367 d->m_rootViews.current()->setPartManager( d->m_manager );
1368 d->m_manager->setActivePart( d->m_rootDoc, d->m_rootViews.current() );
1369 d->m_removeView->setEnabled(true);
1370 d->m_orientation->setEnabled(true);
1371}
1372
1374
1375 // Attention: Very touchy code... you know what you're doing? Goooood :)
1376 d->m_forQuit=true;
1377 if(queryClose()) {
1378 // In case the document is embedded we close all open "extra-shells"
1379 if(d->m_rootDoc && d->m_rootDoc->isEmbedded()) {
1380 hide();
1381 d->m_rootDoc->removeShell(this);
1382 TQPtrListIterator<KoMainWindow> it(d->m_rootDoc->shells());
1383 while (it.current()) {
1384 it.current()->hide();
1385 delete it.current(); // this updates the lists' current pointer and thus
1386 // the iterator (the shell dtor calls removeShell)
1387 d->m_rootDoc=0;
1388 }
1389 }
1390 // not embedded -> destroy the document and all shells/views ;)
1391 else
1392 setRootDocument( 0L );
1393 close(); // close this window (and quit the app if necessary)
1394 }
1395 d->m_forQuit=false;
1396}
1397
1398void KoMainWindow::slotRemoveView() {
1399 KoView *view;
1400 if(d->m_rootViews.findRef(d->m_activeView)!=-1)
1401 view=d->m_rootViews.current();
1402 else
1403 view=d->m_rootViews.first();
1404 view->hide();
1405 if ( !d->m_rootViews.removeRef(view) )
1406 kdWarning() << "view not found in d->m_rootViews!" << endl;
1407
1408 if(d->m_rootViews.count()==1)
1409 {
1410 d->m_removeView->setEnabled(false);
1411 d->m_orientation->setEnabled(false);
1412 }
1413 // Prevent the view's destroyed() signal from triggering GUI rebuilding (too early)
1414 d->m_manager->setActivePart( 0, 0 );
1415
1416 delete view;
1417 view=0L;
1418
1419 d->m_rootViews.first()->setPartManager( d->m_manager );
1420 d->m_manager->setActivePart( d->m_rootDoc, d->m_rootViews.first() );
1421
1422 if(d->m_rootViews.count()==1)
1423 d->m_splitted=false;
1424}
1425
1426void KoMainWindow::slotSetOrientation() {
1427 d->m_splitter->setOrientation(static_cast<TQt::Orientation>
1428 (d->m_orientation->currentItem()));
1429}
1430
1431void KoMainWindow::slotProgress(int value) {
1432 //kdDebug(30003) << "KoMainWindow::slotProgress " << value << endl;
1433 if(value==-1) {
1434 if ( d->m_progress )
1435 {
1436 statusBar()->removeWidget(d->m_progress);
1437 delete d->m_progress;
1438 d->m_progress=0L;
1439 }
1440 d->m_firstTime=true;
1441 return;
1442 }
1443 if(d->m_firstTime)
1444 {
1445 // The statusbar might not even be created yet.
1446 // So check for that first, and create it if necessary
1447 TQObjectList *l = queryList( "TQStatusBar" );
1448 if ( !l || !l->first() ) {
1449 statusBar()->show();
1450 TQApplication::sendPostedEvents( this, TQEvent::ChildInserted );
1451 setUpLayout();
1452 }
1453 delete l;
1454
1455 if ( d->m_progress )
1456 {
1457 statusBar()->removeWidget(d->m_progress);
1458 delete d->m_progress;
1459 d->m_progress=0L;
1460 }
1461 statusBar()->setMaximumHeight(statusBar()->height());
1462 d->m_progress=new KProgress(statusBar());
1463 //d->m_progress->setMaximumHeight(statusBar()->height());
1464 statusBar()->addWidget( d->m_progress, 0, true );
1465 d->m_progress->show();
1466 d->m_firstTime=false;
1467 }
1468 d->m_progress->setProgress(value);
1469 kapp->processEvents();
1470}
1471
1472
1473void KoMainWindow::slotActivePartChanged( KParts::Part *newPart )
1474{
1475
1476 // This looks very much like KParts::MainWindow::createGUI, but we have
1477 // to reimplement it because it works with an active part, whereas we work
1478 // with an active view _and_ an active part, depending for what.
1479 // Both are KXMLGUIClients, but e.g. the plugin query needs a TQObject.
1480 //kdDebug(30003) << "KoMainWindow::slotActivePartChanged( Part * newPart) newPart = " << newPart << endl;
1481 //kdDebug(30003) << "current active part is " << d->m_activePart << endl;
1482
1483 if ( d->m_activePart && d->m_activePart == newPart && !d->m_splitted )
1484 {
1485 //kdDebug(30003) << "no need to change the GUI" << endl;
1486 return;
1487 }
1488
1489 KXMLGUIFactory *factory = guiFactory();
1490
1491 setUpdatesEnabled( false );
1492
1493 if ( d->m_activeView )
1494 {
1495 KParts::GUIActivateEvent ev( false );
1496 TQApplication::sendEvent( d->m_activePart, &ev );
1497 TQApplication::sendEvent( d->m_activeView, &ev );
1498
1499
1500 factory->removeClient( d->m_activeView );
1501
1502 unplugActionList( "toolbarlist" );
1503 d->m_toolbarList.clear(); // deletes the actions
1504 }
1505
1506 if ( !d->bMainWindowGUIBuilt )
1507 {
1508 // Load mainwindow plugins
1509 KParts::Plugin::loadPlugins( this, this, instance(), true );
1510 createShellGUI();
1511 }
1512
1513 if ( newPart && d->m_manager->activeWidget() && d->m_manager->activeWidget()->inherits( "KoView" ) )
1514 {
1515 d->m_activeView = (KoView *)d->m_manager->activeWidget();
1516 d->m_activePart = newPart;
1517 //kdDebug(30003) << "new active part is " << d->m_activePart << endl;
1518
1519 factory->addClient( d->m_activeView );
1520
1521
1522 // This gets plugged in even for embedded views
1523 factory->plugActionList(d->m_activeView, "view_closeallviews",
1524 d->m_veryHackyActionList);
1525 // This one only for root views
1526 if(d->m_rootViews.findRef(d->m_activeView)!=-1)
1527 factory->plugActionList(d->m_activeView, "view_split", d->m_splitViewActionList );
1528
1529 // Position and show toolbars according to user's preference
1530 setAutoSaveSettings( newPart->instance()->instanceName(), false );
1531
1532 // Create and plug toolbar list for Settings menu
1533 //TQPtrListIterator<TDEToolBar> it = toolBarIterator();
1534 TQPtrList<TQWidget> toolBarList = factory->containers( "ToolBar" );
1535 TQPtrListIterator<TQWidget> it( toolBarList );
1536 for ( ; it.current() ; ++it )
1537 {
1538 if ( it.current()->inherits("TDEToolBar") )
1539 {
1540 TDEToolBar * tb = static_cast<TDEToolBar *>(it.current());
1541 TDEToggleAction * act = new TDEToggleAction( i18n("Show %1 Toolbar").arg( tb->text() ), 0,
1542 actionCollection(), tb->name() );
1543 act->setCheckedState(i18n("Hide %1 Toolbar").arg( tb->text() ));
1544 connect( act, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotToolbarToggled( bool ) ) );
1545 act->setChecked ( !tb->isHidden() );
1546 d->m_toolbarList.append( act );
1547 }
1548 else
1549 kdWarning(30003) << "Toolbar list contains a " << it.current()->className() << " which is not a toolbar!" << endl;
1550 }
1551 plugActionList( "toolbarlist", d->m_toolbarList );
1552
1553 // Send the GUIActivateEvent only now, since it might show/hide toolbars too
1554 // (and this has priority over applyMainWindowSettings)
1555 KParts::GUIActivateEvent ev( true );
1556 TQApplication::sendEvent( d->m_activePart, &ev );
1557 TQApplication::sendEvent( d->m_activeView, &ev );
1558 }
1559 else
1560 {
1561 d->m_activeView = 0L;
1562 d->m_activePart = 0L;
1563 }
1564 setUpdatesEnabled( true );
1565}
1566
1568{
1569 if ( !d->statusBarLabel )
1570 {
1571 d->statusBarLabel = new TQLabel( statusBar() );
1572 statusBar()->addWidget( d->statusBarLabel, 1, true );
1573 }
1574 return d->statusBarLabel;
1575}
1576
1578{
1579 m_recent->setMaxItems( _number );
1580}
1581
1582DCOPObject * KoMainWindow::dcopObject()
1583{
1584 if ( !d->m_dcopObject )
1585 {
1586 d->m_dcopObject = new KoMainWindowIface( this );
1587 }
1588
1589 return d->m_dcopObject;
1590}
1591
1593{
1594 if (!rootDocument())
1595 return;
1596
1597 // Subject = Document file name
1598 // Attachment = The current file
1599 // Message Body = The current document in HTML export? <-- This may be an option.
1600 TQString theSubject;
1601 TQStringList urls;
1602 TQString fileURL;
1603 if (rootDocument()->url ().isEmpty () ||
1604 rootDocument()->isModified())
1605 {
1606 //Save the file as a temporary file
1607 bool const tmp_modified = rootDocument()->isModified();
1608 KURL const tmp_url = rootDocument()->url();
1609 TQCString const tmp_mimetype = rootDocument()->outputMimeType();
1610 KTempFile tmpfile; //TODO: The temorary file should be deleted when the mail program is closed
1611 KURL u;
1612 u.setPath(tmpfile.name());
1613 rootDocument()->setURL(u);
1614 rootDocument()->setModified(true);
1615 rootDocument()->setOutputMimeType(rootDocument()->nativeFormatMimeType());
1616
1617 saveDocument(false, true);
1618
1619 fileURL = tmpfile.name();
1620 theSubject = i18n("Document");
1621 urls.append( fileURL );
1622
1623 rootDocument()->setURL(tmp_url);
1624 rootDocument()->setModified(tmp_modified);
1625 rootDocument()->setOutputMimeType(tmp_mimetype);
1626 }
1627 else
1628 {
1629 fileURL = rootDocument()->url().url();
1630 theSubject = i18n("Document - %1").arg(rootDocument()->url().fileName(false));
1631 urls.append( fileURL );
1632 }
1633
1634 kdDebug(30003) << "(" << fileURL <<")" << endl;
1635
1636 if (!fileURL.isEmpty())
1637 {
1638 kapp->invokeMailer(TQString(), TQString(), TQString(), theSubject,
1639 TQString(), //body
1640 TQString(),
1641 urls); // attachments
1642 }
1643}
1644
1646{
1647 KoVersionDialog *dlg = new KoVersionDialog( this );
1648 dlg->exec();
1649 delete dlg;
1650}
1651
1653{
1654 KoDocument* pDoc = rootDocument();
1655 if(!pDoc || pDoc->url().isEmpty() || !pDoc->isModified())
1656 return;
1657
1658 bool bOk = KMessageBox::questionYesNo( this,
1659 i18n("You will lose all your changes!\n"
1660 "Do you want to continue?"),
1661 i18n("Warning") ) == KMessageBox::Yes;
1662 if ( !bOk )
1663 return;
1664
1665 KURL url = pDoc->url();
1666 if ( pDoc && !pDoc->isEmpty() )
1667 {
1668 setRootDocument( 0L ); // don't delete this shell when deleting the document
1669 delete d->m_rootDoc;
1670 d->m_rootDoc = 0L;
1671 }
1672 openDocument( url );
1673 return;
1674
1675}
1676
1678{
1679 kdDebug(30003) << "slotImportFile()" << endl;
1680
1681 d->m_isImporting = true;
1682 slotFileOpen();
1683 d->m_isImporting = false;
1684}
1685
1687{
1688 kdDebug(30003) << "slotExportFile()" << endl;
1689
1690 d->m_isExporting = true;
1692 d->m_isExporting = false;
1693}
1694
1696{
1697 return d->m_isImporting;
1698}
1699
1701{
1702 return d->m_isExporting;
1703}
1704
1706{
1707 d->m_docToOpen = doc;
1708}
1709
1710#include <KoMainWindow.moc>
This file is part of the KDE/KOffice project.
KKbdAccessExtensions is an object that improves accessibility for motor impaired users who may not be...
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
static int questionYesNo(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
static int warningYesNoCancel(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
static int warningContinueCancel(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonContinue=KStdGuiItem::cont(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
virtual void setInstance(TDEInstance *instance)
void setIgnoreScrollBars(bool ignore)
PartManager(TQWidget *parent, const char *name=0L)
void setActivationButtonMask(short int buttonMask)
void setSelectionPolicy(SelectionPolicy policy)
void setAllowNestedParts(bool allow)
virtual void setSelectable(bool selectable)
static void loadPlugins(TQObject *parent, const TDEInstance *instance)
virtual bool saveAs(const KURL &url)
virtual bool save()
void plugActionList(const TQString &name, const TQPtrList< TDEAction > &actionList)
void unplugActionList(const TQString &name)
virtual TDEInstance * instance() const
virtual void setXMLFile(const TQString &file, bool merge=false, bool setXMLDoc=true)
KXMLGUIFactory * factory() const
virtual TDEActionCollection * actionCollection() const
void removeClient(KXMLGUIClient *client)
void addClient(KXMLGUIClient *client)
Represents an available KOffice component that supports the document interface.
KoDocument * createDoc(KoDocument *parent=0, const char *name=0) const
Uses the factory of the component to create a document.
The KOffice document class.
Definition KoDocument.h:61
void resetURL()
Sets the document URL to empty URL KParts doesn't allow this, but KOffice apps have e....
Definition KoDocument.h:818
void removeAutoSaveFiles()
Performs a cleanup of unneeded backup files.
virtual int supportedSpecialFormats() const
Return the set of SupportedSpecialFormats that the application wants to offer in the "Save" file dial...
bool checkAutoSaveFile()
Called by koApplication to check for an autosave file in $HOME.
KoView * createView(TQWidget *parent=0, const char *name=0)
Create a new view for the document.
static TQCString readNativeFormatMimeType(TDEInstance *instance=0)
Used by KoApplication, and by KoMainWindow, when no document exists yet.
virtual TQStringList extraNativeMimeTypes() const
Returns a list of the mimetypes considered "native", i.e.
bool isNativeFormat(const TQCString &mimetype) const
Checks whether a given mimetype can be handled natively.
TQString & file()
Only use these functions to restore m_file (in KoMainWindow) after a failed save (remember to use set...
Definition KoDocument.h:846
virtual void removeShell(KoMainWindow *shell)
Removes the shell from the list.
static TQStringList readExtraNativeMimeTypes(TDEInstance *instance=0)
Used by KoMainWindow, when no document exists yet.
TQCString mimeType() const
Returns the actual mimetype of the document.
bool isEmbedded() const
Is the document embedded?
bool import(const KURL &url)
Opens the document given by url, without storing the URL in the KoDocument.
bool confirmNonNativeSave(const bool exporting) const
Returns true if this document was the result of opening a foreign file format and if the user hasn't ...
virtual void addShell(KoMainWindow *shell)
Appends the shell to the list of shells which show this document as their root document.
virtual void setModified(bool _mod)
Sets the modified flag on the document.
virtual void initEmpty()
Initialize an empty document using default values.
int viewCount() const
virtual bool openURL(const KURL &url)
Reimplemented from KParts::ReadWritePart for internal reasons (for the autosave functionality)
KoDocumentInfo * documentInfo() const
virtual TQCString nativeFormatMimeType() const
To be preferred when a document exists.
bool exp0rt(const KURL &url)
Saves the document as url without changing the state of the KoDocument (URL, modified flag etc....
void setURL(const KURL &url)
Sets the document URL to url KParts doesn't really allow this, but it is needed for undo of setStoreI...
Definition KoDocument.h:836
bool isModified() const
Returns true if this document or any of its internal child documents are modified.
void setOutputMimeType(const TQCString &mimeType, int specialOutputFlag=0)
Set the format in which the document should be saved.
static KService::Ptr readNativeService(TDEInstance *instance=0)
With the help of instance or TDEApplication::instance() this method figures out which ....
virtual void showStartUpWidget(KoMainWindow *parent, bool alwaysShow=false)
Creates and shows the start up widget.
virtual bool isEmpty() const
Definition KoDocument.h:489
void setFile(const TQString &file)
Only use these functions to restore m_file (in KoMainWindow) after a failed save (remember to use set...
Definition KoDocument.h:856
virtual void setTitleModified()
Tells the document that its title has been modified, either because the modified status changes (this...
Extension to KFileDialog in order to add special entries to the filter combo, like "save as koffice-1...
static TQStringList mimeFilter()
The same method as KoFilterManager::mimeFilter but suited for KoShell.
Main window for a KOffice application.
bool isImporting() const
Returns whether or not the current slotFileOpen() or openDocument() call is actually an import operat...
KoMainWindow(TDEInstance *instance, const char *_name=0)
Constructor.
virtual void slotToolbarToggled(bool toggle)
Shows or hides a toolbar.
void slotEmailFile()
Slot for eMailing the document using KMail.
virtual void slotConfigureKeys()
Configure key bindings.
void slotFilePrintPreview()
Show a print preview.
virtual void slotConfigureToolbars()
Configure toolbars.
virtual void slotNewToolbarConfig()
Post toolbar config.
virtual void slotDocumentInfo()
Show a dialog with author and document information.
void setRootDocumentDirect(KoDocument *doc, const TQPtrList< KoView > &views)
Special method for KOShell, to allow switching the root document (and its views) among a set of them.
virtual void slotFileClose()
Closes the document.
void slotImportFile()
File --> Import.
void saveRecentFiles()
Save the list of recent files.
bool isExporting() const
Returns whether or not the current slotFileSave[As]() or saveDocument() call is actually an export op...
void slotReloadFile()
Reload file.
virtual bool saveDocument(bool saveas=false, bool silent=false)
Saves the document, asking for a filename if necessary.
void print(bool quick)
Prints the document.
virtual void slotSplitView()
View splitting stuff.
void setDocToOpen(KoDocument *doc)
This is used to handle the document used at start up before it actually added as root document.
virtual bool queryClose()
Ask user about saving changes to the document upon exit.
virtual void setRootDocument(KoDocument *doc)
Called when a document is assigned to this mainwindow.
void slotExportFile()
File --> Export.
TQLabel * statusBarLabel()
Get hold of the label in the statusbar, to write messages to it.
virtual void slotFileOpen()
Slot for opening a saved file.
~KoMainWindow()
Destructor.
virtual void slotFilePrint()
Prints the actual document.
virtual void slotFileSave()
Saves the current document with the current name.
virtual KoDocument * createDoc() const
Create a new empty document.
virtual void slotCloseAllViews()
Close all views.
void saveDialogShown()
This signals is emmitted before the save dialog is shown.
virtual void slotFileSaveAs()
Saves the current document with a new name.
virtual void slotFileOpenRecent(const KURL &)
Slot for opening a file among the recently opened files.
void slotVersionsFile()
This will call a dialogbox to add version to list of files.
void showToolbar(const char *tbName, bool shown)
The application should call this to show or hide a toolbar.
virtual KoDocument * rootDocument() const
Retrieves the document that is displayed in the mainwindow.
bool toolbarIsVisible(const char *tbName)
void setMaxRecentItems(uint _number)
Sets the maximum number of recent documents entries.
virtual bool openDocument(const KURL &url)
Load the desired document and show it.
void addRecentURL(const KURL &url)
The document opened a URL -> store into recent documents list.
virtual void slotFileQuit()
Closes the shell.
void reloadRecentFileList()
Reloads the recent documents list.
virtual void updateCaption()
Update caption from document info - call when document info (title in the about page) changes.
void chooseNewDocument(int initDocFlags)
Helper method for slotFileNew and slotFileClose.
void documentSaved()
This signal is emitted if the document has been saved successfully.
virtual void slotFileNew()
Slot for opening a new document.
KoSpeaker is a singleton object that provides Text-to-Speech services for KOffice applications.
Definition KoSpeaker.h:64
static bool isKttsdInstalled()
Returns whether the KTTSD deamon is installed in the system.
This class is used to display a KoDocument.
Definition KoView.h:58
KoDocument * koDocument() const
Retrieves the document object of this view.
Definition KoView.cpp:182
virtual void print(KPrinter &printer)
Overload this method with your own printing code.
Definition KoView.cpp:639
virtual void setupPrinter(KPrinter &printer)
Overload this method to setup KPrinter before the actual printing.
Definition KoView.cpp:634
TDEToolBar * toolBar(const char *name=0)
virtual void hide()
KStatusBar * statusBar()
void setStandardToolBarMenuEnabled(bool enable)
virtual void setCaption(const TQString &caption)
bool initialGeometrySet() const
void saveMainWindowSettings(TDEConfig *config, const TQString &groupName=TQString::null)
void resetAutoSaveSettings()
void saveWindowSize(TDEConfig *config) const
static TQPtrList< TDEMainWindow > * memberList
virtual void closeEvent(TQCloseEvent *)
void restoreWindowSize(TDEConfig *config)
void setAutoSaveSettings(const TQString &groupName=TQString::fromLatin1("MainWindow"), bool saveWindowSize=true)
void applyMainWindowSettings(TDEConfig *config, const TQString &groupName, bool force)
virtual void show()
void loadEntries(TDEConfig *config, TQString groupname=TQString::null)
void setMaxItems(uint maxItems)
void removeURL(const KURL &url)
void addURL(const KURL &url)
void saveEntries(TDEConfig *config, TQString groupname=TQString::null)
void setCheckedState(const KGuiItem &checkedItem)
virtual void setChecked(bool)
TQString text() const
This file is part of the KDE/KOffice project.
TDEAction * close(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * save(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDERecentFilesAction * openRecent(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * configureToolbars(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * mail(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * open(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * quit(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * printPreview(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * openNew(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * saveAs(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * print(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
const char * name(StdAction id)
TDEAction * keyBindings(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)