kexi

keximainwindowimpl.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3 Copyright (C) 2003-2007 Jaroslaw Staniek <js@iidea.pl>
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 "keximainwindowimpl.h"
22
23#include <unistd.h>
24
25#include <tqapplication.h>
26#include <tqeventloop.h>
27#include <tqfile.h>
28#include <tqtimer.h>
29#include <tqobjectlist.h>
30#include <tqprocess.h>
31#include <tqtoolbutton.h>
32#include <tqtooltip.h>
33#include <tqmutex.h>
34#include <tqwaitcondition.h>
35#include <tqfiledialog.h>
36#include <tqdockwindow.h>
37#include <tqdockarea.h>
38
39#include <tdeapplication.h>
40#include <tdecmdlineargs.h>
41#include <tdeaction.h>
42#include <tdelocale.h>
43#include <tdestdaccel.h>
44#include <tdeconfig.h>
45#include <tdeglobal.h>
46#include <kdebug.h>
47#include <kkeydialog.h>
48#include <kedittoolbar.h>
49#include <tdeglobalsettings.h>
50#include <tdeparts/componentfactory.h>
51#include <ktip.h>
52#include <kstandarddirs.h>
53#include <kpushbutton.h>
54#include <ktextbrowser.h>
55#include <kiconloader.h>
56#include <ktabwidget.h>
57#include <kimageio.h>
58#include <khelpmenu.h>
59#include <tdefiledialog.h>
60#include <tderecentdocument.h>
61
62#include <kexidb/connection.h>
63#include <kexidb/utils.h>
64#include <kexidb/cursor.h>
65#include <kexidb/dbobjectnamevalidator.h>
66#include <kexidb/admin.h>
67#include <kexiutils/utils.h>
68
69//#include "projectsettingsui.h"
70#include "kexiactionproxy.h"
71#include "kexidialogbase.h"
72#include "kexipartmanager.h"
73#include "kexipart.h"
74#include "kexipartinfo.h"
75#include "kexipartguiclient.h"
76#include "kexiproject.h"
77#include "kexiprojectdata.h"
78#include "kexiprojectset.h"
79#include "kexi.h"
80#include "kexistatusbar.h"
81#include "kexiinternalpart.h"
82#include "kexiactioncategories.h"
83#include "kexifinddialog.h"
84#include "kexisearchandreplaceiface.h"
85
86#include "kde2_closebutton.xpm"
87
88#include <widget/kexibrowser.h>
89#include <widget/kexipropertyeditorview.h>
90#include <widget/utils/kexirecordnavigator.h>
91#include <koproperty/editor.h>
92#include <koproperty/set.h>
93
94#include "startup/KexiStartup.h"
95#include "startup/KexiNewProjectWizard.h"
96#include "startup/KexiStartupDialog.h"
97#include "startup/KexiStartupFileDialog.h"
98#include "kexinamedialog.h"
99#include "printing/kexisimpleprintingpart.h"
100#include "printing/kexisimpleprintingpagesetup.h"
101
102//Extreme verbose debug
103#if defined(TQ_WS_WIN)
104# include <tderecentdirs.h>
105# include <win32_utils.h>
106//# define KexiVDebug kdDebug()
107#endif
108
109#if !defined(KexiVDebug)
110# define KexiVDebug if (0) kdDebug()
111#endif
112
113//first fix the geometry
114//#define KEXI_NO_CTXT_HELP 1
115
116#ifndef KEXI_NO_CTXT_HELP
117#include <kexicontexthelp.h>
118#endif
119
120#ifdef HAVE_TDENEWSTUFF
121#include <tdenewstuff/downloaddialog.h>
122#include "kexinewstuff.h"
123#endif
124
127//#define PROPEDITOR_VISIBILITY_CHANGES
128
129//temporary fix to manage layout
130#include "ksplitter.h"
131#define KDOCKWIDGET_P 1
132
133#ifndef KEXI_NO_FEEDBACK_AGENT
134#ifdef FEEDBACK_INCLUDE
135#include FEEDBACK_INCLUDE
136#endif
137#include <tdeapplication.h>
138#include <tdeaboutdata.h>
139#endif
140
141#include "keximainwindowimpl_p.h"
142
143//-------------------------------------------------
144
145//static
146int KexiMainWindowImpl::create(int argc, char *argv[], TDEAboutData* aboutdata)
147{
148 Kexi::initCmdLineArgs( argc, argv, aboutdata );
149
150 bool GUIenabled = true;
151 TQWidget *dummyWidget = 0; //needed to have icon for dialogs before KexiMainWindowImpl is created
153 TDEApplication* app = new TDEApplication(true, GUIenabled);
154
155#ifdef KEXI_STANDALONE
156 TDEGlobal::locale()->removeCatalogue("kexi");
157 TDEGlobal::locale()->insertCatalogue("standalone_kexi");
158#endif
159 TDEGlobal::locale()->insertCatalogue("koffice");
160 TDEGlobal::locale()->insertCatalogue("koproperty");
161
162#ifdef CUSTOM_VERSION
163# include "custom_exec.h"
164#endif
165
166#ifdef KEXI_DEBUG_GUI
167 TQWidget* debugWindow = 0;
168#endif
169 if (GUIenabled) {
170 dummyWidget = new TQWidget();
171 dummyWidget->setIcon( DesktopIcon( "kexi" ) );
172 app->setMainWidget(dummyWidget);
173#ifdef KEXI_DEBUG_GUI
174 app->config()->setGroup("General");
175 if (app->config()->readBoolEntry("showInternalDebugger", false)) {
176 debugWindow = KexiUtils::createDebugWindow(0);
177 }
178#endif
179 }
180
181 tristate res = Kexi::startupHandler().init(argc, argv);
182 if (!res || ~res) {
183#ifdef KEXI_DEBUG_GUI
184 delete debugWindow;
185#endif
186 delete app;
187 return (~res) ? 0 : 1;
188 }
189
190 kdDebug() << "startupActions OK" <<endl;
191
192 /* Exit requested, e.g. after database removing. */
193 if (Kexi::startupHandler().action() == KexiStartupData::Exit) {
194#ifdef KEXI_DEBUG_GUI
195 delete debugWindow;
196#endif
197 delete app;
198 return 0;
199 }
200
202 app->setMainWidget(win);
203#ifdef KEXI_DEBUG_GUI
204 //if (debugWindow)
205 //debugWindow->reparent(win, TQPoint(1,1));
206#endif
207 delete dummyWidget;
208
209 if (true != win->startup()) {
210 delete win;
211 delete app;
212 return 1;
213 }
214
215 win->show();
216 app->processEvents();//allow refresh our app
217
218//#ifdef KEXI_DEBUG_GUI
219// delete debugWindow;
220//#endif
221 return 0;
222}
223
224//-------------------------------------------------
225
227 : KexiMainWindow()
228 , KexiGUIMessageHandler(this)
229 , d(new KexiMainWindowImpl::Private(this) )
230{
231 KImageIO::registerFormats();
233 d->userMode = Kexi::startupHandler().forcedUserMode() /* <-- simply forced the user mode */
234 /* project has 'user mode' set as default and not 'design mode' override is found: */
235 || (pdata && pdata->userMode() && !Kexi::startupHandler().forcedDesignMode());
236 d->isProjectNavigatorVisible = Kexi::startupHandler().isProjectNavigatorVisible();
237
238 if(userMode())
239 kdDebug() << "KexiMainWindowImpl::KexiMainWindowImpl(): starting up in the User Mode" << endl;
240
241 d->config = kapp->config();
242
243 if ( !initialGeometrySet() ) {
244 int scnum = TQApplication::desktop()->screenNumber(parentWidget());
245 TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
246 d->config->setGroup("MainWindow");
247 TQSize s ( d->config->readNumEntry( TQString::fromLatin1("Width %1").arg(desk.width()), 700 ),
248 d->config->readNumEntry( TQString::fromLatin1("Height %1").arg(desk.height()), 480 ) );
249 resize (kMin (s.width(), desk.width()), kMin(s.height(), desk.height()));
250 }
251
252 setManagedDockPositionModeEnabled(true);//TODO(js): remove this if will be default in tdemdi :)
253 manager()->setSplitterHighResolution(true);
254 manager()->setSplitterKeepSize(true);
255 setStandardMDIMenuEnabled(false);
256 setAsDefaultHost(); //this is default host now.
257 TDEGlobal::iconLoader()->addAppDir("kexi");
258 TDEGlobal::iconLoader()->addAppDir("koffice");
259
260 //get informed
261 connect(&Kexi::partManager(),TQ_SIGNAL(partLoaded(KexiPart::Part*)),this,TQ_SLOT(slotPartLoaded(KexiPart::Part*)));
262 connect( m_pMdi, TQ_SIGNAL(nowMaximized(bool)), this, TQ_SLOT(slotCaptionForCurrentMDIChild(bool)) );
263 connect( m_pMdi, TQ_SIGNAL(noMaximizedChildFrmLeft(KMdiChildFrm*)), this, TQ_SLOT(slotNoMaximizedChildFrmLeft(KMdiChildFrm*)));
264// connect( this, TQ_SIGNAL(lastChildFrmClosed()), this, TQ_SLOT(slotLastChildFrmClosed()));
265 connect( this, TQ_SIGNAL(lastChildViewClosed()), this, TQ_SLOT(slotLastChildViewClosed()));
266
267 connect( this, TQ_SIGNAL(childViewIsDetachedNow(TQWidget*)), this, TQ_SLOT(slotChildViewIsDetachedNow(TQWidget*)));
268 connect( this, TQ_SIGNAL(mdiModeHasBeenChangedTo(KMdi::MdiMode)),
269 this, TQ_SLOT(slotMdiModeHasBeenChangedTo(KMdi::MdiMode)));
270
271
272 //if (!userMode()) {
273 setXMLFile("kexiui.rc");
274 setAcceptDrops(true);
275 initActions();
276 createShellGUI(true);
277 //}
278
279 d->statusBar = new KexitStatusBar(this, "status_bar");
280
281 d->origAppCaption = caption();
282
284 (void)Kexi::smallFont(this/*init*/);
285
286 if (!userMode()) {
287 initContextHelp();
288 initPropertyEditor();
289 }
290
291 {//store menu popups list
292 TQObjectList *l = queryList( "TQPopupMenu" );
293 for (TQObjectListIt it( *l ); it.current(); ++it ) {
294 //kdDebug() << "name=" <<it.current()->name() << " cname="<<it.current()->className()<<endl;
295 //KexiMainWindowImpl::eventFilter() will filter our popups:
296 it.current()->installEventFilter(this);
297 d->popups.insert(it.current()->name(), static_cast<TQPopupMenu*>(it.current()));
298 }
299 delete l;
300 d->createMenu = d->popups["create"];
301
302#ifdef KEXI_NO_REPORTBUG_COMMAND
303 //remove "bug report" action to avoid confusion for supported with commercial technical support
304 TQPopupMenu *helpMenu = d->popups["help"];
305 if (helpMenu) {
306 //const int idx = helpMenu->indexOf( (int)KHelpMenu::menuReportBug );
307 helpMenu->removeItemAt(int(KHelpMenu::menuReportBug)-1);
308 helpMenu->removeItemAt(int(KHelpMenu::menuReportBug)-1); //separator
309 }
310#endif
311 }
312
313 //fix menus a bit more:
314#ifndef KEXI_SHOW_UNIMPLEMENTED
315//disabled (possible crash) d->hideMenuItem("file", i18n("&Import"), true);
316//disabled (possible crash) d->hideMenuItem("help", i18n( "&Report Bug..." ), true);
317#endif
318 TDEAction *tdemdi_tooldock_menu_action = childClients()->getFirst() ? childClients()->getFirst()->actionCollection()->action("tdemdi_tooldock_menu") : 0;
319 if (tdemdi_tooldock_menu_action) {
320 tdemdi_tooldock_menu_action->setEnabled(false);
321 }
322
323 if (!isFakingSDIApplication()/* && !userMode()*/) {
324// TQPopupMenu *menu = (TQPopupMenu*) child( "window", "TDEPopupMenu" );
325 TQPopupMenu *menu = d->popups["window"];
326 unsigned int count = menuBar()->count();
327 if (menu)
328 setWindowMenu(menu);
329 else
330 menuBar()->insertItem( i18n("&Window"), windowMenu(), -1, count-2); // standard position is left to the last ('Help')
331 }
332 if (userMode()) {
333 //hide "insert" menu and disable "project_import", "edit_paste_special" menus
334 TQPopupMenu *menu = d->popups["insert"];
335 if (menu) {
336 for (uint i=0; i < menuBar()->count(); i++) {
337 if (menuBar()->text( menuBar()->idAt(i) ) == i18n("&Insert")) {
338 menuBar()->setItemVisible( menuBar()->idAt(i), false );
339 break;
340 }
341 }
342 }
343 d->disableMenuItem("file", i18n("&Import"));
344 d->disableMenuItem("edit", i18n("Paste &Special"));
345 }
346
347 m_pTaskBar->setCaption(i18n("Task Bar")); //js TODO: move this to KMDIlib
348
349// if (!userMode()) {
351 d->timer.singleShot(0,this,TQ_SLOT(slotLastActions()));
352// }
353
354 setTabWidgetVisibility(KMdi::AlwaysShowTabs);
355 if (mdiMode()==KMdi::IDEAlMode) {
356 d->config->setGroup("MainWindow");
357 tabWidget()->setHoverCloseButton(d->config->readBoolEntry("HoverCloseButtonForTabs", false));
358 //create special close button as corner widget for IDEAl mode
359 TQToolButton *closeButton = new TQToolButton( tabWidget() );
360 closeButton->setAutoRaise( true );
361 closeButton->setPixmap( TQPixmap( kde2_closebutton ) );
362 closeButton->setPaletteBackgroundColor(closeButton->palette().active().background());
363// closeButton->setIconSet(SmallIconSet("tab_remove"));
364 tabWidget()->setCornerWidget( closeButton, TQt::TopRight );
365 closeButton->hide(); // hide until it's needed to avoid problems in "user mode"
366 // when initially the main window is empty
367 TQToolTip::add(closeButton,
368 i18n("Close the current tab page in Kexi tab interface", "Close the current tab"));
369 TQObject::connect( closeButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( closeActiveView() ) );
370 }
371
372#ifdef KEXI_ADD_CUSTOM_KEXIMAINWINDOWIMPL
373# include "keximainwindowimpl_ctor.h"
374#endif
375}
376
377KexiMainWindowImpl::~KexiMainWindowImpl()
378{
379 d->forceDialogClosing=true;
380 closeProject();
381 delete d;
382}
383
385{
386 return d->prj;
387}
388
389void KexiMainWindowImpl::setWindowMenu(TQPopupMenu *menu)
390{
391 delete m_pWindowMenu;
392 m_pWindowMenu = menu;
393 int count = menuBar()->count();
394 //try to move "window" menu just before "Settings" menu (count-3)
395 const TQString txt = i18n("&Window");
396 int i;
397 for (i=0; i<count; i++) {
398 //kdDebug() << menuBar()->text( menuBar()->idAt(i) ) << endl;
399 if (txt==menuBar()->text( menuBar()->idAt(i) ))
400 break;
401 }
402 if (i<count) {
403 const int id = menuBar()->idAt(i);
404 menuBar()->removeItemAt(i);
405 menuBar()->insertItem(txt, m_pWindowMenu, id, count-3);
406 }
407 m_pWindowMenu->setCheckable(true);
408 TQObject::connect( m_pWindowMenu, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(fillWindowMenu()) );
409}
410
411void KexiMainWindowImpl::fillWindowMenu()
412{
413 KexiMainWindow::fillWindowMenu();
414
415/* int i;
416 for (i=0; i < (int)m_pWindowMenu->count(); i++) {
417 if (m_pWindowMenu->text( m_pWindowMenu->idAt( i ) ) == i18n( "&MDI Mode" )) {
418// kdDebug() << m_pWindowMenu->text( m_pWindowMenu->idAt( i ) ) << endl;
419 m_pWindowMenu->removeItem( m_pWindowMenu->idAt( i ) );
420 break;
421 }
422 }*/
423
424 m_pMdiModeMenu->removeItem( m_pMdiModeMenu->idAt( 0 ) ); //hide toplevel mode
425 m_pMdiModeMenu->removeItem( m_pMdiModeMenu->idAt( 1 ) ); //hide tabbed mode
426 //update
427 if (d->mdiModeToSwitchAfterRestart != (KMdi::MdiMode)0) {
428 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 0 ),
429 d->mdiModeToSwitchAfterRestart == KMdi::ChildframeMode );
430 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 1 ),
431 d->mdiModeToSwitchAfterRestart == KMdi::IDEAlMode );
432 }
433
434 //insert window_next, window_previous actions:
435// const TQString t = i18n("&Dock/Undock...");
436 int i = m_pWindowMenu->count()-1;
437 for (int index;; i--) {
438 index = m_pWindowMenu->idAt(i);
439 if (index==-1 || m_pWindowMenu->text(index).isNull())
440 break;
441 }
442 i++;
443 d->action_window_next->plug( m_pWindowMenu, i++ );
444 d->action_window_previous->plug( m_pWindowMenu, i++ );
445 if (!m_pDocumentViews->isEmpty())
446 m_pWindowMenu->insertSeparator( i++ );
447}
448
453
454void KexiMainWindowImpl::switchToIDEAlMode(bool showMessage)
455{
456 if (showMessage) {
457 if ((int)d->mdiModeToSwitchAfterRestart == 0 && mdiMode()==KMdi::IDEAlMode)
458 return;
459 if (d->mdiModeToSwitchAfterRestart == KMdi::IDEAlMode)
460 return;
461 if (mdiMode()==KMdi::IDEAlMode) {//current mode
462 d->mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
463 }
464 else {
465 KMessageBox::information(this,
466 i18n("User interface mode will be switched to IDEAl at next %1 application startup.")
467 .arg(KEXI_APP_NAME));
468 //delayed
469 d->mdiModeToSwitchAfterRestart = KMdi::IDEAlMode;
470 }
471 }
472 else
473 KexiMainWindow::switchToIDEAlMode();
474}
475
476void KexiMainWindowImpl::switchToChildframeMode()
477{
478 switchToChildframeMode(true);
479}
480
481void KexiMainWindowImpl::switchToChildframeMode(bool showMessage)
482{
483 if (showMessage) {
484 if ((int)d->mdiModeToSwitchAfterRestart == 0 && mdiMode()==KMdi::ChildframeMode)
485 return;
486 if (d->mdiModeToSwitchAfterRestart == KMdi::ChildframeMode)
487 return;
488 if (mdiMode()==KMdi::ChildframeMode) {//current mode
489 d->mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
490 }
491 else {
492 KMessageBox::information(this,
493 i18n("User interface mode will be switched to Childframe at next %1 application startup.")
494 .arg(KEXI_APP_NAME));
495 //delayed
496 d->mdiModeToSwitchAfterRestart = KMdi::ChildframeMode;
497 }
498 }
499 else
500 KexiMainWindow::switchToChildframeMode();
501}
502
503TQPopupMenu* KexiMainWindowImpl::findPopupMenu(const char *popupName)
504{
505 return d->popups[popupName];
506}
507
508TDEActionPtrList KexiMainWindowImpl::allActions() const
509{
510 return actionCollection()->actions();
511}
512
514{
515 return d->curDialog;
516}
517
519{
520// setupGUI(TDEMainWindow::Keys|TDEMainWindow::StatusBar|TDEMainWindow::Save|TDEMainWindow::Create);
521
522// d->actionMapper = new TQSignalMapper(this, "act_map");
523// connect(d->actionMapper, TQ_SIGNAL(mapped(const TQString &)), this, TQ_SLOT(slotAction(const TQString &)));
524
525 // PROJECT MENU
526 TDEAction *action = new TDEAction(i18n("&New..."), "document-new", TDEStdAccel::shortcut(TDEStdAccel::New),
527 this, TQ_SLOT(slotProjectNew()), actionCollection(), "project_new");
528 action->setToolTip(i18n("Create a new project"));
529 action->setWhatsThis(i18n("Creates a new project. Currently opened project is not affected."));
530
531 action = KStdAction::open( this, TQ_SLOT( slotProjectOpen() ), actionCollection(), "project_open" );
532 action->setToolTip(i18n("Open an existing project"));
533 action->setWhatsThis(i18n("Opens an existing project. Currently opened project is not affected."));
534
535#ifdef HAVE_TDENEWSTUFF
536 action = new TDEAction(i18n("&Download Example Databases..."), "kget", TDEShortcut(0),
537 this, TQ_SLOT(slotGetNewStuff()), actionCollection(), "project_download_examples");
538 action->setToolTip(i18n("Download example databases from the Internet"));
539 action->setWhatsThis(i18n("Downloads example databases from the Internet."));
540#endif
541
542// d->action_open_recent = KStdAction::openRecent( this, TQ_SLOT(slotProjectOpenRecent(const KURL&)), actionCollection(), "project_open_recent" );
543
544//#ifdef KEXI_SHOW_UNIMPLEMENTED
545#ifndef KEXI_NO_UNFINISHED
546 d->action_open_recent = new TDEActionMenu(i18n("Open Recent"),
547 actionCollection(), "project_open_recent");
548 connect(d->action_open_recent->popupMenu(),TQ_SIGNAL(activated(int)),
549 this,TQ_SLOT(slotProjectOpenRecent(int)));
550 connect(d->action_open_recent->popupMenu(), TQ_SIGNAL(aboutToShow()),
551 this,TQ_SLOT(slotProjectOpenRecentAboutToShow()));
552//moved down d->action_open_recent_projects_title_id =
553// d->action_open_recent->popupMenu()->insertTitle(i18n("Recently Opened Databases"));
554//moved down d->action_open_recent_connections_title_id =
555// d->action_open_recent->popupMenu()->insertTitle(i18n("Recently Connected Database Servers"));
556// d->action_open_recent->popupMenu()->insertSeparator();
557// d->action_open_recent_more_id = d->action_open_recent->popupMenu()
558// ->insertItem(i18n("&More Projects..."), this, TQ_SLOT(slotProjectOpenRecentMore()), 0, 1000);
559#else
560 d->action_open_recent = d->dummy_action;
561#endif
562
563 d->action_save = KStdAction::save(
564 this, TQ_SLOT( slotProjectSave() ), actionCollection(), "project_save" );
565// d->action_save = new TDEAction(i18n("&Save"), "document-save", TDEStdAccel::shortcut(TDEStdAccel::Save),
566// this, TQ_SLOT(slotProjectSave()), actionCollection(), "project_save");
567 d->action_save->setToolTip(i18n("Save object changes"));
568 d->action_save->setWhatsThis(i18n("Saves object changes from currently selected window."));
569
570#ifdef KEXI_SHOW_UNIMPLEMENTED
571 d->action_save_as = new TDEAction(i18n("Save &As..."), "document-save-as", 0,
572 this, TQ_SLOT(slotProjectSaveAs()), actionCollection(), "project_saveas");
573 d->action_save_as->setToolTip(i18n("Save object as"));
574 d->action_save_as->setWhatsThis(
575 i18n("Saves object changes from currently selected window under a new name (within the same project)."));
576
577 d->action_project_properties = new TDEAction(i18n("Project Properties"), "application-vnd.tde.info", 0,
578 this, TQ_SLOT(slotProjectProperties()), actionCollection(), "project_properties");
579#else
580 d->action_save_as = d->dummy_action;
581 d->action_project_properties = d->dummy_action;
582#endif
583
584 d->action_close = new TDEAction(i18n("&Close Project"), "window-close", 0,
585 this, TQ_SLOT(slotProjectClose()), actionCollection(), "project_close" );
586 d->action_close->setToolTip(i18n("Close the current project"));
587 d->action_close->setWhatsThis(i18n("Closes the current project."));
588
589 KStdAction::quit( this, TQ_SLOT(slotProjectQuit()), actionCollection(), "quit");
590
591#ifdef KEXI_SHOW_UNIMPLEMENTED
592 d->action_project_relations = new TDEAction(i18n("&Relationships..."), "relation", TQt::CTRL + TQt::Key_R,
593 this, TQ_SLOT(slotProjectRelations()), actionCollection(), "project_relations");
594 d->action_project_relations->setToolTip(i18n("Project relationships"));
595 d->action_project_relations->setWhatsThis(i18n("Shows project relationships."));
596
597#else
598 d->action_project_relations = d->dummy_action;
599#endif
600 d->action_tools_data_migration = new TDEAction(
601 i18n("&Import Database..."), "database_import", 0,
602 this, TQ_SLOT(slotToolsProjectMigration()), actionCollection(), "tools_import_project");
603 d->action_tools_data_migration->setToolTip(i18n("Import entire database as a Kexi project"));
604 d->action_tools_data_migration->setWhatsThis(i18n("Imports entire database as a Kexi project."));
605
606 d->action_tools_compact_database = new TDEAction(
607 i18n("&Compact Database..."), "", 0,
608 this, TQ_SLOT(slotToolsCompactDatabase()), actionCollection(), "tools_compact_database");
609 d->action_tools_compact_database->setToolTip(i18n("Compact the current database project"));
610 d->action_tools_compact_database->setWhatsThis(
611 i18n("Compacts the current database project, so it will take less space and work faster."));
612
613 if (userMode())
614 d->action_project_import_data_table = 0;
615 else {
616 d->action_project_import_data_table = new TDEAction(
617 i18n("Import->Table Data From File...", "Table Data From &File..."),
618 "table",
619 0, this, TQ_SLOT(slotProjectImportDataTable()), actionCollection(),
620 "project_import_data_table");
621 d->action_project_import_data_table->setToolTip(i18n("Import table data from a file"));
622 d->action_project_import_data_table->setWhatsThis(i18n("Imports table data from a file."));
623 }
624
625 d->action_project_export_data_table = new TDEAction(i18n("Export->Table or Query Data to File...",
626 "Table or Query Data to &File..."),
627 "table",
628 0, this, TQ_SLOT(slotProjectExportDataTable()), actionCollection(),
629 "project_export_data_table");
630 d->action_project_export_data_table->setToolTip(
631 i18n("Export data from the active table or query data to a file"));
632 d->action_project_export_data_table->setWhatsThis(
633 i18n("Exports data from the active table or query data to a file."));
634
635//TODO new TDEAction(i18n("From File..."), "document-open", 0,
636//TODO this, TQ_SLOT(slotImportFile()), actionCollection(), "project_import_file");
637//TODO new TDEAction(i18n("From Server..."), "server", 0,
638//TODO this, TQ_SLOT(slotImportServer()), actionCollection(), "project_import_server");
639
640 d->action_project_print = KStdAction::print(this, TQ_SLOT(slotProjectPrint()),
641 actionCollection(), "project_print" );
642 d->action_project_print->setToolTip(i18n("Print data from the active table or query"));
643 d->action_project_print->setWhatsThis(i18n("Prints data from the active table or query."));
644
645 d->action_project_print_preview = KStdAction::printPreview(
646 this, TQ_SLOT(slotProjectPrintPreview()),
647 actionCollection(), "project_print_preview" );
648 d->action_project_print_preview->setToolTip(
649 i18n("Show print preview for the active table or query"));
650 d->action_project_print_preview->setWhatsThis(
651 i18n("Shows print preview for the active table or query."));
652
653 d->action_project_print_setup = new TDEAction(i18n("Page Set&up..."),
654 "", 0, this, TQ_SLOT(slotProjectPageSetup()), actionCollection(),
655 "project_print_setup");
656 d->action_project_print_setup->setToolTip(
657 i18n("Show page setup for printing the active table or query"));
658 d->action_project_print_setup->setWhatsThis(
659 i18n("Shows page setup for printing the active table or query."));
660
661 //EDIT MENU
662 d->action_edit_cut = createSharedAction( KStdAction::Cut, "edit_cut");
663 d->action_edit_copy = createSharedAction( KStdAction::Copy, "edit_copy");
664 d->action_edit_paste = createSharedAction( KStdAction::Paste, "edit_paste");
665
666 if (userMode())
667 d->action_edit_paste_special_data_table = 0;
668 else {
669 d->action_edit_paste_special_data_table =
670 new TDEAction(i18n("Paste Special->As Data &Table...", "As Data &Table..."),
671 "table", 0, this, TQ_SLOT(slotEditPasteSpecialDataTable()),
672 actionCollection(), "edit_paste_special_data_table");
673 d->action_edit_paste_special_data_table->setToolTip(
674 i18n("Paste clipboard data as a table"));
675 d->action_edit_paste_special_data_table->setWhatsThis(
676 i18n("Pastes clipboard data to a table."));
677 }
678
679 d->action_edit_copy_special_data_table =
680 new TDEAction(i18n("Copy Special->Table or Query Data...",
681 "Table or Query as Data Table..."),
682 "table", 0, this, TQ_SLOT(slotEditCopySpecialDataTable()),
683 actionCollection(), "edit_copy_special_data_table");
684 d->action_edit_copy_special_data_table->setToolTip(
685 i18n("Copy selected table or query data to clipboard"));
686 d->action_edit_copy_special_data_table->setWhatsThis(
687 i18n("Copies selected table or query data to clipboard."));
688
689 d->action_edit_undo = createSharedAction( KStdAction::Undo, "edit_undo");
690 d->action_edit_undo->setWhatsThis(i18n("Reverts the most recent editing action."));
691 d->action_edit_redo = createSharedAction( KStdAction::Redo, "edit_redo");
692 d->action_edit_redo->setWhatsThis(i18n("Reverts the most recent undo action."));
693
694#if 0 //old
695 d->action_edit_find = createSharedAction( KStdAction::Find, "edit_find");
696 d->action_edit_findnext = createSharedAction( KStdAction::FindNext, "edit_findnext");
697 d->action_edit_findprev = createSharedAction( KStdAction::FindPrev, "edit_findprevious");
699#endif
700
701 d->action_edit_find = KStdAction::find(
702 this, TQ_SLOT(slotEditFind()), actionCollection(), "edit_find" );
703// d->action_edit_find = createSharedAction( KStdAction::Find, "edit_find");
704 d->action_edit_findnext = KStdAction::findNext(
705 this, TQ_SLOT(slotEditFindNext()), actionCollection(), "edit_findnext");
706 d->action_edit_findprev = KStdAction::findPrev(
707 this, TQ_SLOT(slotEditFindPrevious()), actionCollection(), "edit_findprevious");
708 d->action_edit_replace = 0;
711 d->action_edit_replace_all = 0;
714
715 d->action_edit_select_all = createSharedAction( KStdAction::SelectAll, "edit_select_all");
716
717 d->action_edit_delete = createSharedAction(i18n("&Delete"), "edit-delete",
718 0/*TQt::Key_Delete*/, "edit_delete");
719 d->action_edit_delete->setToolTip(i18n("Delete selected object"));
720 d->action_edit_delete->setWhatsThis(i18n("Deletes currently selected object."));
721
722 d->action_edit_delete_row = createSharedAction(i18n("Delete Row"), "delete_table_row",
723 TQt::CTRL+TQt::Key_Delete, "edit_delete_row");
724 d->action_edit_delete_row->setToolTip(i18n("Delete currently selected row"));
725 d->action_edit_delete_row->setWhatsThis(i18n("Deletes currently selected row."));
726
727 d->action_edit_clear_table = createSharedAction(i18n("Clear Table Contents"), "clear_table_contents",
728 0, "edit_clear_table");
729 d->action_edit_clear_table->setToolTip(i18n("Clear table contents"));
730 d->action_edit_clear_table->setWhatsThis(i18n("Clears table contents."));
731 setActionVolatile( d->action_edit_clear_table, true );
732
733 d->action_edit_edititem = createSharedAction(i18n("Edit Item"), 0, 0, /* CONFLICT in TV: TQt::Key_F2, */
734 "edit_edititem");
735 d->action_edit_edititem->setToolTip(i18n("Edit currently selected item"));
736 d->action_edit_edititem->setWhatsThis(i18n("Edits currently selected item."));
737
738 d->action_edit_insert_empty_row = createSharedAction(i18n("&Insert Empty Row"), "insert_table_row",
739 TQt::SHIFT | TQt::CTRL | TQt::Key_Insert, "edit_insert_empty_row");
740 setActionVolatile( d->action_edit_insert_empty_row, true );
741 d->action_edit_insert_empty_row->setToolTip(i18n("Insert one empty row above"));
742 d->action_edit_insert_empty_row->setWhatsThis(i18n("Inserts one empty row above currently selected table row."));
743
744 //VIEW MENU
745 if (!userMode()) {
746 d->action_view_data_mode = new TDERadioAction(i18n("&Data View"), "state_data", TQt::Key_F6,
747 this, TQ_SLOT(slotViewDataMode()), actionCollection(), "view_data_mode");
748 d->actions_for_view_modes.insert( Kexi::DataViewMode, d->action_view_data_mode );
749 d->action_view_data_mode->setExclusiveGroup("view_mode");
750 d->action_view_data_mode->setToolTip(i18n("Switch to data view"));
751 d->action_view_data_mode->setWhatsThis(i18n("Switches to data view."));
752 }
753 else
754 d->action_view_data_mode = 0;
755
756 if (!userMode()) {
757 d->action_view_design_mode = new TDERadioAction(i18n("D&esign View"), "state_edit", TQt::Key_F7,
758 this, TQ_SLOT(slotViewDesignMode()), actionCollection(), "view_design_mode");
759 d->actions_for_view_modes.insert( Kexi::DesignViewMode, d->action_view_design_mode );
760 d->action_view_design_mode->setExclusiveGroup("view_mode");
761 d->action_view_design_mode->setToolTip(i18n("Switch to design view"));
762 d->action_view_design_mode->setWhatsThis(i18n("Switches to design view."));
763 }
764 else
765 d->action_view_design_mode = 0;
766
767 if (!userMode()) {
768 d->action_view_text_mode = new TDERadioAction(i18n("&Text View"), "state_sql", TQt::Key_F8,
769 this, TQ_SLOT(slotViewTextMode()), actionCollection(), "view_text_mode");
770 d->actions_for_view_modes.insert( Kexi::TextViewMode, d->action_view_text_mode );
771 d->action_view_text_mode->setExclusiveGroup("view_mode");
772 d->action_view_text_mode->setToolTip(i18n("Switch to text view"));
773 d->action_view_text_mode->setWhatsThis(i18n("Switches to text view."));
774 }
775 else
776 d->action_view_text_mode = 0;
777
778 if (d->isProjectNavigatorVisible) {
779 d->action_view_nav = new TDEAction(i18n("Project Navigator"), "", TQt::ALT + TQt::Key_1,
780 this, TQ_SLOT(slotViewNavigator()), actionCollection(), "view_navigator");
781 d->action_view_nav->setToolTip(i18n("Go to project navigator panel"));
782 d->action_view_nav->setWhatsThis(i18n("Goes to project navigator panel."));
783 }
784 else
785 d->action_view_nav = 0;
786
787 d->action_view_mainarea = new TDEAction(i18n("Main Area"), "", TQt::ALT + TQt::Key_2,
788 this, TQ_SLOT(slotViewMainArea()), actionCollection(), "view_mainarea");
789 d->action_view_mainarea->setToolTip(i18n("Go to main area"));
790 d->action_view_mainarea->setWhatsThis(i18n("Goes to main area."));
791
792 if (!userMode()) {
793 d->action_view_propeditor = new TDEAction(i18n("Property Editor"), "", TQt::ALT + TQt::Key_3,
794 this, TQ_SLOT(slotViewPropertyEditor()), actionCollection(), "view_propeditor");
795 d->action_view_propeditor->setToolTip(i18n("Go to property editor panel"));
796 d->action_view_propeditor->setWhatsThis(i18n("Goes to property editor panel."));
797 }
798 else
799 d->action_view_propeditor = 0;
800
801 //DATA MENU
802 d->action_data_save_row = createSharedAction(i18n("&Save Row"), "button_ok",
803 TQt::SHIFT | TQt::Key_Return, "data_save_row");
804 d->action_data_save_row->setToolTip(i18n("Save changes made to the current row"));
805 d->action_data_save_row->setWhatsThis(i18n("Saves changes made to the current row."));
806//temp. disable because of problems with volatile actions setActionVolatile( d->action_data_save_row, true );
807
808 d->action_data_cancel_row_changes = createSharedAction(i18n("&Cancel Row Changes"),
809 "button_cancel", 0 , "data_cancel_row_changes");
810 d->action_data_cancel_row_changes->setToolTip(i18n("Cancel changes made to the current row"));
811 d->action_data_cancel_row_changes->setWhatsThis(i18n("Cancels changes made to the current row."));
812//temp. disable because of problems with volatile actions setActionVolatile( d->action_data_cancel_row_changes, true );
813
814 d->action_data_execute = createSharedAction(i18n("&Execute"), "media-playback-start", 0 , "data_execute");
815 //d->action_data_execute->setToolTip(i18n("")); //TODO
816 //d->action_data_execute->setWhatsThis(i18n("")); //TODO
817
818#ifndef KEXI_NO_UNFINISHED
819 action = createSharedAction(i18n("&Filter"), "filter", 0, "data_filter");
820 setActionVolatile( action, true );
821#endif
822// action->setToolTip(i18n("")); //todo
823// action->setWhatsThis(i18n("")); //todo
824
825// setSharedMenu("data_sort");
826 action = createSharedAction(i18n("&Ascending"), "sort_az", 0, "data_sort_az");
827//temp. disable because of problems with volatile actions setActionVolatile( action, true );
828 action->setToolTip(i18n("Sort data in ascending order"));
829 action->setWhatsThis(i18n("Sorts data in ascending order (from A to Z and from 0 to 9). Data from selected column is used for sorting."));
830
831 action = createSharedAction(i18n("&Descending"), "sort_za", 0, "data_sort_za");
832//temp. disable because of problems with volatile actions setActionVolatile( action, true );
833 action->setToolTip(i18n("Sort data in descending order"));
834 action->setWhatsThis(i18n("Sorts data in descending (from Z to A and from 9 to 0). Data from selected column is used for sorting."));
835
836 // - record-navigation related actions
837 createSharedAction( KexiRecordNavigator::Actions::moveToFirstRecord(), 0, "data_go_to_first_record");
838 createSharedAction( KexiRecordNavigator::Actions::moveToPreviousRecord(), 0, "data_go_to_previous_record");
839 createSharedAction( KexiRecordNavigator::Actions::moveToNextRecord(), 0, "data_go_to_next_record");
840 createSharedAction( KexiRecordNavigator::Actions::moveToLastRecord(), 0, "data_go_to_last_record");
841 createSharedAction( KexiRecordNavigator::Actions::moveToNewRecord(), 0, "data_go_to_new_record");
842
843 //FORMAT MENU
844 d->action_format_font = createSharedAction(i18n("&Font..."), "fonts", 0, "format_font");
845 d->action_format_font->setToolTip(i18n("Change font for selected object"));
846 d->action_format_font->setWhatsThis(i18n("Changes font for selected object."));
847
848 //TOOLS MENU
849
850 //WINDOW MENU
851#ifndef TQ_WS_WIN
852 //KMDI <= 3.5.1 has no shortcut here:
853 TDEAction *closeWindowAction = actionCollection()->action("window_close");
854 if (closeWindowAction)
855 closeWindowAction->setShortcut(TDEStdAccel::close());
856#endif
857
858 //additional 'Window' menu items
859 d->action_window_next = new TDEAction( i18n("&Next Window"), "",
860#ifdef TQ_WS_WIN
861 TQt::CTRL+TQt::Key_Tab,
862#else
863 TQt::ALT+TQt::Key_Right,
864#endif
865 this, TQ_SLOT(activateNextWin()), actionCollection(), "window_next");
866 d->action_window_next->setToolTip( i18n("Next window") );
867 d->action_window_next->setWhatsThis(i18n("Switches to the next window."));
868
869 d->action_window_previous = new TDEAction( i18n("&Previous Window"), "",
870#ifdef TQ_WS_WIN
871 TQt::CTRL+TQt::SHIFT+TQt::Key_Tab,
872#else
873 TQt::ALT+TQt::Key_Left,
874#endif
875 this, TQ_SLOT(activatePrevWin()), actionCollection(), "window_previous");
876 d->action_window_previous->setToolTip( i18n("Previous window") );
877 d->action_window_previous->setWhatsThis(i18n("Switches to the previous window."));
878
879 //SETTINGS MENU
880 setStandardToolBarMenuEnabled( true );
881 action = KStdAction::keyBindings(this, TQ_SLOT( slotConfigureKeys() ), actionCollection() );
882 action->setWhatsThis(i18n("Lets you configure shortcut keys."));
883
884#ifdef KEXI_SHOW_UNIMPLEMENTED
885 action = KStdAction::configureToolbars( this, TQ_SLOT( slotConfigureToolbars() ), actionCollection() );
886 action->setWhatsThis(i18n("Lets you configure toolbars."));
887
888 d->action_show_other = new TDEActionMenu(i18n("Other"),
889 actionCollection(), "options_show_other");
890#endif
891
892#ifndef KEXI_NO_CTXT_HELP
893 d->action_show_helper = new TDEToggleAction(i18n("Show Context Help"), "", TQt::CTRL + TQt::Key_H,
894 actionCollection(), "options_show_contexthelp");
895 d->action_show_helper->setCheckedState(i18n("Hide Context Help"));
896#endif
897
898#ifdef KEXI_FORMS_SUPPORT
899 slotOptionsEnableForms(true, true);
900#else
901 slotOptionsEnableForms(false, true);
902#endif
903
904#ifdef KEXI_REPORTS_SUPPORT
905 Kexi::tempShowReports() = true;
906#else
907 Kexi::tempShowReports() = false;
908#endif
909
910#ifdef KEXI_MACROS_SUPPORT
911 Kexi::tempShowMacros() = true;
912#else
913 Kexi::tempShowMacros() = false;
914#endif
915
916#ifdef KEXI_SCRIPTS_SUPPORT
917 Kexi::tempShowScripts() = true;
918#else
919 Kexi::tempShowScripts() = false;
920#endif
921
922#ifdef KEXI_SHOW_UNIMPLEMENTED
923 d->action_configure = KStdAction::preferences(this, TQ_SLOT(slotShowSettings()), actionCollection());
924 action->setWhatsThis(i18n("Lets you configure Kexi."));
925#endif
926
927 //HELP MENU
928#if 0//js: todo reenable later
929 KStdAction::tipOfDay( this, TQ_SLOT( slotTipOfTheDayAction() ), actionCollection() )
930 ->setWhatsThis(i18n("This shows useful tips on the use of this application."));
931#endif
932#if 0 //we don't have a time for updating info text for each new version
933 new TDEAction(i18n("Important Information"), "messagebox_info", 0,
934 this, TQ_SLOT(slotImportantInfo()), actionCollection(), "help_show_important_info");
935#endif
936//TODO: UNCOMMENT TO REMOVE MDI MODES SETTING m_pMdiModeMenu->hide();
937
938#ifndef KEXI_NO_FEEDBACK_AGENT
939#ifdef FEEDBACK_CLASS
940 new TDEAction(i18n("Give Feedback..."), "messagebox_info", 0,
941 this, TQ_SLOT(slotStartFeedbackAgent()), actionCollection(), "help_start_feedback_agent");
942#endif
943#endif
944// TDEAction *actionSettings = new TDEAction(i18n("Configure Kexi..."), "configure", 0,
945// actionCollection(), "kexi_settings");
946// actionSettings->setWhatsThis(i18n("Lets you configure Kexi."));
947// connect(actionSettings, TQ_SIGNAL(activated()), this, TQ_SLOT(slotShowSettings()));
948
949 // -- add a few missing tooltips (usable especially in Form's "Assign action" dialog)
950 if ((action = actionCollection()->action("window_close")))
951 action->setToolTip(i18n("Close the current window"));
952
953 // ----- declare action categories, so form's "assign action to button"
954 // (and macros in the future) will be able to recognize category
955 // of actions and filter them -----------------------------------
958 acat->addAction("data_execute", Kexi::PartItemActionCategory);
959
961 acat->addWindowAction("data_filter",
962 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
963
964 acat->addWindowAction("data_save_row",
965 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
966
967 acat->addWindowAction("data_cancel_row_changes",
968 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
969
970 acat->addWindowAction("delete_table_row",
971 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
972
974 acat->addWindowAction("data_sort_az",
975 KexiPart::TableObjectType, KexiPart::QueryObjectType);
976
978 acat->addWindowAction("data_sort_za",
979 KexiPart::TableObjectType, KexiPart::QueryObjectType);
980
982 acat->addWindowAction("edit_clear_table",
983 KexiPart::TableObjectType, KexiPart::QueryObjectType);
984
986 acat->addWindowAction("edit_copy_special_data_table",
987 KexiPart::TableObjectType, KexiPart::QueryObjectType);
988
989 // GlobalActions, etc.
991
993
995
997 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
998
1000 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1001
1003 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1004
1006 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1007
1009 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1010
1012 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1013
1015 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1016
1017 acat->addAction("edit_paste_special_data_table", Kexi::GlobalActionCategory);
1018
1019 acat->addAction("help_about_app", Kexi::GlobalActionCategory);
1020
1021 acat->addAction("help_about_kde", Kexi::GlobalActionCategory);
1022
1023 acat->addAction("help_contents", Kexi::GlobalActionCategory);
1024
1025 acat->addAction("help_report_bug", Kexi::GlobalActionCategory);
1026
1027 acat->addAction("help_whats_this", Kexi::GlobalActionCategory);
1028
1029 acat->addAction("options_configure_keybinding", Kexi::GlobalActionCategory);
1030
1031 acat->addAction("project_close", Kexi::GlobalActionCategory);
1032
1034 acat->addAction("project_export_data_table", Kexi::GlobalActionCategory|Kexi::WindowActionCategory,
1035 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1036
1037 acat->addAction("project_import_data_table", Kexi::GlobalActionCategory);
1038
1039 acat->addAction("project_new", Kexi::GlobalActionCategory);
1040
1041 acat->addAction("project_open", Kexi::GlobalActionCategory);
1042
1044 acat->addAction("project_print", Kexi::WindowActionCategory,
1045 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1046
1048 acat->addAction("project_print_preview", Kexi::WindowActionCategory,
1049 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1050
1052 acat->addAction("project_print_setup", Kexi::WindowActionCategory,
1053 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1054
1056
1057 acat->addAction("tools_compact_database", Kexi::GlobalActionCategory);
1058
1059 acat->addAction("tools_import_project", Kexi::GlobalActionCategory);
1060
1061 acat->addAction("view_data_mode", Kexi::GlobalActionCategory);
1062
1063 acat->addAction("view_design_mode", Kexi::GlobalActionCategory);
1064
1065 acat->addAction("view_text_mode", Kexi::GlobalActionCategory);
1066
1067 acat->addAction("view_mainarea", Kexi::GlobalActionCategory);
1068
1069 acat->addAction("view_navigator", Kexi::GlobalActionCategory);
1070
1071 acat->addAction("view_propeditor", Kexi::GlobalActionCategory);
1072
1074 acat->setAllObjectTypesSupported("window_close", true);
1075
1076 acat->addAction("window_next", Kexi::GlobalActionCategory);
1077
1078 acat->addAction("window_previous", Kexi::GlobalActionCategory);
1079
1080 //skipped - design view only
1081 acat->addAction("format_font", Kexi::NoActionCategory);
1082 acat->addAction("project_save", Kexi::NoActionCategory);
1083 acat->addAction("edit_insert_empty_row", Kexi::NoActionCategory);
1085 acat->addAction("edit_select_all", Kexi::NoActionCategory);
1087 acat->addAction("edit_redo", Kexi::NoActionCategory);
1089 acat->addAction("edit_undo", Kexi::NoActionCategory);
1090
1091 //record-navigation related actions
1092 acat->addAction("data_go_to_first_record", Kexi::WindowActionCategory,
1093 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1094 acat->addAction("data_go_to_previous_record", Kexi::WindowActionCategory,
1095 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1096 acat->addAction("data_go_to_next_record", Kexi::WindowActionCategory,
1097 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1098 acat->addAction("data_go_to_last_record", Kexi::WindowActionCategory,
1099 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1100 acat->addAction("data_go_to_new_record", Kexi::WindowActionCategory,
1101 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1102
1103 //skipped - internal:
1104 acat->addAction("tablepart_create", Kexi::NoActionCategory);
1105 acat->addAction("querypart_create", Kexi::NoActionCategory);
1106 acat->addAction("formpart_create", Kexi::NoActionCategory);
1107 acat->addAction("reportpart_create", Kexi::NoActionCategory);
1108 acat->addAction("macropart_create", Kexi::NoActionCategory);
1109 acat->addAction("scriptpart_create", Kexi::NoActionCategory);
1110}
1111
1117
1119{
1120 //TODO: enabling is more complex...
1121/* d->action_edit_cut->setEnabled(true);
1122 d->action_edit_copy->setEnabled(true);
1123 d->action_edit_paste->setEnabled(true);*/
1124
1125 if (!o)
1126 o = focusWindow();
1128}
1129
1131{
1133}
1134
1135// unused, I think
1136void KexiMainWindowImpl::invalidateSharedActionsLater()
1137{
1138 TQTimer::singleShot(1, this, TQ_SLOT(invalidateSharedActions()));
1139}
1140
1142{
1143// stateChanged("project_opened",d->prj ? StateNoReverse : StateReverse);
1144
1145 const bool have_dialog = d->curDialog;
1146 const bool dialog_dirty = d->curDialog && d->curDialog->dirty();
1147 const bool readOnly = d->prj && d->prj->dbConnection() && d->prj->dbConnection()->isReadOnly();
1148
1149 //PROJECT MENU
1150 d->action_save->setEnabled(have_dialog && dialog_dirty && !readOnly);
1151 d->action_save_as->setEnabled(have_dialog && !readOnly);
1152 d->action_project_properties->setEnabled(d->prj);
1153 d->action_close->setEnabled(d->prj);
1154 d->action_project_relations->setEnabled(d->prj);
1155 if (d->action_project_import_data_table)
1156 d->action_project_import_data_table->setEnabled(d->prj && !readOnly);
1157 d->action_project_export_data_table->setEnabled(
1158 d->curDialog && d->curDialog->part()->info()->isDataExportSupported()
1159 && !d->curDialog->neverSaved() );
1160
1161 const bool printingActionsEnabled =
1162 d->curDialog && d->curDialog->part()->info()->isPrintingSupported()
1163 && !d->curDialog->neverSaved();
1164 d->action_project_print->setEnabled( printingActionsEnabled );
1165 d->action_project_print_preview->setEnabled( printingActionsEnabled );
1166 d->action_project_print_setup->setEnabled( printingActionsEnabled );
1167
1168 //EDIT MENU
1169
1170 if (d->action_edit_paste_special_data_table)
1171 d->action_edit_paste_special_data_table->setEnabled(d->prj && !readOnly);
1172
1175 if (d->curDialog && d->curDialog->currentViewMode()==Kexi::DataViewMode) {
1176 KexiPart::Info *activePartInfo = d->curDialog->part()->info();
1177 d->action_edit_copy_special_data_table->setEnabled(
1178 activePartInfo ? activePartInfo->isDataExportSupported() : false );
1179 }
1180 else
1181 d->action_edit_copy_special_data_table->setEnabled( false );
1182
1183 //VIEW MENU
1184 if (d->action_view_nav)
1185 d->action_view_nav->setEnabled(d->prj);
1186 d->action_view_mainarea->setEnabled(d->prj);
1187 if (d->action_view_propeditor)
1188 d->action_view_propeditor->setEnabled(d->prj);
1189 if (d->action_view_data_mode) {
1190 d->action_view_data_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::DataViewMode) );
1191 if (!d->action_view_data_mode->isEnabled())
1192 d->action_view_data_mode->setChecked(false);
1193 }
1194 if (d->action_view_design_mode) {
1195 d->action_view_design_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::DesignViewMode) );
1196 if (!d->action_view_design_mode->isEnabled())
1197 d->action_view_design_mode->setChecked(false);
1198 }
1199 if (d->action_view_text_mode) {
1200 d->action_view_text_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::TextViewMode) );
1201 if (!d->action_view_text_mode->isEnabled())
1202 d->action_view_text_mode->setChecked(false);
1203 }
1204#ifndef KEXI_NO_CTXT_HELP
1205 d->action_show_helper->setEnabled(d->prj);
1206#endif
1207
1208 //CREATE MENU
1209 if (d->createMenu)
1210 d->createMenu->setEnabled(d->prj);
1211
1212 // DATA MENU
1213 //d->action_data_execute->setEnabled( d->curDialog && d->curDialog->part()->info()->isExecuteSupported() );
1214
1215 //TOOLS MENU
1216 // "compact db" supported if there's no db or the current db supports compacting and is opened r/w:
1217 d->action_tools_compact_database->setEnabled(
1218 !d->prj || !readOnly && d->prj && d->prj->dbConnection()
1219 && (d->prj->dbConnection()->driver()->features() & KexiDB::Driver::CompactingDatabaseSupported) );
1220
1221 //WINDOW MENU
1222 if (d->action_window_next) {
1223 d->action_window_next->setEnabled(!m_pDocumentViews->isEmpty());
1224 d->action_window_previous->setEnabled(!m_pDocumentViews->isEmpty());
1225 }
1226
1227 //DOCKS
1228 if (d->nav)
1229 d->nav->setEnabled(d->prj);
1230 if (d->propEditor)
1231 d->propEditorTabWidget->setEnabled(d->prj);
1232}
1233
1235{
1236 if (d->curDialog) {
1237 //update toggle action
1238 if (d->curDialog->currentViewMode()==Kexi::DataViewMode) {
1239 if (d->action_view_data_mode)
1240 d->action_view_data_mode->setChecked( true );
1241 }
1242 else if (d->curDialog->currentViewMode()==Kexi::DesignViewMode) {
1243 if (d->action_view_design_mode)
1244 d->action_view_design_mode->setChecked( true );
1245 }
1246 else if (d->curDialog->currentViewMode()==Kexi::TextViewMode) {
1247 if (d->action_view_text_mode)
1248 d->action_view_text_mode->setChecked( true );
1249 }
1250 }
1251}
1252
1254{
1255 switch (Kexi::startupHandler().action()) {
1256 case KexiStartupHandler::CreateBlankProject:
1257 if (d->propEditor)
1258 makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1259 return createBlankProject();
1260 case KexiStartupHandler::CreateFromTemplate:
1261 return createProjectFromTemplate(*Kexi::startupHandler().projectData());
1262 case KexiStartupHandler::OpenProject:
1263 return openProject(*Kexi::startupHandler().projectData());
1264 case KexiStartupHandler::ImportProject:
1266 Kexi::startupHandler().importActionData().mimeType,
1267 Kexi::startupHandler().importActionData().fileName
1268 );
1269 default:;
1270 if (d->propEditor)
1271 makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1272 }
1273 return true;
1274}
1275
1276static TQString internalReason(KexiDB::Object *obj)
1277{
1278 const TQString &s = obj->errorMsg();
1279 if (s.isEmpty())
1280 return s;
1281 return TQString("<br>(%1) ").arg(i18n("reason:")+" <i>"+s+"</i>");
1282}
1283
1285{
1286 KexiProjectData *newProjectData = new KexiProjectData(projectData);
1287// if (userMode()) {
1288 //TODO: maybe also auto allow to open objects...
1289// return initUserModeMode(newProjectData);
1290// }
1291 createKexiProject( newProjectData );
1292 if (!newProjectData->connectionData()->savePassword
1293 && newProjectData->connectionData()->password.isEmpty()
1294 && newProjectData->connectionData()->fileName().isEmpty()
1295 )
1296 {
1297 //ask for password
1298 KexiDBPasswordDialog pwdDlg(this, *newProjectData->connectionData(),
1299 false );
1300 if (TQDialog::Accepted!=pwdDlg.exec()) {
1301 delete d->prj;
1302 d->prj = 0;
1303 return cancelled;
1304 }
1305 }
1306 bool incompatibleWithKexi;
1307 tristate res = d->prj->open(incompatibleWithKexi);
1308 if (~res) {
1309 delete d->prj;
1310 d->prj = 0;
1311 return cancelled;
1312 }
1313 else if (!res) {
1314 delete d->prj;
1315 d->prj = 0;
1316 if (incompatibleWithKexi) {
1317 if (KMessageBox::Yes == KMessageBox::questionYesNo(this,
1318 i18n("<qt>Database project %1 does not appear to have been created using Kexi.<br><br>"
1319 "Do you want to import it as a new Kexi project?</qt>").arg(projectData.infoString()),
1320 0, KGuiItem(i18n("Import Database", "&Import..."), "database_import"),
1321 KStdGuiItem::quit()))
1322 {
1323 const bool anotherProjectAlreadyOpened = d->prj;
1324 tristate res = showProjectMigrationWizard("application/x-kexi-connectiondata",
1325 projectData.databaseName(), projectData.constConnectionData());
1326
1327 if (!anotherProjectAlreadyOpened) //the project could have been opened within this instance
1328 return res;
1329
1330 //always return cancelled because even if migration succeeded, new Kexi instance
1331 //will be started if user wanted to open the imported db
1332 return cancelled;
1333 }
1334 return cancelled;
1335 }
1336 return false;
1337 }
1338 initNavigator();
1339 Kexi::recentProjects().addProjectData( newProjectData );
1342// d->disableErrorMessages = true;
1343 enableMessages( false );
1344
1345 TQTimer::singleShot(1, this, TQ_SLOT(slotAutoOpenObjectsLater()));
1346 return true;
1347}
1348
1350{
1351 TQStringList mimetypes;
1353 TQString fname;
1354 const TQString startDir(":OpenExistingOrCreateNewProject"/*as in KexiNewProjectWizard*/);
1355 const TQString caption( i18n("Select New Project's Location") );
1356
1357 while (true) {
1358#ifdef TQ_WS_WIN
1360 TQString recentDir = TDEGlobalSettings::documentPath();
1361 if (fname.isEmpty() && !projectData.constConnectionData()->dbFileName().isEmpty()) //propose filename from db template name
1362 fname = KFileDialog::getStartURL(startDir, recentDir).path()
1363 + '/' + projectData.constConnectionData()->dbFileName();
1364 fname = TQFileDialog::getSaveFileName(
1365 KFileDialog::getStartURL(fname.isEmpty() ? startDir : fname, recentDir).path(),
1366 KexiUtils::fileDialogFilterStrings(mimetypes, false),
1367 this, "CreateProjectFromTemplate", caption);
1368 if ( !fname.isEmpty() ) {
1369 //save last visited path
1370 KURL url;
1371 url.setPath( fname );
1372 if (url.isLocalFile())
1373 TDERecentDirs::add(startDir, url.directory());
1374 }
1375#else
1376 Q_UNUSED(projectData);
1377 if (fname.isEmpty() &&
1378 !projectData.constConnectionData()->dbFileName().isEmpty())
1379 {
1380 //propose filename from db template name
1381 fname = projectData.constConnectionData()->dbFileName();
1382 }
1383 const bool specialDir = fname.isEmpty();
1384 kdDebug() << fname << "............." << endl;
1385 KFileDialog dlg( specialDir ? startDir : TQString(),
1386 mimetypes.join(" "), this, "filedialog", true);
1387 if ( !specialDir )
1388 dlg.setSelection( fname ); // may also be a filename
1389 dlg.setOperationMode( KFileDialog::Saving );
1390 dlg.setCaption( caption );
1391 dlg.exec();
1392 fname = dlg.selectedFile();
1393 if (!fname.isEmpty())
1394 TDERecentDocument::add(fname);
1395// fname = KFileDialog::getSaveFileName(fname.isEmpty() ? startDir : fname,
1396 // mimetypes.join(" "), this, caption);
1397#endif
1398 if ( fname.isEmpty() )
1399 return cancelled;
1401 break;
1402 }
1403
1404 if (KexiUtils::CopySuccess != KexiUtils::copyFile(
1405 projectData.constConnectionData()->fileName(), fname ))
1406 {
1407 return false;
1408 }
1409
1410 return openProject(fname, 0, TQString(), projectData.autoopenObjects/*copy*/);
1411}
1412
1414{
1415 const bool readOnly = d->prj && d->prj->dbConnection() && d->prj->dbConnection()->isReadOnly();
1416 d->statusBar->setReadOnlyFlag( readOnly );
1417 if (d->nav)
1418 d->nav->setReadOnly(readOnly);
1419 // update "insert ....." actions for every part
1420 TDEActionCollection *ac = actionCollection();
1421 for (KexiPart::PartInfoListIterator it(*Kexi::partManager().partInfoList()); it.current(); ++it) {
1422 TDEAction *a = ac->action( TQString(KexiPart::nameForCreateAction( *it.current() )).ascii() );
1423 if (a)
1424 a->setEnabled(!readOnly);
1425 }
1426}
1427
1429{
1430 TQString not_found_msg;
1431 bool openingCancelled;
1432 //ok, now open "autoopen: objects
1433 if (d->prj) {
1434 for (TQValueList<KexiProjectData::ObjectInfo>::ConstIterator it =
1435 d->prj->data()->autoopenObjects.constBegin();
1436 it != d->prj->data()->autoopenObjects.constEnd(); ++it )
1437 {
1438 KexiProjectData::ObjectInfo info = *it;
1440 TQCString("kexi/")+info["type"].lower().latin1() );
1441 if (!i) {
1442 not_found_msg += "<li>";
1443 if (!info["name"].isEmpty())
1444 not_found_msg += (TQString("\"") + info["name"] + "\" - ");
1445 if (info["action"]=="new")
1446 not_found_msg += i18n("cannot create object - unknown object type \"%1\"")
1447 .arg(info["type"]);
1448 else
1449 not_found_msg += i18n("unknown object type \"%1\"").arg(info["type"]);
1450 not_found_msg += internalReason(&Kexi::partManager())+"<br></li>";
1451 continue;
1452 }
1453 // * NEW
1454 if (info["action"]=="new") {
1455 if (!newObject( i, openingCancelled) && !openingCancelled) {
1456 not_found_msg += "<li>";
1457 not_found_msg += (i18n("cannot create object of type \"%1\"").arg(info["type"])+
1458 internalReason(d->prj)+"<br></li>");
1459 }
1460 else
1461 d->wasAutoOpen = true;
1462 continue;
1463 }
1464
1465 KexiPart::Item *item = d->prj->item(i, info["name"]);
1466
1467 if (!item) {
1468 TQString taskName;
1469 if (info["action"]=="print-preview")
1470 taskName = i18n("making print preview for");
1471 else if (info["action"]=="print")
1472 taskName = i18n("printing");
1473 else if (info["action"]=="execute")
1474 taskName = i18n("\"executing object\" action", "executing");
1475 else
1476 taskName = i18n("opening");
1477
1478 not_found_msg += (TQString("<li>")+ taskName + " \"" + info["name"] + "\" - ");
1479 if ("table"==info["type"].lower())
1480 not_found_msg += i18n("table not found");
1481 else if ("query"==info["type"].lower())
1482 not_found_msg += i18n("query not found");
1483 else if ("macro"==info["type"].lower())
1484 not_found_msg += i18n("macro not found");
1485 else if ("script"==info["type"].lower())
1486 not_found_msg += i18n("script not found");
1487 else
1488 not_found_msg += i18n("object not found");
1489 not_found_msg += (internalReason(d->prj)+"<br></li>");
1490 continue;
1491 }
1492 // * EXECUTE, PRINT, PRINT PREVIEW
1493 if (info["action"]=="execute") {
1494 tristate res = executeItem(item);
1495 if (false == res) {
1496 not_found_msg += ( TQString("<li>\"")+ info["name"] + "\" - " + i18n("cannot execute object")+
1497 internalReason(d->prj)+"<br></li>" );
1498 }
1499 continue;
1500 }
1501 else if (info["action"]=="print") {
1502 tristate res = printItem(item);
1503 if (false == res) {
1504 not_found_msg += ( TQString("<li>\"")+ info["name"] + "\" - " + i18n("cannot print object")+
1505 internalReason(d->prj)+"<br></li>" );
1506 }
1507 continue;
1508 }
1509 else if (info["action"]=="print-preview") {
1510 tristate res = printPreviewForItem(item);
1511 if (false == res) {
1512 not_found_msg += ( TQString("<li>\"")+ info["name"] + "\" - " + i18n("cannot make print preview of object")+
1513 internalReason(d->prj)+"<br></li>" );
1514 }
1515 continue;
1516 }
1517
1518 int viewMode;
1519 if (info["action"]=="open")
1520 viewMode = Kexi::DataViewMode;
1521 else if (info["action"]=="design")
1522 viewMode = Kexi::DesignViewMode;
1523 else if (info["action"]=="edittext")
1524 viewMode = Kexi::TextViewMode;
1525 else
1526 continue; //sanity
1527
1528 TQString openObjectMessage;
1529 if (!openObject(item, viewMode, openingCancelled, 0, &openObjectMessage)
1530 && (!openingCancelled || !openObjectMessage.isEmpty()))
1531 {
1532 not_found_msg += (TQString("<li>\"")+ info["name"] + "\" - ");
1533 if (openObjectMessage.isEmpty())
1534 not_found_msg += i18n("cannot open object");
1535 else
1536 not_found_msg += openObjectMessage;
1537 not_found_msg += internalReason(d->prj) + "<br></li>";
1538 continue;
1539 }
1540 else {
1541 d->wasAutoOpen = true;
1542 }
1543 }
1544 }
1545 enableMessages( true );
1546// d->disableErrorMessages = false;
1547
1548 if (!not_found_msg.isEmpty())
1549 showErrorMessage(i18n("You have requested selected objects to be automatically opened "
1550 "or processed on startup. Several objects cannot be opened or processed."),
1551 TQString("<ul>%1</ul>").arg(not_found_msg) );
1552
1553 d->updatePropEditorVisibility(d->curDialog ? d->curDialog->currentViewMode() : 0);
1554#if defined(KDOCKWIDGET_P)
1555 if (d->propEditor) {
1556 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1557 KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
1558 if(ds)
1559 ds->setSeparatorPosInPercent(d->config->readNumEntry("RightDockPosition", 80/* % */));
1560 }
1561#endif
1562
1564
1565// d->navToolWindow->wrapperWidget()->setFixedWidth(200);
1566//js TODO: make visible FOR OTHER MODES if needed
1567 if (mdiMode()==KMdi::ChildframeMode || mdiMode()==KMdi::TabPageMode) {
1568 //make docks visible again
1569 if (!d->navToolWindow->wrapperWidget()->isVisible())
1570 static_cast<KDockWidget*>(d->navToolWindow->wrapperWidget())->makeDockVisible();
1571// if (!d->propEditorToolWindow->wrapperWidget()->isVisible())
1572// static_cast<KDockWidget*>(d->propEditorToolWindow->wrapperWidget())->makeDockVisible();
1573 }
1574
1575 // if (!d->prj->data()->autoopenObjects.isEmpty())
1576 d->restoreNavigatorWidth();
1577
1578#ifndef PROPEDITOR_VISIBILITY_CHANGES
1579// KDockWidget *dw = (KDockWidget *)d->nav->parentWidget();
1580// KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
1581// const int pos = ds->separatorPos();
1582
1583 //if (!d->curDialog || d->curDialog->currentViewMode()==Kexi::DataViewMode)
1584// d->propEditorToolWindow->hide();
1585
1586// ds->setSeparatorPos( pos, true );
1587#endif
1588 if (d->nav) {
1589 d->nav->updateGeometry();
1590 }
1591 tqApp->processEvents();
1592 emit projectOpened();
1593}
1594
1596{
1597#ifndef KEXI_NO_PENDING_DIALOGS
1598 if (d->pendingDialogsExist()) {
1599 kdDebug() << "KexiMainWindowImpl::closeProject() pendingDialogsExist..." << endl;
1600 d->actionToExecuteWhenPendingJobsAreFinished = Private::CloseProjectAction;
1601 return cancelled;
1602 }
1603#endif
1604
1605 //only save nav. visibility setting is project is opened
1606 d->saveSettingsForShowProjectNavigator = d->prj && d->isProjectNavigatorVisible;
1607
1608 if (!d->prj)
1609 return true;
1610
1611 {
1612 // make sure the project can be closed
1613 bool cancel = false;
1614 emit acceptProjectClosingRequested(cancel);
1615 if (cancel)
1616 return cancelled;
1617 }
1618
1619 d->dialogExistedBeforeCloseProject = !d->curDialog.isNull();
1620
1621#if defined(KDOCKWIDGET_P)
1622 //remember docks position - will be used on storeSettings()
1623 if (d->propEditor) {
1624 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1625 KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
1626 if (ds)
1627 d->propEditorDockSeparatorPos = ds->separatorPosInPercent();
1628 }
1629 if (d->nav) {
1630// makeDockInvisible( manager()->findWidgetParentDock(d->propEditor) );
1631
1632 if (d->propEditor) {
1633 if (d->openedDialogsCount() == 0)
1634 makeWidgetDockVisible(d->propEditorTabWidget);
1635 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1636 KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
1637 if(ds)
1639 }
1640
1641 KDockWidget *dw = (KDockWidget *)d->nav->parentWidget();
1642 KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
1643 int dwWidth = dw->width();
1644 if (ds) {
1645 if (d->openedDialogsCount()!=0 && d->propEditorTabWidget && d->propEditorTabWidget->isVisible())
1646 d->navDockSeparatorPos = ds->separatorPosInPercent();
1647 else
1648 d->navDockSeparatorPos = (100 * dwWidth) / width();
1649
1650// int navDockSeparatorPosWithAutoOpen = (100 * dw->width()) / width() + 4;
1651// d->navDockSeparatorPos = (100 * dw->width()) / width() + 1;
1652 }
1653 }
1654#endif
1655
1656 //close each window, optionally asking if user wants to close (if data changed)
1657 while (!d->curDialog.isNull()) {
1658 tristate res = closeDialog( d->curDialog );
1659 if (!res || ~res)
1660 return res;
1661 }
1662
1663 // now we will close for sure
1664 emit beforeProjectClosing();
1665
1666 if (!d->prj->closeConnection())
1667 return false;
1668
1669 if(d->nav)
1670 {
1671 d->navWasVisibleBeforeProjectClosing = manager()->findWidgetParentDock(d->nav)->isVisible();
1672 d->nav->clear();
1673#if 0 //do not confuse users
1674 d->navToolWindow->hide();
1675#endif
1676 }
1677
1678 if (d->propEditor)
1679 makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1680
1681// if(d->propEditorToolWindow)
1682 // d->propEditorToolWindow->hide();
1683
1684 d->clearDialogs(); //sanity!
1685 delete d->prj;
1686 d->prj=0;
1687
1688// Kexi::partManager().unloadAllParts();
1689
1692// if (!userMode())
1694
1695 emit projectClosed();
1696 return true;
1697}
1698
1699void KexiMainWindowImpl::initContextHelp() {
1700#ifndef KEXI_NO_CTXT_HELP
1701 d->ctxHelp=new KexiContextHelp(this,this);
1702/*todo
1703 d->ctxHelp->setContextHelp(i18n("Welcome"),i18n("The <B>KEXI team</B> wishes you a lot of productive work, "
1704 "with this product. <BR><HR><BR>If you have found a <B>bug</B> or have a <B>feature</B> request, please don't "
1705 "hesitate to report it at our <A href=\"http://www.kexi-project.org/cgi-bin/bug.pl\"> issue "
1706 "tracking system </A>.<BR><HR><BR>If you would like to <B>join</B> our effort, the <B>development</B> documentation "
1707 "at <A href=\"http://www.kexi-project.org\">www.kexi-project.org</A> is a good starting point."),0);
1708*/
1709 addToolWindow(d->ctxHelp,KDockWidget::DockBottom | KDockWidget::DockLeft,getMainDockWidget(),20);
1710#endif
1711}
1712
1714{
1715 if (!d->isProjectNavigatorVisible)
1716 return;
1717
1718 if(!d->nav)
1719 {
1720 d->nav = new KexiBrowser(this, this);
1721 d->nav->installEventFilter(this);
1722 d->navToolWindow = addToolWindow(d->nav, KDockWidget::DockLeft, getMainDockWidget(), 20/*, lv, 35, "2"*/);
1723// d->navToolWindow->hide();
1724
1725 connect(d->nav,TQ_SIGNAL(openItem(KexiPart::Item*,int)),this,TQ_SLOT(openObject(KexiPart::Item*,int)));
1726 connect(d->nav,TQ_SIGNAL(openOrActivateItem(KexiPart::Item*,int)),
1727 this,TQ_SLOT(openObjectFromNavigator(KexiPart::Item*,int)));
1728 connect(d->nav,TQ_SIGNAL(newItem( KexiPart::Info* )),
1729 this,TQ_SLOT(newObject(KexiPart::Info*)));
1730 connect(d->nav,TQ_SIGNAL(removeItem(KexiPart::Item*)),
1731 this,TQ_SLOT(removeObject(KexiPart::Item*)));
1732 connect(d->nav,TQ_SIGNAL(renameItem(KexiPart::Item*,const TQString&, bool&)),
1733 this,TQ_SLOT(renameObject(KexiPart::Item*,const TQString&, bool&)));
1734 connect(d->nav,TQ_SIGNAL(executeItem(KexiPart::Item*)),
1735 this,TQ_SLOT(executeItem(KexiPart::Item*)));
1736 connect(d->nav,TQ_SIGNAL(exportItemAsDataTable(KexiPart::Item*)),
1737 this,TQ_SLOT(exportItemAsDataTable(KexiPart::Item*)));
1738 connect(d->nav,TQ_SIGNAL(printItem( KexiPart::Item* )),
1739 this,TQ_SLOT(printItem(KexiPart::Item*)));
1740 connect(d->nav,TQ_SIGNAL(pageSetupForItem( KexiPart::Item*)),
1741 this,TQ_SLOT(showPageSetupForItem(KexiPart::Item*)));
1742 if (d->prj) {//connect to the project
1743 connect(d->prj, TQ_SIGNAL(itemRemoved(const KexiPart::Item&)),
1744 d->nav, TQ_SLOT(slotRemoveItem(const KexiPart::Item&)));
1745 }
1746 connect(d->nav,TQ_SIGNAL(selectionChanged(KexiPart::Item*)),
1748
1749// d->restoreNavigatorWidth();
1750 }
1751 if(d->prj->isConnected()) {
1752 TQString partManagerErrorMessages;
1753 d->nav->setProject( d->prj, TQString()/*all mimetypes*/, &partManagerErrorMessages );
1754 if (!partManagerErrorMessages.isEmpty()) {
1755 showWarningContinueMessage(partManagerErrorMessages, TQString(),
1756 "dontShowWarningsRelatedToPluginsLoading");
1757 }
1758 }
1759 connect(d->prj, TQ_SIGNAL(newItemStored(KexiPart::Item&)), d->nav, TQ_SLOT(addItem(KexiPart::Item&)));
1760 d->nav->setFocus();
1761
1762 if (d->forceShowProjectNavigatorOnCreation) {
1763 slotViewNavigator();
1764 d->forceShowProjectNavigatorOnCreation = false;
1765 }
1766 else if (d->forceHideProjectNavigatorOnCreation) {
1767 d->navToolWindow->hide();
1768// makeDockInvisible( manager()->findWidgetParentDock(d->nav) );
1769 d->forceHideProjectNavigatorOnCreation = false;
1770 }
1771
1773}
1774
1776{
1777#if defined(KDOCKWIDGET_P)
1778 if (mdiMode()==KMdi::ChildframeMode || mdiMode()==KMdi::TabPageMode) {
1779// KDockWidget *dw = (KDockWidget *)d->propEditor->parentWidget();
1780 //KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
1781// Q_UNUSED(ds);
1782//1 ds->resize(ds->width()*3, ds->height());
1783//1 ds->setSeparatorPos(30, true);
1784//1 ds->setForcedFixedWidth( dw, 200 );
1785 }
1786#endif
1787#ifdef TQ_WS_WIN
1788 showMaximized();//js: workaround for not yet completed layout settings storage on win32
1789#endif
1790}
1791
1792void KexiMainWindowImpl::initPropertyEditor()
1793{
1794 if (!d->propEditor) {
1795//TODO: FIX LAYOUT PROBLEMS
1796 d->propEditorTabWidget = new KTabWidget(this);
1797 d->propEditorTabWidget->hide();
1798 d->propEditor = new KexiPropertyEditorView(this, d->propEditorTabWidget);
1799 d->propEditorTabWidget->setCaption(d->propEditor->caption());
1800 d->propEditorTabWidget->addTab(d->propEditor, i18n("Properties"));
1801 d->propEditor->installEventFilter(this);
1802 d->propEditorToolWindow = addToolWindow(d->propEditorTabWidget,
1803 KDockWidget::DockRight, getMainDockWidget(), 20);
1804
1805 d->config->setGroup("PropertyEditor");
1806 int size = d->config->readNumEntry("FontSize", -1);
1807 TQFont f( Kexi::smallFont() );
1808 if (size>0)
1809 f.setPixelSize( size );
1810 d->propEditorTabWidget->setFont(f);
1811
1812 if (mdiMode()==KMdi::ChildframeMode || mdiMode()==KMdi::TabPageMode) {
1813 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1814 #if defined(KDOCKWIDGET_P)
1815 KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
1816// ds->setKeepSize(true);
1817 makeWidgetDockVisible(d->propEditorTabWidget);
1818 // ds->show();
1819 // ds->resize(400, ds->height());
1820 // ds->setSeparatorPos(400, true);
1821 // ds->setForcedFixedWidth( dw, 400 );
1822 // ds->setSeparatorPos(600, true);
1823
1824
1825 d->config->setGroup("MainWindow");
1826 ds->setSeparatorPosInPercent(d->config->readNumEntry("RightDockPosition", 80/* % */));
1827// makeDockInvisible( manager()->findWidgetParentDock(d->propEditor) );
1828
1829 // ds->setForcedFixedWidth( dw, d->config->readNumEntry("RightDockPosition", 80) );
1830 // ds->resize(400, ds->height());
1831 // dw->resize(400, dw->height());
1832 #endif
1833
1834 //1 dw->setMinimumWidth(200);
1835
1836 // ds->setSeparatorPos(d->propEditor->sizeHint().width(), true);
1837
1838 //heh, this is for IDEAl only, I suppose?
1839 //js if (m_rightContainer) {
1840 //js m_rightContainer->setForcedFixedWidth( 400 );
1841 //js }
1842 }
1843
1844 // int w = d->propEditor->width();
1845 /* KMdiToolViewAccessor *tmp=createToolWindow();
1846 tmp->setWidgetToWrap(d->propEditor);
1847 d->propEditor->show(); // I'm not sure, if this is a bug in kdockwidget, which I would better fix there
1848 tmp->show(KDockWidget::DockRight,getMainDockWidget(),20);
1849 */
1850 }
1851// makeDockInvisible(manager()->findWidgetParentDock(d->propEditorTabWidget));
1852}
1853
1854void KexiMainWindowImpl::slotPartLoaded(KexiPart::Part* p)
1855{
1856 if (!p)
1857 return;
1858 connect(p, TQ_SIGNAL(newObjectRequest(KexiPart::Info*)),
1859 this, TQ_SLOT(newObject(KexiPart::Info*)));
1860 p->createGUIClients(this);
1861}
1862
1865{
1866 //js todo: allow to set custom "static" app caption
1867
1868 KMdiChildView *view = 0L;
1869 if (!d->curDialog)
1870 view = 0;
1871 else if (d->curDialog->isAttached()) {
1872 view = d->curDialog;
1873 } else {
1874 //current dialog isn't attached! - find top level child
1875 if (m_pMdi->topChild()) {
1876 view = m_pMdi->topChild()->m_pClient;
1877 childrenMaximized = view->mdiParent()->state()==KMdiChildFrm::Maximized;
1878 }
1879 else
1880 view = 0;
1881 }
1882
1883 if (childrenMaximized && view) {
1884 setCaption( d->curDialog->caption()
1885 + (d->appCaptionPrefix.isEmpty() ? TQString() : (TQString::fromLatin1(" - ") + d->appCaptionPrefix)) );
1886 }
1887 else {
1888 setCaption( (d->appCaptionPrefix.isEmpty() ? TQString() : (d->appCaptionPrefix + TQString::fromLatin1(" - ")))
1889 + d->origAppCaption );
1890 }
1891}
1892
1894{
1895 //js todo: allow to set custom "static" app caption
1896
1897 d->appCaptionPrefix = "";
1898 if (d->prj && d->prj->data()) {//add project name
1899 d->appCaptionPrefix = d->prj->data()->caption();
1900 if (d->appCaptionPrefix.isEmpty())
1901 d->appCaptionPrefix = d->prj->data()->databaseName();
1902 }
1903// if (!d->appCaptionPrefix.isEmpty())
1904// d->appCaptionPrefix = d->appCaptionPrefix;
1905
1906 bool max = false;
1907 if (d->curDialog && d->curDialog->mdiParent())
1908 max = d->curDialog->mdiParent()->state()==KMdiChildFrm::Maximized;
1909
1911/*
1912 KMdiChildView *view;
1913 if (!d->curDialog)
1914 view = 0;
1915 else if (d->curDialog->isAttached()) {
1916 view = d->curDialog;
1917 } else {
1918 //current dialog isn't attached! - find top level child
1919 if (m_pMdi->topChild()) {
1920 view = m_pMdi->topChild()->m_pClient;
1921 }
1922 else
1923 view = 0;
1924 }
1925
1926 kApp->setCaption( d->appCaption );
1927 if (view && view->mdiParent()->state()==KMdiChildFrm::Maximized) {
1928 setCaption( view->caption() );
1929 }
1930 else {
1931 setCaption( d->appCaption );
1932 }*/
1933}
1934
1935void KexiMainWindowImpl::slotNoMaximizedChildFrmLeft(KMdiChildFrm*)
1936{
1938}
1939
1940void KexiMainWindowImpl::slotLastChildViewClosed() //slotLastChildFrmClosed()
1941{
1942 if (m_pDocumentViews->count()>0) //a fix for KMDI bug (will be fixed in KDE 3.4)
1943 return;
1944
1947
1948//js: too WEIRD if (d->propEditor)
1949//js: too WEIRD makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1950// if (d->propEditorToolWindow)
1951 // d->propEditorToolWindow->hide();
1952}
1953
1954void KexiMainWindowImpl::slotChildViewIsDetachedNow(TQWidget*)
1955{
1957}
1958
1959/*void
1960KexiMainWindowImpl::closeEvent(TQCloseEvent *ev)
1961{
1962 storeSettings();
1963
1964 bool cancelled = false;
1965 if (!closeProject(cancelled)) {
1966 //todo: error message
1967 return;
1968 }
1969 if (cancelled) {
1970 ev->ignore();
1971 return;
1972 }
1973
1974 ev->accept();
1975}*/
1976
1977bool
1978KexiMainWindowImpl::queryClose()
1979{
1980#ifndef KEXI_NO_PENDING_DIALOGS
1981 if (d->pendingDialogsExist()) {
1982 kdDebug() << "KexiMainWindowImpl::queryClose() pendingDialogsExist..." << endl;
1983 d->actionToExecuteWhenPendingJobsAreFinished = Private::QuitAction;
1984 return false;
1985 }
1986#endif
1987// storeSettings();
1988 const tristate res = closeProject();
1989 if (~res)
1990 return false;
1991
1992 if (res==true)
1993 storeSettings();
1994
1995 return ! ~res;
1996}
1997
1998bool
1999KexiMainWindowImpl::queryExit()
2000{
2001// storeSettings();
2002 return true;
2003}
2004
2005void
2007{
2008 d->config->setGroup("MainWindow");
2009
2010 // Saved settings
2011 applyMainWindowSettings( d->config, "MainWindow" );
2012
2013 //small hack - set the default -- bottom
2014// d->config->setGroup(TQString(name()) + " KMdiTaskBar Toolbar style");
2015 d->config->setGroup("MainWindow Toolbar KMdiTaskBar");
2016 const bool tbe = d->config->readEntry("Position").isEmpty();
2017 if (tbe || d->config->readEntry("Position")=="Bottom") {
2018 if (tbe)
2019 d->config->writeEntry("Position","Bottom");
2020 moveDockWindow(m_pTaskBar, DockBottom);
2021 }
2022
2023 d->config->setGroup("MainWindow");
2024 int mdimode = d->config->readNumEntry("MDIMode", -1);//KMdi::TabPageMode);
2025
2026 const bool showProjectNavigator = d->config->readBoolEntry("ShowProjectNavigator", true);
2027
2028 switch(mdimode)
2029 {
2030/* case KMdi::ToplevelMode:
2031 switchToToplevelMode();
2032 m_pTaskBar->switchOn(true);
2033 break;*/
2034 case KMdi::ChildframeMode:
2035 switchToChildframeMode(false);
2036 m_pTaskBar->switchOn(true);
2037
2038 // restore a possible maximized Childframe mode,
2039 // will be used in KexiMainWindowImpl::addWindow()
2040 d->maximizeFirstOpenedChildFrm = d->config->readBoolEntry("maximized childframes", true);
2041 setEnableMaximizedChildFrmMode(d->maximizeFirstOpenedChildFrm);
2042
2043 if (!showProjectNavigator) {
2044 //it's visible by default but we want to hide it on navigator creation
2045 d->forceHideProjectNavigatorOnCreation = true;
2046 }
2047
2048 break;
2049
2050#define DEFAULT_MDI_MODE KMdi::IDEAlMode
2051
2052 case DEFAULT_MDI_MODE:
2053 default:
2054 switchToIDEAlMode(false);
2055 if (showProjectNavigator) {
2056 //it's invisible by default but we want to show it on navigator creation
2057 d->forceShowProjectNavigatorOnCreation = true;
2058 }
2059 break;
2060/* case KMdi::TabPageMode:
2061 switchToTabPageMode();
2062 break;
2063*/
2064 }
2065
2066#if 0
2067 if ( !initialGeometrySet() ) {
2068 // Default size
2069// int restoredWidth, restoredHeight;
2070 int scnum = TQApplication::desktop()->screenNumber(parentWidget());
2071 TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
2072// restoredWidth = TDEGlobalSettings::screenGeometry(scnum).width();
2073 // restoredHeight = TDEGlobalSettings::screenGeometry(scnum).height();
2074/* if (restoredWidth > 1100) {// very big desktop ?
2075 restoredWidth = 1000;
2076 restoredHeight = 800;
2077 }
2078 if (restoredWidth > 850) {// big desktop ?
2079 restoredWidth = 800;
2080 restoredHeight = 600;
2081 }
2082 else {// small (800x600, 640x480) desktop
2083 restoredWidth = TQMIN( restoredWidth, 600 );
2084 restoredHeight = TQMIN( restoredHeight, 400 );
2085 }*/
2086
2087 config->setGroup("MainWindow");
2088 TQSize s ( config->readNumEntry( TQString::fromLatin1("Width %1").arg(desk.width()), 700 ),
2089 config->readNumEntry( TQString::fromLatin1("Height %1").arg(desk.height()), 480 ) );
2090 resize (kMin (s.width(), desk.width()), kMin(s.height(), desk.height()));
2091 }
2092#endif
2093}
2094
2095void
2097{
2098 kdDebug() << "KexiMainWindowImpl::storeSettings()" << endl;
2099
2100// saveWindowSize( d->config ); //instance()->config() );
2101 saveMainWindowSettings( d->config, "MainWindow" );
2102 d->config->setGroup("MainWindow");
2103 KMdi::MdiMode modeToSave = mdiMode();
2104 if (d->mdiModeToSwitchAfterRestart!=(KMdi::MdiMode)0)
2105 modeToSave = d->mdiModeToSwitchAfterRestart;
2106 if (modeToSave == DEFAULT_MDI_MODE)
2107 d->config->deleteEntry("MDIMode");
2108 else
2109 d->config->writeEntry("MDIMode", modeToSave);
2110 d->config->writeEntry("maximized childframes", isInMaximizedChildFrmMode());
2111
2112// if (manager()->findWidgetParentDock(d->nav)->isVisible())
2113 if (d->saveSettingsForShowProjectNavigator) {
2114 if (d->navWasVisibleBeforeProjectClosing)
2115 d->config->deleteEntry("ShowProjectNavigator");
2116 else
2117 d->config->writeEntry("ShowProjectNavigator", false);
2118 }
2119
2120 if (modeToSave==KMdi::ChildframeMode || modeToSave==KMdi::TabPageMode) {
2121 if (d->propEditor && d->propEditorDockSeparatorPos >= 0 && d->propEditorDockSeparatorPos <= 100) {
2122 d->config->setGroup("MainWindow");
2123 d->config->writeEntry("RightDockPosition", d->propEditorDockSeparatorPos);
2124 }
2125 else
2126 d->propEditorDockSeparatorPos = 80;
2127 if (d->nav && d->navDockSeparatorPos >= 0 && d->navDockSeparatorPos <= 100) {
2128 d->config->setGroup("MainWindow");
2129 //KDockWidget *dw = (KDockWidget *)d->nav->parentWidget();
2130 //int w = dw->width();
2131 //int ww = width();
2132 //int d1 = (100 * dw->width()) / width() + 1;
2133 //KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
2134 //int d2 = ds->separatorPosInPercent();
2135 if (d->wasAutoOpen && d->dialogExistedBeforeCloseProject) {
2136#ifdef TQ_WS_WIN
2137 d->config->writeEntry("LeftDockPositionWithAutoOpen",
2138 d->navDockSeparatorPos);
2139#endif
2140// d->config->writeEntry("LeftDockPosition", dw->width());
2141// d->config->writeEntry("LeftDockPosition", d->nav->width());
2142 } else {
2143#ifdef TQ_WS_WIN
2144 if (d->dialogExistedBeforeCloseProject)
2145 d->config->writeEntry("LeftDockPosition", d->navDockSeparatorPos);
2146 else
2147 d->config->writeEntry("LeftDockPosition", tqRound(double(d->navDockSeparatorPos) / 0.77
2148 / (double(d->propEditorDockSeparatorPos) / 80) ));
2149#endif
2150 }
2151 }
2152 }
2153
2154 if (d->propEditor) {
2155 d->config->setGroup("PropertyEditor");
2156 d->config->writeEntry("FontSize", d->propEditorTabWidget->font().pixelSize());
2157 }
2158}
2159
2160void
2161KexiMainWindowImpl::restoreWindowConfiguration(TDEConfig *config)
2162{
2163 kdDebug()<<"preparing session restoring"<<endl;
2164
2165 config->setGroup("MainWindow");
2166
2167 TQString dockGrp;
2168
2169 if (kapp->isRestored())
2170 dockGrp=config->group()+"-Docking";
2171 else
2172 dockGrp="MainWindow0-Docking";
2173
2174 if (config->hasGroup(dockGrp))
2175 readDockConfig(config,dockGrp);
2176}
2177
2178void
2179KexiMainWindowImpl::storeWindowConfiguration(TDEConfig *config)
2180{
2181 kdDebug()<<"preparing session saving"<<endl;
2182 config->setGroup("MainWindow");
2183 TQString dockGrp;
2184
2185#if !defined(TQ_WS_WIN)
2186 if (kapp->sessionSaving())
2187 dockGrp=config->group()+"-Docking";
2188 else
2189#endif
2190 dockGrp="MainWindow0-Docking";
2191
2192 kdDebug()<<"Before write dock config"<<endl;
2193 writeDockConfig(config,dockGrp);
2194 kdDebug()<<"After write dock config"<<endl;
2195}
2196
2197void
2199 restoreWindowConfiguration(config);
2200}
2201
2202void
2203KexiMainWindowImpl::saveProperties(TDEConfig *config)
2204{
2205 storeWindowConfiguration(config);
2206// m_docManager->saveDocumentList (config);
2207 // m_projectManager->saveProjectList (config);
2208}
2209
2210void
2211KexiMainWindowImpl::saveGlobalProperties( TDEConfig* sessionConfig ) {
2212 storeWindowConfiguration(sessionConfig);
2213}
2214
2215void
2217{
2218 kdDebug() << "KexiMainWindowImpl::registerChild()" << endl;
2219 connect(dlg, TQ_SIGNAL(activated(KMdiChildView *)),
2220 this, TQ_SLOT(activeWindowChanged(KMdiChildView *)));
2221 connect(dlg, TQ_SIGNAL(dirtyChanged(KexiDialogBase*)),
2222 this, TQ_SLOT(slotDirtyFlagChanged(KexiDialogBase*)));
2223
2224// connect(dlg, TQ_SIGNAL(childWindowCloseRequest(KMdiChildView *)), this, TQ_SLOT(childClosed(KMdiChildView *)));
2225 if(dlg->id() != -1) {
2226 d->insertDialog(dlg);
2227 }
2228 kdDebug() << "KexiMainWindowImpl::registerChild() ID = " << dlg->id() << endl;
2229
2230 if (m_mdiMode==KMdi::ToplevelMode || m_mdiMode==KMdi::ChildframeMode) {//tdemdi fix
2231 //js TODO: check if taskbar is switched in menu
2232 if (m_pTaskBar && !m_pTaskBar->isSwitchedOn())
2233 m_pTaskBar->switchOn(true);
2234 }
2235 //KMdiChildFrm *frm = dlg->mdiParent();
2236 //if (frm) {
2237// dlg->setMargin(20);
2238 //dlg->setLineWidth(20);
2239 //}
2240}
2241
2242void
2244{
2245 if (viewClient!=d->curDialogViewGUIClient) {
2246 //view clients differ
2247 kdDebug()<<"KexiMainWindowImpl::activeWindowChanged(): old view gui client:"
2248 <<(d->curDialogViewGUIClient ? d->curDialogViewGUIClient->xmlFile() : "")
2249 <<" new view gui client: "<<( viewClient ? viewClient->xmlFile() : "") <<endl;
2250 if (d->curDialogViewGUIClient) {
2251 guiFactory()->removeClient(d->curDialogViewGUIClient);
2252 }
2253 if (viewClient) {
2254 if (d->closedDialogViewGUIClient) {
2255 //ooh, there is a client which dialog is already closed -- BUT it is the same client as our
2256 //so: give up
2257 }
2258 else {
2259 guiFactory()->addClient(viewClient);
2260 }
2261 }
2262 }
2263}
2264
2265void KexiMainWindowImpl::updateCustomPropertyPanelTabs(KexiDialogBase *prevDialog, int prevViewMode)
2266{
2268 prevDialog ? prevDialog->part() : 0,
2269 prevDialog ? prevDialog->currentViewMode() : prevViewMode,
2270 d->curDialog ? d->curDialog->part() : 0,
2271 d->curDialog ? d->curDialog->currentViewMode() : Kexi::NoViewMode
2272 );
2273}
2274
2276 KexiPart::Part *prevDialogPart, int prevViewMode, KexiPart::Part *curDialogPart, int curViewMode )
2277{
2278 if (!d->propEditorTabWidget)
2279 return;
2280
2281 if (!curDialogPart
2282 || (/*prevDialogPart &&*/ curDialogPart
2283 && (prevDialogPart!=curDialogPart || prevViewMode!=curViewMode)
2284 ))
2285 {
2286 if (d->partForPreviouslySetupPropertyPanelTabs) {
2287 //remember current page number for this part
2288 if (prevViewMode==Kexi::DesignViewMode &&
2289 ((KexiPart::Part*)d->partForPreviouslySetupPropertyPanelTabs != curDialogPart) //part changed
2290 || curViewMode!=Kexi::DesignViewMode) //..or switching to other view mode
2291 {
2292 d->recentlySelectedPropertyPanelPages.insert( d->partForPreviouslySetupPropertyPanelTabs,
2293 d->propEditorTabWidget->currentPageIndex() );
2294 }
2295 }
2296
2297 //delete old custom tabs (other than 'property' tab)
2298 const uint count = d->propEditorTabWidget->count();
2299 for (uint i=1; i < count; i++)
2300 d->propEditorTabWidget->removePage( d->propEditorTabWidget->page(1) );
2301 }
2302
2303 //don't change anything if part is not switched nor view mode changed
2304 if ((!prevDialogPart && !curDialogPart)
2305 || (prevDialogPart == curDialogPart && prevViewMode==curViewMode)
2306 || (curDialogPart && curViewMode!=Kexi::DesignViewMode))
2307 {
2308 //new part for 'previously setup tabs'
2309 d->partForPreviouslySetupPropertyPanelTabs = curDialogPart;
2310 return;
2311 }
2312
2313 if (curDialogPart) {
2314 //recreate custom tabs
2315 curDialogPart->setupCustomPropertyPanelTabs(d->propEditorTabWidget, this);
2316
2317 //restore current page number for this part
2318 if (d->recentlySelectedPropertyPanelPages.contains( curDialogPart )) {
2319 d->propEditorTabWidget->setCurrentPage(
2320 d->recentlySelectedPropertyPanelPages[ curDialogPart ]
2321 );
2322 }
2323 }
2324
2325 //new part for 'previously setup tabs'
2326 d->partForPreviouslySetupPropertyPanelTabs = curDialogPart;
2327}
2328
2330{
2331 KexiDialogBase *dlg = static_cast<KexiDialogBase *>(v);
2332 kdDebug() << "KexiMainWindowImpl::activeWindowChanged() to = " << (dlg ? dlg->caption() : "<none>") << endl;
2333
2334 KXMLGUIClient *client=0; //common for all views
2335 KXMLGUIClient *viewClient=0; //specific for current dialog's view
2336 KexiDialogBase* prevDialog = d->curDialog;
2337
2338 if (!dlg)
2339 client=0;
2340 else if ( dlg->isRegistered()) {
2341// client=dlg->guiClient();
2342 client=dlg->commonGUIClient();
2343 viewClient=dlg->guiClient();
2344 if (d->closedDialogGUIClient) {
2345 if (client!=d->closedDialogGUIClient) {
2346 //ooh, there is a client which dialog is already closed -- and we don't want it
2347 guiFactory()->removeClient(d->closedDialogGUIClient);
2348 d->closedDialogGUIClient=0;
2349 }
2350 }
2351 if (d->closedDialogViewGUIClient) {
2352 if (viewClient!=d->closedDialogViewGUIClient) {
2353 //ooh, there is a client which dialog is already closed -- and we don't want it
2354 guiFactory()->removeClient(d->closedDialogViewGUIClient);
2355 d->closedDialogViewGUIClient=0;
2356 }
2357 }
2358 if (client!=d->curDialogGUIClient) {
2359 //clients differ
2360 kdDebug()<<"KexiMainWindowImpl::activeWindowChanged(): old gui client:"
2361 <<(d->curDialogGUIClient ? d->curDialogGUIClient->xmlFile() : "")
2362 <<" new gui client: "<<( client ? client->xmlFile() : "") <<endl;
2363 if (d->curDialogGUIClient) {
2364 guiFactory()->removeClient(d->curDialogGUIClient);
2365 d->curDialog->detachFromGUIClient();
2366 }
2367 if (client) {
2368 if (d->closedDialogGUIClient) {
2369 //ooh, there is a client which dialog is already closed -- BUT it is the same client as our
2370 //so: give up
2371 }
2372 else {
2373 guiFactory()->addClient(client);
2374 }
2375 dlg->attachToGUIClient();
2376 }
2377 } else {
2378 //clients are the same
2379 if ((KexiDialogBase*)d->curDialog!=dlg) {
2380 if (d->curDialog)
2381 d->curDialog->detachFromGUIClient();
2382 if (dlg)
2383 dlg->attachToGUIClient();
2384 }
2385 }
2386 updateDialogViewGUIClient(viewClient);
2387/* if (viewClient!=d->curDialogViewGUIClient) {
2388 //view clients differ
2389 kdDebug()<<"KexiMainWindowImpl::activeWindowChanged(): old view gui client:"
2390 <<d->curDialogViewGUIClient<<" new view gui client: "<<viewClient<<endl;
2391 if (d->curDialogViewGUIClient) {
2392 guiFactory()->removeClient(d->curDialogViewGUIClient);
2393 }
2394 if (viewClient) {
2395 if (d->closedDialogViewGUIClient) {
2396 //ooh, there is a client which dialog is already closed -- BUT it is the same client as our
2397 //so: give up
2398 }
2399 else {
2400 guiFactory()->addClient(viewClient);
2401 }
2402 }
2403 }*/
2404 }
2405 bool update_dlg_caption = dlg && dlg!=(KexiDialogBase*)d->curDialog && dlg->mdiParent();
2406
2407 if (d->curDialogGUIClient && !client)
2408 guiFactory()->removeClient(d->curDialogGUIClient);
2409 d->curDialogGUIClient=client;
2410
2411 if (d->curDialogViewGUIClient && !viewClient)
2412 guiFactory()->removeClient(d->curDialogViewGUIClient);
2413 d->curDialogViewGUIClient=viewClient;
2414
2415 bool dialogChanged = ((KexiDialogBase*)d->curDialog)!=dlg;
2416
2417 if (dialogChanged) {
2418 if (d->curDialog) {
2419 //inform previously activated dialog about deactivation
2420 d->curDialog->deactivate();
2421 }
2422 }
2423 d->curDialog=dlg;
2424
2425//moved below: propertySetSwitched(d->curDialog);
2426
2427 updateCustomPropertyPanelTabs(prevDialog, prevDialog ? prevDialog->currentViewMode() : Kexi::NoViewMode);
2428
2429 // inform the current view of the new dialog about property switching
2430 // (this will also call KexiMainWindowImpl::propertySetSwitched() to update the current property editor's set
2431 if (dialogChanged && d->curDialog)
2432 d->curDialog->selectedView()->propertySetSwitched();
2433
2434 if (dialogChanged) {
2435// invalidateSharedActions();
2436 //update property editor's contents...
2437// if ((KexiPropertyBuffer*)d->propBuffer!=d->curDialog->propertyBuffer()) {
2438// propertyBufferSwitched();//d->curDialog);
2439// d->propBuffer = d->curDialog->propertyBuffer();
2440// d->propEditor->editor()->setBuffer( d->propBuffer );
2441// }
2442 if (d->curDialog && d->curDialog->currentViewMode()!=0) //on opening new dialog it can be 0; we don't want this
2443 d->updatePropEditorVisibility(d->curDialog->currentViewMode());
2444 }
2445
2446 //update caption...
2447 if (update_dlg_caption) {//d->curDialog is != null for sure
2448 slotCaptionForCurrentMDIChild(d->curDialog->mdiParent()->state()==KMdiChildFrm::Maximized);
2449 }
2450// if (!d->curDialog.isNull())
2451// d->last_checked_mode = d->actions_for_view_modes[ d->curDialog->currentViewMode() ];
2454 d->updateFindDialogContents();
2455 if (dlg)
2456 dlg->setFocus();
2457}
2458
2459bool
2461{
2462 kdDebug() << "KexiMainWindowImpl::activateWindow()" << endl;
2463#ifndef KEXI_NO_PENDING_DIALOGS
2464 Private::PendingJobType pendingType;
2465 return activateWindow( d->openedDialogFor( id, pendingType ) );
2466#else
2467 return activateWindow( d->openedDialogFor( id ) );
2468#endif
2469}
2470
2471bool
2473{
2474 kdDebug() << "KexiMainWindowImpl::activateWindow(KexiDialogBase *)" << endl;
2475 if(!dlg)
2476 return false;
2477
2478 d->focus_before_popup = dlg;
2479 dlg->activate();
2480 return true;
2481}
2482
2483void
2485{
2486 KexiDialogBase *dlg = static_cast<KexiDialogBase *>(v);
2487 d->removeDialog(dlg->id());
2488#ifndef KEXI_NO_PENDING_DIALOGS
2489 d->removePendingDialog(dlg->id());
2490#endif
2491
2492 //focus navigator if nothing else available
2493 if (d->openedDialogsCount() == 0)
2494 d->nav->setFocus();
2495}
2496
2497void
2498KexiMainWindowImpl::slotShowSettings()
2499{
2500 KEXI_UNFINISHED(d->action_configure->text());
2501//TODO KexiSettings s(this);
2502// s.exec();
2503}
2504
2505void
2506KexiMainWindowImpl::slotConfigureKeys()
2507{
2508/* KKeyDialog dlg;
2509 dlg.insert( actionCollection() );
2510 dlg.configure();*/
2511 KKeyDialog::configure( actionCollection(), false/*bAllowLetterShortcuts*/, this );
2512}
2513
2514void
2515KexiMainWindowImpl::slotConfigureToolbars()
2516{
2517 KEditToolbar edit(factory());
2518// connect(&edit,TQ_SIGNAL(newToolbarConfig()),this,TQ_SLOT(slotNewToolbarConfig()));
2519 (void) edit.exec();
2520}
2521
2522void
2524{
2525 if (!d->prj) {
2526 //create within this instance
2528 return;
2529 }
2530//TODO use KexiStartupDialog(KexiStartupDialog::Templates...)
2531
2532 bool cancel;
2533 TQString fileName;
2535 cancel,
2536 false, /* do not confirm prj overwrites: user will be asked on process startup */
2537 &fileName //shortcut fname
2538 );
2539 if (!new_data)
2540 return;
2541
2542 TQStringList args;
2543 args << tqApp->applicationFilePath() << "-create-opendb";
2544 if (new_data->connectionData()->fileName().isEmpty()) {
2545 //server based - pass .kexic file
2546 if (fileName.isEmpty())
2547 return;
2548 args << new_data->databaseName() << fileName;
2549 //args << "--skip-conn-dialog"; //user does not expect conn. dialog to be shown here
2550 }
2551 else {
2552 //file based
2553 fileName = new_data->connectionData()->fileName();
2554 args << fileName;
2555 }
2556//todo: pass new_data->caption()
2557 //start new instance
2559 TQProcess proc(args, this, "process");
2560 proc.setCommunication((TQProcess::Communication)0);
2561// proc.setWorkingDirectory( TQFileInfo(new_data->connectionData()->fileName()).dir(true) );
2562 proc.setWorkingDirectory( TQFileInfo(fileName).dir(true) );
2563 if (!proc.start()) {
2564 d->showStartProcessMsg(args);
2565 }
2566 delete new_data;
2567}
2568
2569void
2571{
2572 d->prj = new KexiProject( new_data, this );
2573// d->prj = ::createKexiProject(new_data);
2574//provided by KexiMessageHandler connect(d->prj, TQ_SIGNAL(error(const TQString&,KexiDB::Object*)), this, TQ_SLOT(showErrorMessage(const TQString&,KexiDB::Object*)));
2575//provided by KexiMessageHandler connect(d->prj, TQ_SIGNAL(error(const TQString&,const TQString&)), this, TQ_SLOT(showErrorMessage(const TQString&,const TQString&)));
2576 connect(d->prj, TQ_SIGNAL(itemRenamed(const KexiPart::Item&, const TQCString&)), this, TQ_SLOT(slotObjectRenamed(const KexiPart::Item&, const TQCString&)));
2577
2578 if (d->nav)
2579 connect(d->prj, TQ_SIGNAL(itemRemoved(const KexiPart::Item&)), d->nav, TQ_SLOT(slotRemoveItem(const KexiPart::Item&)));
2580}
2581
2583KexiMainWindowImpl::createBlankProjectData(bool &cancelled, bool confirmOverwrites,
2584 TQString* shortcutFileName)
2585{
2586 cancelled = false;
2587 KexiNewProjectWizard wiz(Kexi::connset(), 0, "KexiNewProjectWizard", true);
2588 wiz.setConfirmOverwrites(confirmOverwrites);
2589 if (wiz.exec() != TQDialog::Accepted) {
2590 cancelled=true;
2591 return 0;
2592 }
2593
2594 KexiProjectData *new_data;
2595
2596 if (shortcutFileName)
2597 *shortcutFileName = TQString();
2598 if (wiz.projectConnectionData()) {
2599 //server-based project
2600 KexiDB::ConnectionData *cdata = wiz.projectConnectionData();
2601 kdDebug() << "DBNAME: " << wiz.projectDBName() << " SERVER: " << cdata->serverInfoString() << endl;
2602 new_data = new KexiProjectData( *cdata, wiz.projectDBName(), wiz.projectCaption() );
2603 if (shortcutFileName)
2604 *shortcutFileName = Kexi::connset().fileNameForConnectionData(cdata);
2605 }
2606 else if (!wiz.projectDBName().isEmpty()) {
2607 //file-based project
2609 cdata.caption = wiz.projectCaption();
2611 cdata.setFileName( wiz.projectDBName() );
2612 new_data = new KexiProjectData( cdata, wiz.projectDBName(), wiz.projectCaption() );
2613 }
2614 else {
2615 cancelled = true;
2616 return 0;
2617 }
2618 return new_data;
2619}
2620
2623{
2624 bool cancel;
2625 KexiProjectData *new_data = createBlankProjectData(cancel);
2626 if (cancel)
2627 return cancelled;
2628 if (!new_data)
2629 return false;
2630
2631 createKexiProject( new_data );
2632
2633 tristate res = d->prj->create(true /*overwrite*/ );
2634 if (res != true) {
2635 delete d->prj;
2636 d->prj = 0;
2637 return res;
2638 }
2639 kdDebug() << "KexiMainWindowImpl::slotProjectNew(): new project created --- " << endl;
2640 initNavigator();
2642
2645 return true;
2646}
2647
2648void
2649KexiMainWindowImpl::slotProjectOpen()
2650{
2652 KexiStartupDialog::OpenExisting, 0, Kexi::connset(), Kexi::recentProjects(),
2653 this, "KexiOpenDialog");
2654
2655 if (dlg.exec()!=TQDialog::Accepted)
2656 return;
2657
2658 openProject(dlg.selectedFileName(), dlg.selectedExistingConnection());
2659}
2660
2662 const TQString& fileNameForConnectionData, const TQString& dbName)
2663{
2664 if (d->prj)
2665 return openProjectInExternalKexiInstance(aFileName, fileNameForConnectionData, dbName);
2666
2667 KexiDB::ConnectionData *cdata = 0;
2668 if (!fileNameForConnectionData.isEmpty()) {
2669 cdata = Kexi::connset().connectionDataForFileName( fileNameForConnectionData );
2670 if (!cdata) {
2671 kdWarning() << "KexiMainWindowImpl::openProject() cdata?" << endl;
2672 return false;
2673 }
2674 }
2675 return openProject(aFileName, cdata, dbName);
2676}
2677
2679 KexiDB::ConnectionData *cdata, const TQString& dbName,
2680 const TQValueList<KexiProjectData::ObjectInfo>& autoopenObjects)
2681{
2682 if (d->prj) {
2683 return openProjectInExternalKexiInstance(aFileName, cdata, dbName);
2684 }
2685
2686 KexiProjectData* projectData = 0;
2687 bool deleteAfterOpen = false;
2688 if (cdata) {
2689 //server-based project
2690 if (dbName.isEmpty()) {//no database name given, ask user
2691 bool cancel;
2692 projectData = Kexi::startupHandler().selectProject( cdata, cancel, this );
2693 if (cancel)
2694 return cancelled;
2695 }
2696 else {
2698 projectData = new KexiProjectData( *cdata, dbName );
2699 deleteAfterOpen = true;
2700 }
2701 }
2702 else {
2703// TQString selFile = dlg.selectedExistingFile();
2704 if (aFileName.isEmpty()) {
2705 kdWarning() << "KexiMainWindowImpl::openProject(): aFileName.isEmpty()" << endl;
2706 return false;
2707 }
2708 //file-based project
2709 kdDebug() << "Project File: " << aFileName << endl;
2711 cdata.setFileName( aFileName );
2712// cdata.driverName = KexiStartupHandler::detectDriverForFile( cdata.driverName, fileName, this );
2713 TQString detectedDriverName;
2714 KexiStartupData::Import importActionData;
2716 importActionData, detectedDriverName, cdata.driverName, aFileName, this );
2717 if (true != res)
2718 return res;
2719
2720 if (importActionData) { //importing requested
2721 return showProjectMigrationWizard( importActionData.mimeType, importActionData.fileName );
2722 }
2723 cdata.driverName = detectedDriverName;
2724
2725 if (cdata.driverName.isEmpty())
2726 return false;
2727
2728 //opening requested
2729 projectData = new KexiProjectData(cdata, aFileName);
2730 deleteAfterOpen = true;
2731 }
2732 if (!projectData)
2733 return false;
2734 projectData->autoopenObjects = autoopenObjects;
2735 const tristate res = openProject(*projectData);
2736 if (deleteAfterOpen) //projectData object has been copied
2737 delete projectData;
2738 return res;
2739}
2740
2742 KexiDB::ConnectionData *cdata, const TQString& dbName)
2743{
2744 TQString fileNameForConnectionData;
2745 if (aFileName.isEmpty()) { //try .kexic file
2746 if (cdata)
2747 fileNameForConnectionData = Kexi::connset().fileNameForConnectionData(cdata);
2748 }
2749 return openProjectInExternalKexiInstance(aFileName, fileNameForConnectionData, dbName);
2750}
2751
2753 const TQString& fileNameForConnectionData, const TQString& dbName)
2754{
2755 TQString fileName(aFileName);
2756 TQStringList args;
2757 args << tqApp->applicationFilePath();
2758 // open a file-based project or a server connection provided as a .kexic file
2759 // (we have no other simple way to provide the startup data to a new process)
2760 if (fileName.isEmpty()) { //try .kexic file
2761 if (!fileNameForConnectionData.isEmpty())
2762 args << "--skip-conn-dialog"; //user does not expect conn. dialog to be shown here
2763
2764 if (dbName.isEmpty()) { //use 'kexi --skip-conn-dialog file.kexic'
2765 fileName = fileNameForConnectionData;
2766 }
2767 else { //use 'kexi --skip-conn-dialog --connection file.kexic dbName'
2768 args << "--connection" << fileNameForConnectionData;
2769 fileName = dbName;
2770 }
2771 }
2772 if (fileName.isEmpty()) {
2773 kdWarning() << "KexiMainWindowImpl::openProjectInExternalKexiInstance() fileName?" << endl;
2774 return false;
2775 }
2777 args << fileName;
2778 TQProcess proc(args, this, "process");
2779 proc.setWorkingDirectory( TQFileInfo(fileName).dir(true) );
2780 const bool ok = proc.start();
2781 if (!ok) {
2782 d->showStartProcessMsg(args);
2783 }
2784 return ok;
2785}
2786
2787void
2788KexiMainWindowImpl::slotProjectOpenRecentAboutToShow()
2789{
2790 /*
2791 //setup
2792 TDEPopupMenu *popup = d->action_open_recent->popupMenu();
2793 const int cnt = popup->count();
2794 //remove older
2795 for (int i = 0; i<cnt; i++) {
2796 int id = popup->idAt(0);
2797 if (id==d->action_open_recent_more_id)
2798 break;
2799 if (id>=0) {
2800 popup->removeItem(id);
2801 }
2802 }
2803 //insert current items
2804 int cur_id = 0, cur_idx = 0;
2805 //TODO:
2806 cur_id = popup->insertItem("My example project 1", ++cur_id, cur_idx++);
2807 cur_id = popup->insertItem("My example project 2", ++cur_id, cur_idx++);
2808 cur_id = popup->insertItem("My example project 3", ++cur_id, cur_idx++);
2809 */
2810
2811 //show recent databases
2812 TDEPopupMenu *popup = d->action_open_recent->popupMenu();
2813 popup->clear();
2814#if 0
2815 d->action_open_recent_projects_title_id = popup->insertTitle(i18n("Recently Opened Databases"));
2816#endif
2817// int action_open_recent_projects_title_index = popup->indexOf(d->action_open_recent_projects_title_id);
2818// int count = popup->count();
2819// int action_open_recent_connections_title_index = popup->indexOf(d->action_open_recent_connections_title_id);
2820// for (int i=action_open_recent_projects_title_index+1;
2821// i<action_open_recent_connections_title_index; i++)
2822// {
2823// popup->removeItemAt(action_open_recent_projects_title_index+1);
2824// }
2825
2826// int cur_idx = action_open_recent_projects_title_index+1;
2827 popup->insertItem(SmallIconSet("kexiproject_sqlite"), "My project 1");
2828 popup->insertItem(SmallIconSet("kexiproject_sqlite"), "My project 2");
2829 popup->insertItem(SmallIconSet("kexiproject_sqlite"), "My project 3");
2830
2831#if 0
2832 //show recent connections
2833 d->action_open_recent_connections_title_id =
2834 d->action_open_recent->popupMenu()->insertTitle(i18n("Recently Connected Database Servers"));
2835
2836// cur_idx = popup->indexOf(d->action_open_recent_connections_title_id) + 1;
2837// for (int i=cur_idx; i<count; i++) {
2838// popup->removeItemAt(cur_idx);
2839// }
2840 popup->insertItem(SmallIconSet("socket"), "My connection 1");
2841 popup->insertItem(SmallIconSet("socket"), "My connection 2");
2842 popup->insertItem(SmallIconSet("socket"), "My connection 3");
2843 popup->insertItem(SmallIconSet("socket"), "My connection 4");
2844#endif
2845}
2846
2847void
2848KexiMainWindowImpl::slotProjectOpenRecent(int id)
2849{
2850 if (id<0) // || id==d->action_open_recent_more_id)
2851 return;
2852 kdDebug() << "KexiMainWindowImpl::slotProjectOpenRecent("<<id<<")"<<endl;
2853}
2854
2855void
2856KexiMainWindowImpl::slotProjectOpenRecentMore()
2857{
2858 KEXI_UNFINISHED(i18n("Open Recent"));
2859}
2860
2861void
2862KexiMainWindowImpl::slotProjectSave()
2863{
2864 if (!d->curDialog)
2865 return;
2866 saveObject( d->curDialog );
2869}
2870
2871void
2872KexiMainWindowImpl::slotProjectSaveAs()
2873{
2874 KEXI_UNFINISHED(i18n("Save object as"));
2875}
2876
2877void
2878KexiMainWindowImpl::slotProjectPrint()
2879{
2880 if (d->curDialog && d->curDialog->partItem())
2881 printItem(d->curDialog->partItem());
2882}
2883
2884void
2885KexiMainWindowImpl::slotProjectPrintPreview()
2886{
2887 if (d->curDialog && d->curDialog->partItem())
2888 printPreviewForItem(d->curDialog->partItem());
2889}
2890
2891void
2892KexiMainWindowImpl::slotProjectPageSetup()
2893{
2894 if (d->curDialog && d->curDialog->partItem())
2895 showPageSetupForItem(d->curDialog->partItem());
2896}
2897
2898void KexiMainWindowImpl::slotProjectExportDataTable()
2899{
2900 if (d->curDialog && d->curDialog->partItem())
2901 exportItemAsDataTable(d->curDialog->partItem());
2902}
2903
2904void
2905KexiMainWindowImpl::slotProjectProperties()
2906{
2907 //TODO: load the implementation not the ui :)
2908// ProjectSettingsUI u(this);
2909// u.exec();
2910}
2911
2912void
2913KexiMainWindowImpl::slotProjectClose()
2914{
2915 closeProject();
2916}
2917
2918void KexiMainWindowImpl::slotProjectRelations()
2919{
2920 if (!d->prj)
2921 return;
2922 KexiDialogBase *d = KexiInternalPart::createKexiDialogInstance("relation", this, this);
2923 activateWindow(d);
2924}
2925
2926void KexiMainWindowImpl::slotImportFile()
2927{
2928 KEXI_UNFINISHED("Import: " + i18n("From File..."));
2929}
2930
2931void KexiMainWindowImpl::slotImportServer()
2932{
2933 KEXI_UNFINISHED("Import: " + i18n("From Server..."));
2934}
2935
2936void
2937KexiMainWindowImpl::slotProjectQuit()
2938{
2939 if (~ closeProject())
2940 return;
2941 close();
2942}
2943
2944void KexiMainWindowImpl::slotViewNavigator()
2945{
2946 if (!d->nav || !d->navToolWindow)
2947 return;
2948 if (!d->nav->isVisible())
2949 makeWidgetDockVisible(d->nav);
2950// makeDockVisible(dynamic_cast<KDockWidget*>(d->navToolWindow->wrapperWidget()));
2951// d->navToolWindow->wrapperWidget()->show();
2952// d->navToolWindow->show(KDockWidget::DockLeft, getMainDockWidget());
2953
2954 d->navToolWindow->wrapperWidget()->raise();
2955//
2956 d->block_KMdiMainFrm_eventFilter=true;
2957 d->nav->setFocus();
2958 d->block_KMdiMainFrm_eventFilter=false;
2959}
2960
2961void KexiMainWindowImpl::slotViewMainArea()
2962{
2963 if (d->curDialog)
2964 d->curDialog->setFocus();
2965}
2966
2967void KexiMainWindowImpl::slotViewPropertyEditor()
2968{
2969 if (!d->propEditor || !d->propEditorToolWindow)
2970 return;
2971
2972//js d->config->setGroup("MainWindow");
2973//js ds->setSeparatorPos(d->config->readNumEntry("RightDockPosition", 80/* % */), true);
2974
2975 if (!d->propEditorTabWidget->isVisible())
2976 makeWidgetDockVisible(d->propEditorTabWidget);
2977
2978
2979 d->propEditorToolWindow->wrapperWidget()->raise();
2980
2981 d->block_KMdiMainFrm_eventFilter=true;
2982 if (d->propEditorTabWidget->currentPage())
2983 d->propEditorTabWidget->currentPage()->setFocus();
2984 d->block_KMdiMainFrm_eventFilter=false;
2985
2986/*#if defined(KDOCKWIDGET_P)
2987 KDockWidget *dw = (KDockWidget *)d->propEditor->parentWidget();
2988 KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
2989 ds->setSeparatorPos(80,true);//d->config->readNumEntry("RightDockPosition", 80), true);
2990#endif*/
2991}
2992
2994{
2995 if (!d->curDialog) {
2996 d->toggleLastCheckedMode();
2997 return false;
2998 }
2999 if (!d->curDialog->supportsViewMode( viewMode )) {
3000 showErrorMessage(i18n("Selected view is not supported for \"%1\" object.")
3001 .arg(d->curDialog->partItem()->name()),
3002 i18n("Selected view (%1) is not supported by this object type (%2).")
3003 .arg(Kexi::nameForViewMode(viewMode))
3004 .arg(d->curDialog->part()->instanceCaption()) );
3005 d->toggleLastCheckedMode();
3006 return false;
3007 }
3008 int prevViewMode = d->curDialog->currentViewMode();
3009 updateCustomPropertyPanelTabs(d->curDialog->part(), prevViewMode,
3010 d->curDialog->part(), viewMode );
3011 tristate res = d->curDialog->switchToViewMode( viewMode );
3012 if (!res) {
3014 showErrorMessage(i18n("Switching to other view failed (%1).").arg(Kexi::nameForViewMode(viewMode)),
3015 d->curDialog);
3016 d->toggleLastCheckedMode();
3017 return false;
3018 }
3019 if (~res) {
3021 d->toggleLastCheckedMode();
3022 return false;
3023 }
3024
3025 //view changed: switch to this view's gui client
3026 KXMLGUIClient *viewClient=d->curDialog->guiClient();
3027 updateDialogViewGUIClient(viewClient);
3028 if (d->curDialogViewGUIClient && !viewClient)
3029 guiFactory()->removeClient(d->curDialogViewGUIClient);
3030 d->curDialogViewGUIClient=viewClient; //remember
3031
3032 d->updatePropEditorVisibility(viewMode);
3035 d->updateFindDialogContents();
3036 return true;
3037}
3038
3039
3040void KexiMainWindowImpl::slotViewDataMode()
3041{
3042 switchToViewMode(Kexi::DataViewMode);
3043}
3044
3045void KexiMainWindowImpl::slotViewDesignMode()
3046{
3047 switchToViewMode(Kexi::DesignViewMode);
3048}
3049
3054
3055void KexiMainWindowImpl::closeWindow(KMdiChildView *pWnd, bool layoutTaskBar)
3056{
3057 if (d->insideCloseDialog && dynamic_cast<KexiDialogBase *>(pWnd)) {
3058 d->windowsToClose.append(dynamic_cast<KexiDialogBase *>(pWnd));
3059 return;
3060 }
3061 /*moved to closeDialog()
3062 if (pWnd == d->curDialog && !pWnd->isAttached()) {
3063 if (d->propEditor) {
3064 // ah, closing detached window - better switch off property buffer right now...
3065 d->propBuffer = 0;
3066 d->propEditor->editor()->setBuffer( 0, false );
3067 }
3068 }
3069 */
3070 closeDialog(dynamic_cast<KexiDialogBase *>(pWnd), layoutTaskBar);
3071}
3072
3074 KexiPart::Item *partItem, KexiPart::Part *part,
3075 bool& allowOverwriting, const TQString& messageWhenAskingForName )
3076{
3077 //data was never saved in the past -we need to create a new object at the backend
3078 KexiPart::Info *info = part->info();
3079#ifdef KEXI_ADD_CUSTOM_OBJECT_CREATION
3080# include "keximainwindowimpl_customobjcreation.h"
3081#endif
3082 if (!d->nameDialog) {
3083 d->nameDialog = new KexiNameDialog(
3084 messageWhenAskingForName, this, "nameDialog");
3085 //check if that name is allowed
3086 d->nameDialog->widget()->addNameSubvalidator(
3087 new KexiDB::ObjectNameValidator(project()->dbConnection()->driver(), 0, "sub"));
3088 }
3089 else {
3090 d->nameDialog->widget()->setMessageText( messageWhenAskingForName );
3091 }
3092 d->nameDialog->widget()->setCaptionText(partItem->caption());
3093 d->nameDialog->widget()->setNameText(partItem->name());
3094 d->nameDialog->setCaption(i18n("Save Object As"));
3095 d->nameDialog->setDialogIcon( DesktopIcon( info->itemIcon(), TDEIcon::SizeMedium ) );
3096 allowOverwriting = false;
3097 bool found;
3098 do {
3099 if (d->nameDialog->exec()!=TQDialog::Accepted)
3100 return cancelled;
3101 //check if that name already exists
3102 KexiDB::SchemaData tmp_sdata;
3104 info->projectPartID(),
3105 d->nameDialog->widget()->nameText(), tmp_sdata );
3106 if (!result)
3107 return false;
3108 found = result==true;
3109 if (found) {
3110 if (allowOverwriting) {
3111 int res = KMessageBox::warningYesNoCancel(this,
3112 "<p>"+part->i18nMessage("Object \"%1\" already exists.", 0)
3113 .arg(d->nameDialog->widget()->nameText())
3114 +"</p><p>"+i18n("Do you want to replace it?")+"</p>", 0,
3115 KGuiItem(i18n("&Replace"), "button_yes"),
3116 KGuiItem(i18n("&Choose Other Name...")),
3117 TQString(), KMessageBox::Notify|KMessageBox::Dangerous);
3118 if (res == KMessageBox::No)
3119 continue;
3120 else if (res == KMessageBox::Cancel)
3121 return cancelled;
3122 else {//yes
3123 allowOverwriting = true;
3124 break;
3125 }
3126 }
3127 else {
3128 KMessageBox::information(this,
3129 "<p>"+part->i18nMessage("Object \"%1\" already exists.", 0)
3130 .arg(d->nameDialog->widget()->nameText())
3131 +"</p><p>"+i18n("Please choose other name.")+"</p>");
3132// " For example: Table \"my_table\" already exists" ,
3133// "%1 \"%2\" already exists.\nPlease choose other name.")
3134// .arg(dlg->part()->instanceName()).arg(d->nameDialog->widget()->nameText()));
3135 continue;
3136 }
3137 }
3138 }
3139 while (found);
3140
3141 //update name and caption
3142 partItem->setName( d->nameDialog->widget()->nameText() );
3143 partItem->setCaption( d->nameDialog->widget()->captionText() );
3144 return true;
3145}
3146
3147tristate KexiMainWindowImpl::saveObject( KexiDialogBase *dlg, const TQString& messageWhenAskingForName,
3148 bool dontAsk)
3149{
3150 tristate res;
3151 if (!dlg->neverSaved()) {
3152 //data was saved in the past -just save again
3153 res = dlg->storeData(dontAsk);
3154 if (!res)
3155 showErrorMessage(i18n("Saving \"%1\" object failed.").arg(dlg->partItem()->name()),
3156 d->curDialog);
3157 return res;
3158 }
3159
3160 const int oldItemID = dlg->partItem()->identifier();
3161
3162 bool allowOverwriting = false;
3163 res = getNewObjectInfo( dlg->partItem(), dlg->part(), allowOverwriting,
3164 messageWhenAskingForName );
3165 if (res != true)
3166 return res;
3167
3168 res = dlg->storeNewData();
3169 if (~res)
3170 return cancelled;
3171 if (!res) {
3172 showErrorMessage(i18n("Saving new \"%1\" object failed.").arg(dlg->partItem()->name()),
3173 d->curDialog);
3174 return false;
3175 }
3176
3177 //update navigator
3178//this is alreday done in KexiProject::addStoredItem(): d->nav->addItem(dlg->partItem());
3179 //item id changed to final one: update association in dialogs' dictionary
3180// d->dialogs.take(oldItemID);
3181 d->updateDialogId(dlg, oldItemID);
3183 return true;
3184}
3185
3187{
3188 return closeDialog(dlg, true);
3189}
3190
3191tristate KexiMainWindowImpl::closeDialog(KexiDialogBase *dlg, bool layoutTaskBar, bool doNotSaveChanges)
3192{
3193 if (!dlg)
3194 return true;
3195 if (d->insideCloseDialog)
3196 return true;
3197
3198#ifndef KEXI_NO_PENDING_DIALOGS
3199 d->addItemToPendingDialogs(dlg->partItem(), Private::DialogClosingJob);
3200#endif
3201
3202 d->insideCloseDialog = true;
3203
3204 if (dlg == d->curDialog && !dlg->isAttached()) {
3205 if (d->propEditor) {
3206 // ah, closing detached window - better switch off property buffer right now...
3207 d->propBuffer = 0;
3208 d->propEditor->editor()->changeSet( 0, false );
3209 }
3210 }
3211
3212 bool remove_on_closing = dlg->partItem() ? dlg->partItem()->neverSaved() : false;
3213 if (dlg->dirty() && !d->forceDialogClosing && !doNotSaveChanges) {
3214 //more accurate tool tips and what's this
3215 KGuiItem saveChanges( KStdGuiItem::save() );
3216 saveChanges.setToolTip(i18n("Save changes"));
3217 saveChanges.setWhatsThis(
3218 i18n( "Pressing this button will save all recent changes made in \"%1\" object." )
3219 .arg(dlg->partItem()->name()) );
3220 KGuiItem discardChanges( KStdGuiItem::discard() );
3221 discardChanges.setWhatsThis(
3222 i18n( "Pressing this button will discard all recent changes made in \"%1\" object." )
3223 .arg(dlg->partItem()->name()) );
3224
3225 //dialog's data is dirty:
3226 //--adidional message, e.g. table designer will return
3227 // "Note: This table is already filled with data which will be removed."
3228 // if the dlg is in design view mode.
3229 TQString additionalMessage = dlg->part()->i18nMessage(
3230 ":additional message before saving design", dlg);
3231 if (additionalMessage.startsWith(":"))
3232 additionalMessage = TQString();
3233 if (!additionalMessage.isEmpty())
3234 additionalMessage = "<p>"+additionalMessage+"</p>";
3235
3236 const int questionRes = KMessageBox::warningYesNoCancel( this,
3237 "<p>"+dlg->part()->i18nMessage("Design of object \"%1\" has been modified.", dlg)
3238 .arg(dlg->partItem()->name())+"</p><p>"+i18n("Do you want to save changes?")+"</p>"
3239 + additionalMessage /*may be empty*/,
3240 TQString(),
3241 saveChanges,
3242 discardChanges);
3243 if (questionRes==KMessageBox::Cancel) {
3244#ifndef KEXI_NO_PENDING_DIALOGS
3245 d->removePendingDialog(dlg->id());
3246#endif
3247 d->insideCloseDialog = false;
3248 d->windowsToClose.clear(); //give up with 'close all'
3249 return cancelled;
3250 }
3251 if (questionRes==KMessageBox::Yes) {
3252 //save it
3253// if (!dlg->storeData())
3254 tristate res = saveObject( dlg, TQString(), true /*dontAsk*/ );
3255 if (!res || ~res) {
3256//js:TODO show error info; (retry/ignore/cancel)
3257#ifndef KEXI_NO_PENDING_DIALOGS
3258 d->removePendingDialog(dlg->id());
3259#endif
3260 d->insideCloseDialog = false;
3261 d->windowsToClose.clear(); //give up with 'close all'
3262 return res;
3263 }
3264 remove_on_closing = false;
3265 }
3266 }
3267
3268 const int dlg_id = dlg->id(); //remember now, because removeObject() can destruct partitem object
3269
3270 if (remove_on_closing) {
3271 //we won't save this object, and it was never saved -remove it
3272 if (!removeObject( dlg->partItem(), true )) {
3273#ifndef KEXI_NO_PENDING_DIALOGS
3274 d->removePendingDialog(dlg->id());
3275#endif
3276 //msg?
3277 //TODO: ask if we'd continue and return true/false
3278 d->insideCloseDialog = false;
3279 d->windowsToClose.clear(); //give up with 'close all'
3280 return false;
3281 }
3282 }
3283 else {
3284 //not dirty now
3285 if(d->nav)
3286 d->nav->updateItemName( *dlg->partItem(), false );
3287 }
3288
3289 d->removeDialog(dlg_id); //don't remove -KMDI will do that
3290 //also remove from 'print setup dialogs' cache, if needed
3291 int printedObjectID = 0;
3292 if (d->pageSetupDialogItemID2dataItemID_map.contains(dlg_id))
3293 printedObjectID = d->pageSetupDialogItemID2dataItemID_map[ dlg_id ];
3294 d->pageSetupDialogs.take(printedObjectID);
3295
3296 KXMLGUIClient *client = dlg->commonGUIClient();
3297 KXMLGUIClient *viewClient = dlg->guiClient();
3298 if (d->curDialogGUIClient==client) {
3299 d->curDialogGUIClient=0;
3300 }
3301 if (d->curDialogViewGUIClient==viewClient) {
3302 d->curDialogViewGUIClient=0;
3303 }
3304 if (client) {
3305 //sanity: ouch, it is not removed yet? - do it now
3306 if (d->closedDialogGUIClient && d->closedDialogGUIClient!=client)
3307 guiFactory()->removeClient(d->closedDialogGUIClient);
3308 if (d->openedDialogsCount()==0) {//now there is no dialogs - remove client RIGHT NOW!
3309 d->closedDialogGUIClient=0;
3310 guiFactory()->removeClient(client);
3311 }
3312 else {
3313 //remember this - and MAYBE remove later, if needed
3314 d->closedDialogGUIClient=client;
3315 }
3316 }
3317 if (viewClient) {
3318 //sanity: ouch, it is not removed yet? - do it now
3319 if (d->closedDialogViewGUIClient && d->closedDialogViewGUIClient!=viewClient)
3320 guiFactory()->removeClient(d->closedDialogViewGUIClient);
3321 if (d->openedDialogsCount()==0) {//now there is no dialogs - remove client RIGHT NOW!
3322 d->closedDialogViewGUIClient=0;
3323 guiFactory()->removeClient(viewClient);
3324 }
3325 else {
3326 //remember this - and MAYBE remove later, if needed
3327 d->closedDialogViewGUIClient=viewClient;
3328 }
3329 }
3330
3331 const bool isInMaximizedChildFrmMode = this->isInMaximizedChildFrmMode();
3332
3333 KMdiMainFrm::closeWindow(dlg, layoutTaskBar);
3334
3335 //focus navigator if nothing else available
3336 if (d->openedDialogsCount()==0) {
3337 d->maximizeFirstOpenedChildFrm = isInMaximizedChildFrmMode;
3338 if (d->nav)
3339 d->nav->setFocus();
3340 d->updatePropEditorVisibility(0);
3341 }
3342
3344 d->insideCloseDialog = false;
3345 if (!d->windowsToClose.isEmpty()) //continue 'close all'
3346 closeDialog(d->windowsToClose.take(0), true);
3347
3348#ifndef KEXI_NO_PENDING_DIALOGS
3349 d->removePendingDialog( dlg_id );
3350
3351 //perform pending global action that was suspended:
3352 if (!d->pendingDialogsExist()) {
3353 d->executeActionWhenPendingJobsAreFinished();
3354 }
3355#endif
3356 return true;
3357}
3358
3359void KexiMainWindowImpl::detachWindow(KMdiChildView *pWnd,bool bShow)
3360{
3361 KMdiMainFrm::detachWindow(pWnd,bShow);
3362 // update icon - from small to large
3363 pWnd->setIcon( DesktopIcon( static_cast<KexiDialogBase *>(pWnd)->itemIcon() ) );
3364// pWnd->setIcon( DesktopIcon( static_cast<KexiDialogBase *>(pWnd)->part()->info()->itemIcon() ) );
3365 if (dynamic_cast<KexiDialogBase*>(pWnd))
3366 dynamic_cast<KexiDialogBase*>(pWnd)->sendDetachedStateToCurrentView();
3367}
3368
3369void KexiMainWindowImpl::attachWindow(KMdiChildView *pWnd, bool /*bShow*/, bool bAutomaticResize)
3370{
3371// if (bAutomaticResize || w->size().isEmpty() || (w->size() == TQSize(1,1))) {
3372 KMdiMainFrm::attachWindow(pWnd,true,bAutomaticResize);
3373 //for dialogs in normal state: decrease dialog's height if it exceeds area contents
3374 if (pWnd->mdiParent()->state() == KMdiChildFrm::Normal
3375 && pWnd->geometry().bottom() > pWnd->mdiParent()->mdiAreaContentsRect().bottom())
3376 {
3377 TQRect r = pWnd->geometry();
3378 r.setBottom( pWnd->mdiParent()->mdiAreaContentsRect().bottom() - 5 );
3379 pWnd->setGeometry( r );
3380 }
3381 // update icon - from large to small
3382 pWnd->mdiParent()->setIcon( SmallIcon( static_cast<KexiDialogBase *>(pWnd)->itemIcon() ) );
3383 if (dynamic_cast<KexiDialogBase*>(pWnd))
3384 dynamic_cast<KexiDialogBase*>(pWnd)->sendAttachedStateToCurrentView();
3385}
3386
3388{
3389 while (w && !acceptsSharedActions(w))
3390 w = w->parentWidget();
3391 return w;
3392}
3393
3395{
3396 return w->inherits("KexiDialogBase") || w->inherits("KexiViewBase");
3397}
3398
3399bool KexiMainWindowImpl::eventFilter( TQObject *obj, TQEvent * e )
3400{
3401 //KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name()<<endl;
3402 if (e->type()==TQEvent::KeyPress) {
3403 KexiVDebug << "KEY EVENT " << TQString::number(static_cast<TQKeyEvent*>(e)->key(), 16) << endl;
3404 KexiVDebug << endl;
3405 }
3406 if (e->type()==TQEvent::AccelOverride) {
3407 //KexiVDebug << "AccelOverride EVENT " << static_cast<TQKeyEvent*>(e)->key() << " " << static_cast<TQKeyEvent*>(e)->state() == ControlButton << endl;
3408
3409 //avoid sending CTRL+Tab key twice for tabbed/ideal mode, epecially for win32
3410 if (static_cast<TQKeyEvent*>(e)->key()==TQt::Key_Tab && static_cast<TQKeyEvent*>(e)->state() == ControlButton) {
3411 if (d->action_window_next->shortcut().keyCodeQt()==TQt::Key_Tab+TQt::CTRL && d->action_window_next->shortcut().count()==1
3412 && (mdiMode()==KMdi::TabPageMode || mdiMode()==KMdi::IDEAlMode))
3413 {
3414 static_cast<TQKeyEvent*>(e)->accept();
3415 }
3416 }
3417 }
3418 if (e->type()==TQEvent::Close) {
3419 KexiVDebug << "Close EVENT" << endl;
3420 }
3421 if (e->type()==TQEvent::Resize) {
3422 KexiVDebug << "Resize EVENT" << endl;
3423 }
3424 if (e->type()==TQEvent::ShowMaximized) {
3425 KexiVDebug << "ShowMaximized EVENT" << endl;
3426 }
3427
3428/* if (obj==d->propEditor) {
3429 if (e->type()==TQEvent::Resize) {
3430 d->updatePropEditorDockWidthInfo();
3431 }
3432 }*/
3433
3434 TQWidget *focus_w = 0;
3435 if (obj->inherits("TQPopupMenu")) {
3436 /* Fixes for popup menus behaviour:
3437 For hiding/showing: focus previously (d->focus_before_popup)
3438 focused window, if known, otherwise focus currently focused one.
3439 And: just invalidate actions.
3440 */
3441 if (e->type()==TQEvent::Hide || e->type()==TQEvent::Show) {
3442 KexiVDebug << e->type() << endl;
3443 focus_w = focusWindow();
3444 if (!d->focus_before_popup.isNull()) {
3445 d->focus_before_popup->setFocus();
3446 d->focus_before_popup=0;
3448 } else {
3449 if (focus_w) {
3450 focus_w->setFocus();
3452 }
3453 }
3454 }
3455 return false;
3456 }
3457
3459 if (e->type()==TQEvent::MouseButtonPress) {
3460 TQWidget *w = findWindow(static_cast<TQWidget*>(obj));
3461 KexiVDebug << "MouseButtonPress EVENT " << (w ? w->name() : 0) << endl;
3462 if (w) {
3463 w->setFocus();
3464 invalidateSharedActions(d->curDialog);
3465 }
3466 }
3467 TQWidget *w = findWindow(static_cast<TQWidget*>(obj));
3468 if (e->type()==TQEvent::FocusIn) {
3469 focus_w = focusWindow();
3470 KexiVDebug << "Focus EVENT" << endl;
3471 KexiVDebug << (focus_w ? focus_w->name() : "" ) << endl;
3472 KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name() <<endl;
3473#ifdef KEXI_STATUSBAR_DEBUG
3474 TQWidget *focus_widget = focus_w ? focus_w->focusWidget() : 0;
3475 d->statusBar->setStatus(TQString("FOCUS VIEW: %1 %2, FOCUS WIDGET: %3 %4")
3476 .arg(focus_w ? focus_w->className() : "").arg(focus_w ? focus_w->name() : "")
3477 .arg(focus_widget ? focus_widget->className() : "").arg(focus_widget ? focus_widget->name() : "")
3478 );
3479#endif
3480 }
3481 else if (e->type()==TQEvent::FocusOut) {
3482 focus_w = focusWindow();
3483 KexiVDebug << "Focus OUT EVENT" << endl;
3484 KexiVDebug << (focus_w ? focus_w->name() : "" ) << endl;
3485 KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name() <<endl;
3486#ifdef KEXI_STATUSBAR_DEBUG
3487 TQWidget *focus_widget = focus_w ? focus_w->focusWidget() : 0;
3488 d->statusBar->setStatus(TQString("FOCUS VIEW: %1 %2, FOCUS WIDGET: %3 %4")
3489 .arg(focus_w ? focus_w->className() : "").arg(focus_w ? focus_w->name() : "")
3490 .arg(focus_widget ? focus_widget->className() : "").arg(focus_widget ? focus_widget->name() : "")
3491 );
3492#endif
3493 }
3494 if (e->type()==TQEvent::WindowActivate) {
3495 KexiVDebug << "WindowActivate EVENT" << endl;
3496 KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name()<<endl;
3497 }
3498#if 0
3499 if (e->type()==TQEvent::FocusIn) {
3500 if (focus_w) {
3501// if (d->actionProxies[ w ])
3502// if (d->actionProxies[ focus_w ]) {
3503 if (actionProxyFor( focus_w )) {
3504// invalidateSharedActions();
3505 }
3506 else {
3507/* TQObject* o = focusWidget();
3508 while (o && !o->inherits("KexiDialogBase") && !o->inherits("KexiDockBase"))
3509 o = o->parent();*/
3510//js invalidateSharedActions(focus_w);
3511 }
3512 }
3513// /*|| e->type()==TQEvent::FocusOut*/) && /*(!obj->inherits("KexiDialogBase")) &&*/ d->actionProxies[ obj ]) {
3514// invalidateSharedActions();
3515 }
3516 if (e->type()==TQEvent::FocusOut && focus_w && focus_w==d->curDialog && actionProxyFor( obj )) {
3517 invalidateSharedActions(d->curDialog);
3518 }
3519#endif
3520
3521 if (!d->focus_before_popup.isNull() && e->type()==TQEvent::FocusOut && obj->inherits("KMenuBar")) {
3522 //d->nav->setFocus();
3523 d->focus_before_popup->setFocus();
3524 d->focus_before_popup=0;
3525 invalidateSharedActions(d->curDialog);
3526 return true;
3527 }
3528
3529 //remember currently focued window invalidate act.
3530 if (e->type()==TQEvent::FocusOut) {
3531 if (static_cast<TQFocusEvent*>(e)->reason()==TQFocusEvent::Popup) {
3532 if (KexiUtils::hasParent(d->curDialog, focus_w)) {
3533 invalidateSharedActions(d->curDialog);
3534 d->focus_before_popup=d->curDialog;
3535 }
3536 else {
3537//not needed??? invalidateSharedActions(focus_w);
3538 d->focus_before_popup=focus_w;
3539 }
3540 }
3541 }
3542
3543 //keep focus in main window:
3544 if (w && w==d->nav) {
3545// kdDebug() << "NAV" << endl;
3546 if (e->type()==TQEvent::FocusIn) {
3547 return true;
3548 } else if (e->type()==TQEvent::WindowActivate && w==d->focus_before_popup) {
3549// d->nav->setFocus();
3550 d->focus_before_popup=0;
3551 return true;
3552 } else if (e->type()==TQEvent::FocusOut) {
3553 if (static_cast<TQFocusEvent*>(e)->reason()==TQFocusEvent::Tab) {
3554 //activate current child:
3555 if (d->curDialog) {
3556 d->curDialog->activate();
3557 return true;
3558 }
3559 }
3560 else if (static_cast<TQFocusEvent*>(e)->reason()==TQFocusEvent::Popup) {
3561 d->focus_before_popup=w;
3562 }
3563 //invalidateSharedActions();
3564 } else if (e->type()==TQEvent::Hide) {
3565 setFocus();
3566 return false;
3567 }
3568 }
3569 if (d->block_KMdiMainFrm_eventFilter)//we don't want KMDI to eat our event!
3570 return false;
3571 return KMdiMainFrm::eventFilter(obj,e);//let KMDI do its work
3572}
3573
3575{
3577 if (!userMode())
3578 return true;
3579 KexiPart::Part * part = Kexi::partManager().partForMimeType(item->mimeType());
3580 return part && (part->supportedUserViewModes() & viewMode);
3581}
3582
3584KexiMainWindowImpl::openObject(const TQCString& mimeType, const TQString& name,
3585 int viewMode, bool &openingCancelled, TQMap<TQString,TQString>* staticObjectArgs)
3586{
3587 KexiPart::Item *item = d->prj->itemForMimeType(mimeType,name);
3588 if (!item)
3589 return 0;
3590 return openObject(item, viewMode, openingCancelled, staticObjectArgs);
3591}
3592
3594KexiMainWindowImpl::openObject(KexiPart::Item* item, int viewMode, bool &openingCancelled,
3595 TQMap<TQString,TQString>* staticObjectArgs, TQString* errorMessage)
3596{
3597 if (!openingAllowed(item, viewMode)) {
3598 if (errorMessage)
3599 *errorMessage = i18n("opening is not allowed in \"data view/design view/text view\" mode",
3600 "opening is not allowed in \"%1\" mode").arg(Kexi::nameForViewMode(viewMode));
3601 openingCancelled = true;
3602 return 0;
3603 }
3604
3605 if (!d->prj || !item)
3606 return 0;
3608#ifndef KEXI_NO_PENDING_DIALOGS
3609 Private::PendingJobType pendingType;
3610 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
3611 if (pendingType != Private::NoJob) {
3612 openingCancelled = true;
3613 return 0;
3614 }
3615#else
3616 KexiDialogBase *dlg = d->openedDialogFor( item );
3617#endif
3618 openingCancelled = false;
3619
3620 bool needsUpdateViewGUIClient = true;
3621 if (dlg) {
3622 dlg->activate();
3623 if (viewMode!=dlg->currentViewMode()) {
3624 if (!switchToViewMode(viewMode))
3625 return 0;
3626 }
3627 needsUpdateViewGUIClient = false;
3628 }
3629 else {
3630 d->updatePropEditorVisibility(viewMode);
3631 KexiPart::Part *part = Kexi::partManager().partForMimeType(item->mimeType());
3632 //update tabs before opening
3633 updateCustomPropertyPanelTabs(d->curDialog ? d->curDialog->part() : 0,
3634 d->curDialog ? d->curDialog->currentViewMode() : Kexi::NoViewMode,
3635 part, viewMode);
3636
3637#ifndef KEXI_NO_PENDING_DIALOGS
3638 d->addItemToPendingDialogs(item, Private::DialogOpeningJob);
3639#endif
3640 dlg = d->prj->openObject(this, *item, viewMode, staticObjectArgs);
3641 }
3642
3643 if (!dlg || !activateWindow(dlg)) {
3644#ifndef KEXI_NO_PENDING_DIALOGS
3645 d->removePendingDialog(item->identifier());
3646#endif
3648 //js TODO: add error msg...
3649 return 0;
3650 }
3651
3652 if (needsUpdateViewGUIClient /*&& !userMode()*/) {
3653 //view changed: switch to this view's gui client
3654 KXMLGUIClient *viewClient=dlg->guiClient();
3655 updateDialogViewGUIClient(viewClient);
3656 if (d->curDialogViewGUIClient && !viewClient)
3657 guiFactory()->removeClient(d->curDialogViewGUIClient);
3658 d->curDialogViewGUIClient=viewClient; //remember
3659 }
3660
3662 if (viewMode!=dlg->currentViewMode())
3664
3665#ifndef KEXI_NO_PENDING_DIALOGS
3666 d->removePendingDialog( dlg->id() );
3667
3668 //perform pending global action that was suspended:
3669 if (!d->pendingDialogsExist()) {
3670 d->executeActionWhenPendingJobsAreFinished();
3671 }
3672#endif
3673 return dlg;
3674}
3675
3678{
3679 bool openingCancelled;
3680 return openObjectFromNavigator(item, viewMode, openingCancelled);
3681}
3682
3685 bool &openingCancelled)
3686{
3687 if (!openingAllowed(item, viewMode)) {
3688 openingCancelled = true;
3689 return 0;
3690 }
3691 if (!d->prj || !item)
3692 return 0;
3693#ifndef KEXI_NO_PENDING_DIALOGS
3694 Private::PendingJobType pendingType;
3695 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
3696 if (pendingType!=Private::NoJob) {
3697 openingCancelled = true;
3698 return 0;
3699 }
3700#else
3701 KexiDialogBase *dlg = d->openedDialogFor( item );
3702#endif
3703 openingCancelled = false;
3704 if (dlg) {
3705 if (activateWindow(dlg)) {//item->identifier())) {//just activate
3707 return dlg;
3708 }
3709 }
3710 //if DataViewMode is not supported, try Design, then Text mode (currently useful for script part)
3711 KexiPart::Part *part = Kexi::partManager().partForMimeType(item->mimeType());
3712 if (!part)
3713 return 0;
3714 if (viewMode == Kexi::DataViewMode && !(part->supportedViewModes() & Kexi::DataViewMode)) {
3715 if (part->supportedViewModes() & Kexi::DesignViewMode)
3716 return openObjectFromNavigator( item, Kexi::DesignViewMode, openingCancelled );
3717 else if (part->supportedViewModes() & Kexi::TextViewMode)
3718 return openObjectFromNavigator( item, Kexi::TextViewMode, openingCancelled );
3719 }
3720 //do the same as in openObject()
3721 return openObject(item, viewMode, openingCancelled);
3722}
3723
3725{
3726#ifndef KEXI_NO_PENDING_DIALOGS
3727 Private::PendingJobType pendingType;
3728 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
3729 if (pendingType == Private::DialogClosingJob)
3730 return true;
3731 else if (pendingType == Private::DialogOpeningJob)
3732 return cancelled;
3733#else
3734 KexiDialogBase *dlg = d->openedDialogFor( item );
3735#endif
3736 if (!dlg)
3737 return cancelled;
3738 return closeDialog(dlg);
3739}
3740
3741bool KexiMainWindowImpl::newObject( KexiPart::Info *info, bool& openingCancelled )
3742{
3743 if (userMode()) {
3744 openingCancelled = true;
3745 return false;
3746 }
3747 openingCancelled = false;
3748 if (!d->prj || !info)
3749 return false;
3751 if(!part)
3752 return false;
3753
3754#ifdef KEXI_ADD_CUSTOM_OBJECT_CREATION
3755# include "keximainwindowimpl_customobjcreation.h"
3756#endif
3757
3758 KexiPart::Item *it = d->prj->createPartItem(info); //this, *item, viewMode);
3759 if (!it) {
3760 //js: todo: err
3761 return false;
3762 }
3763
3764 if (!it->neverSaved()) //only add stored objects to the browser
3765 d->nav->addItem(*it);
3766 return openObject(it, Kexi::DesignViewMode, openingCancelled);
3767}
3768
3770{
3771 if (userMode())
3772 return cancelled;
3773 if (!d->prj || !item)
3774 return false;
3775
3776 KexiPart::Part *part = Kexi::partManager().partForMimeType(item->mimeType());
3777 if (!part)
3778 return false;
3779
3780 if (!dontAsk) {
3781 if (KMessageBox::No == KMessageBox::warningYesNo(this,
3782 "<p>"+i18n("Do you want to permanently delete:\n"
3783 "%1\n"
3784 "If you click \"Delete\", you will not be able to undo the deletion.")
3785 .arg( "</p><p>"+part->instanceCaption()+" \""+ item->name() + "\"?</p>" ),
3786 0, KGuiItem(i18n("Delete"), "edit-delete"), KStdGuiItem::no()))
3787 return cancelled;
3788 }
3789
3790 //also close 'print setup' dialog for this item, if any
3791 tristate res;
3792// int printedObjectID = 0;
3793// if (d->pageSetupDialogItemID2dataItemID_map.contains(item->identifier()))
3794// printedObjectID = d->pageSetupDialogItemID2dataItemID_map[ item->identifier() ];
3795 KexiDialogBase * pageSetupDlg = d->pageSetupDialogs[ item->identifier() ];
3796 const bool oldInsideCloseDialog = d->insideCloseDialog;
3797 d->insideCloseDialog = false;
3798 res = closeDialog(pageSetupDlg);
3799 d->insideCloseDialog = oldInsideCloseDialog;
3800 if (!res || ~res) {
3801 return res;
3802 }
3803
3804#ifndef KEXI_NO_PENDING_DIALOGS
3805 Private::PendingJobType pendingType;
3806 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
3807 if (pendingType!=Private::NoJob) {
3808 return cancelled;
3809 }
3810#else
3811 KexiDialogBase *dlg = d->openedDialogFor( item );
3812#endif
3813
3814 if (dlg) {//close existing window
3815// if (!dlg->tryClose(true))
3816 const bool tmp = d->forceDialogClosing;
3817 /*const bool remove_on_closing = */dlg->partItem()->neverSaved();
3818 d->forceDialogClosing = true;
3819 res = closeDialog(dlg);
3820 d->forceDialogClosing = tmp; //restore
3821 if (!res || ~res) {
3822 return res;
3823 }
3824// if (remove_on_closing) //already removed
3825 // return true;
3826// if (!dlg->close(true))
3827// return true; //ok - close cancelled
3828 }
3829
3830 //in case the dialog is a 'print setup' dialog, also update d->pageSetupDialogs
3831 int dataItemID = d->pageSetupDialogItemID2dataItemID_map[item->identifier()];
3832 d->pageSetupDialogItemID2dataItemID_map.remove(item->identifier());
3833 d->pageSetupDialogs.take( dataItemID );
3834
3835 if (!d->prj->removeObject(this, *item)) {
3836 //TODO(js) better msg
3837 showSorryMessage( i18n("Could not remove object.") );
3838 return false;
3839 }
3840 return true;
3841}
3842
3843void KexiMainWindowImpl::renameObject( KexiPart::Item *item, const TQString& _newName, bool &success )
3844{
3845 if (userMode()) {
3846 success = false;
3847 return;
3848 }
3849 d->pendingDialogsExist();
3850 TQString newName = _newName.stripWhiteSpace();
3851 if (newName.isEmpty()) {
3852 showSorryMessage( i18n("Could not set empty name for this object.") );
3853 success = false;
3854 return;
3855 }
3856 enableMessages(false); //to avoid double messages
3857 const bool res = d->prj->renameObject(this, *item, newName);
3858 enableMessages(true);
3859 if (!res) {
3860 showErrorMessage( d->prj, i18n("Renaming object \"%1\" failed.").arg(newName) );
3861 success = false;
3862 return;
3863 }
3864 d->pendingDialogsExist();
3865}
3866
3867void KexiMainWindowImpl::slotObjectRenamed(const KexiPart::Item &item, const TQCString& /*oldName*/)
3868{
3869#ifndef KEXI_NO_PENDING_DIALOGS
3870 Private::PendingJobType pendingType;
3871 KexiDialogBase *dlg = d->openedDialogFor( &item, pendingType );
3872 if (pendingType!=Private::NoJob)
3873 return;
3874#else
3875 KexiDialogBase *dlg = d->openedDialogFor( &item );
3876#endif
3877 if (!dlg)
3878 return;
3879
3880 //change item
3881 dlg->updateCaption();
3882 if (static_cast<KexiDialogBase*>(d->curDialog)==dlg)//optionally, update app. caption
3884}
3885
3887{
3888 return --d->privateIDCounter;
3889}
3890
3892{
3893 if (d->propEditor)
3894 d->propEditor->editor()->acceptInput();
3895}
3896
3897void KexiMainWindowImpl::propertySetSwitched(KexiDialogBase *dlg, bool force,
3898 bool preservePrevSelection, const TQCString& propertyToSelect)
3899{
3900 kdDebug() << "KexiMainWindowImpl::propertySetSwitched() d->curDialog: "
3901 << (d->curDialog ? d->curDialog->caption() : TQString("NULL")) << " dlg: " << (dlg ? dlg->caption() : TQString("NULL"))<< endl;
3902 if ((KexiDialogBase*)d->curDialog!=dlg) {
3903 d->propBuffer = 0; //we'll need to move to another prop. set
3904 return;
3905 }
3906 if (d->propEditor) {
3907 KoProperty::Set *newBuf = d->curDialog ? d->curDialog->propertySet() : 0;
3908 if (!newBuf || (force || static_cast<KoProperty::Set*>(d->propBuffer) != newBuf)) {
3909 d->propBuffer = newBuf;
3910 if (preservePrevSelection) {
3911 if (propertyToSelect.isEmpty())
3912 d->propEditor->editor()->changeSet( d->propBuffer, preservePrevSelection );
3913 else
3914 d->propEditor->editor()->changeSet( d->propBuffer, propertyToSelect );
3915 }
3916 }
3917 }
3918}
3919
3921{
3922 KexiPart::Item *item = dlg->partItem();
3923 //update text in navigator and app. caption
3924 if(!userMode())
3925 d->nav->updateItemName( *item, dlg->dirty() );
3926
3929}
3930
3931void KexiMainWindowImpl::slotMdiModeHasBeenChangedTo(KMdi::MdiMode)
3932{
3933 //after switching to other MDI mode, pointer to current dialog needs to be updated
3934 activateFirstWin();
3935 activeWindowChanged(activeWindow());
3936}
3937
3938void KexiMainWindowImpl::slotTipOfTheDay()
3939{
3940 //todo
3941}
3942
3947
3948void KexiMainWindowImpl::slotStartFeedbackAgent()
3949{
3950#ifndef KEXI_NO_FEEDBACK_AGENT
3951#ifdef FEEDBACK_CLASS
3952 const TDEAboutData* about = TDEApplication::kApplication()->aboutData();
3953 FEEDBACK_CLASS* wizard = new FEEDBACK_CLASS( about->programName(),
3954 about->version(), 0, 0, 0, FEEDBACK_CLASS::AllPages );
3955
3956 if ( wizard->exec() )
3957 {
3958 TDEApplication::kApplication()->invokeMailer( "kexi-reports-dummy@kexi.org",
3959 TQString(), TQString(),
3960 about->appName() + TQCString( " [feedback]" ),
3961 wizard->feedbackDocument().toString( 2 ).local8Bit() );
3962 }
3963
3964 delete wizard;
3965#endif
3966#endif
3967}
3968
3970{
3971#if 0
3972 if (onStartup && !d->showImportantInfoOnStartup)
3973 return;
3974
3975 TQString key = TQString("showImportantInfo %1").arg(KEXI_VERSION_STRING);
3976 d->config->setGroup("Startup");
3977 bool show = d->config->readBoolEntry(key,true);
3978
3979 if (show || !onStartup) { //if !onStartup - dialog is always shown
3980 d->config->setGroup("TipOfDay");
3981 if (!d->config->hasKey("RunOnStart"))
3982 d->config->writeEntry("RunOnStart",true);
3983
3984 TQString lang = TDEGlobal::locale()->language();
3985 TQString fname = locate("data", TQString("kexi/readme_")+lang);
3986 if (fname.isEmpty())//back to default
3987 fname = locate("data", "kexi/readme_en");
3988 KTipDialog tipDialog(new KTipDatabase(TQString()), 0);
3989 tipDialog.setCaption(i18n("Important Information"));
3990 TQObjectList *l = tipDialog.queryList( "KPushButton" );//hack: hide <- -> buttons
3991 int i=0;
3992 for (TQObjectListIt it( *l ); it.current() && i<2; ++it, i++ )
3993 static_cast<KPushButton*>(it.current())->hide();
3994 TQFile f(fname);
3995 if ( f.open( IO_ReadOnly ) ) {
3996 TQTextStream ts(&f);
3997 ts.setCodec( TDEGlobal::locale()->codecForEncoding() );
3998 TQTextBrowser *tb = KexiUtils::findFirstChild<KTextBrowser>(&tipDialog,"KTextBrowser");
3999 if (tb) {
4000 tb->setText( TQString("<qt>%1</qt>").arg(ts.read()) );
4001 }
4002 f.close();
4003 }
4004
4005 tipDialog.adjustSize();
4006 TQRect desk = TQApplication::desktop()->screenGeometry( TQApplication::desktop()->screenNumber(this) );
4007 tipDialog.resize( TQMAX(tipDialog.width(),desk.width()*3/5), TQMAX(tipDialog.height(),desk.height()*3/5) );
4008 KDialog::centerOnScreen(&tipDialog);
4009 tipDialog.setModal ( true );
4010 tipDialog.exec();
4011 //a hack: get user's settings
4012 d->config->setGroup("TipOfDay");
4013 show = d->config->readBoolEntry("RunOnStart", show);
4014 }
4015
4016 //write our settings back
4017 d->config->setGroup("Startup");
4018 d->config->writeEntry(key,show);
4019 d->showImportantInfoOnStartup = false;
4020#endif
4021}
4022
4023void KexiMainWindowImpl::slotOptionsEnableForms(bool show, bool noMessage)
4024{
4025 Q_UNUSED(noMessage);
4026 Kexi::tempShowForms() = show;
4027}
4028
4030{
4031 return d->userMode;
4032}
4033
4034bool
4036{
4037// Kexi::tempShowForms() = true;
4038// Kexi::tempShowReports() = true;
4039// Kexi::tempShowMacros() = true;
4040// Kexi::tempShowScripts() = true;
4041 if(!projectData)
4042 return false;
4043
4044 createKexiProject(projectData); //initialize project
4045// d->prj->setFinal(true); //announce that we are in fianl mode
4046
4047 tristate res = d->prj->open(); //try to open database
4048 if (!res || ~res) {
4049 delete d->prj;
4050 d->prj = 0;
4051 return false;
4052 }
4053
4054#if 0 //todo reenable; autoopen objects are handled elsewhere
4055 KexiDB::TableSchema *sch = d->prj->dbConnection()->tableSchema("kexi__final");
4056 TQString err_msg = i18n("Could not start project \"%1\" in Final Mode.")
4057 .arg(static_cast<KexiDB::SchemaData*>(projectData)->name());
4058 if(!sch)
4059 {
4060 hide();
4061 showErrorMessage( err_msg, i18n("No Final Mode data found.") );
4062 return false;
4063 }
4064
4065 KexiDB::Cursor *c = d->prj->dbConnection()->executeQuery(*sch);
4066 if(!c)
4067 {
4068 hide();
4069 showErrorMessage( err_msg, i18n("Error reading Final Mode data.") );
4070 return false;
4071 }
4072
4073 TQString startupPart;
4074 TQString startupItem;
4075 while(c->moveNext())
4076 {
4077 kdDebug() << "KexiMainWinImpl::initFinalMode(): property: [" << c->value(1).toString() << "] " << c->value(2).toString() << endl;
4078 if(c->value(1).toString() == "startup-part")
4079 startupPart = c->value(2).toString();
4080 else if(c->value(1).toString() == "startup-item")
4081 startupItem = c->value(2).toString();
4082 else if(c->value(1).toString() == "mainxmlui")
4083 setXML(c->value(2).toString());
4084 }
4085 d->prj->dbConnection()->deleteCursor(c);
4086
4087 kdDebug() << "KexiMainWinImpl::initFinalMode(): part: " << startupPart << endl;
4088 kdDebug() << "KexiMainWinImpl::initFinalMode(): item: " << startupItem << endl;
4089
4090 initActions();
4092 guiFactory()->addClient(this);
4093 setStandardToolBarMenuEnabled(false);
4094 setHelpMenuEnabled(false);
4095
4096 KexiPart::Info *i = Kexi::partManager().infoForMimeType(startupPart.latin1());
4097 if (!i) {
4098 hide();
4099 showErrorMessage( err_msg, i18n("Specified plugin does not exist.") );
4100 return false;
4101 }
4102
4104 KexiPart::Item *item = d->prj->item(i, startupItem);
4105 bool openingCancelled;
4106 if(!openObject(item, Kexi::DataViewMode, openingCancelled) && !openingCancelled) {
4107 hide();
4108 showErrorMessage( err_msg, i18n("Specified object could not be opened.") );
4109 return false;
4110 }
4111
4112 TQWidget::setCaption("MyApp");//TODO
4113#endif
4114 return true;
4115}
4116
4117void
4119{
4120#if 0 //unused for now
4121 KexiDB::Cursor *c = d->prj->dbConnection()->executeQuery("SELECT p_id, name, text, icon, method, arguments FROM kexi__useractions WHERE scope = 0");
4122 if(!c)
4123 return;
4124
4125 while(c->moveNext())
4126 {
4127 KexiUserAction::fromCurrentRecord(this, actionCollection(), c);
4128 }
4129 d->prj->dbConnection()->deleteCursor(c);
4130/*
4131 KexiUserAction *a1 = new KexiUserAction(this, actionCollection(), "user_dataview", "Change to dataview", "table");
4132 Arguments args;
4133 args.append(TQVariant("kexi/table"));
4134 args.append(TQVariant("persons"));
4135 a1->setMethod(KexiUserAction::OpenObject, args);
4136*/
4137#endif
4138}
4139
4140void KexiMainWindowImpl::slotToolsProjectMigration()
4141{
4142 showProjectMigrationWizard(TQString(), TQString());
4143}
4144
4146{
4147 KexiProjectData *data = 0;
4148 KexiDB::Driver *drv = 0;
4149 const bool projectWasOpened = d->prj;
4150
4151 if (!d->prj) {
4153 KexiStartupDialog::OpenExisting, 0, Kexi::connset(), Kexi::recentProjects(),
4154 this, "KexiOpenDialog");
4155
4156 if (dlg.exec()!=TQDialog::Accepted)
4157 return;
4158
4159 if (dlg.selectedFileName().isEmpty()) {
4161 return;
4162 }
4164 cdata.setFileName( dlg.selectedFileName() );
4165
4166 //detect driver name for the selected file
4167 KexiStartupData::Import detectedImportAction;
4169 detectedImportAction, cdata.driverName,
4170 "" /*suggestedDriverName*/, cdata.fileName(), 0,
4173
4174 if (true==res && !detectedImportAction)
4175 drv = Kexi::driverManager().driver( cdata.driverName );
4176 if (!drv || !(drv->features() & KexiDB::Driver::CompactingDatabaseSupported)) {
4177 KMessageBox::information(this, "<qt>"+
4178 i18n("Compacting database file <nobr>\"%1\"</nobr> is not supported.")
4179 .arg(TQDir::convertSeparators(cdata.fileName())));
4180 return;
4181 }
4182 data = new KexiProjectData( cdata, cdata.fileName() );
4183 }
4184 else {
4185 //sanity
4186 if ( !(d->prj && d->prj->dbConnection()
4187 && (d->prj->dbConnection()->driver()->features() & KexiDB::Driver::CompactingDatabaseSupported) ))
4188 return;
4189
4190 if (KMessageBox::Continue != KMessageBox::warningContinueCancel(this,
4191 i18n("The current project has to be closed before compacting the database. "
4192 "It will be open again after compacting.\n\nDo you want to continue?")))
4193 return;
4194
4195 data = new KexiProjectData(*d->prj->data()); // a copy
4196 drv = d->prj->dbConnection()->driver();
4197 const tristate res = closeProject();
4198 if (~res || !res) {
4199 delete data;
4200 return;
4201 }
4202 }
4203
4204 if (!drv->adminTools().vacuum(*data->connectionData(), data->databaseName())) {
4205 //err msg
4206 showErrorMessage( &drv->adminTools() );
4207 }
4208
4209 if (projectWasOpened)
4210 openProject(*data);
4211 delete data;
4212}
4213
4215 const TQString& mimeType, const TQString& databaseName, const KexiDB::ConnectionData *cdata)
4216{
4217 //pass arguments
4218 TQMap<TQString,TQString> args;
4219 args.insert("mimeType", mimeType);
4220 args.insert("databaseName", databaseName);
4221 if (cdata) { //pass ConnectionData serialized as a string...
4222 TQString str;
4223 KexiUtils::serializeMap( KexiDB::toMap( *cdata ), str );
4224 args.insert("connectionData", str);
4225 }
4226
4227 TQDialog *dlg = KexiInternalPart::createModalDialogInstance("migration", this, this, 0, &args);
4228 if (!dlg)
4229 return false; //error msg has been shown by KexiInternalPart
4230
4231 const int result = dlg->exec();
4232 delete dlg;
4233 //raise();
4234 if (result!=TQDialog::Accepted)
4235 return cancelled;
4236
4237 //open imported project in a new Kexi instance
4238 TQString destinationDatabaseName( args["destinationDatabaseName"] );
4239 TQString fileName, destinationConnectionShortcut, dbName;
4240 if (!destinationDatabaseName.isEmpty()) {
4241 if (args.contains("destinationConnectionShortcut")) {
4242 // server-based
4243 destinationConnectionShortcut = args["destinationConnectionShortcut"];
4244 }
4245 else {
4246 // file-based
4247 fileName = destinationDatabaseName;
4248 destinationDatabaseName = TQString();
4249 }
4250 tristate res = openProject(fileName, destinationConnectionShortcut,
4251 destinationDatabaseName);
4252 raise();
4253 return res;
4254// KexiDB::ConnectionData *connData = new KexiDB::ConnectionData();
4255// KexiDB::fromMap( KexiUtils::deserializeMap( args["destinationConnectionData"] ), *connData );
4256// return openProject(destinationFileName, 0);
4257 }
4258 return true;
4259}
4260
4262{
4263 KexiPart::Info *info = item ? Kexi::partManager().infoForMimeType(item->mimeType()) : 0;
4264 if ( (! info) || (! info->isExecuteSupported()) )
4265 return false;
4266 KexiPart::Part *part = Kexi::partManager().part(info);
4267 if (!part)
4268 return false;
4269 return part->execute(item);
4270}
4271
4273{
4275 if (userMode())
4276 return;
4277 TQMap<TQString,TQString> args;
4278 args.insert("sourceType", "file");
4280 "csv_importexport", "KexiCSVImportDialog", this, this, 0, &args);
4281 if (!dlg)
4282 return; //error msg has been shown by KexiInternalPart
4283 dlg->exec();
4284 delete dlg;
4285}
4286
4288 const TQString& actionName)
4289{
4290 if (actionName == "exportToCSV")
4291 return exportItemAsDataTable(item);
4292 else if (actionName == "copyToClipboardAsCSV")
4293 return copyItemToClipboardAsDataTable(item);
4294
4295 kexiwarn << "KexiMainWindowImpl::executeCustomActionForObject(): no such action: "
4296 << actionName << endl;
4297 return false;
4298}
4299
4301{
4302 if (!item)
4303 return false;
4306
4307 TQMap<TQString,TQString> args;
4308 args.insert("destinationType", "file");
4309 args.insert("itemId", TQString::number(item->identifier()));
4311 "csv_importexport", "KexiCSVExportWizard", this, this, 0, &args);
4312 if (!dlg)
4313 return false; //error msg has been shown by KexiInternalPart
4314 int result = dlg->exec();
4315 delete dlg;
4316 return result == TQDialog::Rejected ? cancelled : true;
4317}
4318
4319bool KexiMainWindowImpl::printItem(KexiPart::Item* item, const TQString& titleText)
4320{
4321 return printItem(item, KexiSimplePrintingSettings::load(), titleText);
4322}
4323
4325{
4326 return printItem(item, TQString());
4327}
4328
4330 const TQString& titleText)
4331{
4334 KexiSimplePrintingCommand cmd(this, item->identifier());
4335 //modal
4336 return cmd.print(settings, titleText);
4337}
4338
4339bool KexiMainWindowImpl::printPreviewForItem(KexiPart::Item* item, const TQString& titleText, bool reload)
4340{
4341 return printPreviewForItem(item, KexiSimplePrintingSettings::load(), titleText, reload);
4342}
4343
4345{
4346 return printPreviewForItem(item, TQString(),
4348 true/*reload*/);
4349}
4350
4352 const KexiSimplePrintingSettings& settings, const TQString& titleText, bool reload)
4353{
4356 KexiSimplePrintingCommand* cmd = d->openedCustomObjectsForItem<KexiSimplePrintingCommand>(
4357 item, "KexiSimplePrintingCommand");
4358 if (!cmd) {
4359 d->addOpenedCustomObjectForItem(
4360 item,
4361 cmd = new KexiSimplePrintingCommand(this, item->identifier()),
4362 "KexiSimplePrintingCommand"
4363 );
4364 }
4365 return cmd->showPrintPreview(settings, titleText, reload);
4366}
4367
4369{
4372 return printActionForItem(item, PageSetupForItem);
4373}
4374
4376{
4377 if (!item)
4378 return false;
4379 KexiPart::Info *info = Kexi::partManager().infoForMimeType( item->mimeType() );
4380 if (!info->isPrintingSupported())
4381 return false;
4382
4383 KexiDialogBase *printingDialog = d->pageSetupDialogs[ item->identifier() ];
4384 if (printingDialog) {
4385 if (!activateWindow(printingDialog))
4386 return false;
4387 if (action == PreviewItem || action == PrintItem) {
4388 TQTimer::singleShot(0,printingDialog->selectedView(),
4389 (action == PreviewItem) ? TQ_SLOT(printPreview()) : TQ_SLOT(print()));
4390 }
4391 return true;
4392 }
4393
4394#ifndef KEXI_NO_PENDING_DIALOGS
4395 Private::PendingJobType pendingType;
4396 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
4397 if (pendingType!=Private::NoJob)
4398 return cancelled;
4399#else
4400 KexiDialogBase *dlg = d->openedDialogFor( item );
4401#endif
4402
4403 if (dlg) {
4404 // accept row changes
4405 TQWidget *prevFocusWidget = focusWidget();
4406 dlg->setFocus();
4407 d->action_data_save_row->activate();
4408 if (prevFocusWidget)
4409 prevFocusWidget->setFocus();
4410
4411 // opened: check if changes made to this dialog are saved, if not: ask for saving
4412 if (dlg->neverSaved()) //sanity check
4413 return false;
4414 if (dlg->dirty()) {
4415 KGuiItem saveChanges( KStdGuiItem::save() );
4416 saveChanges.setToolTip(i18n("Save changes"));
4417 saveChanges.setWhatsThis(
4418 i18n( "Pressing this button will save all recent changes made in \"%1\" object." )
4419 .arg(item->name()) );
4420 KGuiItem doNotSave( KStdGuiItem::no() );
4421 doNotSave.setWhatsThis(
4422 i18n( "Pressing this button will ignore all unsaved changes made in \"%1\" object." )
4423 .arg(dlg->partItem()->name()) );
4424
4425 TQString question;
4426 if (action == PrintItem)
4427 question = i18n("Do you want to save changes before printing?");
4428 else if (action == PreviewItem)
4429 question = i18n("Do you want to save changes before making print preview?");
4430 else if (action == PageSetupForItem)
4431 question = i18n("Do you want to save changes before showing page setup?");
4432 else
4433 return false;
4434
4435 const int questionRes = KMessageBox::warningYesNoCancel( this,
4436 "<p>"+dlg->part()->i18nMessage("Design of object \"%1\" has been modified.", dlg)
4437 .arg(item->name()) + "</p><p>" + question + "</p>",
4438 TQString(),
4439 saveChanges,
4440 doNotSave);
4441 if (KMessageBox::Cancel == questionRes)
4442 return cancelled;
4443 if (KMessageBox::Yes == questionRes) {
4444 tristate savingRes = saveObject( dlg, TQString(), true /*dontAsk*/ );
4445 if (true != savingRes)
4446 return savingRes;
4447 }
4448 }
4449 }
4450 KexiPart::Part * printingPart = Kexi::partManager().partForMimeType("kexi/simpleprinting");
4451 if (!printingPart)
4452 printingPart = new KexiSimplePrintingPart(); //hardcoded as there're no .desktop file
4453 KexiPart::Item* printingPartItem = d->prj->createPartItem(
4454 printingPart, item->name() //<-- this will look like "table1 : printing" on the window list
4455 );
4456 TQMap<TQString,TQString> staticObjectArgs;
4457 staticObjectArgs["identifier"] = TQString::number(item->identifier());
4458 if (action == PrintItem)
4459 staticObjectArgs["action"] = "print";
4460 else if (action == PreviewItem)
4461 staticObjectArgs["action"] = "printPreview";
4462 else if (action == PageSetupForItem)
4463 staticObjectArgs["action"] = "pageSetup";
4464 else
4465 return false;
4466 bool openingCancelled;
4467 printingDialog = openObject(printingPartItem, Kexi::DesignViewMode,
4468 openingCancelled, &staticObjectArgs);
4469 if (openingCancelled)
4470 return cancelled;
4471 if (!printingDialog) //sanity
4472 return false;
4473 d->pageSetupDialogs.insert(item->identifier(), printingDialog);
4474 d->pageSetupDialogItemID2dataItemID_map.insert(
4475 printingDialog->partItem()->identifier(), item->identifier());
4476
4477 return true;
4478}
4479
4480void KexiMainWindowImpl::slotEditCopySpecialDataTable()
4481{
4482 KexiPart::Item* item = d->nav->selectedPartItem();
4483 if (item)
4485}
4486
4488{
4489 if (!item)
4490 return false;
4491
4492 TQMap<TQString,TQString> args;
4493 args.insert("destinationType", "clipboard");
4494 args.insert("itemId", TQString::number(item->identifier()));
4496 "csv_importexport", "KexiCSVExportWizard", this, this, 0, &args);
4497 if (!dlg)
4498 return false; //error msg has been shown by KexiInternalPart
4499 const int result = dlg->exec();
4500 delete dlg;
4501 return result == TQDialog::Rejected ? cancelled : true;
4502}
4503
4505{
4507 if (userMode())
4508 return;
4509 TQMap<TQString,TQString> args;
4510 args.insert("sourceType", "clipboard");
4512 "csv_importexport", "KexiCSVImportDialog", this, this, 0, &args);
4513 if (!dlg)
4514 return; //error msg has been shown by KexiInternalPart
4515 dlg->exec();
4516 delete dlg;
4517}
4518
4519void KexiMainWindowImpl::slotEditFind()
4520{
4521// KexiViewBase *view = d->currentViewSupportingAction("edit_findnext");
4522 KexiSearchAndReplaceViewInterface* iface = d->currentViewSupportingSearchAndReplaceInterface();
4523 if (!iface)
4524 return;
4525 d->updateFindDialogContents(true/*create if does not exist*/);
4526 d->findDialog()->setReplaceMode(false);
4527
4528 d->findDialog()->show();
4529 d->findDialog()->setActiveWindow();
4530 d->findDialog()->raise();
4531}
4532
4533void KexiMainWindowImpl::slotEditFind(bool next)
4534{
4535 KexiSearchAndReplaceViewInterface* iface = d->currentViewSupportingSearchAndReplaceInterface();
4536 if (!iface)
4537 return;
4538 tristate res = iface->find(
4539 d->findDialog()->valueToFind(), d->findDialog()->options(), next);
4540 if (~res)
4541 return;
4542 d->findDialog()->updateMessage( true == res );
4544}
4545
4546void KexiMainWindowImpl::slotEditFindNext()
4547{
4548 slotEditFind( true );
4549}
4550
4551void KexiMainWindowImpl::slotEditFindPrevious()
4552{
4553 slotEditFind( false );
4554}
4555
4557{
4558 KexiSearchAndReplaceViewInterface* iface = d->currentViewSupportingSearchAndReplaceInterface();
4559 if (!iface)
4560 return;
4561 d->updateFindDialogContents(true/*create if does not exist*/);
4562 d->findDialog()->setReplaceMode(true);
4564 d->findDialog()->show();
4565 d->findDialog()->setActiveWindow();
4566}
4567
4568void KexiMainWindowImpl::slotEditReplaceNext()
4569{
4570 slotEditReplace( false );
4571}
4572
4574{
4575 KexiSearchAndReplaceViewInterface* iface = d->currentViewSupportingSearchAndReplaceInterface();
4576 if (!iface)
4577 return;
4580 tristate res = iface->findNextAndReplace(
4581 d->findDialog()->valueToFind(), d->findDialog()->valueToReplaceWith(),
4582 d->findDialog()->options(), all);
4583 d->findDialog()->updateMessage( true == res );
4585}
4586
4587void KexiMainWindowImpl::slotEditReplaceAll()
4588{
4589 slotEditReplace( true );
4590}
4591
4592void KexiMainWindowImpl::addWindow( KMdiChildView* pView, int flags )
4593{
4594 //maximize this window, if it's
4597 if (d->maximizeFirstOpenedChildFrm) {
4598 flags |= KMdi::Maximize;
4599 d->maximizeFirstOpenedChildFrm = false;
4600 }
4601 KexiMainWindow::addWindow( pView, flags );
4602}
4603
4606{
4607#ifdef HAVE_TDENEWSTUFF
4608 if(!d->newStuff)
4609 d->newStuff = new KexiNewStuff(this);
4610 d->newStuff->download();
4611
4612 //KNS::DownloadDialog::open(newstuff->customEngine(), "kexi/template");
4613#endif
4614}
4615
4616void KexiMainWindowImpl::highlightObject(const TQCString& mime, const TQCString& name)
4617{
4618 slotViewNavigator();
4619 if (!d->prj)
4620 return;
4621 KexiPart::Item *item = d->prj->itemForMimeType(mime, name);
4622 if (!item)
4623 return;
4624 if (d->nav) {
4625 d->nav->selectItem(*item);
4626 }
4627}
4628
4630{
4631 Q_UNUSED(item);
4632}
4633
4634#include "keximainwindowimpl.moc"
Like TQSplitter but specially designed for dockwidgets stuff.
Definition ksplitter.h:47
void setSeparatorPosInPercent(int percent)
Set the separator position in percent (%), so the range must be [0..100].
int separatorPosInPercent()
Return the separator position in percent (%), so the range is [0..100].
The Main Kexi navigator widget.
Definition kexibrowser.h:52
TQString fileNameForConnectionData(KexiDB::ConnectionData *data) const
KexiDB::ConnectionData * connectionDataForFileName(const TQString &fileName) const
virtual bool vacuum(const ConnectionData &data, const TQString &databaseName)
Definition admin.cpp:36
bool savePassword
True if password should be saved to a file for the connection.
TQString caption
The caption of the connection.
TQString password
Password used for the connection.
TQString driverName
the name of the driver that should be used to create a connection
Database specific connection data, e.g. host, port.
void setFileName(const TQString &fn)
Set the filename used by the connection.
TQString serverInfoString(bool addUser=true) const
A user-friendly string for the server.
TQString fileName() const
Get the filename used by the connection.
TQString dbFileName() const
The file name (without path) of the database file.
tristate loadObjectSchemaData(int objectID, SchemaData &sdata)
Provides database cursor functionality.
Definition cursor.h:67
virtual bool moveNext()
Definition cursor.cpp:292
virtual TQVariant value(uint i)=0
Driver * driver(const TQString &name)
Generic database abstraction.
Definition driver.h:67
@ CompactingDatabaseSupported
Definition driver.h:104
static TQString defaultFileBasedDriverName()
Definition driver.cpp:140
int features() const
Definition driver.cpp:152
static TQString defaultFileBasedDriverMimeType()
Definition driver.cpp:137
AdminTools & adminTools() const
Definition driver.cpp:158
void enableMessages(bool enable)
Definition msghandler.h:68
const TQString & errorMsg() const
Definition object.h:42
Base class for child window of Kexi's main application window.
tristate storeNewData()
int currentViewMode() const
bool neverSaved() const
KexiPart::GUIClient * commonGUIClient() const
virtual void attachToGUIClient()
KexiPart::GUIClient * guiClient() const
KexiPart::Part * part() const
tristate storeData(bool dontAsk=false)
KexiPart::Item * partItem() const
KexiViewBase * selectedView() const
bool dirty() const
static KexiDialogBase * createKexiDialogInstance(const char *partName, KexiDB::MessageHandler *msgHdr, KexiMainWindow *mainWin, const char *objName=0)
static TQDialog * createModalDialogInstance(const char *partName, const char *dialogClass, KexiDB::MessageHandler *msgHdr, KexiMainWindow *mainWin, const char *objName=0, TQMap< TQString, TQString > *args=0)
void slotImportantInfo()
just importantInfo(false);
bool switchToViewMode(int viewMode)
void createKexiProject(KexiProjectData *new_data)
internal - creates and initializes kexi project
virtual void slotObjectRenamed(const KexiPart::Item &item, const TQCString &oldName)
void slotDirtyFlagChanged(KexiDialogBase *)
virtual KexiDialogBase * currentDialog() const
virtual tristate showPageSetupForItem(KexiPart::Item *item)
virtual bool acceptsSharedActions(TQObject *w)
static int create(int argc, char *argv[], TDEAboutData *aboutdata=0)
virtual tristate closeObject(KexiPart::Item *item)
virtual void highlightObject(const TQCString &mime, const TQCString &name)
virtual tristate closeDialog(KexiDialogBase *dlg)
void initActions()
reimplementation of events
virtual tristate printItem(KexiPart::Item *item)
KexiDialogBase * openObjectFromNavigator(KexiPart::Item *item, int viewMode, bool &openingCancelled)
virtual KexiProject * project()
Project data of currently opened project or NULL if no project here yet.
virtual bool eventFilter(TQObject *obj, TQEvent *e)
virtual tristate getNewObjectInfo(KexiPart::Item *partItem, KexiPart::Part *part, bool &allowOverwriting, const TQString &messageWhenAskingForName=TQString())
void projectOpened()
Emitted after opening a project, even after slotAutoOpenObjectsLater().
virtual void switchToIDEAlMode()
reimplemented to add "restart is required" message box
virtual void closeWindow(KMdiChildView *pWnd, bool layoutTaskBar=true)
virtual void invalidateSharedActions(TQObject *o)
void slotViewTextMode()
sometimes called "SQL View"
virtual bool userMode() const
tristate executeItem(KexiPart::Item *item)
bool initUserMode(KexiProjectData *projectData)
virtual void addWindow(KMdiChildView *pView, int flags=KMdi::StandardAdd)
virtual KexiDialogBase * openObject(KexiPart::Item *item, int viewMode, bool &openingCancelled, TQMap< TQString, TQString > *staticObjectArgs=0, TQString *errorMessage=0)
virtual TQPopupMenu * findPopupMenu(const char *popupName)
void importantInfo(bool onStartup)
Shows 'important info' dialog, is onStartup is false, it's always shown.
virtual void registerChild(KexiDialogBase *dlg)
void activeWindowChanged(KMdiChildView *dlg)
void childClosed(KMdiChildView *dlg)
void slotLastActions()
There are performed all actions that need to be done immediately after ctro (using timer).
void updateCustomPropertyPanelTabs(KexiDialogBase *prevDialog, int prevViewMode)
tristate printActionForItem(KexiPart::Item *item, PrintActionType action)
tristate copyItemToClipboardAsDataTable(KexiPart::Item *item)
Shows "copy special as data table" dialog for item.
void updateDialogViewGUIClient(KXMLGUIClient *viewClient)
TQWidget * findWindow(TQWidget *w)
void slotPartItemSelectedInNavigator(KexiPart::Item *item)
Receives "selectionChanged()" signal from navigator to update some actions.
virtual tristate executeCustomActionForObject(KexiPart::Item *item, const TQString &actionName)
tristate openProjectInExternalKexiInstance(const TQString &aFileName, KexiDB::ConnectionData *cdata, const TQString &dbName)
tristate exportItemAsDataTable(KexiPart::Item *item)
Shows "exports as data table" dialog for item.
virtual tristate printPreviewForItem(KexiPart::Item *item)
bool openingAllowed(KexiPart::Item *item, int viewMode)
tristate openProject(const KexiProjectData &projectData)
virtual TDEActionPtrList allActions() const
virtual void readProperties(TDEConfig *config)
void slotCaptionForCurrentMDIChild(bool childrenMaximized)
internal
tristate removeObject(KexiPart::Item *item, bool dontAsk=false)
tristate showProjectMigrationWizard(const TQString &mimeType, const TQString &databaseName, const KexiDB::ConnectionData *cdata=0)
void renameObject(KexiPart::Item *item, const TQString &_newName, bool &succes)
void slotGetNewStuff()
TMP: Display a dialog to download db examples from internet.
KexiProjectData * createBlankProjectData(bool &cancelled, bool confirmOverwrites=true, TQString *shortcutFileName=0)
tristate createProjectFromTemplate(const KexiProjectData &projectData)
virtual bool newObject(KexiPart::Info *info, bool &openingCancelled)
virtual tristate saveObject(KexiDialogBase *dlg, const TQString &messageWhenAskingForName=TQString(), bool dontAsk=false)
PrintActionType
Used by printActionForItem().
void beforeProjectClosing()
virtual void acceptPropertySetEditing()=0
void acceptProjectClosingRequested(bool &cancel)
void projectClosed()
Emitted after closing the project.
Information about a Kexi Part (plugin).
bool isDataExportSupported() const
int projectPartID() const
TQCString mimeType() const
bool isPrintingSupported() const
TQString itemIcon() const
bool isExecuteSupported() const
Information about a single object that can be instantiated using Kexi Part.
bool neverSaved() const
Part * partForMimeType(const TQString &mimeTypt)
Info * infoForMimeType(const TQString &mimeType)
The main class for kexi frontend parts like tables, queries, forms and reports.
Definition kexipart.h:66
void createGUIClients(KexiMainWindow *win)
Definition kexipart.cpp:121
int supportedViewModes() const
Definition kexipart.h:98
int supportedUserViewModes() const
Definition kexipart.h:106
virtual void setupCustomPropertyPanelTabs(KTabWidget *tab, KexiMainWindow *mainWin)
Definition kexipart.cpp:404
TQString instanceCaption() const
Definition kexipart.cpp:415
virtual bool execute(KexiPart::Item *item, TQObject *sender=0)
Definition kexipart.h:85
virtual TQString i18nMessage(const TQCString &englishMessage, KexiDialogBase *dlg) const
Definition kexipart.cpp:398
Kexi project core data member.
TQValueList< ObjectInfo > autoopenObjects
bool userMode() const
TQString infoString(bool nobr=true) const
TQString databaseName() const
void addProjectData(KexiProjectData *data)
A project's main controller.
Definition kexiproject.h:68
KexiDB::Connection * dbConnection() const
The container (acts as a dock window) for KexiPropertyEditor.
An interface used by Kexi views (KexiViewBase) supporting search/replace features.
virtual tristate findNextAndReplace(const TQVariant &valueToFind, const TQVariant &replacement, const KexiSearchAndReplaceViewInterface::Options &options, bool replaceAll)=0
virtual tristate find(const TQVariant &valueToFind, const KexiSearchAndReplaceViewInterface::Options &options, bool next)=0
void setActionVolatile(TDEAction *a, bool set)
KexiActionProxy * actionProxyFor(TQObject *o) const
virtual void invalidateSharedActions(TQObject *o)
TDEAction * createSharedAction(const TQString &text, const TQString &pix_name, const TDEShortcut &cut, const char *name, TDEActionCollection *col=0, const char *subclassName=0)
A command for simple printing and print preview. This class is instantiated in KexiMainWindowImpl so ...
bool showPrintPreview(const KexiSimplePrintingSettings &settings, const TQString &aTitleText=TQString(), bool reload=false)
Internal Kexi Simple Printing Plugin.
Settings data for simple printing engine.
static KexiSimplePrintingSettings load()
bool isProjectNavigatorVisible() const
bool forcedUserMode() const
KexiProjectData * projectData() const
TQString selectedFileName() const
static bool askForOverwriting(const TQString &filePath, TQWidget *parent=0)
@ DontConvert
skip asking for conversion (used e.g. when dropdb is called)
Definition KexiStartup.h:86
@ SkipMessages
do not display error or warning messages
Definition KexiStartup.h:92
@ ThisIsAProjectFile
a hint, forces detection of the file as a project file
Definition KexiStartup.h:87
static tristate detectActionForFile(KexiStartupData::Import &detectedImportAction, TQString &detectedDriverName, const TQString &_suggestedDriverName, const TQString &dbFileName, TQWidget *parent=0, int options=0)
KexiProjectData * selectProject(KexiDB::ConnectionData *cdata, bool &cancelled, TQWidget *parent=0)
virtual tristate init(int argc, char **argv)
static KexiUserAction * fromCurrentRecord(KexiMainWindow *context, TDEActionCollection *parent, KexiDB::Cursor *c)
A set of functions used to declare action categories.
void addWindowAction(const char *name, KexiPart::ObjectTypes supportedObjectType1=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType2=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType3=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType4=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType5=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType6=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType7=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType8=(KexiPart::ObjectTypes) 0)
void addAction(const char *name, int categories, KexiPart::ObjectTypes supportedObjectType1=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType2=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType3=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType4=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType5=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType6=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType7=(KexiPart::ObjectTypes) 0, KexiPart::ObjectTypes supportedObjectType8=(KexiPart::ObjectTypes) 0)
void setAllObjectTypesSupported(const char *name, bool set)
3-state logical type with three values: true, false and cancelled and convenient operators.
Definition tristate.h:100
KEXI_DB_EXPORT TQMap< TQString, TQString > toMap(const ConnectionData &data)
KEXIUTILS_EXPORT CopyFileResult copyFile(const TQString &src, const TQString &dest)
bool hasParent(TQObject *par, TQObject *o)
KEXIUTILS_EXPORT void serializeMap(const TQMap< TQString, TQString > &map, const TQByteArray &array)
type * findFirstChild(TQObject *o, const char *className, const char *objName=0)
KEXIUTILS_EXPORT TQString fileDialogFilterStrings(const TQStringList &mimeStrings, bool kdeFormat)
KEXICORE_EXPORT bool & tempShowScripts()
false by default, flag loaded on main window startup
Definition kexi.cpp:134
KexiStartupHandler & startupHandler()
KEXICORE_EXPORT bool & tempShowForms()
false by default, flag loaded on main window startup
Definition kexi.cpp:110
KEXICORE_EXPORT bool & tempShowMacros()
false by default, flag loaded on main window startup
Definition kexi.cpp:126
@ NoActionCategory
no category at all
KEXICORE_EXPORT TQFont smallFont(TQWidget *init=0)
Definition kexi.cpp:143
KEXICORE_EXPORT ActionCategories * actionCategories()
KEXICORE_EXPORT KexiPart::Manager & partManager()
shared part manager
Definition kexi.cpp:97
KEXICORE_EXPORT KexiDB::DriverManager & driverManager()
shared driver manager
Definition kexi.cpp:91
KEXICORE_EXPORT bool & tempShowReports()
false by default, flag loaded on main window startup
Definition kexi.cpp:118
KEXICORE_EXPORT KexiDBConnectionSet & connset()
A set of known connections.
Definition kexi.cpp:74
KEXICORE_EXPORT TQString nameForViewMode(int m)
i18n'ed name of view mode m
Definition kexi.cpp:157
KEXICORE_EXPORT KexiProjectSet & recentProjects()
A set avaiulable of project infos.
Definition kexi.cpp:86
@ TextViewMode
Also known as SQL View Mode.
Definition kexi.h:48
@ NoViewMode
Definition kexi.h:44