Kexi API Documentation (2.0 alpha)

keximainwindowimpl.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 2003-2007 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "keximainwindowimpl.h"
00022 
00023 #include <unistd.h>
00024 
00025 #include <qapplication.h>
00026 #include <qeventloop.h>
00027 #include <qfile.h>
00028 #include <qtimer.h>
00029 #include <qobjectlist.h>
00030 #include <qprocess.h>
00031 #include <qtoolbutton.h>
00032 #include <qtooltip.h>
00033 #include <qmutex.h>
00034 #include <qwaitcondition.h>
00035 
00036 #include <kapplication.h>
00037 #include <kcmdlineargs.h>
00038 #include <kaction.h>
00039 #include <klocale.h>
00040 #include <kstdaccel.h>
00041 #include <kconfig.h>
00042 #include <kglobal.h>
00043 #include <kdebug.h>
00044 #include <kkeydialog.h>
00045 #include <kedittoolbar.h>
00046 #include <kdeversion.h>
00047 #include <kglobalsettings.h>
00048 #include <kparts/componentfactory.h>
00049 #include <ktip.h>
00050 #include <kstandarddirs.h>
00051 #include <kpushbutton.h>
00052 #include <ktextbrowser.h>
00053 #include <kiconloader.h>
00054 #include <ktabwidget.h>
00055 #include <kimageio.h>
00056 #include <khelpmenu.h>
00057 
00058 #include <kexidb/connection.h>
00059 #include <kexidb/utils.h>
00060 #include <kexidb/cursor.h>
00061 #include <kexidb/dbobjectnamevalidator.h>
00062 #include <kexidb/admin.h>
00063 #include <kexiutils/utils.h>
00064 
00065 //#include "projectsettingsui.h"
00066 #include "kexiactionproxy.h"
00067 #include "kexidialogbase.h"
00068 #include "kexipartmanager.h"
00069 #include "kexipart.h"
00070 #include "kexipartinfo.h"
00071 #include "kexipartguiclient.h"
00072 #include "kexiproject.h"
00073 #include "kexiprojectdata.h"
00074 #include "kexiprojectset.h"
00075 #include "kexi.h"
00076 #include "kexistatusbar.h"
00077 #include "kexiinternalpart.h"
00078 #include "kexiactioncategories.h"
00079 #include "kde2_closebutton.xpm"
00080 
00081 #include <widget/kexibrowser.h>
00082 #include <widget/kexipropertyeditorview.h>
00083 #include <widget/utils/kexirecordnavigator.h>
00084 #include <koproperty/editor.h>
00085 #include <koproperty/set.h>
00086 
00087 #include "startup/KexiStartup.h"
00088 #include "startup/KexiNewProjectWizard.h"
00089 #include "startup/KexiStartupDialog.h"
00090 /*
00091 #include "startup/KexiConnSelector.h"
00092 #include "startup/KexiProjectSelectorBase.h"
00093 #include "startup/KexiProjectSelector.h"
00094 */
00095 #include "kexinamedialog.h"
00096 #include "printing/kexisimpleprintingpart.h"
00097 #include "printing/kexisimpleprintingpagesetup.h"
00098 
00099 //Extreme verbose debug
00100 #if defined(Q_WS_WIN)
00101 //# define KexiVDebug kdDebug()
00102 #endif
00103 #if !defined(KexiVDebug)
00104 # define KexiVDebug if (0) kdDebug()
00105 #endif
00106 
00107 //first fix the geometry
00108 //#define KEXI_NO_CTXT_HELP 1
00109 
00110 #ifndef KEXI_NO_CTXT_HELP
00111 #include <kexicontexthelp.h>
00112 #endif
00113 
00114 #ifdef HAVE_KNEWSTUFF
00115 #include <knewstuff/downloaddialog.h>
00116 #include "kexinewstuff.h"
00117 #endif
00118 
00121 //#define PROPEDITOR_VISIBILITY_CHANGES
00122 
00123 //temporary fix to manage layout
00124 #include "ksplitter.h"
00125 #define KDOCKWIDGET_P 1
00126 
00127 #ifndef KEXI_NO_FEEDBACK_AGENT
00128 #ifdef FEEDBACK_INCLUDE
00129 #include FEEDBACK_INCLUDE
00130 #endif
00131 #include <kapplication.h>
00132 #include <kaboutdata.h>
00133 #endif
00134 
00135 #include "keximainwindowimpl_p.h"
00136 
00137 //-------------------------------------------------
00138 
00139 //static
00140 int KexiMainWindowImpl::create(int argc, char *argv[], KAboutData* aboutdata)
00141 {
00142     Kexi::initCmdLineArgs( argc, argv, aboutdata );
00143 
00144     bool GUIenabled = true;
00145     QWidget *dummyWidget = 0; //needed to have icon for dialogs before KexiMainWindowImpl is created
00147     KApplication* app = new KApplication(true, GUIenabled);
00148 #ifdef KEXI_STANDALONE
00149     KGlobal::locale()->removeCatalogue("kexi");
00150     KGlobal::locale()->insertCatalogue("standalone_kexi");
00151 #endif
00152     KGlobal::locale()->insertCatalogue("koffice");
00153     KGlobal::locale()->insertCatalogue("koproperty");
00154 
00155 #ifdef KEXI_DEBUG_GUI
00156     QWidget* debugWindow = 0;
00157 #endif
00158     if (GUIenabled) {
00159         dummyWidget = new QWidget();
00160         dummyWidget->setIcon( DesktopIcon( "kexi" ) );
00161         app->setMainWidget(dummyWidget);
00162 #ifdef KEXI_DEBUG_GUI
00163         app->config()->setGroup("General");
00164         if (app->config()->readBoolEntry("showInternalDebugger", false)) {
00165             debugWindow = KexiUtils::createDebugWindow(0);
00166         }
00167 #endif
00168     }
00169 
00170     tristate res = Kexi::startupHandler().init(argc, argv);
00171     if (!res || ~res) {
00172 #ifdef KEXI_DEBUG_GUI
00173         delete debugWindow;
00174 #endif
00175         delete app;
00176         return (~res) ? 0 : 1;
00177     }
00178     
00179     kdDebug() << "startupActions OK" <<endl;
00180 
00181     /* Exit requested, e.g. after database removing. */
00182     if (Kexi::startupHandler().action() == KexiStartupData::Exit) {
00183 #ifdef KEXI_DEBUG_GUI
00184         delete debugWindow;
00185 #endif
00186         delete app;
00187         return 0;
00188     }
00189 
00190 #ifdef CUSTOM_VERSION
00191 # include "custom_exec.h"
00192 #endif
00193 
00194     KexiMainWindowImpl *win = new KexiMainWindowImpl();
00195     app->setMainWidget(win);
00196 #ifdef KEXI_DEBUG_GUI
00197     //if (debugWindow)
00198         //debugWindow->reparent(win, QPoint(1,1));
00199 #endif
00200     delete dummyWidget;
00201 
00202     if (true != win->startup()) {
00203         delete win;
00204         delete app;
00205         return 1;
00206     }
00207 
00208     win->show();
00209     app->processEvents();//allow refresh our app
00210 
00211 //#ifdef KEXI_DEBUG_GUI
00212 //  delete debugWindow;
00213 //#endif
00214     return 0;
00215 }
00216 
00217 //-------------------------------------------------
00218 
00219 KexiMainWindowImpl::KexiMainWindowImpl()
00220  : KexiMainWindow()
00221  , KexiGUIMessageHandler(this)
00222  , d(new KexiMainWindowImpl::Private(this) )
00223 {
00224     KImageIO::registerFormats();
00225     KexiProjectData *pdata = Kexi::startupHandler().projectData();
00226     d->userMode = Kexi::startupHandler().forcedUserMode() /* <-- simply forced the user mode */
00227         /* project has 'user mode' set as default and not 'design mode' override is found: */
00228         || (pdata && pdata->userMode() && !Kexi::startupHandler().forcedDesignMode());
00229     d->isProjectNavigatorVisible = Kexi::startupHandler().isProjectNavigatorVisible();
00230 
00231     if(userMode())
00232         kdDebug() << "KexiMainWindowImpl::KexiMainWindowImpl(): starting up in the User Mode" << endl;
00233 
00234     d->config = kapp->config();
00235 
00236     if ( !initialGeometrySet() ) {
00237         int scnum = QApplication::desktop()->screenNumber(parentWidget());
00238         QRect desk = QApplication::desktop()->screenGeometry(scnum);
00239         d->config->setGroup("MainWindow");
00240         QSize s ( d->config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 700 ),
00241             d->config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 480 ) );
00242         resize (kMin (s.width(), desk.width()), kMin(s.height(), desk.height()));
00243     }
00244 
00245     setManagedDockPositionModeEnabled(true);//TODO(js): remove this if will be default in kmdi :)
00246     manager()->setSplitterHighResolution(true);
00247     manager()->setSplitterKeepSize(true);
00248     setStandardMDIMenuEnabled(false);
00249     setAsDefaultHost(); //this is default host now.
00250     KGlobal::iconLoader()->addAppDir("kexi");
00251     KGlobal::iconLoader()->addAppDir("koffice");
00252 
00253     //get informed
00254     connect(&Kexi::partManager(),SIGNAL(partLoaded(KexiPart::Part*)),this,SLOT(slotPartLoaded(KexiPart::Part*)));
00255     connect( m_pMdi, SIGNAL(nowMaximized(bool)), this, SLOT(slotCaptionForCurrentMDIChild(bool)) );
00256     connect( m_pMdi, SIGNAL(noMaximizedChildFrmLeft(KMdiChildFrm*)), this, SLOT(slotNoMaximizedChildFrmLeft(KMdiChildFrm*)));
00257 //  connect( this, SIGNAL(lastChildFrmClosed()), this, SLOT(slotLastChildFrmClosed()));
00258     connect( this, SIGNAL(lastChildViewClosed()), this, SLOT(slotLastChildViewClosed()));
00259 
00260     connect( this, SIGNAL(childViewIsDetachedNow(QWidget*)), this, SLOT(slotChildViewIsDetachedNow(QWidget*)));
00261     connect( this, SIGNAL(mdiModeHasBeenChangedTo(KMdi::MdiMode)),
00262         this, SLOT(slotMdiModeHasBeenChangedTo(KMdi::MdiMode)));
00263 
00264 
00265     //if (!userMode()) {
00266         setXMLFile("kexiui.rc");
00267         setAcceptDrops(true);
00268         initActions();
00269         createShellGUI(true);
00270     //}
00271 
00272     d->statusBar = new KexiStatusBar(this, "status_bar");
00273 
00274     d->origAppCaption = caption();
00275 
00276     restoreSettings();
00277     (void)Kexi::smallFont(this/*init*/);
00278 
00279     if (!userMode()) {
00280         initContextHelp();
00281         initPropertyEditor();
00282     }
00283 
00284     {//store menu popups list
00285         QObjectList *l = queryList( "QPopupMenu" );
00286         for (QObjectListIt it( *l ); it.current(); ++it ) {
00287             //kdDebug() << "name=" <<it.current()->name() << " cname="<<it.current()->className()<<endl;
00288             //KexiMainWindowImpl::eventFilter() will filter our popups:
00289             it.current()->installEventFilter(this);
00290             d->popups.insert(it.current()->name(), static_cast<QPopupMenu*>(it.current()));
00291         }
00292         delete l;
00293         d->createMenu = d->popups["create"];
00294 
00295 #ifdef KEXI_NO_REPORTBUG_COMMAND
00296         //remove "bug report" action to avoid confusion for supported with commercial technical support
00297         QPopupMenu *helpMenu = d->popups["help"];
00298         if (helpMenu) {
00299             //const int idx = helpMenu->indexOf( (int)KHelpMenu::menuReportBug );
00300             helpMenu->removeItemAt(int(KHelpMenu::menuReportBug)-1);
00301             helpMenu->removeItemAt(int(KHelpMenu::menuReportBug)-1); //separator
00302         }
00303 #endif
00304     }
00305 
00306     //fix menus a bit more:
00307 #ifndef KEXI_SHOW_UNIMPLEMENTED
00308 //disabled (possible crash) d->hideMenuItem("file", i18n("&Import"), true);
00309 //disabled (possible crash) d->hideMenuItem("help", i18n( "&Report Bug..." ), true);
00310 #endif
00311     KAction *kmdi_tooldock_menu_action = childClients()->getFirst() ? childClients()->getFirst()->actionCollection()->action("kmdi_tooldock_menu") : 0;
00312     if (kmdi_tooldock_menu_action) {
00313         kmdi_tooldock_menu_action->setEnabled(false);
00314     }
00315 
00316     if (!isFakingSDIApplication()/* && !userMode()*/) {
00317 //      QPopupMenu *menu = (QPopupMenu*) child( "window", "KPopupMenu" );
00318         QPopupMenu *menu = d->popups["window"];
00319         unsigned int count = menuBar()->count();
00320         if (menu)
00321             setWindowMenu(menu);
00322         else
00323             menuBar()->insertItem( i18n("&Window"), windowMenu(), -1, count-2); // standard position is left to the last ('Help')
00324     }
00325     if (userMode()) {
00326         //hide "insert" menu and disable "project_import", "edit_paste_special" menus
00327         QPopupMenu *menu = d->popups["insert"];
00328         if (menu) {
00329             for (uint i=0; i < menuBar()->count(); i++) {
00330                 if (menuBar()->text( menuBar()->idAt(i) ) == i18n("&Insert")) {
00331                     menuBar()->setItemVisible( menuBar()->idAt(i), false );
00332                     break;
00333                 }
00334             }
00335         }
00336         d->disableMenuItem("file", i18n("&Import"));
00337         d->disableMenuItem("edit", i18n("Paste &Special"));
00338     }
00339 
00340     m_pTaskBar->setCaption(i18n("Task Bar"));   //js TODO: move this to KMDIlib
00341 
00342 //  if (!userMode()) {
00343         invalidateActions();
00344         d->timer.singleShot(0,this,SLOT(slotLastActions()));
00345 //  }
00346 
00347     setTabWidgetVisibility(KMdi::AlwaysShowTabs);
00348     if (mdiMode()==KMdi::IDEAlMode) {
00349         d->config->setGroup("MainWindow");
00350         tabWidget()->setHoverCloseButton(d->config->readBoolEntry("HoverCloseButtonForTabs", false));
00351         //create special close button as corner widget for IDEAl mode
00352         QToolButton *closeButton = new QToolButton( tabWidget() );
00353         closeButton->setAutoRaise( true );
00354         closeButton->setPixmap( QPixmap( kde2_closebutton ) );
00355         closeButton->setPaletteBackgroundColor(closeButton->palette().active().background()); 
00356 //      closeButton->setIconSet(SmallIconSet("tab_remove"));
00357         tabWidget()->setCornerWidget( closeButton, Qt::TopRight );
00358         closeButton->hide(); // hide until it's needed to avoid problems in "user mode" 
00359                              // when initially the main window is empty
00360         QToolTip::add(closeButton, 
00361             i18n("Close the current tab page in Kexi tab interface", "Close the current tab"));
00362         QObject::connect( closeButton, SIGNAL( clicked() ), this, SLOT( closeActiveView() ) );
00363     }
00364 
00365 //  manager()->readConfig( d->config, "DockWindows" );
00366 }
00367 
00368 KexiMainWindowImpl::~KexiMainWindowImpl()
00369 {
00370     d->forceDialogClosing=true;
00371     closeProject();
00372     delete d;
00373 }
00374 
00375 KexiProject *KexiMainWindowImpl::project()
00376 {
00377     return d->prj;
00378 }
00379 
00380 void KexiMainWindowImpl::setWindowMenu(QPopupMenu *menu)
00381 {
00382     delete m_pWindowMenu;
00383     m_pWindowMenu = menu;
00384     int count = menuBar()->count();
00385     //try to move "window" menu just before "Settings" menu (count-3)
00386     const QString txt = i18n("&Window");
00387     int i;
00388     for (i=0; i<count; i++) {
00389         //kdDebug() << menuBar()->text( menuBar()->idAt(i) ) << endl;
00390         if (txt==menuBar()->text( menuBar()->idAt(i) ))
00391             break;
00392     }
00393     if (i<count) {
00394         const int id = menuBar()->idAt(i);
00395         menuBar()->removeItemAt(i);
00396         menuBar()->insertItem(txt, m_pWindowMenu, id, count-3);
00397     }
00398     m_pWindowMenu->setCheckable(true);
00399     QObject::connect( m_pWindowMenu, SIGNAL(aboutToShow()), this, SLOT(fillWindowMenu()) );
00400 }
00401 
00402 void KexiMainWindowImpl::fillWindowMenu()
00403 {
00404     KexiMainWindow::fillWindowMenu();
00405 
00406 /*  int i;
00407     for (i=0; i < (int)m_pWindowMenu->count(); i++) {
00408         if (m_pWindowMenu->text( m_pWindowMenu->idAt( i ) ) == i18n( "&MDI Mode" )) {
00409 //          kdDebug() << m_pWindowMenu->text( m_pWindowMenu->idAt( i ) ) << endl;
00410             m_pWindowMenu->removeItem( m_pWindowMenu->idAt( i ) );
00411             break;
00412         }
00413     }*/
00414 
00415     m_pMdiModeMenu->removeItem( m_pMdiModeMenu->idAt( 0 ) ); //hide toplevel mode
00416     m_pMdiModeMenu->removeItem( m_pMdiModeMenu->idAt( 1 ) ); //hide tabbed mode
00417     //update
00418     if (d->mdiModeToSwitchAfterRestart != (KMdi::MdiMode)0) {
00419         m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 0 ), 
00420             d->mdiModeToSwitchAfterRestart == KMdi::ChildframeMode );
00421         m_pMdiModeMenu->setItemChecked( m_pMdiModeMenu->idAt( 1 ), 
00422             d->mdiModeToSwitchAfterRestart == KMdi::IDEAlMode );
00423     }
00424 
00425     //insert window_next, window_previous actions:
00426 //  const QString t = i18n("&Dock/Undock...");
00427     int i = m_pWindowMenu->count()-1;
00428     for (int index;; i--) {
00429         index = m_pWindowMenu->idAt(i);
00430         if (index==-1 || m_pWindowMenu->text(index).isNull())
00431                 break;
00432     }
00433     i++;
00434     d->action_window_next->plug( m_pWindowMenu, i++ );
00435     d->action_window_previous->plug( m_pWindowMenu, i++ );
00436     if (!m_pDocumentViews->isEmpty())
00437         m_pWindowMenu->insertSeparator( i++ );
00438 }
00439 
00440 void KexiMainWindowImpl::switchToIDEAlMode()
00441 {
00442     switchToIDEAlMode(true);
00443 }
00444 
00445 void KexiMainWindowImpl::switchToIDEAlMode(bool showMessage)
00446 {
00447     if (showMessage) {
00448         if ((int)d->mdiModeToSwitchAfterRestart == 0 && mdiMode()==KMdi::IDEAlMode)
00449             return;
00450         if (d->mdiModeToSwitchAfterRestart == KMdi::IDEAlMode)
00451             return;
00452         if (mdiMode()==KMdi::IDEAlMode) {//current mode
00453             d->mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
00454         }
00455         else {
00456             KMessageBox::information(this,
00457                 i18n("User interface mode will be switched to IDEAl at next %1 application startup.")
00458                 .arg(KEXI_APP_NAME));
00459             //delayed
00460             d->mdiModeToSwitchAfterRestart = KMdi::IDEAlMode;
00461         }
00462     }
00463     else
00464         KexiMainWindow::switchToIDEAlMode();
00465 }
00466 
00467 void KexiMainWindowImpl::switchToChildframeMode()
00468 {
00469     switchToChildframeMode(true);
00470 }
00471 
00472 void KexiMainWindowImpl::switchToChildframeMode(bool showMessage)
00473 {
00474     if (showMessage) {
00475         if ((int)d->mdiModeToSwitchAfterRestart == 0 && mdiMode()==KMdi::ChildframeMode)
00476             return;
00477         if (d->mdiModeToSwitchAfterRestart == KMdi::ChildframeMode)
00478             return;
00479         if (mdiMode()==KMdi::ChildframeMode) {//current mode
00480             d->mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
00481         }
00482         else {
00483             KMessageBox::information(this,
00484                 i18n("User interface mode will be switched to Childframe at next %1 application startup.")
00485                 .arg(KEXI_APP_NAME));
00486             //delayed
00487             d->mdiModeToSwitchAfterRestart = KMdi::ChildframeMode;
00488         }
00489     }
00490     else
00491         KexiMainWindow::switchToChildframeMode();
00492 }
00493 
00494 QPopupMenu* KexiMainWindowImpl::findPopupMenu(const char *popupName)
00495 {
00496     return d->popups[popupName];
00497 }
00498 
00499 KActionPtrList KexiMainWindowImpl::allActions() const
00500 {
00501     return actionCollection()->actions();
00502 }
00503 
00504 KexiDialogBase* KexiMainWindowImpl::currentDialog() const
00505 {
00506     return d->curDialog;
00507 }
00508 
00509 void KexiMainWindowImpl::initActions()
00510 {
00511 //  setupGUI(KMainWindow::Keys|KMainWindow::StatusBar|KMainWindow::Save|KMainWindow::Create);
00512 
00513 //  d->actionMapper = new QSignalMapper(this, "act_map");
00514 //  connect(d->actionMapper, SIGNAL(mapped(const QString &)), this, SLOT(slotAction(const QString &)));
00515 
00516     // PROJECT MENU
00517     KAction *action = new KAction(i18n("&New..."), "filenew", KStdAccel::shortcut(KStdAccel::New),
00518         this, SLOT(slotProjectNew()), actionCollection(), "project_new");
00519     action->setToolTip(i18n("Create a new project"));
00520     action->setWhatsThis(i18n("Creates a new project. Currently opened project is not affected."));
00521 
00522     action = KStdAction::open( this, SLOT( slotProjectOpen() ), actionCollection(), "project_open" );
00523     action->setToolTip(i18n("Open an existing project"));
00524     action->setWhatsThis(i18n("Opens an existing project. Currently opened project is not affected."));
00525 
00526 #ifdef HAVE_KNEWSTUFF
00527     action = new KAction(i18n("&Download Example Databases..."), "kget", KShortcut(0),
00528         this, SLOT(slotGetNewStuff()), actionCollection(), "project_download_examples");
00529     action->setToolTip(i18n("Download example databases from the Internet"));
00530     action->setWhatsThis(i18n("Downloads example databases from the Internet."));
00531 #endif
00532 
00533 //  d->action_open_recent = KStdAction::openRecent( this, SLOT(slotProjectOpenRecent(const KURL&)), actionCollection(), "project_open_recent" );
00534 
00535 //#ifdef KEXI_SHOW_UNIMPLEMENTED
00536 #ifndef KEXI_NO_UNFINISHED
00537     d->action_open_recent = new KActionMenu(i18n("Open Recent"),
00538         actionCollection(), "project_open_recent");
00539     connect(d->action_open_recent->popupMenu(),SIGNAL(activated(int)),
00540         this,SLOT(slotProjectOpenRecent(int)));
00541     connect(d->action_open_recent->popupMenu(), SIGNAL(aboutToShow()),
00542         this,SLOT(slotProjectOpenRecentAboutToShow()));
00543 //moved down        d->action_open_recent_projects_title_id = 
00544 //      d->action_open_recent->popupMenu()->insertTitle(i18n("Recently Opened Databases"));
00545 //moved down    d->action_open_recent_connections_title_id = 
00546 //      d->action_open_recent->popupMenu()->insertTitle(i18n("Recently Connected Database Servers"));
00547 //  d->action_open_recent->popupMenu()->insertSeparator();
00548 //  d->action_open_recent_more_id = d->action_open_recent->popupMenu()
00549 //      ->insertItem(i18n("&More Projects..."), this, SLOT(slotProjectOpenRecentMore()), 0, 1000);
00550 #else
00551     d->action_open_recent = d->dummy_action;
00552 #endif
00553 
00554     d->action_save = KStdAction::save( 
00555         this, SLOT( slotProjectSave() ), actionCollection(), "project_save" );
00556 //  d->action_save = new KAction(i18n("&Save"), "filesave", KStdAccel::shortcut(KStdAccel::Save),
00557 //      this, SLOT(slotProjectSave()), actionCollection(), "project_save");
00558     d->action_save->setToolTip(i18n("Save object changes"));
00559     d->action_save->setWhatsThis(i18n("Saves object changes from currently selected window."));
00560 
00561 #ifdef KEXI_SHOW_UNIMPLEMENTED
00562     d->action_save_as = new KAction(i18n("Save &As..."), "filesaveas", 0,
00563         this, SLOT(slotProjectSaveAs()), actionCollection(), "project_saveas");
00564     d->action_save_as->setToolTip(i18n("Save object as"));
00565     d->action_save_as->setWhatsThis(
00566         i18n("Saves object changes from currently selected window under a new name (within the same project)."));
00567 
00568     d->action_project_properties = new KAction(i18n("Project Properties"), "info", 0,
00569         this, SLOT(slotProjectProperties()), actionCollection(), "project_properties");
00570 #else
00571     d->action_save_as = d->dummy_action;
00572     d->action_project_properties = d->dummy_action;
00573 #endif
00574 
00575     d->action_close = new KAction(i18n("&Close Project"), "fileclose", 0,
00576         this, SLOT(slotProjectClose()), actionCollection(), "project_close" );
00577     d->action_close->setToolTip(i18n("Close the current project"));
00578     d->action_close->setWhatsThis(i18n("Closes the current project."));
00579 
00580     KStdAction::quit( this, SLOT(slotProjectQuit()), actionCollection(), "quit");
00581 
00582 #ifdef KEXI_SHOW_UNIMPLEMENTED
00583     d->action_project_relations = new KAction(i18n("&Relationships..."), "relation", Qt::CTRL + Qt::Key_R,
00584         this, SLOT(slotProjectRelations()), actionCollection(), "project_relations");
00585     d->action_project_relations->setToolTip(i18n("Project relationships"));
00586     d->action_project_relations->setWhatsThis(i18n("Shows project relationships."));
00587 
00588 #else
00589     d->action_project_relations = d->dummy_action;
00590 #endif
00591     d->action_tools_data_migration = new KAction(
00592         i18n("&Import Database..."), "database_import", 0,
00593         this, SLOT(slotToolsProjectMigration()), actionCollection(), "tools_import_project");
00594     d->action_tools_data_migration->setToolTip(i18n("Import entire database as a Kexi project"));
00595     d->action_tools_data_migration->setWhatsThis(i18n("Imports entire database as a Kexi project."));
00596 
00597     d->action_tools_compact_database = new KAction(
00598         i18n("&Compact Database..."), "", 0,
00599         this, SLOT(slotToolsCompactDatabase()), actionCollection(), "tools_compact_database");
00600     d->action_tools_compact_database->setToolTip(i18n("Compact the current database project"));
00601     d->action_tools_compact_database->setWhatsThis(
00602         i18n("Compacts the current database project, so it will take less space and work faster."));
00603 
00604     if (userMode())
00605         d->action_project_import_data_table = 0;
00606     else {
00607         d->action_project_import_data_table = new KAction(
00608             i18n("Import->Table Data From File...", "Table Data From &File..."),
00609             "table",
00610             0, this, SLOT(slotProjectImportDataTable()), actionCollection(), 
00611             "project_import_data_table");
00612         d->action_project_import_data_table->setToolTip(i18n("Import table data from a file"));
00613         d->action_project_import_data_table->setWhatsThis(i18n("Imports table data from a file."));
00614     }
00615 
00616     d->action_project_export_data_table = new KAction(i18n("Export->Table or Query Data to File...", 
00617         "Table or Query Data to &File..."),
00618         "table",
00619         0, this, SLOT(slotProjectExportDataTable()), actionCollection(), 
00620         "project_export_data_table");
00621     d->action_project_export_data_table->setToolTip(
00622         i18n("Export data from the active table or query data to a file"));
00623     d->action_project_export_data_table->setWhatsThis(
00624         i18n("Exports data from the active table or query data to a file."));
00625 
00626 //TODO  new KAction(i18n("From File..."), "fileopen", 0,
00627 //TODO      this, SLOT(slotImportFile()), actionCollection(), "project_import_file");
00628 //TODO  new KAction(i18n("From Server..."), "server", 0,
00629 //TODO      this, SLOT(slotImportServer()), actionCollection(), "project_import_server");
00630 
00631     d->action_project_print = KStdAction::print(this, SLOT(slotProjectPrint()),
00632         actionCollection(), "project_print" ); 
00633     d->action_project_print->setToolTip(i18n("Print data from the active table or query"));
00634     d->action_project_print->setWhatsThis(i18n("Prints data from the active table or query."));
00635 
00636     d->action_project_print_preview = KStdAction::printPreview(
00637         this, SLOT(slotProjectPrintPreview()),
00638         actionCollection(), "project_print_preview" ); 
00639     d->action_project_print_preview->setToolTip(
00640         i18n("Show print preview for the active table or query"));
00641     d->action_project_print_preview->setWhatsThis(
00642         i18n("Shows print preview for the active table or query."));
00643 
00644     d->action_project_print_setup = new KAction(i18n("Page Set&up..."),
00645         "", 0, this, SLOT(slotProjectPageSetup()), actionCollection(), 
00646         "project_print_setup");
00647     d->action_project_print_setup->setToolTip(
00648         i18n("Show page setup for printing the active table or query"));
00649     d->action_project_print_setup->setWhatsThis(
00650         i18n("Shows page setup for printing the active table or query."));
00651 
00652     //EDIT MENU
00653     d->action_edit_cut = createSharedAction( KStdAction::Cut, "edit_cut");
00654     d->action_edit_copy = createSharedAction( KStdAction::Copy, "edit_copy");
00655     d->action_edit_paste = createSharedAction( KStdAction::Paste, "edit_paste");
00656 
00657     if (userMode())
00658         d->action_edit_paste_special_data_table = 0;
00659     else {
00660         d->action_edit_paste_special_data_table = 
00661             new KAction(i18n("Paste Special->As Data &Table...", "As Data &Table..."),
00662             "table", 0, this, SLOT(slotEditPasteSpecialDataTable()),
00663             actionCollection(), "edit_paste_special_data_table");
00664         d->action_edit_paste_special_data_table->setToolTip(
00665             i18n("Paste clipboard data as a table"));
00666         d->action_edit_paste_special_data_table->setWhatsThis(
00667             i18n("Pastes clipboard data to a table."));
00668     }
00669 
00670     d->action_edit_copy_special_data_table =
00671         new KAction(i18n("Copy Special->Table or Query Data...", 
00672             "Table or Query as Data Table..."),
00673         "table", 0, this, SLOT(slotEditCopySpecialDataTable()),
00674         actionCollection(), "edit_copy_special_data_table");
00675     d->action_edit_copy_special_data_table->setToolTip(
00676         i18n("Copy selected table or query data to clipboard"));
00677     d->action_edit_copy_special_data_table->setWhatsThis(
00678         i18n("Copies selected table or query data to clipboard."));
00679 
00680     d->action_edit_undo = createSharedAction( KStdAction::Undo, "edit_undo");
00681     d->action_edit_undo->setWhatsThis(i18n("Reverts the most recent editing action."));
00682     d->action_edit_redo = createSharedAction( KStdAction::Redo, "edit_redo");
00683     d->action_edit_redo->setWhatsThis(i18n("Reverts the most recent undo action."));
00684 
00685     d->action_edit_select_all =  createSharedAction( KStdAction::SelectAll, "edit_select_all");
00686 
00687     d->action_edit_delete = createSharedAction(i18n("&Delete"), "editdelete",
00688         0/*Qt::Key_Delete*/, "edit_delete");
00689     d->action_edit_delete->setToolTip(i18n("Delete selected object"));
00690     d->action_edit_delete->setWhatsThis(i18n("Deletes currently selected object."));
00691 
00692     d->action_edit_delete_row = createSharedAction(i18n("Delete Row"), "delete_table_row",
00693         Qt::CTRL+Qt::Key_Delete, "edit_delete_row");
00694     d->action_edit_delete_row->setToolTip(i18n("Delete currently selected row"));
00695     d->action_edit_delete_row->setWhatsThis(i18n("Deletes currently selected row."));
00696 
00697     d->action_edit_clear_table = createSharedAction(i18n("Clear Table Contents"), "clear_table_contents",
00698         0, "edit_clear_table");
00699     d->action_edit_clear_table->setToolTip(i18n("Clear table contents"));
00700     d->action_edit_clear_table->setWhatsThis(i18n("Clears table contents."));
00701     setActionVolatile( d->action_edit_clear_table, true );
00702 
00703     d->action_edit_edititem = createSharedAction(i18n("Edit Item"), 0, 0, /* CONFLICT in TV: Qt::Key_F2,  */
00704         "edit_edititem");
00705     d->action_edit_edititem->setToolTip(i18n("Edit currently selected item"));
00706     d->action_edit_edititem->setWhatsThis(i18n("Edits currently selected item."));
00707 
00708     d->action_edit_insert_empty_row = createSharedAction(i18n("&Insert Empty Row"), "insert_table_row", 
00709         Qt::SHIFT | Qt::CTRL | Qt::Key_Insert, "edit_insert_empty_row");
00710     setActionVolatile( d->action_edit_insert_empty_row, true );
00711     d->action_edit_insert_empty_row->setToolTip(i18n("Insert one empty row above"));
00712     d->action_edit_insert_empty_row->setWhatsThis(i18n("Inserts one empty row above currently selected table row."));
00713 
00714     //VIEW MENU
00715     if (!userMode()) {
00716         d->action_view_data_mode = new KRadioAction(i18n("&Data View"), "state_data", Qt::Key_F6,
00717             this, SLOT(slotViewDataMode()), actionCollection(), "view_data_mode");
00718         d->actions_for_view_modes.insert( Kexi::DataViewMode, d->action_view_data_mode );
00719         d->action_view_data_mode->setExclusiveGroup("view_mode");
00720         d->action_view_data_mode->setToolTip(i18n("Switch to data view"));
00721         d->action_view_data_mode->setWhatsThis(i18n("Switches to data view."));
00722     }
00723     else
00724         d->action_view_data_mode = 0;
00725 
00726     if (!userMode()) {
00727         d->action_view_design_mode = new KRadioAction(i18n("D&esign View"), "state_edit", Qt::Key_F7,
00728             this, SLOT(slotViewDesignMode()), actionCollection(), "view_design_mode");
00729         d->actions_for_view_modes.insert( Kexi::DesignViewMode, d->action_view_design_mode );
00730         d->action_view_design_mode->setExclusiveGroup("view_mode");
00731         d->action_view_design_mode->setToolTip(i18n("Switch to design view"));
00732         d->action_view_design_mode->setWhatsThis(i18n("Switches to design view."));
00733     }
00734     else
00735         d->action_view_design_mode = 0;
00736 
00737     if (!userMode()) {
00738         d->action_view_text_mode = new KRadioAction(i18n("&Text View"), "state_sql", Qt::Key_F8,
00739             this, SLOT(slotViewTextMode()), actionCollection(), "view_text_mode");
00740         d->actions_for_view_modes.insert( Kexi::TextViewMode, d->action_view_text_mode );
00741         d->action_view_text_mode->setExclusiveGroup("view_mode");
00742         d->action_view_text_mode->setToolTip(i18n("Switch to text view"));
00743         d->action_view_text_mode->setWhatsThis(i18n("Switches to text view."));
00744     }
00745     else
00746         d->action_view_text_mode = 0;
00747 
00748     if (d->isProjectNavigatorVisible) {
00749         d->action_view_nav = new KAction(i18n("Project Navigator"), "", Qt::ALT + Qt::Key_1,
00750             this, SLOT(slotViewNavigator()), actionCollection(), "view_navigator");
00751         d->action_view_nav->setToolTip(i18n("Go to project navigator panel"));
00752         d->action_view_nav->setWhatsThis(i18n("Goes to project navigator panel."));
00753     }
00754     else
00755         d->action_view_nav = 0;
00756 
00757     d->action_view_mainarea = new KAction(i18n("Main Area"), "", Qt::ALT + Qt::Key_2,
00758         this, SLOT(slotViewMainArea()), actionCollection(), "view_mainarea");
00759     d->action_view_mainarea->setToolTip(i18n("Go to main area"));
00760     d->action_view_mainarea->setWhatsThis(i18n("Goes to main area."));
00761 
00762     if (!userMode()) {
00763         d->action_view_propeditor = new KAction(i18n("Property Editor"), "", Qt::ALT + Qt::Key_3,
00764             this, SLOT(slotViewPropertyEditor()), actionCollection(), "view_propeditor");
00765         d->action_view_propeditor->setToolTip(i18n("Go to property editor panel"));
00766         d->action_view_propeditor->setWhatsThis(i18n("Goes to property editor panel."));
00767     }
00768     else
00769         d->action_view_propeditor = 0;
00770 
00771     //DATA MENU
00772     d->action_data_save_row = createSharedAction(i18n("&Save Row"), "button_ok", 
00773         Qt::SHIFT | Qt::Key_Return, "data_save_row");
00774     d->action_data_save_row->setToolTip(i18n("Save changes made to the current row"));
00775     d->action_data_save_row->setWhatsThis(i18n("Saves changes made to the current row."));
00776 //temp. disable because of problems with volatile actions   setActionVolatile( d->action_data_save_row, true );
00777 
00778     d->action_data_cancel_row_changes = createSharedAction(i18n("&Cancel Row Changes"), 
00779         "button_cancel", 0 , "data_cancel_row_changes");
00780     d->action_data_cancel_row_changes->setToolTip(i18n("Cancel changes made to the current row"));
00781     d->action_data_cancel_row_changes->setWhatsThis(i18n("Cancels changes made to the current row."));
00782 //temp. disable because of problems with volatile actions   setActionVolatile( d->action_data_cancel_row_changes, true );
00783 
00784     d->action_data_execute = createSharedAction(i18n("&Execute"), "player_play", 0 , "data_execute");
00785     //d->action_data_execute->setToolTip(i18n("")); //TODO
00786     //d->action_data_execute->setWhatsThis(i18n("")); //TODO
00787 
00788 #ifndef KEXI_NO_UNFINISHED
00789     action = createSharedAction(i18n("&Filter"), "filter", 0, "data_filter");
00790     setActionVolatile( action, true );
00791 #endif
00792 //  action->setToolTip(i18n("")); //todo
00793 //  action->setWhatsThis(i18n("")); //todo
00794 
00795 //  setSharedMenu("data_sort");
00796     action = createSharedAction(i18n("&Ascending"), "sort_az", 0, "data_sort_az");
00797 //temp. disable because of problems with volatile actions   setActionVolatile( action, true );
00798     action->setToolTip(i18n("Sort data in ascending order"));
00799     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."));
00800 
00801     action = createSharedAction(i18n("&Descending"), "sort_za", 0, "data_sort_za");
00802 //temp. disable because of problems with volatile actions   setActionVolatile( action, true );
00803     action->setToolTip(i18n("Sort data in descending order"));
00804     action->setWhatsThis(i18n("Sorts data in descending (from Z to A and from 9 to 0). Data from selected column is used for sorting."));
00805 
00806     // - record-navigation related actions
00807     createSharedAction( KexiRecordNavigator::Actions::moveToFirstRecord(), 0, "data_go_to_first_record");
00808     createSharedAction( KexiRecordNavigator::Actions::moveToPreviousRecord(), 0, "data_go_to_previous_record");
00809     createSharedAction( KexiRecordNavigator::Actions::moveToNextRecord(), 0, "data_go_to_next_record");
00810     createSharedAction( KexiRecordNavigator::Actions::moveToLastRecord(), 0, "data_go_to_last_record");
00811     createSharedAction( KexiRecordNavigator::Actions::moveToNewRecord(), 0, "data_go_to_new_record");
00812 
00813     //FORMAT MENU
00814     d->action_format_font = createSharedAction(i18n("&Font..."), "fonts", 0, "format_font");
00815     d->action_format_font->setToolTip(i18n("Change font for selected object"));
00816     d->action_format_font->setWhatsThis(i18n("Changes font for selected object."));
00817 
00818     //TOOLS MENU
00819 
00820     //WINDOW MENU
00821 #ifndef Q_WS_WIN
00822     //KMDI <= 3.5.1 has no shortcut here:
00823     KAction *closeWindowAction = actionCollection()->action("window_close");
00824     if (closeWindowAction)
00825         closeWindowAction->setShortcut(KStdAccel::close());
00826 #endif
00827 
00828     //additional 'Window' menu items
00829     d->action_window_next = new KAction( i18n("&Next Window"), "",
00830 #ifdef Q_WS_WIN
00831         Qt::CTRL+Qt::Key_Tab,
00832 #else
00833         Qt::ALT+Qt::Key_Right,
00834 #endif
00835         this, SLOT(activateNextWin()), actionCollection(), "window_next");
00836     d->action_window_next->setToolTip( i18n("Next window") );
00837     d->action_window_next->setWhatsThis(i18n("Switches to the next window."));
00838 
00839     d->action_window_previous = new KAction( i18n("&Previous Window"), "",
00840 #ifdef Q_WS_WIN
00841         Qt::CTRL+Qt::SHIFT+Qt::Key_Tab,
00842 #else
00843         Qt::ALT+Qt::Key_Left,
00844 #endif
00845         this, SLOT(activatePrevWin()), actionCollection(), "window_previous");
00846     d->action_window_previous->setToolTip( i18n("Previous window") );
00847     d->action_window_previous->setWhatsThis(i18n("Switches to the previous window."));
00848 
00849     //SETTINGS MENU
00850     setStandardToolBarMenuEnabled( true );
00851     action = KStdAction::keyBindings(this, SLOT( slotConfigureKeys() ), actionCollection() );
00852     action->setWhatsThis(i18n("Lets you configure shortcut keys."));
00853 
00854 #ifdef KEXI_SHOW_UNIMPLEMENTED
00855     action = KStdAction::configureToolbars( this, SLOT( slotConfigureToolbars() ), actionCollection() );
00856     action->setWhatsThis(i18n("Lets you configure toolbars."));
00857 
00858     d->action_show_other = new KActionMenu(i18n("Other"),
00859         actionCollection(), "options_show_other");
00860 #endif
00861 
00862 #ifndef KEXI_NO_CTXT_HELP
00863     d->action_show_helper = new KToggleAction(i18n("Show Context Help"), "", Qt::CTRL + Qt::Key_H,
00864      actionCollection(), "options_show_contexthelp");
00865 #if KDE_IS_VERSION(3,2,90)
00866     d->action_show_helper->setCheckedState(i18n("Hide Context Help"));
00867 #endif
00868 #endif
00869 
00870 #ifdef KEXI_FORMS_SUPPORT
00871     slotOptionsEnableForms(true, true);
00872 #else
00873     slotOptionsEnableForms(false, true);
00874 #endif
00875 
00876 #ifdef KEXI_REPORTS_SUPPORT
00877     Kexi::tempShowReports() = true;
00878 #else
00879     Kexi::tempShowReports() = false;
00880 #endif
00881 
00882 #ifdef KEXI_MACROS_SUPPORT
00883     Kexi::tempShowMacros() = true;
00884 #else
00885     Kexi::tempShowMacros() = false;
00886 #endif
00887 
00888 #ifdef KEXI_SCRIPTS_SUPPORT
00889     Kexi::tempShowScripts() = true;
00890 #else
00891     Kexi::tempShowScripts() = false;
00892 #endif
00893 
00894 #ifdef KEXI_SHOW_UNIMPLEMENTED
00895     d->action_configure = KStdAction::preferences(this, SLOT(slotShowSettings()), actionCollection());
00896     action->setWhatsThis(i18n("Lets you configure Kexi."));
00897 #endif
00898 
00899     //HELP MENU
00900 #if 0//js: todo reenable later
00901     KStdAction::tipOfDay( this, SLOT( slotTipOfTheDayAction() ), actionCollection() )
00902         ->setWhatsThis(i18n("This shows useful tips on the use of this application."));
00903 #endif
00904 #if 0 //we don't have a time for updating info text for each new version
00905     new KAction(i18n("Important Information"), "messagebox_info", 0,
00906         this, SLOT(slotImportantInfo()), actionCollection(), "help_show_important_info");
00907 #endif
00908 //TODO: UNCOMMENT TO REMOVE MDI MODES SETTING   m_pMdiModeMenu->hide();
00909 
00910 #ifndef KEXI_NO_FEEDBACK_AGENT
00911 #ifdef FEEDBACK_CLASS
00912     new KAction(i18n("Give Feedback..."), "messagebox_info", 0,
00913         this, SLOT(slotStartFeedbackAgent()), actionCollection(), "help_start_feedback_agent");
00914 #endif
00915 #endif
00916 //  KAction *actionSettings = new KAction(i18n("Configure Kexi..."), "configure", 0,
00917 //   actionCollection(), "kexi_settings");
00918 //  actionSettings->setWhatsThis(i18n("Lets you configure Kexi."));
00919 //  connect(actionSettings, SIGNAL(activated()), this, SLOT(slotShowSettings()));
00920 
00921     // -- add a few missing tooltips (usable especially in Form's "Assign action" dialog)
00922     if ((action = actionCollection()->action("window_close")))
00923 <<<<<<< .mine
00924         action->setToolTip(futureI18n("Close the current window"));
00925 =======
00926         action->setToolTip(i18n("Close the current window"));
00927 >>>>>>> .r626454
00928 
00929     // ----- declare action categories, so form's "assign action to button"
00930     //       (and macros in the future) will be able to recognize category 
00931     //       of actions and filter them -----------------------------------
00933     Kexi::ActionCategories *acat = Kexi::actionCategories();
00934     acat->addAction("data_execute", Kexi::PartItemActionCategory);
00935 
00937     acat->addWindowAction("data_filter",
00938         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
00939 
00940     acat->addWindowAction("data_save_row",
00941         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
00942 
00943     acat->addWindowAction("data_cancel_row_changes",
00944         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
00945 
00946     acat->addWindowAction("delete_table_row",
00947         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
00948 
00950     acat->addWindowAction("data_sort_az",
00951         KexiPart::TableObjectType, KexiPart::QueryObjectType);
00952 
00954     acat->addWindowAction("data_sort_za",
00955         KexiPart::TableObjectType, KexiPart::QueryObjectType);
00956 
00958     acat->addWindowAction("edit_clear_table",
00959         KexiPart::TableObjectType, KexiPart::QueryObjectType);
00960 
00962     acat->addWindowAction("edit_copy_special_data_table", 
00963         KexiPart::TableObjectType, KexiPart::QueryObjectType);
00964 
00965     // GlobalActions, etc.
00966     acat->addAction("edit_copy", Kexi::GlobalActionCategory|Kexi::PartItemActionCategory);
00967 
00968     acat->addAction("edit_cut", Kexi::GlobalActionCategory|Kexi::PartItemActionCategory);
00969 
00970     acat->addAction("edit_paste", Kexi::GlobalActionCategory|Kexi::PartItemActionCategory);
00971 
00972     acat->addAction("edit_delete", Kexi::GlobalActionCategory|Kexi::PartItemActionCategory|Kexi::WindowActionCategory,
00973         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
00974 
00975     acat->addAction("edit_delete_row", Kexi::GlobalActionCategory|Kexi::WindowActionCategory,
00976         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
00977 
00978     acat->addAction("edit_edititem", Kexi::PartItemActionCategory|Kexi::WindowActionCategory,
00979         KexiPart::TableObjectType, KexiPart::QueryObjectType);
00980 
00981     acat->addAction("edit_paste_special_data_table", Kexi::GlobalActionCategory);
00982 
00983     acat->addAction("help_about_app", Kexi::GlobalActionCategory);
00984 
00985     acat->addAction("help_about_kde", Kexi::GlobalActionCategory);
00986 
00987     acat->addAction("help_contents", Kexi::GlobalActionCategory);
00988 
00989     acat->addAction("help_report_bug", Kexi::GlobalActionCategory);
00990 
00991     acat->addAction("help_whats_this", Kexi::GlobalActionCategory);
00992 
00993     acat->addAction("options_configure_keybinding", Kexi::GlobalActionCategory);
00994 
00995     acat->addAction("project_close", Kexi::GlobalActionCategory);
00996 
00998     acat->addAction("project_export_data_table", Kexi::GlobalActionCategory|Kexi::WindowActionCategory,
00999         KexiPart::TableObjectType, KexiPart::QueryObjectType);
01000 
01001     acat->addAction("project_import_data_table", Kexi::GlobalActionCategory);
01002 
01003     acat->addAction("project_new", Kexi::GlobalActionCategory);
01004 
01005     acat->addAction("project_open", Kexi::GlobalActionCategory);
01006 
01008     acat->addAction("project_print", Kexi::WindowActionCategory,
01009         KexiPart::TableObjectType, KexiPart::QueryObjectType);
01010 
01012     acat->addAction("project_print_preview", Kexi::WindowActionCategory,
01013         KexiPart::TableObjectType, KexiPart::QueryObjectType);
01014 
01016     acat->addAction("project_print_setup", Kexi::WindowActionCategory,
01017         KexiPart::TableObjectType, KexiPart::QueryObjectType);
01018 
01019     acat->addAction("quit", Kexi::GlobalActionCategory);
01020 
01021     acat->addAction("tools_compact_database", Kexi::GlobalActionCategory);
01022 
01023     acat->addAction("tools_import_project", Kexi::GlobalActionCategory);
01024 
01025     acat->addAction("view_data_mode", Kexi::GlobalActionCategory);
01026 
01027     acat->addAction("view_design_mode", Kexi::GlobalActionCategory);
01028 
01029     acat->addAction("view_text_mode", Kexi::GlobalActionCategory);
01030 
01031     acat->addAction("view_mainarea", Kexi::GlobalActionCategory);
01032 
01033     acat->addAction("view_navigator", Kexi::GlobalActionCategory);
01034 
01035     acat->addAction("view_propeditor", Kexi::GlobalActionCategory);
01036 
01037     acat->addAction("window_close", Kexi::GlobalActionCategory | Kexi::WindowActionCategory);
01038     acat->setAllObjectTypesSupported("window_close", true);
01039 
01040     acat->addAction("window_next", Kexi::GlobalActionCategory);
01041 
01042     acat->addAction("window_previous", Kexi::GlobalActionCategory);
01043 
01044     //skipped - design view only
01045     acat->addAction("format_font", Kexi::NoActionCategory);
01046     acat->addAction("project_save", Kexi::NoActionCategory);
01047     acat->addAction("edit_insert_empty_row", Kexi::NoActionCategory);
01049     acat->addAction("edit_select_all", Kexi::NoActionCategory);
01051     acat->addAction("edit_redo", Kexi::NoActionCategory);
01053     acat->addAction("edit_undo", Kexi::NoActionCategory);
01054 
01055     //record-navigation related actions
01056     acat->addAction("data_go_to_first_record", Kexi::WindowActionCategory,
01057         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
01058     acat->addAction("data_go_to_previous_record", Kexi::WindowActionCategory,
01059         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
01060     acat->addAction("data_go_to_next_record", Kexi::WindowActionCategory,
01061         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
01062     acat->addAction("data_go_to_last_record", Kexi::WindowActionCategory,
01063         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
01064     acat->addAction("data_go_to_new_record", Kexi::WindowActionCategory,
01065         KexiPart::TableObjectType, KexiPart::QueryObjectType, KexiPart::FormObjectType);
01066 
01067     //skipped - internal: 
01068     acat->addAction("tablepart_create", Kexi::NoActionCategory);
01069     acat->addAction("querypart_create", Kexi::NoActionCategory);
01070     acat->addAction("formpart_create", Kexi::NoActionCategory);
01071     acat->addAction("reportpart_create", Kexi::NoActionCategory);
01072     acat->addAction("macropart_create", Kexi::NoActionCategory);
01073     acat->addAction("scriptpart_create", Kexi::NoActionCategory);
01074 }
01075 
01076 void KexiMainWindowImpl::invalidateActions()
01077 {
01078     invalidateProjectWideActions();
01079     invalidateSharedActions();
01080 }
01081 
01082 void KexiMainWindowImpl::invalidateSharedActions(QObject *o)
01083 {
01084     //TODO: enabling is more complex...
01085 /*  d->action_edit_cut->setEnabled(true);
01086     d->action_edit_copy->setEnabled(true);
01087     d->action_edit_paste->setEnabled(true);*/
01088 
01089     if (!o)
01090         o = focusWindow();
01091     KexiSharedActionHost::invalidateSharedActions(o);
01092 }
01093 
01094 void KexiMainWindowImpl::invalidateSharedActions()
01095 {
01096     invalidateSharedActions(0);
01097 }
01098 
01099 // unused, I think
01100 void KexiMainWindowImpl::invalidateSharedActionsLater()
01101 {
01102     QTimer::singleShot(1, this, SLOT(invalidateSharedActions()));
01103 }
01104 
01105 void KexiMainWindowImpl::invalidateProjectWideActions()
01106 {
01107 //  stateChanged("project_opened",d->prj ? StateNoReverse : StateReverse);
01108 
01109     const bool have_dialog = d->curDialog;
01110     const bool dialog_dirty = d->curDialog && d->curDialog->dirty();
01111     const bool readOnly = d->prj && d->prj->dbConnection() && d->prj->dbConnection()->isReadOnly();
01112 
01113     //PROJECT MENU
01114     d->action_save->setEnabled(have_dialog && dialog_dirty && !readOnly);
01115     d->action_save_as->setEnabled(have_dialog && !readOnly);
01116     d->action_project_properties->setEnabled(d->prj);
01117     d->action_close->setEnabled(d->prj);
01118     d->action_project_relations->setEnabled(d->prj);
01119     if (d->action_project_import_data_table)
01120         d->action_project_import_data_table->setEnabled(d->prj && !readOnly);
01121     d->action_project_export_data_table->setEnabled( 
01122         d->curDialog && d->curDialog->part()->info()->isDataExportSupported() 
01123         && !d->curDialog->neverSaved() );
01124 
01125     const bool printingActionsEnabled = 
01126         d->curDialog && d->curDialog->part()->info()->isPrintingSupported()
01127         && !d->curDialog->neverSaved();
01128     d->action_project_print->setEnabled( printingActionsEnabled );
01129     d->action_project_print_preview->setEnabled( printingActionsEnabled );
01130     d->action_project_print_setup->setEnabled( printingActionsEnabled );
01131 
01132     //EDIT MENU
01133 
01134     if (d->action_edit_paste_special_data_table)
01135         d->action_edit_paste_special_data_table->setEnabled(d->prj && !readOnly);
01136 
01139     if (d->curDialog && d->curDialog->currentViewMode()==Kexi::DataViewMode) {
01140         KexiPart::Info *activePartInfo = d->curDialog->part()->info();
01141         d->action_edit_copy_special_data_table->setEnabled(
01142             activePartInfo ? activePartInfo->isDataExportSupported() : false );
01143     }
01144     else
01145         d->action_edit_copy_special_data_table->setEnabled( false );
01146 
01147     //VIEW MENU
01148     if (d->action_view_nav)
01149         d->action_view_nav->setEnabled(d->prj);
01150     d->action_view_mainarea->setEnabled(d->prj);
01151     if (d->action_view_propeditor)
01152         d->action_view_propeditor->setEnabled(d->prj);
01153     if (d->action_view_data_mode) {
01154         d->action_view_data_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::DataViewMode) );
01155         if (!d->action_view_data_mode->isEnabled())
01156             d->action_view_data_mode->setChecked(false);
01157     }
01158     if (d->action_view_design_mode) {
01159         d->action_view_design_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::DesignViewMode) );
01160         if (!d->action_view_design_mode->isEnabled())
01161             d->action_view_design_mode->setChecked(false);
01162     }
01163     if (d->action_view_text_mode) {
01164         d->action_view_text_mode->setEnabled( have_dialog && d->curDialog->supportsViewMode(Kexi::TextViewMode) );
01165         if (!d->action_view_text_mode->isEnabled())
01166             d->action_view_text_mode->setChecked(false);
01167     }
01168 #ifndef KEXI_NO_CTXT_HELP
01169     d->action_show_helper->setEnabled(d->prj);
01170 #endif
01171 
01172     //CREATE MENU
01173     if (d->createMenu)
01174         d->createMenu->setEnabled(d->