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> // schroder 00048 #include <X11/Xlib.h> // schroder 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 void KDockWidget::undock() 01264 { 01265 // kdDebug()<<"KDockWidget::undock()"<<endl; 01266 01267 manager->d->dragRect = QRect (); 01268 manager->drawDragRectangle (); 01269 01270 QWidget* parentW = parentWidget(); 01271 if ( !parentW ){ 01272 hide(); 01273 if (!d->blockHasUndockedSignal) 01274 emit hasUndocked(); 01275 return; 01276 } 01277 01278 formerDockPos = currentDockPos; 01279 currentDockPos = KDockWidget::DockDesktop; 01280 01281 manager->blockSignals(true); 01282 manager->undockProcess = true; 01283 01284 bool isV = parentW->isVisibleToTLW(); 01285 01286 //UNDOCK HAS TO BE IMPLEMENTED CORRECTLY :) 01287 KDockTabGroup* parentTab = parentDockTabGroup(); 01288 if ( parentTab ){ 01289 d->index = parentTab->indexOf( this); // memorize the page position in the tab widget 01290 parentTab->removePage( this ); 01291 /* 01292 QWidget *wantTransient=parentTab->transientTo(); 01293 target->setDockWindowTransient(wantTransient,wantTransient); 01294 */ 01295 setFormerBrotherDockWidget((KDockWidget*)parentTab->page(0)); 01296 applyToWidget( 0L ); 01297 if ( parentTab->count() == 1 ){ 01298 01299 // last subdock widget in the tab control 01300 KDockWidget* lastTab = (KDockWidget*)parentTab->page(0); 01301 parentTab->removePage( lastTab ); 01302 /* QWidget *wantTransient=parentTab->transientTo(); 01303 target->setDockWindowTransient(wantTransient,wantTransient);*/ 01304 01305 lastTab->applyToWidget( 0L ); 01306 lastTab->move( parentTab->mapToGlobal(parentTab->frameGeometry().topLeft()) ); 01307 01308 // KDockTabGroup always have a parent that is a KDockWidget 01309 KDockWidget* parentOfTab = (KDockWidget*)parentTab->parent(); 01310 delete parentTab; // KDockTabGroup 01311 01312 QWidget* parentOfDockWidget = parentOfTab->parentWidget(); 01313 if ( parentOfDockWidget == 0L ){ 01314 if ( isV ) lastTab->show(); 01315 } else { 01316 if ( parentOfDockWidget->inherits("KDockSplitter") ){ 01317 KDockSplitter* split = (KDockSplitter*)parentOfDockWidget; 01318 lastTab->applyToWidget( split ); 01319 split->deactivate(); 01320 if ( split->getFirst() == parentOfTab ){ 01321 split->activate( lastTab ); 01322 if ( ((KDockWidget*)split->parent())->splitterOrientation == Vertical ) 01323 emit ((KDockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockLeft ); 01324 else 01325 emit ((KDockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockTop ); 01326 } else { 01327 split->activate( 0L, lastTab ); 01328 if ( ((KDockWidget*)split->parent())->splitterOrientation == Vertical ) 01329 emit ((KDockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockRight ); 01330 else 01331 emit ((KDockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, KDockWidget::DockBottom ); 01332 } 01333 split->show(); 01334 } else { 01335 lastTab->applyToWidget( parentOfDockWidget ); 01336 } 01337 lastTab->show(); 01338 } 01339 manager->blockSignals(false); 01340 emit manager->replaceDock( parentOfTab, lastTab ); 01341 lastTab->currentDockPos = parentOfTab->currentDockPos; 01342 emit parentOfTab->iMBeingClosed(); 01343 manager->blockSignals(true); 01344 delete parentOfTab; 01345 01346 } else { 01347 setDockTabName( parentTab ); 01348 } 01349 } else { 01350 /*********************************************************************************************/ 01351 //QWidget* containerWidget = (QWidget*)parent(); 01352 bool undockedFromContainer=false; 01353 if (d->container) 01354 { 01355 // kdDebug()<<"undocked from dockcontainer"<<endl; 01356 undockedFromContainer=true; 01357 KDockContainer* dc = dynamic_cast<KDockContainer*>(d->container.operator->()); 01358 if (dc) { 01359 dc->undockWidget(this); 01360 setFormerBrotherDockWidget(dc->parentDockWidget()); 01361 } 01362 applyToWidget( 0L ); 01363 } 01364 if (!undockedFromContainer) { 01365 /*********************************************************************************************/ 01366 if ( parentW->inherits("KDockSplitter") ){ 01367 KDockSplitter* parentSplitterOfDockWidget = (KDockSplitter*)parentW; 01368 d->splitPosInPercent = parentSplitterOfDockWidget->separatorPos(); 01369 01370 KDockWidget* secondWidget = (KDockWidget*)parentSplitterOfDockWidget->getAnother( this ); 01371 KDockWidget* group = (KDockWidget*)parentSplitterOfDockWidget->parentWidget(); 01372 setFormerBrotherDockWidget(secondWidget); 01373 applyToWidget( 0L ); 01374 group->hide(); 01375 01376 if ( !group->parentWidget() ){ 01377 secondWidget->applyToWidget( 0L, group->frameGeometry().topLeft() ); 01378 secondWidget->resize( group->width(), group->height() ); 01379 } else { 01380 QWidget* obj = group->parentWidget(); 01381 secondWidget->applyToWidget( obj ); 01382 if ( obj->inherits("KDockSplitter") ){ 01383 KDockSplitter* parentOfGroup = (KDockSplitter*)obj; 01384 parentOfGroup->deactivate(); 01385 01386 if ( parentOfGroup->getFirst() == group ) 01387 parentOfGroup->activate( secondWidget ); 01388 else 01389 parentOfGroup->activate( 0L, secondWidget ); 01390 } 01391 } 01392 secondWidget->currentDockPos = group->currentDockPos; 01393 secondWidget->formerDockPos = group->formerDockPos; 01394 delete parentSplitterOfDockWidget; 01395 manager->blockSignals(false); 01396 emit manager->replaceDock( group, secondWidget ); 01397 emit group->iMBeingClosed(); 01398 manager->blockSignals(true); 01399 delete group; 01400 01401 if ( isV ) secondWidget->show(); 01402 } else { 01403 if (!d->pendingDtor) { 01404 // don't reparent in the dtor of this 01405 applyToWidget( 0L ); 01406 } 01407 } 01408 /*********************************************************************************************/ 01409 } 01410 } 01411 manager->blockSignals(false); 01412 if (!d->blockHasUndockedSignal) 01413 emit manager->change(); 01414 manager->undockProcess = false; 01415 01416 if (!d->blockHasUndockedSignal) 01417 emit hasUndocked(); 01418 } 01419 01420 void KDockWidget::setWidget( QWidget* mw ) 01421 { 01422 if ( !mw ) return; 01423 01424 if ( mw->parent() != this ){ 01425 mw->reparent(this, 0, QPoint(0,0), false); 01426 } 01427 01428 #ifdef BORDERLESS_WINDOWS 01429 if (!mw->ownCursor()) mw->setCursor(QCursor(ArrowCursor)); 01430 #endif 01431 widget = mw; 01432 delete layout; 01433 01434 layout = new QVBoxLayout( this ); 01435 layout->setResizeMode( QLayout::Minimum ); 01436 01437 KDockContainer* dc = dynamic_cast<KDockContainer*>(widget); 01438 if (dc) 01439 { 01440 d->isContainer=true; 01441 manager->d->containerDocks.append(this); 01442 } 01443 else 01444 { 01445 d->isContainer=false; 01446 } 01447 01448 { 01449 header->show(); 01450 layout->addWidget( header ); 01451 layout->addWidget( widget,1 ); 01452 } 01453 updateHeader(); 01454 emit widgetSet(mw); 01455 } 01456 01457 void KDockWidget::setDockTabName( KDockTabGroup* tab ) 01458 { 01459 QString listOfName; 01460 QString listOfCaption; 01461 for ( int i = 0; i < tab->count(); ++i ) { 01462 QWidget *w = tab->page( i ); 01463 listOfCaption.append( w->caption() ).append(","); 01464 listOfName.append( w->name() ).append(","); 01465 } 01466 listOfCaption.remove( listOfCaption.length()-1, 1 ); 01467 listOfName.remove( listOfName.length()-1, 1 ); 01468 01469 tab->parentWidget()->setName( listOfName.utf8() ); 01470 tab->parentWidget()->setCaption( listOfCaption ); 01471 01472 tab->parentWidget()->repaint( false ); // KDockWidget->repaint 01473 if ( tab->parentWidget()->parent() ) 01474 if ( tab->parentWidget()->parent()->inherits("KDockSplitter") ) 01475 ((KDockSplitter*)(tab->parentWidget()->parent()))->updateName(); 01476 } 01477 01478 bool KDockWidget::mayBeHide() const 01479 { 01480 bool f = (parent() != manager->main); 01481 return ( !isGroup && !isTabGroup && f && isVisible() && ( eDocking != (int)KDockWidget::DockNone ) ); 01482 } 01483 01484 bool KDockWidget::mayBeShow() const 01485 { 01486 bool f = (parent() != manager->main); 01487 return ( !isGroup && !isTabGroup && f && !isVisible() ); 01488 } 01489 01490 void KDockWidget::changeHideShowState() 01491 { 01492 if ( mayBeHide() ){ 01493 undock(); 01494 return; 01495 } 01496 01497 if ( mayBeShow() ){ 01498 if ( manager->main->inherits("KDockMainWindow") ){ 01499 ((KDockMainWindow*)manager->main)->makeDockVisible(this); 01500 } else { 01501 makeDockVisible(); 01502 } 01503 } 01504 } 01505 01506 void KDockWidget::makeDockVisible() 01507 { 01508 if ( parentDockTabGroup() ){ 01509 parentDockTabGroup()->showPage( this ); 01510 } 01511 if (parentDockContainer()) { 01512 QWidget *contWid=parentDockContainer(); 01513 KDockContainer *x = dynamic_cast<KDockContainer*>(contWid); 01514 if (x) { 01515 x->showWidget(this); 01516 } 01517 } 01518 if ( isVisible() ) return; 01519 01520 QWidget* p = parentWidget(); 01521 while ( p ){ 01522 if ( !p->isVisible() ) 01523 p->show(); 01524 p = p->parentWidget(); 01525 } 01526 if( parent() == 0L) // is undocked 01527 dockBack(); 01528 show(); 01529 } 01530 01531 void KDockWidget::setFormerBrotherDockWidget(KDockWidget *dockWidget) 01532 { 01533 formerBrotherDockWidget = dockWidget; 01534 if( formerBrotherDockWidget != 0L) 01535 QObject::connect( formerBrotherDockWidget, SIGNAL(iMBeingClosed()), 01536 this, SLOT(loseFormerBrotherDockWidget()) ); 01537 } 01538 01539 void KDockWidget::loseFormerBrotherDockWidget() 01540 { 01541 if( formerBrotherDockWidget != 0L) 01542 QObject::disconnect( formerBrotherDockWidget, SIGNAL(iMBeingClosed()), 01543 this, SLOT(loseFormerBrotherDockWidget()) ); 01544 formerBrotherDockWidget = 0L; 01545 repaint(); 01546 } 01547 01548 void KDockWidget::dockBack() 01549 { 01550 if( formerBrotherDockWidget) { 01551 // search all children if it tries to dock back to a child 01552 bool found = false; 01553 QObjectList* cl = queryList("KDockWidget"); 01554 QObjectListIt it( *cl ); 01555 QObject * obj; 01556 while ( !found && (obj=it.current()) != 0 ) { 01557 ++it; 01558 QWidget* widg = (QWidget*)obj; 01559 if( widg == formerBrotherDockWidget) 01560 found = true; 01561 } 01562 delete cl; 01563 01564 if( !found) { 01565 // can dock back to the former brother dockwidget 01566 manualDock( formerBrotherDockWidget, formerDockPos, d->splitPosInPercent, QPoint(0,0), false, d->index); 01567 formerBrotherDockWidget = 0L; 01568 makeDockVisible(); 01569 return; 01570 } 01571 } 01572 01573 // else dockback to the dockmainwindow (default behavior) 01574 manualDock( ((KDockMainWindow*)manager->main)->getMainDockWidget(), formerDockPos, d->splitPosInPercent, QPoint(0,0), false, d->index); 01575 formerBrotherDockWidget = 0L; 01576 if (parent()) 01577 makeDockVisible(); 01578 } 01579 01580 bool KDockWidget::isDockBackPossible() const 01581 { 01582 if( (formerBrotherDockWidget == 0L) || !(formerBrotherDockWidget->dockSite() & formerDockPos)) 01583 return false; 01584 else 01585 return true; 01586 } 01587 01588 /**************************************************************************************/ 01589 01590 01591 KDockManager::KDockManager( QWidget* mainWindow , const char* name ) 01592 :QObject( mainWindow, name ) 01593 ,main(mainWindow) 01594 ,currentDragWidget(0L) 01595 ,currentMoveWidget(0L) 01596 ,childDockWidgetList(0L) 01597 ,autoCreateDock(0L) 01598 ,storeW(0) 01599 ,storeH(0) 01600 ,dragging(false) 01601 ,undockProcess(false) 01602 ,dropCancel(true) 01603 { 01604 d = new KDockManagerPrivate; 01605 01606 d->readyToDrag = false; 01607 d->mainDockWidget=0; 01608 01609 #ifndef NO_KDE2 01610 d->splitterOpaqueResize = KGlobalSettings::opaqueResize(); 01611 #else 01612 d->splitterOpaqueResize = false; 01613 #endif 01614 01615 d->splitterKeepSize = false; 01616 d->splitterHighResolution = false; 01617 d->m_readDockConfigMode = WrapExistingWidgetsOnly; // default as before 01618 01619 main->installEventFilter( this ); 01620 01621 undockProcess = false; 01622 01623 menuData = new QPtrList<MenuDockData>; 01624 menuData->setAutoDelete( true ); 01625 menuData->setAutoDelete( true ); 01626 01627 #ifndef NO_KDE2 01628 menu = new KPopupMenu(); 01629 #else 01630 menu = new QPopupMenu(); 01631 #endif 01632 01633 connect( menu, SIGNAL(aboutToShow()), SLOT(slotMenuPopup()) ); 01634 connect( menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int)) ); 01635 01636 childDock = new QObjectList(); 01637 childDock->setAutoDelete( false ); 01638 } 01639 01640 01641 void KDockManager::setMainDockWidget2(KDockWidget *w) 01642 { 01643 d->mainDockWidget=w; 01644 } 01645 01646 KDockManager::~KDockManager() 01647 { 01648 delete menuData; 01649 delete menu; 01650 01651 QObjectListIt it( *childDock ); 01652 KDockWidget * obj; 01653 01654 while ( (obj=(KDockWidget*)it.current()) ) { 01655 delete obj; 01656 } 01657 delete childDock; 01658 delete d; 01659 d=0; 01660 } 01661 01662 void KDockManager::activate() 01663 { 01664 QObjectListIt it( *childDock ); 01665 KDockWidget * obj; 01666 01667 while ( (obj=(KDockWidget*)it.current()) ) { 01668 ++it; 01669 if ( obj->widget ) obj->widget->show(); 01670 if ( !obj->parentDockTabGroup() ){ 01671 obj->show(); 01672 } 01673 } 01674 if ( !main->inherits("QDialog") ) main->show(); 01675 } 01676 01677 bool KDockManager::eventFilter( QObject *obj, QEvent *event ) 01678 { 01679 01680 if ( obj->inherits("KDockWidgetAbstractHeaderDrag") ){ 01681 KDockWidget* pDockWdgAtCursor = 0L; 01682 KDockWidget* curdw = ((KDockWidgetAbstractHeaderDrag*)obj)->dockWidget(); 01683 switch ( event->type() ){ 01684 case QEvent::MouseButtonDblClick: 01685 if (curdw->currentDockPos == KDockWidget::DockDesktop) curdw->dockBack(); 01686 else 01687 { 01688 curdw->toDesktop(); 01689 // curdw->manualDock (0, KDockWidget::DockDesktop); 01690 } 01691 break; 01692 01693 case QEvent::MouseButtonPress: 01694 if ( ((QMouseEvent*)event)->button() == LeftButton ){ 01695 if ( curdw->eDocking != (int)KDockWidget::DockNone ){ 01696 dropCancel = true; 01697 curdw->setFocus(); 01698 qApp->processOneEvent(); 01699 01700 currentDragWidget = curdw; 01701 currentMoveWidget = 0L; 01702 childDockWidgetList = new QWidgetList(); 01703 childDockWidgetList->append( curdw ); 01704 findChildDockWidget( curdw, childDockWidgetList ); 01705 01706 //d->oldDragRect = QRect(); should fix rectangle not erased problem 01707 d->dragRect = QRect(curdw->geometry()); 01708 QPoint p = curdw->mapToGlobal(QPoint(0,0)); 01709 d->dragRect.moveTopLeft(p); 01710 drawDragRectangle(); 01711 d->readyToDrag = true; 01712 01713 d->dragOffset = QCursor::pos()-currentDragWidget->mapToGlobal(QPoint(0,0)); 01714 } 01715 01716 } 01717 break; 01718 case QEvent::MouseButtonRelease: 01719 if ( ((QMouseEvent*)event)->button() == LeftButton ){ 01720 if ( dragging ){ 01721 if ( !dropCancel ) 01722 drop(); 01723 else 01724 cancelDrop(); 01725 } 01726 if (d->readyToDrag) { 01727 d->readyToDrag = false; 01728 //d->oldDragRect = QRect(); should fix rectangle not erased problem 01729 d->dragRect = QRect(curdw->geometry()); 01730 QPoint p = curdw->mapToGlobal(QPoint(0,0)); 01731 d->dragRect.moveTopLeft(p); 01732 drawDragRectangle(); 01733 currentDragWidget = 0L; 01734 delete childDockWidgetList; 01735 childDockWidgetList = 0L; 01736 } 01737 dragging = false; 01738 dropCancel = true; 01739 } 01740 break; 01741 case QEvent::MouseMove: 01742 if ( dragging ) { 01743 01744 #ifdef BORDERLESS_WINDOWS 01745 //BEGIN TEST 01746 KDockWidget *oldMoveWidget; 01747 if (curdw->parent()==0) 01748 { 01749 curdw->move(QCursor::pos()-d->dragOffset); 01750 pDockWdgAtCursor = findDockWidgetAt( QCursor::pos()-QPoint(0,d->dragOffset.y()+3) ); 01751 oldMoveWidget = currentMoveWidget; 01752 } 01753 else 01754 { 01755 pDockWdgAtCursor = findDockWidgetAt( QCursor::pos() ); 01756 oldMoveWidget = currentMoveWidget; 01757 } 01758 //END TEST 01759 #else 01760 pDockWdgAtCursor = findDockWidgetAt( QCursor::pos() ); 01761 KDockWidget* oldMoveWidget = currentMoveWidget; 01762 #endif 01763 01764 if ( currentMoveWidget && pDockWdgAtCursor == currentMoveWidget ) { //move 01765 dragMove( currentMoveWidget, currentMoveWidget->mapFromGlobal( QCursor::pos() ) ); 01766 break; 01767 } else { 01768 if (dropCancel && curdw) { 01769 d->dragRect = QRect(curdw->geometry()); 01770 QPoint p = curdw->mapToGlobal(QPoint(0,0)); 01771 d->dragRect.moveTopLeft(p); 01772 }else 01773 d->dragRect = QRect(); 01774 01775 drawDragRectangle(); 01776 } 01777 01778 if ( !pDockWdgAtCursor && (curdw->eDocking & (int)KDockWidget::DockDesktop) == 0 ){ 01779 // just moving at the desktop 01780 currentMoveWidget = pDockWdgAtCursor; 01781 curPos = KDockWidget::DockDesktop; 01782 } else { 01783 if ( oldMoveWidget && pDockWdgAtCursor != currentMoveWidget ) { //leave 01784 currentMoveWidget = pDockWdgAtCursor; 01785 curPos = KDockWidget::DockDesktop; 01786 } 01787 } 01788 01789 if ( oldMoveWidget != pDockWdgAtCursor && pDockWdgAtCursor ) { //enter pDockWdgAtCursor 01790 currentMoveWidget = pDockWdgAtCursor; 01791 curPos = KDockWidget::DockDesktop; 01792 } 01793 } else { 01794 if (d->readyToDrag) { 01795 d->readyToDrag = false; 01796 } 01797 if ( (((QMouseEvent*)event)->state() == LeftButton) && 01798 (curdw->eDocking != (int)KDockWidget::DockNone) ) { 01799 startDrag( curdw); 01800 } 01801 } 01802 break; 01803 default: 01804 break; 01805 } 01806 } 01807 return QObject::eventFilter( obj, event ); 01808 } 01809 01810 KDockWidget* KDockManager::findDockWidgetAt( const QPoint& pos ) 01811 { 01812 dropCancel = true; 01813 01814 if (!currentDragWidget) 01815 return 0L; // pointer access safety 01816 01817 if (currentDragWidget->eDocking == (int)KDockWidget::DockNone ) return 0L; 01818 01819 QWidget* p = QApplication::widgetAt( pos ); 01820 if ( !p ) { 01821 dropCancel = false; 01822 return 0L; 01823 } 01824 #if defined(_OS_WIN32_) || defined(Q_OS_WIN32) 01825 p = p->topLevelWidget(); 01826 #endif 01827 QWidget* w = 0L; 01828 findChildDockWidget( w, p, p->mapFromGlobal(pos) ); 01829 if ( !w ){ 01830 if ( !p->inherits("KDockWidget") ) { 01831 return 0L; 01832 } 01833 w = p; 01834 } 01835 if ( qt_find_obj_child( w, "KDockSplitter", "_dock_split_" ) ) return 0L; 01836 if ( qt_find_obj_child( w, "KDockTabGroup", "_dock_tab" ) ) return 0L; 01837 if (dynamic_cast<KDockContainer*>(w)) return 0L; 01838 01839 if (!childDockWidgetList) return 0L; 01840 if ( childDockWidgetList->find(w) != -1 ) return 0L; 01841 if ( currentDragWidget->isGroup && ((KDockWidget*)w)->parentDockTabGroup() ) return 0L; 01842 01843 KDockWidget* www = (KDockWidget*)w; 01844 if ( www->sDocking == (int)KDockWidget::DockNone ) return 0L; 01845 if( !www->widget ) 01846 return 0L; 01847 01848 KDockWidget::DockPosition curPos = KDockWidget::DockDesktop; 01849 QPoint cpos = www->mapFromGlobal( pos ); 01850 01851 int ww = www->widget->width() / 3; 01852 int hh = www->widget->height() / 3; 01853 01854 if ( cpos.y() <= hh ){ 01855 curPos = KDockWidget::DockTop; 01856 } else 01857 if ( cpos.y() >= 2*hh ){ 01858 curPos = KDockWidget::DockBottom; 01859 } else 01860 if ( cpos.x() <= ww ){ 01861 curPos = KDockWidget::DockLeft; 01862 } else 01863 if ( cpos.x() >= 2*ww ){ 01864 curPos = KDockWidget::DockRight; 01865 } else 01866 curPos = KDockWidget::DockCenter; 01867 01868 if ( !(www->sDocking & (int)curPos) ) return 0L; 01869 if ( !(currentDragWidget->eDocking & (int)curPos) ) return 0L; 01870 if ( www->manager != this ) return 0L; 01871 01872 dropCancel = false; 01873 return www; 01874 } 01875 01876 void KDockManager::findChildDockWidget( QWidget*& ww, const QWidget* p, const QPoint& pos ) 01877 { 01878 if ( p->children() ) { 01879 QWidget *w; 01880 QObjectListIt it( *p->children() ); 01881 it.toLast(); 01882 while ( it.current() ) { 01883 if ( it.current()->isWidgetType() ) { 01884 w = (QWidget*)it.current(); 01885 if ( w->isVisible() && w->geometry().contains(pos) ) { 01886 if ( w->inherits("KDockWidget") ) ww = w; 01887 findChildDockWidget( ww, w, w->mapFromParent(pos) ); 01888 return; 01889 } 01890 } 01891 --it; 01892 } 01893 } 01894 return; 01895 } 01896 01897 void KDockManager::findChildDockWidget( const QWidget* p, QWidgetList*& list ) 01898 { 01899 if ( p->children() ) { 01900 QWidget *w; 01901 QObjectListIt it( *p->children() ); 01902 it.toLast(); 01903 while ( it.current() ) { 01904 if ( it.current()->isWidgetType() ) { 01905 w = (QWidget*)it.current(); 01906 if ( w->isVisible() ) { 01907 if ( w->inherits("KDockWidget") ) list->append( w ); 01908 findChildDockWidget( w, list ); 01909 } 01910 } 01911 --it; 01912 } 01913 } 01914 return; 01915 } 01916 01917 void KDockManager::startDrag( KDockWidget* w ) 01918 { 01919 if(( w->currentDockPos == KDockWidget::DockLeft) || ( w->currentDockPos == KDockWidget::DockRight) 01920 || ( w->currentDockPos == KDockWidget::DockTop) || ( w->currentDockPos == KDockWidget::DockBottom)) { 01921 w->prevSideDockPosBeforeDrag = w->currentDockPos; 01922 01923 if ( w->parentWidget()->inherits("KDockSplitter") ){ 01924 KDockSplitter* parentSplitterOfDockWidget = (KDockSplitter*)(w->parentWidget()); 01925 w->d->splitPosInPercent = parentSplitterOfDockWidget->separatorPos(); 01926 } 01927 } 01928 01929 curPos = KDockWidget::DockDesktop; 01930 dragging = true; 01931 01932 QApplication::setOverrideCursor(QCursor(sizeAllCursor)); 01933 } 01934 01935 void KDockManager::dragMove( KDockWidget* dw, QPoint pos ) 01936 { 01937 QPoint p = dw->mapToGlobal( dw->widget->pos() ); 01938 KDockWidget::DockPosition oldPos = curPos; 01939 01940 QSize r = dw->widget->size(); 01941 if ( dw->parentDockTabGroup() ){ 01942 curPos = KDockWidget::DockCenter; 01943 if ( oldPos != curPos ) { 01944 d->dragRect.setRect( p.x()+2, p.y()+2, r.width()-4, r.height()-4 ); 01945 } 01946 return; 01947 } 01948 01949 int w = r.width() / 3; 01950 int h = r.height() / 3; 01951 01952 if ( pos.y() <= h ){ 01953 curPos = KDockWidget::DockTop; 01954 w = r.width(); 01955 } else 01956 if ( pos.y() >= 2*h ){ 01957 curPos = KDockWidget::DockBottom; 01958 p.setY( p.y() + 2*h ); 01959 w = r.width(); 01960 } else 01961 if ( pos.x() <= w ){ 01962 curPos = KDockWidget::DockLeft; 01963 h = r.height(); 01964 } else 01965 if ( pos.x() >= 2*w ){ 01966 curPos = KDockWidget::DockRight; 01967 p.setX( p.x() + 2*w ); 01968 h = r.height(); 01969 } else 01970 { 01971 curPos = KDockWidget::DockCenter; 01972 p.setX( p.x() + w ); 01973 p.setY( p.y() + h ); 01974 } 01975 01976 if ( oldPos != curPos ) { 01977 d->dragRect.setRect( p.x(), p.y(), w, h ); 01978 drawDragRectangle(); 01979 } 01980 } 01981 01982 01983 void KDockManager::cancelDrop() 01984 { 01985 QApplication::restoreOverrideCursor(); 01986 01987 delete childDockWidgetList; 01988 childDockWidgetList = 0L; 01989 01990 d->dragRect = QRect(); // cancel drawing 01991 drawDragRectangle(); // only the old rect will be deleted 01992 } 01993 01994 01995 void KDockManager::drop() 01996 { 01997 d->dragRect = QRect(); // cancel drawing 01998 drawDragRectangle(); // only the old rect will be deleted 01999 02000 QApplication::restoreOverrideCursor(); 02001 02002 delete childDockWidgetList; 02003 childDockWidgetList = 0L; 02004 02005 if ( dropCancel ) return; 02006 if ( !currentMoveWidget && ((currentDragWidget->eDocking & (int)KDockWidget::DockDesktop) == 0) ) { 02007 d->dragRect = QRect(); // cancel drawing 02008 drawDragRectangle(); // only the old rect will be deleted 02009 return; 02010 } 02011 if ( !currentMoveWidget && !currentDragWidget->parent() ) { 02012 currentDragWidget->move( QCursor::pos() - d->dragOffset ); 02013 } 02014 else { 02015 int splitPos = currentDragWidget->d->splitPosInPercent; 02016 // do we have to calculate 100%-splitPosInPercent? 02017 if( (curPos != currentDragWidget->prevSideDockPosBeforeDrag) && (curPos != KDockWidget::DockCenter) && (curPos != KDockWidget::DockDesktop)) { 02018 switch( currentDragWidget->prevSideDockPosBeforeDrag) { 02019 case KDockWidget::DockLeft: if(curPos != KDockWidget::DockTop) splitPos = 100-splitPos; break; 02020 case KDockWidget::DockRight: if(curPos != KDockWidget::DockBottom) splitPos = 100-splitPos; break; 02021 case KDockWidget::DockTop: if(curPos != KDockWidget::DockLeft) splitPos = 100-splitPos; break; 02022 case KDockWidget::DockBottom: if(curPos != KDockWidget::DockRight) splitPos = 100-splitPos; break; 02023 default: break; 02024 } 02025 } 02026 currentDragWidget->manualDock( currentMoveWidget, curPos , splitPos, QCursor::pos() - d->dragOffset ); 02027 currentDragWidget->makeDockVisible(); 02028 } 02029 } 02030 02031 02032 static QDomElement createStringEntry(QDomDocument &doc, const QString &tagName, const QString &str) 02033 { 02034 QDomElement el = doc.createElement(tagName); 02035 02036 el.appendChild(doc.createTextNode(str)); 02037 return el; 02038 } 02039 02040 02041 static QDomElement createBoolEntry(QDomDocument &doc, const QString &tagName, bool b) 02042 { 02043 return createStringEntry(doc, tagName, QString::fromLatin1(b? "true" : "false")); 02044 } 02045 02046 02047 static QDomElement createNumberEntry(QDomDocument &doc, const QString &tagName, int n) 02048 { 02049 return createStringEntry(doc, tagName, QString::number(n)); 02050 } 02051 02052 02053 static QDomElement createRectEntry(QDomDocument &doc, const QString &tagName, const QRect &rect) 02054 { 02055 QDomElement el = doc.createElement(tagName); 02056 02057 QDomElement xel = doc.createElement("x"); 02058 xel.appendChild(doc.createTextNode(QString::number(rect.x()))); 02059 el.appendChild(xel); 02060 QDomElement yel = doc.createElement("y"); 02061 yel.appendChild(doc.createTextNode(QString::number(rect.y()))); 02062 el.appendChild(yel); 02063 QDomElement wel = doc.createElement("width"); 02064 wel.appendChild(doc.createTextNode(QString::number(rect.width()))); 02065 el.appendChild(wel); 02066 QDomElement hel = doc.createElement("height"); 02067 hel.appendChild(doc.createTextNode(QString::number(rect.height()))); 02068 el.appendChild(hel); 02069 02070 return el; 02071 } 02072 02073 02074 static QDomElement createListEntry(QDomDocument &doc, const QString &tagName, 02075 const QString &subTagName, const QStrList &list) 02076 { 02077 QDomElement el = doc.createElement(tagName); 02078 02079 QStrListIterator it(list); 02080 for (; it.current(); ++it) { 02081 QDomElement subel = doc.createElement(subTagName); 02082 subel.appendChild(doc.createTextNode(QString::fromLatin1(it.current()))); 02083 el.appendChild(subel); 02084 } 02085 02086 return el; 02087 } 02088 02089 02090 static QString stringEntry(QDomElement &base, const QString &tagName) 02091 { 02092 return base.namedItem(tagName).firstChild().toText().data(); 02093 } 02094 02095 02096 static bool boolEntry(QDomElement &base, const QString &tagName) 02097 { 02098 return base.namedItem(tagName).firstChild().toText().data() == "true"; 02099 } 02100 02101 02102 static int numberEntry(QDomElement &base, const QString &tagName) 02103 { 02104 return stringEntry(base, tagName).toInt(); 02105 } 02106 02107 02108 static QRect rectEntry(QDomElement &base, const QString &tagName) 02109 { 02110 QDomElement el = base.namedItem(tagName).toElement(); 02111 02112 int x = numberEntry(el, "x"); 02113 int y = numberEntry(el, "y"); 02114 int width = numberEntry(el, "width"); 02115 int height = numberEntry(el, "height"); 02116 02117 return QRect(x, y, width, height); 02118 } 02119 02120 02121 static QStrList listEntry(QDomElement &base, const QString &tagName, const QString &subTagName) 02122 { 02123 QStrList list; 02124 02125 QDomElement subel = base.namedItem(tagName).firstChild().toElement(); 02126 while (!subel.isNull()) { 02127 if (subel.tagName() == subTagName) 02128 list.append(subel.firstChild().toText().data().latin1()); 02129 subel = subel.nextSibling().toElement(); 02130 } 02131 02132 return list; 02133 } 02134 02135 02136 void KDockManager::writeConfig(QDomElement &base) 02137 { 02138 // First of all, clear the tree under base 02139 while (!base.firstChild().isNull()) 02140 base.removeChild(base.firstChild()); 02141 QDomDocument doc = base.ownerDocument(); 02142 02143 QStrList nameList; 02144 QString mainWidgetStr; 02145 02146 // collect widget names 02147 QStringList nList; 02148 QObjectListIt it(*childDock); 02149 KDockWidget *obj1; 02150 while ( (obj1=(KDockWidget*)it.current()) ) { 02151 if ( obj1->parent() == main ) 02152 mainWidgetStr = QString::fromLatin1(obj1->name()); 02153 nList.append(obj1->name()); 02154 ++it; 02155 } 02156 02157 for (QObjectListIt it(d->containerDocks);it.current();++it) 02158 { 02159 KDockContainer* dc = dynamic_cast<KDockContainer*>(((KDockWidget*)it.current())->widget); 02160 if (dc) { 02161 dc->prepareSave(nList); 02162 } 02163 } 02164 02165 QStringList::Iterator nListIt=nList.begin(); 02166 while ( nListIt!=nList.end() ) { 02167 KDockWidget *obj = getDockWidgetFromName( *nListIt); 02168 if ((obj->isGroup && (!obj->d->isContainer)) && (nameList.find( obj->firstName.latin1() ) == -1 02169 || nameList.find(obj->lastName.latin1()) == -1)) { 02170 // Skip until children are saved (why?) 02171 ++nListIt; 02172 // nList.next(); 02173 //falk? if ( !nList.current() ) nList.first(); 02174 continue; 02175 } 02176 02177 QDomElement groupEl; 02178 if (obj->d->isContainer) { 02179 KDockContainer* x = dynamic_cast<KDockContainer*>(obj->widget); 02180 if (x) { 02181 groupEl=doc.createElement("dockContainer"); 02182 x->save(groupEl); 02183 } 02184 } else 02185 if (obj->isGroup) { 02187 groupEl = doc.createElement("splitGroup"); 02188 02189 groupEl.appendChild(createStringEntry(doc, "firstName", obj->firstName)); 02190 groupEl.appendChild(createStringEntry(doc, "secondName", obj->lastName)); 02191 groupEl.appendChild(createNumberEntry(doc, "orientation", (int)obj->splitterOrientation)); 02192 groupEl.appendChild(createNumberEntry(doc, "separatorPos", ((KDockSplitter*)obj->widget)->separatorPos())); 02193 } else if (obj->isTabGroup) { 02195 groupEl = doc.createElement("tabGroup"); 02196 02197 QStrList list; 02198 for ( int i = 0; i < ((KDockTabGroup*)obj->widget)->count(); ++i ) 02199 list.append( ((KDockTabGroup*)obj->widget)->page( i )->name() ); 02200 groupEl.appendChild(createListEntry(doc, "tabs", "tab", list)); 02201 groupEl.appendChild(createNumberEntry(doc, "currentTab", ((KDockTabGroup*)obj->widget)->currentPageIndex())); 02202 if (!obj->parent()) { 02203 groupEl.appendChild(createStringEntry(doc, "dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : "")); 02204 groupEl.appendChild(createNumberEntry(doc, "dockBackToPos", obj->formerDockPos)); 02205 } 02206 } else { 02208 groupEl = doc.createElement("dock"); 02209 groupEl.appendChild(createStringEntry(doc, "tabCaption", obj->tabPageLabel())); 02210 groupEl.appendChild(createStringEntry(doc, "tabToolTip", obj->toolTipString())); 02211 if (!obj->parent()) { 02212 groupEl.appendChild(createStringEntry(doc, "dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : "")); 02213 groupEl.appendChild(createNumberEntry(doc, "dockBackToPos", obj->formerDockPos)); 02214 } 02215 } 02216 02217 groupEl.appendChild(createStringEntry(doc, "name", QString::fromLatin1(obj->name()))); 02218 groupEl.appendChild(createBoolEntry(doc, "hasParent", obj->parent())); 02219 if ( !obj->parent() ) { 02220 groupEl.appendChild(createRectEntry(doc, "geometry", QRect(main->frameGeometry().topLeft(), main->size()))); 02221 groupEl.appendChild(createBoolEntry(doc, "visible", obj->isVisible())); 02222 } 02223 if (obj->header && obj->header->inherits("KDockWidgetHeader")) { 02224 KDockWidgetHeader *h = static_cast<KDockWidgetHeader*>(obj->header); 02225 groupEl.appendChild(createBoolEntry(doc, "dragEnabled", h->dragEnabled())); 02226 } 02227 02228 base.appendChild(groupEl); 02229 nameList.append(obj->name()); 02230 nList.remove(nListIt); 02231 nListIt=nList.begin(); 02232 } 02233 02234 if (main->inherits("KDockMainWindow")) { 02235 KDockMainWindow *dmain = (KDockMainWindow*)main; 02236 QString centralWidgetStr = QString(dmain->centralWidget()? dmain->centralWidget()->name() : ""); 02237 base.appendChild(createStringEntry(doc, "centralWidget", centralWidgetStr)); 02238 QString mainDockWidgetStr = QString(dmain->getMainDockWidget()? dmain->getMainDockWidget()->name() : ""); 02239 base.appendChild(createStringEntry(doc, "mainDockWidget", mainDockWidgetStr)); 02240 } else { 02241 base.appendChild(createStringEntry(doc, "mainWidget", mainWidgetStr)); 02242 } 02243 02244 base.appendChild(createRectEntry(doc, "geometry", QRect(main->frameGeometry().topLeft(), main->size()))); 02245 } 02246 02247 02248 void KDockManager::readConfig(QDomElement &base) 02249 { 02250 if (base.namedItem("group").isNull() 02251 && base.namedItem("tabgroup").isNull() 02252 && base.namedItem("dock").isNull() 02253 && base.namedItem("dockContainer").isNull()) { 02254 activate(); 02255 return; 02256 } 02257 02258 autoCreateDock = new QObjectList(); 02259 autoCreateDock->setAutoDelete( true ); 02260 02261 bool isMainVisible = main->isVisible(); 02262 main->hide(); 02263 02264 QObjectListIt it(*childDock); 02265 KDockWidget *obj1; 02266 while ( (obj1=(KDockWidget*)it.current()) ) { 02267 if ( !obj1->isGroup && !obj1->isTabGroup ) { 02268 if ( obj1->parent() ) 02269 obj1->undock(); 02270 else 02271 obj1->hide(); 02272 } 02273 ++it; 02274 } 02275 02276 // firstly, recreate all common dockwidgets 02277 QDomElement childEl = base.firstChild().toElement(); 02278 while (!childEl.isNull() ) { 02279 KDockWidget *obj = 0; 02280 02281 if (childEl.tagName() != "dock") { 02282 childEl = childEl.nextSibling().toElement(); 02283 continue; 02284 } 02285 // Read an ordinary dock widget 02286 obj = getDockWidgetFromName(stringEntry(childEl, "name")); 02287 obj->setTabPageLabel(stringEntry(childEl, "tabCaption")); 02288 obj->setToolTipString(stringEntry(childEl, "tabToolTip")); 02289 02290 if (!boolEntry(childEl, "hasParent")) { 02291 QRect r = rectEntry(childEl, "geometry"); 02292 obj = getDockWidgetFromName(stringEntry(childEl, "name")); 02293 obj->applyToWidget(0); 02294 obj->setGeometry(r); 02295 if (boolEntry(childEl, "visible")) 02296 obj->QWidget::show(); 02297 } 02298 02299 if (obj && obj->header && obj->header->inherits("KDockWidgetHeader")) { 02300 KDockWidgetHeader *h = static_cast<KDockWidgetHeader*>(obj->header); 02301 h->setDragEnabled(boolEntry(childEl, "dragEnabled")); 02302 } 02303 02304 childEl = childEl.nextSibling().toElement(); 02305 } 02306 02307 // secondly, now iterate again and create the groups and tabwidgets, apply the dockwidgets to them 02308 childEl = base.firstChild().toElement(); 02309 while (!childEl.isNull() ) { 02310 KDockWidget *obj = 0; 02311 02312 if (childEl.tagName() == "dockContainer") { 02313 02314 KDockWidget *cont=getDockWidgetFromName(stringEntry(childEl, "name")); 02315 kdDebug()<<"dockContainer: "<<stringEntry(childEl,"name")<<endl; 02316 if (!(cont->d->isContainer)) { 02317 kdDebug()<<"restoration of dockContainer is only supported for already existing dock containers"<<endl; 02318 } else { 02319 KDockContainer *dc=dynamic_cast<KDockContainer*>(cont->getWidget()); 02320 if (!dc) kdDebug()<<"Error while trying to handle dockcontainer configuration restoration"<<endl; 02321 else { 02322 dc->load(childEl); 02323 removeFromAutoCreateList(cont); 02324 } 02325 02326 } 02327 } 02328 else 02329 if (childEl.tagName() == "splitGroup") { 02330 // Read a group 02331 QString name = stringEntry(childEl, "name"); 02332 QString firstName = stringEntry(childEl, "firstName"); 02333 QString secondName = stringEntry(childEl, "secondName"); 02334 int orientation = numberEntry(childEl, "orientation"); 02335 int separatorPos = numberEntry(childEl, "separatorPos"); 02336 02337 KDockWidget *first = getDockWidgetFromName(firstName); 02338 KDockWidget *second = getDockWidgetFromName(secondName); 02339 if (first && second) { 02340 obj = first->manualDock(second, 02341 (orientation == (int)Vertical)? KDockWidget::DockLeft : KDockWidget::DockTop, 02342 separatorPos); 02343 if (obj) 02344 obj->setName(name.latin1()); 02345 } 02346 } else if (childEl.tagName() == "tabGroup") { 02347 // Read a tab group 02348 QString name = stringEntry(childEl, "name"); 02349 QStrList list = listEntry(childEl, "tabs", "tab"); 02350 02351 KDockWidget *d1 = getDockWidgetFromName( list.first() ); 02352 list.next(); 02353 KDockWidget *d2 = getDockWidgetFromName( list.current() ); 02354 02355 KDockWidget *obj = d2->manualDock( d1, KDockWidget::DockCenter ); 02356 if (obj) { 02357 KDockTabGroup *tab = (KDockTabGroup*)obj->widget; 02358 list.next(); 02359 while (list.current() && obj) { 02360 KDockWidget *tabDock = getDockWidgetFromName(list.current()); 02361 obj = tabDock->manualDock(d1, KDockWidget::DockCenter); 02362 list.next(); 02363 } 02364 if (obj) { 02365 obj->setName(name.latin1()); 02366 tab->showPage(tab->page(numberEntry(childEl, "currentTab"))); 02367 } 02368 } 02369 } else { 02370 childEl = childEl.nextSibling().toElement(); 02371 continue; 02372 } 02373 02374 if (!boolEntry(childEl, "hasParent")) { 02375 QRect r = rectEntry(childEl, "geometry"); 02376 obj = getDockWidgetFromName(stringEntry(childEl, "name")); 02377 obj->applyToWidget(0); 02378 obj->setGeometry(r); 02379 if (boolEntry(childEl, "visible")) 02380 obj->QWidget::show(); 02381 } 02382 02383 if (obj && obj->header && obj->header->inherits("KDockWidgetHeader")) { 02384 KDockWidgetHeader *h = static_cast<KDockWidgetHeader*>(obj->header); 02385 h->setDragEnabled(boolEntry(childEl, "dragEnabled")); 02386 } 02387 02388 childEl = childEl.nextSibling().toElement(); 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 childEl = base.firstChild().toElement(); 02394 while (!childEl.isNull() ) { 02395 KDockWidget *obj = 0; 02396 02397 if (childEl.tagName() != "dock" && childEl.tagName() != "tabGroup") { 02398 childEl = childEl.nextSibling().toElement(); 02399 continue; 02400 } 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 childEl = childEl.nextSibling().toElement(); 02413 } 02414 02415 if (main->inherits("KDockMainWindow")) { 02416 KDockMainWindow *dmain = (KDockMainWindow*)main; 02417 02418 QString mv = stringEntry(base, "centralWidget"); 02419 if (!mv.isEmpty() && getDockWidgetFromName(mv) ) { 02420 KDockWidget *mvd = getDockWidgetFromName(mv); 02421 mvd->applyToWidget(dmain); 02422 mvd->show(); 02423 dmain->setCentralWidget(mvd); 02424 } 02425 QString md = stringEntry(base, "mainDockWidget"); 02426 if (!md.isEmpty() && getDockWidgetFromName(md)) { 02427 KDockWidget *mvd = getDockWidgetFromName(md); 02428 dmain->setMainDockWidget(mvd); 02429 } 02430 } else { 02431 QString mv = stringEntry(base, "mainWidget"); 02432 if (!mv.isEmpty() && getDockWidgetFromName(mv)) { 02433 KDockWidget *mvd = getDockWidgetFromName(mv); 02434 mvd->applyToWidget(main); 02435 mvd->show(); 02436 } 02437 02438 // only resize + move non-mainwindows 02439 QRect mr = rectEntry(base, "geometry"); 02440 main->move(mr.topLeft()); 02441 main->resize(mr.size()); 02442 } 02443 02444 if (isMainVisible) 02445 main->show(); 02446 02447 if (d->m_readDockConfigMode == WrapExistingWidgetsOnly) { 02448 finishReadDockConfig(); // remove empty dockwidgets 02449 } 02450 } 02451 02452 void KDockManager::removeFromAutoCreateList(KDockWidget* pDockWidget) 02453 { 02454 if (!autoCreateDock) return; 02455 autoCreateDock->setAutoDelete(false); 02456 autoCreateDock->removeRef(pDockWidget); 02457 autoCreateDock->setAutoDelete(true); 02458 } 02459 02460 void KDockManager::finishReadDockConfig() 02461 { 02462 delete autoCreateDock; 02463 autoCreateDock = 0; 02464 } 02465 02466 void KDockManager::setReadDockConfigMode(int mode) 02467 { 02468 d->m_readDockConfigMode = mode; 02469 } 02470 02471 #ifndef NO_KDE2 02472 void KDockManager::writeConfig( KConfig* c, QString group ) 02473 { 02474 //debug("BEGIN Write Config"); 02475 if ( !c ) c = KGlobal::config(); 02476 if ( group.isEmpty() ) group = "dock_setting_default"; 02477 02478 c->setGroup( group ); 02479 c->writeEntry( "Version", DOCK_CONFIG_VERSION ); 02480 02481 QStringList nameList; 02482 QStringList findList; 02483 QObjectListIt it( *childDock ); 02484 KDockWidget * obj; 02485 02486 // collect KDockWidget's name 02487 QStringList nList; 02488 while ( (obj=(KDockWidget*)it.current()) ) { 02489 ++it; 02490 //debug(" +Add subdock %s", obj->name()); 02491 nList.append( obj->name() ); 02492 if ( obj->parent() == main ) 02493 c->writeEntry( "Main:view", obj->name() ); 02494 } 02495 02496 // kdDebug()<<QString("list size: %1").arg(nList.count())<<endl; 02497 for (QObjectListIt it(d->containerDocks);it.current();++it) 02498 { 02499 KDockContainer* dc = dynamic_cast<KDockContainer*>(((KDockWidget*)it.current())->widget); 02500 if (dc) { 02501 dc->prepareSave(nList); 02502 } 02503 } 02504 // kdDebug()<<QString("new list size: %1").arg(nList.count())<<endl; 02505 02506 QStringList::Iterator nListIt=nList.begin(); 02507 while ( nListIt!=nList.end() ){ 02508 //debug(" -Try to save %s", nList.current()); 02509 obj = getDockWidgetFromName( *nListIt ); 02510 QString cname = obj->name(); 02511 if ( obj->header ){ 02512 obj->header->saveConfig( c ); 02513 } 02514 if (obj->d->isContainer) { 02515 KDockContainer* x = dynamic_cast<KDockContainer*>(obj->widget); 02516 if (x) { 02517 x->save(c,group); 02518 } 02519 } 02520 /*************************************************************************************************/ 02521 if ( obj->isGroup ){ 02522 if ( (findList.find( obj->firstName ) != findList.end()) && (findList.find( obj->lastName ) != findList.end() )){ 02523 02524 c->writeEntry( cname+":type", "GROUP"); 02525 if ( !obj->parent() ){ 02526 c->writeEntry( cname+":parent", "___null___"); 02527 c->writeEntry( cname+":geometry", QRect(obj->frameGeometry().topLeft(), obj->size()) ); 02528 c->writeEntry( cname+":visible", obj->isVisible()); 02529 } else { 02530 c->writeEntry( cname+":parent", "yes"); 02531 } 02532 c->writeEntry( cname+":first_name", obj->firstName ); 02533 c->writeEntry( cname+":last_name", obj->lastName ); 02534 c->writeEntry( cname+":orientation", (int)obj->splitterOrientation ); 02535 c->writeEntry( cname+":sepPos", ((KDockSplitter*)obj->widget)->separatorPos() ); 02536 02537 nameList.append( obj->name() ); 02538 findList.append( obj->name() ); 02539 //debug(" Save %s", nList.current()); 02540 nList.remove(nListIt); 02541 nListIt=nList.begin(); //nList.first(); 02542 } else { 02543 /*************************************************************************************************/ 02544 //debug(" Skip %s", nList.current()); 02545 //if ( findList.find( obj->firstName ) == -1 ) 02546 // debug(" ? Not found %s", obj->firstName); 02547 //if ( findList.find( obj->lastName ) == -1 ) 02548 // debug(" ? Not found %s", obj->lastName); 02549 ++nListIt; 02550 // if ( !nList.current() ) nList.first(); 02551 if (nListIt==nList.end()) nListIt=nList.begin(); 02552 } 02553 } else { 02554 /*************************************************************************************************/ 02555 if ( obj->isTabGroup){ 02556 c->writeEntry( cname+":type", "TAB_GROUP"); 02557 if ( !obj->parent() ){ 02558 c->writeEntry( cname+":parent", "___null___"); 02559 c->writeEntry( cname+":geometry", QRect(obj->frameGeometry().topLeft(), obj->size()) ); 02560 c->writeEntry( cname+":visible", obj->isVisible()); 02561 c->writeEntry( cname+":dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : ""); 02562 c->writeEntry( cname+":dockBackToPos", obj->formerDockPos); 02563 } else { 02564 c->writeEntry( cname+":parent", "yes"); 02565 } 02566 QStrList list; 02567 for ( int i = 0; i < ((KDockTabGroup*)obj->widget)->count(); ++i ) 02568 list.append( ((KDockTabGroup*)obj->widget)->page( i )->name() ); 02569 c->writeEntry( cname+":tabNames", list ); 02570 c->writeEntry( cname+":curTab", ((KDockTabGroup*)obj->widget)->currentPageIndex() ); 02571 02572 nameList.append( obj->name() ); 02573 findList.append( obj->name() ); // not really need !!! 02574 //debug(" Save %s", nList.current()); 02575 nList.remove(nListIt); 02576 nListIt=nList.begin(); 02577 } else { 02578 /*************************************************************************************************/ 02579 c->writeEntry( cname+":tabCaption", obj->tabPageLabel()); 02580 c->writeEntry( cname+":tabToolTip", obj->toolTipString()); 02581 if ( !obj->parent() ){ 02582 c->writeEntry( cname+":type", "NULL_DOCK"); 02583 c->writeEntry( cname+":geometry", QRect(obj->frameGeometry().topLeft(), obj->size()) ); 02584 c->writeEntry( cname+":visible", obj->isVisible()); 02585 c->writeEntry( cname+":dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : ""); 02586 c->writeEntry( cname+":dockBackToPos", obj->formerDockPos); 02587 } else { 02588 c->writeEntry( cname+":type", "DOCK"); 02589 } 02590 nameList.append( cname.latin1() ); 02591 //debug(" Save %s", nList.current()); 02592 findList.append( obj->name() ); 02593 nList.remove(nListIt); 02594 nListIt=nList.begin(); 02595 } 02596 } 02597 } 02598 c->writeEntry( "NameList", nameList ); 02599 02600 c->writeEntry( "Main:Geometry", QRect(main->frameGeometry().topLeft(), main->size()) ); 02601 c->writeEntry( "Main:visible", main->isVisible()); // curently nou use 02602 02603 if ( main->inherits("KDockMainWindow") ){ 02604 KDockMainWindow* dmain = (KDockMainWindow*)main; 02605 // for KDockMainWindow->setView() in readConfig() 02606 c->writeEntry( "Main:view", dmain->centralWidget() ? dmain->centralWidget()->name():"" ); 02607 c->writeEntry( "Main:dock", dmain->getMainDockWidget() ? dmain->getMainDockWidget()->name() :"" ); 02608 } 02609 02610 c->sync(); 02611 //debug("END Write Config"); 02612 } 02613 #include <qmessagebox.h> 02614 void KDockManager::readConfig( KConfig* c, QString group ) 02615 { 02616 if ( !c ) c = KGlobal::config(); 02617 if ( group.isEmpty() ) group = "dock_setting_default"; 02618 02619 c->setGroup( group ); 02620 QStrList nameList; 02621 c->readListEntry( "NameList", nameList ); 02622 QString ver = c->readEntry( "Version", "0.0.1" ); 02623 nameList.first(); 02624 if ( !nameList.current() || ver != DOCK_CONFIG_VERSION ){ 02625 activate(); 02626 return; 02627 } 02628 02629 autoCreateDock = new QObjectList(); 02630 autoCreateDock->setAutoDelete( true ); 02631 02632 bool isMainVisible = main->isVisible(); 02633 // if (isMainVisible) // CCC 02634 //QMessageBox::information(0,"","hallo"); 02635 //COMMENTED4TESTING main->hide(); 02636 02637 QObjectListIt it( *childDock ); 02638 KDockWidget * obj; 02639 02640 while ( (obj=(KDockWidget*)it.current()) ){ 02641 ++it; 02642 if ( !obj->isGroup && !obj->isTabGroup ) 02643 { 02644 if ( obj->parent() ) obj->undock(); else obj->hide(); 02645 } 02646 } 02647 02648 // firstly, only the common dockwidgets, 02649 // they must be restored before e.g. tabgroups are restored 02650 nameList.first(); 02651 while ( nameList.current() ){ 02652 QString oname = nameList.current(); 02653 c->setGroup( group ); 02654 QString type = c->readEntry( oname + ":type" ); 02655 obj = 0L; 02656 02657 if ( type == "NULL_DOCK" || c->readEntry( oname + ":parent") == "___null___" ){ 02658 QRect r = c->readRectEntry( oname + ":geometry" ); 02659 obj = getDockWidgetFromName( oname ); 02660 obj->applyToWidget( 0L ); 02661 obj->setGeometry(r); 02662 02663 c->setGroup( group ); 02664 obj->setTabPageLabel(c->readEntry( oname + ":tabCaption" )); 02665 obj->setToolTipString(c->readEntry( oname + ":tabToolTip" )); 02666 if ( c->readBoolEntry( oname + ":visible" ) ){ 02667 obj->QWidget::show(); 02668 } 02669 } 02670 02671 if ( type == "DOCK" ){ 02672 obj = getDockWidgetFromName( oname ); 02673 obj->setTabPageLabel(c->readEntry( oname + ":tabCaption" )); 02674 obj->setToolTipString(c->readEntry( oname + ":tabToolTip" )); 02675 } 02676 02677 if (obj && obj->d->isContainer) { 02678 dynamic_cast<KDockContainer*>(obj->widget)->load(c,group); 02679 removeFromAutoCreateList(obj); 02680 } 02681 if ( obj && obj->header){ 02682 obj->header->loadConfig( c ); 02683 } 02684 nameList.next(); 02685 } 02686 02687 // secondly, after the common dockwidgets, restore the groups and tabgroups 02688 nameList.first(); 02689 while ( nameList.current() ){ 02690 QString oname = nameList.current(); 02691 c->setGroup( group ); 02692 QString type = c->readEntry( oname + ":type" ); 02693 obj = 0L; 02694 02695 if ( type == "GROUP" ){ 02696 KDockWidget* first = getDockWidgetFromName( c->readEntry( oname + ":first_name" ) ); 02697 KDockWidget* last = getDockWidgetFromName( c->readEntry( oname + ":last_name" ) ); 02698 int sepPos = c->readNumEntry( oname + ":sepPos" ); 02699 02700 Orientation p = (Orientation)c->readNumEntry( oname + ":orientation" ); 02701 if ( first && last ){ 02702 obj = first->manualDock( last, ( p == Vertical ) ? KDockWidget::DockLeft : KDockWidget::DockTop, sepPos ); 02703 if (obj){ 02704 obj->setName( oname.latin1() ); 02705 } 02706 } 02707 } 02708 02709 if ( type == "TAB_GROUP" ){ 02710 QStrList list; 02711 KDockWidget* tabDockGroup = 0L; 02712 c->readListEntry( oname+":tabNames", list ); 02713 KDockWidget* d1 = getDockWidgetFromName( list.first() ); 02714 list.next(); 02715 KDockWidget* d2 = getDockWidgetFromName( list.current() ); 02716 tabDockGroup = d2->manualDock( d1, KDockWidget::DockCenter ); 02717 if ( tabDockGroup ){ 02718 KDockTabGroup* tab = (KDockTabGroup*)tabDockGroup->widget; 02719 list.next(); 02720 while ( list.current() && tabDockGroup ){ 02721 KDockWidget* tabDock = getDockWidgetFromName( list.current() ); 02722 tabDockGroup = tabDock->manualDock( d1, KDockWidget::DockCenter ); 02723 list.next(); 02724 } 02725 if ( tabDockGroup ){ 02726 tabDockGroup->setName( oname.latin1() ); 02727 c->setGroup( group ); 02728 tab->showPage( tab->page( c->readNumEntry( oname+":curTab" ) ) ); 02729 } 02730 } 02731 obj = tabDockGroup; 02732 } 02733 02734 if (obj && obj->d->isContainer) dynamic_cast<KDockContainer*>(obj->widget)->load(c,group); 02735 if ( obj && obj->header){ 02736 obj->header->loadConfig( c ); 02737 } 02738 nameList.next(); 02739 } 02740 02741 // thirdly, now that all ordinary dockwidgets are created, 02742 // iterate them again and link the toplevel ones of them with their corresponding dockwidget for the dockback action 02743 nameList.first(); 02744 while ( nameList.current() ){ 02745 QString oname = nameList.current(); 02746 c->setGroup( group ); 02747 QString type = c->readEntry( oname + ":type" ); 02748 obj = 0L; 02749 02750 if ( type == "NULL_DOCK" || c->readEntry( oname + ":parent") == "___null___" ){ 02751 obj = getDockWidgetFromName( oname ); 02752 c->setGroup( group ); 02753 QString name = c->readEntry( oname + ":dockBackTo" ); 02754 if (!name.isEmpty()) { 02755 obj->setFormerBrotherDockWidget(getDockWidgetFromName( name )); 02756 } 02757 obj->formerDockPos = KDockWidget::DockPosition(c->readNumEntry( oname + ":dockBackToPos" )); 02758 } 02759 02760 nameList.next(); 02761 } 02762 02763 if ( main->inherits("KDockMainWindow") ){ 02764 KDockMainWindow* dmain = (KDockMainWindow*)main; 02765 02766 c->setGroup( group ); 02767 QString mv = c->readEntry( "Main:view" ); 02768 if ( !mv.isEmpty() && getDockWidgetFromName( mv ) ){ 02769 KDockWidget* mvd = getDockWidgetFromName( mv ); 02770 mvd->applyToWidget( dmain ); 02771 mvd->show(); 02772 dmain->setView( mvd ); 02773 } 02774 c->setGroup( group ); 02775 QString md = c->readEntry( "Main:dock" ); 02776 if ( !md.isEmpty() && getDockWidgetFromName( md ) ){ 02777 KDockWidget* mvd = getDockWidgetFromName( md ); 02778 dmain->setMainDockWidget( mvd ); 02779 } 02780 } else { 02781 c->setGroup( group ); 02782 QString mv = c->readEntry( "Main:view" ); 02783 if ( !mv.isEmpty() && getDockWidgetFromName( mv ) ){ 02784 KDockWidget* mvd = getDockWidgetFromName( mv ); 02785 mvd->applyToWidget( main ); 02786 mvd->show(); 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.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 8 11:14:25 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003