21#include "keximainwindowimpl.h"
25#include <tqapplication.h>
26#include <tqeventloop.h>
29#include <tqobjectlist.h>
31#include <tqtoolbutton.h>
34#include <tqwaitcondition.h>
35#include <tqfiledialog.h>
36#include <tqdockwindow.h>
37#include <tqdockarea.h>
39#include <tdeapplication.h>
40#include <tdecmdlineargs.h>
43#include <tdestdaccel.h>
47#include <kkeydialog.h>
48#include <kedittoolbar.h>
49#include <tdeglobalsettings.h>
50#include <tdeparts/componentfactory.h>
52#include <kstandarddirs.h>
53#include <kpushbutton.h>
54#include <ktextbrowser.h>
55#include <kiconloader.h>
56#include <ktabwidget.h>
59#include <tdefiledialog.h>
60#include <tderecentdocument.h>
62#include <kexidb/connection.h>
63#include <kexidb/utils.h>
64#include <kexidb/cursor.h>
65#include <kexidb/dbobjectnamevalidator.h>
66#include <kexidb/admin.h>
67#include <kexiutils/utils.h>
70#include "kexiactionproxy.h"
71#include "kexidialogbase.h"
72#include "kexipartmanager.h"
74#include "kexipartinfo.h"
75#include "kexipartguiclient.h"
76#include "kexiproject.h"
77#include "kexiprojectdata.h"
78#include "kexiprojectset.h"
80#include "kexistatusbar.h"
81#include "kexiinternalpart.h"
82#include "kexiactioncategories.h"
83#include "kexifinddialog.h"
84#include "kexisearchandreplaceiface.h"
86#include "kde2_closebutton.xpm"
88#include <widget/kexibrowser.h>
89#include <widget/kexipropertyeditorview.h>
90#include <widget/utils/kexirecordnavigator.h>
91#include <koproperty/editor.h>
92#include <koproperty/set.h>
94#include "startup/KexiStartup.h"
95#include "startup/KexiNewProjectWizard.h"
96#include "startup/KexiStartupDialog.h"
97#include "startup/KexiStartupFileDialog.h"
98#include "kexinamedialog.h"
99#include "printing/kexisimpleprintingpart.h"
100#include "printing/kexisimpleprintingpagesetup.h"
103#if defined(TQ_WS_WIN)
104# include <tderecentdirs.h>
105# include <win32_utils.h>
109#if !defined(KexiVDebug)
110# define KexiVDebug if (0) kdDebug()
116#ifndef KEXI_NO_CTXT_HELP
117#include <kexicontexthelp.h>
120#ifdef HAVE_TDENEWSTUFF
121#include <tdenewstuff/downloaddialog.h>
122#include "kexinewstuff.h"
130#include "ksplitter.h"
131#define KDOCKWIDGET_P 1
133#ifndef KEXI_NO_FEEDBACK_AGENT
134#ifdef FEEDBACK_INCLUDE
135#include FEEDBACK_INCLUDE
137#include <tdeapplication.h>
138#include <tdeaboutdata.h>
141#include "keximainwindowimpl_p.h"
148 Kexi::initCmdLineArgs( argc, argv, aboutdata );
150 bool GUIenabled = true;
151 TQWidget *dummyWidget = 0;
153 TDEApplication* app = new TDEApplication( true, GUIenabled);
155#ifdef KEXI_STANDALONE
156 TDEGlobal::locale()->removeCatalogue( "kexi");
157 TDEGlobal::locale()->insertCatalogue( "standalone_kexi");
159 TDEGlobal::locale()->insertCatalogue( "koffice");
160 TDEGlobal::locale()->insertCatalogue( "koproperty");
163# include "custom_exec.h"
167 TQWidget* debugWindow = 0;
170 dummyWidget = new TQWidget();
171 dummyWidget->setIcon( DesktopIcon( "kexi" ) );
172 app->setMainWidget(dummyWidget);
174 app->config()->setGroup( "General");
175 if (app->config()->readBoolEntry( "showInternalDebugger", false)) {
176 debugWindow = KexiUtils::createDebugWindow(0);
187 return (~res) ? 0 : 1;
190 kdDebug() << "startupActions OK" <<endl;
202 app->setMainWidget(win);
216 app->processEvents();
228 , KexiGUIMessageHandler(this)
231 KImageIO::registerFormats();
239 kdDebug() << "KexiMainWindowImpl::KexiMainWindowImpl(): starting up in the User Mode" << endl;
241 d->config = kapp->config();
243 if ( !initialGeometrySet() ) {
244 int scnum = TQApplication::desktop()->screenNumber(parentWidget());
245 TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
246 d->config->setGroup( "MainWindow");
247 TQSize s ( d->config->readNumEntry( TQString::fromLatin1( "Width %1").arg(desk.width()), 700 ),
248 d->config->readNumEntry( TQString::fromLatin1( "Height %1").arg(desk.height()), 480 ) );
249 resize (kMin (s.width(), desk.width()), kMin(s.height(), desk.height()));
252 setManagedDockPositionModeEnabled( true);
253 manager()->setSplitterHighResolution( true);
254 manager()->setSplitterKeepSize( true);
255 setStandardMDIMenuEnabled( false);
257 TDEGlobal::iconLoader()->addAppDir( "kexi");
258 TDEGlobal::iconLoader()->addAppDir( "koffice");
263 connect( m_pMdi, TQ_SIGNAL(noMaximizedChildFrmLeft(KMdiChildFrm*)), this, TQ_SLOT(slotNoMaximizedChildFrmLeft(KMdiChildFrm*)));
265 connect( this, TQ_SIGNAL(lastChildViewClosed()), this, TQ_SLOT(slotLastChildViewClosed()));
267 connect( this, TQ_SIGNAL(childViewIsDetachedNow(TQWidget*)), this, TQ_SLOT(slotChildViewIsDetachedNow(TQWidget*)));
268 connect( this, TQ_SIGNAL(mdiModeHasBeenChangedTo(KMdi::MdiMode)),
269 this, TQ_SLOT(slotMdiModeHasBeenChangedTo(KMdi::MdiMode)));
273 setXMLFile( "kexiui.rc");
274 setAcceptDrops( true);
276 createShellGUI( true);
279 d->statusBar = new KexitStatusBar( this, "status_bar");
281 d->origAppCaption = caption();
288 initPropertyEditor();
292 TQObjectList *l = queryList( "TQPopupMenu" );
293 for (TQObjectListIt it( *l ); it.current(); ++it ) {
296 it.current()->installEventFilter( this);
297 d->popups.insert(it.current()->name(), static_cast<TQPopupMenu* >(it.current()));
300 d->createMenu = d->popups[ "create"];
302#ifdef KEXI_NO_REPORTBUG_COMMAND
304 TQPopupMenu *helpMenu = d->popups[ "help"];
307 helpMenu->removeItemAt( int(KHelpMenu::menuReportBug)-1);
308 helpMenu->removeItemAt( int(KHelpMenu::menuReportBug)-1);
314#ifndef KEXI_SHOW_UNIMPLEMENTED
318 TDEAction *tdemdi_tooldock_menu_action = childClients()->getFirst() ? childClients()->getFirst()->actionCollection()->action( "tdemdi_tooldock_menu") : 0;
319 if (tdemdi_tooldock_menu_action) {
320 tdemdi_tooldock_menu_action->setEnabled( false);
323 if (!isFakingSDIApplication()) {
325 TQPopupMenu *menu = d->popups[ "window"];
326 unsigned int count = menuBar()->count();
330 menuBar()->insertItem( i18n( "&Window"), windowMenu(), -1, count-2);
334 TQPopupMenu *menu = d->popups[ "insert"];
336 for (uint i=0; i < menuBar()->count(); i++) {
337 if (menuBar()->text( menuBar()->idAt(i) ) == i18n( "&Insert")) {
338 menuBar()->setItemVisible( menuBar()->idAt(i), false );
343 d->disableMenuItem( "file", i18n( "&Import"));
344 d->disableMenuItem( "edit", i18n( "Paste &Special"));
347 m_pTaskBar->setCaption(i18n( "Task Bar"));
354 setTabWidgetVisibility(KMdi::AlwaysShowTabs);
355 if (mdiMode()==KMdi::IDEAlMode) {
356 d->config->setGroup( "MainWindow");
357 tabWidget()->setHoverCloseButton(d->config->readBoolEntry( "HoverCloseButtonForTabs", false));
359 TQToolButton *closeButton = new TQToolButton( tabWidget() );
360 closeButton->setAutoRaise( true );
361 closeButton->setPixmap( TQPixmap( kde2_closebutton ) );
362 closeButton->setPaletteBackgroundColor(closeButton->palette().active().background());
364 tabWidget()->setCornerWidget( closeButton, TQt::TopRight );
367 TQToolTip::add(closeButton,
368 i18n( "Close the current tab page in Kexi tab interface", "Close the current tab"));
369 TQObject::connect( closeButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( closeActiveView() ) );
372#ifdef KEXI_ADD_CUSTOM_KEXIMAINWINDOWIMPL
373# include "keximainwindowimpl_ctor.h"
377KexiMainWindowImpl::~KexiMainWindowImpl()
379 d->forceDialogClosing= true;
389void KexiMainWindowImpl::setWindowMenu(TQPopupMenu *menu)
391 delete m_pWindowMenu;
392 m_pWindowMenu = menu;
393 int count = menuBar()->count();
395 const TQString txt = i18n( "&Window");
397 for (i=0; i<count; i++) {
399 if (txt==menuBar()->text( menuBar()->idAt(i) ))
403 const int id = menuBar()->idAt(i);
404 menuBar()->removeItemAt(i);
405 menuBar()->insertItem(txt, m_pWindowMenu, id, count-3);
407 m_pWindowMenu->setCheckable( true);
408 TQObject::connect( m_pWindowMenu, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(fillWindowMenu()) );
411void KexiMainWindowImpl::fillWindowMenu()
413 KexiMainWindow::fillWindowMenu();
424 m_pMdiModeMenu->removeItem( m_pMdiModeMenu->idAt( 0 ) );
425 m_pMdiModeMenu->removeItem( m_pMdiModeMenu->idAt( 1 ) );
427 if (d->mdiModeToSwitchAfterRestart != (KMdi::MdiMode)0) {
428 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 0 ),
429 d->mdiModeToSwitchAfterRestart == KMdi::ChildframeMode );
430 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 1 ),
431 d->mdiModeToSwitchAfterRestart == KMdi::IDEAlMode );
436 int i = m_pWindowMenu->count()-1;
437 for ( int index;; i--) {
438 index = m_pWindowMenu->idAt(i);
439 if (index==-1 || m_pWindowMenu->text(index).isNull())
443 d->action_window_next->plug( m_pWindowMenu, i++ );
444 d->action_window_previous->plug( m_pWindowMenu, i++ );
445 if (!m_pDocumentViews->isEmpty())
446 m_pWindowMenu->insertSeparator( i++ );
457 if (( int)d->mdiModeToSwitchAfterRestart == 0 && mdiMode()==KMdi::IDEAlMode)
459 if (d->mdiModeToSwitchAfterRestart == KMdi::IDEAlMode)
461 if (mdiMode()==KMdi::IDEAlMode) {
462 d->mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
465 KMessageBox::information( this,
466 i18n( "User interface mode will be switched to IDEAl at next %1 application startup.")
467 .arg(KEXI_APP_NAME));
469 d->mdiModeToSwitchAfterRestart = KMdi::IDEAlMode;
473 KexiMainWindow::switchToIDEAlMode();
476void KexiMainWindowImpl::switchToChildframeMode()
478 switchToChildframeMode( true);
481void KexiMainWindowImpl::switchToChildframeMode( bool showMessage)
484 if (( int)d->mdiModeToSwitchAfterRestart == 0 && mdiMode()==KMdi::ChildframeMode)
486 if (d->mdiModeToSwitchAfterRestart == KMdi::ChildframeMode)
488 if (mdiMode()==KMdi::ChildframeMode) {
489 d->mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
492 KMessageBox::information( this,
493 i18n( "User interface mode will be switched to Childframe at next %1 application startup.")
494 .arg(KEXI_APP_NAME));
496 d->mdiModeToSwitchAfterRestart = KMdi::ChildframeMode;
500 KexiMainWindow::switchToChildframeMode();
505 return d->popups[popupName];
510 return actionCollection()->actions();
526 TDEAction *action = new TDEAction(i18n( "&New..."), "document-new", TDEStdAccel::shortcut(TDEStdAccel::New),
527 this, TQ_SLOT( slotProjectNew()), actionCollection(), "project_new");
528 action->setToolTip(i18n( "Create a new project"));
529 action->setWhatsThis(i18n( "Creates a new project. Currently opened project is not affected."));
531 action = KStdAction::open( this, TQ_SLOT( slotProjectOpen() ), actionCollection(), "project_open" );
532 action->setToolTip(i18n( "Open an existing project"));
533 action->setWhatsThis(i18n( "Opens an existing project. Currently opened project is not affected."));
535#ifdef HAVE_TDENEWSTUFF
536 action = new TDEAction(i18n( "&Download Example Databases..."), "kget", TDEShortcut(0),
537 this, TQ_SLOT( slotGetNewStuff()), actionCollection(), "project_download_examples");
538 action->setToolTip(i18n( "Download example databases from the Internet"));
539 action->setWhatsThis(i18n( "Downloads example databases from the Internet."));
545#ifndef KEXI_NO_UNFINISHED
546 d->action_open_recent = new TDEActionMenu(i18n( "Open Recent"),
547 actionCollection(), "project_open_recent");
548 connect(d->action_open_recent->popupMenu(),TQ_SIGNAL(activated( int)),
549 this,TQ_SLOT(slotProjectOpenRecent( int)));
550 connect(d->action_open_recent->popupMenu(), TQ_SIGNAL(aboutToShow()),
551 this,TQ_SLOT(slotProjectOpenRecentAboutToShow()));
560 d->action_open_recent = d->dummy_action;
563 d->action_save = KStdAction::save(
564 this, TQ_SLOT( slotProjectSave() ), actionCollection(), "project_save" );
567 d->action_save->setToolTip(i18n( "Save object changes"));
568 d->action_save->setWhatsThis(i18n( "Saves object changes from currently selected window."));
570#ifdef KEXI_SHOW_UNIMPLEMENTED
571 d->action_save_as = new TDEAction(i18n( "Save &As..."), "document-save-as", 0,
572 this, TQ_SLOT(slotProjectSaveAs()), actionCollection(), "project_saveas");
573 d->action_save_as->setToolTip(i18n( "Save object as"));
574 d->action_save_as->setWhatsThis(
575 i18n( "Saves object changes from currently selected window under a new name (within the same project)."));
577 d->action_project_properties = new TDEAction(i18n( "Project Properties"), "application-vnd.tde.info", 0,
578 this, TQ_SLOT(slotProjectProperties()), actionCollection(), "project_properties");
580 d->action_save_as = d->dummy_action;
581 d->action_project_properties = d->dummy_action;
584 d->action_close = new TDEAction(i18n( "&Close Project"), "window-close", 0,
585 this, TQ_SLOT(slotProjectClose()), actionCollection(), "project_close" );
586 d->action_close->setToolTip(i18n( "Close the current project"));
587 d->action_close->setWhatsThis(i18n( "Closes the current project."));
589 KStdAction::quit( this, TQ_SLOT(slotProjectQuit()), actionCollection(), "quit");
591#ifdef KEXI_SHOW_UNIMPLEMENTED
592 d->action_project_relations = new TDEAction(i18n( "&Relationships..."), "relation", TQt::CTRL + TQt::Key_R,
593 this, TQ_SLOT(slotProjectRelations()), actionCollection(), "project_relations");
594 d->action_project_relations->setToolTip(i18n( "Project relationships"));
595 d->action_project_relations->setWhatsThis(i18n( "Shows project relationships."));
598 d->action_project_relations = d->dummy_action;
600 d->action_tools_data_migration = new TDEAction(
601 i18n( "&Import Database..."), "database_import", 0,
602 this, TQ_SLOT(slotToolsProjectMigration()), actionCollection(), "tools_import_project");
603 d->action_tools_data_migration->setToolTip(i18n( "Import entire database as a Kexi project"));
604 d->action_tools_data_migration->setWhatsThis(i18n( "Imports entire database as a Kexi project."));
606 d->action_tools_compact_database = new TDEAction(
607 i18n( "&Compact Database..."), "", 0,
609 d->action_tools_compact_database->setToolTip(i18n( "Compact the current database project"));
610 d->action_tools_compact_database->setWhatsThis(
611 i18n( "Compacts the current database project, so it will take less space and work faster."));
614 d->action_project_import_data_table = 0;
616 d->action_project_import_data_table = new TDEAction(
617 i18n( "Import->Table Data From File...", "Table Data From &File..."),
620 "project_import_data_table");
621 d->action_project_import_data_table->setToolTip(i18n( "Import table data from a file"));
622 d->action_project_import_data_table->setWhatsThis(i18n( "Imports table data from a file."));
625 d->action_project_export_data_table = new TDEAction(i18n( "Export->Table or Query Data to File...",
626 "Table or Query Data to &File..."),
628 0, this, TQ_SLOT(slotProjectExportDataTable()), actionCollection(),
629 "project_export_data_table");
630 d->action_project_export_data_table->setToolTip(
631 i18n( "Export data from the active table or query data to a file"));
632 d->action_project_export_data_table->setWhatsThis(
633 i18n( "Exports data from the active table or query data to a file."));
640 d->action_project_print = KStdAction::print( this, TQ_SLOT(slotProjectPrint()),
641 actionCollection(), "project_print" );
642 d->action_project_print->setToolTip(i18n( "Print data from the active table or query"));
643 d->action_project_print->setWhatsThis(i18n( "Prints data from the active table or query."));
645 d->action_project_print_preview = KStdAction::printPreview(
646 this, TQ_SLOT(slotProjectPrintPreview()),
647 actionCollection(), "project_print_preview" );
648 d->action_project_print_preview->setToolTip(
649 i18n( "Show print preview for the active table or query"));
650 d->action_project_print_preview->setWhatsThis(
651 i18n( "Shows print preview for the active table or query."));
653 d->action_project_print_setup = new TDEAction(i18n( "Page Set&up..."),
654 "", 0, this, TQ_SLOT(slotProjectPageSetup()), actionCollection(),
655 "project_print_setup");
656 d->action_project_print_setup->setToolTip(
657 i18n( "Show page setup for printing the active table or query"));
658 d->action_project_print_setup->setWhatsThis(
659 i18n( "Shows page setup for printing the active table or query."));
667 d->action_edit_paste_special_data_table = 0;
669 d->action_edit_paste_special_data_table =
670 new TDEAction(i18n( "Paste Special->As Data &Table...", "As Data &Table..."),
672 actionCollection(), "edit_paste_special_data_table");
673 d->action_edit_paste_special_data_table->setToolTip(
674 i18n( "Paste clipboard data as a table"));
675 d->action_edit_paste_special_data_table->setWhatsThis(
676 i18n( "Pastes clipboard data to a table."));
679 d->action_edit_copy_special_data_table =
680 new TDEAction(i18n( "Copy Special->Table or Query Data...",
681 "Table or Query as Data Table..."),
682 "table", 0, this, TQ_SLOT(slotEditCopySpecialDataTable()),
683 actionCollection(), "edit_copy_special_data_table");
684 d->action_edit_copy_special_data_table->setToolTip(
685 i18n( "Copy selected table or query data to clipboard"));
686 d->action_edit_copy_special_data_table->setWhatsThis(
687 i18n( "Copies selected table or query data to clipboard."));
690 d->action_edit_undo->setWhatsThis(i18n( "Reverts the most recent editing action."));
692 d->action_edit_redo->setWhatsThis(i18n( "Reverts the most recent undo action."));
697 d->action_edit_findprev = createSharedAction( KStdAction::FindPrev, "edit_findprevious");
701 d->action_edit_find = KStdAction::find(
702 this, TQ_SLOT(slotEditFind()), actionCollection(), "edit_find" );
704 d->action_edit_findnext = KStdAction::findNext(
705 this, TQ_SLOT(slotEditFindNext()), actionCollection(), "edit_findnext");
706 d->action_edit_findprev = KStdAction::findPrev(
707 this, TQ_SLOT(slotEditFindPrevious()), actionCollection(), "edit_findprevious");
708 d->action_edit_replace = 0;
711 d->action_edit_replace_all = 0;
715 d->action_edit_select_all = createSharedAction( KStdAction::SelectAll, "edit_select_all");
719 d->action_edit_delete->setToolTip(i18n( "Delete selected object"));
720 d->action_edit_delete->setWhatsThis(i18n( "Deletes currently selected object."));
722 d->action_edit_delete_row = createSharedAction(i18n( "Delete Row"), "delete_table_row",
723 TQt::CTRL+TQt::Key_Delete, "edit_delete_row");
724 d->action_edit_delete_row->setToolTip(i18n( "Delete currently selected row"));
725 d->action_edit_delete_row->setWhatsThis(i18n( "Deletes currently selected row."));
727 d->action_edit_clear_table = createSharedAction(i18n( "Clear Table Contents"), "clear_table_contents",
728 0, "edit_clear_table");
729 d->action_edit_clear_table->setToolTip(i18n( "Clear table contents"));
730 d->action_edit_clear_table->setWhatsThis(i18n( "Clears table contents."));
735 d->action_edit_edititem->setToolTip(i18n( "Edit currently selected item"));
736 d->action_edit_edititem->setWhatsThis(i18n( "Edits currently selected item."));
738 d->action_edit_insert_empty_row = createSharedAction(i18n( "&Insert Empty Row"), "insert_table_row",
739 TQt::SHIFT | TQt::CTRL | TQt::Key_Insert, "edit_insert_empty_row");
741 d->action_edit_insert_empty_row->setToolTip(i18n( "Insert one empty row above"));
742 d->action_edit_insert_empty_row->setWhatsThis(i18n( "Inserts one empty row above currently selected table row."));
746 d->action_view_data_mode = new TDERadioAction(i18n( "&Data View"), "state_data", TQt::Key_F6,
747 this, TQ_SLOT(slotViewDataMode()), actionCollection(), "view_data_mode");
748 d->actions_for_view_modes.insert( Kexi::DataViewMode, d->action_view_data_mode );
749 d->action_view_data_mode->setExclusiveGroup( "view_mode");
750 d->action_view_data_mode->setToolTip(i18n( "Switch to data view"));
751 d->action_view_data_mode->setWhatsThis(i18n( "Switches to data view."));
754 d->action_view_data_mode = 0;
757 d->action_view_design_mode = new TDERadioAction(i18n( "D&esign View"), "state_edit", TQt::Key_F7,
758 this, TQ_SLOT(slotViewDesignMode()), actionCollection(), "view_design_mode");
759 d->actions_for_view_modes.insert( Kexi::DesignViewMode, d->action_view_design_mode );
760 d->action_view_design_mode->setExclusiveGroup( "view_mode");
761 d->action_view_design_mode->setToolTip(i18n( "Switch to design view"));
762 d->action_view_design_mode->setWhatsThis(i18n( "Switches to design view."));
765 d->action_view_design_mode = 0;
768 d->action_view_text_mode = new TDERadioAction(i18n( "&Text View"), "state_sql", TQt::Key_F8,
771 d->action_view_text_mode->setExclusiveGroup( "view_mode");
772 d->action_view_text_mode->setToolTip(i18n( "Switch to text view"));
773 d->action_view_text_mode->setWhatsThis(i18n( "Switches to text view."));
776 d->action_view_text_mode = 0;
778 if (d->isProjectNavigatorVisible) {
779 d->action_view_nav = new TDEAction(i18n( "Project Navigator"), "", TQt::ALT + TQt::Key_1,
780 this, TQ_SLOT(slotViewNavigator()), actionCollection(), "view_navigator");
781 d->action_view_nav->setToolTip(i18n( "Go to project navigator panel"));
782 d->action_view_nav->setWhatsThis(i18n( "Goes to project navigator panel."));
785 d->action_view_nav = 0;
787 d->action_view_mainarea = new TDEAction(i18n( "Main Area"), "", TQt::ALT + TQt::Key_2,
788 this, TQ_SLOT(slotViewMainArea()), actionCollection(), "view_mainarea");
789 d->action_view_mainarea->setToolTip(i18n( "Go to main area"));
790 d->action_view_mainarea->setWhatsThis(i18n( "Goes to main area."));
793 d->action_view_propeditor = new TDEAction(i18n( "Property Editor"), "", TQt::ALT + TQt::Key_3,
794 this, TQ_SLOT(slotViewPropertyEditor()), actionCollection(), "view_propeditor");
795 d->action_view_propeditor->setToolTip(i18n( "Go to property editor panel"));
796 d->action_view_propeditor->setWhatsThis(i18n( "Goes to property editor panel."));
799 d->action_view_propeditor = 0;
803 TQt::SHIFT | TQt::Key_Return, "data_save_row");
804 d->action_data_save_row->setToolTip(i18n( "Save changes made to the current row"));
805 d->action_data_save_row->setWhatsThis(i18n( "Saves changes made to the current row."));
809 "button_cancel", 0 , "data_cancel_row_changes");
810 d->action_data_cancel_row_changes->setToolTip(i18n( "Cancel changes made to the current row"));
811 d->action_data_cancel_row_changes->setWhatsThis(i18n( "Cancels changes made to the current row."));
814 d->action_data_execute = createSharedAction(i18n( "&Execute"), "media-playback-start", 0 , "data_execute");
818#ifndef KEXI_NO_UNFINISHED
828 action->setToolTip(i18n( "Sort data in ascending order"));
829 action->setWhatsThis(i18n( "Sorts data in ascending order (from A to Z and from 0 to 9). Data from selected column is used for sorting."));
833 action->setToolTip(i18n( "Sort data in descending order"));
834 action->setWhatsThis(i18n( "Sorts data in descending (from Z to A and from 9 to 0). Data from selected column is used for sorting."));
837 createSharedAction( KexiRecordNavigator::Actions::moveToFirstRecord(), 0, "data_go_to_first_record");
838 createSharedAction( KexiRecordNavigator::Actions::moveToPreviousRecord(), 0, "data_go_to_previous_record");
839 createSharedAction( KexiRecordNavigator::Actions::moveToNextRecord(), 0, "data_go_to_next_record");
840 createSharedAction( KexiRecordNavigator::Actions::moveToLastRecord(), 0, "data_go_to_last_record");
841 createSharedAction( KexiRecordNavigator::Actions::moveToNewRecord(), 0, "data_go_to_new_record");
844 d->action_format_font = createSharedAction(i18n( "&Font..."), "fonts", 0, "format_font");
845 d->action_format_font->setToolTip(i18n( "Change font for selected object"));
846 d->action_format_font->setWhatsThis(i18n( "Changes font for selected object."));
853 TDEAction *closeWindowAction = actionCollection()->action( "window_close");
854 if (closeWindowAction)
855 closeWindowAction->setShortcut(TDEStdAccel::close());
859 d->action_window_next = new TDEAction( i18n( "&Next Window"), "",
861 TQt::CTRL+TQt::Key_Tab,
863 TQt::ALT+TQt::Key_Right,
865 this, TQ_SLOT(activateNextWin()), actionCollection(), "window_next");
866 d->action_window_next->setToolTip( i18n( "Next window") );
867 d->action_window_next->setWhatsThis(i18n( "Switches to the next window."));
869 d->action_window_previous = new TDEAction( i18n( "&Previous Window"), "",
871 TQt::CTRL+TQt::SHIFT+TQt::Key_Tab,
873 TQt::ALT+TQt::Key_Left,
875 this, TQ_SLOT(activatePrevWin()), actionCollection(), "window_previous");
876 d->action_window_previous->setToolTip( i18n( "Previous window") );
877 d->action_window_previous->setWhatsThis(i18n( "Switches to the previous window."));
880 setStandardToolBarMenuEnabled( true );
881 action = KStdAction::keyBindings( this, TQ_SLOT( slotConfigureKeys() ), actionCollection() );
882 action->setWhatsThis(i18n( "Lets you configure shortcut keys."));
884#ifdef KEXI_SHOW_UNIMPLEMENTED
885 action = KStdAction::configureToolbars( this, TQ_SLOT( slotConfigureToolbars() ), actionCollection() );
886 action->setWhatsThis(i18n( "Lets you configure toolbars."));
888 d->action_show_other = new TDEActionMenu(i18n( "Other"),
889 actionCollection(), "options_show_other");
892#ifndef KEXI_NO_CTXT_HELP
893 d->action_show_helper = new TDEToggleAction(i18n( "Show Context Help"), "", TQt::CTRL + TQt::Key_H,
894 actionCollection(), "options_show_contexthelp");
895 d->action_show_helper->setCheckedState(i18n( "Hide Context Help"));
898#ifdef KEXI_FORMS_SUPPORT
899 slotOptionsEnableForms( true, true);
901 slotOptionsEnableForms( false, true);
904#ifdef KEXI_REPORTS_SUPPORT
910#ifdef KEXI_MACROS_SUPPORT
916#ifdef KEXI_SCRIPTS_SUPPORT
922#ifdef KEXI_SHOW_UNIMPLEMENTED
923 d->action_configure = KStdAction::preferences( this, TQ_SLOT(slotShowSettings()), actionCollection());
924 action->setWhatsThis(i18n( "Lets you configure Kexi."));
929 KStdAction::tipOfDay( this, TQ_SLOT( slotTipOfTheDayAction() ), actionCollection() )
930 ->setWhatsThis(i18n( "This shows useful tips on the use of this application."));
933 new TDEAction(i18n( "Important Information"), "messagebox_info", 0,
934 this, TQ_SLOT( slotImportantInfo()), actionCollection(), "help_show_important_info");
938#ifndef KEXI_NO_FEEDBACK_AGENT
940 new TDEAction(i18n( "Give Feedback..."), "messagebox_info", 0,
941 this, TQ_SLOT(slotStartFeedbackAgent()), actionCollection(), "help_start_feedback_agent");
950 if ((action = actionCollection()->action( "window_close")))
951 action->setToolTip(i18n( "Close the current window"));
962 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
965 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
968 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
971 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
975 KexiPart::TableObjectType, KexiPart::QueryObjectType);
979 KexiPart::TableObjectType, KexiPart::QueryObjectType);
983 KexiPart::TableObjectType, KexiPart::QueryObjectType);
987 KexiPart::TableObjectType, KexiPart::QueryObjectType);
997 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1000 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1003 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1006 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1009 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1012 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1015 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1035 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1045 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1049 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1053 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1093 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1095 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1097 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1099 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1101 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1136void KexiMainWindowImpl::invalidateSharedActionsLater()
1145 const bool have_dialog = d->curDialog;
1146 const bool dialog_dirty = d->curDialog && d->curDialog->dirty();
1147 const bool readOnly = d->prj && d->prj->dbConnection() && d->prj->dbConnection()->isReadOnly();
1150 d->action_save->setEnabled(have_dialog && dialog_dirty && !readOnly);
1151 d->action_save_as->setEnabled(have_dialog && !readOnly);
1152 d->action_project_properties->setEnabled(d->prj);
1153 d->action_close->setEnabled(d->prj);
1154 d->action_project_relations->setEnabled(d->prj);
1155 if (d->action_project_import_data_table)
1156 d->action_project_import_data_table->setEnabled(d->prj && !readOnly);
1157 d->action_project_export_data_table->setEnabled(
1158 d->curDialog && d->curDialog->part()->info()->isDataExportSupported()
1159 && !d->curDialog->neverSaved() );
1161 const bool printingActionsEnabled =
1162 d->curDialog && d->curDialog->part()->info()->isPrintingSupported()
1163 && !d->curDialog->neverSaved();
1164 d->action_project_print->setEnabled( printingActionsEnabled );
1165 d->action_project_print_preview->setEnabled( printingActionsEnabled );
1166 d->action_project_print_setup->setEnabled( printingActionsEnabled );
1170 if (d->action_edit_paste_special_data_table)
1171 d->action_edit_paste_special_data_table->setEnabled(d->prj && !readOnly);
1175 if (d->curDialog && d->curDialog->currentViewMode()==Kexi::DataViewMode) {
1177 d->action_edit_copy_special_data_table->setEnabled(
1181 d->action_edit_copy_special_data_table->setEnabled( false );
1184 if (d->action_view_nav)
1185 d->action_view_nav->setEnabled(d->prj);
1186 d->action_view_mainarea->setEnabled(d->prj);
1187 if (d->action_view_propeditor)
1188 d->action_view_propeditor->setEnabled(d->prj);
1189 if (d->action_view_data_mode) {
1190 d->action_view_data_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::DataViewMode) );
1191 if (!d->action_view_data_mode->isEnabled())
1192 d->action_view_data_mode->setChecked( false);
1194 if (d->action_view_design_mode) {
1195 d->action_view_design_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::DesignViewMode) );
1196 if (!d->action_view_design_mode->isEnabled())
1197 d->action_view_design_mode->setChecked( false);
1199 if (d->action_view_text_mode) {
1200 d->action_view_text_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode( Kexi::TextViewMode) );
1201 if (!d->action_view_text_mode->isEnabled())
1202 d->action_view_text_mode->setChecked( false);
1204#ifndef KEXI_NO_CTXT_HELP
1205 d->action_show_helper->setEnabled(d->prj);
1210 d->createMenu->setEnabled(d->prj);
1217 d->action_tools_compact_database->setEnabled(
1218 !d->prj || !readOnly && d->prj && d->prj->dbConnection()
1222 if (d->action_window_next) {
1223 d->action_window_next->setEnabled(!m_pDocumentViews->isEmpty());
1224 d->action_window_previous->setEnabled(!m_pDocumentViews->isEmpty());
1229 d->nav->setEnabled(d->prj);
1231 d->propEditorTabWidget->setEnabled(d->prj);
1238 if (d->curDialog->currentViewMode()==Kexi::DataViewMode) {
1239 if (d->action_view_data_mode)
1240 d->action_view_data_mode->setChecked( true );
1242 else if (d->curDialog->currentViewMode()==Kexi::DesignViewMode) {
1243 if (d->action_view_design_mode)
1244 d->action_view_design_mode->setChecked( true );
1247 if (d->action_view_text_mode)
1248 d->action_view_text_mode->setChecked( true );
1256 case KexiStartupHandler::CreateBlankProject:
1258 makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1260 case KexiStartupHandler::CreateFromTemplate:
1262 case KexiStartupHandler::OpenProject:
1264 case KexiStartupHandler::ImportProject:
1271 makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1278 const TQString &s = obj-> errorMsg();
1281 return TQString( "<br>(%1) ").arg(i18n( "reason:")+ " <i>"+s+ "</i>");
1293 && newProjectData->connectionData()-> password.isEmpty()
1294 && newProjectData->connectionData()-> fileName().isEmpty()
1298 KexiDBPasswordDialog pwdDlg( this, *newProjectData->connectionData(),
1300 if (TQDialog::Accepted!=pwdDlg.exec()) {
1306 bool incompatibleWithKexi;
1307 tristate res = d->prj->open(incompatibleWithKexi);
1316 if (incompatibleWithKexi) {
1317 if (KMessageBox::Yes == KMessageBox::questionYesNo( this,
1318 i18n( "<qt>Database project %1 does not appear to have been created using Kexi.<br><br>"
1319 "Do you want to import it as a new Kexi project?</qt>").arg(projectData. infoString()),
1320 0, KGuiItem(i18n( "Import Database", "&Import..."), "database_import"),
1321 KStdGuiItem::quit()))
1323 const bool anotherProjectAlreadyOpened = d->prj;
1325 projectData. databaseName(), projectData.constConnectionData());
1327 if (!anotherProjectAlreadyOpened)
1351 TQStringList mimetypes;
1354 const TQString startDir( ":OpenExistingOrCreateNewProject");
1355 const TQString caption( i18n( "Select New Project's Location") );
1360 TQString recentDir = TDEGlobalSettings::documentPath();
1361 if (fname.isEmpty() && !projectData.constConnectionData()-> dbFileName().isEmpty())
1362 fname = KFileDialog::getStartURL(startDir, recentDir).path()
1363 + '/' + projectData.constConnectionData()-> dbFileName();
1364 fname = TQFileDialog::getSaveFileName(
1365 KFileDialog::getStartURL(fname.isEmpty() ? startDir : fname, recentDir).path(),
1367 this, "CreateProjectFromTemplate", caption);
1368 if ( !fname.isEmpty() ) {
1371 url.setPath( fname );
1372 if (url.isLocalFile())
1373 TDERecentDirs::add(startDir, url.directory());
1376 Q_UNUSED(projectData);
1377 if (fname.isEmpty() &&
1378 !projectData.constConnectionData()-> dbFileName().isEmpty())
1381 fname = projectData.constConnectionData()-> dbFileName();
1383 const bool specialDir = fname.isEmpty();
1384 kdDebug() << fname << "............." << endl;
1385 KFileDialog dlg( specialDir ? startDir : TQString(),
1386 mimetypes.join( " "), this, "filedialog", true);
1388 dlg.setSelection( fname );
1389 dlg.setOperationMode( KFileDialog::Saving );
1390 dlg.setCaption( caption );
1392 fname = dlg.selectedFile();
1393 if (!fname.isEmpty())
1394 TDERecentDocument::add(fname);
1398 if ( fname.isEmpty() )
1405 projectData.constConnectionData()-> fileName(), fname ))
1415 const bool readOnly = d->prj && d->prj->dbConnection() && d->prj->dbConnection()->isReadOnly();
1416 d->statusBar->setReadOnlyFlag( readOnly );
1418 d->nav->setReadOnly(readOnly);
1420 TDEActionCollection *ac = actionCollection();
1421 for (KexiPart::PartInfoListIterator it(* Kexi::partManager().partInfoList()); it.current(); ++it) {
1422 TDEAction *a = ac->action( TQString(KexiPart::nameForCreateAction( *it.current() )).ascii() );
1424 a->setEnabled(!readOnly);
1430 TQString not_found_msg;
1431 bool openingCancelled;
1434 for (TQValueList<KexiProjectData::ObjectInfo>::ConstIterator it =
1435 d->prj->data()->autoopenObjects.constBegin();
1436 it != d->prj->data()->autoopenObjects.constEnd(); ++it )
1438 KexiProjectData::ObjectInfo info = *it;
1440 TQCString( "kexi/")+info[ "type"].lower().latin1() );
1442 not_found_msg += "<li>";
1443 if (!info[ "name"].isEmpty())
1444 not_found_msg += (TQString( "\"") + info[ "name"] + "\" - ");
1445 if (info[ "action"]== "new")
1446 not_found_msg += i18n( "cannot create object - unknown object type \"%1\"")
1449 not_found_msg += i18n( "unknown object type \"%1\"").arg(info[ "type"]);
1454 if (info[ "action"]== "new") {
1455 if (! newObject( i, openingCancelled) && !openingCancelled) {
1456 not_found_msg += "<li>";
1457 not_found_msg += (i18n( "cannot create object of type \"%1\"").arg(info[ "type"])+
1458 internalReason(d->prj)+ "<br></li>");
1461 d->wasAutoOpen = true;
1469 if (info[ "action"]== "print-preview")
1470 taskName = i18n( "making print preview for");
1471 else if (info[ "action"]== "print")
1472 taskName = i18n( "printing");
1473 else if (info[ "action"]== "execute")
1474 taskName = i18n( "\"executing object\" action", "executing");
1476 taskName = i18n( "opening");
1478 not_found_msg += (TQString( "<li>")+ taskName + " \"" + info[ "name"] + "\" - ");
1479 if ( "table"==info[ "type"].lower())
1480 not_found_msg += i18n( "table not found");
1481 else if ( "query"==info[ "type"].lower())
1482 not_found_msg += i18n( "query not found");
1483 else if ( "macro"==info[ "type"].lower())
1484 not_found_msg += i18n( "macro not found");
1485 else if ( "script"==info[ "type"].lower())
1486 not_found_msg += i18n( "script not found");
1488 not_found_msg += i18n( "object not found");
1489 not_found_msg += (internalReason(d->prj)+ "<br></li>");
1493 if (info[ "action"]== "execute") {
1496 not_found_msg += ( TQString( "<li>\"")+ info[ "name"] + "\" - " + i18n( "cannot execute object")+
1497 internalReason(d->prj)+ "<br></li>" );
1501 else if (info[ "action"]== "print") {
1504 not_found_msg += ( TQString( "<li>\"")+ info[ "name"] + "\" - " + i18n( "cannot print object")+
1505 internalReason(d->prj)+ "<br></li>" );
1509 else if (info[ "action"]== "print-preview") {
1512 not_found_msg += ( TQString( "<li>\"")+ info[ "name"] + "\" - " + i18n( "cannot make print preview of object")+
1513 internalReason(d->prj)+ "<br></li>" );
1519 if (info[ "action"]== "open")
1520 viewMode = Kexi::DataViewMode;
1521 else if (info[ "action"]== "design")
1522 viewMode = Kexi::DesignViewMode;
1523 else if (info[ "action"]== "edittext")
1528 TQString openObjectMessage;
1529 if (! openObject(item, viewMode, openingCancelled, 0, &openObjectMessage)
1530 && (!openingCancelled || !openObjectMessage.isEmpty()))
1532 not_found_msg += (TQString( "<li>\"")+ info[ "name"] + "\" - ");
1533 if (openObjectMessage.isEmpty())
1534 not_found_msg += i18n( "cannot open object");
1536 not_found_msg += openObjectMessage;
1537 not_found_msg += internalReason(d->prj) + "<br></li>";
1541 d->wasAutoOpen = true;
1548 if (!not_found_msg.isEmpty())
1549 showErrorMessage(i18n( "You have requested selected objects to be automatically opened "
1550 "or processed on startup. Several objects cannot be opened or processed."),
1551 TQString( "<ul>%1</ul>").arg(not_found_msg) );
1553 d->updatePropEditorVisibility(d->curDialog ? d->curDialog->currentViewMode() : 0);
1554#if defined(KDOCKWIDGET_P)
1555 if (d->propEditor) {
1556 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1567 if (mdiMode()==KMdi::ChildframeMode || mdiMode()==KMdi::TabPageMode) {
1569 if (!d->navToolWindow->wrapperWidget()->isVisible())
1570 static_cast<KDockWidget* >(d->navToolWindow->wrapperWidget())->makeDockVisible();
1576 d->restoreNavigatorWidth();
1578#ifndef PROPEDITOR_VISIBILITY_CHANGES
1589 d->nav->updateGeometry();
1591 tqApp->processEvents();
1597#ifndef KEXI_NO_PENDING_DIALOGS
1598 if (d->pendingDialogsExist()) {
1599 kdDebug() << "KexiMainWindowImpl::closeProject() pendingDialogsExist..." << endl;
1600 d->actionToExecuteWhenPendingJobsAreFinished = Private::CloseProjectAction;
1606 d->saveSettingsForShowProjectNavigator = d->prj && d->isProjectNavigatorVisible;
1613 bool cancel = false;
1619 d->dialogExistedBeforeCloseProject = !d->curDialog.isNull();
1621#if defined(KDOCKWIDGET_P)
1623 if (d->propEditor) {
1624 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1632 if (d->propEditor) {
1633 if (d->openedDialogsCount() == 0)
1634 makeWidgetDockVisible(d->propEditorTabWidget);
1635 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1641 KDockWidget *dw = (KDockWidget *)d->nav->parentWidget();
1643 int dwWidth = dw->width();
1645 if (d->openedDialogsCount()!=0 && d->propEditorTabWidget && d->propEditorTabWidget->isVisible())
1648 d->navDockSeparatorPos = (100 * dwWidth) / width();
1657 while (!d->curDialog.isNull()) {
1666 if (!d->prj->closeConnection())
1671 d->navWasVisibleBeforeProjectClosing = manager()->findWidgetParentDock(d->nav)->isVisible();
1674 d->navToolWindow->hide();
1679 makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1699void KexiMainWindowImpl::initContextHelp() {
1700#ifndef KEXI_NO_CTXT_HELP
1701 d->ctxHelp= new KexiContextHelp( this, this);
1709 addToolWindow(d->ctxHelp,KDockWidget::DockBottom | KDockWidget::DockLeft,getMainDockWidget(),20);
1715 if (!d->isProjectNavigatorVisible)
1721 d->nav->installEventFilter( this);
1722 d->navToolWindow = addToolWindow(d->nav, KDockWidget::DockLeft, getMainDockWidget(), 20);
1726 connect(d->nav,TQ_SIGNAL(openOrActivateItem( KexiPart::Item*, int)),
1732 connect(d->nav,TQ_SIGNAL(renameItem( KexiPart::Item*, const TQString&, bool&)),
1751 if(d->prj->isConnected()) {
1752 TQString partManagerErrorMessages;
1753 d->nav->setProject( d->prj, TQString(), &partManagerErrorMessages );
1754 if (!partManagerErrorMessages.isEmpty()) {
1755 showWarningContinueMessage(partManagerErrorMessages, TQString(),
1756 "dontShowWarningsRelatedToPluginsLoading");
1762 if (d->forceShowProjectNavigatorOnCreation) {
1763 slotViewNavigator();
1764 d->forceShowProjectNavigatorOnCreation = false;
1766 else if (d->forceHideProjectNavigatorOnCreation) {
1767 d->navToolWindow->hide();
1769 d->forceHideProjectNavigatorOnCreation = false;
1777#if defined(KDOCKWIDGET_P)
1778 if (mdiMode()==KMdi::ChildframeMode || mdiMode()==KMdi::TabPageMode) {
1792void KexiMainWindowImpl::initPropertyEditor()
1794 if (!d->propEditor) {
1796 d->propEditorTabWidget = new KTabWidget( this);
1797 d->propEditorTabWidget->hide();
1799 d->propEditorTabWidget->setCaption(d->propEditor->caption());
1800 d->propEditorTabWidget->addTab(d->propEditor, i18n( "Properties"));
1801 d->propEditor->installEventFilter( this);
1802 d->propEditorToolWindow = addToolWindow(d->propEditorTabWidget,
1803 KDockWidget::DockRight, getMainDockWidget(), 20);
1805 d->config->setGroup( "PropertyEditor");
1806 int size = d->config->readNumEntry( "FontSize", -1);
1809 f.setPixelSize( size );
1810 d->propEditorTabWidget->setFont(f);
1812 if (mdiMode()==KMdi::ChildframeMode || mdiMode()==KMdi::TabPageMode) {
1813 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1814 #if defined(KDOCKWIDGET_P)
1817 makeWidgetDockVisible(d->propEditorTabWidget);
1825 d->config->setGroup( "MainWindow");
1858 connect(p, TQ_SIGNAL(newObjectRequest(KexiPart::Info*)),
1859 this, TQ_SLOT( newObject(KexiPart::Info*)));
1868 KMdiChildView *view = 0L;
1871 else if (d->curDialog->isAttached()) {
1872 view = d->curDialog;
1875 if (m_pMdi->topChild()) {
1876 view = m_pMdi->topChild()->m_pClient;
1877 childrenMaximized = view->mdiParent()->state()==KMdiChildFrm::Maximized;
1883 if (childrenMaximized && view) {
1884 setCaption( d->curDialog->caption()
1885 + (d->appCaptionPrefix.isEmpty() ? TQString() : (TQString::fromLatin1( " - ") + d->appCaptionPrefix)) );
1888 setCaption( (d->appCaptionPrefix.isEmpty() ? TQString() : (d->appCaptionPrefix + TQString::fromLatin1( " - ")))
1889 + d->origAppCaption );
1897 d->appCaptionPrefix = "";
1898 if (d->prj && d->prj->data()) {
1899 d->appCaptionPrefix = d->prj->data()->caption();
1900 if (d->appCaptionPrefix.isEmpty())
1901 d->appCaptionPrefix = d->prj->data()->databaseName();
1907 if (d->curDialog && d->curDialog->mdiParent())
1908 max = d->curDialog->mdiParent()->state()==KMdiChildFrm::Maximized;
1935void KexiMainWindowImpl::slotNoMaximizedChildFrmLeft(KMdiChildFrm*)
1940void KexiMainWindowImpl::slotLastChildViewClosed()
1942 if (m_pDocumentViews->count()>0)
1954void KexiMainWindowImpl::slotChildViewIsDetachedNow(TQWidget*)
1978KexiMainWindowImpl::queryClose()
1980#ifndef KEXI_NO_PENDING_DIALOGS
1981 if (d->pendingDialogsExist()) {
1982 kdDebug() << "KexiMainWindowImpl::queryClose() pendingDialogsExist..." << endl;
1983 d->actionToExecuteWhenPendingJobsAreFinished = Private::QuitAction;
1999KexiMainWindowImpl::queryExit()
2008 d->config->setGroup( "MainWindow");
2011 applyMainWindowSettings( d->config, "MainWindow" );
2015 d->config->setGroup( "MainWindow Toolbar KMdiTaskBar");
2016 const bool tbe = d->config->readEntry( "Position").isEmpty();
2017 if (tbe || d->config->readEntry( "Position")== "Bottom") {
2019 d->config->writeEntry( "Position", "Bottom");
2020 moveDockWindow(m_pTaskBar, DockBottom);
2023 d->config->setGroup( "MainWindow");
2024 int mdimode = d->config->readNumEntry( "MDIMode", -1);
2026 const bool showProjectNavigator = d->config->readBoolEntry( "ShowProjectNavigator", true);
2034 case KMdi::ChildframeMode:
2035 switchToChildframeMode( false);
2036 m_pTaskBar->switchOn( true);
2040 d->maximizeFirstOpenedChildFrm = d->config->readBoolEntry( "maximized childframes", true);
2041 setEnableMaximizedChildFrmMode(d->maximizeFirstOpenedChildFrm);
2043 if (!showProjectNavigator) {
2045 d->forceHideProjectNavigatorOnCreation = true;
2050#define DEFAULT_MDI_MODE KMdi::IDEAlMode
2052 case DEFAULT_MDI_MODE:
2055 if (showProjectNavigator) {
2057 d->forceShowProjectNavigatorOnCreation = true;
2067 if ( !initialGeometrySet() ) {
2070 int scnum = TQApplication::desktop()->screenNumber(parentWidget());
2071 TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
2087 config->setGroup( "MainWindow");
2088 TQSize s ( config->readNumEntry( TQString::fromLatin1( "Width %1").arg(desk.width()), 700 ),
2089 config->readNumEntry( TQString::fromLatin1( "Height %1").arg(desk.height()), 480 ) );
2090 resize (kMin (s.width(), desk.width()), kMin(s.height(), desk.height()));
2098 kdDebug() << "KexiMainWindowImpl::storeSettings()" << endl;
2101 saveMainWindowSettings( d->config, "MainWindow" );
2102 d->config->setGroup( "MainWindow");
2103 KMdi::MdiMode modeToSave = mdiMode();
2104 if (d->mdiModeToSwitchAfterRestart!=(KMdi::MdiMode)0)
2105 modeToSave = d->mdiModeToSwitchAfterRestart;
2106 if (modeToSave == DEFAULT_MDI_MODE)
2107 d->config->deleteEntry( "MDIMode");
2109 d->config->writeEntry( "MDIMode", modeToSave);
2110 d->config->writeEntry( "maximized childframes", isInMaximizedChildFrmMode());
2113 if (d->saveSettingsForShowProjectNavigator) {
2114 if (d->navWasVisibleBeforeProjectClosing)
2115 d->config->deleteEntry( "ShowProjectNavigator");
2117 d->config->writeEntry( "ShowProjectNavigator", false);
2120 if (modeToSave==KMdi::ChildframeMode || modeToSave==KMdi::TabPageMode) {
2121 if (d->propEditor && d->propEditorDockSeparatorPos >= 0 && d->propEditorDockSeparatorPos <= 100) {
2122 d->config->setGroup( "MainWindow");
2123 d->config->writeEntry( "RightDockPosition", d->propEditorDockSeparatorPos);
2126 d->propEditorDockSeparatorPos = 80;
2127 if (d->nav && d->navDockSeparatorPos >= 0 && d->navDockSeparatorPos <= 100) {
2128 d->config->setGroup( "MainWindow");
2135 if (d->wasAutoOpen && d->dialogExistedBeforeCloseProject) {
2137 d->config->writeEntry( "LeftDockPositionWithAutoOpen",
2138 d->navDockSeparatorPos);
2144 if (d->dialogExistedBeforeCloseProject)
2145 d->config->writeEntry( "LeftDockPosition", d->navDockSeparatorPos);
2147 d->config->writeEntry( "LeftDockPosition", tqRound( double(d->navDockSeparatorPos) / 0.77
2148 / ( double(d->propEditorDockSeparatorPos) / 80) ));
2154 if (d->propEditor) {
2155 d->config->setGroup( "PropertyEditor");
2156 d->config->writeEntry( "FontSize", d->propEditorTabWidget->font().pixelSize());
2161KexiMainWindowImpl::restoreWindowConfiguration(TDEConfig *config)
2163 kdDebug()<< "preparing session restoring"<<endl;
2165 config->setGroup( "MainWindow");
2169 if (kapp->isRestored())
2170 dockGrp=config->group()+ "-Docking";
2172 dockGrp= "MainWindow0-Docking";
2174 if (config->hasGroup(dockGrp))
2175 readDockConfig(config,dockGrp);
2179KexiMainWindowImpl::storeWindowConfiguration(TDEConfig *config)
2181 kdDebug()<< "preparing session saving"<<endl;
2182 config->setGroup( "MainWindow");
2185#if !defined(TQ_WS_WIN)
2186 if (kapp->sessionSaving())
2187 dockGrp=config->group()+ "-Docking";
2190 dockGrp= "MainWindow0-Docking";
2192 kdDebug()<< "Before write dock config"<<endl;
2193 writeDockConfig(config,dockGrp);
2194 kdDebug()<< "After write dock config"<<endl;
2199 restoreWindowConfiguration(config);
2203KexiMainWindowImpl::saveProperties(TDEConfig *config)
2205 storeWindowConfiguration(config);
2211KexiMainWindowImpl::saveGlobalProperties( TDEConfig* sessionConfig ) {
2212 storeWindowConfiguration(sessionConfig);
2218 kdDebug() << "KexiMainWindowImpl::registerChild()" << endl;
2219 connect(dlg, TQ_SIGNAL(activated(KMdiChildView *)),
2221 connect(dlg, TQ_SIGNAL(dirtyChanged(KexiDialogBase*)),
2225 if(dlg-> id() != -1) {
2226 d->insertDialog(dlg);
2228 kdDebug() << "KexiMainWindowImpl::registerChild() ID = " << dlg-> id() << endl;
2230 if (m_mdiMode==KMdi::ToplevelMode || m_mdiMode==KMdi::ChildframeMode) {
2232 if (m_pTaskBar && !m_pTaskBar->isSwitchedOn())
2233 m_pTaskBar->switchOn( true);
2245 if (viewClient!=d->curDialogViewGUIClient) {
2247 kdDebug()<< "KexiMainWindowImpl::activeWindowChanged(): old view gui client:"
2248 <<(d->curDialogViewGUIClient ? d->curDialogViewGUIClient->xmlFile() : "")
2249 << " new view gui client: "<<( viewClient ? viewClient->xmlFile() : "") <<endl;
2250 if (d->curDialogViewGUIClient) {
2251 guiFactory()->removeClient(d->curDialogViewGUIClient);
2254 if (d->closedDialogViewGUIClient) {
2259 guiFactory()->addClient(viewClient);
2268 prevDialog ? prevDialog-> part() : 0,
2270 d->curDialog ? d->curDialog->part() : 0,
2278 if (!d->propEditorTabWidget)
2283 && (prevDialogPart!=curDialogPart || prevViewMode!=curViewMode)
2286 if (d->partForPreviouslySetupPropertyPanelTabs) {
2288 if (prevViewMode==Kexi::DesignViewMode &&
2289 (( KexiPart::Part*)d->partForPreviouslySetupPropertyPanelTabs != curDialogPart)
2290 || curViewMode!=Kexi::DesignViewMode)
2292 d->recentlySelectedPropertyPanelPages.insert( d->partForPreviouslySetupPropertyPanelTabs,
2293 d->propEditorTabWidget->currentPageIndex() );
2298 const uint count = d->propEditorTabWidget->count();
2299 for (uint i=1; i < count; i++)
2300 d->propEditorTabWidget->removePage( d->propEditorTabWidget->page(1) );
2304 if ((!prevDialogPart && !curDialogPart)
2305 || (prevDialogPart == curDialogPart && prevViewMode==curViewMode)
2306 || (curDialogPart && curViewMode!=Kexi::DesignViewMode))
2309 d->partForPreviouslySetupPropertyPanelTabs = curDialogPart;
2313 if (curDialogPart) {
2318 if (d->recentlySelectedPropertyPanelPages.contains( curDialogPart )) {
2319 d->propEditorTabWidget->setCurrentPage(
2320 d->recentlySelectedPropertyPanelPages[ curDialogPart ]
2326 d->partForPreviouslySetupPropertyPanelTabs = curDialogPart;
2331 KexiDialogBase *dlg = static_cast<KexiDialogBase * >(v);
2332 kdDebug() << "KexiMainWindowImpl::activeWindowChanged() to = " << (dlg ? dlg->caption() : "<none>") << endl;
2334 KXMLGUIClient *client=0;
2335 KXMLGUIClient *viewClient=0;
2336 KexiDialogBase* prevDialog = d->curDialog;
2340 else if ( dlg->isRegistered()) {
2344 if (d->closedDialogGUIClient) {
2345 if (client!=d->closedDialogGUIClient) {
2347 guiFactory()->removeClient(d->closedDialogGUIClient);
2348 d->closedDialogGUIClient=0;
2351 if (d->closedDialogViewGUIClient) {
2352 if (viewClient!=d->closedDialogViewGUIClient) {
2354 guiFactory()->removeClient(d->closedDialogViewGUIClient);
2355 d->closedDialogViewGUIClient=0;
2358 if (client!=d->curDialogGUIClient) {
2360 kdDebug()<< "KexiMainWindowImpl::activeWindowChanged(): old gui client:"
2361 <<(d->curDialogGUIClient ? d->curDialogGUIClient->xmlFile() : "")
2362 << " new gui client: "<<( client ? client->xmlFile() : "") <<endl;
2363 if (d->curDialogGUIClient) {
2364 guiFactory()->removeClient(d->curDialogGUIClient);
2365 d->curDialog->detachFromGUIClient();
2368 if (d->closedDialogGUIClient) {
2373 guiFactory()->addClient(client);
2379 if ((KexiDialogBase*)d->curDialog!=dlg) {
2381 d->curDialog->detachFromGUIClient();
2405 bool update_dlg_caption = dlg && dlg!=(KexiDialogBase*)d->curDialog && dlg->mdiParent();
2407 if (d->curDialogGUIClient && !client)
2408 guiFactory()->removeClient(d->curDialogGUIClient);
2409 d->curDialogGUIClient=client;
2411 if (d->curDialogViewGUIClient && !viewClient)
2412 guiFactory()->removeClient(d->curDialogViewGUIClient);
2413 d->curDialogViewGUIClient=viewClient;
2415 bool dialogChanged = ((KexiDialogBase*)d->curDialog)!=dlg;
2417 if (dialogChanged) {
2420 d->curDialog->deactivate();
2431 if (dialogChanged && d->curDialog)
2432 d->curDialog->selectedView()->propertySetSwitched();
2434 if (dialogChanged) {
2442 if (d->curDialog && d->curDialog->currentViewMode()!=0)
2443 d->updatePropEditorVisibility(d->curDialog->currentViewMode());
2447 if (update_dlg_caption) {
2454 d->updateFindDialogContents();
2462 kdDebug() << "KexiMainWindowImpl::activateWindow()" << endl;
2463#ifndef KEXI_NO_PENDING_DIALOGS
2464 Private::PendingJobType pendingType;
2474 kdDebug() << "KexiMainWindowImpl::activateWindow(KexiDialogBase *)" << endl;
2478 d->focus_before_popup = dlg;
2486 KexiDialogBase *dlg = static_cast<KexiDialogBase * >(v);
2487 d->removeDialog(dlg-> id());
2488#ifndef KEXI_NO_PENDING_DIALOGS
2489 d->removePendingDialog(dlg-> id());
2493 if (d->openedDialogsCount() == 0)
2498KexiMainWindowImpl::slotShowSettings()
2500 KEXI_UNFINISHED(d->action_configure->text());
2506KexiMainWindowImpl::slotConfigureKeys()
2511 KKeyDialog::configure( actionCollection(), false, this );
2515KexiMainWindowImpl::slotConfigureToolbars()
2517 KEditToolbar edit(factory());
2543 args << tqApp->applicationFilePath() << "-create-opendb";
2544 if (new_data->connectionData()-> fileName().isEmpty()) {
2546 if (fileName.isEmpty())
2553 fileName = new_data->connectionData()-> fileName();
2559 TQProcess proc(args, this, "process");
2560 proc.setCommunication((TQProcess::Communication)0);
2562 proc.setWorkingDirectory( TQFileInfo(fileName).dir( true) );
2563 if (!proc.start()) {
2564 d->showStartProcessMsg(args);
2584 TQString* shortcutFileName)
2587 KexiNewProjectWizard wiz( Kexi::connset(), 0, "KexiNewProjectWizard", true);
2588 wiz.setConfirmOverwrites(confirmOverwrites);
2589 if (wiz.exec() != TQDialog::Accepted) {
2596 if (shortcutFileName)
2597 *shortcutFileName = TQString();
2598 if (wiz.projectConnectionData()) {
2601 kdDebug() << "DBNAME: " << wiz.projectDBName() << " SERVER: " << cdata-> serverInfoString() << endl;
2602 new_data = new KexiProjectData( *cdata, wiz.projectDBName(), wiz.projectCaption() );
2603 if (shortcutFileName)
2606 else if (!wiz.projectDBName().isEmpty()) {
2609 cdata. caption = wiz.projectCaption();
2612 new_data = new KexiProjectData( cdata, wiz.projectDBName(), wiz.projectCaption() );
2633 tristate res = d->prj->create( true );
2639 kdDebug() << "KexiMainWindowImpl::slotProjectNew(): new project created --- " << endl;
2649KexiMainWindowImpl::slotProjectOpen()
2653 this, "KexiOpenDialog");
2655 if (dlg.exec()!=TQDialog::Accepted)
2658 openProject(dlg.selectedFileName(), dlg.selectedExistingConnection());
2662 const TQString& fileNameForConnectionData, const TQString& dbName)
2668 if (!fileNameForConnectionData.isEmpty()) {
2671 kdWarning() << "KexiMainWindowImpl::openProject() cdata?" << endl;
2680 const TQValueList<KexiProjectData::ObjectInfo>& autoopenObjects)
2687 bool deleteAfterOpen = false;
2690 if (dbName.isEmpty()) {
2699 deleteAfterOpen = true;
2704 if (aFileName.isEmpty()) {
2705 kdWarning() << "KexiMainWindowImpl::openProject(): aFileName.isEmpty()" << endl;
2709 kdDebug() << "Project File: " << aFileName << endl;
2713 TQString detectedDriverName;
2716 importActionData, detectedDriverName, cdata. driverName, aFileName, this );
2720 if (importActionData) {
2730 deleteAfterOpen = true;
2736 if (deleteAfterOpen)
2744 TQString fileNameForConnectionData;
2745 if (aFileName.isEmpty()) {
2753 const TQString& fileNameForConnectionData, const TQString& dbName)
2755 TQString fileName(aFileName);
2757 args << tqApp->applicationFilePath();
2760 if (fileName.isEmpty()) {
2761 if (!fileNameForConnectionData.isEmpty())
2762 args << "--skip-conn-dialog";
2764 if (dbName.isEmpty()) {
2765 fileName = fileNameForConnectionData;
2768 args << "--connection" << fileNameForConnectionData;
2772 if (fileName.isEmpty()) {
2773 kdWarning() << "KexiMainWindowImpl::openProjectInExternalKexiInstance() fileName?" << endl;
2778 TQProcess proc(args, this, "process");
2779 proc.setWorkingDirectory( TQFileInfo(fileName).dir( true) );
2780 const bool ok = proc.start();
2782 d->showStartProcessMsg(args);
2788KexiMainWindowImpl::slotProjectOpenRecentAboutToShow()
2812 TDEPopupMenu *popup = d->action_open_recent->popupMenu();
2815 d->action_open_recent_projects_title_id = popup->insertTitle(i18n( "Recently Opened Databases"));
2827 popup->insertItem(SmallIconSet( "kexiproject_sqlite"), "My project 1");
2828 popup->insertItem(SmallIconSet( "kexiproject_sqlite"), "My project 2");
2829 popup->insertItem(SmallIconSet( "kexiproject_sqlite"), "My project 3");
2833 d->action_open_recent_connections_title_id =
2834 d->action_open_recent->popupMenu()->insertTitle(i18n( "Recently Connected Database Servers"));
2840 popup->insertItem(SmallIconSet( "socket"), "My connection 1");
2841 popup->insertItem(SmallIconSet( "socket"), "My connection 2");
2842 popup->insertItem(SmallIconSet( "socket"), "My connection 3");
2843 popup->insertItem(SmallIconSet( "socket"), "My connection 4");
2848KexiMainWindowImpl::slotProjectOpenRecent( int id)
2852 kdDebug() << "KexiMainWindowImpl::slotProjectOpenRecent("<< id<< ")"<<endl;
2856KexiMainWindowImpl::slotProjectOpenRecentMore()
2858 KEXI_UNFINISHED(i18n( "Open Recent"));
2862KexiMainWindowImpl::slotProjectSave()
2872KexiMainWindowImpl::slotProjectSaveAs()
2874 KEXI_UNFINISHED(i18n( "Save object as"));
2878KexiMainWindowImpl::slotProjectPrint()
2880 if (d->curDialog && d->curDialog->partItem())
2885KexiMainWindowImpl::slotProjectPrintPreview()
2887 if (d->curDialog && d->curDialog->partItem())
2892KexiMainWindowImpl::slotProjectPageSetup()
2894 if (d->curDialog && d->curDialog->partItem())
2898void KexiMainWindowImpl::slotProjectExportDataTable()
2900 if (d->curDialog && d->curDialog->partItem())
2905KexiMainWindowImpl::slotProjectProperties()
2913KexiMainWindowImpl::slotProjectClose()
2918void KexiMainWindowImpl::slotProjectRelations()
2926void KexiMainWindowImpl::slotImportFile()
2928 KEXI_UNFINISHED( "Import: " + i18n( "From File..."));
2931void KexiMainWindowImpl::slotImportServer()
2933 KEXI_UNFINISHED( "Import: " + i18n( "From Server..."));
2937KexiMainWindowImpl::slotProjectQuit()
2944void KexiMainWindowImpl::slotViewNavigator()
2946 if (!d->nav || !d->navToolWindow)
2948 if (!d->nav->isVisible())
2949 makeWidgetDockVisible(d->nav);
2954 d->navToolWindow->wrapperWidget()->raise();
2956 d->block_KMdiMainFrm_eventFilter= true;
2958 d->block_KMdiMainFrm_eventFilter= false;
2961void KexiMainWindowImpl::slotViewMainArea()
2964 d->curDialog->setFocus();
2967void KexiMainWindowImpl::slotViewPropertyEditor()
2969 if (!d->propEditor || !d->propEditorToolWindow)
2975 if (!d->propEditorTabWidget->isVisible())
2976 makeWidgetDockVisible(d->propEditorTabWidget);
2979 d->propEditorToolWindow->wrapperWidget()->raise();
2981 d->block_KMdiMainFrm_eventFilter= true;
2982 if (d->propEditorTabWidget->currentPage())
2983 d->propEditorTabWidget->currentPage()->setFocus();
2984 d->block_KMdiMainFrm_eventFilter= false;
2995 if (!d->curDialog) {
2996 d->toggleLastCheckedMode();
2999 if (!d->curDialog->supportsViewMode( viewMode )) {
3000 showErrorMessage(i18n( "Selected view is not supported for \"%1\" object.")
3001 .arg(d->curDialog->partItem()->name()),
3002 i18n( "Selected view (%1) is not supported by this object type (%2).")
3004 .arg(d->curDialog->part()->instanceCaption()) );
3005 d->toggleLastCheckedMode();
3008 int prevViewMode = d->curDialog->currentViewMode();
3010 d->curDialog->part(), viewMode );
3011 tristate res = d->curDialog->switchToViewMode( viewMode );
3016 d->toggleLastCheckedMode();
3021 d->toggleLastCheckedMode();
3026 KXMLGUIClient *viewClient=d->curDialog->guiClient();
3028 if (d->curDialogViewGUIClient && !viewClient)
3029 guiFactory()->removeClient(d->curDialogViewGUIClient);
3030 d->curDialogViewGUIClient=viewClient;
3032 d->updatePropEditorVisibility(viewMode);
3035 d->updateFindDialogContents();
3040void KexiMainWindowImpl::slotViewDataMode()
3045void KexiMainWindowImpl::slotViewDesignMode()
3057 if (d->insideCloseDialog && dynamic_cast<KexiDialogBase * >(pWnd)) {
3058 d->windowsToClose.append( dynamic_cast<KexiDialogBase * >(pWnd));
3070 closeDialog( dynamic_cast<KexiDialogBase * >(pWnd), layoutTaskBar);
3075 bool& allowOverwriting, const TQString& messageWhenAskingForName )
3079#ifdef KEXI_ADD_CUSTOM_OBJECT_CREATION
3080# include "keximainwindowimpl_customobjcreation.h"
3082 if (!d->nameDialog) {
3083 d->nameDialog = new KexiNameDialog(
3084 messageWhenAskingForName, this, "nameDialog");
3086 d->nameDialog->widget()->addNameSubvalidator(
3090 d->nameDialog->widget()->setMessageText( messageWhenAskingForName );
3092 d->nameDialog->widget()->setCaptionText(partItem->caption());
3093 d->nameDialog->widget()->setNameText(partItem->name());
3094 d->nameDialog->setCaption(i18n( "Save Object As"));
3095 d->nameDialog->setDialogIcon( DesktopIcon( info-> itemIcon(), TDEIcon::SizeMedium ) );
3096 allowOverwriting = false;
3099 if (d->nameDialog->exec()!=TQDialog::Accepted)
3105 d->nameDialog->widget()->nameText(), tmp_sdata );
3108 found = result== true;
3110 if (allowOverwriting) {
3111 int res = KMessageBox::warningYesNoCancel( this,
3112 "<p>"+part-> i18nMessage( "Object \"%1\" already exists.", 0)
3113 .arg(d->nameDialog->widget()->nameText())
3114 + "</p><p>"+i18n( "Do you want to replace it?")+ "</p>", 0,
3115 KGuiItem(i18n( "&Replace"), "button_yes"),
3116 KGuiItem(i18n( "&Choose Other Name...")),
3117 TQString(), KMessageBox::Notify|KMessageBox::Dangerous);
3118 if (res == KMessageBox::No)
3120 else if (res == KMessageBox::Cancel)
3123 allowOverwriting = true;
3128 KMessageBox::information( this,
3129 "<p>"+part-> i18nMessage( "Object \"%1\" already exists.", 0)
3130 .arg(d->nameDialog->widget()->nameText())
3131 + "</p><p>"+i18n( "Please choose other name.")+ "</p>");
3142 partItem->setName( d->nameDialog->widget()->nameText() );
3143 partItem->setCaption( d->nameDialog->widget()->captionText() );
3155 showErrorMessage(i18n( "Saving \"%1\" object failed.").arg(dlg-> partItem()->name()),
3160 const int oldItemID = dlg-> partItem()->identifier();
3162 bool allowOverwriting = false;
3164 messageWhenAskingForName );
3172 showErrorMessage(i18n( "Saving new \"%1\" object failed.").arg(dlg-> partItem()->name()),
3181 d->updateDialogId(dlg, oldItemID);
3195 if (d->insideCloseDialog)
3198#ifndef KEXI_NO_PENDING_DIALOGS
3199 d->addItemToPendingDialogs(dlg-> partItem(), Private::DialogClosingJob);
3202 d->insideCloseDialog = true;
3204 if (dlg == d->curDialog && !dlg->isAttached()) {
3205 if (d->propEditor) {
3208 d->propEditor->editor()->changeSet( 0, false );
3213 if (dlg-> dirty() && !d->forceDialogClosing && !doNotSaveChanges) {
3215 KGuiItem saveChanges( KStdGuiItem::save() );
3216 saveChanges.setToolTip(i18n( "Save changes"));
3217 saveChanges.setWhatsThis(
3218 i18n( "Pressing this button will save all recent changes made in \"%1\" object." )
3220 KGuiItem discardChanges( KStdGuiItem::discard() );
3221 discardChanges.setWhatsThis(
3222 i18n( "Pressing this button will discard all recent changes made in \"%1\" object." )
3230 ":additional message before saving design", dlg);
3231 if (additionalMessage.startsWith( ":"))
3232 additionalMessage = TQString();
3233 if (!additionalMessage.isEmpty())
3234 additionalMessage = "<p>"+additionalMessage+ "</p>";
3236 const int questionRes = KMessageBox::warningYesNoCancel( this,
3237 "<p>"+dlg-> part()-> i18nMessage( "Design of object \"%1\" has been modified.", dlg)
3238 .arg(dlg-> partItem()->name())+ "</p><p>"+i18n( "Do you want to save changes?")+ "</p>"
3239 + additionalMessage ,
3243 if (questionRes==KMessageBox::Cancel) {
3244#ifndef KEXI_NO_PENDING_DIALOGS
3245 d->removePendingDialog(dlg-> id());
3247 d->insideCloseDialog = false;
3248 d->windowsToClose.clear();
3251 if (questionRes==KMessageBox::Yes) {
3257#ifndef KEXI_NO_PENDING_DIALOGS
3258 d->removePendingDialog(dlg-> id());
3260 d->insideCloseDialog = false;
3261 d->windowsToClose.clear();
3264 remove_on_closing = false;
3268 const int dlg_id = dlg-> id();
3270 if (remove_on_closing) {
3273#ifndef KEXI_NO_PENDING_DIALOGS
3274 d->removePendingDialog(dlg-> id());
3278 d->insideCloseDialog = false;
3279 d->windowsToClose.clear();
3286 d->nav->updateItemName( *dlg-> partItem(), false );
3289 d->removeDialog(dlg_id);
3291 int printedObjectID = 0;
3292 if (d->pageSetupDialogItemID2dataItemID_map.contains(dlg_id))
3293 printedObjectID = d->pageSetupDialogItemID2dataItemID_map[ dlg_id ];
3294 d->pageSetupDialogs.take(printedObjectID);
3297 KXMLGUIClient *viewClient = dlg-> guiClient();
3298 if (d->curDialogGUIClient==client) {
3299 d->curDialogGUIClient=0;
3301 if (d->curDialogViewGUIClient==viewClient) {
3302 d->curDialogViewGUIClient=0;
3306 if (d->closedDialogGUIClient && d->closedDialogGUIClient!=client)
3307 guiFactory()->removeClient(d->closedDialogGUIClient);
3308 if (d->openedDialogsCount()==0) {
3309 d->closedDialogGUIClient=0;
3310 guiFactory()->removeClient(client);
3314 d->closedDialogGUIClient=client;
3319 if (d->closedDialogViewGUIClient && d->closedDialogViewGUIClient!=viewClient)
3320 guiFactory()->removeClient(d->closedDialogViewGUIClient);
3321 if (d->openedDialogsCount()==0) {
3322 d->closedDialogViewGUIClient=0;
3323 guiFactory()->removeClient(viewClient);
3327 d->closedDialogViewGUIClient=viewClient;
3331 const bool isInMaximizedChildFrmMode = this->isInMaximizedChildFrmMode();
3333 KMdiMainFrm::closeWindow(dlg, layoutTaskBar);
3336 if (d->openedDialogsCount()==0) {
3337 d->maximizeFirstOpenedChildFrm = isInMaximizedChildFrmMode;
3340 d->updatePropEditorVisibility(0);
3344 d->insideCloseDialog = false;
3345 if (!d->windowsToClose.isEmpty())
3348#ifndef KEXI_NO_PENDING_DIALOGS
3349 d->removePendingDialog( dlg_id );
3352 if (!d->pendingDialogsExist()) {
3353 d->executeActionWhenPendingJobsAreFinished();
3359void KexiMainWindowImpl::detachWindow(KMdiChildView *pWnd, bool bShow)
3361 KMdiMainFrm::detachWindow(pWnd,bShow);
3363 pWnd->setIcon( DesktopIcon( static_cast<KexiDialogBase * >(pWnd)->itemIcon() ) );
3366 dynamic_cast<KexiDialogBase* >(pWnd)->sendDetachedStateToCurrentView();
3369void KexiMainWindowImpl::attachWindow(KMdiChildView *pWnd, bool , bool bAutomaticResize)
3372 KMdiMainFrm::attachWindow(pWnd, true,bAutomaticResize);
3374 if (pWnd->mdiParent()->state() == KMdiChildFrm::Normal
3375 && pWnd->geometry().bottom() > pWnd->mdiParent()->mdiAreaContentsRect().bottom())
3377 TQRect r = pWnd->geometry();
3378 r.setBottom( pWnd->mdiParent()->mdiAreaContentsRect().bottom() - 5 );
3379 pWnd->setGeometry( r );
3382 pWnd->mdiParent()->setIcon( SmallIcon( static_cast<KexiDialogBase * >(pWnd)->itemIcon() ) );
3383 if ( dynamic_cast<KexiDialogBase* >(pWnd))
3384 dynamic_cast<KexiDialogBase* >(pWnd)->sendAttachedStateToCurrentView();
3390 w = w->parentWidget();
3396 return w->inherits( "KexiDialogBase") || w->inherits( "KexiViewBase");
3402 if (e->type()==TQEvent::KeyPress) {
3403 KexiVDebug << "KEY EVENT " << TQString::number( static_cast<TQKeyEvent* >(e)->key(), 16) << endl;
3406 if (e->type()==TQEvent::AccelOverride) {
3410 if ( static_cast<TQKeyEvent* >(e)->key()==TQt::Key_Tab && static_cast<TQKeyEvent* >(e)->state() == ControlButton) {
3411 if (d->action_window_next->shortcut().keyCodeQt()==TQt::Key_Tab+TQt::CTRL && d->action_window_next->shortcut().count()==1
3412 && (mdiMode()==KMdi::TabPageMode || mdiMode()==KMdi::IDEAlMode))
3414 static_cast<TQKeyEvent* >(e)->accept();
3418 if (e->type()==TQEvent::Close) {
3419 KexiVDebug << "Close EVENT" << endl;
3421 if (e->type()==TQEvent::Resize) {
3422 KexiVDebug << "Resize EVENT" << endl;
3424 if (e->type()==TQEvent::ShowMaximized) {
3425 KexiVDebug << "ShowMaximized EVENT" << endl;
3434 TQWidget *focus_w = 0;
3435 if (obj->inherits( "TQPopupMenu")) {
3441 if (e->type()==TQEvent::Hide || e->type()==TQEvent::Show) {
3442 KexiVDebug << e->type() << endl;
3444 if (!d->focus_before_popup.isNull()) {
3445 d->focus_before_popup->setFocus();
3446 d->focus_before_popup=0;
3450 focus_w->setFocus();
3459 if (e->type()==TQEvent::MouseButtonPress) {
3460 TQWidget *w = findWindow( static_cast<TQWidget* >(obj));
3461 KexiVDebug << "MouseButtonPress EVENT " << (w ? w->name() : 0) << endl;
3467 TQWidget *w = findWindow( static_cast<TQWidget* >(obj));
3468 if (e->type()==TQEvent::FocusIn) {
3470 KexiVDebug << "Focus EVENT" << endl;
3471 KexiVDebug << (focus_w ? focus_w->name() : "" ) << endl;
3472 KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name() <<endl;
3473#ifdef KEXI_STATUSBAR_DEBUG
3474 TQWidget *focus_widget = focus_w ? focus_w->focusWidget() : 0;
3475 d->statusBar->setStatus(TQString( "FOCUS VIEW: %1 %2, FOCUS WIDGET: %3 %4")
3476 .arg(focus_w ? focus_w->className() : "").arg(focus_w ? focus_w->name() : "")
3477 .arg(focus_widget ? focus_widget->className() : "").arg(focus_widget ? focus_widget->name() : "")
3481 else if (e->type()==TQEvent::FocusOut) {
3483 KexiVDebug << "Focus OUT EVENT" << endl;
3484 KexiVDebug << (focus_w ? focus_w->name() : "" ) << endl;
3485 KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name() <<endl;
3486#ifdef KEXI_STATUSBAR_DEBUG
3487 TQWidget *focus_widget = focus_w ? focus_w->focusWidget() : 0;
3488 d->statusBar->setStatus(TQString( "FOCUS VIEW: %1 %2, FOCUS WIDGET: %3 %4")
3489 .arg(focus_w ? focus_w->className() : "").arg(focus_w ? focus_w->name() : "")
3490 .arg(focus_widget ? focus_widget->className() : "").arg(focus_widget ? focus_widget->name() : "")
3494 if (e->type()==TQEvent::WindowActivate) {
3495 KexiVDebug << "WindowActivate EVENT" << endl;
3496 KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name()<<endl;
3499 if (e->type()==TQEvent::FocusIn) {
3516 if (e->type()==TQEvent::FocusOut && focus_w && focus_w==d->curDialog && actionProxyFor( obj )) {
3521 if (!d->focus_before_popup.isNull() && e->type()==TQEvent::FocusOut && obj->inherits( "KMenuBar")) {
3523 d->focus_before_popup->setFocus();
3524 d->focus_before_popup=0;
3530 if (e->type()==TQEvent::FocusOut) {
3531 if ( static_cast<TQFocusEvent* >(e)->reason()==TQFocusEvent::Popup) {
3534 d->focus_before_popup=d->curDialog;
3538 d->focus_before_popup=focus_w;
3544 if (w && w==d->nav) {
3546 if (e->type()==TQEvent::FocusIn) {
3548 } else if (e->type()==TQEvent::WindowActivate && w==d->focus_before_popup) {
3550 d->focus_before_popup=0;
3552 } else if (e->type()==TQEvent::FocusOut) {
3553 if ( static_cast<TQFocusEvent* >(e)->reason()==TQFocusEvent::Tab) {
3556 d->curDialog->activate();
3560 else if ( static_cast<TQFocusEvent* >(e)->reason()==TQFocusEvent::Popup) {
3561 d->focus_before_popup=w;
3564 } else if (e->type()==TQEvent::Hide) {
3569 if (d->block_KMdiMainFrm_eventFilter)
3571 return KMdiMainFrm::eventFilter(obj,e);
3585 int viewMode, bool &openingCancelled, TQMap<TQString,TQString>* staticObjectArgs)
3590 return openObject(item, viewMode, openingCancelled, staticObjectArgs);
3595 TQMap<TQString,TQString>* staticObjectArgs, TQString* errorMessage)
3599 *errorMessage = i18n( "opening is not allowed in \"data view/design view/text view\" mode",
3601 openingCancelled = true;
3605 if (!d->prj || !item)
3608#ifndef KEXI_NO_PENDING_DIALOGS
3609 Private::PendingJobType pendingType;
3610 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
3611 if (pendingType != Private::NoJob) {
3612 openingCancelled = true;
3616 KexiDialogBase *dlg = d->openedDialogFor( item );
3618 openingCancelled = false;
3620 bool needsUpdateViewGUIClient = true;
3627 needsUpdateViewGUIClient = false;
3630 d->updatePropEditorVisibility(viewMode);
3637#ifndef KEXI_NO_PENDING_DIALOGS
3638 d->addItemToPendingDialogs(item, Private::DialogOpeningJob);
3640 dlg = d->prj->openObject( this, *item, viewMode, staticObjectArgs);
3644#ifndef KEXI_NO_PENDING_DIALOGS
3645 d->removePendingDialog(item->identifier());
3652 if (needsUpdateViewGUIClient ) {
3654 KXMLGUIClient *viewClient=dlg-> guiClient();
3656 if (d->curDialogViewGUIClient && !viewClient)
3657 guiFactory()->removeClient(d->curDialogViewGUIClient);
3658 d->curDialogViewGUIClient=viewClient;
3665#ifndef KEXI_NO_PENDING_DIALOGS
3666 d->removePendingDialog( dlg-> id() );
3669 if (!d->pendingDialogsExist()) {
3670 d->executeActionWhenPendingJobsAreFinished();
3679 bool openingCancelled;
3685 bool &openingCancelled)
3688 openingCancelled = true;
3691 if (!d->prj || !item)
3693#ifndef KEXI_NO_PENDING_DIALOGS
3694 Private::PendingJobType pendingType;
3695 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
3696 if (pendingType!=Private::NoJob) {
3697 openingCancelled = true;
3701 KexiDialogBase *dlg = d->openedDialogFor( item );
3703 openingCancelled = false;
3714 if (viewMode == Kexi::DataViewMode && !(part-> supportedViewModes() & Kexi::DataViewMode)) {
3721 return openObject(item, viewMode, openingCancelled);
3726#ifndef KEXI_NO_PENDING_DIALOGS
3727 Private::PendingJobType pendingType;
3728 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
3729 if (pendingType == Private::DialogClosingJob)
3731 else if (pendingType == Private::DialogOpeningJob)
3734 KexiDialogBase *dlg = d->openedDialogFor( item );
3744 openingCancelled = true;
3747 openingCancelled = false;
3748 if (!d->prj || !info)
3754#ifdef KEXI_ADD_CUSTOM_OBJECT_CREATION
3755# include "keximainwindowimpl_customobjcreation.h"
3765 d->nav->addItem(*it);
3766 return openObject(it, Kexi::DesignViewMode, openingCancelled);
3773 if (!d->prj || !item)
3781 if (KMessageBox::No == KMessageBox::warningYesNo( this,
3782 "<p>"+i18n( "Do you want to permanently delete:\n"
3784 "If you click \"Delete\", you will not be able to undo the deletion.")
3785 .arg( "</p><p>"+part-> instanceCaption()+ " \""+ item->name() + "\"?</p>" ),
3786 0, KGuiItem(i18n( "Delete"), "edit-delete"), KStdGuiItem::no()))
3795 KexiDialogBase * pageSetupDlg = d->pageSetupDialogs[ item->identifier() ];
3796 const bool oldInsideCloseDialog = d->insideCloseDialog;
3797 d->insideCloseDialog = false;
3799 d->insideCloseDialog = oldInsideCloseDialog;
3804#ifndef KEXI_NO_PENDING_DIALOGS
3805 Private::PendingJobType pendingType;
3806 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
3807 if (pendingType!=Private::NoJob) {
3811 KexiDialogBase *dlg = d->openedDialogFor( item );
3816 const bool tmp = d->forceDialogClosing;
3818 d->forceDialogClosing = true;
3820 d->forceDialogClosing = tmp;
3831 int dataItemID = d->pageSetupDialogItemID2dataItemID_map[item->identifier()];
3832 d->pageSetupDialogItemID2dataItemID_map.remove(item->identifier());
3833 d->pageSetupDialogs.take( dataItemID );
3835 if (!d->prj->removeObject( this, *item)) {
3837 showSorryMessage( i18n( "Could not remove object.") );
3849 d->pendingDialogsExist();
3850 TQString newName = _newName.stripWhiteSpace();
3851 if (newName.isEmpty()) {
3852 showSorryMessage( i18n( "Could not set empty name for this object.") );
3857 const bool res = d->prj->renameObject( this, *item, newName);
3860 showErrorMessage( d->prj, i18n( "Renaming object \"%1\" failed.").arg(newName) );
3864 d->pendingDialogsExist();
3869#ifndef KEXI_NO_PENDING_DIALOGS
3870 Private::PendingJobType pendingType;
3871 KexiDialogBase *dlg = d->openedDialogFor( &item, pendingType );
3872 if (pendingType!=Private::NoJob)
3875 KexiDialogBase *dlg = d->openedDialogFor( &item );
3881 dlg->updateCaption();
3882 if ( static_cast<KexiDialogBase* >(d->curDialog)==dlg)
3888 return --d->privateIDCounter;
3894 d->propEditor->editor()->acceptInput();
3897void KexiMainWindowImpl::propertySetSwitched( KexiDialogBase *dlg, bool force,
3898 bool preservePrevSelection, const TQCString& propertyToSelect)
3900 kdDebug() << "KexiMainWindowImpl::propertySetSwitched() d->curDialog: "
3901 << (d->curDialog ? d->curDialog->caption() : TQString( "NULL")) << " dlg: " << (dlg ? dlg->caption() : TQString( "NULL"))<< endl;
3902 if ((KexiDialogBase*)d->curDialog!=dlg) {
3906 if (d->propEditor) {
3907 KoProperty::Set *newBuf = d->curDialog ? d->curDialog->propertySet() : 0;
3908 if (!newBuf || (force || static_cast<KoProperty::Set* >(d->propBuffer) != newBuf)) {
3909 d->propBuffer = newBuf;
3910 if (preservePrevSelection) {
3911 if (propertyToSelect.isEmpty())
3912 d->propEditor->editor()->changeSet( d->propBuffer, preservePrevSelection );
3914 d->propEditor->editor()->changeSet( d->propBuffer, propertyToSelect );
3925 d->nav->updateItemName( *item, dlg-> dirty() );
3931void KexiMainWindowImpl::slotMdiModeHasBeenChangedTo(KMdi::MdiMode)
3938void KexiMainWindowImpl::slotTipOfTheDay()
3948void KexiMainWindowImpl::slotStartFeedbackAgent()
3950#ifndef KEXI_NO_FEEDBACK_AGENT
3951#ifdef FEEDBACK_CLASS
3952 const TDEAboutData* about = TDEApplication::kApplication()->aboutData();
3953 FEEDBACK_CLASS* wizard = new FEEDBACK_CLASS( about->programName(),
3954 about->version(), 0, 0, 0, FEEDBACK_CLASS::AllPages );
3956 if ( wizard->exec() )
3958 TDEApplication::kApplication()->invokeMailer( "kexi-reports-dummy@kexi.org",
3959 TQString(), TQString(),
3960 about->appName() + TQCString( " [feedback]" ),
3961 wizard->feedbackDocument().toString( 2 ).local8Bit() );
3972 if (onStartup && !d->showImportantInfoOnStartup)
3975 TQString key = TQString( "showImportantInfo %1").arg(KEXI_VERSION_STRING);
3976 d->config->setGroup( "Startup");
3977 bool show = d->config->readBoolEntry(key, true);
3979 if (show || !onStartup) {
3980 d->config->setGroup( "TipOfDay");
3981 if (!d->config->hasKey( "RunOnStart"))
3982 d->config->writeEntry( "RunOnStart", true);
3984 TQString lang = TDEGlobal::locale()->language();
3985 TQString fname = locate( "data", TQString( "kexi/readme_")+lang);
3986 if (fname.isEmpty())
3987 fname = locate( "data", "kexi/readme_en");
3988 KTipDialog tipDialog( new KTipDatabase(TQString()), 0);
3989 tipDialog.setCaption(i18n( "Important Information"));
3990 TQObjectList *l = tipDialog.queryList( "KPushButton" );
3992 for (TQObjectListIt it( *l ); it.current() && i<2; ++it, i++ )
3993 static_cast<KPushButton* >(it.current())->hide();
3995 if ( f.open( IO_ReadOnly ) ) {
3996 TQTextStream ts(&f);
3997 ts.setCodec( TDEGlobal::locale()->codecForEncoding() );
4000 tb->setText( TQString( "<qt>%1</qt>").arg(ts.read()) );
4005 tipDialog.adjustSize();
4006 TQRect desk = TQApplication::desktop()->screenGeometry( TQApplication::desktop()->screenNumber( this) );
4007 tipDialog.resize( TQMAX(tipDialog.width(),desk.width()*3/5), TQMAX(tipDialog.height(),desk.height()*3/5) );
4008 KDialog::centerOnScreen(&tipDialog);
4009 tipDialog.setModal ( true );
4012 d->config->setGroup( "TipOfDay");
4013 show = d->config->readBoolEntry( "RunOnStart", show);
4017 d->config->setGroup( "Startup");
4018 d->config->writeEntry(key,show);
4019 d->showImportantInfoOnStartup = false;
4023void KexiMainWindowImpl::slotOptionsEnableForms( bool show, bool noMessage)
4025 Q_UNUSED(noMessage);
4056 TQString err_msg = i18n( "Could not start project \"%1\" in Final Mode.")
4061 showErrorMessage( err_msg, i18n( "No Final Mode data found.") );
4069 showErrorMessage( err_msg, i18n( "Error reading Final Mode data.") );
4073 TQString startupPart;
4074 TQString startupItem;
4077 kdDebug() << "KexiMainWinImpl::initFinalMode(): property: [" << c-> value(1).toString() << "] " << c-> value(2).toString() << endl;
4078 if(c-> value(1).toString() == "startup-part")
4079 startupPart = c-> value(2).toString();
4080 else if(c-> value(1).toString() == "startup-item")
4081 startupItem = c-> value(2).toString();
4082 else if(c-> value(1).toString() == "mainxmlui")
4083 setXML(c-> value(2).toString());
4085 d->prj->dbConnection()->deleteCursor(c);
4087 kdDebug() << "KexiMainWinImpl::initFinalMode(): part: " << startupPart << endl;
4088 kdDebug() << "KexiMainWinImpl::initFinalMode(): item: " << startupItem << endl;
4092 guiFactory()->addClient( this);
4093 setStandardToolBarMenuEnabled( false);
4094 setHelpMenuEnabled( false);
4099 showErrorMessage( err_msg, i18n( "Specified plugin does not exist.") );
4105 bool openingCancelled;
4106 if(! openObject(item, Kexi::DataViewMode, openingCancelled) && !openingCancelled) {
4108 showErrorMessage( err_msg, i18n( "Specified object could not be opened.") );
4112 TQWidget::setCaption( "MyApp");
4121 KexiDB::Cursor *c = d->prj->dbConnection()->executeQuery( "SELECT p_id, name, text, icon, method, arguments FROM kexi__useractions WHERE scope = 0");
4129 d->prj->dbConnection()->deleteCursor(c);
4140void KexiMainWindowImpl::slotToolsProjectMigration()
4149 const bool projectWasOpened = d->prj;
4154 this, "KexiOpenDialog");
4156 if (dlg.exec()!=TQDialog::Accepted)
4174 if ( true==res && !detectedImportAction)
4177 KMessageBox::information( this, "<qt>"+
4178 i18n( "Compacting database file <nobr>\"%1\"</nobr> is not supported.")
4179 .arg(TQDir::convertSeparators(cdata. fileName())));
4186 if ( !(d->prj && d->prj->dbConnection()
4190 if (KMessageBox::Continue != KMessageBox::warningContinueCancel( this,
4191 i18n( "The current project has to be closed before compacting the database. "
4192 "It will be open again after compacting.\n\nDo you want to continue?")))
4196 drv = d->prj->dbConnection()->driver();
4209 if (projectWasOpened)
4218 TQMap<TQString,TQString> args;
4219 args.insert( "mimeType", mimeType);
4220 args.insert( "databaseName", databaseName);
4224 args.insert( "connectionData", str);
4231 const int result = dlg->exec();
4234 if (result!=TQDialog::Accepted)
4238 TQString destinationDatabaseName( args[ "destinationDatabaseName"] );
4239 TQString fileName, destinationConnectionShortcut, dbName;
4240 if (!destinationDatabaseName.isEmpty()) {
4241 if (args.contains( "destinationConnectionShortcut")) {
4243 destinationConnectionShortcut = args[ "destinationConnectionShortcut"];
4247 fileName = destinationDatabaseName;
4248 destinationDatabaseName = TQString();
4251 destinationDatabaseName);
4277 TQMap<TQString,TQString> args;
4278 args.insert( "sourceType", "file");
4280 "csv_importexport", "KexiCSVImportDialog", this, this, 0, &args);
4288 const TQString& actionName)
4290 if (actionName == "exportToCSV")
4292 else if (actionName == "copyToClipboardAsCSV")
4295 kexiwarn << "KexiMainWindowImpl::executeCustomActionForObject(): no such action: "
4296 << actionName << endl;
4307 TQMap<TQString,TQString> args;
4308 args.insert( "destinationType", "file");
4309 args.insert( "itemId", TQString::number(item->identifier()));
4311 "csv_importexport", "KexiCSVExportWizard", this, this, 0, &args);
4314 int result = dlg->exec();
4316 return result == TQDialog::Rejected ? cancelled : true;
4330 const TQString& titleText)
4336 return cmd.print(settings, titleText);
4357 item, "KexiSimplePrintingCommand");
4359 d->addOpenedCustomObjectForItem(
4362 "KexiSimplePrintingCommand"
4383 KexiDialogBase *printingDialog = d->pageSetupDialogs[ item->identifier() ];
4384 if (printingDialog) {
4387 if (action == PreviewItem || action == PrintItem) {
4389 (action == PreviewItem) ? TQ_SLOT(printPreview()) : TQ_SLOT(print()));
4394#ifndef KEXI_NO_PENDING_DIALOGS
4395 Private::PendingJobType pendingType;
4396 KexiDialogBase *dlg = d->openedDialogFor( item, pendingType );
4397 if (pendingType!=Private::NoJob)
4400 KexiDialogBase *dlg = d->openedDialogFor( item );
4405 TQWidget *prevFocusWidget = focusWidget();
4407 d->action_data_save_row->activate();
4408 if (prevFocusWidget)
4409 prevFocusWidget->setFocus();
4415 KGuiItem saveChanges( KStdGuiItem::save() );
4416 saveChanges.setToolTip(i18n( "Save changes"));
4417 saveChanges.setWhatsThis(
4418 i18n( "Pressing this button will save all recent changes made in \"%1\" object." )
4419 .arg(item->name()) );
4420 KGuiItem doNotSave( KStdGuiItem::no() );
4421 doNotSave.setWhatsThis(
4422 i18n( "Pressing this button will ignore all unsaved changes made in \"%1\" object." )
4426 if (action == PrintItem)
4427 question = i18n( "Do you want to save changes before printing?");
4428 else if (action == PreviewItem)
4429 question = i18n( "Do you want to save changes before making print preview?");
4430 else if (action == PageSetupForItem)
4431 question = i18n( "Do you want to save changes before showing page setup?");
4435 const int questionRes = KMessageBox::warningYesNoCancel( this,
4436 "<p>"+dlg-> part()-> i18nMessage( "Design of object \"%1\" has been modified.", dlg)
4437 .arg(item->name()) + "</p><p>" + question + "</p>",
4441 if (KMessageBox::Cancel == questionRes)
4443 if (KMessageBox::Yes == questionRes) {
4445 if ( true != savingRes)
4454 printingPart, item->name()
4456 TQMap<TQString,TQString> staticObjectArgs;
4457 staticObjectArgs[ "identifier"] = TQString::number(item->identifier());
4458 if (action == PrintItem)
4459 staticObjectArgs[ "action"] = "print";
4460 else if (action == PreviewItem)
4461 staticObjectArgs[ "action"] = "printPreview";
4462 else if (action == PageSetupForItem)
4463 staticObjectArgs[ "action"] = "pageSetup";
4466 bool openingCancelled;
4467 printingDialog = openObject(printingPartItem, Kexi::DesignViewMode,
4468 openingCancelled, &staticObjectArgs);
4469 if (openingCancelled)
4471 if (!printingDialog)
4473 d->pageSetupDialogs.insert(item->identifier(), printingDialog);
4474 d->pageSetupDialogItemID2dataItemID_map.insert(
4475 printingDialog-> partItem()->identifier(), item->identifier());
4480void KexiMainWindowImpl::slotEditCopySpecialDataTable()
4492 TQMap<TQString,TQString> args;
4493 args.insert( "destinationType", "clipboard");
4494 args.insert( "itemId", TQString::number(item->identifier()));
4496 "csv_importexport", "KexiCSVExportWizard", this, this, 0, &args);
4499 const int result = dlg->exec();
4501 return result == TQDialog::Rejected ? cancelled : true;
4509 TQMap<TQString,TQString> args;
4510 args.insert( "sourceType", "clipboard");
4512 "csv_importexport", "KexiCSVImportDialog", this, this, 0, &args);
4519void KexiMainWindowImpl::slotEditFind()
4525 d->updateFindDialogContents( true);
4526 d->findDialog()->setReplaceMode( false);
4528 d->findDialog()->show();
4529 d->findDialog()->setActiveWindow();
4530 d->findDialog()->raise();
4533void KexiMainWindowImpl::slotEditFind( bool next)
4539 d->findDialog()->valueToFind(), d->findDialog()->options(), next);
4542 d->findDialog()->updateMessage( true == res );
4546void KexiMainWindowImpl::slotEditFindNext()
4548 slotEditFind( true );
4551void KexiMainWindowImpl::slotEditFindPrevious()
4553 slotEditFind( false );
4561 d->updateFindDialogContents( true);
4562 d->findDialog()->setReplaceMode( true);
4564 d->findDialog()->show();
4565 d->findDialog()->setActiveWindow();
4568void KexiMainWindowImpl::slotEditReplaceNext()
4581 d->findDialog()->valueToFind(), d->findDialog()->valueToReplaceWith(),
4582 d->findDialog()->options(), all);
4583 d->findDialog()->updateMessage( true == res );
4587void KexiMainWindowImpl::slotEditReplaceAll()
4597 if (d->maximizeFirstOpenedChildFrm) {
4598 flags |= KMdi::Maximize;
4599 d->maximizeFirstOpenedChildFrm = false;
4601 KexiMainWindow::addWindow( pView, flags );
4607#ifdef HAVE_TDENEWSTUFF
4609 d->newStuff = new KexiNewStuff( this);
4610 d->newStuff->download();
4618 slotViewNavigator();
4625 d->nav->selectItem(*item);
4634#include "keximainwindowimpl.moc"
Like TQSplitter but specially designed for dockwidgets stuff.
void setSeparatorPosInPercent(int percent) Set the separator position in percent (%), so the range must be [0..100].
int separatorPosInPercent() Return the separator position in percent (%), so the range is [0..100].
The Main Kexi navigator widget.
TQString fileNameForConnectionData(KexiDB::ConnectionData *data) const
KexiDB::ConnectionData * connectionDataForFileName(const TQString &fileName) const
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.
virtual TQVariant value(uint i)=0
Driver * driver(const TQString &name)
Generic database abstraction.
@ CompactingDatabaseSupported
static TQString defaultFileBasedDriverName()
static TQString defaultFileBasedDriverMimeType()
AdminTools & adminTools() const
void enableMessages(bool enable)
const TQString & errorMsg() const
Base class for child window of Kexi's main application window.
int currentViewMode() const
KexiPart::GUIClient * commonGUIClient() const
virtual void attachToGUIClient()
KexiPart::GUIClient * guiClient() const
KexiPart::Part * part() const
tristate storeData(bool dontAsk=false)
KexiPart::Item * partItem() const
KexiViewBase * selectedView() const
static KexiDialogBase * createKexiDialogInstance(const char *partName, KexiDB::MessageHandler *msgHdr, KexiMainWindow *mainWin, const char *objName=0)
static TQDialog * createModalDialogInstance(const char *partName, const char *dialogClass, KexiDB::MessageHandler *msgHdr, KexiMainWindow *mainWin, const char *objName=0, TQMap< TQString, TQString > *args=0)
void slotImportantInfo() just importantInfo(false);
void updateReadOnlyState()
bool switchToViewMode(int viewMode)
void createKexiProject(KexiProjectData *new_data) internal - creates and initializes kexi project
virtual void slotObjectRenamed(const KexiPart::Item &item, const TQCString &oldName)
void slotDirtyFlagChanged(KexiDialogBase *)
virtual KexiDialogBase * currentDialog() const
virtual tristate showPageSetupForItem(KexiPart::Item *item)
virtual bool acceptsSharedActions(TQObject *w)
void slotEditPasteSpecialDataTable()
void invalidateProjectWideActions()
static int create(int argc, char *argv[], TDEAboutData *aboutdata=0)
virtual tristate closeObject(KexiPart::Item *item)
void slotAutoOpenObjectsLater()
virtual void highlightObject(const TQCString &mime, const TQCString &name)
virtual tristate closeDialog(KexiDialogBase *dlg)
void initActions() reimplementation of events
virtual tristate printItem(KexiPart::Item *item)
KexiDialogBase * openObjectFromNavigator(KexiPart::Item *item, int viewMode, bool &openingCancelled)
virtual KexiProject * project() Project data of currently opened project or NULL if no project here yet.
virtual bool eventFilter(TQObject *obj, TQEvent *e)
virtual tristate getNewObjectInfo(KexiPart::Item *partItem, KexiPart::Part *part, bool &allowOverwriting, const TQString &messageWhenAskingForName=TQString())
void projectOpened() Emitted after opening a project, even after slotAutoOpenObjectsLater().
virtual void switchToIDEAlMode() reimplemented to add "restart is required" message box
virtual void closeWindow(KMdiChildView *pWnd, bool layoutTaskBar=true)
virtual void invalidateSharedActions(TQObject *o)
void slotViewTextMode() sometimes called "SQL View"
virtual bool userMode() const
tristate executeItem(KexiPart::Item *item)
bool initUserMode(KexiProjectData *projectData)
virtual void addWindow(KMdiChildView *pView, int flags=KMdi::StandardAdd)
virtual KexiDialogBase * openObject(KexiPart::Item *item, int viewMode, bool &openingCancelled, TQMap< TQString, TQString > *staticObjectArgs=0, TQString *errorMessage=0)
virtual TQPopupMenu * findPopupMenu(const char *popupName)
void importantInfo(bool onStartup) Shows 'important info' dialog, is onStartup is false, it's always shown.
virtual void registerChild(KexiDialogBase *dlg)
void activeWindowChanged(KMdiChildView *dlg)
void childClosed(KMdiChildView *dlg)
void slotLastActions() There are performed all actions that need to be done immediately after ctro (using timer).
void updateCustomPropertyPanelTabs(KexiDialogBase *prevDialog, int prevViewMode)
tristate printActionForItem(KexiPart::Item *item, PrintActionType action)
tristate copyItemToClipboardAsDataTable(KexiPart::Item *item) Shows "copy special as data table" dialog for item.
void slotToolsCompactDatabase()
void updateDialogViewGUIClient(KXMLGUIClient *viewClient)
TQWidget * findWindow(TQWidget *w)
void slotProjectImportDataTable()
void slotPartItemSelectedInNavigator(KexiPart::Item *item) Receives "selectionChanged()" signal from navigator to update some actions.
bool activateWindow(int id)
virtual tristate executeCustomActionForObject(KexiPart::Item *item, const TQString &actionName)
tristate openProjectInExternalKexiInstance(const TQString &aFileName, KexiDB::ConnectionData *cdata, const TQString &dbName)
tristate exportItemAsDataTable(KexiPart::Item *item) Shows "exports as data table" dialog for item.
virtual tristate printPreviewForItem(KexiPart::Item *item)
bool openingAllowed(KexiPart::Item *item, int viewMode)
tristate openProject(const KexiProjectData &projectData)
virtual TDEActionPtrList allActions() const
virtual void readProperties(TDEConfig *config)
void slotCaptionForCurrentMDIChild(bool childrenMaximized) internal
tristate createBlankProject()
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)
virtual int generatePrivateID()
void invalidateViewModeActions()
tristate createProjectFromTemplate(const KexiProjectData &projectData)
virtual bool newObject(KexiPart::Info *info, bool &openingCancelled)
virtual tristate saveObject(KexiDialogBase *dlg, const TQString &messageWhenAskingForName=TQString(), bool dontAsk=false)
PrintActionType Used by printActionForItem().
void beforeProjectClosing()
virtual void acceptPropertySetEditing()=0
void acceptProjectClosingRequested(bool &cancel)
void projectClosed() Emitted after closing the project.
Information about a Kexi Part (plugin).
bool isDataExportSupported() const
int projectPartID() const
TQCString mimeType() const
bool isPrintingSupported() const
TQString itemIcon() const
bool isExecuteSupported() const
Information about a single object that can be instantiated using Kexi Part.
Part * partForMimeType(const TQString &mimeTypt)
Info * infoForMimeType(const TQString &mimeType)
The main class for kexi frontend parts like tables, queries, forms and reports.
void createGUIClients(KexiMainWindow *win)
int supportedViewModes() const
int supportedUserViewModes() const
virtual void setupCustomPropertyPanelTabs(KTabWidget *tab, KexiMainWindow *mainWin)
TQString instanceCaption() const
virtual bool execute(KexiPart::Item *item, TQObject *sender=0)
virtual TQString i18nMessage(const TQCString &englishMessage, KexiDialogBase *dlg) const
Kexi project core data member.
TQValueList< ObjectInfo > autoopenObjects
TQString infoString(bool nobr=true) const
TQString databaseName() const
void addProjectData(KexiProjectData *data)
A project's main controller.
KexiDB::Connection * dbConnection() const
The container (acts as a dock window) for KexiPropertyEditor.
An interface used by Kexi views (KexiViewBase) supporting search/replace features.
virtual tristate findNextAndReplace(const TQVariant &valueToFind, const TQVariant &replacement, const KexiSearchAndReplaceViewInterface::Options &options, bool replaceAll)=0
virtual tristate find(const TQVariant &valueToFind, const KexiSearchAndReplaceViewInterface::Options &options, bool next)=0
void setActionVolatile(TDEAction *a, bool set)
KexiActionProxy * actionProxyFor(TQObject *o) const
virtual void invalidateSharedActions(TQObject *o)
TDEAction * createSharedAction(const TQString &text, const TQString &pix_name, const TDEShortcut &cut, const char *name, TDEActionCollection *col=0, const char *subclassName=0)
A command for simple printing and print preview. This class is instantiated in KexiMainWindowImpl so ...
bool showPrintPreview(const KexiSimplePrintingSettings &settings, const TQString &aTitleText=TQString(), bool reload=false)
Internal Kexi Simple Printing Plugin.
Settings data for simple printing engine.
static KexiSimplePrintingSettings load()
bool isProjectNavigatorVisible() const
bool forcedUserMode() const
KexiProjectData * projectData() const
TQString selectedFileName() const
static bool askForOverwriting(const TQString &filePath, TQWidget *parent=0)
@ DontConvert skip asking for conversion (used e.g. when dropdb is called)
@ SkipMessages do not display error or warning messages
@ ThisIsAProjectFile a hint, forces detection of the file as a project file
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.
KEXI_DB_EXPORT TQMap< TQString, TQString > toMap(const ConnectionData &data)
KEXIUTILS_EXPORT CopyFileResult copyFile(const TQString &src, const TQString &dest)
bool hasParent(TQObject *par, TQObject *o)
KEXIUTILS_EXPORT void serializeMap(const TQMap< TQString, TQString > &map, const TQByteArray &array)
type * findFirstChild(TQObject *o, const char *className, const char *objName=0)
KEXIUTILS_EXPORT TQString fileDialogFilterStrings(const TQStringList &mimeStrings, bool kdeFormat)
KEXICORE_EXPORT bool & tempShowScripts() false by default, flag loaded on main window startup
KexiStartupHandler & startupHandler()
KEXICORE_EXPORT bool & tempShowForms() false by default, flag loaded on main window startup
KEXICORE_EXPORT bool & tempShowMacros() false by default, flag loaded on main window startup
@ NoActionCategory no category at all
KEXICORE_EXPORT TQFont smallFont(TQWidget *init=0)
KEXICORE_EXPORT ActionCategories * actionCategories()
KEXICORE_EXPORT KexiPart::Manager & partManager() shared part manager
KEXICORE_EXPORT KexiDB::DriverManager & driverManager() shared driver manager
KEXICORE_EXPORT bool & tempShowReports() false by default, flag loaded on main window startup
KEXICORE_EXPORT KexiDBConnectionSet & connset() A set of known connections.
KEXICORE_EXPORT TQString nameForViewMode(int m) i18n'ed name of view mode m
KEXICORE_EXPORT KexiProjectSet & recentProjects() A set avaiulable of project infos.
@ TextViewMode Also known as SQL View Mode.
|