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 <tdeversion.h>
50#include <tdeglobalsettings.h>
51#include <tdeparts/componentfactory.h>
53#include <kstandarddirs.h>
54#include <kpushbutton.h>
55#include <ktextbrowser.h>
56#include <kiconloader.h>
57#include <ktabwidget.h>
60#include <tdefiledialog.h>
61#include <tderecentdocument.h>
63#include <kexidb/connection.h>
64#include <kexidb/utils.h>
65#include <kexidb/cursor.h>
66#include <kexidb/dbobjectnamevalidator.h>
67#include <kexidb/admin.h>
68#include <kexiutils/utils.h>
71#include "kexiactionproxy.h"
72#include "kexidialogbase.h"
73#include "kexipartmanager.h"
75#include "kexipartinfo.h"
76#include "kexipartguiclient.h"
77#include "kexiproject.h"
78#include "kexiprojectdata.h"
79#include "kexiprojectset.h"
81#include "kexistatusbar.h"
82#include "kexiinternalpart.h"
83#include "kexiactioncategories.h"
84#include "kexifinddialog.h"
85#include "kexisearchandreplaceiface.h"
87#include "kde2_closebutton.xpm"
89#include <widget/kexibrowser.h>
90#include <widget/kexipropertyeditorview.h>
91#include <widget/utils/kexirecordnavigator.h>
92#include <koproperty/editor.h>
93#include <koproperty/set.h>
95#include "startup/KexiStartup.h"
96#include "startup/KexiNewProjectWizard.h"
97#include "startup/KexiStartupDialog.h"
98#include "startup/KexiStartupFileDialog.h"
99#include "kexinamedialog.h"
100#include "printing/kexisimpleprintingpart.h"
101#include "printing/kexisimpleprintingpagesetup.h"
104#if defined(TQ_WS_WIN)
105# include <tderecentdirs.h>
106# include <win32_utils.h>
110#if !defined(KexiVDebug)
111# define KexiVDebug if (0) kdDebug()
117#ifndef KEXI_NO_CTXT_HELP
118#include <kexicontexthelp.h>
121#ifdef HAVE_TDENEWSTUFF
122#include <tdenewstuff/downloaddialog.h>
123#include "kexinewstuff.h"
131#include "ksplitter.h"
132#define KDOCKWIDGET_P 1
134#ifndef KEXI_NO_FEEDBACK_AGENT
135#ifdef FEEDBACK_INCLUDE
136#include FEEDBACK_INCLUDE
138#include <tdeapplication.h>
139#include <tdeaboutdata.h>
142#include "keximainwindowimpl_p.h"
149 Kexi::initCmdLineArgs( argc, argv, aboutdata );
151 bool GUIenabled = true;
152 TQWidget *dummyWidget = 0;
154 TDEApplication* app = new TDEApplication( true, GUIenabled);
156#ifdef KEXI_STANDALONE
157 TDEGlobal::locale()->removeCatalogue( "kexi");
158 TDEGlobal::locale()->insertCatalogue( "standalone_kexi");
160 TDEGlobal::locale()->insertCatalogue( "koffice");
161 TDEGlobal::locale()->insertCatalogue( "koproperty");
164# include "custom_exec.h"
168 TQWidget* debugWindow = 0;
171 dummyWidget = new TQWidget();
172 dummyWidget->setIcon( DesktopIcon( "kexi" ) );
173 app->setMainWidget(dummyWidget);
175 app->config()->setGroup( "General");
176 if (app->config()->readBoolEntry( "showInternalDebugger", false)) {
188 return (~res) ? 0 : 1;
191 kdDebug() << "startupActions OK" <<endl;
203 app->setMainWidget(win);
217 app->processEvents();
229 , KexiGUIMessageHandler(this)
232 KImageIO::registerFormats();
240 kdDebug() << "KexiMainWindowImpl::KexiMainWindowImpl(): starting up in the User Mode" << endl;
242 d->config = kapp->config();
244 if ( !initialGeometrySet() ) {
245 int scnum = TQApplication::desktop()->screenNumber(parentWidget());
246 TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
247 d->config->setGroup( "MainWindow");
248 TQSize s ( d->config->readNumEntry( TQString::fromLatin1( "Width %1").arg(desk.width()), 700 ),
249 d->config->readNumEntry( TQString::fromLatin1( "Height %1").arg(desk.height()), 480 ) );
250 resize (kMin (s.width(), desk.width()), kMin(s.height(), desk.height()));
253 setManagedDockPositionModeEnabled( true);
254 manager()->setSplitterHighResolution( true);
255 manager()->setSplitterKeepSize( true);
256 setStandardMDIMenuEnabled( false);
258 TDEGlobal::iconLoader()->addAppDir( "kexi");
259 TDEGlobal::iconLoader()->addAppDir( "koffice");
264 connect( m_pMdi, TQ_SIGNAL(noMaximizedChildFrmLeft(KMdiChildFrm*)), this, TQ_SLOT(slotNoMaximizedChildFrmLeft(KMdiChildFrm*)));
266 connect( this, TQ_SIGNAL(lastChildViewClosed()), this, TQ_SLOT(slotLastChildViewClosed()));
268 connect( this, TQ_SIGNAL(childViewIsDetachedNow(TQWidget*)), this, TQ_SLOT(slotChildViewIsDetachedNow(TQWidget*)));
269 connect( this, TQ_SIGNAL(mdiModeHasBeenChangedTo(KMdi::MdiMode)),
270 this, TQ_SLOT(slotMdiModeHasBeenChangedTo(KMdi::MdiMode)));
274 setXMLFile( "kexiui.rc");
275 setAcceptDrops( true);
277 createShellGUI( true);
280 d->statusBar = new KexitStatusBar( this, "status_bar");
282 d->origAppCaption = caption();
289 initPropertyEditor();
293 TQObjectList *l = queryList( "TQPopupMenu" );
294 for (TQObjectListIt it( *l ); it.current(); ++it ) {
297 it.current()->installEventFilter( this);
298 d->popups.insert(it.current()->name(), static_cast<TQPopupMenu* >(it.current()));
301 d->createMenu = d->popups[ "create"];
303#ifdef KEXI_NO_REPORTBUG_COMMAND
305 TQPopupMenu *helpMenu = d->popups[ "help"];
308 helpMenu->removeItemAt( int(KHelpMenu::menuReportBug)-1);
309 helpMenu->removeItemAt( int(KHelpMenu::menuReportBug)-1);
315#ifndef KEXI_SHOW_UNIMPLEMENTED
319 TDEAction *tdemdi_tooldock_menu_action = childClients()->getFirst() ? childClients()->getFirst()->actionCollection()->action( "tdemdi_tooldock_menu") : 0;
320 if (tdemdi_tooldock_menu_action) {
321 tdemdi_tooldock_menu_action->setEnabled( false);
324 if (!isFakingSDIApplication()) {
326 TQPopupMenu *menu = d->popups[ "window"];
327 unsigned int count = menuBar()->count();
331 menuBar()->insertItem( i18n( "&Window"), windowMenu(), -1, count-2);
335 TQPopupMenu *menu = d->popups[ "insert"];
337 for (uint i=0; i < menuBar()->count(); i++) {
338 if (menuBar()->text( menuBar()->idAt(i) ) == i18n( "&Insert")) {
339 menuBar()->setItemVisible( menuBar()->idAt(i), false );
344 d->disableMenuItem( "file", i18n( "&Import"));
345 d->disableMenuItem( "edit", i18n( "Paste &Special"));
348 m_pTaskBar->setCaption(i18n( "Task Bar"));
355 setTabWidgetVisibility(KMdi::AlwaysShowTabs);
356 if (mdiMode()==KMdi::IDEAlMode) {
357 d->config->setGroup( "MainWindow");
358 tabWidget()->setHoverCloseButton(d->config->readBoolEntry( "HoverCloseButtonForTabs", false));
360 TQToolButton *closeButton = new TQToolButton( tabWidget() );
361 closeButton->setAutoRaise( true );
362 closeButton->setPixmap( TQPixmap( kde2_closebutton ) );
363 closeButton->setPaletteBackgroundColor(closeButton->palette().active().background());
365 tabWidget()->setCornerWidget( closeButton, TQt::TopRight );
368 TQToolTip::add(closeButton,
369 i18n( "Close the current tab page in Kexi tab interface", "Close the current tab"));
370 TQObject::connect( closeButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( closeActiveView() ) );
373#ifdef KEXI_ADD_CUSTOM_KEXIMAINWINDOWIMPL
374# include "keximainwindowimpl_ctor.h"
378KexiMainWindowImpl::~KexiMainWindowImpl()
380 d->forceDialogClosing= true;
390void KexiMainWindowImpl::setWindowMenu(TQPopupMenu *menu)
392 delete m_pWindowMenu;
393 m_pWindowMenu = menu;
394 int count = menuBar()->count();
396 const TQString txt = i18n( "&Window");
398 for (i=0; i<count; i++) {
400 if (txt==menuBar()->text( menuBar()->idAt(i) ))
404 const int id = menuBar()->idAt(i);
405 menuBar()->removeItemAt(i);
406 menuBar()->insertItem(txt, m_pWindowMenu, id, count-3);
408 m_pWindowMenu->setCheckable( true);
409 TQObject::connect( m_pWindowMenu, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(fillWindowMenu()) );
412void KexiMainWindowImpl::fillWindowMenu()
414 KexiMainWindow::fillWindowMenu();
425 m_pMdiModeMenu->removeItem( m_pMdiModeMenu->idAt( 0 ) );
426 m_pMdiModeMenu->removeItem( m_pMdiModeMenu->idAt( 1 ) );
428 if (d->mdiModeToSwitchAfterRestart != (KMdi::MdiMode)0) {
429 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 0 ),
430 d->mdiModeToSwitchAfterRestart == KMdi::ChildframeMode );
431 m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 1 ),
432 d->mdiModeToSwitchAfterRestart == KMdi::IDEAlMode );
437 int i = m_pWindowMenu->count()-1;
438 for ( int index;; i--) {
439 index = m_pWindowMenu->idAt(i);
440 if (index==-1 || m_pWindowMenu->text(index).isNull())
444 d->action_window_next->plug( m_pWindowMenu, i++ );
445 d->action_window_previous->plug( m_pWindowMenu, i++ );
446 if (!m_pDocumentViews->isEmpty())
447 m_pWindowMenu->insertSeparator( i++ );
458 if (( int)d->mdiModeToSwitchAfterRestart == 0 && mdiMode()==KMdi::IDEAlMode)
460 if (d->mdiModeToSwitchAfterRestart == KMdi::IDEAlMode)
462 if (mdiMode()==KMdi::IDEAlMode) {
463 d->mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
466 KMessageBox::information( this,
467 i18n( "User interface mode will be switched to IDEAl at next %1 application startup.")
468 .arg(KEXI_APP_NAME));
470 d->mdiModeToSwitchAfterRestart = KMdi::IDEAlMode;
474 KexiMainWindow::switchToIDEAlMode();
477void KexiMainWindowImpl::switchToChildframeMode()
479 switchToChildframeMode( true);
482void KexiMainWindowImpl::switchToChildframeMode( bool showMessage)
485 if (( int)d->mdiModeToSwitchAfterRestart == 0 && mdiMode()==KMdi::ChildframeMode)
487 if (d->mdiModeToSwitchAfterRestart == KMdi::ChildframeMode)
489 if (mdiMode()==KMdi::ChildframeMode) {
490 d->mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
493 KMessageBox::information( this,
494 i18n( "User interface mode will be switched to Childframe at next %1 application startup.")
495 .arg(KEXI_APP_NAME));
497 d->mdiModeToSwitchAfterRestart = KMdi::ChildframeMode;
501 KexiMainWindow::switchToChildframeMode();
506 return d->popups[popupName];
511 return actionCollection()->actions();
527 TDEAction *action = new TDEAction(i18n( "&New..."), "document-new", TDEStdAccel::shortcut(TDEStdAccel::New),
528 this, TQ_SLOT( slotProjectNew()), actionCollection(), "project_new");
529 action->setToolTip(i18n( "Create a new project"));
530 action->setWhatsThis(i18n( "Creates a new project. Currently opened project is not affected."));
532 action = KStdAction::open( this, TQ_SLOT( slotProjectOpen() ), actionCollection(), "project_open" );
533 action->setToolTip(i18n( "Open an existing project"));
534 action->setWhatsThis(i18n( "Opens an existing project. Currently opened project is not affected."));
536#ifdef HAVE_TDENEWSTUFF
537 action = new TDEAction(i18n( "&Download Example Databases..."), "kget", TDEShortcut(0),
538 this, TQ_SLOT( slotGetNewStuff()), actionCollection(), "project_download_examples");
539 action->setToolTip(i18n( "Download example databases from the Internet"));
540 action->setWhatsThis(i18n( "Downloads example databases from the Internet."));
546#ifndef KEXI_NO_UNFINISHED
547 d->action_open_recent = new TDEActionMenu(i18n( "Open Recent"),
548 actionCollection(), "project_open_recent");
549 connect(d->action_open_recent->popupMenu(),TQ_SIGNAL(activated( int)),
550 this,TQ_SLOT(slotProjectOpenRecent( int)));
551 connect(d->action_open_recent->popupMenu(), TQ_SIGNAL(aboutToShow()),
552 this,TQ_SLOT(slotProjectOpenRecentAboutToShow()));
561 d->action_open_recent = d->dummy_action;
564 d->action_save = KStdAction::save(
565 this, TQ_SLOT( slotProjectSave() ), actionCollection(), "project_save" );
568 d->action_save->setToolTip(i18n( "Save object changes"));
569 d->action_save->setWhatsThis(i18n( "Saves object changes from currently selected window."));
571#ifdef KEXI_SHOW_UNIMPLEMENTED
572 d->action_save_as = new TDEAction(i18n( "Save &As..."), "document-save-as", 0,
573 this, TQ_SLOT(slotProjectSaveAs()), actionCollection(), "project_saveas");
574 d->action_save_as->setToolTip(i18n( "Save object as"));
575 d->action_save_as->setWhatsThis(
576 i18n( "Saves object changes from currently selected window under a new name (within the same project)."));
578 d->action_project_properties = new TDEAction(i18n( "Project Properties"), "application-vnd.tde.info", 0,
579 this, TQ_SLOT(slotProjectProperties()), actionCollection(), "project_properties");
581 d->action_save_as = d->dummy_action;
582 d->action_project_properties = d->dummy_action;
585 d->action_close = new TDEAction(i18n( "&Close Project"), "window-close", 0,
586 this, TQ_SLOT(slotProjectClose()), actionCollection(), "project_close" );
587 d->action_close->setToolTip(i18n( "Close the current project"));
588 d->action_close->setWhatsThis(i18n( "Closes the current project."));
590 KStdAction::quit( this, TQ_SLOT(slotProjectQuit()), actionCollection(), "quit");
592#ifdef KEXI_SHOW_UNIMPLEMENTED
593 d->action_project_relations = new TDEAction(i18n( "&Relationships..."), "relation", TQt::CTRL + TQt::Key_R,
594 this, TQ_SLOT(slotProjectRelations()), actionCollection(), "project_relations");
595 d->action_project_relations->setToolTip(i18n( "Project relationships"));
596 d->action_project_relations->setWhatsThis(i18n( "Shows project relationships."));
599 d->action_project_relations = d->dummy_action;
601 d->action_tools_data_migration = new TDEAction(
602 i18n( "&Import Database..."), "database_import", 0,
603 this, TQ_SLOT(slotToolsProjectMigration()), actionCollection(), "tools_import_project");
604 d->action_tools_data_migration->setToolTip(i18n( "Import entire database as a Kexi project"));
605 d->action_tools_data_migration->setWhatsThis(i18n( "Imports entire database as a Kexi project."));
607 d->action_tools_compact_database = new TDEAction(
608 i18n( "&Compact Database..."), "", 0,
610 d->action_tools_compact_database->setToolTip(i18n( "Compact the current database project"));
611 d->action_tools_compact_database->setWhatsThis(
612 i18n( "Compacts the current database project, so it will take less space and work faster."));
615 d->action_project_import_data_table = 0;
617 d->action_project_import_data_table = new TDEAction(
618 i18n( "Import->Table Data From File...", "Table Data From &File..."),
621 "project_import_data_table");
622 d->action_project_import_data_table->setToolTip(i18n( "Import table data from a file"));
623 d->action_project_import_data_table->setWhatsThis(i18n( "Imports table data from a file."));
626 d->action_project_export_data_table = new TDEAction(i18n( "Export->Table or Query Data to File...",
627 "Table or Query Data to &File..."),
629 0, this, TQ_SLOT(slotProjectExportDataTable()), actionCollection(),
630 "project_export_data_table");
631 d->action_project_export_data_table->setToolTip(
632 i18n( "Export data from the active table or query data to a file"));
633 d->action_project_export_data_table->setWhatsThis(
634 i18n( "Exports data from the active table or query data to a file."));
641 d->action_project_print = KStdAction::print( this, TQ_SLOT(slotProjectPrint()),
642 actionCollection(), "project_print" );
643 d->action_project_print->setToolTip(i18n( "Print data from the active table or query"));
644 d->action_project_print->setWhatsThis(i18n( "Prints data from the active table or query."));
646 d->action_project_print_preview = KStdAction::printPreview(
647 this, TQ_SLOT(slotProjectPrintPreview()),
648 actionCollection(), "project_print_preview" );
649 d->action_project_print_preview->setToolTip(
650 i18n( "Show print preview for the active table or query"));
651 d->action_project_print_preview->setWhatsThis(
652 i18n( "Shows print preview for the active table or query."));
654 d->action_project_print_setup = new TDEAction(i18n( "Page Set&up..."),
655 "", 0, this, TQ_SLOT(slotProjectPageSetup()), actionCollection(),
656 "project_print_setup");
657 d->action_project_print_setup->setToolTip(
658 i18n( "Show page setup for printing the active table or query"));
659 d->action_project_print_setup->setWhatsThis(
660 i18n( "Shows page setup for printing the active table or query."));
668 d->action_edit_paste_special_data_table = 0;
670 d->action_edit_paste_special_data_table =
671 new TDEAction(i18n( "Paste Special->As Data &Table...", "As Data &Table..."),
673 actionCollection(), "edit_paste_special_data_table");
674 d->action_edit_paste_special_data_table->setToolTip(
675 i18n( "Paste clipboard data as a table"));
676 d->action_edit_paste_special_data_table->setWhatsThis(
677 i18n( "Pastes clipboard data to a table."));
680 d->action_edit_copy_special_data_table =
681 new TDEAction(i18n( "Copy Special->Table or Query Data...",
682 "Table or Query as Data Table..."),
683 "table", 0, this, TQ_SLOT(slotEditCopySpecialDataTable()),
684 actionCollection(), "edit_copy_special_data_table");
685 d->action_edit_copy_special_data_table->setToolTip(
686 i18n( "Copy selected table or query data to clipboard"));
687 d->action_edit_copy_special_data_table->setWhatsThis(
688 i18n( "Copies selected table or query data to clipboard."));
691 d->action_edit_undo->setWhatsThis(i18n( "Reverts the most recent editing action."));
693 d->action_edit_redo->setWhatsThis(i18n( "Reverts the most recent undo action."));
698 d->action_edit_findprev = createSharedAction( KStdAction::FindPrev, "edit_findprevious");
702 d->action_edit_find = KStdAction::find(
703 this, TQ_SLOT(slotEditFind()), actionCollection(), "edit_find" );
705 d->action_edit_findnext = KStdAction::findNext(
706 this, TQ_SLOT(slotEditFindNext()), actionCollection(), "edit_findnext");
707 d->action_edit_findprev = KStdAction::findPrev(
708 this, TQ_SLOT(slotEditFindPrevious()), actionCollection(), "edit_findprevious");
709 d->action_edit_replace = 0;
712 d->action_edit_replace_all = 0;
716 d->action_edit_select_all = createSharedAction( KStdAction::SelectAll, "edit_select_all");
720 d->action_edit_delete->setToolTip(i18n( "Delete selected object"));
721 d->action_edit_delete->setWhatsThis(i18n( "Deletes currently selected object."));
723 d->action_edit_delete_row = createSharedAction(i18n( "Delete Row"), "delete_table_row",
724 TQt::CTRL+TQt::Key_Delete, "edit_delete_row");
725 d->action_edit_delete_row->setToolTip(i18n( "Delete currently selected row"));
726 d->action_edit_delete_row->setWhatsThis(i18n( "Deletes currently selected row."));
728 d->action_edit_clear_table = createSharedAction(i18n( "Clear Table Contents"), "clear_table_contents",
729 0, "edit_clear_table");
730 d->action_edit_clear_table->setToolTip(i18n( "Clear table contents"));
731 d->action_edit_clear_table->setWhatsThis(i18n( "Clears table contents."));
736 d->action_edit_edititem->setToolTip(i18n( "Edit currently selected item"));
737 d->action_edit_edititem->setWhatsThis(i18n( "Edits currently selected item."));
739 d->action_edit_insert_empty_row = createSharedAction(i18n( "&Insert Empty Row"), "insert_table_row",
740 TQt::SHIFT | TQt::CTRL | TQt::Key_Insert, "edit_insert_empty_row");
742 d->action_edit_insert_empty_row->setToolTip(i18n( "Insert one empty row above"));
743 d->action_edit_insert_empty_row->setWhatsThis(i18n( "Inserts one empty row above currently selected table row."));
747 d->action_view_data_mode = new TDERadioAction(i18n( "&Data View"), "state_data", TQt::Key_F6,
748 this, TQ_SLOT(slotViewDataMode()), actionCollection(), "view_data_mode");
749 d->actions_for_view_modes.insert( Kexi::DataViewMode, d->action_view_data_mode );
750 d->action_view_data_mode->setExclusiveGroup( "view_mode");
751 d->action_view_data_mode->setToolTip(i18n( "Switch to data view"));
752 d->action_view_data_mode->setWhatsThis(i18n( "Switches to data view."));
755 d->action_view_data_mode = 0;
758 d->action_view_design_mode = new TDERadioAction(i18n( "D&esign View"), "state_edit", TQt::Key_F7,
759 this, TQ_SLOT(slotViewDesignMode()), actionCollection(), "view_design_mode");
760 d->actions_for_view_modes.insert( Kexi::DesignViewMode, d->action_view_design_mode );
761 d->action_view_design_mode->setExclusiveGroup( "view_mode");
762 d->action_view_design_mode->setToolTip(i18n( "Switch to design view"));
763 d->action_view_design_mode->setWhatsThis(i18n( "Switches to design view."));
766 d->action_view_design_mode = 0;
769 d->action_view_text_mode = new TDERadioAction(i18n( "&Text View"), "state_sql", TQt::Key_F8,
772 d->action_view_text_mode->setExclusiveGroup( "view_mode");
773 d->action_view_text_mode->setToolTip(i18n( "Switch to text view"));
774 d->action_view_text_mode->setWhatsThis(i18n( "Switches to text view."));
777 d->action_view_text_mode = 0;
779 if (d->isProjectNavigatorVisible) {
780 d->action_view_nav = new TDEAction(i18n( "Project Navigator"), "", TQt::ALT + TQt::Key_1,
781 this, TQ_SLOT(slotViewNavigator()), actionCollection(), "view_navigator");
782 d->action_view_nav->setToolTip(i18n( "Go to project navigator panel"));
783 d->action_view_nav->setWhatsThis(i18n( "Goes to project navigator panel."));
786 d->action_view_nav = 0;
788 d->action_view_mainarea = new TDEAction(i18n( "Main Area"), "", TQt::ALT + TQt::Key_2,
789 this, TQ_SLOT(slotViewMainArea()), actionCollection(), "view_mainarea");
790 d->action_view_mainarea->setToolTip(i18n( "Go to main area"));
791 d->action_view_mainarea->setWhatsThis(i18n( "Goes to main area."));
794 d->action_view_propeditor = new TDEAction(i18n( "Property Editor"), "", TQt::ALT + TQt::Key_3,
795 this, TQ_SLOT(slotViewPropertyEditor()), actionCollection(), "view_propeditor");
796 d->action_view_propeditor->setToolTip(i18n( "Go to property editor panel"));
797 d->action_view_propeditor->setWhatsThis(i18n( "Goes to property editor panel."));
800 d->action_view_propeditor = 0;
804 TQt::SHIFT | TQt::Key_Return, "data_save_row");
805 d->action_data_save_row->setToolTip(i18n( "Save changes made to the current row"));
806 d->action_data_save_row->setWhatsThis(i18n( "Saves changes made to the current row."));
810 "button_cancel", 0 , "data_cancel_row_changes");
811 d->action_data_cancel_row_changes->setToolTip(i18n( "Cancel changes made to the current row"));
812 d->action_data_cancel_row_changes->setWhatsThis(i18n( "Cancels changes made to the current row."));
815 d->action_data_execute = createSharedAction(i18n( "&Execute"), "media-playback-start", 0 , "data_execute");
819#ifndef KEXI_NO_UNFINISHED
829 action->setToolTip(i18n( "Sort data in ascending order"));
830 action->setWhatsThis(i18n( "Sorts data in ascending order (from A to Z and from 0 to 9). Data from selected column is used for sorting."));
834 action->setToolTip(i18n( "Sort data in descending order"));
835 action->setWhatsThis(i18n( "Sorts data in descending (from Z to A and from 9 to 0). Data from selected column is used for sorting."));
838 createSharedAction( KexiRecordNavigator::Actions::moveToFirstRecord(), 0, "data_go_to_first_record");
839 createSharedAction( KexiRecordNavigator::Actions::moveToPreviousRecord(), 0, "data_go_to_previous_record");
840 createSharedAction( KexiRecordNavigator::Actions::moveToNextRecord(), 0, "data_go_to_next_record");
841 createSharedAction( KexiRecordNavigator::Actions::moveToLastRecord(), 0, "data_go_to_last_record");
842 createSharedAction( KexiRecordNavigator::Actions::moveToNewRecord(), 0, "data_go_to_new_record");
845 d->action_format_font = createSharedAction(i18n( "&Font..."), "fonts", 0, "format_font");
846 d->action_format_font->setToolTip(i18n( "Change font for selected object"));
847 d->action_format_font->setWhatsThis(i18n( "Changes font for selected object."));
854 TDEAction *closeWindowAction = actionCollection()->action( "window_close");
855 if (closeWindowAction)
856 closeWindowAction->setShortcut(TDEStdAccel::close());
860 d->action_window_next = new TDEAction( i18n( "&Next Window"), "",
862 TQt::CTRL+TQt::Key_Tab,
864 TQt::ALT+TQt::Key_Right,
866 this, TQ_SLOT(activateNextWin()), actionCollection(), "window_next");
867 d->action_window_next->setToolTip( i18n( "Next window") );
868 d->action_window_next->setWhatsThis(i18n( "Switches to the next window."));
870 d->action_window_previous = new TDEAction( i18n( "&Previous Window"), "",
872 TQt::CTRL+TQt::SHIFT+TQt::Key_Tab,
874 TQt::ALT+TQt::Key_Left,
876 this, TQ_SLOT(activatePrevWin()), actionCollection(), "window_previous");
877 d->action_window_previous->setToolTip( i18n( "Previous window") );
878 d->action_window_previous->setWhatsThis(i18n( "Switches to the previous window."));
881 setStandardToolBarMenuEnabled( true );
882 action = KStdAction::keyBindings( this, TQ_SLOT( slotConfigureKeys() ), actionCollection() );
883 action->setWhatsThis(i18n( "Lets you configure shortcut keys."));
885#ifdef KEXI_SHOW_UNIMPLEMENTED
886 action = KStdAction::configureToolbars( this, TQ_SLOT( slotConfigureToolbars() ), actionCollection() );
887 action->setWhatsThis(i18n( "Lets you configure toolbars."));
889 d->action_show_other = new TDEActionMenu(i18n( "Other"),
890 actionCollection(), "options_show_other");
893#ifndef KEXI_NO_CTXT_HELP
894 d->action_show_helper = new TDEToggleAction(i18n( "Show Context Help"), "", TQt::CTRL + TQt::Key_H,
895 actionCollection(), "options_show_contexthelp");
896#if KDE_IS_VERSION(3,2,90)
897 d->action_show_helper->setCheckedState(i18n( "Hide Context Help"));
901#ifdef KEXI_FORMS_SUPPORT
902 slotOptionsEnableForms( true, true);
904 slotOptionsEnableForms( false, true);
907#ifdef KEXI_REPORTS_SUPPORT
913#ifdef KEXI_MACROS_SUPPORT
919#ifdef KEXI_SCRIPTS_SUPPORT
925#ifdef KEXI_SHOW_UNIMPLEMENTED
926 d->action_configure = KStdAction::preferences( this, TQ_SLOT(slotShowSettings()), actionCollection());
927 action->setWhatsThis(i18n( "Lets you configure Kexi."));
932 KStdAction::tipOfDay( this, TQ_SLOT( slotTipOfTheDayAction() ), actionCollection() )
933 ->setWhatsThis(i18n( "This shows useful tips on the use of this application."));
936 new TDEAction(i18n( "Important Information"), "messagebox_info", 0,
937 this, TQ_SLOT( slotImportantInfo()), actionCollection(), "help_show_important_info");
941#ifndef KEXI_NO_FEEDBACK_AGENT
943 new TDEAction(i18n( "Give Feedback..."), "messagebox_info", 0,
944 this, TQ_SLOT(slotStartFeedbackAgent()), actionCollection(), "help_start_feedback_agent");
953 if ((action = actionCollection()->action( "window_close")))
954 action->setToolTip(i18n( "Close the current window"));
965 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
968 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
971 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
974 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
978 KexiPart::TableObjectType, KexiPart::QueryObjectType);
982 KexiPart::TableObjectType, KexiPart::QueryObjectType);
986 KexiPart::TableObjectType, KexiPart::QueryObjectType);
990 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1000 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1003 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1006 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1009 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1012 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1015 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1018 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1038 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1048 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1052 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1056 KexiPart::TableObjectType, KexiPart::QueryObjectType);
1096 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1098 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1100 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1102 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1104 KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
1133void KexiMainWindowImpl::invalidateSharedActions()
1135 invalidateSharedActions(0);
1139void KexiMainWindowImpl::invalidateSharedActionsLater()
1148 const bool have_dialog = d->curDialog;
1149 const bool dialog_dirty = d->curDialog && d->curDialog->dirty();
1150 const bool readOnly = d->prj && d->prj->dbConnection() && d->prj->dbConnection()->isReadOnly();
1153 d->action_save->setEnabled(have_dialog && dialog_dirty && !readOnly);
1154 d->action_save_as->setEnabled(have_dialog && !readOnly);
1155 d->action_project_properties->setEnabled(d->prj);
1156 d->action_close->setEnabled(d->prj);
1157 d->action_project_relations->setEnabled(d->prj);
1158 if (d->action_project_import_data_table)
1159 d->action_project_import_data_table->setEnabled(d->prj && !readOnly);
1160 d->action_project_export_data_table->setEnabled(
1161 d->curDialog && d->curDialog->part()->info()->isDataExportSupported()
1162 && !d->curDialog->neverSaved() );
1164 const bool printingActionsEnabled =
1165 d->curDialog && d->curDialog->part()->info()->isPrintingSupported()
1166 && !d->curDialog->neverSaved();
1167 d->action_project_print->setEnabled( printingActionsEnabled );
1168 d->action_project_print_preview->setEnabled( printingActionsEnabled );
1169 d->action_project_print_setup->setEnabled( printingActionsEnabled );
1173 if (d->action_edit_paste_special_data_table)
1174 d->action_edit_paste_special_data_table->setEnabled(d->prj && !readOnly);
1178 if (d->curDialog && d->curDialog->currentViewMode()==Kexi::DataViewMode) {
1180 d->action_edit_copy_special_data_table->setEnabled(
1184 d->action_edit_copy_special_data_table->setEnabled( false );
1187 if (d->action_view_nav)
1188 d->action_view_nav->setEnabled(d->prj);
1189 d->action_view_mainarea->setEnabled(d->prj);
1190 if (d->action_view_propeditor)
1191 d->action_view_propeditor->setEnabled(d->prj);
1192 if (d->action_view_data_mode) {
1193 d->action_view_data_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::DataViewMode) );
1194 if (!d->action_view_data_mode->isEnabled())
1195 d->action_view_data_mode->setChecked( false);
1197 if (d->action_view_design_mode) {
1198 d->action_view_design_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::DesignViewMode) );
1199 if (!d->action_view_design_mode->isEnabled())
1200 d->action_view_design_mode->setChecked( false);
1202 if (d->action_view_text_mode) {
1203 d->action_view_text_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode( Kexi::TextViewMode) );
1204 if (!d->action_view_text_mode->isEnabled())
1205 d->action_view_text_mode->setChecked( false);
1207#ifndef KEXI_NO_CTXT_HELP
1208 d->action_show_helper->setEnabled(d->prj);
1213 d->createMenu->setEnabled(d->prj);
1220 d->action_tools_compact_database->setEnabled(
1221 !d->prj || !readOnly && d->prj && d->prj->dbConnection()
1225 if (d->action_window_next) {
1226 d->action_window_next->setEnabled(!m_pDocumentViews->isEmpty());
1227 d->action_window_previous->setEnabled(!m_pDocumentViews->isEmpty());
1232 d->nav->setEnabled(d->prj);
1234 d->propEditorTabWidget->setEnabled(d->prj);
1241 if (d->curDialog->currentViewMode()==Kexi::DataViewMode) {
1242 if (d->action_view_data_mode)
1243 d->action_view_data_mode->setChecked( true );
1245 else if (d->curDialog->currentViewMode()==Kexi::DesignViewMode) {
1246 if (d->action_view_design_mode)
1247 d->action_view_design_mode->setChecked( true );
1250 if (d->action_view_text_mode)
1251 d->action_view_text_mode->setChecked( true );
1259 case KexiStartupHandler::CreateBlankProject:
1261 makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1263 case KexiStartupHandler::CreateFromTemplate:
1265 case KexiStartupHandler::OpenProject:
1267 case KexiStartupHandler::ImportProject:
1274 makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1281 const TQString &s = obj-> errorMsg();
1284 return TQString( "<br>(%1) ").arg(i18n( "reason:")+ " <i>"+s+ "</i>");
1296 && newProjectData->connectionData()-> password.isEmpty()
1297 && newProjectData->connectionData()-> fileName().isEmpty()
1301 KexiDBPasswordDialog pwdDlg( this, *newProjectData->connectionData(),
1303 if (TQDialog::Accepted!=pwdDlg.exec()) {
1309 bool incompatibleWithKexi;
1310 tristate res = d->prj->open(incompatibleWithKexi);
1319 if (incompatibleWithKexi) {
1320 if (KMessageBox::Yes == KMessageBox::questionYesNo( this,
1321 i18n( "<qt>Database project %1 does not appear to have been created using Kexi.<br><br>"
1322 "Do you want to import it as a new Kexi project?</qt>").arg(projectData. infoString()),
1323 0, KGuiItem(i18n( "Import Database", "&Import..."), "database_import"),
1324 KStdGuiItem::quit()))
1326 const bool anotherProjectAlreadyOpened = d->prj;
1328 projectData. databaseName(), projectData.constConnectionData());
1330 if (!anotherProjectAlreadyOpened)
1354 TQStringList mimetypes;
1357 const TQString startDir( ":OpenExistingOrCreateNewProject");
1358 const TQString caption( i18n( "Select New Project's Location") );
1363 TQString recentDir = TDEGlobalSettings::documentPath();
1364 if (fname.isEmpty() && !projectData.constConnectionData()-> dbFileName().isEmpty())
1365 fname = KFileDialog::getStartURL(startDir, recentDir).path()
1366 + '/' + projectData.constConnectionData()-> dbFileName();
1367 fname = TQFileDialog::getSaveFileName(
1368 KFileDialog::getStartURL(fname.isEmpty() ? startDir : fname, recentDir).path(),
1370 this, "CreateProjectFromTemplate", caption);
1371 if ( !fname.isEmpty() ) {
1374 url.setPath( fname );
1375 if (url.isLocalFile())
1376 TDERecentDirs::add(startDir, url.directory());
1379 Q_UNUSED(projectData);
1380 if (fname.isEmpty() &&
1381 !projectData.constConnectionData()-> dbFileName().isEmpty())
1384 fname = projectData.constConnectionData()-> dbFileName();
1386 const bool specialDir = fname.isEmpty();
1387 kdDebug() << fname << "............." << endl;
1388 KFileDialog dlg( specialDir ? startDir : TQString(),
1389 mimetypes.join( " "), this, "filedialog", true);
1391 dlg.setSelection( fname );
1392 dlg.setOperationMode( KFileDialog::Saving );
1393 dlg.setCaption( caption );
1395 fname = dlg.selectedFile();
1396 if (!fname.isEmpty())
1397 TDERecentDocument::add(fname);
1401 if ( fname.isEmpty() )
1408 projectData.constConnectionData()-> fileName(), fname ))
1418 const bool readOnly = d->prj && d->prj->dbConnection() && d->prj->dbConnection()->isReadOnly();
1419 d->statusBar->setReadOnlyFlag( readOnly );
1421 d->nav->setReadOnly(readOnly);
1423 TDEActionCollection *ac = actionCollection();
1424 for (KexiPart::PartInfoListIterator it(* Kexi::partManager().partInfoList()); it.current(); ++it) {
1425 TDEAction *a = ac->action( TQString(KexiPart::nameForCreateAction( *it.current() )).ascii() );
1427 a->setEnabled(!readOnly);
1433 TQString not_found_msg;
1434 bool openingCancelled;
1437 for (TQValueList<KexiProjectData::ObjectInfo>::ConstIterator it =
1438 d->prj->data()->autoopenObjects.constBegin();
1439 it != d->prj->data()->autoopenObjects.constEnd(); ++it )
1441 KexiProjectData::ObjectInfo info = *it;
1443 TQCString( "kexi/")+info[ "type"].lower().latin1() );
1445 not_found_msg += "<li>";
1446 if (!info[ "name"].isEmpty())
1447 not_found_msg += (TQString( "\"") + info[ "name"] + "\" - ");
1448 if (info[ "action"]== "new")
1449 not_found_msg += i18n( "cannot create object - unknown object type \"%1\"")
1452 not_found_msg += i18n( "unknown object type \"%1\"").arg(info[ "type"]);
1457 if (info[ "action"]== "new") {
1458 if (! newObject( i, openingCancelled) && !openingCancelled) {
1459 not_found_msg += "<li>";
1460 not_found_msg += (i18n( "cannot create object of type \"%1\"").arg(info[ "type"])+
1461 internalReason(d->prj)+ "<br></li>");
1464 d->wasAutoOpen = true;
1472 if (info[ "action"]== "print-preview")
1473 taskName = i18n( "making print preview for");
1474 else if (info[ "action"]== "print")
1475 taskName = i18n( "printing");
1476 else if (info[ "action"]== "execute")
1477 taskName = i18n( "\"executing object\" action", "executing");
1479 taskName = i18n( "opening");
1481 not_found_msg += (TQString( "<li>")+ taskName + " \"" + info[ "name"] + "\" - ");
1482 if ( "table"==info[ "type"].lower())
1483 not_found_msg += i18n( "table not found");
1484 else if ( "query"==info[ "type"].lower())
1485 not_found_msg += i18n( "query not found");
1486 else if ( "macro"==info[ "type"].lower())
1487 not_found_msg += i18n( "macro not found");
1488 else if ( "script"==info[ "type"].lower())
1489 not_found_msg += i18n( "script not found");
1491 not_found_msg += i18n( "object not found");
1492 not_found_msg += (internalReason(d->prj)+ "<br></li>");
1496 if (info[ "action"]== "execute") {
1499 not_found_msg += ( TQString( "<li>\"")+ info[ "name"] + "\" - " + i18n( "cannot execute object")+
1500 internalReason(d->prj)+ "<br></li>" );
1504 else if (info[ "action"]== "print") {
1507 not_found_msg += ( TQString( "<li>\"")+ info[ "name"] + "\" - " + i18n( "cannot print object")+
1508 internalReason(d->prj)+ "<br></li>" );
1512 else if (info[ "action"]== "print-preview") {
1515 not_found_msg += ( TQString( "<li>\"")+ info[ "name"] + "\" - " + i18n( "cannot make print preview of object")+
1516 internalReason(d->prj)+ "<br></li>" );
1522 if (info[ "action"]== "open")
1523 viewMode = Kexi::DataViewMode;
1524 else if (info[ "action"]== "design")
1525 viewMode = Kexi::DesignViewMode;
1526 else if (info[ "action"]== "edittext")
1531 TQString openObjectMessage;
1532 if (! openObject(item, viewMode, openingCancelled, 0, &openObjectMessage)
1533 && (!openingCancelled || !openObjectMessage.isEmpty()))
1535 not_found_msg += (TQString( "<li>\"")+ info[ "name"] + "\" - ");
1536 if (openObjectMessage.isEmpty())
1537 not_found_msg += i18n( "cannot open object");
1539 not_found_msg += openObjectMessage;
1540 not_found_msg += internalReason(d->prj) + "<br></li>";
1544 d->wasAutoOpen = true;
1551 if (!not_found_msg.isEmpty())
1552 showErrorMessage(i18n( "You have requested selected objects to be automatically opened "
1553 "or processed on startup. Several objects cannot be opened or processed."),
1554 TQString( "<ul>%1</ul>").arg(not_found_msg) );
1556 d->updatePropEditorVisibility(d->curDialog ? d->curDialog->currentViewMode() : 0);
1557#if defined(KDOCKWIDGET_P)
1558 if (d->propEditor) {
1559 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1570 if (mdiMode()==KMdi::ChildframeMode || mdiMode()==KMdi::TabPageMode) {
1572 if (!d->navToolWindow->wrapperWidget()->isVisible())
1573 static_cast<KDockWidget* >(d->navToolWindow->wrapperWidget())->makeDockVisible();
1579 d->restoreNavigatorWidth();
1581#ifndef PROPEDITOR_VISIBILITY_CHANGES
1592 d->nav->updateGeometry();
1594 tqApp->processEvents();
1600#ifndef KEXI_NO_PENDING_DIALOGS
1601 if (d->pendingDialogsExist()) {
1602 kdDebug() << "KexiMainWindowImpl::closeProject() pendingDialogsExist..." << endl;
1603 d->actionToExecuteWhenPendingJobsAreFinished = Private::CloseProjectAction;
1609 d->saveSettingsForShowProjectNavigator = d->prj && d->isProjectNavigatorVisible;
1616 bool cancel = false;
1622 d->dialogExistedBeforeCloseProject = !d->curDialog.isNull();
1624#if defined(KDOCKWIDGET_P)
1626 if (d->propEditor) {
1627 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1635 if (d->propEditor) {
1636 if (d->openedDialogsCount() == 0)
1637 makeWidgetDockVisible(d->propEditorTabWidget);
1638 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1644 KDockWidget *dw = (KDockWidget *)d->nav->parentWidget();
1646 int dwWidth = dw->width();
1648 if (d->openedDialogsCount()!=0 && d->propEditorTabWidget && d->propEditorTabWidget->isVisible())
1651 d->navDockSeparatorPos = (100 * dwWidth) / width();
1660 while (!d->curDialog.isNull()) {
1669 if (!d->prj->closeConnection())
1674 d->navWasVisibleBeforeProjectClosing = manager()->findWidgetParentDock(d->nav)->isVisible();
1677 d->navToolWindow->hide();
1682 makeDockInvisible( manager()->findWidgetParentDock(d->propEditorTabWidget) );
1702void KexiMainWindowImpl::initContextHelp() {
1703#ifndef KEXI_NO_CTXT_HELP
1704 d->ctxHelp= new KexiContextHelp( this, this);
1712 addToolWindow(d->ctxHelp,KDockWidget::DockBottom | KDockWidget::DockLeft,getMainDockWidget(),20);
1718 if (!d->isProjectNavigatorVisible)
1724 d->nav->installEventFilter( this);
1725 d->navToolWindow = addToolWindow(d->nav, KDockWidget::DockLeft, getMainDockWidget(), 20);
1729 connect(d->nav,TQ_SIGNAL(openOrActivateItem( KexiPart::Item*, int)),
1735 connect(d->nav,TQ_SIGNAL(renameItem( KexiPart::Item*, const TQString&, bool&)),
1754 if(d->prj->isConnected()) {
1755 TQString partManagerErrorMessages;
1756 d->nav->setProject( d->prj, TQString(), &partManagerErrorMessages );
1757 if (!partManagerErrorMessages.isEmpty()) {
1758 showWarningContinueMessage(partManagerErrorMessages, TQString(),
1759 "dontShowWarningsRelatedToPluginsLoading");
1765 if (d->forceShowProjectNavigatorOnCreation) {
1766 slotViewNavigator();
1767 d->forceShowProjectNavigatorOnCreation = false;
1769 else if (d->forceHideProjectNavigatorOnCreation) {
1770 d->navToolWindow->hide();
1772 d->forceHideProjectNavigatorOnCreation = false;
1780#if defined(KDOCKWIDGET_P)
1781 if (mdiMode()==KMdi::ChildframeMode || mdiMode()==KMdi::TabPageMode) {
1795void KexiMainWindowImpl::initPropertyEditor()
1797 if (!d->propEditor) {
1799 d->propEditorTabWidget = new KTabWidget( this);
1800 d->propEditorTabWidget->hide();
1802 d->propEditorTabWidget->setCaption(d->propEditor->caption());
1803 d->propEditorTabWidget->addTab(d->propEditor, i18n( "Properties"));
1804 d->propEditor->installEventFilter( this);
1805 d->propEditorToolWindow = addToolWindow(d->propEditorTabWidget,
1806 KDockWidget::DockRight, getMainDockWidget(), 20);
1808 d->config->setGroup( "PropertyEditor");
1809 int size = d->config->readNumEntry( "FontSize", -1);
1812 f.setPixelSize( size );
1813 d->propEditorTabWidget->setFont(f);
1815 if (mdiMode()==KMdi::ChildframeMode || mdiMode()==KMdi::TabPageMode) {
1816 KDockWidget *dw = (KDockWidget *)d->propEditorTabWidget->parentWidget();
1817 #if defined(KDOCKWIDGET_P)
1820 makeWidgetDockVisible(d->propEditorTabWidget);
1828 d->config->setGroup( "MainWindow");
1871 KMdiChildView *view = 0L;
1874 else if (d->curDialog->isAttached()) {
1875 view = d->curDialog;
1878 if (m_pMdi->topChild()) {
1879 view = m_pMdi->topChild()->m_pClient;
1880 childrenMaximized = view->mdiParent()->state()==KMdiChildFrm::Maximized;
1886 if (childrenMaximized && view) {
1887 setCaption( d->curDialog->caption()
1888 + (d->appCaptionPrefix.isEmpty() ? TQString() : (TQString::fromLatin1( " - ") + d->appCaptionPrefix)) );
1891 setCaption( (d->appCaptionPrefix.isEmpty() ? TQString() : (d->appCaptionPrefix + TQString::fromLatin1( " - ")))
1892 + d->origAppCaption );
1900 d->appCaptionPrefix = "";
1901 if (d->prj && d->prj->data()) {
1902 d->appCaptionPrefix = d->prj->data()->caption();
1903 if (d->appCaptionPrefix.isEmpty())
1904 d->appCaptionPrefix = d->prj->data()->databaseName();
1910 if (d->curDialog && d->curDialog->mdiParent())
1911 max = d->curDialog->mdiParent()->state()==KMdiChildFrm::Maximized;
1938void KexiMainWindowImpl::slotNoMaximizedChildFrmLeft(KMdiChildFrm*)
1943void KexiMainWindowImpl::slotLastChildViewClosed()
1945 if (m_pDocumentViews->count()>0)
1957void KexiMainWindowImpl::slotChildViewIsDetachedNow(TQWidget*)
1981KexiMainWindowImpl::queryClose()
1983#ifndef KEXI_NO_PENDING_DIALOGS
1984 if (d->pendingDialogsExist()) {
1985 kdDebug() << "KexiMainWindowImpl::queryClose() pendingDialogsExist..." << endl;
1986 d->actionToExecuteWhenPendingJobsAreFinished = Private::QuitAction;
2002KexiMainWindowImpl::queryExit()
2011 d->config->setGroup( "MainWindow");
2014 applyMainWindowSettings( d->config, "MainWindow" );
2018 d->config->setGroup( "MainWindow Toolbar KMdiTaskBar");
2019 const bool tbe = d->config->readEntry( "Position").isEmpty();
2020 if (tbe || d->config->readEntry( "Position")== "Bottom") {
2022 d->config->writeEntry( "Position", "Bottom");
2023 moveDockWindow(m_pTaskBar, DockBottom);
2026 d->config->setGroup( "MainWindow");
2027 int mdimode = d->config->readNumEntry( "MDIMode", -1);
2029 const bool showProjectNavigator = d->config->readBoolEntry( "ShowProjectNavigator", true);
2037 case KMdi::ChildframeMode:
2038 switchToChildframeMode( false);
2039 m_pTaskBar->switchOn( true);
2043 d->maximizeFirstOpenedChildFrm = d->config->readBoolEntry( "maximized childframes", true);
2044 setEnableMaximizedChildFrmMode(d->maximizeFirstOpenedChildFrm);
2046 if (!showProjectNavigator) {
2048 d->forceHideProjectNavigatorOnCreation = true;
2053#define DEFAULT_MDI_MODE KMdi::IDEAlMode
2055 case DEFAULT_MDI_MODE:
2058 if (showProjectNavigator) {
2060 d->forceShowProjectNavigatorOnCreation = true;
2070 if ( !initialGeometrySet() ) {
2073 int scnum = TQApplication::desktop()->screenNumber(parentWidget());
2074 TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
2095 config->setGroup( "MainWindow");
2096 TQSize s ( config->readNumEntry( TQString::fromLatin1( "Width %1").arg(desk.width()), 700 ),
2097 config->readNumEntry( TQString::fromLatin1( "Height %1").arg(desk.height()), 480 ) );
2098 resize (kMin (s.width(), desk.width()), kMin(s.height(), desk.height()));
2106 kdDebug() << "KexiMainWindowImpl::storeSettings()" << endl;
2109 saveMainWindowSettings( d->config, "MainWindow" );
2110 d->config->setGroup( "MainWindow");
2111 KMdi::MdiMode modeToSave = mdiMode();
2112 if (d->mdiModeToSwitchAfterRestart!=(KMdi::MdiMode)0)
2113 modeToSave = d->mdiModeToSwitchAfterRestart;
2114 if (modeToSave == DEFAULT_MDI_MODE)
2115 d->config->deleteEntry( "MDIMode");
2117 d->config->writeEntry( "MDIMode", modeToSave);
2118 d->config->writeEntry( "maximized childframes", isInMaximizedChildFrmMode());
2121 if (d->saveSettingsForShowProjectNavigator) {
2122 if (d->navWasVisibleBeforeProjectClosing)
2123 d->config->deleteEntry( "ShowProjectNavigator");
2125 d->config->writeEntry( "ShowProjectNavigator", false);
2128 if (modeToSave==KMdi::ChildframeMode || modeToSave==KMdi::TabPageMode) {
2129 if (d->propEditor && d->propEditorDockSeparatorPos >= 0 && d->propEditorDockSeparatorPos <= 100) {
2130 d->config->setGroup( "MainWindow");
2131 d->config->writeEntry( "RightDockPosition", d->propEditorDockSeparatorPos);
2134 d->propEditorDockSeparatorPos = 80;
2135 if (d->nav && d->navDockSeparatorPos >= 0 && d->navDockSeparatorPos <= 100) {
2136 d->config->setGroup( "MainWindow");
2143 if (d->wasAutoOpen && d->dialogExistedBeforeCloseProject) {
2145 d->config->writeEntry( "LeftDockPositionWithAutoOpen",
2146 d->navDockSeparatorPos);
2152 if (d->dialogExistedBeforeCloseProject)
2153 d->config->writeEntry( "LeftDockPosition", d->navDockSeparatorPos);
2155 d->config->writeEntry( "LeftDockPosition", tqRound( double(d->navDockSeparatorPos) / 0.77
2156 / ( double(d->propEditorDockSeparatorPos) / 80) ));
2162 if (d->propEditor) {
2163 d->config->setGroup( "PropertyEditor");
2164 d->config->writeEntry( "FontSize", d->propEditorTabWidget->font().pixelSize());
2169KexiMainWindowImpl::restoreWindowConfiguration(TDEConfig *config)
2171 kdDebug()<< "preparing session restoring"<<endl;
2173 config->setGroup( "MainWindow");
2177 if (kapp->isRestored())
2178 dockGrp=config->group()+ "-Docking";
2180 dockGrp= "MainWindow0-Docking";
2182 if (config->hasGroup(dockGrp))
2183 readDockConfig(config,dockGrp);
2187KexiMainWindowImpl::storeWindowConfiguration(TDEConfig *config)
2189 kdDebug()<< "preparing session saving"<<endl;
2190 config->setGroup( "MainWindow");
2193#if KDE_IS_VERSION(3,1,9) && !defined(TQ_WS_WIN)
2194 if (kapp->sessionSaving())
2195 dockGrp=config->group()+ "-Docking";
2198 dockGrp= "MainWindow0-Docking";
2200 kdDebug()<< "Before write dock config"<<endl;
2201 writeDockConfig(config,dockGrp);
2202 kdDebug()<< "After write dock config"<<endl;
2207 restoreWindowConfiguration(config);
2211KexiMainWindowImpl::saveProperties(TDEConfig *config)
2213 storeWindowConfiguration(config);
2219KexiMainWindowImpl::saveGlobalProperties( TDEConfig* sessionConfig ) {
2220 storeWindowConfiguration(sessionConfig);
2226 kdDebug() << "KexiMainWindowImpl::registerChild()" << endl;
2227 connect(dlg, TQ_SIGNAL(activated(KMdiChildView *)),
2233 if(dlg-> id() != -1) {
2234 d->insertDialog(dlg);
2236 kdDebug() << "KexiMainWindowImpl::registerChild() ID = " << dlg-> id() << endl;
2238 if (m_mdiMode==KMdi::ToplevelMode || m_mdiMode==KMdi::ChildframeMode) {
2240 if (m_pTaskBar && !m_pTaskBar->isSwitchedOn())
2241 m_pTaskBar->switchOn( true);
2253 if (viewClient!=d->curDialogViewGUIClient) {
2255 kdDebug()<< "KexiMainWindowImpl::activeWindowChanged(): old view gui client:"
2256 <<(d->curDialogViewGUIClient ? d->curDialogViewGUIClient->xmlFile() : "")
2257 << " new view gui client: "<<( viewClient ? viewClient->xmlFile() : "") <<endl;
2258 if (d->curDialogViewGUIClient) {
2259 guiFactory()->removeClient(d->curDialogViewGUIClient);
2262 if (d->closedDialogViewGUIClient) {
2267 guiFactory()->addClient(viewClient);
2276 prevDialog ? prevDialog-> part() : 0,
2278 d->curDialog ? d->curDialog->part() : 0,
2286 if (!d->propEditorTabWidget)
2291 && (prevDialogPart!=curDialogPart || prevViewMode!=curViewMode)
2294 if (d->partForPreviouslySetupPropertyPanelTabs) {
2296 if (prevViewMode==Kexi::DesignViewMode &&
2297 (( KexiPart::Part*)d->partForPreviouslySetupPropertyPanelTabs != curDialogPart)
2298 || curViewMode!=Kexi::DesignViewMode)
2300 d->recentlySelectedPropertyPanelPages.insert( d->partForPreviouslySetupPropertyPanelTabs,
2301 d->propEditorTabWidget->currentPageIndex() );
2306 const uint count = d->propEditorTabWidget->count();
2307 for (uint i=1; i < count; i++)
2308 d->propEditorTabWidget->removePage( d->propEditorTabWidget->page(1) );
2312 if ((!prevDialogPart && !curDialogPart)
2313 || (prevDialogPart == curDialogPart && prevViewMode==curViewMode)
2314 || (curDialogPart && curViewMode!=Kexi::DesignViewMode))
2317 d->partForPreviouslySetupPropertyPanelTabs = curDialogPart;
2321 if (curDialogPart) {
2326 if (d->recentlySelectedPropertyPanelPages.contains( curDialogPart )) {
2327 d->propEditorTabWidget->setCurrentPage(
2328 d->recentlySelectedPropertyPanelPages[ curDialogPart ]
2334 d->partForPreviouslySetupPropertyPanelTabs = curDialogPart;
2340 kdDebug() << "KexiMainWindowImpl::activeWindowChanged() to = " << (dlg ? dlg->caption() : "<none>") << endl;
2342 KXMLGUIClient *client=0;
2343 KXMLGUIClient *viewClient=0;
2348 else if ( dlg->isRegistered()) {
2352 if (d->closedDialogGUIClient) {
2353 if (client!=d->closedDialogGUIClient) {
2355 guiFactory()->removeClient(d->closedDialogGUIClient);
2356 d->closedDialogGUIClient=0;
2359 if (d->closedDialogViewGUIClient) {
2360 if (viewClient!=d->closedDialogViewGUIClient) {
2362 guiFactory()->removeClient(d->closedDialogViewGUIClient);
2363 d->closedDialogViewGUIClient=0;
2366 if (client!=d->curDialogGUIClient) {
2368 kdDebug()<< "KexiMainWindowImpl::activeWindowChanged(): old gui client:"
2369 <<(d->curDialogGUIClient ? d->curDialogGUIClient->xmlFile() : "")
2370 << " new gui client: "<<( client ? client->xmlFile() : "") <<endl;
2371 if (d->curDialogGUIClient) {
2372 guiFactory()->removeClient(d->curDialogGUIClient);
2373 d->curDialog->detachFromGUIClient();
2376 if (d->closedDialogGUIClient) {
2381 guiFactory()->addClient(client);
2389 d->curDialog->detachFromGUIClient();
2413 bool update_dlg_caption = dlg && dlg!=( KexiDialogBase*)d->curDialog && dlg->mdiParent();
2415 if (d->curDialogGUIClient && !client)
2416 guiFactory()->removeClient(d->curDialogGUIClient);
2417 d->curDialogGUIClient=client;
2419 if (d->curDialogViewGUIClient && !viewClient)
2420 guiFactory()->removeClient(d->curDialogViewGUIClient);
2421 d->curDialogViewGUIClient=viewClient;
2425 if (dialogChanged) {
2428 d->curDialog->deactivate();
2439 if (dialogChanged && d->curDialog)
2440 d->curDialog->selectedView()->propertySetSwitched();
2442 if (dialogChanged) {
2450 if (d->curDialog && d->curDialog->currentViewMode()!=0)
2451 d->updatePropEditorVisibility(d->curDialog->currentViewMode());
2455 if (update_dlg_caption) {
2462 d->updateFindDialogContents();
2470 kdDebug() << "KexiMainWindowImpl::activateWindow()" << endl;
2471#ifndef KEXI_NO_PENDING_DIALOGS
2472 Private::PendingJobType pendingType;
2482 kdDebug() << "KexiMainWindowImpl::activateWindow(KexiDialogBase *)" << endl;
2486 d->focus_before_popup = dlg;
2495 d->removeDialog(dlg-> id());
2496#ifndef KEXI_NO_PENDING_DIALOGS
2497 d->removePendingDialog(dlg-> id());
2501 if (d->openedDialogsCount() == 0)
2506KexiMainWindowImpl::slotShowSettings()
2508 KEXI_UNFINISHED(d->action_configure->text());
2514KexiMainWindowImpl::slotConfigureKeys()
2519 KKeyDialog::configure( actionCollection(), false, this );
2523KexiMainWindowImpl::slotConfigureToolbars()
2525 KEditToolbar edit(factory());
2551 args << tqApp->applicationFilePath() << "-create-opendb";
2552 if (new_data->connectionData()-> fileName().isEmpty()) {
2554 if (fileName.isEmpty())
2561 fileName = new_data->connectionData()-> fileName();
2567 TQProcess proc(args, this, "process");
2568 proc.setCommunication((TQProcess::Communication)0);
2570 proc.setWorkingDirectory( TQFileInfo(fileName).dir( true) );
2571 if (!proc.start()) {
2572 d->showStartProcessMsg(args);
2592 TQString* shortcutFileName)
2595 KexiNewProjectWizard wiz( Kexi::connset(), 0, "KexiNewProjectWizard", true);
2596 wiz.setConfirmOverwrites(confirmOverwrites);
2597 if (wiz.exec() != TQDialog::Accepted) {
2604 if (shortcutFileName)
2605 *shortcutFileName = TQString();
2606 if (wiz.projectConnectionData()) {
2609 kdDebug() << "DBNAME: " << wiz.projectDBName() << " SERVER: " << cdata-> serverInfoString() << endl;
2610 new_data = new KexiProjectData( *cdata, wiz.projectDBName(), wiz.projectCaption() );
2611 if (shortcutFileName)
2614 else if (!wiz.projectDBName().isEmpty()) {
2617 cdata. caption = wiz.projectCaption();
2620 new_data = new KexiProjectData( cdata, wiz.projectDBName(), wiz.projectCaption() );
2641 tristate res = d->prj->create( true );
2647 kdDebug() << "KexiMainWindowImpl::slotProjectNew(): new project created --- " << endl;
2657KexiMainWindowImpl::slotProjectOpen()
2661 this, "KexiOpenDialog");
2663 if (dlg.exec()!=TQDialog::Accepted)
2666 openProject(dlg.selectedFileName(), dlg.selectedExistingConnection());
2670 const TQString& fileNameForConnectionData, const TQString& dbName)
2676 if (!fileNameForConnectionData.isEmpty()) {
2679 kdWarning() << "KexiMainWindowImpl::openProject() cdata?" << endl;
2688 const TQValueList<KexiProjectData::ObjectInfo>& autoopenObjects)
2695 bool deleteAfterOpen = false;
2698 if (dbName.isEmpty()) {
2707 deleteAfterOpen = true;
2712 if (aFileName.isEmpty()) {
2713 kdWarning() << "KexiMainWindowImpl::openProject(): aFileName.isEmpty()" << endl;
2717 kdDebug() << "Project File: " << aFileName << endl;
2721 TQString detectedDriverName;
2724 importActionData, detectedDriverName, cdata. driverName, aFileName, this );
2728 if (importActionData) {
2738 deleteAfterOpen = true;
2744 if (deleteAfterOpen)
2752 TQString fileNameForConnectionData;
2753 if (aFileName.isEmpty()) {
2761 const TQString& fileNameForConnectionData, const TQString& dbName)
2763 TQString fileName(aFileName);
2765 args << tqApp->applicationFilePath();
2768 if (fileName.isEmpty()) {
2769 if (!fileNameForConnectionData.isEmpty())
2770 args << "--skip-conn-dialog";
2772 if (dbName.isEmpty()) {
2773 fileName = fileNameForConnectionData;
2776 args << "--connection" << fileNameForConnectionData;
2780 if (fileName.isEmpty()) {
2781 kdWarning() << "KexiMainWindowImpl::openProjectInExternalKexiInstance() fileName?" << endl;
2786 TQProcess proc(args, this, "process");
2787 proc.setWorkingDirectory( TQFileInfo(fileName).dir( true) );
2788 const bool ok = proc.start();
2790 d->showStartProcessMsg(args);
2796KexiMainWindowImpl::slotProjectOpenRecentAboutToShow()
2820 TDEPopupMenu *popup = d->action_open_recent->popupMenu();
2823 d->action_open_recent_projects_title_id = popup->insertTitle(i18n( "Recently Opened Databases"));
2835 popup->insertItem(SmallIconSet( "kexiproject_sqlite"), "My project 1");
2836 popup->insertItem(SmallIconSet( "kexiproject_sqlite"), "My project 2");
2837 popup->insertItem(SmallIconSet( "kexiproject_sqlite"), "My project 3");
2841 d->action_open_recent_connections_title_id =
2842 d->action_open_recent->popupMenu()->insertTitle(i18n( "Recently Connected Database Servers"));
2848 popup->insertItem(SmallIconSet( "socket"), "My connection 1");
2849 popup->insertItem(SmallIconSet( "socket"), "My connection 2");
2850 popup->insertItem(SmallIconSet( "socket"), "My connection 3");
2851 popup->insertItem(SmallIconSet( "socket"), "My connection 4");
2856KexiMainWindowImpl::slotProjectOpenRecent( int id)
2860 kdDebug() << "KexiMainWindowImpl::slotProjectOpenRecent("<< id<< ")"<<endl;
2864KexiMainWindowImpl::slotProjectOpenRecentMore()
2866 KEXI_UNFINISHED(i18n( "Open Recent"));
2870KexiMainWindowImpl::slotProjectSave()
2880KexiMainWindowImpl::slotProjectSaveAs()
2882 KEXI_UNFINISHED(i18n( "Save object as"));
2886KexiMainWindowImpl::slotProjectPrint()
2888 if (d->curDialog && d->curDialog->partItem())
2893KexiMainWindowImpl::slotProjectPrintPreview()
2895 if (d->curDialog && d->curDialog->partItem())
2900KexiMainWindowImpl::slotProjectPageSetup()
2902 if (d->curDialog && d->curDialog->partItem())
2906void KexiMainWindowImpl::slotProjectExportDataTable()
2908 if (d->curDialog && d->curDialog->partItem())
2913KexiMainWindowImpl::slotProjectProperties()
2921KexiMainWindowImpl::slotProjectClose()
2926void KexiMainWindowImpl::slotProjectRelations()
2934void KexiMainWindowImpl::slotImportFile()
2936 KEXI_UNFINISHED( "Import: " + i18n( "From File..."));
2939void KexiMainWindowImpl::slotImportServer()
2941 KEXI_UNFINISHED( "Import: " + i18n( "From Server..."));
2945KexiMainWindowImpl::slotProjectQuit()
2952void KexiMainWindowImpl::slotViewNavigator()
2954 if (!d->nav || !d->navToolWindow)
2956 if (!d->nav->isVisible())
2957 makeWidgetDockVisible(d->nav);
2962 d->navToolWindow->wrapperWidget()->raise();
2964 d->block_KMdiMainFrm_eventFilter= true;
2966 d->block_KMdiMainFrm_eventFilter= false;
2969void KexiMainWindowImpl::slotViewMainArea()
2972 d->curDialog->setFocus();
2975void KexiMainWindowImpl::slotViewPropertyEditor()
2977 if (!d->propEditor || !d->propEditorToolWindow)
2983 if (!d->propEditorTabWidget->isVisible())
2984 makeWidgetDockVisible(d->propEditorTabWidget);
2987 d->propEditorToolWindow->wrapperWidget()->raise();
2989 d->block_KMdiMainFrm_eventFilter= true;
2990 if (d->propEditorTabWidget->currentPage())
2991 d->propEditorTabWidget->currentPage()->setFocus();
2992 d->block_KMdiMainFrm_eventFilter= false;
3003 if (!d->curDialog) {
3004 d->toggleLastCheckedMode();
3007 if (!d->curDialog->supportsViewMode( viewMode )) {
3008 showErrorMessage(i18n( "Selected view is not supported for \"%1\" object.")
3009 .arg(d->curDialog->partItem()->name()),
3010 i18n( "Selected view (%1) is not supported by this object type (%2).")
3012 .arg(d->curDialog->part()->instanceCaption()) );
3013 d->toggleLastCheckedMode();
3016 int prevViewMode = d->curDialog->currentViewMode();
3018 d->curDialog->part(), viewMode );
3019 tristate res = d->curDialog->switchToViewMode( viewMode );
3024 d->toggleLastCheckedMode();
3029 d->toggleLastCheckedMode();
3034 KXMLGUIClient *viewClient=d->curDialog->guiClient();
3036 if (d->curDialogViewGUIClient && !viewClient)
3037 guiFactory()->removeClient(d->curDialogViewGUIClient);
3038 d->curDialogViewGUIClient=viewClient;
3040 d->updatePropEditorVisibility(viewMode);
3043 d->updateFindDialogContents();
3048void KexiMainWindowImpl::slotViewDataMode()
3053void KexiMainWindowImpl::slotViewDesignMode()
3065 if (d->insideCloseDialog && dynamic_cast<KexiDialogBase * >(pWnd)) {
3083 bool& allowOverwriting, const TQString& messageWhenAskingForName )
3087#ifdef KEXI_ADD_CUSTOM_OBJECT_CREATION
3088# include "keximainwindowimpl_customobjcreation.h"
3090 if (!d->nameDialog) {
3091 d->nameDialog = new KexiNameDialog(
3092 messageWhenAskingForName, this, "nameDialog");
3094 d->nameDialog->widget()->addNameSubvalidator(
3098 d->nameDialog->widget()->setMessageText( messageWhenAskingForName );
3100 d->nameDialog->widget()->setCaptionText(partItem->caption());
3101 d->nameDialog->widget()->setNameText(partItem->name());
3102 d->nameDialog->setCaption(i18n( "Save Object As"));
3103 d->nameDialog->setDialogIcon( DesktopIcon( info-> itemIcon(), TDEIcon::SizeMedium ) );
3104 allowOverwriting = false;
3107 if (d->nameDialog->exec()!=TQDialog::Accepted)
3113 d->nameDialog->widget()->nameText(), tmp_sdata );
3116 found = result== true;
3118 if (allowOverwriting) {
3119 int res = KMessageBox::warningYesNoCancel( this,
3120 "<p>"+part-> i18nMessage( "Object \"%1\" already exists.", 0)
3121 .arg(d->nameDialog->widget()->nameText())
3122 + "</p><p>"+i18n( "Do you want to replace it?")+ "</p>", 0,
3123 KGuiItem(i18n( "&Replace"), "button_yes"),
3124 KGuiItem(i18n( "&Choose Other Name...")),
3125 TQString(), KMessageBox::Notify|KMessageBox::Dangerous);
3126 if (res == KMessageBox::No)
3128 else if (res == KMessageBox::Cancel)
3131 allowOverwriting = true;
3136 KMessageBox::information( this,
3137 "<p>"+part-> i18nMessage( "Object \"%1\" already exists.", 0)
3138 .arg(d->nameDialog->widget()->nameText())
3139 + "</p><p>"+i18n( "Please choose other name.")+ "</p>");
3150 partItem->setName( d->nameDialog->widget()->nameText() );
3151 partItem->setCaption( d->nameDialog->widget()->captionText() );
3163 showErrorMessage(i18n( "Saving \"%1\" object failed.").arg(dlg-> partItem()->name()),
3168 const int oldItemID = dlg-> partItem()->identifier();
3170 bool allowOverwriting = false;
3172 messageWhenAskingForName );
3180 showErrorMessage(i18n( "Saving new \"%1\" object failed.").arg(dlg-> partItem()->name()),
3189 d->updateDialogId(dlg, oldItemID);
3203 if (d->insideCloseDialog)
3206#ifndef KEXI_NO_PENDING_DIALOGS
3207 d->addItemToPendingDialogs(dlg-> partItem(), Private::DialogClosingJob);
3210 d->insideCloseDialog = true;
3212 if (dlg == d->curDialog && !dlg->isAttached()) {
3213 if (d->propEditor) {
3216 d->propEditor->editor()->changeSet( 0, false );
3221 if (dlg-> dirty() && !d->forceDialogClosing && !doNotSaveChanges) {
3223 KGuiItem saveChanges( KStdGuiItem::save() );
3224 saveChanges.setToolTip(i18n( "Save changes"));
3225 saveChanges.setWhatsThis(
3226 i18n( "Pressing this button will save all recent changes made in \"%1\" object." )
3228 KGuiItem discardChanges( KStdGuiItem::discard() );
3229 discardChanges.setWhatsThis(
3230 i18n( "Pressing this button will discard all recent changes made in \"%1\" object." )
3238 ":additional message before saving design", dlg);
3239 if (additionalMessage.startsWith( ":"))
3240 additionalMessage = TQString();
3241 if (!additionalMessage.isEmpty())
3242 additionalMessage = "<p>"+additionalMessage+ "</p>";
3244 const int questionRes = KMessageBox::warningYesNoCancel( this,
3245 "<p>"+dlg-> part()-> i18nMessage( "Design of object \"%1\" has been modified.", dlg)
3246 .arg(dlg-> partItem()->name())+ "</p><p>"+i18n( "Do you want to save changes?")+ "</p>"
3247 + additionalMessage ,
3251 if (questionRes==KMessageBox::Cancel) {
3252#ifndef KEXI_NO_PENDING_DIALOGS
3253 d->removePendingDialog(dlg-> id());
3255 d->insideCloseDialog = false;
3256 d->windowsToClose.clear();
3259 if (questionRes==KMessageBox::Yes) {
3265#ifndef KEXI_NO_PENDING_DIALOGS
3266 d->removePendingDialog(dlg-> id());
3268 d->insideCloseDialog = false;
3269 d->windowsToClose.clear();
3272 remove_on_closing = false;
3276 const int dlg_id = dlg-> id();
3278 if (remove_on_closing) {
3281#ifndef KEXI_NO_PENDING_DIALOGS
3282 d->removePendingDialog(dlg-> id());
3286 d->insideCloseDialog = false;
3287 d->windowsToClose.clear();
3294 d->nav->updateItemName( *dlg-> partItem(), false );
3297 d->removeDialog(dlg_id);
3299 int printedObjectID = 0;
3300 if (d->pageSetupDialogItemID2dataItemID_map.contains(dlg_id))
3301 printedObjectID = d->pageSetupDialogItemID2dataItemID_map[ dlg_id ];
3302 d->pageSetupDialogs.take(printedObjectID);
3305 KXMLGUIClient *viewClient = dlg-> guiClient();
3306 if (d->curDialogGUIClient==client) {
3307 d->curDialogGUIClient=0;
3309 if (d->curDialogViewGUIClient==viewClient) {
3310 d->curDialogViewGUIClient=0;
3314 if (d->closedDialogGUIClient && d->closedDialogGUIClient!=client)
3315 guiFactory()->removeClient(d->closedDialogGUIClient);
3316 if (d->openedDialogsCount()==0) {
3317 d->closedDialogGUIClient=0;
3318 guiFactory()->removeClient(client);
3322 d->closedDialogGUIClient=client;
3327 if (d->closedDialogViewGUIClient && d->closedDialogViewGUIClient!=viewClient)
3328 guiFactory()->removeClient(d->closedDialogViewGUIClient);
3329 if (d->openedDialogsCount()==0) {
3330 d->closedDialogViewGUIClient=0;
3331 guiFactory()->removeClient(viewClient);
3335 d->closedDialogViewGUIClient=viewClient;
3339 const bool isInMaximizedChildFrmMode = this->isInMaximizedChildFrmMode();
3341 KMdiMainFrm::closeWindow(dlg, layoutTaskBar);
3344 if (d->openedDialogsCount()==0) {
3345 d->maximizeFirstOpenedChildFrm = isInMaximizedChildFrmMode;
3348 d->updatePropEditorVisibility(0);
3352 d->insideCloseDialog = false;
3353 if (!d->windowsToClose.isEmpty())
3356#ifndef KEXI_NO_PENDING_DIALOGS
3357 d->removePendingDialog( dlg_id );
3360 if (!d->pendingDialogsExist()) {
3361 d->executeActionWhenPendingJobsAreFinished();
3367void KexiMainWindowImpl::detachWindow(KMdiChildView *pWnd, bool bShow)
3369 KMdiMainFrm::detachWindow(pWnd,bShow);
3371 pWnd->setIcon( DesktopIcon( static_cast<KexiDialogBase * >(pWnd)->itemIcon() ) );
3374 dynamic_cast<KexiDialogBase* >(pWnd)->sendDetachedStateToCurrentView();
3377void KexiMainWindowImpl::attachWindow(KMdiChildView *pWnd, bool , bool bAutomaticResize)
3380 KMdiMainFrm::attachWindow(pWnd, true,bAutomaticResize);
3382 if (pWnd->mdiParent()->state() == KMdiChildFrm::Normal
3383 && pWnd->geometry().bottom() > pWnd->mdiParent()->mdiAreaContentsRect().bottom())
3385 TQRect r = pWnd->geometry();
3386 r.setBottom( pWnd->mdiParent()->mdiAreaContentsRect().bottom() - 5 );
3387 pWnd->setGeometry( r );
3390 pWnd->mdiParent()->setIcon( SmallIcon( static_cast<KexiDialogBase * >(pWnd)->itemIcon() ) );
3392 dynamic_cast<KexiDialogBase* >(pWnd)->sendAttachedStateToCurrentView();
3398 w = w->parentWidget();
3404 return w->inherits( "KexiDialogBase") || w->inherits( "KexiViewBase");
3410 if (e->type()==TQEvent::KeyPress) {
3411 KexiVDebug << "KEY EVENT " << TQString::number( static_cast<TQKeyEvent* >(e)->key(), 16) << endl;
3414 if (e->type()==TQEvent::AccelOverride) {
3418 if ( static_cast<TQKeyEvent* >(e)->key()==TQt::Key_Tab && static_cast<TQKeyEvent* >(e)->state() == ControlButton) {
3419 if (d->action_window_next->shortcut().keyCodeQt()==TQt::Key_Tab+TQt::CTRL && d->action_window_next->shortcut().count()==1
3420 && (mdiMode()==KMdi::TabPageMode || mdiMode()==KMdi::IDEAlMode))
3422 static_cast<TQKeyEvent* >(e)->accept();
3426 if (e->type()==TQEvent::Close) {
3427 KexiVDebug << "Close EVENT" << endl;
3429 if (e->type()==TQEvent::Resize) {
3430 KexiVDebug << "Resize EVENT" << endl;
3432 if (e->type()==TQEvent::ShowMaximized) {
3433 KexiVDebug << "ShowMaximized EVENT" << endl;
3442 TQWidget *focus_w = 0;
3443 if (obj->inherits( "TQPopupMenu")) {
3449 if (e->type()==TQEvent::Hide || e->type()==TQEvent::Show) {
3450 KexiVDebug << e->type() << endl;
3452 if (!d->focus_before_popup.isNull()) {
3453 d->focus_before_popup->setFocus();
3454 d->focus_before_popup=0;
3458 focus_w->setFocus();
3467 if (e->type()==TQEvent::MouseButtonPress) {
3468 TQWidget *w = findWindow( static_cast<TQWidget* >(obj));
3469 KexiVDebug << "MouseButtonPress EVENT " << (w ? w->name() : 0) << endl;
3475 TQWidget *w = findWindow( static_cast<TQWidget* >(obj));
3476 if (e->type()==TQEvent::FocusIn) {
3478 KexiVDebug << "Focus EVENT" << endl;
3479 KexiVDebug << (focus_w ? focus_w->name() : "" ) << endl;
3480 KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name() <<endl;
3481#ifdef KEXI_STATUSBAR_DEBUG
3482 TQWidget *focus_widget = focus_w ? focus_w->focusWidget() : 0;
3483 d->statusBar->setStatus(TQString( "FOCUS VIEW: %1 %2, FOCUS WIDGET: %3 %4")
3484 .arg(focus_w ? focus_w->className() : "").arg(focus_w ? focus_w->name() : "")
3485 .arg(focus_widget ? focus_widget->className() : "").arg(focus_widget ? focus_widget->name() : "")
3489 else if (e->type()==TQEvent::FocusOut) {
3491 KexiVDebug << "Focus OUT EVENT" << endl;
3492 KexiVDebug << (focus_w ? focus_w->name() : "" ) << endl;
3493 KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name() <<endl;
3494#ifdef KEXI_STATUSBAR_DEBUG
3495 TQWidget *focus_widget = focus_w ? focus_w->focusWidget() : 0;
3496 d->statusBar->setStatus(TQString( "FOCUS VIEW: %1 %2, FOCUS WIDGET: %3 %4")
3497 .arg(focus_w ? focus_w->className() : "").arg(focus_w ? focus_w->name() : "")
3498 .arg(focus_widget ? focus_widget->className() : "").arg(focus_widget ? focus_widget->name() : "")
3502 if (e->type()==TQEvent::WindowActivate) {
3503 KexiVDebug << "WindowActivate EVENT" << endl;
3504 KexiVDebug << "eventFilter: " <<e->type() << " " <<obj->name()<<endl;
3507 if (e->type()==TQEvent::FocusIn) {
3524 if (e->type()==TQEvent::FocusOut && focus_w && focus_w==d->curDialog && actionProxyFor( obj )) {
3529 if (!d->focus_before_popup.isNull() && e->type()==TQEvent::FocusOut && obj->inherits( "KMenuBar")) {
3531 d->focus_before_popup->setFocus();
3532 d->focus_before_popup=0;
3538 if (e->type()==TQEvent::FocusOut) {
3539 if ( static_cast<TQFocusEvent* >(e)->reason()==TQFocusEvent::Popup) {
3542 d->focus_before_popup=d->curDialog;
3546 d->focus_before_popup=focus_w;
3552 if (w && w==d->nav) {
3554 if (e->type()==TQEvent::FocusIn) {
3556 } else if (e->type()==TQEvent::WindowActivate && w==d->focus_before_popup) {
3558 d->focus_before_popup=0;
3560 } else if (e->type()==TQEvent::FocusOut) {
3561 if ( static_cast<TQFocusEvent* >(e)->reason()==TQFocusEvent::Tab) {
3564 d->curDialog->activate();
3568 else if ( static_cast<TQFocusEvent* >(e)->reason()==TQFocusEvent::Popup) {
3569 d->focus_before_popup=w;
3572 } else if (e->type()==TQEvent::Hide) {
3577 if (d->block_KMdiMainFrm_eventFilter)
3579 return KMdiMainFrm::eventFilter(obj,e);
3593 int viewMode, bool &openingCancelled, TQMap<TQString,TQString>* staticObjectArgs)
3598 return openObject(item, viewMode, openingCancelled, staticObjectArgs);
3603 TQMap<TQString,TQString>* staticObjectArgs, TQString* errorMessage)
3607 *errorMessage = i18n( "opening is not allowed in \"data view/design view/text view\" mode",
3609 openingCancelled = true;
3613 if (!d->prj || !item)
3616#ifndef KEXI_NO_PENDING_DIALOGS
3617 Private::PendingJobType pendingType;
3619 if (pendingType != Private::NoJob) {
3620 openingCancelled = true;
3626 openingCancelled = false;
3628 bool needsUpdateViewGUIClient = true;
3635 needsUpdateViewGUIClient = false;
3638 d->updatePropEditorVisibility(viewMode);
3645#ifndef KEXI_NO_PENDING_DIALOGS
3646 d->addItemToPendingDialogs(item, Private::DialogOpeningJob);
3648 dlg = d->prj->openObject( this, *item, viewMode, staticObjectArgs);
3652#ifndef KEXI_NO_PENDING_DIALOGS
3653 d->removePendingDialog(item->identifier());
3660 if (needsUpdateViewGUIClient ) {
3662 KXMLGUIClient *viewClient=dlg-> guiClient();
3664 if (d->curDialogViewGUIClient && !viewClient)
3665 guiFactory()->removeClient(d->curDialogViewGUIClient);
3666 d->curDialogViewGUIClient=viewClient;
3673#ifndef KEXI_NO_PENDING_DIALOGS
3674 d->removePendingDialog( dlg-> id() );
3677 if (!d->pendingDialogsExist()) {
3678 d->executeActionWhenPendingJobsAreFinished();
3687 bool openingCancelled;
3693 bool &openingCancelled)
3696 openingCancelled = true;
3699 if (!d->prj || !item)
3701#ifndef KEXI_NO_PENDING_DIALOGS
3702 Private::PendingJobType pendingType;
3704 if (pendingType!=Private::NoJob) {
3705 openingCancelled = true;
3711 openingCancelled = false;
3722 if (viewMode == Kexi::DataViewMode && !(part-> supportedViewModes() & Kexi::DataViewMode)) {
3729 return openObject(item, viewMode, openingCancelled);
3734#ifndef KEXI_NO_PENDING_DIALOGS
3735 Private::PendingJobType pendingType;
3737 if (pendingType == Private::DialogClosingJob)
3739 else if (pendingType == Private::DialogOpeningJob)
3752 openingCancelled = true;
3755 openingCancelled = false;
3756 if (!d->prj || !info)
3762#ifdef KEXI_ADD_CUSTOM_OBJECT_CREATION
3763# include "keximainwindowimpl_customobjcreation.h"
3773 d->nav->addItem(*it);
3774 return openObject(it, Kexi::DesignViewMode, openingCancelled);
3781 if (!d->prj || !item)
3789 if (KMessageBox::No == KMessageBox::warningYesNo( this,
3790 "<p>"+i18n( "Do you want to permanently delete:\n"
3792 "If you click \"Delete\", you will not be able to undo the deletion.")
3793 .arg( "</p><p>"+part-> instanceCaption()+ " \""+ item->name() + "\"?</p>" ),
3794 0, KGuiItem(i18n( "Delete"), "edit-delete"), KStdGuiItem::no()))
3803 KexiDialogBase * pageSetupDlg = d->pageSetupDialogs[ item->identifier() ];
3804 const bool oldInsideCloseDialog = d->insideCloseDialog;
3805 d->insideCloseDialog = false;
3807 d->insideCloseDialog = oldInsideCloseDialog;
3812#ifndef KEXI_NO_PENDING_DIALOGS
3813 Private::PendingJobType pendingType;
3815 if (pendingType!=Private::NoJob) {
3824 const bool tmp = d->forceDialogClosing;
3826 d->forceDialogClosing = true;
3828 d->forceDialogClosing = tmp;
3839 int dataItemID = d->pageSetupDialogItemID2dataItemID_map[item->identifier()];
3840 d->pageSetupDialogItemID2dataItemID_map.remove(item->identifier());
3841 d->pageSetupDialogs.take( dataItemID );
3843 if (!d->prj->removeObject( this, *item)) {
3845 showSorryMessage( i18n( "Could not remove object.") );
3857 d->pendingDialogsExist();
3858 TQString newName = _newName.stripWhiteSpace();
3859 if (newName.isEmpty()) {
3860 showSorryMessage( i18n( "Could not set empty name for this object.") );
3865 const bool res = d->prj->renameObject( this, *item, newName);
3868 showErrorMessage( d->prj, i18n( "Renaming object \"%1\" failed.").arg(newName) );
3872 d->pendingDialogsExist();
3877#ifndef KEXI_NO_PENDING_DIALOGS
3878 Private::PendingJobType pendingType;
3880 if (pendingType!=Private::NoJob)
3889 dlg->updateCaption();
3896 return --d->privateIDCounter;
3899void KexiMainWindowImpl::acceptPropertySetEditing()
3902 d->propEditor->editor()->acceptInput();
3905void KexiMainWindowImpl::propertySetSwitched( KexiDialogBase *dlg, bool force,
3906 bool preservePrevSelection, const TQCString& propertyToSelect)
3908 kdDebug() << "KexiMainWindowImpl::propertySetSwitched() d->curDialog: "
3909 << (d->curDialog ? d->curDialog->caption() : TQString( "NULL")) << " dlg: " << (dlg ? dlg->caption() : TQString( "NULL"))<< endl;
3914 if (d->propEditor) {
3915 KoProperty::Set *newBuf = d->curDialog ? d->curDialog->propertySet() : 0;
3916 if (!newBuf || (force || static_cast<KoProperty::Set* >(d->propBuffer) != newBuf)) {
3917 d->propBuffer = newBuf;
3918 if (preservePrevSelection) {
3919 if (propertyToSelect.isEmpty())
3920 d->propEditor->editor()->changeSet( d->propBuffer, preservePrevSelection );
3922 d->propEditor->editor()->changeSet( d->propBuffer, propertyToSelect );
3933 d->nav->updateItemName( *item, dlg-> dirty() );
3939void KexiMainWindowImpl::slotMdiModeHasBeenChangedTo(KMdi::MdiMode)
3946void KexiMainWindowImpl::slotTipOfTheDay()
3956void KexiMainWindowImpl::slotStartFeedbackAgent()
3958#ifndef KEXI_NO_FEEDBACK_AGENT
3959#ifdef FEEDBACK_CLASS
3960 const TDEAboutData* about = TDEApplication::kApplication()->aboutData();
3961 FEEDBACK_CLASS* wizard = new FEEDBACK_CLASS( about->programName(),
3962 about->version(), 0, 0, 0, FEEDBACK_CLASS::AllPages );
3964 if ( wizard->exec() )
3966 TDEApplication::kApplication()->invokeMailer( "kexi-reports-dummy@kexi.org",
3967 TQString(), TQString(),
3968 about->appName() + TQCString( " [feedback]" ),
3969 wizard->feedbackDocument().toString( 2 ).local8Bit() );
3980 if (onStartup && !d->showImportantInfoOnStartup)
3983 TQString key = TQString( "showImportantInfo %1").arg(KEXI_VERSION_STRING);
3984 d->config->setGroup( "Startup");
3985 bool show = d->config->readBoolEntry(key, true);
3987 if (show || !onStartup) {
3988 d->config->setGroup( "TipOfDay");
3989 if (!d->config->hasKey( "RunOnStart"))
3990 d->config->writeEntry( "RunOnStart", true);
3992 TQString lang = TDEGlobal::locale()->language();
3993 TQString fname = locate( "data", TQString( "kexi/readme_")+lang);
3994 if (fname.isEmpty())
3995 fname = locate( "data", "kexi/readme_en");
3996 KTipDialog tipDialog( new KTipDatabase(TQString()), 0);
3997 tipDialog.setCaption(i18n( "Important Information"));
3998 TQObjectList *l = tipDialog.queryList( "KPushButton" );
4000 for (TQObjectListIt it( *l ); it.current() && i<2; ++it, i++ )
4001 static_cast<KPushButton* >(it.current())->hide();
4003 if ( f.open( IO_ReadOnly ) ) {
4004 TQTextStream ts(&f);
4005 ts.setCodec( TDEGlobal::locale()->codecForEncoding() );
4008 tb->setText( TQString( "<qt>%1</qt>").arg(ts.read()) );
4013 tipDialog.adjustSize();
4014 TQRect desk = TQApplication::desktop()->screenGeometry( TQApplication::desktop()->screenNumber( this) );
4015 tipDialog.resize( TQMAX(tipDialog.width(),desk.width()*3/5), TQMAX(tipDialog.height(),desk.height()*3/5) );
4016 KDialog::centerOnScreen(&tipDialog);
4017 tipDialog.setModal ( true );
4020 d->config->setGroup( "TipOfDay");
4021 show = d->config->readBoolEntry( "RunOnStart", show);
4025 d->config->setGroup( "Startup");
4026 d->config->writeEntry(key,show);
4027 d->showImportantInfoOnStartup = false;
4031void KexiMainWindowImpl::slotOptionsEnableForms( bool show, bool noMessage)
4033 Q_UNUSED(noMessage);
4064 TQString err_msg = i18n( "Could not start project \"%1\" in Final Mode.")
4069 showErrorMessage( err_msg, i18n( "No Final Mode data found.") );
4077 showErrorMessage( err_msg, i18n( "Error reading Final Mode data.") );
4081 TQString startupPart;
4082 TQString startupItem;
4085 kdDebug() << "KexiMainWinImpl::initFinalMode(): property: [" << c-> value(1).toString() << "] " << c-> value(2).toString() << endl;
4086 if(c-> value(1).toString() == "startup-part")
4087 startupPart = c-> value(2).toString();
4088 else if(c-> value(1).toString() == "startup-item")
4089 startupItem = c-> value(2).toString();
4090 else if(c-> value(1).toString() == "mainxmlui")
4091 setXML(c-> value(2).toString());
4093 d->prj->dbConnection()->deleteCursor(c);
4095 kdDebug() << "KexiMainWinImpl::initFinalMode(): part: " << startupPart << endl;
4096 kdDebug() << "KexiMainWinImpl::initFinalMode(): item: " << startupItem << endl;
4100 guiFactory()->addClient( this);
4101 setStandardToolBarMenuEnabled( false);
4102 setHelpMenuEnabled( false);
4107 showErrorMessage( err_msg, i18n( "Specified plugin does not exist.") );
4113 bool openingCancelled;
4114 if(! openObject(item, Kexi::DataViewMode, openingCancelled) && !openingCancelled) {
4116 showErrorMessage( err_msg, i18n( "Specified object could not be opened.") );
4120 TQWidget::setCaption( "MyApp");
4129 KexiDB::Cursor *c = d->prj->dbConnection()->executeQuery( "SELECT p_id, name, text, icon, method, arguments FROM kexi__useractions WHERE scope = 0");
4137 d->prj->dbConnection()->deleteCursor(c);
4148void KexiMainWindowImpl::slotToolsProjectMigration()
4157 const bool projectWasOpened = d->prj;
4162 this, "KexiOpenDialog");
4164 if (dlg.exec()!=TQDialog::Accepted)
4182 if ( true==res && !detectedImportAction)
4185 KMessageBox::information( this, "<qt>"+
4186 i18n( "Compacting database file <nobr>\"%1\"</nobr> is not supported.")
4187 .arg(TQDir::convertSeparators(cdata. fileName())));
4194 if ( !(d->prj && d->prj->dbConnection()
4198 if (KMessageBox::Continue != KMessageBox::warningContinueCancel( this,
4199 i18n( "The current project has to be closed before compacting the database. "
4200 "It will be open again after compacting.\n\nDo you want to continue?")))
4204 drv = d->prj->dbConnection()->driver();
4217 if (projectWasOpened)
4226 TQMap<TQString,TQString> args;
4227 args.insert( "mimeType", mimeType);
4228 args.insert( "databaseName", databaseName);
4232 args.insert( "connectionData", str);
4239 const int result = dlg->exec();
4242 if (result!=TQDialog::Accepted)
4246 TQString destinationDatabaseName( args[ "destinationDatabaseName"] );
4247 TQString fileName, destinationConnectionShortcut, dbName;
4248 if (!destinationDatabaseName.isEmpty()) {
4249 if (args.contains( "destinationConnectionShortcut")) {
4251 destinationConnectionShortcut = args[ "destinationConnectionShortcut"];
4255 fileName = destinationDatabaseName;
4256 destinationDatabaseName = TQString();
4259 destinationDatabaseName);
4285 TQMap<TQString,TQString> args;
4286 args.insert( "sourceType", "file");
4288 "csv_importexport", "KexiCSVImportDialog", this, this, 0, &args);
4296 const TQString& actionName)
4298 if (actionName == "exportToCSV")
4300 else if (actionName == "copyToClipboardAsCSV")
4303 kexiwarn << "KexiMainWindowImpl::executeCustomActionForObject(): no such action: "
4304 << actionName << endl;
4315 TQMap<TQString,TQString> args;
4316 args.insert( "destinationType", "file");
4317 args.insert( "itemId", TQString::number(item->identifier()));
4319 "csv_importexport", "KexiCSVExportWizard", this, this, 0, &args);
4322 int result = dlg->exec();
4324 return result == TQDialog::Rejected ? cancelled : true;
4338 const TQString& titleText)
4344 return cmd.print(settings, titleText);
4365 item, "KexiSimplePrintingCommand");
4367 d->addOpenedCustomObjectForItem(
4370 "KexiSimplePrintingCommand"
4391 KexiDialogBase *printingDialog = d->pageSetupDialogs[ item->identifier() ];
4392 if (printingDialog) {
4395 if (action == PreviewItem || action == PrintItem) {
4397 (action == PreviewItem) ? TQ_SLOT(printPreview()) : TQ_SLOT(print()));
4402#ifndef KEXI_NO_PENDING_DIALOGS
4403 Private::PendingJobType pendingType;
4405 if (pendingType!=Private::NoJob)
4413 TQWidget *prevFocusWidget = focusWidget();
4415 d->action_data_save_row->activate();
4416 if (prevFocusWidget)
4417 prevFocusWidget->setFocus();
4423 KGuiItem saveChanges( KStdGuiItem::save() );
4424 saveChanges.setToolTip(i18n( "Save changes"));
4425 saveChanges.setWhatsThis(
4426 i18n( "Pressing this button will save all recent changes made in \"%1\" object." )
4427 .arg(item->name()) );
4428 KGuiItem doNotSave( KStdGuiItem::no() );
4429 doNotSave.setWhatsThis(
4430 i18n( "Pressing this button will ignore all unsaved changes made in \"%1\" object." )
4434 if (action == PrintItem)
4435 question = i18n( "Do you want to save changes before printing?");
4436 else if (action == PreviewItem)
4437 question = i18n( "Do you want to save changes before making print preview?");
4438 else if (action == PageSetupForItem)
4439 question = i18n( "Do you want to save changes before showing page setup?");
4443 const int questionRes = KMessageBox::warningYesNoCancel( this,
4444 "<p>"+dlg-> part()-> i18nMessage( "Design of object \"%1\" has been modified.", dlg)
4445 .arg(item->name()) + "</p><p>" + question + "</p>",
4449 if (KMessageBox::Cancel == questionRes)
4451 if (KMessageBox::Yes == questionRes) {
4453 if ( true != savingRes)
4462 printingPart, item->name()
4464 TQMap<TQString,TQString> staticObjectArgs;
4465 staticObjectArgs[ "identifier"] = TQString::number(item->identifier());
4466 if (action == PrintItem)
4467 staticObjectArgs[ "action"] = "print";
4468 else if (action == PreviewItem)
4469 staticObjectArgs[ "action"] = "printPreview";
4470 else if (action == PageSetupForItem)
4471 staticObjectArgs[ "action"] = "pageSetup";
4474 bool openingCancelled;
4475 printingDialog = openObject(printingPartItem, Kexi::DesignViewMode,
4476 openingCancelled, &staticObjectArgs);
4477 if (openingCancelled)
4479 if (!printingDialog)
4481 d->pageSetupDialogs.insert(item->identifier(), printingDialog);
4482 d->pageSetupDialogItemID2dataItemID_map.insert(
4483 printingDialog-> partItem()->identifier(), item->identifier());
4488void KexiMainWindowImpl::slotEditCopySpecialDataTable()
4500 TQMap<TQString,TQString> args;
4501 args.insert( "destinationType", "clipboard");
4502 args.insert( "itemId", TQString::number(item->identifier()));
4504 "csv_importexport", "KexiCSVExportWizard", this, this, 0, &args);
4507 const int result = dlg->exec();
4509 return result == TQDialog::Rejected ? cancelled : true;
4517 TQMap<TQString,TQString> args;
4518 args.insert( "sourceType", "clipboard");
4520 "csv_importexport", "KexiCSVImportDialog", this, this, 0, &args);
4527void KexiMainWindowImpl::slotEditFind()
4533 d->updateFindDialogContents( true);
4534 d->findDialog()->setReplaceMode( false);
4536 d->findDialog()->show();
4537 d->findDialog()->setActiveWindow();
4538 d->findDialog()->raise();
4541void KexiMainWindowImpl::slotEditFind( bool next)
4547 d->findDialog()->valueToFind(), d->findDialog()->options(), next);
4550 d->findDialog()->updateMessage( true == res );
4554void KexiMainWindowImpl::slotEditFindNext()
4556 slotEditFind( true );
4559void KexiMainWindowImpl::slotEditFindPrevious()
4561 slotEditFind( false );
4569 d->updateFindDialogContents( true);
4570 d->findDialog()->setReplaceMode( true);
4572 d->findDialog()->show();
4573 d->findDialog()->setActiveWindow();
4576void KexiMainWindowImpl::slotEditReplaceNext()
4589 d->findDialog()->valueToFind(), d->findDialog()->valueToReplaceWith(),
4590 d->findDialog()->options(), all);
4591 d->findDialog()->updateMessage( true == res );
4595void KexiMainWindowImpl::slotEditReplaceAll()
4605 if (d->maximizeFirstOpenedChildFrm) {
4606 flags |= KMdi::Maximize;
4607 d->maximizeFirstOpenedChildFrm = false;
4609 KexiMainWindow::addWindow( pView, flags );
4615#ifdef HAVE_TDENEWSTUFF
4617 d->newStuff = new KexiNewStuff( this);
4618 d->newStuff->download();
4626 slotViewNavigator();
4633 d->nav->selectItem(*item);
4642#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 Kexi dialog's gui COMMON client.
virtual void attachToGUIClient()
KexiPart::GUIClient * guiClient() const Kexi dialog's gui client for currently selected view.
KexiPart::Part * part() const
tristate storeData(bool dontAsk=false)
KexiPart::Item * partItem() const
KexiViewBase * selectedView() const
static KexiDialogBase * createKexiDialogInstance(const char *partName, KexiDB::MessageHandler *msgHdr, KexiMainWindow *mainWin, const char *objName=0)
static TQDialog * createModalDialogInstance(const char *partName, const char *dialogClass, KexiDB::MessageHandler *msgHdr, KexiMainWindow *mainWin, const char *objName=0, TQMap< TQString, TQString > *args=0)
Kexi's main window implementation.
void slotImportantInfo() just importantInfo(false);
void updateReadOnlyState() Updates the statusbar, navigator and "Insert->....." actions, dependent on read-only state.
bool switchToViewMode(int viewMode)
void createKexiProject(KexiProjectData *new_data) internal - creates and initializes kexi project
virtual void slotObjectRenamed(const KexiPart::Item &item, const TQCString &oldName)
void slotDirtyFlagChanged(KexiDialogBase *)
virtual KexiDialogBase * currentDialog() const
virtual tristate showPageSetupForItem(KexiPart::Item *item) Shows "page setup" dialog for item.
virtual bool acceptsSharedActions(TQObject *w)
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) Shows "print" dialog for item.
KexiDialogBase * openObjectFromNavigator(KexiPart::Item *item, int viewMode, bool &openingCancelled)
virtual KexiProject * project() Project data of currently opened project or NULL if no project here yet.
virtual bool eventFilter(TQObject *obj, TQEvent *e)
virtual tristate getNewObjectInfo(KexiPart::Item *partItem, KexiPart::Part *part, bool &allowOverwriting, const TQString &messageWhenAskingForName=TQString())
void projectOpened() Emitted after opening a project, even after slotAutoOpenObjectsLater().
virtual void switchToIDEAlMode() reimplemented to add "restart is required" message box
virtual void closeWindow(KMdiChildView *pWnd, bool layoutTaskBar=true)
virtual void invalidateSharedActions(TQObject *o)
void slotViewTextMode() sometimes called "SQL View"
virtual bool userMode() const
tristate executeItem(KexiPart::Item *item)
bool initUserMode(KexiProjectData *projectData)
virtual void addWindow(KMdiChildView *pView, int flags=KMdi::StandardAdd)
virtual KexiDialogBase * openObject(KexiPart::Item *item, int viewMode, bool &openingCancelled, TQMap< TQString, TQString > *staticObjectArgs=0, TQString *errorMessage=0)
virtual TQPopupMenu * findPopupMenu(const char *popupName)
void importantInfo(bool onStartup) Shows 'important info' dialog, is onStartup is false, it's always shown.
virtual void registerChild(KexiDialogBase *dlg)
void activeWindowChanged(KMdiChildView *dlg)
void childClosed(KMdiChildView *dlg)
void slotLastActions() There are performed all actions that need to be done immediately after ctro (using timer)
void updateCustomPropertyPanelTabs(KexiDialogBase *prevDialog, int prevViewMode)
tristate printActionForItem(KexiPart::Item *item, PrintActionType action)
tristate copyItemToClipboardAsDataTable(KexiPart::Item *item) Shows "copy special as data table" dialog for item.
void 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) Shows "print preview" dialog.
bool openingAllowed(KexiPart::Item *item, int viewMode)
tristate openProject(const KexiProjectData &projectData)
virtual TDEActionPtrList allActions() const
virtual void readProperties(TDEConfig *config)
void slotCaptionForCurrentMDIChild(bool childrenMaximized) internal
tristate 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)
Kexi's main window interface This interface is implemented by KexiMainWindowImpl class.
PrintActionType Used by printActionForItem()
void beforeProjectClosing() Emitted before closing the project (and destroying all it's data members).
void acceptProjectClosingRequested(bool &cancel) Emitted to make sure the project can be close.
void projectClosed() Emitted after closing the project.
Information about a Kexi Part (plugin).
bool isDataExportSupported() const
int projectPartID() const
TQCString mimeType() const
bool isPrintingSupported() const
TQString itemIcon() const
bool isExecuteSupported() const
Information about a single object that can be instantiated using Kexi Part.
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) Creates GUICLients for this part, attached to win This method is called from KexiMainWindow.
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 forcedDesignMode() const
bool forcedUserMode() const
KexiProjectData * projectData() const
TQString selectedFileName() const
static bool askForOverwriting(const TQString &filePath, TQWidget *parent=0)
@ DontConvert skip asking for conversion (used e.g. when dropdb is called)
@ 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)
type * findParent(TQObject *o, const char *className)
bool hasParent(TQObject *par, TQObject *o)
KEXIUTILS_EXPORT void serializeMap(const TQMap< TQString, TQString > &map, const TQByteArray &array)
KEXIUTILS_EXPORT TQString fileDialogFilterStrings(const TQStringList &mimeStrings, bool kdeFormat)
KEXICORE_EXPORT bool & tempShowScripts() false by default, flag loaded on main window startup
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
@ PartItemActionCategory action related to part item, e.g.
@ GlobalActionCategory global application action like editcopy; can be applied to focused widget (of many types)
@ WindowActionCategory action related to active window, which can display table, query, form, report...
KEXICORE_EXPORT TQFont smallFont(TQWidget *init=0)
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.
@ NoViewMode In KexiViewBase::afterSwitchFrom() and KexiViewBase::beforeSwitchTo() means that parent dialog of the...
|