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