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