KDevelop API Documentation

src/mainwindow.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 mainwindow.cpp - KDevelop main widget for all QextMDI-based user 00003 interface modes (Childframe, TabPage, Toplevel) 00004 ------------------- 00005 begin : 22 Dec 2002 00006 copyright : (C) 2002 by the KDevelop team 00007 email : team@kdevelop.org 00008 ***************************************************************************/ 00009 00010 /*************************************************************************** 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 ***************************************************************************/ 00018 00019 #include "mainwindow.h" 00020 00021 #include <qlayout.h> 00022 #include <qmultilineedit.h> 00023 #include <qvbox.h> 00024 #include <qcheckbox.h> 00025 #include <qvaluelist.h> 00026 #include <qguardedptr.h> 00027 00028 #include <kdeversion.h> 00029 #include <kapplication.h> 00030 #include <kstdaction.h> 00031 #include <kdebug.h> 00032 #include <kaction.h> 00033 #include <klocale.h> 00034 #include <kconfig.h> 00035 #include <kstatusbar.h> 00036 #include <kdialogbase.h> 00037 #include <kkeydialog.h> 00038 #include <kedittoolbar.h> 00039 #include <kmenubar.h> 00040 #include <kmessagebox.h> 00041 #include <kiconloader.h> 00042 00043 #include <kdevproject.h> 00044 #include "projectmanager.h" 00045 #include "partcontroller.h" 00046 #include "plugincontroller.h" 00047 #include "api.h" 00048 #include "core.h" 00049 #include "settingswidget.h" 00050 #include "statusbar.h" 00051 #include "projectsession.h" 00052 00053 #include "toplevel.h" 00054 #include "mainwindowshare.h" 00055 #include <kmditoolviewaccessor.h> 00056 00057 // ====================================================== class ViewMenuAction 00058 ViewMenuAction::ViewMenuAction( 00059 ViewMenuActionPrivateData Data, 00060 const QString &Name): 00061 KToggleAction(Name), 00062 WindowData (Data) 00063 {} 00064 00065 ViewMenuAction::ViewMenuAction( 00066 ViewMenuActionPrivateData Data, 00067 const QString& text, const QString& pix, const KShortcut& cut, 00068 const QObject* receiver, const char* slot, 00069 KActionCollection* parent, const char* name ): 00070 KToggleAction(text, pix, cut, 0,0, parent, name), 00071 WindowData (Data) 00072 { 00073 connect(this, SIGNAL(activated(const ViewMenuActionPrivateData &)), receiver, slot); 00074 } 00075 00076 void ViewMenuAction::slotActivated() 00077 { 00078 KToggleAction::slotActivated(); 00079 emit activated(WindowData); 00080 } 00081 00082 00115 class ToolWindowState 00116 { 00117 public: 00118 ToolWindowState (KDockWidget *pDockWidget); 00119 bool hasDockWidget; 00120 KDockTabGroup * pTabGroup; 00121 bool hasTabGroup; 00122 bool mayBeShown; 00123 bool mayBeHide; 00124 KDockWidget * pDockBaseWindow; 00125 bool hasDockBaseWindow; 00126 bool dockBaseMayBeShow; 00127 bool dockBaseMayBeHide; 00128 bool dockBaseMayBeDockBack; 00129 bool dockBaseIsTopLevel; 00130 QString dockBaseName; 00131 bool viewMenuChecked; 00132 bool viewMenuEnabled; 00133 bool dockBaseIsHidden; 00134 bool dockBaseIsVisible; 00135 }; 00136 00137 ToolWindowState::ToolWindowState(KDockWidget *pDockWidget) 00138 { 00139 // Determine the state of the windows inwolved 00140 hasDockWidget = (pDockWidget != 0); 00141 pTabGroup = (hasDockWidget)?pDockWidget->parentDockTabGroup():0L; 00142 hasTabGroup = (pTabGroup != 0); 00143 mayBeShown = (hasDockWidget)?pDockWidget->mayBeShow():false; 00144 mayBeHide = (hasDockWidget)?pDockWidget->mayBeHide():false; 00145 00146 // Search for the dock base window 00147 pDockBaseWindow = 0; 00148 if (hasTabGroup) pDockBaseWindow = pDockWidget->dockManager()->findWidgetParentDock(pTabGroup); 00149 else if (hasDockWidget) pDockBaseWindow = pDockWidget->dockManager()->findWidgetParentDock(pDockWidget); 00150 if (mayBeHide && !pDockBaseWindow) 00151 { 00152 pDockBaseWindow = pDockWidget; // If I'm the only tool window, I'm the dock base! 00153 } 00154 hasDockBaseWindow = (pDockBaseWindow !=0); 00155 dockBaseMayBeDockBack = (hasDockBaseWindow)?pDockBaseWindow->isDockBackPossible():false; 00156 dockBaseMayBeShow = (hasDockBaseWindow)?pDockBaseWindow->mayBeShow():false; 00157 dockBaseMayBeHide = (hasDockBaseWindow)?pDockBaseWindow->mayBeHide():false; 00158 dockBaseIsTopLevel = (hasDockBaseWindow)?(pDockBaseWindow->parent()==0):false; 00159 dockBaseName = (hasDockBaseWindow)?(pDockBaseWindow->caption()):QString(""); 00160 dockBaseIsHidden = (hasDockBaseWindow)?(pDockBaseWindow->isHidden()):false; 00161 dockBaseIsVisible = (hasDockBaseWindow)?(pDockBaseWindow->isVisible()):false; 00162 viewMenuChecked = (hasTabGroup || mayBeHide)?true:false; 00163 viewMenuEnabled = !dockBaseMayBeDockBack && !dockBaseMayBeShow && !dockBaseIsHidden; 00164 } 00165 00185 class ToolDockBaseState 00186 { 00187 public: 00188 ToolDockBaseState(const QPtrList<QWidget> *pViews); 00189 KDockWidget* pDockBaseWindow; 00190 QWidget* pFirstToolWindow; 00191 bool hasDockBaseWindow; 00192 bool dockBaseIsHidden; 00193 bool dockBaseIsVisible; 00194 bool dockBaseMayBeDockBack; 00195 int noViews; 00196 }; 00197 00198 ToolDockBaseState::ToolDockBaseState(const QPtrList<QWidget> *pViews): 00199 pDockBaseWindow (0L), 00200 pFirstToolWindow (0L), 00201 hasDockBaseWindow (false), 00202 dockBaseIsHidden (false), 00203 dockBaseIsVisible (false), 00204 dockBaseMayBeDockBack(false), 00205 noViews (0) 00206 { 00207 00208 return; 00209 #warning this crashes in ideal mode, looks like there are dangling pointers on opening another project 00210 QPtrListIterator<QWidget> it(*pViews); 00211 for( ; it.current(); ++it) // Iterate through all views 00212 { 00213 QWidget *pParent=it.current()->parentWidget(); 00214 if (!pParent) continue; 00215 KDockWidget * pDockWidget = 0; 00216 pDockWidget = dynamic_cast<KDockWidget*>(pParent); 00217 // if (pParent->inherits("KDockWidget") || pParent->inherits("KDockWidget_Compat::KDockWidget")) pDockWidget = (KDockWidget*)pParent; 00218 if (!pDockWidget) continue; 00219 const ToolWindowState winState(pDockWidget); 00220 if (!pFirstToolWindow && winState.viewMenuChecked) pFirstToolWindow = it.current(); 00221 if (winState.hasDockBaseWindow && !hasDockBaseWindow) // Just take the first dock base window 00222 { 00223 hasDockBaseWindow = true; 00224 pDockBaseWindow = winState.pDockBaseWindow; 00225 dockBaseMayBeDockBack = winState.dockBaseMayBeDockBack; 00226 dockBaseIsVisible = winState.dockBaseIsVisible; 00227 if (winState.dockBaseIsHidden || 00228 (winState.dockBaseMayBeDockBack && !winState.dockBaseIsVisible)) 00229 dockBaseIsHidden = true; 00230 00231 } 00232 if (winState.viewMenuChecked) noViews++; 00233 } 00234 } 00235 00236 // ====================================================== class MainWindow 00237 MainWindow::MainWindow(QWidget *parent, const char *name) 00238 : KMdiMainFrm(parent, name) 00239 ,m_myWindowsReady(false) 00240 ,m_pShowOutputViews(0L) 00241 ,m_pShowTreeViews(0L) 00242 ,m_toggleViewbar(0L) 00243 ,m_bUiModeSwitchPending(false) 00244 ,m_bRemoveViewPending(false) 00245 { 00246 KConfig *config = kapp->config(); 00247 config->setGroup("UI"); 00248 mdiStyle = config->readNumEntry("MDIStyle", 1); 00249 00250 setIDEAlModeStyle(mdiStyle); // KDEV3 style of KMultiTabBar 00251 setStandardMDIMenuEnabled(false); 00252 setManagedDockPositionModeEnabled(true); 00253 00254 resize( 800, 600 ); 00255 m_pMainWindowShare = new MainWindowShare(this); 00256 00257 previous_output_view = NULL; 00258 00259 m_pDockbaseAreaOfDocumentViews->dockManager()->setReadDockConfigMode(KDockManager::RestoreAllDockwidgets); 00260 } 00261 00262 00263 void MainWindow::init() 00264 { 00265 actionCollection()->setHighlightingEnabled( true ); 00266 00267 #if (KDE_VERSION > 305) 00268 setStandardToolBarMenuEnabled( true ); 00269 #endif 00270 setXMLFile("kdevelopui.rc"); 00271 00272 createFramework(); 00273 createActions(); 00274 createStatusBar(); 00275 00276 createGUI(0); 00277 00278 m_pMainWindowShare->init(); 00279 00280 KAction *a = actionCollection()->action("help_report_bug"); 00281 disconnect(a, SIGNAL(activated()), 0, 0); 00282 connect(a, SIGNAL(activated()), m_pMainWindowShare, SLOT(slotReportBug())); 00283 00284 connect(PartController::getInstance(), SIGNAL(activePartChanged(KParts::Part*)), 00285 this, SLOT(createGUI(KParts::Part*))); 00286 connect(Core::getInstance(), SIGNAL(projectOpened()), 00287 this, SLOT(slotReactToProjectOpened()) ); 00288 connect(ProjectManager::getInstance()->projectSession(), 00289 SIGNAL(sig_restoreAdditionalViewProperties(const QString&, const QDomElement*)), 00290 this, SLOT(slotRestoreAdditionalViewProperties(const QString&, const QDomElement*))); 00291 connect(ProjectManager::getInstance()->projectSession(), 00292 SIGNAL(sig_saveAdditionalViewProperties(const QString&, QDomElement*)), 00293 this, SLOT(slotSaveAdditionalViewProperties(const QString&, QDomElement*))); 00294 00295 connect(this,SIGNAL(viewActivated(KMdiChildView*)),this,SLOT(slotViewActivated(KMdiChildView*))); 00296 00297 connect( PartController::getInstance(), SIGNAL(partURLChanged(KParts::ReadOnlyPart * )), 00298 this, SLOT(slotPartURLChanged(KParts::ReadOnlyPart * )) ); 00299 00300 if (!isFakingSDIApplication()) { 00301 QPopupMenu *menu = (QPopupMenu*) main()->child( "window", "KPopupMenu" ); 00302 unsigned int count = menuBar()->count(); 00303 if (menu) 00304 setWindowMenu(menu); 00305 else 00306 menuBar()->insertItem( i18n("&Window"), windowMenu(), -1, count-2); // standard position is left to the last ('Help') 00307 } 00308 00309 if ( PluginController::pluginServices().isEmpty() ) { 00310 KMessageBox::sorry( this, i18n("Unable to find plugins, KDevelop will not work properly.\nPlease make sure " 00311 "that KDevelop is installed in your KDE directory, otherwise you have to add KDevelop's installation " 00312 "path to the environment variable KDEDIRS and run kbuildsycoca. Restart KDevelop afterwards.\n" 00313 "Example for BASH users:\nexport KDEDIRS=/path/to/kdevelop:$KDEDIRS && kbuildsycoca"), 00314 i18n("Could not Find Plugins") ); 00315 } 00316 } 00317 00318 00319 void MainWindow::slotViewActivated(KMdiChildView* view) { 00320 kdDebug()<<"void MainWindow::slotViewActivated(KMdiChildView*)"<<endl; 00321 QWidget *w=view->childAt(5,5); 00322 PartController::getInstance()->slotCurrentChanged(w); 00323 } 00324 00325 MainWindow::~MainWindow() 00326 { 00327 TopLevel::invalidateInstance( this ); 00328 } 00329 00330 bool MainWindow::queryClose() 00331 { 00332 return Core::getInstance()->queryClose(); 00333 } 00334 00335 bool MainWindow::queryExit() 00336 { 00337 saveSettings(); 00338 return true; 00339 } 00340 00341 KMainWindow *MainWindow::main() 00342 { 00343 return this; 00344 } 00345 00346 00347 void MainWindow::createStatusBar() 00348 { 00349 (void) new StatusBar(this); 00350 } 00351 00352 00353 void MainWindow::createFramework() 00354 { 00355 PartController::createInstance(this); 00356 setMenuForSDIModeSysButtons(menuBar()); 00357 } 00358 00364 void MainWindow::createActions() 00365 { 00366 // Create actions for the view menu 00367 ViewMenuActionPrivateData ViewActionData; // ViewActionData holds the parameter for the action 00368 ViewActionData.eView = OutputView; // The new action will be for the output tool window 00369 ViewActionData.pChildView = 0L; // It is not for a single window, but for all output tool windows 00370 ViewActionData.pDockWidget = 0L; // Therefore,the window pointers are set to null 00371 m_pShowOutputViews = new ViewMenuAction(ViewActionData,i18n("All Output Views"), "view_bottom", 00372 CTRL + SHIFT + Key_O, this, SLOT(toggleToolDockBaseState(const ViewMenuActionPrivateData &)), 00373 actionCollection(), "output_view" ); 00374 m_pShowOutputViews->setStatusText(i18n("Output view")); 00375 m_pShowOutputViews->setEnabled( true ); 00376 00377 ViewActionData.eView = TreeView; // The next action will be for the tree tool windows 00378 m_pShowTreeViews = new ViewMenuAction(ViewActionData,i18n("All Tree Views"), "tree_win", 00379 CTRL + SHIFT + Key_T, this, SLOT(toggleToolDockBaseState(const ViewMenuActionPrivateData &)), 00380 actionCollection(), "tree_view" ); 00381 m_pShowTreeViews->setStatusText(i18n("Tree view")); 00382 m_pShowTreeViews->setEnabled( true ); 00383 00384 connect(manager(), SIGNAL(change()),this, SLOT(updateActionState())); 00385 00386 m_pOutputToolViewsMenu = new KActionMenu( i18n("Output Tool Views"), 0, "view_output_tool_views"); 00387 m_pOutputToolViewsMenu->setToolTip(i18n("Output tool views")); 00388 m_pOutputToolViewsMenu->setWhatsThis(i18n("<b>Output tool views</b><p>Shows all output views available.")); 00389 connect(m_pOutputToolViewsMenu->popupMenu(),SIGNAL(aboutToShow()),this,SLOT(fillOutputToolViewsMenu())); 00390 actionCollection()->insert(m_pOutputToolViewsMenu); 00391 00392 m_pTreeToolViewsMenu = new KActionMenu( i18n("Tree Tool Views"), 0, "view_tree_tool_views"); 00393 m_pTreeToolViewsMenu->setToolTip(i18n("Tree tool views")); 00394 m_pTreeToolViewsMenu->setWhatsThis(i18n("<b>Tree tool views</b><p>Shows all tool views available.")); 00395 connect(m_pTreeToolViewsMenu->popupMenu(),SIGNAL(aboutToShow()),this,SLOT(fillTreeToolViewsMenu())); 00396 actionCollection()->insert(m_pTreeToolViewsMenu); 00397 00398 m_pMainWindowShare->createActions(); 00399 connect(m_pMainWindowShare, SIGNAL(gotoNextWindow()), this, SLOT(gotoNextWindow())); 00400 connect(m_pMainWindowShare, SIGNAL(gotoPreviousWindow()), this, SLOT(gotoPreviousWindow())); 00401 connect(m_pMainWindowShare, SIGNAL(gotoFirstWindow()), this, SLOT(gotoFirstWindow())); 00402 connect(m_pMainWindowShare, SIGNAL(gotoLastWindow()), this, SLOT(gotoLastWindow())); 00403 00404 m_toggleViewbar = KStdAction::showToolbar(this, SLOT(slotToggleViewbar()),actionCollection(), "settings_viewbar"); 00405 m_toggleViewbar->setText(i18n("Show &Viewbar")); 00406 m_toggleViewbar->setToolTip( i18n("Show viewbar") ); 00407 m_toggleViewbar->setWhatsThis(i18n("<b>Show viewbar</b><p>Hides or shows the viewbar.")); 00408 showViewTaskBar(); // because start state must be equal to the action state 00409 if (m_mdiMode == KMdi::TabPageMode) { 00410 slotToggleViewbar(); 00411 m_toggleViewbar->setEnabled(false); 00412 } 00413 00414 new KAction( i18n("Raise &Editor"), ALT+Key_C, this, SLOT(raiseEditor()), actionCollection(), "raise_editor"); 00415 } 00416 00417 KMdiChildView* MainWindow::wrapper(QWidget *view, const QString& name) 00418 { 00419 QString shortName = name; 00420 int length = shortName.length(); 00421 shortName = shortName.right(length - (shortName.findRev('/') +1)); 00422 00423 KMdiChildView* pMDICover = createWrapper(view, name, shortName); 00424 m_widgetMap.insert(view, pMDICover); 00425 m_childViewMap.insert(pMDICover, view); 00426 00427 return pMDICover; 00428 } 00429 00430 00431 void MainWindow::slotPartURLChanged( KParts::ReadOnlyPart * ro_part ) 00432 { 00433 if ( !ro_part || !ro_part->widget() ) return; 00434 00435 KMdiChildView * child = m_widgetMap[ ro_part->widget() ]; 00436 if ( child ) 00437 { 00438 child->setMDICaption( ro_part->url().fileName() ); 00439 } 00440 } 00441 00442 00443 void MainWindow::embedPartView(QWidget *view, const QString &/*name*/, const QString& fullName) 00444 { 00445 KMdiChildView *child = wrapper(view, fullName); 00446 m_captionDict.insert(fullName, child); 00447 00448 const QPixmap* wndIcon = view->icon(); 00449 if (!wndIcon || (wndIcon && (wndIcon->size().height() > 16))) { 00450 view->setIcon(SmallIcon("kdevelop")); 00451 child->setIcon(SmallIcon("kdevelop")); // was empty or too big, take something useful 00452 } 00453 00454 00455 unsigned int mdiFlags = KMdi::StandardAdd | KMdi::UseKMdiSizeHint; 00456 addWindow(child, mdiFlags); 00457 00458 m_partViews.append(child); 00459 00460 // hack for a strange geometry problem (otherwise the childview doesn't move to the right position in the childframe) 00461 if ((mdiMode() == KMdi::ChildframeMode) && isInMaximizedChildFrmMode()) { 00462 QWidget* v; 00463 if (child->mdiParent()) { v = child->mdiParent(); } 00464 else { v = child; } 00465 QRect geom = v->geometry(); 00466 v->setGeometry(geom.left(),geom.top(),geom.width()+1,geom.height()+1); 00467 v->setGeometry(geom.left(),geom.top(),geom.width(),geom.height()); 00468 } 00469 } 00470 00471 void MainWindow::checkAndFixToolViewObjectName(QWidget* view, const QString& shortName) 00472 { 00473 // a tool-view has to have an object name, otherwise it'll crash when switching the UI modes 00474 00475 static unsigned int s_index4DoubledName = 0; 00476 00477 QString objName = view->name(); 00478 bool fixed = false; 00479 if (objName.isEmpty()) { 00480 objName = shortName; 00481 fixed = true; 00482 } 00483 if (objName == "unnamed") { 00484 objName = shortName; 00485 fixed = true; 00486 } 00487 if (objName.isEmpty()) { 00488 QString s; s.setNum(s_index4DoubledName++); 00489 objName += "unnamed_" + s; 00490 fixed = true; 00491 } 00492 if (fixed) { 00493 view->setName(objName.latin1()); 00494 } 00495 } 00496 00497 void MainWindow::embedSelectView(QWidget *view, const QString &name, const QString &toolTip) 00498 { 00499 const QPixmap* wndIcon = view->icon(); 00500 kdDebug(9000) << "icon = " << wndIcon << endl; 00501 if (!wndIcon ) { // || (wndIcon && (wndIcon->size().height() > 16))) { 00502 view->setIcon(SmallIcon("kdevelop")); // was empty or too big, take something useful 00503 } 00504 00505 QString shortName = name; 00506 int length = shortName.length(); 00507 shortName = shortName.right(length - (shortName.findRev('/') +1)).stripWhiteSpace(); 00508 checkAndFixToolViewObjectName(view, shortName); 00509 00510 KMdiToolViewAccessor *tmp = 00511 KMdiMainFrm::addToolWindow(view, 00512 KDockWidget::DockLeft, 00513 getMainDockWidget(), 00514 25, 00515 toolTip, 00516 mdiMode() == KMdi::IDEAlMode ? shortName : "" // empty tab caption, only icons - otherwise it'll be too wide! 00517 ); 00518 00519 m_selectViews.append(view); 00520 } 00521 00522 void MainWindow::embedSelectViewRight(QWidget* view, const QString& title, const QString &toolTip) 00523 { 00524 if (mdiMode() != KMdi::IDEAlMode) { 00525 //we don't like a right pane in several UI modes, dock to default 00526 embedSelectView( view, title, toolTip ); 00527 return; 00528 } 00529 00530 00531 const QPixmap* wndIcon = view->icon(); 00532 kdDebug(9000) << "icon = " << wndIcon << endl; 00533 if (!wndIcon ) { // || (wndIcon && (wndIcon->size().height() > 16))) { 00534 view->setIcon(SmallIcon("kdevelop")); // was empty or too big, take something useful 00535 } 00536 00537 QString shortName = title; 00538 int length = shortName.length(); 00539 shortName = shortName.right(length - (shortName.findRev('/') +1)).stripWhiteSpace(); 00540 checkAndFixToolViewObjectName(view, shortName); 00541 00542 KMdiToolViewAccessor *tmp=KMdiMainFrm::addToolWindow(view, 00543 KDockWidget::DockRight, 00544 getMainDockWidget(), 00545 25, 00546 toolTip, 00547 shortName); 00548 m_selectViews.append(view); 00549 } 00550 00551 void MainWindow::embedOutputView(QWidget *view, const QString &name, const QString &toolTip) 00552 { 00553 QString shortName = name; 00554 int length = shortName.length(); 00555 shortName = shortName.right(length - (shortName.findRev('/') +1)).stripWhiteSpace(); 00556 checkAndFixToolViewObjectName(view, shortName); 00557 00558 KMdiToolViewAccessor *tmp = 00559 KMdiMainFrm::addToolWindow(view, 00560 KDockWidget::DockBottom, 00561 getMainDockWidget(), 00562 70, 00563 toolTip, 00564 shortName 00565 ); 00566 00567 m_outputViews.append(view); 00568 } 00569 00570 00571 void MainWindow::setViewAvailable(QWidget *pView, bool bEnabled) 00572 { 00573 if (!pView) return; 00574 00575 KDockWidget* pWrappingDockWidget = dockManager->findWidgetParentDock(pView); 00576 if (!pWrappingDockWidget) return; 00577 if (bEnabled) { 00578 pWrappingDockWidget->makeDockVisible(); 00579 } 00580 else { 00581 pWrappingDockWidget->undock(); 00582 } 00583 00584 if (bEnabled) { 00585 m_unavailableViews.remove(pView); 00586 } 00587 else { 00588 m_unavailableViews.append(pView); 00589 } 00590 } 00591 00592 void MainWindow::removeView(QWidget *view) 00593 { 00594 if (!view) { 00595 return; 00596 } 00597 m_bRemoveViewPending = true; 00598 00599 QGuardedPtr<KMdiChildView> wrapper = m_widgetMap[view]; 00600 00601 if (wrapper) { 00602 removeWindowFromMdi(wrapper); 00603 m_partViews.remove(wrapper); 00604 m_widgetMap.remove(view); 00605 m_childViewMap.remove(wrapper); 00606 m_captionDict.remove(wrapper->caption()); 00607 } 00608 00609 // Find the KDockWidget which covers the KMdiChildView to remove and delete. 00610 // Undock the KDockWidget if there is one. 00611 // This will remove the corresponding tab from the output and tree views. 00612 QGuardedPtr<KDockWidget> pDock = dockManager->findWidgetParentDock(wrapper ? wrapper : view); 00613 00614 // Note: this reparenting is necessary. Otherwise, the view gets 00615 // deleted twice: once when the wrapper is deleted, and the second 00616 // time when the part is deleted. 00617 view->hide(); 00618 view->reparent(this, QPoint(0,0), false); 00619 00620 // QextMDI removes and deletes the wrapper widget 00621 // removed by robe.. seems that this fix the crash when exit from kdevelop in MDI mode 00622 if (wrapper) { 00623 closeWindow(wrapper); 00624 } 00625 00626 if( pDock ) { 00627 deleteToolWindow(view); 00628 /* pDock->undock(); 00629 delete (KDockWidget*) pDock;*/ 00630 } 00631 else { 00632 kdDebug(9000) << "pDock already destroyed!!" << endl; 00633 } 00634 if (!wrapper) { 00635 m_selectViews.remove(view); 00636 m_outputViews.remove(view); 00637 } 00638 00639 m_bRemoveViewPending = false; 00640 } 00641 00642 00643 void MainWindow::raiseView(QWidget *view) 00644 { 00645 m_myWindowsReady = true; // From now on, we can rely on the windows beeing active 00646 // Handle differences between output and tree views 00647 QPtrList<QWidget> *pViews = 0L; // The views to make a menu from 00648 00649 QWidget *wrapper = m_widgetMap[ view ]; 00650 if (wrapper) 00651 wrapper->setFocus(); 00652 00653 KDockWidget* pDock = dockManager->findWidgetParentDock(wrapper ? wrapper : view); 00654 if (pDock) 00655 if (!pDock->isVisible()) 00656 makeDockVisible(pDock); 00657 } 00658 00659 00660 void MainWindow::lowerView(QWidget *) 00661 { 00662 // ignored in MDI mode! 00663 } 00664 00665 void MainWindow::lowerAllViews() 00666 { 00667 // ignored in MDI mode! 00668 } 00669 00670 00671 void MainWindow::createGUI(KParts::Part *part) 00672 { 00673 if ( !part ) 00674 setCaption( QString::null ); 00675 KMdiMainFrm::createGUI(part); 00676 00677 m_pMainWindowShare->slotGUICreated( part ); 00678 } 00679 00680 00681 void MainWindow::loadSettings() 00682 { 00683 ProjectManager::getInstance()->loadSettings(); 00684 loadMDISettings(); 00685 applyMainWindowSettings(kapp->config(), "Mainwindow"); 00686 } 00687 00688 00689 void MainWindow::loadMDISettings() 00690 { 00691 KConfig *config = kapp->config(); 00692 config->setGroup("UI"); 00693 00694 int mdiMode = config->readNumEntry("MDIMode", KMdi::ChildframeMode); 00695 switch (mdiMode) 00696 { 00697 case KMdi::ToplevelMode: 00698 { 00699 int childFrmModeHt = config->readNumEntry("Childframe mode height", kapp->desktop()->height() - 50); 00700 resize(width(), childFrmModeHt); 00701 switchToToplevelMode(); 00702 } 00703 break; 00704 00705 case KMdi::ChildframeMode: 00706 break; 00707 00708 case KMdi::TabPageMode: 00709 { 00710 int childFrmModeHt = config->readNumEntry("Childframe mode height", kapp->desktop()->height() - 50); 00711 resize(width(), childFrmModeHt); 00712 switchToTabPageMode(); 00713 } 00714 break; 00715 case KMdi::IDEAlMode: 00716 { 00717 switchToIDEAlMode(); 00718 } 00719 00720 default: 00721 break; 00722 } 00723 00724 // restore a possible maximized Childframe mode 00725 bool maxChildFrmMode = config->readBoolEntry("maximized childframes", true); 00726 setEnableMaximizedChildFrmMode(maxChildFrmMode); 00727 00728 readDockConfig(0L, "dockSession_version1"); 00729 } 00730 00731 void MainWindow::guiRestoringFinished() 00732 { 00733 dockManager->finishReadDockConfig(); 00734 } 00735 00736 void MainWindow::prepareToCloseViews() 00737 { 00738 writeDockConfig(0L, "dockSession_version1"); 00739 } 00740 00741 void MainWindow::saveSettings() 00742 { 00743 ProjectManager::getInstance()->saveSettings(); 00744 saveMainWindowSettings(kapp->config(), "Mainwindow"); 00745 saveMDISettings(); 00746 } 00747 00748 00749 void MainWindow::saveMDISettings() 00750 { 00751 KConfig *config = kapp->config(); 00752 config->setGroup("UI"); 00753 00754 config->writeEntry("maximized childframes", isInMaximizedChildFrmMode()); 00755 config->writeEntry("MDIStyle", mdiStyle); 00756 config->writeEntry("MDIMode", mdiMode()); 00757 } 00758 00759 00760 void MainWindow::resizeEvent(QResizeEvent *ev) 00761 { 00762 KMdiMainFrm::resizeEvent(ev); 00763 setSysButtonsAtMenuPosition(); 00764 } 00765 00766 void MainWindow::childWindowCloseRequest(KMdiChildView *pWnd) 00767 { 00768 PartController::getInstance()->closePartForWidget( m_childViewMap[pWnd] ); 00769 } 00770 00771 void MainWindow::gotoNextWindow() 00772 { 00773 activateNextWin(); 00774 } 00775 00776 void MainWindow::gotoPreviousWindow() 00777 { 00778 activatePrevWin(); 00779 } 00780 00781 void MainWindow::gotoFirstWindow() 00782 { 00783 activateFirstWin(); 00784 } 00785 00786 void MainWindow::gotoLastWindow() 00787 { 00788 activateLastWin(); 00789 } 00790 00791 //=============== fillWindowMenu ===============// 00792 // This is more or less a verbatim copy from what is implemented in KMdiMainFrm 00793 void MainWindow::fillWindowMenu() 00794 { 00795 bool bTabPageMode = FALSE; 00796 if (m_mdiMode == KMdi::TabPageMode) 00797 bTabPageMode = TRUE; 00798 bool bIDEAlMode = FALSE; 00799 if (m_mdiMode == KMdi::IDEAlMode) 00800 bIDEAlMode = TRUE; 00801 00802 bool bNoViewOpened = FALSE; 00803 if (m_pDocumentViews->isEmpty()) { 00804 bNoViewOpened = TRUE; 00805 } 00806 // construct the menu and its submenus 00807 if (!m_bClearingOfWindowMenuBlocked) { 00808 clearWindowMenu(); 00809 } 00810 int closeId = m_pWindowMenu->insertItem(i18n("&Close"), PartController::getInstance(), SLOT(slotCloseWindow())); 00811 m_windowMenus.append(closeId); 00812 int closeAllId = m_pWindowMenu->insertItem(i18n("Close &All"), PartController::getInstance(), SLOT(slotCloseAllWindows())); 00813 m_windowMenus.append(closeAllId); 00814 int closeAllOtherId = m_pWindowMenu->insertItem(i18n("Close All &Others"), PartController::getInstance(), SLOT(slotCloseOtherWindows())); 00815 m_windowMenus.append(closeAllOtherId); 00816 if (bNoViewOpened) { 00817 m_pWindowMenu->setItemEnabled(closeId, FALSE); 00818 m_pWindowMenu->setItemEnabled(closeAllId, FALSE); 00819 m_pWindowMenu->setItemEnabled(closeAllOtherId, FALSE); 00820 } 00821 if (!bTabPageMode && !bIDEAlMode) { 00822 int iconifyId = m_pWindowMenu->insertItem(i18n("&Minimize All"), this, SLOT(iconifyAllViews())); 00823 m_windowMenus.append(iconifyId); 00824 if (bNoViewOpened) { 00825 m_pWindowMenu->setItemEnabled(iconifyId, FALSE); 00826 } 00827 } 00828 m_windowMenus.append(m_pWindowMenu->insertSeparator()); 00829 if (!bTabPageMode && !bIDEAlMode) { 00830 int placMenuId = m_pWindowMenu->insertItem(i18n("&Tile..."), m_pPlacingMenu); 00831 m_windowMenus.append(placMenuId); 00832 m_pPlacingMenu->clear(); 00833 m_pPlacingMenu->insertItem(i18n("Ca&scade Windows"), m_pMdi,SLOT(cascadeWindows())); 00834 m_pPlacingMenu->insertItem(i18n("Cascade &Maximized"), m_pMdi,SLOT(cascadeMaximized())); 00835 m_pPlacingMenu->insertItem(i18n("Expand &Vertically"), m_pMdi,SLOT(expandVertical())); 00836 m_pPlacingMenu->insertItem(i18n("Expand &Horizontally"), m_pMdi,SLOT(expandHorizontal())); 00837 m_pPlacingMenu->insertItem(i18n("Tile &Non-overlapped"), m_pMdi,SLOT(tileAnodine())); 00838 m_pPlacingMenu->insertItem(i18n("Tile Overla&pped"), m_pMdi,SLOT(tilePragma())); 00839 m_pPlacingMenu->insertItem(i18n("Tile V&ertically"), m_pMdi,SLOT(tileVertically())); 00840 if (m_mdiMode == KMdi::ToplevelMode) { 00841 m_pWindowMenu->setItemEnabled(placMenuId, FALSE); 00842 } 00843 m_windowMenus.append(m_pWindowMenu->insertSeparator()); 00844 int dockUndockId = m_pWindowMenu->insertItem(i18n("&Dock/Undock..."), m_pDockMenu); 00845 m_windowMenus.append(dockUndockId); 00846 m_pDockMenu->clear(); 00847 m_windowMenus.append(m_pWindowMenu->insertSeparator()); 00848 if (bNoViewOpened) { 00849 m_pWindowMenu->setItemEnabled(placMenuId, FALSE); 00850 m_pWindowMenu->setItemEnabled(dockUndockId, FALSE); 00851 } 00852 } 00853 int entryCount = m_pWindowMenu->count(); 00854 00855 // for all child frame windows: give an ID to every window and connect them in the end with windowMenuItemActivated() 00856 int i=100; 00857 KMdiChildView* pView = 0L; 00858 QPtrListIterator<KMdiChildView> it(*m_pDocumentViews); 00859 QValueList<QDateTime> timeStamps; 00860 for (; it.current(); ++it) { 00861 00862 pView = it.current(); 00863 if (pView->isToolView()) { 00864 continue; 00865 } 00866 QDateTime timeStamp( pView->getTimeStamp() ); 00867 00868 KParts::ReadOnlyPart * ro_part = getPartFromWidget(m_childViewMap[pView]); 00869 00870 QString name = (ro_part==0L)?pView->caption():ro_part->url().prettyURL(); 00871 QString item; 00872 // set titles of minimized windows in brackets 00873 if (pView->isMinimized()) { 00874 item += "("; 00875 item += name; 00876 item += ")"; 00877 } 00878 else { 00879 item += " "; 00880 item += name; 00881 } 00882 00883 // insert the window entry sorted in alphabetical order 00884 unsigned int indx; 00885 unsigned int windowItemCount = m_pWindowMenu->count() - entryCount; 00886 // bool inserted = FALSE; 00887 QString tmpString; 00888 00889 QValueList<QDateTime>::iterator timeStampIterator = timeStamps.begin(); 00890 for (indx = 0; indx < windowItemCount; indx++, ++timeStampIterator) { 00891 bool putHere = false; 00892 if ((*timeStampIterator) < timeStamp) { 00893 putHere = true; 00894 } 00895 if ( putHere ) { 00896 // timeStamps.insert( timeStampIterator, timeStamp ); 00897 // m_pWindowMenu->insertItem( item, pView, SLOT(slot_clickedInWindowMenu()), 0, -1, indx+entryCount); 00898 // if (pView == m_pCurrentWindow) 00899 // m_pWindowMenu->setItemChecked( m_pWindowMenu->idAt( indx+entryCount), TRUE); 00900 // pView->setWindowMenuID( i); 00901 // if (!bTabPageMode) { 00902 // m_pDockMenu->insertItem( item, pView, SLOT(slot_clickedInDockMenu()), 0, -1, indx); 00903 // if (pView->isAttached()) 00904 // m_pDockMenu->setItemChecked( m_pDockMenu->idAt( indx), TRUE); 00905 // } 00906 // inserted = TRUE; 00907 break; 00908 } 00909 } 00910 // if (!inserted) { // append it 00911 timeStamps.insert( timeStampIterator, timeStamp ); 00912 m_windowMenus.append(m_pWindowMenu->insertItem( item, pView, SLOT(slot_clickedInWindowMenu()), 0, -1, indx+entryCount)); 00913 if (pView == m_pCurrentWindow) 00914 m_pWindowMenu->setItemChecked( m_pWindowMenu->idAt( indx+entryCount), TRUE); 00915 pView->setWindowMenuID( i); 00916 if (!bTabPageMode) { 00917 m_windowMenus.append(m_pDockMenu->insertItem( item, pView, SLOT(slot_clickedInDockMenu()), 0, -1, indx)); 00918 if (pView->isAttached()) 00919 m_pDockMenu->setItemChecked( m_pDockMenu->idAt( indx), TRUE); 00920 } 00921 // } 00922 i++; 00923 } 00924 } 00925 00927 void MainWindow::fillOutputToolViewsMenu() 00928 { 00929 fillToolViewsMenu(OutputView); // Fill tool-view menu for output views 00930 } 00931 00933 void MainWindow::fillTreeToolViewsMenu() 00934 { 00935 fillToolViewsMenu(TreeView); // Fill tool-view menu for tree views 00936 } 00937 00938 //=============== fillToolViewsMenu ===============// 00948 void MainWindow::fillToolViewsMenu( 00949 EView eView) 00950 { 00951 // Handle differences between output and tree views 00952 QPtrList<QWidget>* pViews = 0L; // The views to make a menu from 00953 KActionMenu* pActionMenu = 0L; // The menu to build 00954 ViewMenuAction* pAllViewsAction = 0L; // Pointer to action which will toggle the state of all windows 00955 00956 if (eView == OutputView) 00957 { 00958 pViews = &m_outputViews; 00959 pActionMenu = m_pOutputToolViewsMenu; 00960 pAllViewsAction = m_pShowOutputViews; 00961 } 00962 else 00963 { 00964 pViews = &m_selectViews; 00965 pActionMenu = m_pTreeToolViewsMenu; 00966 pAllViewsAction = m_pShowTreeViews; 00967 } 00968 00969 ToolDockBaseState allToolWinState(pViews); 00970 00971 // Prepare fixed part of the menu 00972 pActionMenu->popupMenu()->clear(); // Remove all entries 00973 pActionMenu->insert(pAllViewsAction); 00974 pActionMenu->popupMenu()->insertSeparator(); 00975 00976 // Prepare variable part of the menu 00977 m_myWindowsReady = true; // From now on, we can rely on the windows beeing active 00978 QPtrListIterator<QWidget> it(*pViews); 00979 for( ; it.current(); ++it) // Iterate through all views 00980 { 00981 if (m_unavailableViews.find(it.current()) != -1) { 00982 continue; // skip this view, it was set to unavailable for the GUI 00983 } 00984 KDockWidget *pDockWidget = manager()->findWidgetParentDock(it.current()); // Get the DockWidget which covers the view 00985 Q_ASSERT(pDockWidget); 00986 QString Name = pDockWidget->tabPageLabel(); // Get the name of the view 00987 ViewMenuActionPrivateData ActionData; 00988 ActionData.pDockWidget = pDockWidget; // Save the pointer to the DockWidget 00989 ActionData.pChildView = it.current(); // Save the pointer to the view 00990 ActionData.eView = eView; // Save whether it is an output or tree view 00991 00992 ViewMenuAction* action = new ViewMenuAction(ActionData,Name); // Action to show or hide the view window 00993 connect(action, // Call toggleSingleToolWin if the action is activated 00994 SIGNAL(activated(const ViewMenuActionPrivateData &)), 00995 this, 00996 SLOT(toggleSingleToolWin(const ViewMenuActionPrivateData &))); 00997 00998 const ToolWindowState winState(pDockWidget); 00999 action->setChecked(winState.viewMenuChecked); 01000 action->setEnabled( 01001 (allToolWinState.hasDockBaseWindow && !allToolWinState.dockBaseIsHidden) 01002 || (allToolWinState.noViews==0)); 01003 pActionMenu->insert(action); 01004 } 01005 } 01006 01008 void MainWindow::updateActionState() 01009 { 01010 if (!m_bUiModeSwitchPending && !m_bRemoveViewPending) { 01011 ToolDockBaseState outputToolState(&m_outputViews); 01012 ToolDockBaseState treeToolState (&m_selectViews); 01013 01014 m_pShowOutputViews->setChecked(outputToolState.dockBaseIsVisible); 01015 m_pShowTreeViews ->setChecked(treeToolState.dockBaseIsVisible); 01016 } 01017 } 01018 01020 void MainWindow::toggleToolDockBaseState(const ViewMenuActionPrivateData &ActionData) 01021 { 01022 m_myWindowsReady = true; // From now on, we can rely on the windows beeing active 01023 // Handle differences between output and tree views 01024 QPtrList<QWidget> *pViews = 0L; // The views to make a menu from 01025 pViews = (ActionData.eView == OutputView)?&m_outputViews:&m_selectViews; 01026 01027 QPtrListIterator<QWidget> it(*pViews); 01028 const ToolDockBaseState allWinState(pViews); 01029 01030 if(allWinState.dockBaseIsVisible) { // If it is visible 01031 allWinState.pDockBaseWindow->undock(); // undock it, so it is invisible 01032 } 01033 else if (allWinState.dockBaseMayBeDockBack){// If it may be dock back, it is invisible 01034 allWinState.pDockBaseWindow->dockBack(); // Show it again 01035 } 01036 else if(allWinState.dockBaseIsHidden) { // In toplevel mode the tool window is just hidden 01037 allWinState.pDockBaseWindow->show(); // Then show it 01038 } 01039 else 01040 { 01041 // not a single tool window found, so we show all of them 01042 showAllToolWin(ActionData.eView,1); 01043 } 01044 01045 } 01046 01048 void MainWindow::showAllToolWin(EView eView, bool show ) 01049 { 01050 // Handle differences between output and tree views 01051 QPtrList<QWidget> *pViews = 0L; // The views to make a menu from 01052 01053 pViews =(eView==OutputView)?&m_outputViews:&m_selectViews; 01054 01055 // If the tool window is not visible, first show it! 01056 const ToolDockBaseState allWinState(pViews); 01057 if(allWinState.dockBaseIsHidden) 01058 { 01059 ViewMenuActionPrivateData ActionData; 01060 ActionData.eView = eView; 01061 ActionData.pChildView = 0; 01062 ActionData.pDockWidget = 0; 01063 toggleToolDockBaseState(ActionData); 01064 } 01065 01066 // Now switch on every single tool window 01067 m_myWindowsReady = true; // From now on, we can rely on the windows beeing active 01068 QPtrListIterator<QWidget> it(*pViews); 01069 for( ; it.current(); ++it) // Iterate through all views 01070 { 01071 if (m_unavailableViews.find(it.current()) != -1) { 01072 continue; 01073 } 01074 KDockWidget *pDockWidget=manager()->findWidgetParentDock(it.current()); // Get the DockWidget which covers the view 01075 Q_ASSERT(pDockWidget); 01076 QString Name = pDockWidget->name(); // Get the name of the view 01077 ViewMenuActionPrivateData ActionData; 01078 ActionData.pDockWidget = pDockWidget; // Save the pointer to the DockWidget 01079 ActionData.pChildView = it.current(); // Save the pointer to the view 01080 ActionData.eView = eView; // Save whether it is an output or tree view 01081 const ToolWindowState winState(pDockWidget); 01082 if(winState.viewMenuChecked != show) 01083 toggleSingleToolWin(ActionData); 01084 } 01085 01086 } 01087 01089 void MainWindow::toggleSingleToolWin(const ViewMenuActionPrivateData &ActionData) 01090 { 01091 // Determine the state of the windows inwolved 01092 const ToolWindowState winState(ActionData.pDockWidget); 01093 QPtrList<QWidget> *pViews = 0L; // The views to make a menu from 01094 pViews = (ActionData.eView == OutputView)?&m_outputViews:&m_selectViews; 01095 01096 const ToolDockBaseState allWinState(pViews); 01097 if(winState.hasTabGroup) 01098 { // the window has a tab page 01099 if (winState.mayBeShown) 01100 { 01101 QWidget *pActiveWidget=winState.pTabGroup->currentPage(); // remember the active page 01102 ActionData.pDockWidget->changeHideShowState(); // pDockWidget has not not been the active page,now it is acitve 01103 ActionData.pDockWidget->changeHideShowState(); // and now it is gone 01104 if (allWinState.noViews > 2) // Is still more than one page left? 01105 { // Yes, so pTabGroup still exists... 01106 winState.pTabGroup->showPage(pActiveWidget); // switch back to previouse active page 01107 } 01108 } 01109 else 01110 { 01111 ActionData.pDockWidget->changeHideShowState(); // and now it is gone 01112 } 01113 } 01114 else // It does not have a tab group 01115 { 01116 if (winState.hasDockWidget) 01117 { 01118 if(winState.mayBeHide) 01119 { 01120 ActionData.pDockWidget->changeHideShowState(); // and now it is gone 01121 } 01122 else 01123 { 01124 // Count how many windows are visible 01125 KDockWidget *first =0L; // Pointer to a widget in that view area, may function as target to docking 01126 QPtrListIterator<QWidget> it((ActionData.eView==OutputView)?m_outputViews:m_selectViews); 01127 for( ; it.current(); ++it) // Iterate through all views 01128 { 01129 KDockWidget *pDockWidget=manager()->findWidgetParentDock(it.current()); // Get the DockWidget which covers the view 01130 if(pDockWidget) 01131 { 01132 KDockTabGroup *pTabGroup = pDockWidget->parentDockTabGroup(); // Get the TabGroup which belongs to pDockWidget 01133 if (pDockWidget->mayBeHide() || pTabGroup) // The window exists, if it has a TabGroup or if it can be hidden 01134 { 01135 first = manager()->findWidgetParentDock(it.current()); // Get the DockWidget which covers the view 01136 break; 01137 } 01138 } 01139 } 01140 if (!first) 01141 { 01142 if (mdiMode() == KMdi::TabPageMode) 01143 { 01144 first = manager()->findWidgetParentDock (m_partViews.first()); 01145 } 01146 if (!first) first = m_pDockbaseAreaOfDocumentViews; 01147 if (ActionData.eView == OutputView) ActionData.pDockWidget->manualDock(first,KDockWidget::DockBottom, 70); 01148 else ActionData.pDockWidget->manualDock(first,KDockWidget::DockLeft , 25); 01149 } 01150 else 01151 { 01152 ActionData.pDockWidget->manualDock(first,KDockWidget::DockCenter, 25); 01153 } 01154 } 01155 } 01156 else // It does not have a DockWidget 01157 { 01158 Q_ASSERT(0); 01159 #if 0 01160 addToolViewWindow(ActionData.eView, ActionData.pChildView, ActionData.pChildView->name(), ActionData.pChildView->name()); 01161 #endif 01162 } 01163 } 01164 } 01165 01166 01167 //=============== getPartFromWidget ===============// 01168 KParts::ReadOnlyPart * MainWindow::getPartFromWidget(const QWidget * pWidget) const 01169 { 01170 // Loop over all parts to search for a matching widget 01171 QPtrListIterator<KParts::Part> it(*(PartController::getInstance()->parts())); 01172 for ( ; it.current(); ++it) 01173 { 01174 KParts::ReadOnlyPart *ro_part = dynamic_cast<KParts::ReadOnlyPart*>(it.current()); 01175 if (ro_part->widget() == pWidget) return ro_part; 01176 } 01177 return (0L); 01178 } 01179 01180 void MainWindow::switchToToplevelMode() 01181 { 01182 if (m_mdiMode == KMdi::ToplevelMode) return; 01183 m_bUiModeSwitchPending = true; 01184 01185 m_toggleViewbar->setEnabled(true); 01186 if (mdiMode() == KMdi::TabPageMode || mdiMode() == KMdi::IDEAlMode) { 01187 slotToggleViewbar(); 01188 } 01189 KMdiMainFrm::switchToToplevelMode(); 01190 01191 m_bUiModeSwitchPending = false; 01192 updateActionState(); 01193 saveMDISettings(); 01194 } 01195 01196 void MainWindow::switchToChildframeMode() 01197 { 01198 if (m_mdiMode == KMdi::ChildframeMode) return; 01199 m_bUiModeSwitchPending = true; 01200 01201 m_toggleViewbar->setEnabled(true); 01202 if (mdiMode() == KMdi::TabPageMode || mdiMode() == KMdi::IDEAlMode) { 01203 slotToggleViewbar(); 01204 } 01205 KMdiMainFrm::switchToChildframeMode(); 01206 01207 m_bUiModeSwitchPending = false; 01208 updateActionState(); 01209 saveMDISettings(); 01210 } 01211 01212 void MainWindow::switchToTabPageMode() 01213 { 01214 if (m_mdiMode == KMdi::TabPageMode) return; 01215 m_bUiModeSwitchPending = true; 01216 01217 if (isViewTaskBarOn()) { 01218 slotToggleViewbar(); 01219 } 01220 m_toggleViewbar->setEnabled(false); 01221 KMdiMainFrm::switchToTabPageMode(); 01222 01223 m_bUiModeSwitchPending = false; 01224 updateActionState(); 01225 saveMDISettings(); 01226 } 01227 01228 void MainWindow::switchToIDEAlMode() 01229 { 01230 if (m_mdiMode == KMdi::IDEAlMode) return; 01231 m_bUiModeSwitchPending = true; 01232 01233 if (isViewTaskBarOn()) { 01234 slotToggleViewbar(); 01235 } 01236 m_toggleViewbar->setEnabled(false); 01237 KMdiMainFrm::switchToIDEAlMode(); 01238 01239 m_bUiModeSwitchPending = false; 01240 updateActionState(); 01241 saveMDISettings(); 01242 } 01243 01244 void MainWindow::slotReactToProjectOpened() 01245 { 01246 // This is a workaround for a bug in KDockWidget::readDockConfig() called above: 01247 // We must hide the unavailable views again because they are somehow shown again here 01248 // (unfortunately, we can't avoid the flickering which is a result of that show()-hide() calling) 01249 QPtrListIterator<QWidget> it(m_unavailableViews); 01250 for (; it.current(); ++it) { 01251 KDockWidget* pWrappingDockWidget = dockManager->findWidgetParentDock(*it); 01252 if (pWrappingDockWidget) { 01253 pWrappingDockWidget->hide(); 01254 pWrappingDockWidget->undock(); 01255 } 01256 } 01257 } 01258 01259 void MainWindow::slotRestoreAdditionalViewProperties(const QString& viewName, const QDomElement* viewEl) 01260 { 01261 KMdiChildView* pMDICover = m_captionDict[viewName]; 01262 if (!pMDICover) { return; } 01263 01264 // read the view position and size 01265 int nMinMaxMode = viewEl->attribute( "MinMaxMode", "0").toInt(); 01266 int nLeft = viewEl->attribute( "Left", "-10000").toInt(); // XXX hack: value -10000 wouldn't be restored correctly 01267 int nTop = viewEl->attribute( "Top", "-10000").toInt(); 01268 int nWidth = viewEl->attribute( "Width", "-1").toInt(); 01269 int nHeight = viewEl->attribute( "Height", "-1").toInt(); 01270 01271 // MDI stuff 01272 bool bAttached = (bool) viewEl->attribute( "Attach", "1").toInt(); 01273 01274 // restore appearence 01275 if ((mdiMode() != KMdi::TabPageMode) && (mdiMode() != KMdi::ToplevelMode) && (mdiMode() != KMdi::IDEAlMode)) { 01276 if ((!pMDICover->isAttached()) && (bAttached) ) { 01277 pMDICover->attach(); 01278 } 01279 if ( (pMDICover->isAttached()) && (!bAttached) ) { 01280 pMDICover->detach(); 01281 } 01282 } 01283 if (nMinMaxMode == 0) { 01284 pMDICover->setInternalGeometry(QRect(nLeft, nTop, nWidth, nHeight)); 01285 } 01286 else { 01287 if (nMinMaxMode == 1) { 01288 pMDICover->minimize(); 01289 } 01290 if (nMinMaxMode == 2) { 01291 // maximize: nothing to do, this is already under control of the mainframe 01292 } 01293 pMDICover->setRestoreGeometry(QRect(nLeft, nTop, nWidth, nHeight)); 01294 } 01295 } 01296 01297 void MainWindow::slotSaveAdditionalViewProperties(const QString& viewName, QDomElement* viewEl) 01298 { 01299 KMdiChildView* pMDICover = m_captionDict[viewName]; 01300 if (!pMDICover) { return; } 01301 01302 // write the view position and size 01303 QRect geom; 01304 int nMinMaxMode = 0; 01305 if (pMDICover->isMinimized()) { 01306 nMinMaxMode = 1; 01307 } 01308 if (pMDICover->isMaximized()) { 01309 nMinMaxMode = 2; 01310 } 01311 if (nMinMaxMode == 0) { 01312 geom = pMDICover->internalGeometry(); 01313 } 01314 else { 01315 geom = pMDICover->restoreGeometry(); 01316 } 01317 viewEl->setAttribute( "MinMaxMode", nMinMaxMode); 01318 viewEl->setAttribute( "Left", geom.left()); 01319 viewEl->setAttribute( "Top", geom.top()); 01320 viewEl->setAttribute( "Width", geom.width()); 01321 viewEl->setAttribute( "Height", geom.height()); 01322 01323 // MDI stuff 01324 viewEl->setAttribute( "Attach", pMDICover->isAttached() || (mdiMode() == KMdi::TabPageMode) || (mdiMode() == KMdi::IDEAlMode)); 01325 } 01326 01327 void MainWindow::slotToggleViewbar() 01328 { 01329 slot_toggleTaskBar(); 01330 } 01331 01332 void MainWindow::setUserInterfaceMode(const QString& uiMode) 01333 { 01334 // immediately switch the mode likely set in the uimode part 01335 if (uiMode == "Childframe") { 01336 switchToChildframeMode(); 01337 } 01338 else if (uiMode == "TabPage") { 01339 switchToTabPageMode(); 01340 } 01341 else if (uiMode == "Toplevel") { 01342 switchToToplevelMode(); 01343 } 01344 else if (uiMode == "KMDI-IDEAl") { 01345 switchToIDEAlMode(); 01346 } 01347 } 01348 01349 void MainWindow::callCommand(const QString& command) 01350 { 01351 if (isInMaximizedChildFrmMode() && (command == "qextmdi-UI: do hack on session loading finished") 01352 && (mdiMode() == KMdi::ChildframeMode)) { 01353 KMdiChildView* pLastView = 0L; 01354 KMdiChildFrm* pLastFrm = 0L; 01355 KMdiIterator<KMdiChildView*>* winListIter = createIterator(); 01356 for (winListIter->first(); !winListIter->isDone(); winListIter->next()){ 01357 pLastView = winListIter->currentItem(); 01358 if (pLastView->isAttached()) { 01359 pLastFrm = pLastView->mdiParent(); 01360 } 01361 } 01362 // evil hack (of Falk): resize the childframe again 'cause of event timing probs with resizing 01363 if (pLastFrm && pLastFrm->parentWidget()) { 01364 QApplication::sendPostedEvents(); 01365 pLastFrm->setGeometry( 01366 -KMDI_CHILDFRM_BORDER, 01367 -KMDI_CHILDFRM_BORDER - pLastFrm->captionHeight() - KMDI_CHILDFRM_SEPARATOR, 01368 pLastFrm->parentWidget()->width() + KMDI_CHILDFRM_DOUBLE_BORDER, 01369 pLastFrm->parentWidget()->height() + KMDI_CHILDFRM_SEPARATOR 01370 + KMDI_CHILDFRM_DOUBLE_BORDER + pLastFrm->captionHeight()); 01371 } 01372 delete winListIter; 01373 } 01374 } 01375 01379 void MainWindow::storeOutputViewTab() 01380 { 01393 } 01394 01395 01399 void MainWindow::restoreOutputViewTab() 01400 { 01415 } 01416 01417 void MainWindow::clearWindowMenu( ) 01418 { 01419 for (QValueList<int>::iterator it = m_windowMenus.begin(); it != m_windowMenus.end(); ++it) 01420 { 01421 m_pWindowMenu->removeItem(*it); 01422 } 01423 } 01424 01425 void MainWindow::setWindowMenu(QPopupMenu *menu) 01426 { 01427 if (m_pWindowMenu) 01428 delete m_pWindowMenu; 01429 m_pWindowMenu = menu; 01430 m_pWindowMenu->setCheckable( TRUE); 01431 QObject::connect( m_pWindowMenu, SIGNAL(aboutToShow()), this, SLOT(fillWindowMenu()) ); 01432 } 01433 01434 void MainWindow::setCaption( const QString & caption ) 01435 { 01436 KDevProject * project = API::getInstance()->project(); 01437 if ( project && !caption.isEmpty() ) 01438 { 01439 QString projectname = project->projectName(); 01440 01441 QString suffix(".kdevelop"); 01442 if ( projectname.endsWith( suffix ) ) 01443 { 01444 projectname.truncate( projectname.length() - suffix.length() ); 01445 } 01446 01447 KMdiMainFrm::setCaption( projectname + " - " + caption ); 01448 } 01449 else 01450 { 01451 KMdiMainFrm::setCaption( caption ); 01452 } 01453 } 01454 01455 void MainWindow::raiseEditor( ) 01456 { 01457 kdDebug() << k_funcinfo << endl; 01458 01459 KDevPartController * partcontroller = API::getInstance()->partController(); 01460 if ( partcontroller->activePart() && partcontroller->activePart()->widget() ) 01461 { 01462 partcontroller->activePart()->widget()->setFocus(); 01463 } 01464 } 01465 01466 #include "mainwindow.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:13 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003