kdeui Library API Documentation

kdockwidget.cpp

00001 00002 /* This file is part of the KDE libraries 00003 Copyright (C) 2000 Max Judin <novaprint@mtu-net.ru> 00004 Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 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., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 #include "kdockwidget.h" 00021 #include "kdockwidget_private.h" 00022 #include "kdockwidget_p.h" 00023 00024 #include <qapplication.h> 00025 #include <qlayout.h> 00026 #include <qpainter.h> 00027 #include <qobjectlist.h> 00028 #include <qstrlist.h> 00029 #include <qcursor.h> 00030 #include <qwidgetlist.h> 00031 #include <qtabwidget.h> 00032 #include <qtooltip.h> 00033 #include <qstyle.h> 00034 00035 #ifndef NO_KDE2 00036 #include <kconfig.h> 00037 #include <kglobal.h> 00038 #include <klocale.h> 00039 #include <ktoolbar.h> 00040 #include <kpopupmenu.h> 00041 #include <kwin.h> 00042 #include <kdebug.h> 00043 #include <kglobalsettings.h> 00044 00045 #include "config.h" 00046 #if defined Q_WS_X11 && ! defined K_WS_QTONLY 00047 #include <X11/X.h> 00048 #include <X11/Xlib.h> 00049 #endif 00050 00051 #else 00052 #include <qtoolbar.h> 00053 #include <qpopupmenu.h> 00054 #endif 00055 00056 #include <stdlib.h> 00057 00058 #undef BORDERLESS_WINDOWS 00059 00060 #define DOCK_CONFIG_VERSION "0.0.5" 00061 00062 static const char* const dockback_xpm[]={ 00063 "6 6 2 1", 00064 "# c black", 00065 ". c None", 00066 "......", 00067 ".#....", 00068 "..#..#", 00069 "...#.#", 00070 "....##", 00071 "..####"}; 00072 00073 static const char* const todesktop_xpm[]={ 00074 "5 5 2 1", 00075 "# c black", 00076 ". c None", 00077 "####.", 00078 "##...", 00079 "#.#..", 00080 "#..#.", 00081 "....#"}; 00082 00083 static const char* const not_close_xpm[]={ 00084 "5 5 2 1", 00085 "# c black", 00086 ". c None", 00087 "#####", 00088 "#...#", 00089 "#...#", 00090 "#...#", 00091 "#####"}; 00092 00102 KDockMainWindow::KDockMainWindow( QWidget* parent, const char *name, WFlags f) 00103 :KMainWindow( parent, name, f ) 00104 { 00105 QString new_name = QString(name) + QString("_DockManager"); 00106 dockManager = new KDockManager( this, new_name.latin1() ); 00107 mainDockWidget = 0L; 00108 } 00109 00110 KDockMainWindow::~KDockMainWindow() 00111 { 00112 delete dockManager; 00113 } 00114 00115 void KDockMainWindow::setMainDockWidget( KDockWidget* mdw ) 00116 { 00117 if ( mainDockWidget == mdw ) return; 00118 mainDockWidget = mdw; 00119 dockManager->setMainDockWidget2(mdw); 00120 } 00121 00122 void KDockMainWindow::setView( QWidget *view ) 00123 { 00124 if ( view->isA("KDockWidget") ){ 00125 if ( view->parent() != this ) ((KDockWidget*)view)->applyToWidget( this ); 00126 } 00127 00128 #ifndef NO_KDE2 00129 KMainWindow::setCentralWidget(view); 00130 #else 00131 QMainWindow::setCentralWidget(view); 00132 #endif 00133 } 00134 00135 KDockWidget* KDockMainWindow::createDockWidget( const QString& name, const QPixmap &pixmap, QWidget* parent, const QString& strCaption, const QString& strTabPageLabel) 00136 { 00137 return new KDockWidget( dockManager, name.latin1(), pixmap, parent, strCaption, strTabPageLabel ); 00138 } 00139 00140 void KDockMainWindow::makeDockVisible( KDockWidget* dock ) 00141 { 00142 if ( dock != 0L) 00143 dock->makeDockVisible(); 00144 } 00145 00146 void KDockMainWindow::makeDockInvisible( KDockWidget* dock ) 00147 { 00148 if ( dock != 0L) 00149 dock->undock(); 00150 } 00151 00152 void KDockMainWindow::makeWidgetDockVisible( QWidget* widget ) 00153 { 00154 makeDockVisible( dockManager->findWidgetParentDock(widget) ); 00155 } 00156 00157 void KDockMainWindow::writeDockConfig(QDomElement &base) 00158 { 00159 dockManager->writeConfig(base); 00160 } 00161 00162 void KDockMainWindow::readDockConfig(QDomElement &base) 00163 { 00164 dockManager->readConfig(base); 00165 } 00166 00167 #ifndef NO_KDE2 00168 void KDockMainWindow::writeDockConfig( KConfig* c, QString group ) 00169 { 00170 dockManager->writeConfig( c, group ); 00171 } 00172 00173 void KDockMainWindow::readDockConfig( KConfig* c, QString group ) 00174 { 00175 dockManager->readConfig( c, group ); 00176 } 00177 #endif 00178 00179 void KDockMainWindow::slotDockWidgetUndocked() 00180 { 00181 QObject* pSender = (QObject*) sender(); 00182 if (!pSender->inherits("KDockWidget")) return; 00183 KDockWidget* pDW = (KDockWidget*) pSender; 00184 emit dockWidgetHasUndocked( pDW); 00185 } 00186 00187 /*************************************************************************/ 00188 KDockWidgetAbstractHeaderDrag::KDockWidgetAbstractHeaderDrag( KDockWidgetAbstractHeader* parent, KDockWidget* dock, const char* name ) 00189 :QFrame( parent, name ) 00190 { 00191 dw = dock; 00192 installEventFilter( dock->dockManager() ); 00193 } 00194 /*************************************************************************/ 00195 KDockWidgetHeaderDrag::KDockWidgetHeaderDrag( KDockWidgetAbstractHeader* parent, KDockWidget* dock, const char* name ) 00196 :KDockWidgetAbstractHeaderDrag( parent, dock, name ) 00197 { 00198 } 00199 00200 void KDockWidgetHeaderDrag::paintEvent( QPaintEvent* ) 00201 { 00202 QPainter paint; 00203 00204 paint.begin( this ); 00205 00206 style().drawPrimitive (QStyle::PE_DockWindowHandle, &paint, QRect(0,0,width(), height()), colorGroup()); 00207 00208 paint.end(); 00209 } 00210 /*************************************************************************/ 00211 KDockWidgetAbstractHeader::KDockWidgetAbstractHeader( KDockWidget* parent, const char* name ) 00212 :QFrame( parent, name ) 00213 { 00214 } 00215 /*************************************************************************/ 00216 KDockWidgetHeader::KDockWidgetHeader( KDockWidget* parent, const char* name ) 00217 :KDockWidgetAbstractHeader( parent, name ) 00218 { 00219 #ifdef BORDERLESS_WINDOWS 00220 setCursor(QCursor(ArrowCursor)); 00221 #endif 00222 d = new KDockWidgetHeaderPrivate( this ); 00223 00224 layout = new QHBoxLayout( this ); 00225 layout->setResizeMode( QLayout::Minimum ); 00226 00227 drag = new KDockWidgetHeaderDrag( this, parent ); 00228 00229 closeButton = new KDockButton_Private( this, "DockCloseButton" ); 00230 QToolTip::add( closeButton, i18n("Close") ); 00231 closeButton->setPixmap( style().stylePixmap (QStyle::SP_TitleBarCloseButton , this)); 00232 closeButton->setFixedSize(closeButton->pixmap()->width(),closeButton->pixmap()->height()); 00233 connect( closeButton, SIGNAL(clicked()), parent, SIGNAL(headerCloseButtonClicked())); 00234 connect( closeButton, SIGNAL(clicked()), parent, SLOT(undock())); 00235 00236 stayButton = new KDockButton_Private( this, "DockStayButton" ); 00237 QToolTip::add( stayButton, i18n("Freeze the window geometry", "Freeze") ); 00238 stayButton->setToggleButton( true ); 00239 stayButton->setPixmap( const_cast< const char** >(not_close_xpm) ); 00240 stayButton->setFixedSize(closeButton->pixmap()->width(),closeButton->pixmap()->height()); 00241 connect( stayButton, SIGNAL(clicked()), this, SLOT(slotStayClicked())); 00242 00243 dockbackButton = new KDockButton_Private( this, "DockbackButton" ); 00244 QToolTip::add( dockbackButton, i18n("Dock this window", "Dock") ); 00245 dockbackButton->setPixmap( const_cast< const char** >(dockback_xpm)); 00246 dockbackButton->setFixedSize(closeButton->pixmap()->width(),closeButton->pixmap()->height()); 00247 connect( dockbackButton, SIGNAL(clicked()), parent, SIGNAL(headerDockbackButtonClicked())); 00248 connect( dockbackButton, SIGNAL(clicked()), parent, SLOT(dockBack())); 00249 00250 d->toDesktopButton = new KDockButton_Private( this, "ToDesktopButton" ); 00251 QToolTip::add( d->toDesktopButton, i18n("Detach") ); 00252 d->toDesktopButton->setPixmap( const_cast< const char** >(todesktop_xpm)); 00253 d->toDesktopButton->setFixedSize(closeButton->pixmap()->width(),closeButton->pixmap()->height()); 00254 connect( d->toDesktopButton, SIGNAL(clicked()), parent, SLOT(toDesktop())); 00255 stayButton->hide(); 00256 00257 d->dummy = new QWidget( this ); 00258 d->dummy->setFixedSize( 1,closeButton->pixmap()->height() ); 00259 00260 00261 layout->addWidget( drag ); 00262 layout->addWidget( dockbackButton ); 00263 layout->addWidget( d->toDesktopButton ); 00264 layout->addWidget( d->dummy); 00265 layout->addWidget( stayButton ); 00266 layout->addWidget( closeButton ); 00267 layout->activate(); 00268 d->dummy->hide(); 00269 drag->setFixedHeight( layout->minimumSize().height() ); 00270 } 00271 00272 void KDockWidgetHeader::setTopLevel( bool isTopLevel ) 00273 { 00274 d->topLevel = isTopLevel; 00275 if ( isTopLevel ){ 00276 KDockWidget* par = (KDockWidget*)parent(); 00277 if( par) { 00278 if( par->isDockBackPossible()) 00279 dockbackButton->show(); 00280 else 00281 dockbackButton->hide(); 00282 } 00283 stayButton->hide(); 00284 closeButton->hide(); 00285 d->toDesktopButton->hide(); 00286 drag->setEnabled( true ); 00287 } else { 00288 dockbackButton->hide(); 00289 stayButton->hide(); 00290 if (!d->forceCloseButtonHidden) closeButton->show(); 00291 if( d->showToDesktopButton ) 00292 d->toDesktopButton->show(); 00293 } 00294 layout->activate(); 00295 00296 bool dontShowDummy=drag->isVisibleTo(this) || dockbackButton->isVisibleTo(this) || 00297 d->toDesktopButton->isVisibleTo(this) || stayButton->isVisibleTo(this) || 00298 closeButton->isVisibleTo(this); 00299 for (QPtrListIterator<KDockButton_Private> it( d->btns );it.current()!=0;++it) { 00300 dontShowDummy=dontShowDummy || (it.current()->isVisibleTo(this)); 00301 } 00302 if (dontShowDummy) d->dummy->hide(); else d->dummy->show(); 00303 00304 updateGeometry(); 00305 } 00306 00307 void KDockWidgetHeader::forceCloseButtonHidden(bool hidden) { 00308 d->forceCloseButtonHidden=hidden; 00309 if (hidden) closeButton->hide(); 00310 else closeButton->show(); 00311 } 00312 00313 void KDockWidgetHeader::setDragPanel( KDockWidgetHeaderDrag* nd ) 00314 { 00315 if ( !nd ) return; 00316 00317 delete layout; 00318 layout = new QHBoxLayout( this ); 00319 layout->setResizeMode( QLayout::Minimum ); 00320 00321 delete drag; 00322 drag = nd; 00323 if (drag->parentWidget()!=this) { 00324 drag->reparent(this,QPoint(0,0)); 00325 } 00326 00327 00328 layout->addWidget( drag ); 00329 layout->addWidget( dockbackButton ); 00330 layout->addWidget( d->dummy ); 00331 layout->addWidget( d->toDesktopButton ); 00332 layout->addWidget( stayButton ); 00333 bool dontShowDummy=drag->isVisibleTo(this) || dockbackButton->isVisibleTo(this) || 00334 d->toDesktopButton->isVisibleTo(this) || stayButton->isVisibleTo(this) || 00335 closeButton->isVisibleTo(this); 00336 for (QPtrListIterator<KDockButton_Private> it( d->btns );it.current()!=0;++it) { 00337 layout->addWidget(it.current()); 00338 dontShowDummy=dontShowDummy || (it.current()->isVisibleTo(this)); 00339 } 00340 if (dontShowDummy) d->dummy->hide(); else d->dummy->show(); 00341 layout->addWidget( closeButton ); 00342 layout->activate(); 00343 kdDebug()<<"KdockWidgetHeader::setDragPanel:minimum height="<<layout->minimumSize().height()<<endl; 00344 #ifdef __GNUC__ 00345 #warning FIXME 00346 #endif 00347 drag->setFixedHeight( closeButton->height()); // /*layout->minimumS*/sizeHint().height() ); 00348 } 00349 00350 void KDockWidgetHeader::addButton(KDockButton_Private* btn) { 00351 if (!btn) return; 00352 00353 if (btn->parentWidget()!=this) { 00354 btn->reparent(this,QPoint(0,0)); 00355 } 00356 btn->setFixedSize(closeButton->pixmap()->width(),closeButton->pixmap()->height()); 00357 if (!d->btns.containsRef(btn)) d->btns.append(btn); 00358 00359 btn->show(); 00360 00361 delete layout; 00362 layout = new QHBoxLayout( this ); 00363 layout->setResizeMode( QLayout::Minimum ); 00364 00365 layout->addWidget( drag ); 00366 layout->addWidget( dockbackButton ); 00367 layout->addWidget( d->toDesktopButton ); 00368 layout->addWidget( d->dummy); 00369 layout->addWidget( stayButton ); 00370 bool dontShowDummy=drag->isVisibleTo(this) || dockbackButton->isVisibleTo(this) || 00371 d->toDesktopButton->isVisibleTo(this) || stayButton->isVisibleTo(this) || 00372 closeButton->isVisibleTo(this); 00373 for (QPtrListIterator<KDockButton_Private> it( d->btns );it.current()!=0;++it) { 00374 layout->addWidget(it.current()); 00375 dontShowDummy=dontShowDummy || (it.current()->isVisibleTo(this)); 00376 } 00377 if (dontShowDummy) d->dummy->hide(); else d->dummy->show(); 00378 layout->addWidget( closeButton ); 00379 layout->activate(); 00380 drag->setFixedHeight( layout->minimumSize().height() ); 00381 } 00382 00383 void KDockWidgetHeader::removeButton(KDockButton_Private* btn) { 00384 if (btn->parentWidget()==this) { 00385 if (d->btns.containsRef(btn)) d->btns.removeRef(btn); 00386 delete btn; 00387 } 00388 } 00389 00390 00391 void KDockWidgetHeader::slotStayClicked() 00392 { 00393 setDragEnabled(!stayButton->isOn()); 00394 } 00395 00396 bool KDockWidgetHeader::dragEnabled() const 00397 { 00398 return drag->isEnabled(); 00399 } 00400 00401 void KDockWidgetHeader::showUndockButton(bool show) 00402 { 00403 kdDebug()<<"KDockWidgetHeader::showUndockButton("<<show<<")"<<endl; 00404 if( d->showToDesktopButton == show ) 00405 return; 00406 00407 d->showToDesktopButton = show; 00408 if( !show || d->topLevel ) 00409 d->toDesktopButton->hide( ); 00410 else 00411 d->toDesktopButton->show( ); 00412 } 00413 00414 void KDockWidgetHeader::setDragEnabled(bool b) 00415 { 00416 stayButton->setOn(!b); 00417 closeButton->setEnabled(b); 00418 drag->setEnabled(b); 00419 } 00420 00421 #ifndef NO_KDE2 00422 void KDockWidgetHeader::saveConfig( KConfig* c ) 00423 { 00424 c->writeEntry( QString("%1%2").arg(parent()->name()).arg(":stayButton"), stayButton->isOn() ); 00425 } 00426 00427 void KDockWidgetHeader::loadConfig( KConfig* c ) 00428 { 00429 setDragEnabled( !c->readBoolEntry( QString("%1%2").arg(parent()->name()).arg(":stayButton"), false ) ); 00430 } 00431 #endif 00432 00433 /*************************************************************************/ 00434 00435 class KDockManager::KDockManagerPrivate 00436 { 00437 public: 00441 QRect dragRect; 00442 00446 QRect oldDragRect; 00447 00451 bool readyToDrag; 00452 00456 QPoint dragOffset; 00457 00461 bool splitterOpaqueResize; 00462 bool splitterKeepSize; 00463 bool splitterHighResolution; 00464 00465 QGuardedPtr<KDockWidget> mainDockWidget; 00466 00467 QObjectList containerDocks; 00468 00469 QGuardedPtr<KDockWidget> leftContainer; 00470 QGuardedPtr<KDockWidget> topContainer; 00471 QGuardedPtr<KDockWidget> rightContainer; 00472 QGuardedPtr<KDockWidget> bottomContainer; 00473 int m_readDockConfigMode; 00474 }; 00475 00476 00477 /*************************************************************************/ 00478 KDockWidget::KDockWidget( KDockManager* dockManager, const char* name, const QPixmap &pixmap, QWidget* parent, const QString& strCaption, const QString& strTabPageLabel, WFlags f) 00479 #ifdef BORDERLESS_WINDOWS 00480 : QWidget( parent, name, f )//| WType_Dialog | WStyle_Customize | WStyle_NoBorder ) 00481 #else 00482 : QWidget( parent, name, f ) 00483 #endif 00484 ,formerBrotherDockWidget(0L) 00485 ,currentDockPos(DockNone) 00486 ,formerDockPos(DockNone) 00487 ,widget(0L) 00488 ,pix(new QPixmap(pixmap)) 00489 ,prevSideDockPosBeforeDrag(DockNone) 00490 ,isGroup(false) 00491 { 00492 d = new KDockWidgetPrivate(); // create private data 00493 00494 d->_parent = parent; 00495 00496 layout = new QVBoxLayout( this ); 00497 layout->setResizeMode( QLayout::Minimum ); 00498 00499 manager = dockManager; 00500 manager->childDock->append( this ); 00501 installEventFilter( manager ); 00502 00503 eDocking = DockFullDocking; 00504 sDocking = DockFullSite; 00505 00506 header = 0L; 00507 setHeader( new KDockWidgetHeader( this, "AutoCreatedDockHeader" ) ); 00508 00509 if( strCaption.isNull() ) 00510 setCaption( name ); 00511 else 00512 setCaption( strCaption); 00513 00514 if( strTabPageLabel == " ") 00515 setTabPageLabel( caption()); 00516 else 00517 setTabPageLabel( strTabPageLabel); 00518 00519 isTabGroup = false; 00520 d->isContainer =false; 00521 setIcon( pixmap); 00522 widget = 0L; 00523 00524 QObject::connect(this, SIGNAL(hasUndocked()), manager->main, SLOT(slotDockWidgetUndocked()) ); 00525 applyToWidget( parent, QPoint(0,0) ); 00526 } 00527 00528 void KDockWidget::setPixmap(const QPixmap& pixmap) { 00529 delete pix; 00530 pix=new QPixmap(pixmap); 00531 setIcon(*pix); 00532 KDockTabGroup *dtg=parentDockTabGroup(); 00533 if (dtg) 00534 dtg->changeTab(this,pixmap,dtg->tabLabel(this)); 00535 QWidget *contWid=parentDockContainer(); 00536 if (contWid) { 00537 KDockContainer *x = dynamic_cast<KDockContainer*>(contWid); 00538 if (x) { 00539 x->setPixmap(this,pixmap); 00540 } 00541 } 00542 } 00543 00544 const QPixmap& KDockWidget::pixmap() const { 00545 return *pix; 00546 } 00547 00548 KDockWidget::~KDockWidget() 00549 { 00550 d->pendingDtor = true; 00551 if ( !manager->undockProcess ){ 00552 d->blockHasUndockedSignal = true; 00553 undock(); 00554 d->blockHasUndockedSignal = false; 00555 } 00556 00557 if (latestKDockContainer()) { 00558 KDockContainer *x = dynamic_cast<KDockContainer*>(latestKDockContainer()); 00559 if (x) { 00560 x->removeWidget(this); 00561 } 00562 } 00563 emit iMBeingClosed(); 00564 if (manager->d) manager->d->containerDocks.remove(this); 00565 manager->childDock->remove( this ); 00566 delete pix; 00567 delete d; // destroy private data 00568 d=0; 00569 } 00570 00571 void KDockWidget::paintEvent(QPaintEvent* pe) 00572 { 00573 QWidget::paintEvent(pe); 00574 QPainter paint; 00575 paint.begin( this ); 00576 style().drawPrimitive (QStyle::PE_Panel, &paint, QRect(0,0,width(), height()), colorGroup()); 00577 paint.end(); 00578 } 00579 00580 void KDockWidget::leaveEvent(QEvent *e) 00581 { 00582 QWidget::leaveEvent(e); 00583 #ifdef BORDERLESS_WINDOWS 00584 if (parent()) return; 00585 // setCursor(QCursor(ArrowCursor)); 00586 #endif 00587 } 00588 00589 void KDockWidget::mousePressEvent(QMouseEvent* mme) 00590 { 00591 #ifdef BORDERLESS_WINDOWS 00592 if (!parent()) 00593 { 00594 kdDebug()<<"KDockWidget::mousePressEvent"<<endl; 00595 00596 bool bbottom; 00597 bool bleft; 00598 bool bright; 00599 bool btop; 00600 int styleheight; 00601 QPoint mp; 00602 mp=mme->pos(); 00603 styleheight=2*style().pixelMetric(QStyle::PM_DefaultFrameWidth,this); 00604 bbottom=mp.y()>=height()-styleheight; 00605 btop=mp.y()<=styleheight; 00606 bleft=mp.x()<=styleheight; 00607 bright=mp.x()>=width()-styleheight; 00608 kdDebug()<<"mousemovevent"<<endl; 00609 d->resizing=true; 00610 if (bright) 00611 { 00612 if (btop) 00613 { 00614 d->resizeMode=KDockWidgetPrivate::ResizeTopRight; 00615 d->resizePos=QPoint(width(),0)-mme->pos(); 00616 00617 } 00618 else 00619 { 00620 d->resizePos=QPoint(width(),height())-mme->pos(); 00621 if (bbottom) d->resizeMode=KDockWidgetPrivate::ResizeBottomRight; 00622 else d->resizeMode=KDockWidgetPrivate::ResizeRight; 00623 } 00624 } 00625 else if (bleft) 00626 { 00627 if (btop) setCursor(QCursor(SizeFDiagCursor)); 00628 else 00629 if (bbottom) setCursor(QCursor(SizeBDiagCursor)); 00630 else setCursor(QCursor(SizeHorCursor)); 00631 } 00632 else 00633 if (bbottom) 00634 { 00635 d->resizeMode=KDockWidgetPrivate::ResizeBottom; 00636 d->resizePos=QPoint(0,height())-mme->pos(); 00637 } 00638 else 00639 if (btop) setCursor(QCursor(SizeVerCursor)); 00640 else d->resizing=false; 00641 00642 if (d->resizing) grabMouse(cursor()); 00643 00644 } 00645 #endif 00646 QWidget::mousePressEvent(mme); 00647 } 00648 00649 void KDockWidget::mouseReleaseEvent(QMouseEvent* ev) 00650 { 00651 #ifdef BORDERLESS_WINDOWS 00652 d->resizing=false; 00653 releaseMouse(); 00654 #endif 00655 QWidget::mouseReleaseEvent(ev); 00656 } 00657 00658 void KDockWidget::mouseMoveEvent(QMouseEvent* mme) 00659 { 00660 QWidget::mouseMoveEvent(mme); 00661 #ifdef BORDERLESS_WINDOWS 00662 if (parent()) return; 00663 00664 if (d->resizing) 00665 { 00666 switch (d->resizeMode) 00667 { 00668 case KDockWidgetPrivate::ResizeRight: 00669 resize(mme->pos().x()+d->resizePos.x(),height()); 00670 break; 00671 case KDockWidgetPrivate::ResizeBottomRight: 00672 resize(mme->pos().x()+d->resizePos.x(),mme->pos().y()+d->resizePos.y()); 00673 break; 00674 case KDockWidgetPrivate::ResizeBottom: 00675 resize(width(),mme->pos().y()+d->resizePos.y()); 00676 break; 00677 default: 00678 break; 00679 } 00680 return; 00681 } 00682 00683 00684 bool bbottom; 00685 bool bleft; 00686 bool bright; 00687 bool btop; 00688 int styleheight; 00689 QPoint mp; 00690 mp=mme->pos(); 00691 styleheight=2*style().pixelMetric(QStyle::PM_DefaultFrameWidth,this); 00692 bbottom=mp.y()>=height()-styleheight; 00693 btop=mp.y()<=styleheight; 00694 bleft=mp.x()<=styleheight; 00695 bright=mp.x()>=width()-styleheight; 00696 kdDebug()<<"mousemovevent"<<endl; 00697 if (bright) 00698 { 00699 if (btop) setCursor(QCursor(SizeBDiagCursor)); 00700 else 00701 if (bbottom) setCursor(QCursor(SizeFDiagCursor)); 00702 else setCursor(QCursor(SizeHorCursor)); 00703 } 00704 else if (bleft) 00705 { 00706 if (btop) setCursor(QCursor(SizeFDiagCursor)); 00707 else 00708 if (bbottom) setCursor(QCursor(SizeBDiagCursor)); 00709 else setCursor(QCursor(SizeHorCursor)); 00710 } 00711 else 00712 if (bbottom || btop) setCursor(QCursor(SizeVerCursor)); 00713 else setCursor(QCursor(ArrowCursor)); 00714 #endif 00715 } 00716 00717 void KDockWidget::setLatestKDockContainer(QWidget* container) 00718 { 00719 if (container) 00720 { 00721 if (dynamic_cast<KDockContainer*>(container)) 00722 d->container=container; 00723 else 00724 d->container=0; 00725 } 00726 } 00727 00728 QWidget* KDockWidget::latestKDockContainer() 00729 { 00730 if (!(d->container)) return 0; 00731 if (dynamic_cast<KDockContainer*>(d->container.operator->())) return d->container; 00732 return 0; 00733 } 00734 00735 00736 00737 KDockWidgetAbstractHeader *KDockWidget::getHeader() { 00738 return header; 00739 } 00740 00741 void KDockWidget::setHeader( KDockWidgetAbstractHeader* h ) 00742 { 00743 if ( !h ) return; 00744 00745 if ( header ){ 00746 delete header; 00747 delete layout; 00748 header = h; 00749 layout = new QVBoxLayout( this ); 00750 layout->setResizeMode( QLayout::Minimum ); 00751 layout->addWidget( header ); 00752 setWidget( widget ); 00753 } else { 00754 header = h; 00755 layout->addWidget( header ); 00756 } 00757 kdDebug()<<caption()<<": KDockWidget::setHeader"<<endl; 00758 setEnableDocking(eDocking); 00759 } 00760 00761 void KDockWidget::setEnableDocking( int pos ) 00762 { 00763 eDocking = pos; 00764 if( header && header->inherits( "KDockWidgetHeader" ) ) 00765 ( ( KDockWidgetHeader* ) header )->showUndockButton( pos & DockDesktop ); 00766 updateHeader(); 00767 } 00768 00769 void KDockWidget::updateHeader() 00770 { 00771 if ( parent() ){ 00772 #ifdef BORDERLESS_WINDOWS 00773 layout->setMargin(0); 00774 setMouseTracking(false); 00775 setCursor(QCursor(ArrowCursor)); 00776 #endif 00777 00778 if ( (parent() == manager->main) || isGroup || (eDocking == KDockWidget::DockNone) ){ 00779 header->hide(); 00780 } else { 00781 header->setTopLevel( false ); 00782 if (widget && dynamic_cast<KDockContainer*>(widget)) 00783 header->hide(); 00784 else 00785 header->show(); 00786 } 00787 } else { 00788 header->setTopLevel( true ); 00789 header->show(); 00790 #ifdef BORDERLESS_WINDOWS 00791 layout->setMargin(2*style().pixelMetric(QStyle::PM_DefaultFrameWidth,this)); 00792 setMouseTracking(true); 00793 #endif 00794 } 00795 } 00796 00797 void KDockWidget::applyToWidget( QWidget* s, const QPoint& p ) 00798 { 00799 if ( parent() != s ) 00800 { 00801 hide(); 00802 reparent(s, 0, QPoint(0,0), false); 00803 } 00804 00805 if ( s && s->inherits("KDockMainWindow") ){ 00806 ((KDockMainWindow*)s)->setView( this ); 00807 } 00808 00809 if ( manager && s == manager->main ){ 00810 setGeometry( QRect(QPoint(0,0), manager->main->geometry().size()) ); 00811 } 00812 00813 if ( !s ) 00814 { 00815 move(p); 00816 00817 #ifndef NO_KDE2 00818 #if defined Q_WS_X11 && ! defined K_WS_QTONLY 00819 if (d->transient && d->_parent) 00820 XSetTransientForHint( qt_xdisplay(), winId(), d->_parent->winId() ); 00821 00822 #ifdef BORDERLESS_WINDOWS 00823 KWin::setType( winId(), NET::Override); //d->windowType ); 00824 // setWFlags(WStyle_Customize | WStyle_NoBorder | WStyle_Tool); 00825 #else 00826 KWin::setType( winId(), d->windowType ); 00827 #endif // BORDERLESS_WINDOW 00828 #endif // Q_WS_X11 && ! K_WS_QTONLY 00829 #endif 00830 00831 } 00832 updateHeader(); 00833 00834 setIcon(*pix); 00835 } 00836 00837 void KDockWidget::show() 00838 { 00839 if ( parent() || manager->main->isVisible() ) 00840 if ( !parent() ){ 00841 emit manager->setDockDefaultPos( this ); 00842 emit setDockDefaultPos(); 00843 if ( parent() ){ 00844 makeDockVisible(); 00845 } else { 00846 QWidget::show(); 00847 } 00848 } else { 00849 QWidget::show(); 00850 } 00851 } 00852 00853 #ifndef NO_KDE2 00854 00855 void KDockWidget::setDockWindowType (NET::WindowType windowType) 00856 { 00857 d->windowType = windowType; 00858 applyToWidget( parentWidget(), QPoint(0,0) ); 00859 } 00860 00861 #endif 00862 00863 void KDockWidget::setDockWindowTransient (QWidget *parent, bool transientEnabled) 00864 { 00865 d->_parent = parent; 00866 d->transient = transientEnabled; 00867 applyToWidget( parentWidget(), QPoint(0,0) ); 00868 } 00869 00870 QWidget *KDockWidget::transientTo() { 00871 if (d->transient && d->_parent) return d->_parent; else return 0; 00872 } 00873 00874 bool KDockWidget::event( QEvent *event ) 00875 { 00876 switch ( event->type() ) 00877 { 00878 #undef FocusIn 00879 case QEvent::FocusIn: 00880 if (widget && !d->pendingFocusInEvent) { 00881 d->pendingFocusInEvent = true; 00882 widget->setFocus(); 00883 } 00884 d->pendingFocusInEvent = false; 00885 break; 00886 case QEvent::ChildRemoved: 00887 if ( widget == ((QChildEvent*)event)->child() ) widget = 0L; 00888 break; 00889 case QEvent::Show: 00890 if ( widget ) widget->show(); 00891 emit manager->change(); 00892 break; 00893 case QEvent::Hide: 00894 if ( widget ) widget->hide(); 00895 emit manager->change(); 00896 break; 00897 case QEvent::CaptionChange: 00898 if ( parentWidget() ){ 00899 if ( parent()->inherits("KDockSplitter") ){ 00900 ((KDockSplitter*)(parent()))->updateName(); 00901 } 00902 if ( parentDockTabGroup() ){ 00903 setDockTabName( parentDockTabGroup() ); 00904 parentDockTabGroup()->setTabLabel( this, tabPageLabel() ); 00905 } 00906 } 00907 break; 00908 case QEvent::Close: 00909 emit iMBeingClosed(); 00910 break; 00911 default: 00912 break; 00913 } 00914 return QWidget::event( event ); 00915 } 00916 00917 KDockWidget *KDockWidget::findNearestDockWidget(DockPosition pos) 00918 { 00919 if (!parent()) return 0; 00920 if (!parent()->inherits("KDockSplitter")) return 0; 00921 Orientation orientation=((pos==DockLeft) || (pos==DockRight)) ? Vertical:Horizontal; 00922 if (((KDockSplitter*)(parent()))->orientation()==orientation) 00923 { 00924 KDockWidget *neighbor= 00925 ((pos==DockLeft)||(pos==DockTop))? 00926 static_cast<KDockWidget*>(((KDockSplitter*)(parent()))->getFirst()): 00927 static_cast<KDockWidget*>(((KDockSplitter*)(parent()))->getLast()); 00928 00929 if (neighbor==this) 00930 return (static_cast<KDockWidget*>(parent()->parent())->findNearestDockWidget(pos)); 00931 else 00932 if (neighbor->getWidget() && (neighbor->getWidget()->qt_cast("KDockTabGroup"))) 00933 return (KDockWidget*)(((KDockTabGroup*)neighbor->getWidget())->page(0)); 00934 else 00935 return neighbor; 00936 } 00937 else 00938 return (static_cast<KDockWidget*>(parent()->parent())->findNearestDockWidget(pos)); 00939 00940 return 0; 00941 } 00942 00943 00944 KDockWidget* KDockWidget::manualDock( KDockWidget* target, DockPosition dockPos, int spliPos, QPoint pos, bool check, int tabIndex ) 00945 { 00946 if (this == target) 00947 return 0L; // docking to itself not possible 00948 // kdDebug()<<"manualDock called "<<endl; 00949 bool succes = true; // tested flag 00950 00951 // check allowed this dock submit this operations 00952 if ( !(eDocking & (int)dockPos) ){ 00953 succes = false; 00954 // kdDebug()<<"KDockWidget::manualDock(): success = false (1)"<<endl; 00955 } 00956 00957 KDockWidget *tmpTarget; 00958 switch (dockPos) { 00959 case DockLeft:tmpTarget=dockManager()->d->leftContainer; 00960 break; 00961 case DockRight:tmpTarget=dockManager()->d->rightContainer; 00962 break; 00963 case DockBottom:tmpTarget=dockManager()->d->bottomContainer; 00964 break; 00965 case DockTop:tmpTarget=dockManager()->d->topContainer; 00966 break; 00967 default: tmpTarget=0; 00968 } 00969 00970 if (this!=tmpTarget) { 00971 if (target && (target==dockManager()->d->mainDockWidget) && tmpTarget) { 00972 return manualDock(tmpTarget,DockCenter,spliPos,pos,check,tabIndex); 00973 } 00974 } 00975 00976 // check allowed target submit this operations 00977 if ( target && !(target->sDocking & (int)dockPos) ){ 00978 succes = false; 00979 // kdDebug()<<"KDockWidget::manualDock(): success = false (2)"<<endl; 00980 } 00981 00982 if ( parent() && !parent()->inherits("KDockSplitter") && !parentDockTabGroup() && 00983 !(dynamic_cast<KDockContainer*>(parent())) && !parentDockContainer()){ 00984 // kdDebug()<<"KDockWidget::manualDock(): success = false (3)"<<endl; 00985 // kdDebug()<<parent()->name()<<endl; 00986 succes = false; 00987 } 00988 00989 // kdDebug()<<"KDockWidget::manualDock(): success == false "<<endl; 00990 if ( !succes ){ 00991 // try to make another manualDock 00992 KDockWidget* dock_result = 0L; 00993 if ( target && !check ){ 00994 KDockWidget::DockPosition another__dockPos = KDockWidget::DockNone; 00995 switch ( dockPos ){ 00996 case KDockWidget::DockLeft : another__dockPos = KDockWidget::DockRight ; break; 00997 case KDockWidget::DockRight : another__dockPos = KDockWidget::DockLeft ; break; 00998 case KDockWidget::DockTop : another__dockPos = KDockWidget::DockBottom; break; 00999 case KDockWidget::DockBottom: another__dockPos = KDockWidget::DockTop ; break; 01000 default: break; 01001 } 01002 dock_result = target->manualDock( this, another__dockPos, spliPos, pos, true, tabIndex ); 01003 } 01004 return dock_result; 01005 } 01006 // end check block 01007 01008 d->blockHasUndockedSignal = true; 01009 undock(); 01010 d->blockHasUndockedSignal = false; 01011 01012 if ( !target ){ 01013 move( pos ); 01014 show(); 01015 emit manager->change(); 01016 return this; 01017 } 01018 01019 // kdDebug()<<"Looking for KDockTabGroup"<<endl; 01020 KDockTabGroup* parentTab = target->parentDockTabGroup(); 01021 if ( parentTab ){ 01022 // add to existing TabGroup 01023 applyToWidget( parentTab ); 01024 parentTab->insertTab( this, icon() ? *icon() : QPixmap(), 01025 tabPageLabel(), tabIndex ); 01026 01027 QWidget *wantTransient=parentTab->transientTo(); 01028 target->setDockWindowTransient(wantTransient,wantTransient); 01029 01030 setDockTabName( parentTab ); 01031 if( !toolTipStr.isEmpty()) 01032 parentTab->setTabToolTip( this, toolTipStr); 01033 01034 currentDockPos = KDockWidget::DockCenter; 01035 emit manager->change(); 01036 return (KDockWidget*)parentTab->parent(); 01037 } 01038 else 01039 { 01040 // kdDebug()<<"Looking for KDockContainer"<<endl; 01041 QWidget *contWid=target->parentDockContainer(); 01042 if (!contWid) contWid=target->widget; 01043 if (contWid) 01044 { 01045 KDockContainer *cont=dynamic_cast<KDockContainer*>(contWid); 01046 if (cont) 01047 { 01048 if (latestKDockContainer() && (latestKDockContainer()!=contWid)) { 01049 KDockContainer* dc = dynamic_cast<KDockContainer*>(latestKDockContainer()); 01050 if (dc) { 01051 dc->removeWidget(this); 01052 } 01053 } 01054 // kdDebug()<<"KDockContainerFound"<<endl; 01055 applyToWidget( contWid ); 01056 cont->insertWidget( this, icon() ? *icon() : QPixmap(), 01057 tabPageLabel(), tabIndex ); 01058 setLatestKDockContainer(contWid); 01059 // setDockTabName( parentTab ); 01060 if( !toolTipStr.isEmpty()) 01061 cont->setToolTip( this, toolTipStr); 01062 01063 currentDockPos = KDockWidget::DockCenter; 01064 emit manager->change(); 01065 return (KDockWidget*)(cont->parentDockWidget()); 01066 01067 } 01068 } 01069 } 01070 01071 // create a new dockwidget that will contain the target and this 01072 QWidget* parentDock = target->parentWidget(); 01073 KDockWidget* newDock = new KDockWidget( manager, "tempName", QPixmap(""), parentDock ); 01074 newDock->currentDockPos = target->currentDockPos; 01075 01076 if ( dockPos == KDockWidget::DockCenter ){ 01077 newDock->isTabGroup = true; 01078 } else { 01079 newDock->isGroup = true; 01080 } 01081 newDock->eDocking = (target->eDocking & eDocking) & (~(int)KDockWidget::DockCenter); 01082 01083 newDock->applyToWidget( parentDock ); 01084 01085 if ( !parentDock ){ 01086 // dock to a toplevel dockwidget means newDock is toplevel now 01087 newDock->move( target->frameGeometry().topLeft() ); 01088 newDock->resize( target->geometry().size() ); 01089 if ( target->isVisibleToTLW() ) newDock->show(); 01090 } 01091 01092 // redirect the dockback button to the new dockwidget 01093 if( target->formerBrotherDockWidget != 0L) { 01094 newDock->setFormerBrotherDockWidget(target->formerBrotherDockWidget); 01095 if( formerBrotherDockWidget != 0L) 01096 target->loseFormerBrotherDockWidget(); 01097 } 01098 newDock->formerDockPos = target->formerDockPos; 01099 01100 01101 // HERE SOMETING CREATING CONTAINERS SHOULD BE ADDED !!!!! 01102 if ( dockPos == KDockWidget::DockCenter ) 01103 { 01104 KDockTabGroup* tab = new KDockTabGroup( newDock, "_dock_tab"); 01105 QObject::connect(tab, SIGNAL(currentChanged(QWidget*)), d, SLOT(slotFocusEmbeddedWidget(QWidget*))); 01106 newDock->setWidget( tab ); 01107 01108 target->applyToWidget( tab ); 01109 applyToWidget( tab ); 01110 01111 01112 tab->insertTab( target, target->icon() ? *(target->icon()) : QPixmap(), 01113 target->tabPageLabel() ); 01114 01115 01116 01117 if( !target->toolTipString().isEmpty()) 01118 tab->setTabToolTip( target, target->toolTipString()); 01119 01120 tab->insertTab( this, icon() ? *icon() : QPixmap(), 01121 tabPageLabel(), tabIndex ); 01122 01123 QRect geom=newDock->geometry(); 01124 QWidget *wantTransient=tab->transientTo(); 01125 newDock->setDockWindowTransient(wantTransient,wantTransient); 01126 newDock->setGeometry(geom); 01127 01128 if( !toolTipString().isEmpty()) 01129 tab->setTabToolTip( this, toolTipString()); 01130 01131 setDockTabName( tab ); 01132 tab->show(); 01133 01134 currentDockPos = DockCenter; 01135 target->formerDockPos = target->currentDockPos; 01136 target->currentDockPos = DockCenter; 01137 } 01138 else { 01139 // if to dock not to the center of the target dockwidget, 01140 // dock to newDock 01141 KDockSplitter* panner = 0L; 01142 if ( dockPos == KDockWidget::DockTop || dockPos == KDockWidget::DockBottom ) panner = new KDockSplitter( newDock, "_dock_split_", Horizontal, spliPos, manager->splitterHighResolution() ); 01143 if ( dockPos == KDockWidget::DockLeft || dockPos == KDockWidget::DockRight ) panner = new KDockSplitter( newDock, "_dock_split_", Vertical , spliPos, manager->splitterHighResolution() ); 01144 newDock->setWidget( panner ); 01145 01146 panner->setOpaqueResize(manager->splitterOpaqueResize()); 01147 panner->setKeepSize(manager->splitterKeepSize()); 01148 panner->setFocusPolicy( NoFocus ); 01149 target->applyToWidget( panner ); 01150 applyToWidget( panner ); 01151 target->formerDockPos = target->currentDockPos; 01152 if ( dockPos == KDockWidget::DockRight) { 01153 panner->activate( target, this ); 01154 currentDockPos = KDockWidget::DockRight; 01155 target->currentDockPos = KDockWidget::DockLeft; 01156 } 01157 else if( dockPos == KDockWidget::DockBottom) { 01158 panner->activate( target, this ); 01159 currentDockPos = KDockWidget::DockBottom; 01160 target->currentDockPos = KDockWidget::DockTop; 01161 } 01162 else if( dockPos == KDockWidget::DockTop) { 01163 panner->activate( this, target ); 01164 currentDockPos = KDockWidget::DockTop; 01165 target->currentDockPos = KDockWidget::DockBottom; 01166 } 01167 else if( dockPos == KDockWidget::DockLeft) { 01168 panner->activate( this, target ); 01169 currentDockPos = KDockWidget::DockLeft; 01170 target->currentDockPos = KDockWidget::DockRight; 01171 } 01172 target->show(); 01173 show(); 01174 panner->show(); 01175 } 01176 01177 if ( parentDock ){ 01178 if ( parentDock->inherits("KDockSplitter") ){ 01179 KDockSplitter* sp = (KDockSplitter*)parentDock; 01180 sp->deactivate(); 01181 if ( sp->getFirst() == target ) 01182 sp->activate( newDock, 0L ); 01183 else 01184 sp->activate( 0L, newDock ); 01185 } 01186 } 01187 01188 newDock->show(); 01189 emit target->docking( this, dockPos ); 01190 emit manager->replaceDock( target, newDock ); 01191 emit manager->change(); 01192 01193 return newDock; 01194 } 01195 01196 KDockTabGroup* KDockWidget::parentDockTabGroup() const 01197 { 01198 if ( !parent() ) return 0L; 01199 QWidget* candidate = parentWidget()->parentWidget(); 01200 if ( candidate && candidate->inherits("KDockTabGroup") ) return (KDockTabGroup*)candidate; 01201 return 0L; 01202 } 01203 01204 QWidget *KDockWidget::parentDockContainer() const 01205 { 01206 if (!parent()) return 0L; 01207 QWidget* candidate = parentWidget()->parentWidget(); 01208 if (candidate && dynamic_cast<KDockContainer*>(candidate)) return candidate; 01209 return 0L; 01210 } 01211 01212 01213 void KDockWidget::setForcedFixedWidth(int w) 01214 { 01215 d->forcedWidth=w; 01216 setFixedWidth(w); 01217 if (!parent()) return; 01218 if (parent()->inherits("KDockSplitter")) 01219 static_cast<KDockSplitter*>(parent()->qt_cast("KDockSplitter"))->setForcedFixedWidth(this,w); 01220 } 01221 01222 void KDockWidget::setForcedFixedHeight(int h) 01223 { 01224 d->forcedHeight=h; 01225 setFixedHeight(h); 01226 if (!parent()) return; 01227 if (parent()->inherits("KDockSplitter")) 01228 static_cast<KDockSplitter*>(parent()->qt_cast("KDockSplitter"))->setForcedFixedHeight(this,h); 01229 } 01230 01231 int KDockWidget::forcedFixedWidth() 01232 { 01233 return d->forcedWidth; 01234 } 01235 01236 int KDockWidget::forcedFixedHeight() 01237 { 01238 return d->forcedHeight; 01239 } 01240 01241 void KDockWidget::restoreFromForcedFixedSize() 01242 { 01243 d->forcedWidth=-1; 01244 setMinimumWidth(0); 01245 setMaximumWidth(32000); 01246 setMinimumHeight(0); 01247 setMaximumHeight(32000); 01248 if (!parent()) return; 01249 if (parent()->inherits("KDockSplitter")) 01250 static_cast<KDockSplitter*>(parent()->qt_cast("KDockSplitter"))->restoreFromForcedFixedSize(this); 01251 } 01252 01253 void KDockWidget::toDesktop() 01254 { 01255 QPoint p = mapToGlobal( QPoint( -30, -30 ) ); 01256 if( p.x( ) < 0 ) 01257 p.setX( 0 ); 01258 if( p.y( ) < 0 ) 01259 p.setY( 0 ); 01260 manualDock( 0, DockDesktop, 50, p ); 01261 } 01262 01263 KDockWidget::DockPosition KDockWidget::currentDockPosition() const 01264 { 01265 return currentDockPos; 01266 } 01267 01268 void KDockWidget::undock() 01269 { 01270 // kdDebug()<<"KDockWidget::undock()"<<endl; 01271 01272 manager->d->dragRect = QRect (); 01273 manager->drawDragRectangle (); 01274 01275 QWidget* parentW = parentWidget(); 01276 if ( !parentW ){ 01277 hide(); 01278 if (!d->blockHasUndockedSignal) 01279 emit hasUndocked(); 01280 return; 01281 } 01282 01283 formerDockPos = currentDockPos; 01284 currentDockPos = KDockWidget::DockDesktop; 01285 01286 manager->blockSignals(true); 01287 manager->undockProcess = true; 01288 01289 bool isV = parentW->isVisibleToTLW(); 01290 01291 //UNDOCK HAS TO BE IMPLEMENTED CORRECTLY :) 01292 KDockTabGroup* parentTab = parentDockTabGroup(); 01293 if ( parentTab ){ 01294 d->index = parentTab->indexOf( this); // memorize the page position in the tab widget 01295 parentTab->removePage( this ); 01296 /* 01297 QWidget *wantTransient=parentTab->transientTo(); 01298 target->setDockWindowTransient(wantTransient,wantTransient); 01299 */ 01300 setFormerBrotherDockWidget((KDockWidget*)parentTab->page(0)); 01301 applyToWidget( 0L ); 01302 if ( parentTab->count() == 1 ){ 01303 01304 // last subdock widget in the tab control 01305 KDockWidget* lastTab = (KDockWidget*)parentTab->page(0); 01306 parentTab->removePage( lastTab ); 01307 /* QWidget *wantTransient=parentTab->transientTo(); 01308 target->setDockWindowTransient(wantTransient,wantTransient);*/ 01309 01310 lastTab->applyToWidget( 0L ); 01311 lastTab->move( parentTab->mapToGlobal(parentTab->frameGeometry().topLeft()) ); 01312 01313 // KDockTabGroup always have a parent that is a KDockWidget 01314 KDockWidget* parentOfTab = (KDockWidget*)parentTab->parent(); 01315 delete parentTab; // KDockTabGroup 01316 01317 QWidget* parentOfDockWidget = parentOfTab->parentWidget(); 01318 if ( parentOfDockWidget == 0L ){ 01319 if ( isV ) lastTab->show(); 01320 } else { 01321 if ( parentOfDockWidget->inherits("KDockSplitter") ){ 01322 KDockSplitter* split = (KDockSplitter*)parentOfDockWidget; 01323 lastTab->applyToWidget( split ); 01324 split->deactivate(); 01325 if ( split->getFirst() == parentOfTab ){ 01326 split->activate( lastTab ); 01327 if ( ((KDockWidget*)split->parent())->splitterOrientation == Vertical ) 01328 emit ((KDockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockLeft ); 01329 else 01330 emit ((KDockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockTop ); 01331 } else { 01332 split->activate( 0L, lastTab ); 01333 if ( ((KDockWidget*)split->parent())->splitterOrientation == Vertical ) 01334 emit ((KDockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockRight ); 01335 else 01336 emit ((KDockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockBottom ); 01337 } 01338 split->show(); 01339 } else { 01340 lastTab->applyToWidget( parentOfDockWidget ); 01341 } 01342 lastTab->show(); 01343 } 01344 manager->blockSignals(false); 01345 emit manager->replaceDock( parentOfTab, lastTab ); 01346 lastTab->currentDockPos = parentOfTab->currentDockPos; 01347 emit parentOfTab->iMBeingClosed(); 01348 manager->blockSignals(true); 01349 delete parentOfTab; 01350 01351 } else { 01352 setDockTabName( parentTab ); 01353 } 01354 } else { 01355 /*********************************************************************************************/ 01356 //QWidget* containerWidget = (QWidget*)parent(); 01357 bool undockedFromContainer=false; 01358 if (d->container) 01359 { 01360 // kdDebug()<<"undocked from dockcontainer"<<endl; 01361 undockedFromContainer=true; 01362 KDockContainer* dc = dynamic_cast<KDockContainer*>(d->container.operator->()); 01363 if (dc) { 01364 dc->undockWidget(this); 01365 setFormerBrotherDockWidget(dc->parentDockWidget()); 01366 } 01367 applyToWidget( 0L ); 01368 } 01369 if (!undockedFromContainer) { 01370 /*********************************************************************************************/ 01371 if ( parentW->inherits("KDockSplitter") ){ 01372 KDockSplitter* parentSplitterOfDockWidget = (KDockSplitter*)parentW; 01373 d->splitPosInPercent = parentSplitterOfDockWidget->separatorPos(); 01374 01375 KDockWidget* secondWidget = (KDockWidget*)parentSplitterOfDockWidget->getAnother( this ); 01376 KDockWidget* group = (KDockWidget*)parentSplitterOfDockWidget->parentWidget(); 01377 setFormerBrotherDockWidget(secondWidget); 01378 applyToWidget( 0L ); 01379 group->hide(); 01380 01381 if ( !group->parentWidget() ){ 01382 secondWidget->applyToWidget( 0L, group->frameGeometry().topLeft() ); 01383 secondWidget->resize( group->width(), group->height() ); 01384 } else { 01385 QWidget* obj = group->parentWidget(); 01386 secondWidget->applyToWidget( obj ); 01387 if ( obj->inherits("KDockSplitter") ){ 01388 KDockSplitter* parentOfGroup = (KDockSplitter*)obj; 01389 parentOfGroup->deactivate(); 01390 01391 if ( parentOfGroup->getFirst() == group ) 01392 parentOfGroup->activate( secondWidget ); 01393 else 01394 parentOfGroup->activate( 0L, secondWidget ); 01395 } 01396 } 01397 secondWidget->currentDockPos = group->currentDockPos; 01398 secondWidget->formerDockPos = group->formerDockPos; 01399 delete parentSplitterOfDockWidget; 01400 manager->blockSignals(false); 01401 emit manager->replaceDock( group, secondWidget ); 01402 emit group->iMBeingClosed(); 01403 manager->blockSignals(true); 01404 delete group; 01405 01406 if ( isV ) secondWidget->show(); 01407 } else { 01408 if (!d->pendingDtor) { 01409 // don't reparent in the dtor of this 01410 applyToWidget( 0L ); 01411 } 01412 } 01413 /*********************************************************************************************/ 01414 } 01415 } 01416 manager->blockSignals(false); 01417 if (!d->blockHasUndockedSignal) 01418 emit manager->change(); 01419 manager->undockProcess = false; 01420 01421 if (!d->blockHasUndockedSignal) 01422 emit hasUndocked(); 01423 } 01424 01425 void KDockWidget::setWidget( QWidget* mw ) 01426 { 01427 if ( !mw ) return; 01428 01429 if ( mw->parent() != this ){ 01430 mw->reparent(this, 0, QPoint(0,0), false); 01431 } 01432 01433 #ifdef BORDERLESS_WINDOWS 01434 if (!mw->ownCursor()) mw->setCursor(QCursor(ArrowCursor)); 01435 #endif 01436 widget = mw; 01437 delete layout; 01438 01439 layout = new QVBoxLayout( this ); 01440 layout->setResizeMode( QLayout::Minimum ); 01441 01442 KDockContainer* dc = dynamic_cast<KDockContainer*>(widget); 01443 if (dc) 01444 { 01445 d->isContainer=true; 01446 manager->d->containerDocks.append(this); 01447 } 01448 else 01449 { 01450 d->isContainer=false; 01451 } 01452 01453 { 01454 header->show(); 01455 layout->addWidget( header ); 01456 layout->addWidget( widget,1 ); 01457 } 01458 updateHeader(); 01459 emit widgetSet(mw); 01460 } 01461 01462 void KDockWidget::setDockTabName( KDockTabGroup* tab ) 01463 { 01464 QString listOfName; 01465 QString listOfCaption; 01466 for ( int i = 0; i < tab->count(); ++i ) { 01467 QWidget *w = tab->page( i ); 01468 listOfCaption.append( w->caption() ).append(","); 01469 listOfName.append( w->name() ).append(","); 01470 } 01471 listOfCaption.remove( listOfCaption.length()-1, 1 ); 01472 listOfName.remove( listOfName.length()-1, 1 ); 01473 01474 tab->parentWidget()->setName( listOfName.utf8() ); 01475 tab->parentWidget()->setCaption( listOfCaption ); 01476 01477 tab->parentWidget()->repaint( false ); // KDockWidget->repaint 01478 if ( tab->parentWidget()->parent() ) 01479 if ( tab->parentWidget()->parent()->inherits("KDockSplitter") ) 01480 ((KDockSplitter*)(tab->parentWidget()->parent()))->updateName(); 01481 } 01482 01483 bool KDockWidget::mayBeHide() const 01484 { 01485 bool f = (parent() != manager->main); 01486 return ( !isGroup && !isTabGroup && f && isVisible() && ( eDocking != (int)KDockWidget::DockNone ) ); 01487 } 01488 01489 bool KDockWidget::mayBeShow() const 01490 { 01491 bool f = (parent() != manager->main); 01492 return ( !isGroup && !isTabGroup && f && !isVisible() ); 01493 } 01494 01495 void KDockWidget::changeHideShowState() 01496 { 01497 if ( mayBeHide() ){ 01498 undock(); 01499 return; 01500 } 01501 01502 if ( mayBeShow() ){ 01503 if ( manager->main->inherits("KDockMainWindow") ){ 01504 ((KDockMainWindow*)manager->main)->makeDockVisible(this); 01505 } else { 01506 makeDockVisible(); 01507 } 01508 } 01509 } 01510 01511 void KDockWidget::makeDockVisible() 01512 { 01513 if ( parentDockTabGroup() ){ 01514 parentDockTabGroup()->showPage( this ); 01515 } 01516 if (parentDockContainer()) { 01517 QWidget *contWid=parentDockContainer(); 01518 KDockContainer *x = dynamic_cast<KDockContainer*>(contWid); 01519 if (x) { 01520 x->showWidget(this); 01521 } 01522 } 01523 if ( isVisible() ) return; 01524 01525 QWidget* p = parentWidget(); 01526 while ( p ){ 01527 if ( !p->isVisible() ) 01528 p->show(); 01529 p = p->parentWidget(); 01530 } 01531 if( parent() == 0L) // is undocked 01532 dockBack(); 01533 show(); 01534 } 01535 01536 void KDockWidget::setFormerBrotherDockWidget(KDockWidget *dockWidget) 01537 { 01538 formerBrotherDockWidget = dockWidget; 01539 if( formerBrotherDockWidget != 0L) 01540 QObject::connect( formerBrotherDockWidget, SIGNAL(iMBeingClosed()), 01541 this, SLOT(loseFormerBrotherDockWidget()) ); 01542 } 01543 01544 void KDockWidget::loseFormerBrotherDockWidget() 01545 { 01546 if( formerBrotherDockWidget != 0L) 01547 QObject::disconnect( formerBrotherDockWidget, SIGNAL(iMBeingClosed()), 01548 this, SLOT(loseFormerBrotherDockWidget()) ); 01549 formerBrotherDockWidget = 0L; 01550 repaint(); 01551 } 01552 01553 void KDockWidget::dockBack() 01554 { 01555 if( formerBrotherDockWidget) { 01556 // search all children if it tries to dock back to a child 01557 bool found = false; 01558 QObjectList* cl = queryList("KDockWidget"); 01559 QObjectListIt it( *cl ); 01560 QObject * obj; 01561 while ( !found && (obj=it.current()) != 0 ) { 01562 ++it; 01563 QWidget* widg = (QWidget*)obj; 01564 if( widg == formerBrotherDockWidget) 01565 found = true; 01566 } 01567 delete cl; 01568 01569 if( !found) { 01570 // can dock back to the former brother dockwidget 01571 manualDock( formerBrotherDockWidget, formerDockPos, d->splitPosInPercent, QPoint(0,0), false, d->index); 01572 formerBrotherDockWidget = 0L; 01573 makeDockVisible(); 01574 return; 01575 } 01576 } 01577 01578 // else dockback to the dockmainwindow (default behavior) 01579 manualDock( ((KDockMainWindow*)manager->main)->getMainDockWidget(), formerDockPos, d->splitPosInPercent, QPoint(0,0), false, d->index); 01580 formerBrotherDockWidget = 0L; 01581 if (parent()) 01582 makeDockVisible(); 01583 } 01584 01585 bool KDockWidget::isDockBackPossible() const 01586 { 01587 if( (formerBrotherDockWidget == 0L) || !(formerBrotherDockWidget->dockSite() & formerDockPos)) 01588 return false; 01589 else 01590 return true; 01591 } 01592 01593 /**************************************************************************************/ 01594 01595 01596 KDockManager::KDockManager( QWidget* mainWindow , const char* name ) 01597 :QObject( mainWindow, name ) 01598 ,main(mainWindow) 01599 ,currentDragWidget(0L) 01600 ,currentMoveWidget(0L) 01601 ,childDockWidgetList(0L) 01602 ,autoCreateDock(0L) 01603 ,storeW(0) 01604 ,storeH(0) 01605 ,dragging(false) 01606 ,undockProcess(false) 01607 ,dropCancel(true) 01608 { 01609 d = new KDockManagerPrivate; 01610 01611 d->readyToDrag = false; 01612 d->mainDockWidget=0; 01613 01614 #ifndef NO_KDE2 01615 d->splitterOpaqueResize = KGlobalSettings::opaqueResize(); 01616 #else 01617 d->splitterOpaqueResize = false; 01618 #endif 01619 01620 d->splitterKeepSize = false; 01621 d->splitterHighResolution = false; 01622 d->m_readDockConfigMode = WrapExistingWidgetsOnly; // default as before 01623 01624 main->installEventFilter( this ); 01625 01626 undockProcess = false; 01627 01628 menuData = new QPtrList<MenuDockData>; 01629 menuData->setAutoDelete( true ); 01630 menuData->setAutoDelete( true ); 01631 01632 #ifndef NO_KDE2 01633 menu = new KPopupMenu(); 01634 #else 01635 menu = new QPopupMenu(); 01636 #endif 01637 01638 connect( menu, SIGNAL(aboutToShow()), SLOT(slotMenuPopup()) ); 01639 connect( menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int)) ); 01640 01641 childDock = new QObjectList(); 01642 childDock->setAutoDelete( false ); 01643 } 01644 01645 01646 void KDockManager::setMainDockWidget2(KDockWidget *w) 01647 { 01648 d->mainDockWidget=w; 01649 } 01650 01651 KDockManager::~KDockManager() 01652 { 01653 delete menuData; 01654 delete menu; 01655 01656 QObjectListIt it( *childDock ); 01657 KDockWidget * obj; 01658 01659 while ( (obj=(KDockWidget*)it.current()) ) { 01660 delete obj; 01661 } 01662 delete childDock; 01663 delete d; 01664 d=0; 01665 } 01666 01667 void KDockManager::activate() 01668 { 01669 QObjectListIt it( *childDock ); 01670 KDockWidget * obj; 01671 01672 while ( (obj=(KDockWidget*)it.current()) ) { 01673 ++it; 01674 if ( obj->widget ) obj->widget->show(); 01675 if ( !obj->parentDockTabGroup() ){ 01676 obj->show(); 01677 } 01678 } 01679 if ( !main->inherits("QDialog") ) main->show(); 01680 } 01681 01682 bool KDockManager::eventFilter( QObject *obj, QEvent *event ) 01683 { 01684 01685 if ( obj->inherits("KDockWidgetAbstractHeaderDrag") ){ 01686 KDockWidget* pDockWdgAtCursor = 0L; 01687 KDockWidget* curdw = ((KDockWidgetAbstractHeaderDrag*)obj)->dockWidget(); 01688 switch ( event->type() ){ 01689 case QEvent::MouseButtonDblClick: 01690 if (curdw->currentDockPos == KDockWidget::DockDesktop) curdw->dockBack(); 01691 else 01692 { 01693 curdw->toDesktop(); 01694 // curdw->manualDock (0, KDockWidget::DockDesktop); 01695 } 01696 break; 01697 01698 case QEvent::MouseButtonPress: 01699 if ( ((QMouseEvent*)event)->button() == LeftButton ){ 01700 if ( curdw->eDocking != (int)KDockWidget::DockNone ){ 01701 dropCancel = true; 01702 curdw->setFocus(); 01703 qApp->processOneEvent(); 01704 01705 currentDragWidget = curdw; 01706 currentMoveWidget = 0L; 01707 childDockWidgetList = new QWidgetList(); 01708 childDockWidgetList->append( curdw ); 01709 findChildDockWidget( curdw, childDockWidgetList ); 01710 01711 //d->oldDragRect = QRect(); should fix rectangle not erased problem 01712 d->dragRect = QRect(curdw->geometry()); 01713 QPoint p = curdw->mapToGlobal(QPoint(0,0)); 01714 d->dragRect.moveTopLeft(p); 01715 drawDragRectangle(); 01716 d->readyToDrag = true; 01717 01718 d->dragOffset = QCursor::pos()-currentDragWidget->mapToGlobal(QPoint(0,0)); 01719 } 01720 01721 } 01722 break; 01723 case QEvent::MouseButtonRelease: 01724 if ( ((QMouseEvent*)event)->button() == LeftButton ){ 01725 if ( dragging ){ 01726 if ( !dropCancel ) 01727 drop(); 01728 else 01729 cancelDrop(); 01730 } 01731 if (d->readyToDrag) { 01732 d->readyToDrag = false; 01733 //d->oldDragRect = QRect(); should fix rectangle not erased problem 01734 d->dragRect = QRect(curdw->geometry()); 01735 QPoint p = curdw->mapToGlobal(QPoint(0,0)); 01736 d->dragRect.moveTopLeft(p); 01737 drawDragRectangle(); 01738 currentDragWidget = 0L; 01739 delete childDockWidgetList; 01740 childDockWidgetList = 0L; 01741 } 01742 dragging = false; 01743 dropCancel = true; 01744 } 01745 break; 01746 case QEvent::MouseMove: 01747 if ( dragging ) { 01748 01749 #ifdef BORDERLESS_WINDOWS 01750 //BEGIN TEST 01751 KDockWidget *oldMoveWidget; 01752 if (curdw->parent()==0) 01753 { 01754 curdw->move(QCursor::pos()-d->dragOffset); 01755 pDockWdgAtCursor = findDockWidgetAt( QCursor::pos()-QPoint(0,d->dragOffset.y()+3) ); 01756 oldMoveWidget = currentMoveWidget; 01757 } 01758 else 01759 { 01760 pDockWdgAtCursor = findDockWidgetAt( QCursor::pos() ); 01761 oldMoveWidget = currentMoveWidget; 01762 } 01763 //END TEST 01764 #else 01765 pDockWdgAtCursor = findDockWidgetAt( QCursor::pos() ); 01766 KDockWidget* oldMoveWidget = currentMoveWidget; 01767 #endif 01768 01769 if ( currentMoveWidget && pDockWdgAtCursor == currentMoveWidget ) { //move 01770 dragMove( currentMoveWidget, currentMoveWidget->mapFromGlobal( QCursor::pos() ) ); 01771 break; 01772 } else { 01773 if (dropCancel && curdw) { 01774 d->dragRect = QRect(curdw->geometry()); 01775 QPoint p = curdw->mapToGlobal(QPoint(0,0)); 01776 d->dragRect.moveTopLeft(p); 01777 }else 01778 d->dragRect = QRect(); 01779 01780 drawDragRectangle(); 01781 } 01782 01783 if ( !pDockWdgAtCursor && (curdw->eDocking & (int)KDockWidget::DockDesktop) == 0 ){ 01784 // just moving at the desktop 01785 currentMoveWidget = pDockWdgAtCursor; 01786 curPos = KDockWidget::DockDesktop; 01787 } else { 01788 if ( oldMoveWidget && pDockWdgAtCursor != currentMoveWidget ) { //leave 01789 currentMoveWidget = pDockWdgAtCursor; 01790 curPos = KDockWidget::DockDesktop; 01791 } 01792 } 01793 01794 if ( oldMoveWidget != pDockWdgAtCursor && pDockWdgAtCursor ) { //enter pDockWdgAtCursor 01795 currentMoveWidget = pDockWdgAtCursor; 01796 curPos = KDockWidget::DockDesktop; 01797 } 01798 } else { 01799 if (d->readyToDrag) { 01800 d->readyToDrag = false; 01801 } 01802 if ( (((QMouseEvent*)event)->state() == LeftButton) && 01803 (curdw->eDocking != (int)KDockWidget::DockNone) ) { 01804 startDrag( curdw); 01805 } 01806 } 01807 break; 01808 default: 01809 break; 01810 } 01811 } 01812 return QObject::eventFilter( obj, event ); 01813 } 01814 01815 KDockWidget* KDockManager::findDockWidgetAt( const QPoint& pos ) 01816 { 01817 dropCancel = true; 01818 01819 if (!currentDragWidget) 01820 return 0L; // pointer access safety 01821 01822 if (currentDragWidget->eDocking == (int)KDockWidget::DockNone ) return 0L; 01823 01824 QWidget* p = QApplication::widgetAt( pos ); 01825 if ( !p ) { 01826 dropCancel = false; 01827 return 0L; 01828 } 01829 #if defined(_OS_WIN32_) || defined(Q_OS_WIN32) 01830 p = p->topLevelWidget(); 01831 #endif 01832 QWidget* w = 0L; 01833 findChildDockWidget( w, p, p->mapFromGlobal(pos) ); 01834 if ( !w ){ 01835 if ( !p->inherits("KDockWidget") ) { 01836 return 0L; 01837 } 01838 w = p; 01839 } 01840 if ( qt_find_obj_child( w, "KDockSplitter", "_dock_split_" ) ) return 0L; 01841 if ( qt_find_obj_child( w, "KDockTabGroup", "_dock_tab" ) ) return 0L; 01842 if (dynamic_cast<KDockContainer*>(w)) return 0L; 01843 01844 if (!childDockWidgetList) return 0L; 01845 if ( childDockWidgetList->find(w) != -1 ) return 0L; 01846 if ( currentDragWidget->isGroup && ((KDockWidget*)w)->parentDockTabGroup() ) return 0L; 01847 01848 KDockWidget* www = (KDockWidget*)w; 01849 if ( www->sDocking == (int)KDockWidget::DockNone ) return 0L; 01850 if( !www->widget ) 01851 return 0L; 01852 01853 KDockWidget::DockPosition curPos = KDockWidget::DockDesktop; 01854 QPoint cpos = www->mapFromGlobal( pos ); 01855 01856 int ww = www->widget->width() / 3; 01857 int hh = www->widget->height() / 3; 01858 01859 if ( cpos.y() <= hh ){ 01860 curPos = KDockWidget::DockTop; 01861 } else 01862 if ( cpos.y() >= 2*hh ){ 01863 curPos = KDockWidget::DockBottom; 01864 } else 01865 if ( cpos.x() <= ww ){ 01866 curPos = KDockWidget::DockLeft; 01867 } else 01868 if ( cpos.x() >= 2*ww ){ 01869 curPos = KDockWidget::DockRight; 01870 } else 01871 curPos = KDockWidget::DockCenter; 01872 01873 if ( !(www->sDocking & (int)curPos) ) return 0L; 01874 if ( !(currentDragWidget->eDocking & (int)curPos) ) return 0L; 01875 if ( www->manager != this ) return 0L; 01876 01877 dropCancel = false; 01878 return www; 01879 } 01880 01881 void KDockManager::findChildDockWidget( QWidget*& ww, const QWidget* p, const QPoint& pos ) 01882 { 01883 if ( p->children() ) { 01884 QWidget *w; 01885 QObjectListIt it( *p->children() ); 01886 it.toLast(); 01887 while ( it.current() ) { 01888 if ( it.current()->isWidgetType() ) { 01889 w = (QWidget*)it.current(); 01890 if ( w->isVisible() && w->geometry().contains(pos) ) { 01891 if ( w->inherits("KDockWidget") ) ww = w; 01892 findChildDockWidget( ww, w, w->mapFromParent(pos) ); 01893 return; 01894 } 01895 } 01896 --it; 01897 } 01898 } 01899 return; 01900 } 01901 01902 void KDockManager::findChildDockWidget( const QWidget* p, QWidgetList*& list ) 01903 { 01904 if ( p->children() ) { 01905 QWidget *w; 01906 QObjectListIt it( *p->children() ); 01907 it.toLast(); 01908 while ( it.current() ) { 01909 if ( it.current()->isWidgetType() ) { 01910 w = (QWidget*)it.current(); 01911 if ( w->isVisible() ) { 01912 if ( w->inherits("KDockWidget") ) list->append( w ); 01913 findChildDockWidget( w, list ); 01914 } 01915 } 01916 --it; 01917 } 01918 } 01919 return; 01920 } 01921 01922 void KDockManager::startDrag( KDockWidget* w ) 01923 { 01924 if(( w->currentDockPos == KDockWidget::DockLeft) || ( w->currentDockPos == KDockWidget::DockRight) 01925 || ( w->currentDockPos == KDockWidget::DockTop) || ( w->currentDockPos == KDockWidget::DockBottom)) { 01926 w->prevSideDockPosBeforeDrag = w->currentDockPos; 01927 01928 if ( w->parentWidget()->inherits("KDockSplitter") ){ 01929 KDockSplitter* parentSplitterOfDockWidget = (KDockSplitter*)(w->parentWidget()); 01930 w->d->splitPosInPercent = parentSplitterOfDockWidget->separatorPos(); 01931 } 01932 } 01933 01934 curPos = KDockWidget::DockDesktop; 01935 dragging = true; 01936 01937 QApplication::setOverrideCursor(QCursor(sizeAllCursor)); 01938 } 01939 01940 void KDockManager::dragMove( KDockWidget* dw, QPoint pos ) 01941 { 01942 QPoint p = dw->mapToGlobal( dw->widget->pos() ); 01943 KDockWidget::DockPosition oldPos = curPos; 01944 01945 QSize r = dw->widget->size(); 01946 if ( dw->parentDockTabGroup() ){ 01947 curPos = KDockWidget::DockCenter; 01948 if ( oldPos != curPos ) { 01949 d->dragRect.setRect( p.x()+2, p.y()+2, r.width()-4, r.height()-4 ); 01950 } 01951 return; 01952 } 01953 01954 int w = r.width() / 3; 01955 int h = r.height() / 3; 01956 01957 if ( pos.y() <= h ){ 01958 curPos = KDockWidget::DockTop; 01959 w = r.width(); 01960 } else 01961 if ( pos.y() >= 2*h ){ 01962 curPos = KDockWidget::DockBottom; 01963 p.setY( p.y() + 2*h ); 01964 w = r.width(); 01965 } else 01966 if ( pos.x() <= w ){ 01967 curPos = KDockWidget::DockLeft; 01968 h = r.height(); 01969 } else 01970 if ( pos.x() >= 2*w ){ 01971 curPos = KDockWidget::DockRight; 01972 p.setX( p.x() + 2*w ); 01973 h = r.height(); 01974 } else 01975 { 01976 curPos = KDockWidget::DockCenter; 01977 p.setX( p.x() + w ); 01978 p.setY( p.y() + h ); 01979 } 01980 01981 if ( oldPos != curPos ) { 01982 d->dragRect.setRect( p.x(), p.y(), w, h ); 01983 drawDragRectangle(); 01984 } 01985 } 01986 01987 01988 void KDockManager::cancelDrop() 01989 { 01990 QApplication::restoreOverrideCursor(); 01991 01992 delete childDockWidgetList; 01993 childDockWidgetList = 0L; 01994 01995 d->dragRect = QRect(); // cancel drawing 01996 drawDragRectangle(); // only the old rect will be deleted 01997 } 01998 01999 02000 void KDockManager::drop() 02001 { 02002 d->dragRect = QRect(); // cancel drawing 02003 drawDragRectangle(); // only the old rect will be deleted 02004 02005 QApplication::restoreOverrideCursor(); 02006 02007 delete childDockWidgetList; 02008 childDockWidgetList = 0L; 02009 02010 if ( dropCancel ) return; 02011 if ( !currentMoveWidget && ((currentDragWidget->eDocking & (int)KDockWidget::DockDesktop) == 0) ) { 02012 d->dragRect = QRect(); // cancel drawing 02013 drawDragRectangle(); // only the old rect will be deleted 02014 return; 02015 } 02016 if ( !currentMoveWidget && !currentDragWidget->parent() ) { 02017 currentDragWidget->move( QCursor::pos() - d->dragOffset ); 02018 } 02019 else { 02020 int splitPos = currentDragWidget->d->splitPosInPercent; 02021 // do we have to calculate 100%-splitPosInPercent? 02022 if( (curPos != currentDragWidget->prevSideDockPosBeforeDrag) && (curPos != KDockWidget::DockCenter) && (curPos != KDockWidget::DockDesktop)) { 02023 switch( currentDragWidget->prevSideDockPosBeforeDrag) { 02024 case KDockWidget::DockLeft: if(curPos != KDockWidget::DockTop) splitPos = 100-splitPos; break; 02025 case KDockWidget::DockRight: if(curPos != KDockWidget::DockBottom) splitPos = 100-splitPos; break; 02026 case KDockWidget::DockTop: if(curPos != KDockWidget::DockLeft) splitPos = 100-splitPos; break; 02027 case KDockWidget::DockBottom: if(curPos != KDockWidget::DockRight) splitPos = 100-splitPos; break; 02028 default: break; 02029 } 02030 } 02031 currentDragWidget->manualDock( currentMoveWidget, curPos , splitPos, QCursor::pos() - d->dragOffset ); 02032 currentDragWidget->makeDockVisible(); 02033 } 02034 } 02035 02036 02037 static QDomElement createStringEntry(QDomDocument &doc, const QString &tagName, const QString &str) 02038 { 02039 QDomElement el = doc.createElement(tagName); 02040 02041 el.appendChild(doc.createTextNode(str)); 02042 return el; 02043 } 02044 02045 02046 static QDomElement createBoolEntry(QDomDocument &doc, const QString &tagName, bool b) 02047 { 02048 return createStringEntry(doc, tagName, QString::fromLatin1(b? "true" : "false")); 02049 } 02050 02051 02052 static QDomElement createNumberEntry(QDomDocument &doc, const QString &tagName, int n) 02053 { 02054 return createStringEntry(doc, tagName, QString::number(n)); 02055 } 02056 02057 02058 static QDomElement createRectEntry(QDomDocument &doc, const QString &tagName, const QRect &rect) 02059 { 02060 QDomElement el = doc.createElement(tagName); 02061 02062 QDomElement xel = doc.createElement("x"); 02063 xel.appendChild(doc.createTextNode(QString::number(rect.x()))); 02064 el.appendChild(xel); 02065 QDomElement yel = doc.createElement("y"); 02066 yel.appendChild(doc.createTextNode(QString::number(rect.y()))); 02067 el.appendChild(yel); 02068 QDomElement wel = doc.createElement("width"); 02069 wel.appendChild(doc.createTextNode(QString::number(rect.width()))); 02070 el.appendChild(wel); 02071 QDomElement hel = doc.createElement("height"); 02072 hel.appendChild(doc.createTextNode(QString::number(rect.height()))); 02073 el.appendChild(hel); 02074 02075 return el; 02076 } 02077 02078 02079 static QDomElement createListEntry(QDomDocument &doc, const QString &tagName, 02080 const QString &subTagName, const QStrList &list) 02081 { 02082 QDomElement el = doc.createElement(tagName); 02083 02084 QStrListIterator it(list); 02085 for (; it.current(); ++it) { 02086 QDomElement subel = doc.createElement(subTagName); 02087 subel.appendChild(doc.createTextNode(QString::fromLatin1(it.current()))); 02088 el.appendChild(subel); 02089 } 02090 02091 return el; 02092 } 02093 02094 02095 static QString stringEntry(QDomElement &base, const QString &tagName) 02096 { 02097 return base.namedItem(tagName).firstChild().toText().data(); 02098 } 02099 02100 02101 static bool boolEntry(QDomElement &base, const QString &tagName) 02102 { 02103 return base.namedItem(tagName).firstChild().toText().data() == "true"; 02104 } 02105 02106 02107 static int numberEntry(QDomElement &base, const QString &tagName) 02108 { 02109 return stringEntry(base, tagName).toInt(); 02110 } 02111 02112 02113 static QRect rectEntry(QDomElement &base, const QString &tagName) 02114 { 02115 QDomElement el = base.namedItem(tagName).toElement(); 02116 02117 int x = numberEntry(el, "x"); 02118 int y = numberEntry(el, "y"); 02119 int width = numberEntry(el, "width"); 02120 int height = numberEntry(el, "height"); 02121 02122 return QRect(x, y, width, height); 02123 } 02124 02125 02126 static QStrList listEntry(QDomElement &base, const QString &tagName, const QString &subTagName) 02127 { 02128 QStrList list; 02129 02130 for( QDomNode n = base.namedItem(tagName).firstChild(); !n.isNull(); n = n.nextSibling() ) 02131 { 02132 QDomElement subel = n.toElement(); 02133 if (subel.tagName() == subTagName) 02134 list.append(subel.firstChild().toText().data().latin1()); 02135 } 02136 02137 return list; 02138 } 02139 02140 02141 void KDockManager::writeConfig(QDomElement &base) 02142 { 02143 // First of all, clear the tree under base 02144 while (!base.firstChild().isNull()) 02145 base.removeChild(base.firstChild()); 02146 QDomDocument doc = base.ownerDocument(); 02147 02148 QStrList nameList; 02149 QString mainWidgetStr; 02150 02151 // collect widget names 02152 QStringList nList; 02153 QObjectListIt it(*childDock); 02154 KDockWidget *obj1; 02155 while ( (obj1=(KDockWidget*)it.current()) ) { 02156 if ( obj1->parent() == main ) 02157 mainWidgetStr = QString::fromLatin1(obj1->name()); 02158 nList.append(obj1->name()); 02159 ++it; 02160 } 02161 02162 for (QObjectListIt it(d->containerDocks);it.current();++it) 02163 { 02164 KDockContainer* dc = dynamic_cast<KDockContainer*>(((KDockWidget*)it.current())->widget); 02165 if (dc) { 02166 dc->prepareSave(nList); 02167 } 02168 } 02169 02170 QStringList::Iterator nListIt=nList.begin(); 02171 while ( nListIt!=nList.end() ) { 02172 KDockWidget *obj = getDockWidgetFromName( *nListIt); 02173 if ((obj->isGroup && (!obj->d->isContainer)) && (nameList.find( obj->firstName.latin1() ) == -1 02174 || nameList.find(obj->lastName.latin1()) == -1)) { 02175 // Skip until children are saved (why?) 02176 ++nListIt; 02177 // nList.next(); 02178 //falk? if ( !nList.current() ) nList.first(); 02179 continue; 02180 } 02181 02182 QDomElement groupEl; 02183 if (obj->d->isContainer) { 02184 KDockContainer* x = dynamic_cast<KDockContainer*>(obj->widget); 02185 if (x) { 02186 groupEl=doc.createElement("dockContainer"); 02187 x->save(groupEl); 02188 } 02189 } else 02190 if (obj->isGroup) { 02192 groupEl = doc.createElement("splitGroup"); 02193 02194 groupEl.appendChild(createStringEntry(doc, "firstName", obj->firstName)); 02195 groupEl.appendChild(createStringEntry(doc, "secondName", obj->lastName)); 02196 groupEl.appendChild(createNumberEntry(doc, "orientation", (int)obj->splitterOrientation)); 02197 groupEl.appendChild(createNumberEntry(doc, "separatorPos", ((KDockSplitter*)obj->widget)->separatorPos())); 02198 } else if (obj->isTabGroup) { 02200 groupEl = doc.createElement("tabGroup"); 02201 02202 QStrList list; 02203 for ( int i = 0; i < ((KDockTabGroup*)obj->widget)->count(); ++i ) 02204 list.append( ((KDockTabGroup*)obj->widget)->page( i )->name() ); 02205 groupEl.appendChild(createListEntry(doc, "tabs", "tab", list)); 02206 groupEl.appendChild(createNumberEntry(doc, "currentTab", ((KDockTabGroup*)obj->widget)->currentPageIndex())); 02207 if (!obj->parent()) { 02208 groupEl.appendChild(createStringEntry(doc, "dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : "")); 02209 groupEl.appendChild(createNumberEntry(doc, "dockBackToPos", obj->formerDockPos)); 02210 } 02211 } else { 02213 groupEl = doc.createElement("dock"); 02214 groupEl.appendChild(createStringEntry(doc, "tabCaption", obj->tabPageLabel())); 02215 groupEl.appendChild(createStringEntry(doc, "tabToolTip", obj->toolTipString())); 02216 if (!obj->parent()) { 02217 groupEl.appendChild(createStringEntry(doc, "dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : "")); 02218 groupEl.appendChild(createNumberEntry(doc, "dockBackToPos", obj->formerDockPos)); 02219 } 02220 } 02221 02222 groupEl.appendChild(createStringEntry(doc, "name", QString::fromLatin1(obj->name()))); 02223 groupEl.appendChild(createBoolEntry(doc, "hasParent", obj->parent())); 02224 if ( !obj->parent() ) { 02225 groupEl.appendChild(createRectEntry(doc, "geometry", QRect(main->frameGeometry().topLeft(), main->size()))); 02226 groupEl.appendChild(createBoolEntry(doc, "visible", obj->isVisible())); 02227 } 02228 if (obj->header && obj->header->inherits("KDockWidgetHeader")) { 02229 KDockWidgetHeader *h = static_cast<KDockWidgetHeader*>(obj->header); 02230 groupEl.appendChild(createBoolEntry(doc, "dragEnabled", h->dragEnabled())); 02231 } 02232 02233 base.appendChild(groupEl); 02234 nameList.append(obj->name()); 02235 nList.remove(nListIt); 02236 nListIt=nList.begin(); 02237 } 02238 02239 if (main->inherits("KDockMainWindow")) { 02240 KDockMainWindow *dmain = (KDockMainWindow*)main; 02241 QString centralWidgetStr = QString(dmain->centralWidget()? dmain->centralWidget()->name() : ""); 02242 base.appendChild(createStringEntry(doc, "centralWidget", centralWidgetStr)); 02243 QString mainDockWidgetStr = QString(dmain->getMainDockWidget()? dmain->getMainDockWidget()->name() : ""); 02244 base.appendChild(createStringEntry(doc, "mainDockWidget", mainDockWidgetStr)); 02245 } else { 02246 base.appendChild(createStringEntry(doc, "mainWidget", mainWidgetStr)); 02247 } 02248 02249 base.appendChild(createRectEntry(doc, "geometry", QRect(main->frameGeometry().topLeft(), main->size()))); 02250 } 02251 02252 02253 void KDockManager::readConfig(QDomElement &base) 02254 { 02255 if (base.namedItem("group").isNull() 02256 && base.namedItem("tabgroup").isNull() 02257 && base.namedItem("dock").isNull() 02258 && base.namedItem("dockContainer").isNull()) { 02259 activate(); 02260 return; 02261 } 02262 02263 autoCreateDock = new QObjectList(); 02264 autoCreateDock->setAutoDelete( true ); 02265 02266 bool isMainVisible = main->isVisible(); 02267 main->hide(); 02268 02269 QObjectListIt it(*childDock); 02270 KDockWidget *obj1; 02271 while ( (obj1=(KDockWidget*)it.current()) ) { 02272 if ( !obj1->isGroup && !obj1->isTabGroup ) { 02273 if ( obj1->parent() ) 02274 obj1->undock(); 02275 else 02276 obj1->hide(); 02277 } 02278 ++it; 02279 } 02280 02281 // firstly, recreate all common dockwidgets 02282 for( QDomNode n = base.firstChild(); !n.isNull(); n = n.nextSibling() ) 02283 { 02284 QDomElement childEl = n.toElement(); 02285 if (childEl.tagName() != "dock") continue; 02286 02287 // Read an ordinary dock widget 02288 KDockWidget *obj = getDockWidgetFromName(stringEntry(childEl, "name")); 02289 obj->setTabPageLabel(stringEntry(childEl, "tabCaption")); 02290 obj->setToolTipString(stringEntry(childEl, "tabToolTip")); 02291 02292 if (!boolEntry(childEl, "hasParent")) { 02293 QRect r = rectEntry(childEl, "geometry"); 02294 obj = getDockWidgetFromName(stringEntry(childEl, "name")); 02295 obj->applyToWidget(0); 02296 obj->setGeometry(r); 02297 if (boolEntry(childEl, "visible")) 02298 obj->QWidget::show(); 02299 } 02300 02301 if (obj && obj->header && obj->header->inherits("KDockWidgetHeader")) { 02302 KDockWidgetHeader *h = static_cast<KDockWidgetHeader*>(obj->header); 02303 h->setDragEnabled(boolEntry(childEl, "dragEnabled")); 02304 } 02305 } 02306 02307 // secondly, now iterate again and create the groups and tabwidgets, apply the dockwidgets to them 02308 for( QDomNode n = base.firstChild(); !n.isNull(); n = n.nextSibling() ) 02309 { 02310 QDomElement childEl = n.toElement(); 02311 if (childEl.isNull()) continue; 02312 02313 KDockWidget *obj = 0; 02314 02315 if (childEl.tagName() == "dockContainer") { 02316 02317 KDockWidget *cont=getDockWidgetFromName(stringEntry(childEl, "name")); 02318 kdDebug()<<"dockContainer: "<<stringEntry(childEl,"name")<<endl; 02319 if (!(cont->d->isContainer)) { 02320 kdDebug()<<"restoration of dockContainer is only supported for already existing dock containers"<<endl; 02321 } else { 02322 KDockContainer *dc=dynamic_cast<KDockContainer*>(cont->getWidget()); 02323 if (!dc) kdDebug()<<"Error while trying to handle dockcontainer configuration restoration"<<endl; 02324 else { 02325 dc->load(childEl); 02326 removeFromAutoCreateList(cont); 02327 } 02328 02329 } 02330 } 02331 else 02332 if (childEl.tagName() == "splitGroup") { 02333 // Read a group 02334 QString name = stringEntry(childEl, "name"); 02335 QString firstName = stringEntry(childEl, "firstName"); 02336 QString secondName = stringEntry(childEl, "secondName"); 02337 int orientation = numberEntry(childEl, "orientation"); 02338 int separatorPos = numberEntry(childEl, "separatorPos"); 02339 02340 KDockWidget *first = getDockWidgetFromName(firstName); 02341 KDockWidget *second = getDockWidgetFromName(secondName); 02342 if (first && second) { 02343 obj = first->manualDock(second, 02344 (orientation == (int)Vertical)? KDockWidget::DockLeft : KDockWidget::DockTop, 02345 separatorPos); 02346 if (obj) 02347 obj->setName(name.latin1()); 02348 } 02349 } else if (childEl.tagName() == "tabGroup") { 02350 // Read a tab group 02351 QString name = stringEntry(childEl, "name"); 02352 QStrList list = listEntry(childEl, "tabs", "tab"); 02353 02354 KDockWidget *d1 = getDockWidgetFromName( list.first() ); 02355 list.next(); 02356 KDockWidget *d2 = getDockWidgetFromName( list.current() ); 02357 02358 KDockWidget *obj = d2->manualDock( d1, KDockWidget::DockCenter ); 02359 if (obj) { 02360 KDockTabGroup *tab = (KDockTabGroup*)obj->widget; 02361 list.next(); 02362 while (list.current() && obj) { 02363 KDockWidget *tabDock = getDockWidgetFromName(list.current()); 02364 obj = tabDock->manualDock(d1, KDockWidget::DockCenter); 02365 list.next(); 02366 } 02367 if (obj) { 02368 obj->setName(name.latin1()); 02369 tab->showPage(tab->page(numberEntry(childEl, "currentTab"))); 02370 } 02371 } 02372 } else { 02373 continue; 02374 } 02375 02376 if (!boolEntry(childEl, "hasParent")) { 02377 QRect r = rectEntry(childEl, "geometry"); 02378 obj = getDockWidgetFromName(stringEntry(childEl, "name")); 02379 obj->applyToWidget(0); 02380 obj->setGeometry(r); 02381 if (boolEntry(childEl, "visible")) 02382 obj->QWidget::show(); 02383 } 02384 02385 if (obj && obj->header && obj->header->inherits("KDockWidgetHeader")) { 02386 KDockWidgetHeader *h = static_cast<KDockWidgetHeader*>(obj->header); 02387 h->setDragEnabled(boolEntry(childEl, "dragEnabled")); 02388 } 02389 } 02390 02391 // thirdly, now that all ordinary dockwidgets are created, 02392 // iterate them again and link them with their corresponding dockwidget for the dockback action 02393 for( QDomNode n = base.firstChild(); !n.isNull(); n = n.nextSibling() ) 02394 { 02395 QDomElement childEl = n.toElement(); 02396 02397 if (childEl.tagName() != "dock" && childEl.tagName() != "tabGroup") 02398 continue; 02399 02400 KDockWidget *obj = 0; 02401 02402 if (!boolEntry(childEl, "hasParent")) { 02403 // Read a common toplevel dock widget 02404 obj = getDockWidgetFromName(stringEntry(childEl, "name")); 02405 QString name = stringEntry(childEl, "dockBackTo"); 02406 if (!name.isEmpty()) { 02407 obj->setFormerBrotherDockWidget(getDockWidgetFromName(name)); 02408 } 02409 obj->formerDockPos = KDockWidget::DockPosition(numberEntry(childEl, "dockBackToPos")); 02410 obj->updateHeader(); 02411 } 02412 } 02413 02414 if (main->inherits("KDockMainWindow")) { 02415 KDockMainWindow *dmain = (KDockMainWindow*)main; 02416 02417 QString mv = stringEntry(base, "centralWidget"); 02418 if (!mv.isEmpty() && getDockWidgetFromName(mv) ) { 02419 KDockWidget *mvd = getDockWidgetFromName(mv); 02420 mvd->applyToWidget(dmain); 02421 mvd->show(); 02422 dmain->setCentralWidget(mvd); 02423 } 02424 QString md = stringEntry(base, "mainDockWidget"); 02425 if (!md.isEmpty() && getDockWidgetFromName(md)) { 02426 KDockWidget *mvd = getDockWidgetFromName(md); 02427 dmain->setMainDockWidget(mvd); 02428 } 02429 } else { 02430 QString mv = stringEntry(base, "mainWidget"); 02431 if (!mv.isEmpty() && getDockWidgetFromName(mv)) { 02432 KDockWidget *mvd = getDockWidgetFromName(mv); 02433 mvd->applyToWidget(main); 02434 mvd->show(); 02435 } 02436 02437 // only resize + move non-mainwindows 02438 QRect mr = rectEntry(base, "geometry"); 02439 main->move(mr.topLeft()); 02440 main->resize(mr.size()); 02441 } 02442 02443 if (isMainVisible) 02444 main->show(); 02445 02446 if (d->m_readDockConfigMode == WrapExistingWidgetsOnly) { 02447 finishReadDockConfig(); // remove empty dockwidgets 02448 } 02449 } 02450 02451 void KDockManager::removeFromAutoCreateList(KDockWidget* pDockWidget) 02452 { 02453 if (!autoCreateDock) return; 02454 autoCreateDock->setAutoDelete(false); 02455 autoCreateDock->removeRef(pDockWidget); 02456 autoCreateDock->setAutoDelete(true); 02457 } 02458 02459 void KDockManager::finishReadDockConfig() 02460 { 02461 delete autoCreateDock; 02462 autoCreateDock = 0; 02463 } 02464 02465 void KDockManager::setReadDockConfigMode(int mode) 02466 { 02467 d->m_readDockConfigMode = mode; 02468 } 02469 02470 #ifndef NO_KDE2 02471 void KDockManager::writeConfig( KConfig* c, QString group ) 02472 { 02473 //debug("BEGIN Write Config"); 02474 if ( !c ) c = KGlobal::config(); 02475 if ( group.isEmpty() ) group = "dock_setting_default"; 02476 02477 c->setGroup( group ); 02478 c->writeEntry( "Version", DOCK_CONFIG_VERSION ); 02479 02480 QStringList nameList; 02481 QStringList findList; 02482 QObjectListIt it( *childDock ); 02483 KDockWidget * obj; 02484 02485 // collect KDockWidget's name 02486 QStringList nList; 02487 while ( (obj=(KDockWidget*)it.current()) ) { 02488 ++it; 02489 //debug(" +Add subdock %s", obj->name()); 02490 nList.append( obj->name() ); 02491 if ( obj->parent() == main ) 02492 c->writeEntry( "Main:view", obj->name() ); 02493 } 02494 02495 // kdDebug()<<QString("list size: %1").arg(nList.count())<<endl; 02496 for (QObjectListIt it(d->containerDocks);it.current();++it) 02497 { 02498 KDockContainer* dc = dynamic_cast<KDockContainer*>(((KDockWidget*)it.current())->widget); 02499 if (dc) { 02500 dc->prepareSave(nList); 02501 } 02502 } 02503 // kdDebug()<<QString("new list size: %1").arg(nList.count())<<endl; 02504 02505 QStringList::Iterator nListIt=nList.begin(); 02506 while ( nListIt!=nList.end() ){ 02507 //debug(" -Try to save %s", nList.current()); 02508 obj = getDockWidgetFromName( *nListIt ); 02509 QString cname = obj->name(); 02510 if ( obj->header ){ 02511 obj->header->saveConfig( c ); 02512 } 02513 if (obj->d->isContainer) { 02514 KDockContainer* x = dynamic_cast<KDockContainer*>(obj->widget); 02515 if (x) { 02516 x->save(c,group); 02517 } 02518 } 02519 /*************************************************************************************************/ 02520 if ( obj->isGroup ){ 02521 if ( (findList.find( obj->firstName ) != findList.end()) && (findList.find( obj->lastName ) != findList.end() )){ 02522 02523 c->writeEntry( cname+":type", "GROUP"); 02524 if ( !obj->parent() ){ 02525 c->writeEntry( cname+":parent", "___null___"); 02526 c->writeEntry( cname+":geometry", QRect(obj->frameGeometry().topLeft(), obj->size()) ); 02527 c->writeEntry( cname+":visible", obj->isVisible()); 02528 } else { 02529 c->writeEntry( cname+":parent", "yes"); 02530 } 02531 c->writeEntry( cname+":first_name", obj->firstName ); 02532 c->writeEntry( cname+":last_name", obj->lastName ); 02533 c->writeEntry( cname+":orientation", (int)obj->splitterOrientation ); 02534 c->writeEntry( cname+":sepPos", ((KDockSplitter*)obj->widget)->separatorPos() ); 02535 02536 nameList.append( obj->name() ); 02537 findList.append( obj->name() ); 02538 //debug(" Save %s", nList.current()); 02539 nList.remove(nListIt); 02540 nListIt=nList.begin(); //nList.first(); 02541 } else { 02542 /*************************************************************************************************/ 02543 //debug(" Skip %s", nList.current()); 02544 //if ( findList.find( obj->firstName ) == -1 ) 02545 // debug(" ? Not found %s", obj->firstName); 02546 //if ( findList.find( obj->lastName ) == -1 ) 02547 // debug(" ? Not found %s", obj->lastName); 02548 ++nListIt; 02549 // if ( !nList.current() ) nList.first(); 02550 if (nListIt==nList.end()) nListIt=nList.begin(); 02551 } 02552 } else { 02553 /*************************************************************************************************/ 02554 if ( obj->isTabGroup){ 02555 c->writeEntry( cname+":type", "TAB_GROUP"); 02556 if ( !obj->parent() ){ 02557 c->writeEntry( cname+":parent", "___null___"); 02558 c->writeEntry( cname+":geometry", QRect(obj->frameGeometry().topLeft(), obj->size()) ); 02559 c->writeEntry( cname+":visible", obj->isVisible()); 02560 c->writeEntry( cname+":dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : ""); 02561 c->writeEntry( cname+":dockBackToPos", obj->formerDockPos); 02562 } else { 02563 c->writeEntry( cname+":parent", "yes"); 02564 } 02565 QStrList list; 02566 for ( int i = 0; i < ((KDockTabGroup*)obj->widget)->count(); ++i ) 02567 list.append( ((KDockTabGroup*)obj->widget)->page( i )->name() ); 02568 c->writeEntry( cname+":tabNames", list ); 02569 c->writeEntry( cname+":curTab", ((KDockTabGroup*)obj->widget)->currentPageIndex() ); 02570 02571 nameList.append( obj->name() ); 02572 findList.append( obj->name() ); // not really need !!! 02573 //debug(" Save %s", nList.current()); 02574 nList.remove(nListIt); 02575 nListIt=nList.begin(); 02576 } else { 02577 /*************************************************************************************************/ 02578 c->writeEntry( cname+":tabCaption", obj->tabPageLabel()); 02579 c->writeEntry( cname+":tabToolTip", obj->toolTipString()); 02580 if ( !obj->parent() ){ 02581 c->writeEntry( cname+":type", "NULL_DOCK"); 02582 c->writeEntry( cname+":geometry", QRect(obj->frameGeometry().topLeft(), obj->size()) ); 02583 c->writeEntry( cname+":visible", obj->isVisible()); 02584 c->writeEntry( cname+":dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : ""); 02585 c->writeEntry( cname+":dockBackToPos", obj->formerDockPos); 02586 } else { 02587 c->writeEntry( cname+":type", "DOCK"); 02588 } 02589 nameList.append( cname.latin1() ); 02590 //debug(" Save %s", nList.current()); 02591 findList.append( obj->name() ); 02592 nList.remove(nListIt); 02593 nListIt=nList.begin(); 02594 } 02595 } 02596 } 02597 c->writeEntry( "NameList", nameList ); 02598 02599 c->writeEntry( "Main:Geometry", QRect(main->frameGeometry().topLeft(), main->size()) ); 02600 c->writeEntry( "Main:visible", main->isVisible()); // curently nou use 02601 02602 if ( main->inherits("KDockMainWindow") ){ 02603 KDockMainWindow* dmain = (KDockMainWindow*)main; 02604 // for KDockMainWindow->setView() in readConfig() 02605 c->writeEntry( "Main:view", dmain->centralWidget() ? dmain->centralWidget()->name():"" ); 02606 c->writeEntry( "Main:dock", dmain->getMainDockWidget() ? dmain->getMainDockWidget()->name() :"" ); 02607 } 02608 02609 c->sync(); 02610 //debug("END Write Config"); 02611 } 02612 #include <qmessagebox.h> 02613 void KDockManager::readConfig( KConfig* c, QString group ) 02614 { 02615 if ( !c ) c = KGlobal::config(); 02616 if ( group.isEmpty() ) group = "dock_setting_default"; 02617 02618 c->setGroup( group ); 02619 QStrList nameList; 02620 c->readListEntry( "NameList", nameList ); 02621 QString ver = c->readEntry( "Version", "0.0.1" ); 02622 nameList.first(); 02623 if ( !nameList.current() || ver != DOCK_CONFIG_VERSION ){ 02624 activate(); 02625 return; 02626 } 02627 02628 autoCreateDock = new QObjectList(); 02629 autoCreateDock->setAutoDelete( true ); 02630 02631 bool isMainVisible = main->isVisible(); 02632 // if (isMainVisible) // CCC 02633 //QMessageBox::information(0,"","hallo"); 02634 //COMMENTED4TESTING main->hide(); 02635 02636 QObjectListIt it( *childDock ); 02637 KDockWidget * obj; 02638 02639 while ( (obj=(KDockWidget*)it.current()) ){ 02640 ++it; 02641 if ( !obj->isGroup && !obj->isTabGroup ) 02642 { 02643 if ( obj->parent() ) obj->undock(); else obj->hide(); 02644 } 02645 } 02646 02647 // firstly, only the common dockwidgets, 02648 // they must be restored before e.g. tabgroups are restored 02649 nameList.first(); 02650 while ( nameList.current() ){ 02651 QString oname = nameList.current(); 02652 c->setGroup( group ); 02653 QString type = c->readEntry( oname + ":type" ); 02654 obj = 0L; 02655 02656 if ( type == "NULL_DOCK" || c->readEntry( oname + ":parent") == "___null___" ){ 02657 QRect r = c->readRectEntry( oname + ":geometry" ); 02658 obj = getDockWidgetFromName( oname ); 02659 obj->applyToWidget( 0L ); 02660 obj->setGeometry(r); 02661 02662 c->setGroup( group ); 02663 obj->setTabPageLabel(c->readEntry( oname + ":tabCaption" )); 02664 obj->setToolTipString(c->readEntry( oname + ":tabToolTip" )); 02665 if ( c->readBoolEntry( oname + ":visible" ) ){ 02666 obj->QWidget::show(); 02667 } 02668 } 02669 02670 if ( type == "DOCK" ){ 02671 obj = getDockWidgetFromName( oname ); 02672 obj->setTabPageLabel(c->readEntry( oname + ":tabCaption" )); 02673 obj->setToolTipString(c->readEntry( oname + ":tabToolTip" )); 02674 } 02675 02676 if (obj && obj->d->isContainer) { 02677 dynamic_cast<KDockContainer*>(obj->widget)->load(c,group); 02678 removeFromAutoCreateList(obj); 02679 } 02680 if ( obj && obj->header){ 02681 obj->header->loadConfig( c ); 02682 } 02683 nameList.next(); 02684 } 02685 02686 // secondly, after the common dockwidgets, restore the groups and tabgroups 02687 nameList.first(); 02688 while ( nameList.current() ){ 02689 QString oname = nameList.current(); 02690 c->setGroup( group ); 02691 QString type = c->readEntry( oname + ":type" ); 02692 obj = 0L; 02693 02694 if ( type == "GROUP" ){ 02695 KDockWidget* first = getDockWidgetFromName( c->readEntry( oname + ":first_name" ) ); 02696 KDockWidget* last = getDockWidgetFromName( c->readEntry( oname + ":last_name" ) ); 02697 int sepPos = c->readNumEntry( oname + ":sepPos" ); 02698 02699 Orientation p = (Orientation)c->readNumEntry( oname + ":orientation" ); 02700 if ( first && last ){ 02701 obj = first->manualDock( last, ( p == Vertical ) ? KDockWidget::DockLeft : KDockWidget::DockTop, sepPos ); 02702 if (obj){ 02703 obj->setName( oname.latin1() ); 02704 } 02705 } 02706 } 02707 02708 if ( type == "TAB_GROUP" ){ 02709 QStrList list; 02710 KDockWidget* tabDockGroup = 0L; 02711 c->readListEntry( oname+":tabNames", list ); 02712 KDockWidget* d1 = getDockWidgetFromName( list.first() ); 02713 list.next(); 02714 KDockWidget* d2 = getDockWidgetFromName( list.current() ); 02715 tabDockGroup = d2->manualDock( d1, KDockWidget::DockCenter ); 02716 if ( tabDockGroup ){ 02717 KDockTabGroup* tab = (KDockTabGroup*)tabDockGroup->widget; 02718 list.next(); 02719 while ( list.current() && tabDockGroup ){ 02720 KDockWidget* tabDock = getDockWidgetFromName( list.current() ); 02721 tabDockGroup = tabDock->manualDock( d1, KDockWidget::DockCenter ); 02722 list.next(); 02723 } 02724 if ( tabDockGroup ){ 02725 tabDockGroup->setName( oname.latin1() ); 02726 c->setGroup( group ); 02727 tab->showPage( tab->page( c->readNumEntry( oname+":curTab" ) ) ); 02728 } 02729 } 02730 obj = tabDockGroup; 02731 } 02732 02733 if (obj && obj->d->isContainer) dynamic_cast<KDockContainer*>(obj->widget)->load(c,group); 02734 if ( obj && obj->header){ 02735 obj->header->loadConfig( c ); 02736 } 02737 nameList.next(); 02738 } 02739 02740 // thirdly, now that all ordinary dockwidgets are created, 02741 // iterate them again and link the toplevel ones of them with their corresponding dockwidget for the dockback action 02742 nameList.first(); 02743 while ( nameList.current() ){ 02744 QString oname = nameList.current(); 02745 c->setGroup( group ); 02746 QString type = c->readEntry( oname + ":type" ); 02747 obj = 0L; 02748 02749 if ( type == "NULL_DOCK" || c->readEntry( oname + ":parent") == "___null___" ){ 02750 obj = getDockWidgetFromName( oname ); 02751 c->setGroup( group ); 02752 QString name = c->readEntry( oname + ":dockBackTo" ); 02753 if (!name.isEmpty()) { 02754 obj->setFormerBrotherDockWidget(getDockWidgetFromName( name )); 02755 } 02756 obj->formerDockPos = KDockWidget::DockPosition(c->readNumEntry( oname + ":dockBackToPos" )); 02757 } 02758 02759 nameList.next(); 02760 } 02761 02762 if ( main->inherits("KDockMainWindow") ){ 02763 KDockMainWindow* dmain = (KDockMainWindow*)main; 02764 02765 c->setGroup( group ); 02766 QString mv = c->readEntry( "Main:view" ); 02767 if ( !mv.isEmpty() && getDockWidgetFromName( mv ) ){ 02768 KDockWidget* mvd = getDockWidgetFromName( mv ); 02769 mvd->applyToWidget( dmain ); 02770 mvd->show(); 02771 dmain->setView( mvd ); 02772 } 02773 c->setGroup( group ); 02774 QString md = c->readEntry( "Main:dock" ); 02775 if ( !md.isEmpty() && getDockWidgetFromName( md ) ){ 02776 KDockWidget* mvd = getDockWidgetFromName( md ); 02777 dmain->setMainDockWidget( mvd ); 02778 } 02779 } else { 02780 c->setGroup( group ); 02781 QString mv = c->readEntry( "Main:view" ); 02782 if ( !mv.isEmpty() && getDockWidgetFromName( mv ) ){ 02783 KDockWidget* mvd = getDockWidgetFromName( mv ); 02784 mvd->applyToWidget( main ); 02785 mvd->show(); 02786 } 02787 02788 } 02789 02790 // delete all autocreate dock 02791 if (d->m_readDockConfigMode == WrapExistingWidgetsOnly) { 02792 finishReadDockConfig(); // remove empty dockwidgets 02793 } 02794 02795 c->setGroup( group ); 02796 QRect mr = c->readRectEntry("Main:Geometry"); 02797 main->move(mr.topLeft()); 02798 main->resize(mr.size()); 02799 if ( isMainVisible ) main->show(); 02800 } 02801 #endif 02802 02803 02804 void KDockManager::dumpDockWidgets() { 02805 QObjectListIt it( *childDock ); 02806 KDockWidget * obj; 02807 while ( (obj=(KDockWidget*)it.current()) ) { 02808 ++it; 02809 kdDebug()<<"KDockManager::dumpDockWidgets:"<<obj->name()<<endl; 02810 } 02811 02812 } 02813 02814 KDockWidget* KDockManager::getDockWidgetFromName( const QString& dockName ) 02815 { 02816 QObjectListIt it( *childDock ); 02817 KDockWidget * obj; 02818 while ( (obj=(KDockWidget*)it.current()) ) { 02819 ++it; 02820 if ( QString(obj->name()) == dockName ) return obj; 02821 } 02822 02823 KDockWidget* autoCreate = 0L; 02824 if ( autoCreateDock ){ 02825 kdDebug()<<"Autocreating dock: "<<dockName<<endl; 02826 autoCreate = new KDockWidget( this, dockName.latin1(), QPixmap("") ); 02827 autoCreateDock->append( autoCreate ); 02828 } 02829 return autoCreate; 02830 } 02831 void KDockManager::setSplitterOpaqueResize(bool b) 02832 { 02833 d->splitterOpaqueResize = b; 02834 } 02835 02836 bool KDockManager::splitterOpaqueResize() const 02837 { 02838 return d->splitterOpaqueResize; 02839 } 02840 02841 void KDockManager::setSplitterKeepSize(bool b) 02842 { 02843 d->splitterKeepSize = b; 02844 } 02845 02846 bool KDockManager::splitterKeepSize() const 02847 { 02848 return d->splitterKeepSize; 02849 } 02850 02851 void KDockManager::setSplitterHighResolution(bool b) 02852 { 02853 d->splitterHighResolution = b; 02854 } 02855 02856 bool KDockManager::splitterHighResolution() const 02857 { 02858 return d->splitterHighResolution; 02859 } 02860 02861 void KDockManager::slotMenuPopup() 02862 { 02863 menu->clear(); 02864 menuData->clear(); 02865 02866 QObjectListIt it( *childDock ); 02867 KDockWidget * obj; 02868 int numerator = 0; 02869 while ( (obj=(KDockWidget*)it.current()) ) { 02870 ++it; 02871 if ( obj->mayBeHide() ) 02872 { 02873 menu->insertItem( obj->icon() ? *(obj->icon()) : QPixmap(), i18n("Hide %1").arg(obj->caption()), numerator++ ); 02874 menuData->append( new MenuDockData( obj, true ) ); 02875 } 02876 02877 if ( obj->mayBeShow() ) 02878 { 02879 menu->insertItem( obj->icon() ? *(obj->icon()) : QPixmap(), i18n("Show %1").arg(obj->caption()), numerator++ ); 02880 menuData->append( new MenuDockData( obj, false ) ); 02881 } 02882 } 02883 } 02884 02885 void KDockManager::slotMenuActivated( int id ) 02886 { 02887 MenuDockData* data = menuData->at( id ); 02888 data->dock->changeHideShowState(); 02889 } 02890 02891 KDockWidget* KDockManager::findWidgetParentDock( QWidget* w ) const 02892 { 02893 QObjectListIt it( *childDock ); 02894 KDockWidget * dock; 02895 KDockWidget * found = 0L; 02896 02897 while ( (dock=(KDockWidget*)it.current()) ) { 02898 ++it; 02899 if ( dock->widget == w ){ found = dock; break; } 02900 } 02901 return found; 02902 } 02903 02904 void KDockManager::drawDragRectangle() 02905 { 02906 if (d->oldDragRect == d->dragRect) 02907 return; 02908 02909 int i; 02910 QRect oldAndNewDragRect[2]; 02911 oldAndNewDragRect[0] = d->oldDragRect; 02912 oldAndNewDragRect[1] = d->dragRect; 02913 02914 // 2 calls, one for the old and one for the new drag rectangle 02915 for (i = 0; i <= 1; i++) { 02916 if (oldAndNewDragRect[i].isEmpty()) 02917 continue; 02918 02919 KDockWidget* pDockWdgAtRect = (KDockWidget*) QApplication::widgetAt( oldAndNewDragRect[i].topLeft(), true ); 02920 if (!pDockWdgAtRect) 02921 continue; 02922 02923 bool isOverMainWdg = false; 02924 bool unclipped; 02925 KDockMainWindow* pMain = 0L; 02926 KDockWidget* pTLDockWdg = 0L; 02927 QWidget* topWdg; 02928 if (pDockWdgAtRect->topLevelWidget() == main) { 02929 isOverMainWdg = true; 02930 topWdg = pMain = (KDockMainWindow*) main; 02931 unclipped = pMain->testWFlags( WPaintUnclipped ); 02932 pMain->setWFlags( WPaintUnclipped ); 02933 } 02934 else { 02935 topWdg = pTLDockWdg = (KDockWidget*) pDockWdgAtRect->topLevelWidget(); 02936 unclipped = pTLDockWdg->testWFlags( WPaintUnclipped ); 02937 pTLDockWdg->setWFlags( WPaintUnclipped ); 02938 } 02939 02940 // draw the rectangle unclipped over the main dock window 02941 QPainter p; 02942 p.begin( topWdg ); 02943 if ( !unclipped ) { 02944 if (isOverMainWdg) 02945 pMain->clearWFlags(WPaintUnclipped); 02946 else 02947 pTLDockWdg->clearWFlags(WPaintUnclipped); 02948 } 02949 // draw the rectangle 02950 p.setRasterOp(Qt::NotXorROP); 02951 QRect r = oldAndNewDragRect[i]; 02952 r.moveTopLeft( r.topLeft() - topWdg->mapToGlobal(QPoint(0,0)) ); 02953 p.drawRect(r.x(), r.y(), r.width(), r.height()); 02954 p.end(); 02955 } 02956 02957 // memorize the current rectangle for later removing 02958 d->oldDragRect = d->dragRect; 02959 } 02960 02961 void KDockManager::setSpecialLeftDockContainer(KDockWidget* container) { 02962 d->leftContainer=container; 02963 } 02964 02965 void KDockManager::setSpecialTopDockContainer(KDockWidget* container) { 02966 d->topContainer=container; 02967 } 02968 02969 void KDockManager::setSpecialRightDockContainer(KDockWidget* container) { 02970 d->rightContainer=container; 02971 02972 } 02973 02974 void KDockManager::setSpecialBottomDockContainer(KDockWidget* container) { 02975 d->bottomContainer=container; 02976 } 02977 02978 02979 KDockArea::KDockArea( QWidget* parent, const char *name) 02980 :QWidget( parent, name) 02981 { 02982 QString new_name = QString(name) + QString("_DockManager"); 02983 dockManager = new KDockManager( this, new_name.latin1() ); 02984 mainDockWidget = 0L; 02985 } 02986 02987 KDockArea::~KDockArea() 02988 { 02989 delete dockManager; 02990 } 02991 02992 KDockWidget* KDockArea::createDockWidget( const QString& name, const QPixmap &pixmap, QWidget* parent, const QString& strCaption, const QString& strTabPageLabel) 02993 { 02994 return new KDockWidget( dockManager, name.latin1(), pixmap, parent, strCaption, strTabPageLabel ); 02995 } 02996 02997 void KDockArea::makeDockVisible( KDockWidget* dock ) 02998 { 02999 if ( dock != 0L) 03000 dock->makeDockVisible(); 03001 } 03002 03003 void KDockArea::makeDockInvisible( KDockWidget* dock ) 03004 { 03005 if ( dock != 0L) 03006 dock->undock(); 03007 } 03008 03009 void KDockArea::makeWidgetDockVisible( QWidget* widget ) 03010 { 03011 makeDockVisible( dockManager->findWidgetParentDock(widget) ); 03012 } 03013 03014 void KDockArea::writeDockConfig(QDomElement &base) 03015 { 03016 dockManager->writeConfig(base); 03017 } 03018 03019 void KDockArea::readDockConfig(QDomElement &base) 03020 { 03021 dockManager->readConfig(base); 03022 } 03023 03024 void KDockArea::slotDockWidgetUndocked() 03025 { 03026 QObject* pSender = (QObject*) sender(); 03027 if (!pSender->inherits("KDockWidget")) return; 03028 KDockWidget* pDW = (KDockWidget*) pSender; 03029 emit dockWidgetHasUndocked( pDW); 03030 } 03031 03032 void KDockArea::resizeEvent(QResizeEvent *rsize) 03033 { 03034 QWidget::resizeEvent(rsize); 03035 if (children()){ 03036 #ifndef NO_KDE2 03037 // kdDebug()<<"KDockArea::resize"<<endl; 03038 #endif 03039 QObjectList *list=queryList("QWidget",0,false); 03040 03041 QObjectListIt it( *list ); // iterate over the buttons 03042 QObject *obj; 03043 03044 while ( (obj = it.current()) != 0 ) { 03045 // for each found object... 03046 ((QWidget*)obj)->setGeometry(QRect(QPoint(0,0),size())); 03047 break; 03048 } 03049 delete list; 03050 #if 0 03051 KDockSplitter *split; 03052 // for (unsigned int i=0;i<children()->count();i++) 03053 { 03054 // QPtrList<QObject> list(children()); 03055 // QObject *obj=((QPtrList<QObject*>)children())->at(i); 03056 QObject *obj=children()->getFirst(); 03057 if (split = dynamic_cast<KDockSplitter*>(obj)) 03058 { 03059 split->setGeometry( QRect(QPoint(0,0), size() )); 03060 // break; 03061 } 03062 } 03063 #endif 03064 } 03065 } 03066 03067 #ifndef NO_KDE2 03068 void KDockArea::writeDockConfig( KConfig* c, QString group ) 03069 { 03070 dockManager->writeConfig( c, group ); 03071 } 03072 03073 void KDockArea::readDockConfig( KConfig* c, QString group ) 03074 { 03075 dockManager->readConfig( c, group ); 03076 } 03077 03078 void KDockArea::setMainDockWidget( KDockWidget* mdw ) 03079 { 03080 if ( mainDockWidget == mdw ) return; 03081 mainDockWidget = mdw; 03082 mdw->applyToWidget(this); 03083 } 03084 #endif 03085 03086 03087 03088 // KDOCKCONTAINER - AN ABSTRACTION OF THE KDOCKTABWIDGET 03089 KDockContainer::KDockContainer(){m_overlapMode=false; m_childrenListBegin=0; m_childrenListEnd=0;} 03090 KDockContainer::~KDockContainer(){ 03091 03092 if (m_childrenListBegin!=0) 03093 { 03094 struct ListItem *tmp=m_childrenListBegin; 03095 while (tmp) 03096 { 03097 struct ListItem *tmp2=tmp->next; 03098 free(tmp->data); 03099 delete tmp; 03100 tmp=tmp2; 03101 } 03102 m_childrenListBegin=0; 03103 m_childrenListEnd=0; 03104 } 03105 03106 } 03107 03108 void KDockContainer::activateOverlapMode(int nonOverlapSize) { 03109 m_nonOverlapSize=nonOverlapSize; 03110 m_overlapMode=true; 03111 if (parentDockWidget()) { 03112 if (parentDockWidget()->parent()) { 03113 kdDebug()<<"KDockContainer::activateOverlapMode: recalculating sizes"<<endl; 03114 KDockSplitter *sp= static_cast<KDockSplitter*>(parentDockWidget()-> 03115 parent()->qt_cast("KDockSplitter")); 03116 if (sp) sp->resizeEvent(0); 03117 } 03118 } 03119 } 03120 03121 void KDockContainer::deactivateOverlapMode() { 03122 if (!m_overlapMode) return; 03123 m_overlapMode=false; 03124 if (parentDockWidget()) { 03125 if (parentDockWidget()->parent()) { 03126 kdDebug()<<"KDockContainer::deactivateOverlapMode: recalculating sizes"<<endl; 03127 KDockSplitter *sp= static_cast<KDockSplitter*>(parentDockWidget()-> 03128 parent()->qt_cast("KDockSplitter")); 03129 if (sp) sp->resizeEvent(0); 03130 } 03131 } 03132 03133 } 03134 03135 bool KDockContainer::isOverlapMode() { 03136 return m_overlapMode; 03137 } 03138 03139 KDockWidget *KDockContainer::parentDockWidget(){return 0;} 03140 03141 QStringList KDockContainer::containedWidgets() const { 03142 QStringList tmp; 03143 for (struct ListItem *it=m_childrenListBegin;it;it=it->next) { 03144 tmp<<QString(it->data); 03145 } 03146 03147 return tmp; 03148 } 03149 03150 void KDockContainer::showWidget(KDockWidget *) { 03151 } 03152 03153 void KDockContainer::insertWidget (KDockWidget *dw, QPixmap, const QString &, int &) 03154 { 03155 struct ListItem *it=new struct ListItem; 03156 it->data=strdup(dw->name()); 03157 it->next=0; 03158 03159 if (m_childrenListEnd) 03160 { 03161 m_childrenListEnd->next=it; 03162 it->prev=m_childrenListEnd; 03163 m_childrenListEnd=it; 03164 } 03165 else 03166 { 03167 it->prev=0; 03168 m_childrenListEnd=it; 03169 m_childrenListBegin=it; 03170 } 03171 } 03172 void KDockContainer::removeWidget (KDockWidget *dw){ 03173 for (struct ListItem *tmp=m_childrenListBegin;tmp;tmp=tmp->next) 03174 { 03175 if (!strcmp(tmp->data,dw->name())) 03176 { 03177 free(tmp->data); 03178 if (tmp->next) tmp->next->prev=tmp->prev; 03179 if (tmp->prev) tmp->prev->next=tmp->next; 03180 if (tmp==m_childrenListBegin) m_childrenListBegin=tmp->next; 03181 if (tmp==m_childrenListEnd) m_childrenListEnd=tmp->prev; 03182 delete tmp; 03183 break; 03184 } 03185 } 03186 } 03187 03188 //m_children.remove(dw->name());} 03189 void KDockContainer::undockWidget (KDockWidget *){;} 03190 void KDockContainer::setToolTip(KDockWidget *, QString &){;} 03191 void KDockContainer::setPixmap(KDockWidget*,const QPixmap&){;} 03192 void KDockContainer::load (KConfig*, const QString&){;} 03193 void KDockContainer::save (KConfig*, const QString&){;} 03194 void KDockContainer::load (QDomElement&){;} 03195 void KDockContainer::save (QDomElement&){;} 03196 void KDockContainer::prepareSave(QStringList &names) 03197 { 03198 03199 for (struct ListItem *tmp=m_childrenListBegin;tmp; tmp=tmp->next) 03200 names.remove(tmp->data); 03201 // for (uint i=0;i<m_children.count();i++) 03202 // { 03203 // names.remove(m_children.at(i)); 03204 // } 03205 } 03206 03207 03208 QWidget *KDockTabGroup::transientTo() { 03209 QWidget *tT=0; 03210 for (int i=0;i<count();i++) { 03211 KDockWidget *dw=static_cast<KDockWidget*>(page(i)->qt_cast("KDockWidget")); 03212 QWidget *tmp; 03213 if ((tmp=dw->transientTo())) { 03214 if (!tT) tT=tmp; 03215 else { 03216 if (tT!=tmp) { 03217 kdDebug()<<"KDockTabGroup::transientTo: widget mismatch"<<endl; 03218 return 0; 03219 } 03220 } 03221 } 03222 } 03223 03224 kdDebug()<<"KDockTabGroup::transientTo: "<<((tT!=0)?"YES":"NO")<<endl; 03225 03226 return tT; 03227 } 03228 03229 void KDockWidgetAbstractHeader::virtual_hook( int, void* ) 03230 { /*BASE::virtual_hook( id, data );*/ } 03231 03232 void KDockWidgetAbstractHeaderDrag::virtual_hook( int, void* ) 03233 { /*BASE::virtual_hook( id, data );*/ } 03234 03235 void KDockWidgetHeaderDrag::virtual_hook( int id, void* data ) 03236 { KDockWidgetAbstractHeaderDrag::virtual_hook( id, data ); } 03237 03238 void KDockWidgetHeader::virtual_hook( int id, void* data ) 03239 { KDockWidgetAbstractHeader::virtual_hook( id, data ); } 03240 03241 void KDockTabGroup::virtual_hook( int, void* ) 03242 { /*BASE::virtual_hook( id, data );*/ } 03243 03244 void KDockWidget::virtual_hook( int, void* ) 03245 { /*BASE::virtual_hook( id, data );*/ } 03246 03247 void KDockManager::virtual_hook( int, void* ) 03248 { /*BASE::virtual_hook( id, data );*/ } 03249 03250 void KDockMainWindow::virtual_hook( int id, void* data ) 03251 { KMainWindow::virtual_hook( id, data ); } 03252 03253 void KDockArea::virtual_hook( int, void* ) 03254 { /*KMainWindow::virtual_hook( id, data );*/ } 03255 03256 03257 #ifndef NO_INCLUDE_MOCFILES // for Qt-only projects, because tmake doesn't take this name 03258 #include "kdockwidget.moc" 03259 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:43:27 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003