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 #ifndef NO_KDE2
00931
00932 void K3DockWidget::setDockWindowType (NET::WindowType windowType)
00933 {
00934 d->windowType = windowType;
00935 applyToWidget( parentWidget(), QPoint(0,0) );
00936 }
00937
00938 #endif
00939
00940 void K3DockWidget::setDockWindowTransient (QWidget *parent, bool transientEnabled)
00941 {
00942 d->_parent = parent;
00943 d->transient = transientEnabled;
00944 applyToWidget( parentWidget(), QPoint(0,0) );
00945 }
00946
00947 QWidget *K3DockWidget::transientTo() {
00948 if (d->transient && d->_parent) return d->_parent; else return 0;
00949 }
00950
00951 bool K3DockWidget::event( QEvent *event )
00952 {
00953 switch ( event->type() )
00954 {
00955 #undef FocusIn
00956 case QEvent::FocusIn:
00957 if (widget && !d->pendingFocusInEvent) {
00958 d->pendingFocusInEvent = true;
00959 widget->setFocus();
00960 }
00961 d->pendingFocusInEvent = false;
00962 break;
00963 case QEvent::ChildRemoved:
00964 if ( widget == ((QChildEvent*)event)->child() ) widget = 0L;
00965 break;
00966 case QEvent::Show:
00967 if ( widget ) widget->show();
00968 emit manager->change();
00969 break;
00970 case QEvent::Hide:
00971 if ( widget ) widget->hide();
00972 emit manager->change();
00973 break;
00974 case QEvent::WindowTitleChange:
00975 if ( parentWidget() ){
00976 if ( parent()->inherits("K3DockSplitter") ){
00977 ((K3DockSplitter*)(parent()))->updateName();
00978 }
00979 if ( parentDockTabGroup() ){
00980 setDockTabName( parentDockTabGroup() );
00981 parentDockTabGroup()->setTabLabel( this, tabPageLabel() );
00982 }
00983 }
00984 break;
00985 case QEvent::Close:
00986 emit iMBeingClosed();
00987 break;
00988 default:
00989 break;
00990 }
00991 return QWidget::event( event );
00992 }
00993
00994 K3DockWidget *K3DockWidget::findNearestDockWidget(DockPosition pos)
00995 {
00996 if (!parent()) return 0;
00997 if (!parent()->inherits("K3DockSplitter")) return 0;
00998 Qt::Orientation orientation= ( ( pos == K3DockWidget::DockLeft) ||
00999 ( pos == K3DockWidget::DockRight ) ) ? Qt::Vertical : Qt::Horizontal;
01000 if (((K3DockSplitter*)(parent()))->orientation() == orientation)
01001 {
01002 K3DockWidget *neighbor=
01003 ( ( pos == K3DockWidget::DockLeft ) || ( pos == K3DockWidget::DockTop ) ) ?
01004 static_cast<K3DockWidget*>( ( ( K3DockSplitter* )( parent() ) )->getFirst() ) :
01005 static_cast<K3DockWidget*>( ( ( K3DockSplitter* )( parent() ) )->getLast() );
01006
01007 if (neighbor==this)
01008 return (static_cast<K3DockWidget*>(parent()->parent())->findNearestDockWidget(pos));
01009 else
01010 if (neighbor->getWidget() && qobject_cast<K3DockTabGroup*>(neighbor->getWidget()))
01011 return (K3DockWidget*)(((K3DockTabGroup*)neighbor->getWidget())->page(0));
01012 else
01013 return neighbor;
01014 }
01015 else
01016 return (static_cast<K3DockWidget*>(parent()->parent())->findNearestDockWidget(pos));
01017
01018 return 0;
01019 }
01020
01021
01022 K3DockWidget* K3DockWidget::manualDock( K3DockWidget* target, DockPosition dockPos, int spliPos, QPoint pos, bool check, int tabIndex )
01023 {
01024 if (this == target)
01025 return 0L;
01026
01027
01028 bool success = true;
01029
01030
01031
01032 if ( !(eDocking & (int)dockPos) ){
01033 success = false;
01034
01035 }
01036
01037
01038
01039 if (spliPos > 100) {
01040 spliPos = spliPos / 100;
01041 kDebug(282) << "K3DockWidget::manualDock(): fix splitter position: " << spliPos;
01042 }
01043
01044 K3DockWidget *tmpTarget = 0;
01045 switch (dockPos) {
01046 case K3DockWidget::DockLeft:
01047 tmpTarget=dockManager()->d->leftContainer;
01048 break;
01049 case K3DockWidget::DockRight:
01050 tmpTarget=dockManager()->d->rightContainer;
01051 break;
01052 case K3DockWidget::DockBottom:
01053 tmpTarget=dockManager()->d->bottomContainer;
01054 break;
01055 case K3DockWidget::DockTop:
01056 tmpTarget=dockManager()->d->topContainer;
01057 break;
01058 default:
01059 tmpTarget = 0;
01060 }
01061
01062
01063
01064 if ( tmpTarget && target && this != tmpTarget && target == dockManager()->d->mainDockWidget )
01065 return manualDock(tmpTarget,DockCenter,spliPos,pos,check,tabIndex);
01066
01067
01068 if ( target && !(target->sDocking & (int)dockPos) ){
01069 success = false;
01070
01071 }
01072
01073
01074
01075
01076 if ( parent() && !parent()->inherits("K3DockSplitter") && !parentDockTabGroup() &&
01077 !(dynamic_cast<K3DockContainer*>(parent())) && !parentDockContainer()){
01078
01079
01080 success = false;
01081 }
01082
01083
01084
01085
01086 if ( !success ){
01087
01088 K3DockWidget* dock_result = 0L;
01089 if ( target && !check ){
01090 K3DockWidget::DockPosition another__dockPos = K3DockWidget::DockNone;
01091 switch ( dockPos ){
01092 case K3DockWidget::DockLeft : another__dockPos = K3DockWidget::DockRight ; break;
01093 case K3DockWidget::DockRight : another__dockPos = K3DockWidget::DockLeft ; break;
01094 case K3DockWidget::DockTop : another__dockPos = K3DockWidget::DockBottom; break;
01095 case K3DockWidget::DockBottom: another__dockPos = K3DockWidget::DockTop ; break;
01096 default: break;
01097 }
01098 dock_result = target->manualDock( this, another__dockPos, spliPos, pos, true, tabIndex );
01099 }
01100 return dock_result;
01101 }
01102
01103
01104 d->blockHasUndockedSignal = true;
01105 undock();
01106 d->blockHasUndockedSignal = false;
01107
01108
01109 if ( !target ){
01110 move( pos );
01111 show();
01112 emit manager->change();
01113 return this;
01114 }
01115
01116
01117 K3DockTabGroup* parentTab = target->parentDockTabGroup();
01118 if ( parentTab ){
01119
01120 applyToWidget( parentTab );
01121 parentTab->insertTab( this, icon() ? *icon() : QPixmap(),
01122 tabPageLabel(), tabIndex );
01123
01124 QWidget *wantTransient=parentTab->transientTo();
01125 target->setDockWindowTransient(wantTransient,wantTransient);
01126
01127 setDockTabName( parentTab );
01128 if( !toolTipStr.isEmpty())
01129 parentTab->setTabToolTip( this, toolTipStr);
01130
01131 currentDockPos = K3DockWidget::DockCenter;
01132 emit manager->change();
01133 return (K3DockWidget*)parentTab->parent();
01134 }
01135 else
01136 {
01137
01138 QWidget *contWid=target->parentDockContainer();
01139 if (!contWid) contWid=target->widget;
01140 if (contWid)
01141 {
01142 K3DockContainer *cont=dynamic_cast<K3DockContainer*>(contWid);
01143 if (cont)
01144 {
01145 if (latestK3DockContainer() && (latestK3DockContainer()!=contWid)) {
01146 K3DockContainer* dc = dynamic_cast<K3DockContainer*>(latestK3DockContainer());
01147 if (dc) {
01148 dc->removeWidget(this);
01149 }
01150 }
01151
01152 applyToWidget( contWid );
01153 cont->insertWidget( this, icon() ? *icon() : QPixmap(),
01154 tabPageLabel(), tabIndex );
01155 setLatestK3DockContainer(contWid);
01156
01157 if( !toolTipStr.isEmpty())
01158 cont->setToolTip( this, toolTipStr);
01159
01160 currentDockPos = K3DockWidget::DockCenter;
01161 emit manager->change();
01162 return (K3DockWidget*)(cont->parentDockWidget());
01163
01164 }
01165 }
01166 }
01167
01168
01169 QWidget* parentDock = target->parentWidget();
01170 K3DockWidget* newDock = new K3DockWidget( manager, "tempName", QPixmap(""), parentDock );
01171 newDock->currentDockPos = target->currentDockPos;
01172
01173 if ( dockPos == K3DockWidget::DockCenter ){
01174 newDock->isTabGroup = true;
01175 } else {
01176 newDock->isGroup = true;
01177 }
01178 newDock->eDocking = (target->eDocking & eDocking) & (~(int)K3DockWidget::DockCenter);
01179
01180 newDock->applyToWidget( parentDock );
01181
01182 if ( !parentDock ){
01183
01184 newDock->move( target->frameGeometry().topLeft() );
01185 newDock->resize( target->geometry().size() );
01186 if ( target->isVisibleToTLW() ) newDock->show();
01187 }
01188
01189
01190 if( target->formerBrotherDockWidget ) {
01191 newDock->setFormerBrotherDockWidget(target->formerBrotherDockWidget);
01192 if( formerBrotherDockWidget )
01193 target->loseFormerBrotherDockWidget();
01194 }
01195 newDock->formerDockPos = target->formerDockPos;
01196
01197
01198
01199 if ( dockPos == K3DockWidget::DockCenter )
01200 {
01201 K3DockTabGroup* tab = new K3DockTabGroup( newDock );
01202 tab->setObjectName( QLatin1String( "_dock_tab" ) );
01203 QObject::connect(tab, SIGNAL(currentChanged(QWidget*)), d, SLOT(slotFocusEmbeddedWidget(QWidget*)));
01204 newDock->setWidget( tab );
01205
01206 target->applyToWidget( tab );
01207 applyToWidget( tab );
01208
01209
01210 tab->insertTab( target, target->icon() ? *(target->icon()) : QPixmap(),
01211 target->tabPageLabel() );
01212
01213
01214
01215 if( !target->toolTipString().isEmpty())
01216 tab->setTabToolTip( target, target->toolTipString());
01217
01218 tab->insertTab( this, icon() ? *icon() : QPixmap(),
01219 tabPageLabel(), tabIndex );
01220
01221 QRect geom=newDock->geometry();
01222 QWidget *wantTransient=tab->transientTo();
01223 newDock->setDockWindowTransient(wantTransient,wantTransient);
01224 newDock->setGeometry(geom);
01225
01226 if( !toolTipString().isEmpty())
01227 tab->setTabToolTip( this, toolTipString());
01228
01229 setDockTabName( tab );
01230 tab->show();
01231
01232 currentDockPos = DockCenter;
01233 target->formerDockPos = target->currentDockPos;
01234 target->currentDockPos = DockCenter;
01235 }
01236 else {
01237
01238
01239 K3DockSplitter* panner = 0L;
01240 if ( dockPos == K3DockWidget::DockTop || dockPos == K3DockWidget::DockBottom ) panner = new K3DockSplitter( newDock, "_dock_split_", Qt::Horizontal, spliPos );
01241 if ( dockPos == K3DockWidget::DockLeft || dockPos == K3DockWidget::DockRight ) panner = new K3DockSplitter( newDock, "_dock_split_", Qt::Vertical , spliPos );
01242 newDock->setWidget( panner );
01243
01244 panner->setOpaqueResize(manager->splitterOpaqueResize());
01245 panner->setKeepSize(manager->splitterKeepSize());
01246 panner->setFocusPolicy( Qt::NoFocus );
01247 target->applyToWidget( panner );
01248 applyToWidget( panner );
01249 target->formerDockPos = target->currentDockPos;
01250 if ( dockPos == K3DockWidget::DockRight) {
01251 panner->activate( target, this );
01252 currentDockPos = K3DockWidget::DockRight;
01253 target->currentDockPos = K3DockWidget::DockLeft;
01254 }
01255 else if( dockPos == K3DockWidget::DockBottom) {
01256 panner->activate( target, this );
01257 currentDockPos = K3DockWidget::DockBottom;
01258 target->currentDockPos = K3DockWidget::DockTop;
01259 }
01260 else if( dockPos == K3DockWidget::DockTop) {
01261 panner->activate( this, target );
01262 currentDockPos = K3DockWidget::DockTop;
01263 target->currentDockPos = K3DockWidget::DockBottom;
01264 }
01265 else if( dockPos == K3DockWidget::DockLeft) {
01266 panner->activate( this, target );
01267 currentDockPos = K3DockWidget::DockLeft;
01268 target->currentDockPos = K3DockWidget::DockRight;
01269 }
01270 target->show();
01271 show();
01272 panner->show();
01273 }
01274
01275 if ( parentDock ){
01276 if ( parentDock->inherits("K3DockSplitter") ){
01277 K3DockSplitter* sp = (K3DockSplitter*)parentDock;
01278 sp->deactivate();
01279 if ( sp->getFirst() == target )
01280 sp->activate( newDock, 0L );
01281 else
01282 sp->activate( 0L, newDock );
01283 }
01284 }
01285
01286 newDock->show();
01287 emit target->docking( this, dockPos );
01288 emit manager->replaceDock( target, newDock );
01289 emit manager->change();
01290
01291 return newDock;
01292 }
01293
01294 K3DockTabGroup* K3DockWidget::parentDockTabGroup() const
01295 {
01296 if ( !parent() ) return 0L;
01297 QWidget* candidate = parentWidget()->parentWidget();
01298 if ( candidate && candidate->inherits("K3DockTabGroup") ) return (K3DockTabGroup*)candidate;
01299 return 0L;
01300 }
01301
01302 QWidget *K3DockWidget::parentDockContainer() const
01303 {
01304 if (!parent()) return 0L;
01305 QWidget* candidate = parentWidget()->parentWidget();
01306 if (candidate && dynamic_cast<K3DockContainer*>(candidate)) return candidate;
01307 return 0L;
01308 }
01309
01310
01311 void K3DockWidget::setForcedFixedWidth(int w)
01312 {
01313 d->forcedWidth=w;
01314 setFixedWidth(w);
01315 if (!parent()) return;
01316 if (parent()->inherits("K3DockSplitter"))
01317 qobject_cast<K3DockSplitter*>(parent())->setForcedFixedWidth(this,w);
01318 }
01319
01320 void K3DockWidget::setForcedFixedHeight(int h)
01321 {
01322 d->forcedHeight=h;
01323 setFixedHeight(h);
01324 if (!parent()) return;
01325 if (parent()->inherits("K3DockSplitter"))
01326 qobject_cast<K3DockSplitter*>(parent())->setForcedFixedHeight(this,h);
01327 }
01328
01329 int K3DockWidget::forcedFixedWidth()
01330 {
01331 return d->forcedWidth;
01332 }
01333
01334 int K3DockWidget::forcedFixedHeight()
01335 {
01336 return d->forcedHeight;
01337 }
01338
01339 void K3DockWidget::restoreFromForcedFixedSize()
01340 {
01341 d->forcedWidth=-1;
01342 d->forcedHeight=-1;
01343 setMinimumWidth(0);
01344 setMaximumWidth(32000);
01345 setMinimumHeight(0);
01346 setMaximumHeight(32000);
01347 if (!parent()) return;
01348 if (parent()->inherits("K3DockSplitter"))
01349 qobject_cast<K3DockSplitter*>(parent())->restoreFromForcedFixedSize(this);
01350 }
01351
01352 void K3DockWidget::toDesktop()
01353 {
01354 QPoint p = mapToGlobal( QPoint( -30, -30 ) );
01355 if( p.x( ) < 0 )
01356 p.setX( 0 );
01357 if( p.y( ) < 0 )
01358 p.setY( 0 );
01359 manualDock( 0, DockDesktop, 50, p );
01360 }
01361
01362 K3DockWidget::DockPosition K3DockWidget::currentDockPosition() const
01363 {
01364 return currentDockPos;
01365 }
01366
01367 void K3DockWidget::undock()
01368 {
01369
01370
01371 manager->d->dragRect = QRect ();
01372 manager->drawDragRectangle ();
01373
01374 QWidget* parentW = parentWidget();
01375 if ( !parentW ){
01376 hide();
01377 if (!d->blockHasUndockedSignal)
01378 emit hasUndocked();
01379 return;
01380 }
01381
01382 formerDockPos = currentDockPos;
01383 currentDockPos = K3DockWidget::DockDesktop;
01384
01385 manager->blockSignals(true);
01386 manager->undockProcess = true;
01387
01388 bool isV = parentW->isVisibleToTLW();
01389
01390
01391 K3DockTabGroup* parentTab = parentDockTabGroup();
01392 if ( parentTab ){
01393 d->index = parentTab->indexOf( this);
01394 parentTab->removePage( this );
01395
01396
01397
01398
01399 setFormerBrotherDockWidget((K3DockWidget*)parentTab->page(0));
01400 applyToWidget( 0L );
01401 if ( parentTab->count() == 1 ){
01402
01403
01404 K3DockWidget* lastTab = (K3DockWidget*)parentTab->page(0);
01405 parentTab->removePage( lastTab );
01406
01407
01408
01409 lastTab->applyToWidget( 0L );
01410 lastTab->move( parentTab->mapToGlobal(parentTab->frameGeometry().topLeft()) );
01411
01412
01413 K3DockWidget* parentOfTab = (K3DockWidget*)parentTab->parent();
01414 delete parentTab;
01415
01416 QWidget* parentOfDockWidget = parentOfTab->parentWidget();
01417 if ( !parentOfDockWidget ){
01418 if ( isV ) lastTab->show();
01419 } else {
01420 if ( parentOfDockWidget->inherits("K3DockSplitter") ){
01421 K3DockSplitter* split = (K3DockSplitter*)parentOfDockWidget;
01422 lastTab->applyToWidget( split );
01423 split->deactivate();
01424 if ( split->getFirst() == parentOfTab ){
01425 split->activate( lastTab );
01426 if ( ((K3DockWidget*)split->parent())->splitterOrientation == Qt::Vertical )
01427 emit ((K3DockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, K3DockWidget::DockLeft );
01428 else
01429 emit ((K3DockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, K3DockWidget::DockTop );
01430 } else {
01431 split->activate( 0L, lastTab );
01432 if ( ((K3DockWidget*)split->parent())->splitterOrientation == Qt::Vertical )
01433 emit ((K3DockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, K3DockWidget::DockRight );
01434 else
01435 emit ((K3DockWidget*)split->getAnother(parentOfTab))->docking( parentOfTab, K3DockWidget::DockBottom );
01436 }
01437 split->show();
01438 } else {
01439 lastTab->applyToWidget( parentOfDockWidget );
01440 }
01441 lastTab->show();
01442 }
01443 manager->blockSignals(false);
01444 emit manager->replaceDock( parentOfTab, lastTab );
01445 lastTab->currentDockPos = parentOfTab->currentDockPos;
01446 emit parentOfTab->iMBeingClosed();
01447 manager->blockSignals(true);
01448 delete parentOfTab;
01449
01450 } else {
01451 setDockTabName( parentTab );
01452 }
01453 } else {
01454
01455
01456 bool undockedFromContainer=false;
01457 if (d->container)
01458 {
01459
01460 undockedFromContainer=true;
01461 K3DockContainer* dc = dynamic_cast<K3DockContainer*>(d->container.operator->());
01462 if (dc) {
01463 dc->undockWidget(this);
01464 setFormerBrotherDockWidget(dc->parentDockWidget());
01465 }
01466 applyToWidget( 0L );
01467 }
01468 if (!undockedFromContainer) {
01469
01470 if ( parentW->inherits("K3DockSplitter") ){
01471 K3DockSplitter* parentSplitterOfDockWidget = (K3DockSplitter*)parentW;
01472 d->splitPosInPercent = parentSplitterOfDockWidget->separatorPosInPercent();
01473
01474 K3DockWidget* secondWidget = (K3DockWidget*)parentSplitterOfDockWidget->getAnother( this );
01475 K3DockWidget* group = (K3DockWidget*)parentSplitterOfDockWidget->parentWidget();
01476 setFormerBrotherDockWidget(secondWidget);
01477 applyToWidget( 0L );
01478 group->hide();
01479
01480 if ( !group->parentWidget() ){
01481 secondWidget->applyToWidget( 0L, group->frameGeometry().topLeft() );
01482 secondWidget->resize( group->width(), group->height() );
01483 } else {
01484 QWidget* obj = group->parentWidget();
01485 secondWidget->applyToWidget( obj );
01486 if ( obj->inherits("K3DockSplitter") ){
01487 K3DockSplitter* parentOfGroup = (K3DockSplitter*)obj;
01488 parentOfGroup->deactivate();
01489
01490 if ( parentOfGroup->getFirst() == group )
01491 parentOfGroup->activate( secondWidget );
01492 else
01493 parentOfGroup->activate( 0L, secondWidget );
01494 }
01495 }
01496 secondWidget->currentDockPos = group->currentDockPos;
01497 secondWidget->formerDockPos = group->formerDockPos;
01498 delete parentSplitterOfDockWidget;
01499 manager->blockSignals(false);
01500 emit manager->replaceDock( group, secondWidget );
01501 emit group->iMBeingClosed();
01502 manager->blockSignals(true);
01503 delete group;
01504
01505 if ( isV ) secondWidget->show();
01506 } else {
01507 if (!d->pendingDtor) {
01508
01509 applyToWidget( 0L );
01510 }
01511 }
01512
01513 }
01514 }
01515 manager->blockSignals(false);
01516 if (!d->blockHasUndockedSignal)
01517 emit manager->change();
01518 manager->undockProcess = false;
01519
01520 if (!d->blockHasUndockedSignal)
01521 emit hasUndocked();
01522 }
01523
01524 void K3DockWidget::setWidget( QWidget* mw )
01525 {
01526 if ( !mw ) return;
01527
01528 if ( mw->parent() != this ){
01529 mw->setParent(this);
01530 mw->move(0,0);
01531 }
01532
01533 #ifdef BORDERLESS_WINDOWS
01534 if (!mw->ownCursor()) mw->setCursor(QCursor(Qt::ArrowCursor));
01535 #endif
01536 widget = mw;
01537 delete layout;
01538
01539
01540
01541
01542
01543 widget->setAutoFillBackground( true );
01544
01545 layout = new QVBoxLayout( this );
01546 layout->setSizeConstraint( QLayout::Minimum );
01547
01548 K3DockContainer* dc = dynamic_cast<K3DockContainer*>(widget);
01549 if (dc)
01550 {
01551 d->isContainer=true;
01552 manager->d->containerDocks.append(this);
01553 }
01554 else
01555 {
01556 d->isContainer=false;
01557 }
01558
01559 {
01560 header->show();
01561 layout->addWidget( header );
01562 layout->addWidget( widget,1 );
01563 }
01564 updateHeader();
01565 emit widgetSet(mw);
01566 }
01567
01568 QWidget* K3DockWidget::getWidget() const
01569 {
01570 return widget;
01571 }
01572
01573 void K3DockWidget::setDockTabName( K3DockTabGroup* tab )
01574 {
01575 QString listOfName;
01576 QString listOfCaption;
01577 for ( int i = 0; i < tab->count(); ++i ) {
01578 QWidget *w = tab->page( i );
01579 listOfCaption.append( w->windowTitle() ).append(",");
01580 listOfName.append( w->name() ).append(",");
01581 }
01582 listOfCaption.remove( listOfCaption.length()-1, 1 );
01583 listOfName.remove( listOfName.length()-1, 1 );
01584
01585 tab->parentWidget()->setName( listOfName.toUtf8() );
01586 tab->parentWidget()->setWindowTitle( listOfCaption );
01587
01588 tab->parentWidget()->repaint();
01589 if ( tab->parentWidget()->parent() )
01590 if ( tab->parentWidget()->parent()->inherits("K3DockSplitter") )
01591 ((K3DockSplitter*)(tab->parentWidget()->parent()))->updateName();
01592 }
01593
01594 bool K3DockWidget::mayBeHide() const
01595 {
01596 bool f = (parent() != manager->main);
01597 return ( !isGroup && !isTabGroup && f && isVisible() && ( eDocking != (int)K3DockWidget::DockNone ) );
01598 }
01599
01600 bool K3DockWidget::mayBeShow() const
01601 {
01602 bool f = (parent() != manager->main);
01603 return ( !isGroup && !isTabGroup && f && !isVisible() );
01604 }
01605
01606 K3DockManager* K3DockWidget::dockManager() const
01607 {
01608 return manager;
01609 }
01610
01611 void K3DockWidget::setToolTipString(const QString& ttStr)
01612 {
01613 toolTipStr = ttStr;
01614 }
01615
01616 const QString& K3DockWidget::toolTipString() const
01617 {
01618 return toolTipStr;
01619 }
01620
01621 void K3DockWidget::changeHideShowState()
01622 {
01623 if ( mayBeHide() ){
01624 undock();
01625 return;
01626 }
01627
01628 if ( mayBeShow() ){
01629 if ( manager->main->inherits("K3DockMainWindow") ){
01630 ((K3DockMainWindow*)manager->main)->makeDockVisible(this);
01631 } else {
01632 makeDockVisible();
01633 }
01634 }
01635 }
01636
01637 void K3DockWidget::makeDockVisible()
01638 {
01639 if ( parentDockTabGroup() ){
01640 parentDockTabGroup()->showPage( this );
01641 }
01642 if (parentDockContainer()) {
01643 QWidget *contWid=parentDockContainer();
01644 K3DockContainer *x = dynamic_cast<K3DockContainer*>(contWid);
01645 if (x) {
01646 x->showWidget(this);
01647 }
01648 }
01649 if ( isVisible() ) return;
01650
01651 QWidget* p = parentWidget();
01652 while ( p ){
01653 if ( !p->isVisible() )
01654 p->show();
01655 p = p->parentWidget();
01656 }
01657 if( !parent() )
01658 dockBack();
01659 show();
01660 }
01661
01662 void K3DockWidget::setFormerBrotherDockWidget(K3DockWidget *dockWidget)
01663 {
01664 formerBrotherDockWidget = dockWidget;
01665 if( formerBrotherDockWidget )
01666 QObject::connect( formerBrotherDockWidget, SIGNAL(iMBeingClosed()),
01667 this, SLOT(loseFormerBrotherDockWidget()) );
01668 }
01669
01670 void K3DockWidget::loseFormerBrotherDockWidget()
01671 {
01672 if( formerBrotherDockWidget )
01673 QObject::disconnect( formerBrotherDockWidget, SIGNAL(iMBeingClosed()),
01674 this, SLOT(loseFormerBrotherDockWidget()) );
01675 formerBrotherDockWidget = 0L;
01676 repaint();
01677 }
01678
01679 void K3DockWidget::dockBack()
01680 {
01681 if( formerBrotherDockWidget) {
01682
01683 bool found = false;
01684 QList<K3DockWidget *> cl = findChildren<K3DockWidget *>();
01685 foreach ( K3DockWidget *obj, cl ) {
01686 while ( !found && obj!= 0 ) {
01687 QWidget* widg = qobject_cast<QWidget*>(obj);
01688 if( widg == formerBrotherDockWidget)
01689 found = true;
01690 }
01691 }
01692
01693 if( !found) {
01694
01695 manualDock( formerBrotherDockWidget, formerDockPos, d->splitPosInPercent, QPoint(0,0), false, d->index);
01696 formerBrotherDockWidget = 0L;
01697 makeDockVisible();
01698 return;
01699 }
01700 }
01701
01702
01703 manualDock( ((K3DockMainWindow*)manager->main)->getMainDockWidget(), formerDockPos, d->splitPosInPercent, QPoint(0,0), false, d->index);
01704 formerBrotherDockWidget = 0L;
01705 if (parent())
01706 makeDockVisible();
01707 }
01708
01709 bool K3DockWidget::isDockBackPossible() const
01710 {
01711 if( !(formerBrotherDockWidget) || !(formerBrotherDockWidget->dockSite() & formerDockPos))
01712 return false;
01713 else
01714 return true;
01715 }
01716
01717 void K3DockWidget::setTabPageLabel( const QString& label)
01718 {
01719 tabPageTitle = label;
01720 }
01721
01722 const QString& K3DockWidget::tabPageLabel() const
01723 {
01724 return tabPageTitle;
01725 }
01726
01727
01728
01729
01730 K3DockManager::K3DockManager( QWidget* mainWindow , const char* name )
01731 :QObject( mainWindow, name )
01732 ,main(mainWindow)
01733 ,currentDragWidget(0L)
01734 ,currentMoveWidget(0L)
01735 ,childDockWidgetList(0L)
01736 ,autoCreateDock(0L)
01737 ,storeW(0)
01738 ,storeH(0)
01739 ,dragging(false)
01740 ,undockProcess(false)
01741 ,dropCancel(true)
01742 {
01743 d = new K3DockManagerPrivate;
01744
01745 d->readyToDrag = false;
01746 d->mainDockWidget=0;
01747
01748 #ifndef NO_KDE2
01749 d->splitterOpaqueResize = KGlobalSettings::opaqueResize();
01750 #else
01751 d->splitterOpaqueResize = false;
01752 #endif
01753
01754 d->splitterKeepSize = false;
01755 d->splitterHighResolution = false;
01756 d->m_readDockConfigMode = WrapExistingWidgetsOnly;
01757
01758 main->installEventFilter( this );
01759
01760 undockProcess = false;
01761
01762 menuData = new Q3PtrList<MenuDockData>;
01763 menuData->setAutoDelete( true );
01764 menuData->setAutoDelete( true );
01765
01766 #ifndef NO_KDE2
01767 menu = new K3PopupMenu();
01768 #else
01769 menu = new Q3PopupMenu();
01770 #endif
01771
01772 connect( menu, SIGNAL(aboutToShow()), SLOT(slotMenuPopup()) );
01773 connect( menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int)) );
01774
01775 childDock = new QList<QObject*>();
01776 }
01777
01778
01779 void K3DockManager::setMainDockWidget2(K3DockWidget *w)
01780 {
01781 d->mainDockWidget=w;
01782 }
01783
01784 K3DockManager::~K3DockManager()
01785 {
01786 delete menuData;
01787 delete menu;
01788
01789
01790 K3DockWidget * obj;
01791 Q_FOREACH ( QObject *o, *childDock ) {
01792 obj = (K3DockWidget*) ( o );
01793 delete obj;
01794 }
01795
01796 delete childDock;
01797 delete d;
01798 d=0;
01799 }
01800
01801 void K3DockManager::activate()
01802 {
01803 K3DockWidget * obj;
01804 foreach ( QObject *o, *childDock ) {
01805 obj=(K3DockWidget*)o;
01806 if ( obj->widget ) obj->widget->show();
01807 if ( !obj->parentDockTabGroup() ){
01808 obj->show();
01809 }
01810 }
01811 if ( !main->inherits("QDialog") ) main->show();
01812 }
01813
01814 bool K3DockManager::eventFilter( QObject *obj, QEvent *event )
01815 {
01816
01817 if ( obj->inherits("K3DockWidgetAbstractHeaderDrag") ){
01818 K3DockWidget* pDockWdgAtCursor = 0L;
01819 K3DockWidget* curdw = ((K3DockWidgetAbstractHeaderDrag*)obj)->dockWidget();
01820 switch ( event->type() ){
01821 case QEvent::MouseButtonDblClick:
01822 if (curdw->currentDockPos == K3DockWidget::DockDesktop) curdw->dockBack();
01823 else
01824 {
01825 curdw->toDesktop();
01826
01827 }
01828 break;
01829
01830 case QEvent::MouseButtonPress:
01831 if ( ((QMouseEvent*)event)->button() == Qt::LeftButton ){
01832 if ( curdw->eDocking != (int)K3DockWidget::DockNone ){
01833 dropCancel = true;
01834 curdw->setFocus();
01835 qApp->processOneEvent();
01836
01837 currentDragWidget = curdw;
01838 currentMoveWidget = 0L;
01839 childDockWidgetList = new QWidgetList();
01840 childDockWidgetList->append( curdw );
01841 findChildDockWidget( curdw, childDockWidgetList );
01842
01843
01844 d->dragRect = QRect(curdw->geometry());
01845 QPoint p = curdw->mapToGlobal(QPoint(0,0));
01846 d->dragRect.moveTopLeft(p);
01847 drawDragRectangle();
01848 d->readyToDrag = true;
01849
01850 d->dragOffset = QCursor::pos()-currentDragWidget->mapToGlobal(QPoint(0,0));
01851 }
01852
01853 }
01854 break;
01855 case QEvent::MouseButtonRelease:
01856 if ( ((QMouseEvent*)event)->button() == Qt::LeftButton ){
01857 if ( dragging ){
01858 if ( !dropCancel )
01859 drop();
01860 else
01861 cancelDrop();
01862 }
01863 if (d->readyToDrag) {
01864 d->readyToDrag = false;
01865
01866 d->dragRect = QRect(curdw->geometry());
01867 QPoint p = curdw->mapToGlobal(QPoint(0,0));
01868 d->dragRect.moveTopLeft(p);
01869 drawDragRectangle();
01870 currentDragWidget = 0L;
01871 delete childDockWidgetList;
01872 childDockWidgetList = 0L;
01873 }
01874 dragging = false;
01875 dropCancel = true;
01876 }
01877 break;
01878 case QEvent::MouseMove:
01879 if ( dragging ) {
01880
01881 #ifdef BORDERLESS_WINDOWS
01882
01883 K3DockWidget *oldMoveWidget;
01884 if (!curdw->parent())
01885 {
01886 curdw->move(QCursor::pos()-d->dragOffset);
01887 pDockWdgAtCursor = findDockWidgetAt( QCursor::pos()-QPoint(0,d->dragOffset.y()+3) );
01888 oldMoveWidget = currentMoveWidget;
01889 }
01890 else
01891 {
01892 pDockWdgAtCursor = findDockWidgetAt( QCursor::pos() );
01893 oldMoveWidget = currentMoveWidget;
01894 }
01895
01896 #else
01897 pDockWdgAtCursor = findDockWidgetAt( QCursor::pos() );
01898 K3DockWidget* oldMoveWidget = currentMoveWidget;
01899 #endif
01900
01901 if ( currentMoveWidget && pDockWdgAtCursor == currentMoveWidget ) {
01902 dragMove( currentMoveWidget, currentMoveWidget->mapFromGlobal( QCursor::pos() ) );
01903 break;
01904 } else {
01905 if (dropCancel && curdw) {
01906 d->dragRect = QRect(curdw->geometry());
01907 QPoint p = curdw->mapToGlobal(QPoint(0,0));
01908 d->dragRect.moveTopLeft(p);
01909 }else
01910 d->dragRect = QRect();
01911
01912 drawDragRectangle();
01913 }
01914
01915 if ( !pDockWdgAtCursor && !(curdw->eDocking & (int)K3DockWidget::DockDesktop) ){
01916
01917 currentMoveWidget = pDockWdgAtCursor;
01918 curPos = K3DockWidget::DockDesktop;
01919 } else {
01920 if ( oldMoveWidget && pDockWdgAtCursor != currentMoveWidget ) {
01921 currentMoveWidget = pDockWdgAtCursor;
01922 curPos = K3DockWidget::DockDesktop;
01923 }
01924 }
01925
01926 if ( oldMoveWidget != pDockWdgAtCursor && pDockWdgAtCursor ) {
01927 currentMoveWidget = pDockWdgAtCursor;
01928 curPos = K3DockWidget::DockDesktop;
01929 }
01930 } else {
01931 if (d->readyToDrag) {
01932 d->readyToDrag = false;
01933 }
01934 if ( (((QMouseEvent*)event)->state() == Qt::LeftButton) &&
01935 (curdw->eDocking != (int)K3DockWidget::DockNone) ) {
01936 startDrag( curdw);
01937 }
01938 }
01939 break;
01940 default:
01941 break;
01942 }
01943 }
01944 return QObject::eventFilter( obj, event );
01945 }
01946
01947 K3DockWidget* K3DockManager::findDockWidgetAt( const QPoint& pos )
01948 {
01949 dropCancel = true;
01950
01951 if (!currentDragWidget)
01952 return 0L;
01953
01954 if (currentDragWidget->eDocking == (int)K3DockWidget::DockNone ) return 0L;
01955
01956 QWidget* p = QApplication::topLevelAt( pos );
01957 if ( !p ) {
01958 dropCancel = false;
01959 return 0L;
01960 }
01961 #if defined(_OS_WIN32_) || defined(Q_OS_WIN32)
01962 p = p->topLevelWidget();
01963 #endif
01964 QWidget* w = 0L;
01965 findChildDockWidget( w, p, p->mapFromGlobal(pos) );
01966 if ( !w ){
01967 if ( !p->inherits("K3DockWidget") ) {
01968 return 0L;
01969 }
01970 w = p;
01971 }
01972 if ( findChild<K3DockSplitter*>("_dock_split_")) return 0L;
01973 if ( findChild<K3DockTabGroup*>( "_dock_tab" )) return 0L;
01974 if (dynamic_cast<K3DockContainer*>(w)) return 0L;
01975
01976 if (!childDockWidgetList) return 0L;
01977 if ( childDockWidgetList->indexOf(w) != -1 ) return 0L;
01978 if ( currentDragWidget->isGroup && ((K3DockWidget*)w)->parentDockTabGroup() ) return 0L;
01979
01980 K3DockWidget* www = (K3DockWidget*)w;
01981 if ( www->sDocking == (int)K3DockWidget::DockNone ) return 0L;
01982 if( !www->widget )
01983 return 0L;
01984
01985 K3DockWidget::DockPosition curPos = K3DockWidget::DockDesktop;
01986 QPoint cpos = www->mapFromGlobal( pos );
01987
01988 int ww = www->widget->width() / 3;
01989 int hh = www->widget->height() / 3;
01990
01991 if ( cpos.y() <= hh ){
01992 curPos = K3DockWidget::DockTop;
01993 } else
01994 if ( cpos.y() >= 2*hh ){
01995 curPos = K3DockWidget::DockBottom;
01996 } else
01997 if ( cpos.x() <= ww ){
01998 curPos = K3DockWidget::DockLeft;
01999 } else
02000 if ( cpos.x() >= 2*ww ){
02001 curPos = K3DockWidget::DockRight;
02002 } else
02003 curPos = K3DockWidget::DockCenter;
02004
02005 if ( !(www->sDocking & (int)curPos) ) return 0L;
02006 if ( !(currentDragWidget->eDocking & (int)curPos) ) return 0L;
02007 if ( www->manager != this ) return 0L;
02008
02009 dropCancel = false;
02010 return www;
02011 }
02012
02013 void K3DockManager::findChildDockWidget( QWidget*& ww, const QWidget* p, const QPoint& pos )
02014 {
02015 if ( !p->children().isEmpty() ) {
02016 QWidget *w;
02017 foreach( QObject* o, p->children() )
02018 {
02019 if ( o->isWidgetType() ) {
02020 w = (QWidget*)o;
02021 if ( w->isVisible() && w->geometry().contains(pos) ) {
02022 if ( w->inherits("K3DockWidget") ) ww = w;
02023 findChildDockWidget( ww, w, w->mapFromParent(pos) );
02024 return;
02025 }
02026 }
02027 }
02028 }
02029 return;
02030 }
02031
02032 void K3DockManager::findChildDockWidget( const QWidget* p, QWidgetList*& list )
02033 {
02034 if ( !p->children().isEmpty() ) {
02035 QWidget *w;
02036 foreach( QObject* o, p->children() )
02037 {
02038 if ( o->isWidgetType() ) {
02039 w = (QWidget*)o;
02040 if ( w->isVisible() ) {
02041 if ( w->inherits("K3DockWidget") ) list->append( w );
02042 findChildDockWidget( w, list );
02043 }
02044 }
02045 }
02046 }
02047 return;
02048 }
02049
02050 void K3DockManager::startDrag( K3DockWidget* w )
02051 {
02052 if(( w->currentDockPos == K3DockWidget::DockLeft) || ( w->currentDockPos == K3DockWidget::DockRight)
02053 || ( w->currentDockPos == K3DockWidget::DockTop) || ( w->currentDockPos == K3DockWidget::DockBottom)) {
02054 w->prevSideDockPosBeforeDrag = w->currentDockPos;
02055
02056 if ( w->parentWidget()->inherits("K3DockSplitter") ){
02057 K3DockSplitter* parentSplitterOfDockWidget = (K3DockSplitter*)(w->parentWidget());
02058 w->d->splitPosInPercent = parentSplitterOfDockWidget->separatorPosInPercent();
02059 }
02060 }
02061
02062 curPos = K3DockWidget::DockDesktop;
02063 dragging = true;
02064
02065 QApplication::setOverrideCursor(QCursor(Qt::SizeAllCursor));
02066 }
02067
02068 void K3DockManager::dragMove( K3DockWidget* dw, QPoint pos )
02069 {
02070 QPoint p = dw->mapToGlobal( dw->widget->pos() );
02071 K3DockWidget::DockPosition oldPos = curPos;
02072
02073 QSize r = dw->widget->size();
02074 if ( dw->parentDockTabGroup() ){
02075 curPos = K3DockWidget::DockCenter;
02076 if ( oldPos != curPos ) {
02077 d->dragRect.setRect( p.x()+2, p.y()+2, r.width()-4, r.height()-4 );
02078 }
02079 return;
02080 }
02081
02082 int w = r.width() / 3;
02083 int h = r.height() / 3;
02084
02085 if ( pos.y() <= h ){
02086 curPos = K3DockWidget::DockTop;
02087 w = r.width();
02088 } else
02089 if ( pos.y() >= 2*h ){
02090 curPos = K3DockWidget::DockBottom;
02091 p.setY( p.y() + 2*h );
02092 w = r.width();
02093 } else
02094 if ( pos.x() <= w ){
02095 curPos = K3DockWidget::DockLeft;
02096 h = r.height();
02097 } else
02098 if ( pos.x() >= 2*w ){
02099 curPos = K3DockWidget::DockRight;
02100 p.setX( p.x() + 2*w );
02101 h = r.height();
02102 } else
02103 {
02104 curPos = K3DockWidget::DockCenter;
02105 p.setX( p.x() + w );
02106 p.setY( p.y() + h );
02107 }
02108
02109 if ( oldPos != curPos ) {
02110 d->dragRect.setRect( p.x(), p.y(), w, h );
02111 drawDragRectangle();
02112 }
02113 }
02114
02115
02116 void K3DockManager::cancelDrop()
02117 {
02118 QApplication::restoreOverrideCursor();
02119
02120 delete childDockWidgetList;
02121 childDockWidgetList = 0L;
02122
02123 d->dragRect = QRect();
02124 drawDragRectangle();
02125 }
02126
02127
02128 void K3DockManager::drop()
02129 {
02130 d->dragRect = QRect();
02131 drawDragRectangle();
02132
02133 QApplication::restoreOverrideCursor();
02134
02135 delete childDockWidgetList;
02136 childDockWidgetList = 0L;
02137
02138 if ( dropCancel ) return;
02139 if ( !currentMoveWidget && (!(currentDragWidget->eDocking & (int)K3DockWidget::DockDesktop)) ) {
02140 d->dragRect = QRect();
02141 drawDragRectangle();
02142 return;
02143 }
02144 if ( !currentMoveWidget && !currentDragWidget->parent() ) {
02145 currentDragWidget->move( QCursor::pos() - d->dragOffset );
02146 }
02147 else {
02148
02149
02150
02151
02152 int splitPos = currentDragWidget->d->splitPosInPercent;
02153 K3DockWidget::DockPosition previousPosition = currentDragWidget->prevSideDockPosBeforeDrag;
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164 if( (curPos != previousPosition)
02165 && (curPos != K3DockWidget::DockCenter) && (curPos != K3DockWidget::DockDesktop)) {
02166
02167 if (previousPosition == K3DockWidget::DockNone)
02168 previousPosition = currentDragWidget->formerDockPos;
02169
02170 switch( previousPosition ) {
02171 case K3DockWidget::DockLeft:
02172 if(curPos != K3DockWidget::DockTop && curPos != K3DockWidget::DockLeft)
02173 splitPos = 100 - splitPos;
02174 break;
02175
02176 case K3DockWidget::DockRight:
02177 if(curPos != K3DockWidget::DockBottom && curPos != K3DockWidget::DockRight)
02178 splitPos = 100 - splitPos;
02179 break;
02180
02181 case K3DockWidget::DockTop:
02182 if(curPos != K3DockWidget::DockLeft && curPos != K3DockWidget::DockTop )
02183 splitPos = 100 - splitPos;
02184 break;
02185
02186 case K3DockWidget::DockBottom:
02187 if(curPos != K3DockWidget::DockRight && curPos != K3DockWidget::DockBottom )
02188 splitPos = 100 - splitPos;
02189 break;
02190
02191 default: break;
02192 }
02193 }
02194
02195 currentDragWidget->prevSideDockPosBeforeDrag = curPos;
02196 currentDragWidget->manualDock( currentMoveWidget, curPos , splitPos, QCursor::pos() - d->dragOffset );
02197 currentDragWidget->makeDockVisible();
02198 }
02199 }
02200
02201
02202 static QDomElement createStringEntry(QDomDocument &doc, const QString &tagName, const QString &str)
02203 {
02204 QDomElement el = doc.createElement(tagName);
02205
02206 el.appendChild(doc.createTextNode(str));
02207 return el;
02208 }
02209
02210
02211 static QDomElement createBoolEntry(QDomDocument &doc, const QString &tagName, bool b)
02212 {
02213 return createStringEntry(doc, tagName, QLatin1String(b? "true" : "false"));
02214 }
02215
02216
02217 static QDomElement createNumberEntry(QDomDocument &doc, const QString &tagName, int n)
02218 {
02219 return createStringEntry(doc, tagName, QString::number(n));
02220 }
02221
02222
02223 static QDomElement createRectEntry(QDomDocument &doc, const QString &tagName, const QRect &rect)
02224 {
02225 QDomElement el = doc.createElement(tagName);
02226
02227 QDomElement xel = doc.createElement("x");
02228 xel.appendChild(doc.createTextNode(QString::number(rect.x())));
02229 el.appendChild(xel);
02230 QDomElement yel = doc.createElement("y");
02231 yel.appendChild(doc.createTextNode(QString::number(rect.y())));
02232 el.appendChild(yel);
02233 QDomElement wel = doc.createElement("width");
02234 wel.appendChild(doc.createTextNode(QString::number(rect.width())));
02235 el.appendChild(wel);
02236 QDomElement hel = doc.createElement("height");
02237 hel.appendChild(doc.createTextNode(QString::number(rect.height())));
02238 el.appendChild(hel);
02239
02240 return el;
02241 }
02242
02243
02244 static QDomElement createListEntry(QDomDocument &doc, const QString &tagName,
02245 const QString &subTagName, const QStringList &list)
02246 {
02247 QDomElement el = doc.createElement(tagName);
02248
02249 foreach( const QString &s, list )
02250 {
02251 QDomElement subel = doc.createElement(subTagName);
02252 subel.appendChild(doc.createTextNode(s));
02253 el.appendChild(subel);
02254 }
02255
02256 return el;
02257 }
02258
02259
02260 static QString stringEntry(QDomElement &base, const QString &tagName)
02261 {
02262 return base.namedItem(tagName).firstChild().toText().data();
02263 }
02264
02265
02266 static bool boolEntry(QDomElement &base, const QString &tagName)
02267 {
02268 return base.namedItem(tagName).firstChild().toText().data() == "true";
02269 }
02270
02271
02272 static int numberEntry(QDomElement &base, const QString &tagName)
02273 {
02274 return stringEntry(base, tagName).toInt();
02275 }
02276
02277
02278 static QRect rectEntry(QDomElement &base, const QString &tagName)
02279 {
02280 QDomElement el = base.namedItem(tagName).toElement();
02281
02282 int x = numberEntry(el, "x");
02283 int y = numberEntry(el, "y");
02284 int width = numberEntry(el, "width");
02285 int height = numberEntry(el, "height");
02286
02287 return QRect(x, y, width, height);
02288 }
02289
02290
02291 static Q3StrList listEntry(QDomElement &base, const QString &tagName, const QString &subTagName)
02292 {
02293 Q3StrList list;
02294
02295 for( QDomNode n = base.namedItem(tagName).firstChild(); !n.isNull(); n = n.nextSibling() )
02296 {
02297 QDomElement subel = n.toElement();
02298 if (subel.tagName() == subTagName)
02299 list.append(subel.firstChild().toText().data().toLatin1().constData());
02300 }
02301
02302 return list;
02303 }
02304
02305
02306 void K3DockManager::writeConfig(QDomElement &base)
02307 {
02308
02309 while (!base.firstChild().isNull())
02310 base.removeChild(base.firstChild());
02311 QDomDocument doc = base.ownerDocument();
02312
02313 QStringList nameList;
02314 QString mainWidgetStr;
02315
02316
02317 QStringList nList;
02318 Q_FOREACH( QObject *o, *childDock )
02319 {
02320 #ifdef __GNUC__ // ### KDE4
02321 # warning "Can dw be 0 and what should we do in the case that it is?"
02322 #endif
02323 K3DockWidget* dw = qobject_cast<K3DockWidget*> ( o );
02324 if ( !dw )
02325 continue;
02326 if ( dw->parent() == main )
02327 mainWidgetStr = dw->objectName();
02328 nList.append( dw->objectName() );
02329 }
02330
02331 for (QObjectList::iterator it = d->containerDocks.begin();it != d->containerDocks.end();++it)
02332 {
02333 K3DockContainer* dc = dynamic_cast<K3DockContainer*>(((K3DockWidget*)(*it))->widget);
02334 if (dc) {
02335 dc->prepareSave(nList);
02336 }
02337 }
02338
02339 QStringList::Iterator nListIt=nList.begin();
02340 while ( nListIt!=nList.end() ) {
02341 K3DockWidget *obj = getDockWidgetFromName( *nListIt);
02342 if ((obj->isGroup && (!obj->d->isContainer)) && (nameList.indexOf( obj->firstName) == -1
02343 || nameList.indexOf(obj->lastName) == -1)) {
02344
02345 ++nListIt;
02346
02347
02348 continue;
02349 }
02350
02351 QDomElement groupEl;
02352 if (obj->d->isContainer) {
02353 K3DockContainer* x = dynamic_cast<K3DockContainer*>(obj->widget);
02354 if (x) {
02355 groupEl=doc.createElement("dockContainer");
02356 x->save(groupEl);
02357 }
02358 } else
02359 if (obj->isGroup) {
02361 groupEl = doc.createElement("splitGroup");
02362
02363 groupEl.appendChild(createStringEntry(doc, "firstName", obj->firstName));
02364 groupEl.appendChild(createStringEntry(doc, "secondName", obj->lastName));
02365 groupEl.appendChild(createNumberEntry(doc, "orientation", (int)obj->splitterOrientation));
02366 groupEl.appendChild(createNumberEntry(doc, "separatorPos", ((K3DockSplitter*)obj->widget)->separatorPosInPercent()));
02367 } else if (obj->isTabGroup) {
02369 groupEl = doc.createElement("tabGroup");
02370
02371 QStringList list;
02372 for ( int i = 0; i < ((K3DockTabGroup*)obj->widget)->count(); ++i )
02373 list.append( ((K3DockTabGroup*)obj->widget)->page( i )->name() );
02374 groupEl.appendChild(createListEntry(doc, "tabs", "tab", list));
02375 groupEl.appendChild(createNumberEntry(doc, "currentTab", ((K3DockTabGroup*)obj->widget)->currentPageIndex()));
02376 if (!obj->parent()) {
02377 groupEl.appendChild(createStringEntry(doc, "dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : ""));
02378 groupEl.appendChild(createNumberEntry(doc, "dockBackToPos", obj->formerDockPos));
02379 }
02380 } else {
02382 groupEl = doc.createElement("dock");
02383 groupEl.appendChild(createStringEntry(doc, "tabCaption", obj->tabPageLabel()));
02384 groupEl.appendChild(createStringEntry(doc, "tabToolTip", obj->toolTipString()));
02385 if (!obj->parent()) {
02386 groupEl.appendChild(createStringEntry(doc, "dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : ""));
02387 groupEl.appendChild(createNumberEntry(doc, "dockBackToPos", obj->formerDockPos));
02388 }
02389 }
02390
02391 groupEl.appendChild(createStringEntry(doc, "name", QLatin1String(obj->name())));
02392 groupEl.appendChild(createBoolEntry(doc, "hasParent", obj->parent()));
02393 if ( !obj->parent() ) {
02394 groupEl.appendChild(createRectEntry(doc, "geometry", QRect(main->frameGeometry().topLeft(), main->size())));
02395 groupEl.appendChild(createBoolEntry(doc, "visible", obj->isVisible()));
02396 }
02397 if (obj->header && obj->header->inherits("K3DockWidgetHeader")) {
02398 K3DockWidgetHeader *h = static_cast<K3DockWidgetHeader*>(obj->header);
02399 groupEl.appendChild(createBoolEntry(doc, "dragEnabled", h->dragEnabled()));
02400 }
02401
02402 base.appendChild(groupEl);
02403 nameList.append(obj->name());
02404 nList.erase(nListIt);
02405 nListIt=nList.begin();
02406 }
02407
02408 if (main->inherits("K3DockMainWindow")) {
02409 K3DockMainWindow *dmain = (K3DockMainWindow*)main;
02410 QString centralWidgetStr = QString(dmain->centralWidget()? dmain->centralWidget()->name() : "");
02411 base.appendChild(createStringEntry(doc, "centralWidget", centralWidgetStr));
02412 QString mainDockWidgetStr = QString(dmain->getMainDockWidget()? dmain->getMainDockWidget()->name() : "");
02413 base.appendChild(createStringEntry(doc, "mainDockWidget", mainDockWidgetStr));
02414 } else {
02415 base.appendChild(createStringEntry(doc, "mainWidget", mainWidgetStr));
02416 }
02417
02418 base.appendChild(createRectEntry(doc, "geometry", QRect(main->frameGeometry().topLeft(), main->size())));
02419 }
02420
02421
02422 void K3DockManager::readConfig(QDomElement &base)
02423 {
02424 if (base.namedItem("group").isNull()
02425 && base.namedItem("tabgroup").isNull()
02426 && base.namedItem("dock").isNull()
02427 && base.namedItem("dockContainer").isNull()) {
02428 activate();
02429 return;
02430 }
02431
02432 autoCreateDock = new QObjectList;
02433
02434 bool isMainVisible = main->isVisible();
02435 main->hide();
02436
02437 QObjectList::iterator it = childDock->begin();
02438 K3DockWidget *obj1;
02439 while ( (obj1=(K3DockWidget*)(*it)) ) {
02440 if ( !obj1->isGroup && !obj1->isTabGroup ) {
02441 if ( obj1->parent() )
02442 obj1->undock();
02443 else
02444 obj1->hide();
02445 }
02446 ++it;
02447 }
02448
02449
02450 for( QDomNode n = base.firstChild(); !n.isNull(); n = n.nextSibling() )
02451 {
02452 QDomElement childEl = n.toElement();
02453 if (childEl.tagName() != "dock") continue;
02454
02455
02456 K3DockWidget *obj = getDockWidgetFromName(stringEntry(childEl, "name"));
02457 obj->setTabPageLabel(stringEntry(childEl, "tabCaption"));
02458 obj->setToolTipString(stringEntry(childEl, "tabToolTip"));
02459
02460 if (!boolEntry(childEl, "hasParent")) {
02461 QRect r = rectEntry(childEl, "geometry");
02462 obj = getDockWidgetFromName(stringEntry(childEl, "name"));
02463 obj->applyToWidget(0);
02464 obj->setGeometry(r);
02465 if (boolEntry(childEl, "visible"))
02466 obj->QWidget::show();
02467 }
02468
02469 if (obj && obj->header && obj->header->inherits("K3DockWidgetHeader")) {
02470 K3DockWidgetHeader *h = static_cast<K3DockWidgetHeader*>(obj->header);
02471 h->setDragEnabled(boolEntry(childEl, "dragEnabled"));
02472 }
02473 }
02474
02475
02476 for( QDomNode n = base.firstChild(); !n.isNull(); n = n.nextSibling() )
02477 {
02478 QDomElement childEl = n.toElement();
02479 if (childEl.isNull()) continue;
02480
02481 K3DockWidget *obj = 0;
02482
02483 if (childEl.tagName() == "dockContainer") {
02484
02485 K3DockWidget *cont=getDockWidgetFromName(stringEntry(childEl, "name"));
02486 kDebug(282)<<"dockContainer: "<<stringEntry(childEl,"name");
02487 if (!(cont->d->isContainer)) {
02488 kDebug(282)<<"restoration of dockContainer is only supported for already existing dock containers";
02489 } else {
02490 K3DockContainer *dc=dynamic_cast<K3DockContainer*>(cont->getWidget());
02491 if (!dc) kDebug(282)<<"Error while trying to handle dockcontainer configuration restoration";
02492 else {
02493 dc->load(childEl);
02494 removeFromAutoCreateList(cont);
02495 }
02496
02497 }
02498 }
02499 else
02500 if (childEl.tagName() == "splitGroup") {
02501
02502 QString name = stringEntry(childEl, "name");
02503 QString firstName = stringEntry(childEl, "firstName");
02504 QString secondName = stringEntry(childEl, "secondName");
02505 int orientation = numberEntry(childEl, "orientation");
02506 int separatorPos = numberEntry(childEl, "separatorPos");
02507
02508 K3DockWidget *first = getDockWidgetFromName(firstName);
02509 K3DockWidget *second = getDockWidgetFromName(secondName);
02510 if (first && second) {
02511 obj = first->manualDock(second,
02512 (orientation == (int)Qt::Vertical)? K3DockWidget::DockLeft : K3DockWidget::DockTop,
02513 separatorPos);
02514 if (obj)
02515 obj->setName(name.toLatin1().constData());
02516 }
02517 } else if (childEl.tagName() == "tabGroup") {
02518
02519 QString name = stringEntry(childEl, "name");
02520 Q3StrList list = listEntry(childEl, "tabs", "tab");
02521
02522 K3DockWidget *d1 = getDockWidgetFromName( list.first() );
02523 list.next();
02524 K3DockWidget *d2 = getDockWidgetFromName( list.current() );
02525
02526 K3DockWidget *obj = d2->manualDock( d1, K3DockWidget::DockCenter );
02527 if (obj) {
02528 K3DockTabGroup *tab = (K3DockTabGroup*)obj->widget;
02529 list.next();
02530 while (list.current() && obj) {
02531 K3DockWidget *tabDock = getDockWidgetFromName(list.current());
02532 obj = tabDock->manualDock(d1, K3DockWidget::DockCenter);
02533 list.next();
02534 }
02535 if (obj) {
02536 obj->setName(name.toLatin1().constData());
02537 tab->showPage(tab->page(numberEntry(childEl, "currentTab")));
02538 }
02539 }
02540 } else {
02541 continue;
02542 }
02543
02544 if (!boolEntry(childEl, "hasParent")) {
02545 QRect r = rectEntry(childEl, "geometry");
02546 obj = getDockWidgetFromName(stringEntry(childEl, "name"));
02547 obj->applyToWidget(0);
02548 obj->setGeometry(r);
02549 if (boolEntry(childEl, "visible"))
02550 obj->QWidget::show();
02551 }
02552
02553 if (obj && obj->header && obj->header->inherits("K3DockWidgetHeader")) {
02554 K3DockWidgetHeader *h = static_cast<K3DockWidgetHeader*>(obj->header);
02555 h->setDragEnabled(boolEntry(childEl, "dragEnabled"));
02556 }
02557 }
02558
02559
02560
02561 for( QDomNode n = base.firstChild(); !n.isNull(); n = n.nextSibling() )
02562 {
02563 QDomElement childEl = n.toElement();
02564
02565 if (childEl.tagName() != "dock" && childEl.tagName() != "tabGroup")
02566 continue;
02567
02568 K3DockWidget *obj = 0;
02569
02570 if (!boolEntry(childEl, "hasParent")) {
02571
02572 obj = getDockWidgetFromName(stringEntry(childEl, "name"));
02573 QString name = stringEntry(childEl, "dockBackTo");
02574 if (!name.isEmpty()) {
02575 obj->setFormerBrotherDockWidget(getDockWidgetFromName(name));
02576 }
02577 obj->formerDockPos = K3DockWidget::DockPosition(numberEntry(childEl, "dockBackToPos"));
02578 obj->updateHeader();
02579 }
02580 }
02581
02582 if (main->inherits("K3DockMainWindow")) {
02583 K3DockMainWindow *dmain = (K3DockMainWindow*)main;
02584
02585 QString mv = stringEntry(base, "centralWidget");
02586 if (!mv.isEmpty() && getDockWidgetFromName(mv) ) {
02587 K3DockWidget *mvd = getDockWidgetFromName(mv);
02588 mvd->applyToWidget(dmain);
02589 mvd->show();
02590 dmain->setCentralWidget(mvd);
02591 }
02592 QString md = stringEntry(base, "mainDockWidget");
02593 if (!md.isEmpty() && getDockWidgetFromName(md)) {
02594 K3DockWidget *mvd = getDockWidgetFromName(md);
02595 dmain->setMainDockWidget(mvd);
02596 }
02597 } else {
02598 QString mv = stringEntry(base, "mainWidget");
02599 if (!mv.isEmpty() && getDockWidgetFromName(mv)) {
02600 K3DockWidget *mvd = getDockWidgetFromName(mv);
02601 mvd->applyToWidget(main);
02602 mvd->show();
02603 }
02604
02605
02606 QRect mr = rectEntry(base, "geometry");
02607 main->move(mr.topLeft());
02608 main->resize(mr.size());
02609 }
02610
02611 if (isMainVisible)
02612 main->show();
02613
02614 if (d->m_readDockConfigMode == WrapExistingWidgetsOnly) {
02615 finishReadDockConfig();
02616 }
02617 }
02618
02619 void K3DockManager::removeFromAutoCreateList(K3DockWidget* pDockWidget)
02620 {
02621 if (!autoCreateDock) return;
02622 autoCreateDock->removeAt(autoCreateDock->indexOf(pDockWidget));
02623 }
02624
02625 void K3DockManager::finishReadDockConfig()
02626 {
02627 delete autoCreateDock;
02628 autoCreateDock = 0;
02629 }
02630
02631 void K3DockManager::setReadDockConfigMode(int mode)
02632 {
02633 d->m_readDockConfigMode = mode;
02634 }
02635
02636 #ifndef NO_KDE2
02637 void K3DockManager::writeConfig( KConfig* c, const QString &_group )
02638 {
02639
02640 if (!c) {
02641 c = KGlobal::config().data();
02642 }
02643 QString group = _group.isEmpty() ? "dock_setting_default" : _group;
02644
02645 KConfigGroup cg(c, group);
02646 cg.writeEntry( "Version", DOCK_CONFIG_VERSION );
02647
02648 QStringList nameList;
02649 QStringList findList;
02650 K3DockWidget* obj;
02651
02652
02653 QStringList nList;
02654 Q_FOREACH( QObject* o, *childDock )
02655 {
02656 #ifdef __GNUC__ // ### KDE4
02657 # warning "Can obj be 0 and what should we do in the case that it is?"
02658 #endif
02659 obj = qobject_cast<K3DockWidget*> ( o );
02660 if ( !obj )
02661 continue;
02662
02663 nList.append( obj->objectName() );
02664 if ( obj->parent() == main )
02665 cg.writeEntry( "Main:view", obj->objectName() );
02666 }
02667
02668
02669 for (QObjectList::iterator it = d->containerDocks.begin() ;it != d->containerDocks.end(); ++it)
02670 {
02671 K3DockContainer* dc = dynamic_cast<K3DockContainer*>(((K3DockWidget*)(*it))->widget);
02672 if (dc) {
02673 dc->prepareSave(nList);
02674 }
02675 }
02676
02677
02678 QStringList::Iterator nListIt=nList.begin();
02679 while ( nListIt!=nList.end() ){
02680
02681 obj = getDockWidgetFromName( *nListIt );
02682 QString cname = obj->name();
02683 if ( obj->header ){
02684 obj->header->saveConfig( &cg );
02685 }
02686 if (obj->d->isContainer) {
02687 K3DockContainer* x = dynamic_cast<K3DockContainer*>(obj->widget);
02688 if (x) {
02689 x->save(c,group);
02690 }
02691 }
02692
02693 if ( obj->isGroup ){
02694 if ( (findList.indexOf( obj->firstName ) != -1) && (findList.indexOf( obj->lastName ) != -1 )){
02695
02696 cg.writeEntry( cname+":type", "GROUP");
02697 if ( !obj->parent() ){
02698 cg.writeEntry( cname+":parent", "___null___");
02699 cg.writeEntry( cname+":geometry", QRect(obj->frameGeometry().topLeft(), obj->size()) );
02700 cg.writeEntry( cname+":visible", QVariant(obj->isVisible()) );
02701 } else {
02702 cg.writeEntry( cname+":parent", "yes");
02703 }
02704 cg.writeEntry( cname+":first_name", obj->firstName );
02705 cg.writeEntry( cname+":last_name", obj->lastName );
02706 cg.writeEntry( cname+":orientation", QVariant(obj->splitterOrientation) );
02707 cg.writeEntry( cname+":sepPos", QVariant(((K3DockSplitter*)obj->widget)->separatorPosInPercent()) );
02708
02709 nameList.append( obj->name() );
02710 findList.append( obj->name() );
02711
02712 nList.erase(nListIt);
02713 nListIt=nList.begin();
02714 } else {
02715
02716
02717
02718
02719
02720
02721 ++nListIt;
02722
02723 if (nListIt==nList.end()) nListIt=nList.begin();
02724 }
02725 } else {
02726
02727 if ( obj->isTabGroup){
02728 cg.writeEntry( cname+":type", "TAB_GROUP");
02729 if ( !obj->parent() ){
02730 cg.writeEntry( cname+":parent", "___null___");
02731 cg.writeEntry( cname+":geometry", QRect(obj->frameGeometry().topLeft(), obj->size()) );
02732 cg.writeEntry( cname+":visible", QVariant(obj->isVisible()) );
02733 cg.writeEntry( cname+":dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : "");
02734 cg.writeEntry( cname+":dockBackToPos", QVariant(obj->formerDockPos) );
02735 } else {
02736 cg.writeEntry( cname+":parent", "yes");
02737 }
02738 QStringList list;
02739 for ( int i = 0; i < ((K3DockTabGroup*)obj->widget)->count(); ++i )
02740 list.append( ((K3DockTabGroup*)obj->widget)->page( i )->name() );
02741 cg.writeEntry( cname+":tabNames", list );
02742 cg.writeEntry( cname+":curTab", QVariant(((K3DockTabGroup*)obj->widget)->currentPageIndex()) );
02743
02744 nameList.append( obj->name() );
02745 findList.append( obj->name() );
02746
02747 nList.erase(nListIt);
02748 nListIt=nList.begin();
02749 } else {
02750
02751 cg.writeEntry( cname+":tabCaption", obj->tabPageLabel());
02752 cg.writeEntry( cname+":tabToolTip", obj->toolTipString());
02753 if ( !obj->parent() ){
02754 cg.writeEntry( cname+":type", "NULL_DOCK");
02755 cg.writeEntry( cname+":geometry", QRect(obj->frameGeometry().topLeft(), obj->size()) );
02756 cg.writeEntry( cname+":visible", QVariant(obj->isVisible()) );
02757 cg.writeEntry( cname+":dockBackTo", obj->formerBrotherDockWidget ? obj->formerBrotherDockWidget->name() : "");
02758 cg.writeEntry( cname+":dockBackToPos", QVariant(obj->formerDockPos) );
02759 } else {
02760 cg.writeEntry( cname+":type", "DOCK");
02761 }
02762 nameList.append( cname.toLatin1().constData() );
02763
02764 findList.append( obj->name() );
02765 nList.erase(nListIt);
02766 nListIt=nList.begin();
02767 }
02768 }
02769 }
02770 cg.writeEntry( "NameList", nameList );
02771
02772 cg.writeEntry( "Main:Geometry", QRect(main->frameGeometry().topLeft(), main->size()) );
02773 cg.writeEntry( "Main:visible", QVariant(main->isVisible()) );
02774
02775 if ( main->inherits("K3DockMainWindow") ){
02776 K3DockMainWindow* dmain = (K3DockMainWindow*)main;
02777
02778 cg.writeEntry( "Main:view", dmain->centralWidget() ? dmain->centralWidget()->name():"" );
02779 cg.writeEntry( "Main:dock", dmain->getMainDockWidget() ? dmain->getMainDockWidget()->name() :"" );
02780 }
02781
02782 c->sync();
02783
02784 }
02785 #include <qmessagebox.h>
02786 void K3DockManager::readConfig( KConfig* c, const QString &_group )
02787 {
02788 if (!c) {
02789 c = KGlobal::config().data();
02790 }
02791 QString group = group.isEmpty() ? "dock_setting_default" : _group;
02792
02793 KConfigGroup cg(c, group );
02794 QStringList nameList;
02795 cg.readEntry( "NameList", nameList );
02796 QString ver = cg.readEntry( "Version", "0.0.1" );
02797 if ( nameList.isEmpty() || ver != DOCK_CONFIG_VERSION ){
02798 activate();
02799 return;
02800 }
02801
02802 autoCreateDock = new QObjectList();
02803
02804 bool isMainVisible = main->isVisible();
02805
02806
02807
02808
02809 QObjectList::iterator it = childDock->begin();
02810 K3DockWidget * obj;
02811
02812 while ( (obj=(K3DockWidget*)(*it)) ){
02813 ++it;
02814 if ( !obj->isGroup && !obj->isTabGroup )
02815 {
02816 if ( obj->parent() ) obj->undock(); else obj->hide();
02817 }
02818 }
02819
02820
02821
02822 foreach( const QString &oname, nameList )
02823 {
02824 cg.changeGroup( group );
02825 QString type = cg.readEntry( oname + ":type", QString() );
02826 obj = 0L;
02827
02828 if ( type == "NULL_DOCK" || cg.readEntry( oname + ":parent", QString() ) == "___null___" ){
02829 QRect r = cg.readEntry( oname + ":geometry",QRect() );
02830 obj = getDockWidgetFromName( oname );
02831 obj->applyToWidget( 0L );
02832 obj->setGeometry(r);
02833
02834 cg.changeGroup( group );
02835 obj->setTabPageLabel(cg.readEntry( oname + ":tabCaption", QString() ));
02836 obj->setToolTipString(cg.readEntry( oname + ":tabToolTip", QString() ));
02837 if ( cg.readEntry( oname + ":visible",QVariant(false) ).toBool() ){
02838 obj->QWidget::show();
02839 }
02840 }
02841
02842 if ( type == "DOCK" ){
02843 obj = getDockWidgetFromName( oname );
02844 obj->setTabPageLabel(cg.readEntry( oname + ":tabCaption", QString() ));
02845 obj->setToolTipString(cg.readEntry( oname + ":tabToolTip", QString() ));
02846 }
02847
02848 if (obj && obj->d->isContainer) {
02849 dynamic_cast<K3DockContainer*>(obj->widget)->load(c,group);
02850 removeFromAutoCreateList(obj);
02851 }
02852 if ( obj && obj->header){
02853 obj->header->loadConfig( &cg );
02854 }
02855 }
02856
02857
02858 foreach( const QString &oname, nameList )
02859 {
02860 cg.changeGroup( group );
02861 QString type = cg.readEntry( oname + ":type", QString() );
02862 obj = 0L;
02863
02864 if ( type == "GROUP" ){
02865 K3DockWidget* first = getDockWidgetFromName( cg.readEntry( oname + ":first_name", QString() ) );
02866 K3DockWidget* last = getDockWidgetFromName( cg.readEntry( oname + ":last_name", QString() ) );
02867 int sepPos = cg.readEntry( oname + ":sepPos",0 );
02868
02869 Qt::Orientation p = (Qt::Orientation)cg.readEntry( oname + ":orientation",0 );
02870 if ( first && last ){
02871 obj = first->manualDock( last, ( p == Qt::Vertical ) ? K3DockWidget::DockLeft : K3DockWidget::DockTop, sepPos );
02872 if (obj){
02873 obj->setName( oname.toLatin1().constData() );
02874 }
02875 }
02876 }
02877
02878 if ( type == "TAB_GROUP" ){
02879 K3DockWidget* tabDockGroup = 0L;
02880 QStringList list = cg.readEntry( oname+":tabNames",QStringList() );
02881 QStringList::const_iterator listit = list.begin();
02882 K3DockWidget* d1 = getDockWidgetFromName( *listit++ );
02883 K3DockWidget* d2 = getDockWidgetFromName( *listit++ );
02884 tabDockGroup = d2->manualDock( d1, K3DockWidget::DockCenter );
02885 if ( tabDockGroup ){
02886 K3DockTabGroup* tab = dynamic_cast<K3DockTabGroup*>(tabDockGroup->widget);
02887 while ( listit != list.end() && tabDockGroup ){
02888 K3DockWidget* tabDock = getDockWidgetFromName( *listit++ );
02889 tabDockGroup = tabDock->manualDock( d1, K3DockWidget::DockCenter );
02890 }
02891 if ( tabDockGroup ){
02892 tabDockGroup->setName( oname.toLatin1().constData() );
02893 cg.changeGroup( group );
02894 if (tab)
02895 tab->showPage( tab->page( cg.readEntry( oname+":curTab",0 ) ) );
02896 }
02897 }
02898 obj = tabDockGroup;
02899 }
02900
02901 if (obj && obj->d->isContainer) dynamic_cast<K3DockContainer*>(obj->widget)->load(c,group);
02902 if ( obj && obj->header){
02903 obj->header->loadConfig( &cg );
02904 }
02905 }
02906
02907
02908
02909 foreach( const QString &oname, nameList )
02910 {
02911 cg.changeGroup( group );
02912 QString type = cg.readEntry( oname + ":type", QString() );
02913 obj = 0L;
02914
02915 if ( type == "NULL_DOCK" || cg.readEntry( oname + ":parent", QString() ) == "___null___" ){
02916 obj = getDockWidgetFromName( oname );
02917 cg.changeGroup( group );
02918 QString name = cg.readEntry( oname + ":dockBackTo", QString() );
02919 if (!name.isEmpty()) {
02920 obj->setFormerBrotherDockWidget(getDockWidgetFromName( name ));
02921 }
02922 obj->formerDockPos = K3DockWidget::DockPosition(cg.readEntry( oname + ":dockBackToPos",0 ));
02923 }
02924 }
02925
02926 if ( main->inherits("K3DockMainWindow") ){
02927 K3DockMainWindow* dmain = (K3DockMainWindow*)main;
02928
02929 cg.changeGroup( group );
02930 QString mv = cg.readEntry( "Main:view" );
02931 if ( !mv.isEmpty() && getDockWidgetFromName( mv ) ){
02932 K3DockWidget* mvd = getDockWidgetFromName( mv );
02933 mvd->applyToWidget( dmain );
02934 mvd->show();
02935 dmain->setView( mvd );
02936 }
02937 cg.changeGroup( group );
02938 QString md = cg.readEntry( "Main:dock" );
02939 if ( !md.isEmpty() && getDockWidgetFromName( md ) ){
02940 K3DockWidget* mvd = getDockWidgetFromName( md );
02941 dmain->setMainDockWidget( mvd );
02942 }
02943 } else {
02944 cg.changeGroup( group );
02945 QString mv = cg.readEntry( "Main:view" );
02946 if ( !mv.isEmpty() && getDockWidgetFromName( mv ) ){
02947 K3DockWidget* mvd = getDockWidgetFromName( mv );
02948 mvd->applyToWidget( main );
02949 mvd->show();
02950 }
02951
02952 }
02953
02954
02955 if (d->m_readDockConfigMode == WrapExistingWidgetsOnly) {
02956 finishReadDockConfig();
02957 }
02958
02959 cg.changeGroup( group );
02960
02961 QRect mr = cg.readEntry("Main:Geometry", QRect());
02962
02963 if (!main->inherits("K3DockMainWindow"))
02964 main->move(mr.topLeft());
02965
02966 main->resize(mr.size());
02967
02968 if ( isMainVisible ) main->show();
02969 }
02970 #endif
02971
02972
02973 void K3DockManager::dumpDockWidgets() {
02974 QObjectList::iterator it = childDock->begin();
02975 K3DockWidget * obj;
02976 while ( (obj=(K3DockWidget*)(*it)) ) {
02977 ++it;
02978 kDebug(282)<<"K3DockManager::dumpDockWidgets:"<<obj->name();
02979 }
02980
02981 }
02982
02983 K3DockWidget* K3DockManager::getDockWidgetFromName( const QString& dockName )
02984 {
02985 QObjectList::iterator it = childDock->begin();
02986 K3DockWidget * obj;
02987 while ( (obj=(K3DockWidget*)(*it)) ) {
02988 ++it;
02989 if ( obj->objectName() == dockName ) return obj;
02990 }
02991
02992 K3DockWidget* autoCreate = 0L;
02993 if ( autoCreateDock ){
02994 kDebug(282)<<"Autocreating dock: "<<dockName;
02995 autoCreate = new K3DockWidget( this, dockName.toLatin1().constData(), QPixmap("") );
02996 autoCreateDock->append( autoCreate );
02997 }
02998 return autoCreate;
02999 }
03000 void K3DockManager::setSplitterOpaqueResize(bool b)
03001 {
03002 d->splitterOpaqueResize = b;
03003 }
03004
03005 bool K3DockManager::splitterOpaqueResize() const
03006 {
03007 return d->splitterOpaqueResize;
03008 }
03009
03010 void K3DockManager::setSplitterKeepSize(bool b)
03011 {
03012 d->splitterKeepSize = b;
03013 }
03014
03015 bool K3DockManager::splitterKeepSize() const
03016 {
03017 return d->splitterKeepSize;
03018 }
03019
03020 void K3DockManager::setSplitterHighResolution(bool b)
03021 {
03022 d->splitterHighResolution = b;
03023 }
03024
03025 bool K3DockManager::splitterHighResolution() const
03026 {
03027 return d->splitterHighResolution;
03028 }
03029
03030 void K3DockManager::slotMenuPopup()
03031 {
03032 menu->clear();
03033 menuData->clear();
03034
03035 QObjectList::iterator it = childDock->begin();
03036 K3DockWidget * obj;
03037 while ( (obj=(K3DockWidget*)(*it)) ) {
03038 ++it;
03039 if ( obj->mayBeHide() )
03040 {
03041 menu->insertItem( i18n("Hide %1", obj->windowTitle()));
03042 menuData->append( new MenuDockData( obj, true ) );
03043 }
03044
03045 if ( obj->mayBeShow() )
03046 {
03047 menu->insertItem( i18n("Show %1", obj->windowTitle()));
03048 menuData->append( new MenuDockData( obj, false ) );
03049 }
03050 }
03051 }
03052
03053 void K3DockManager::slotMenuActivated( int id )
03054 {
03055 MenuDockData* data = menuData->at( id );
03056 data->dock->changeHideShowState();
03057 }
03058
03059 K3DockWidget* K3DockManager::findWidgetParentDock( QWidget* w ) const
03060 {
03061 QObjectList::iterator it = childDock->begin();
03062 K3DockWidget * dock;
03063 K3DockWidget * found = 0L;
03064
03065 while ( (dock=(K3DockWidget*)(*it)) ) {
03066 ++it;
03067 if ( dock->widget == w ){ found = dock; break; }
03068 }
03069 return found;
03070 }
03071
03072 void K3DockManager::makeWidgetDockVisible( QWidget* w )
03073 {
03074 findWidgetParentDock(w)->makeDockVisible();
03075 }
03076
03077 Q3PopupMenu* K3DockManager::dockHideShowMenu() const
03078 {
03079 return menu;
03080 }
03081
03082 void K3DockManager::drawDragRectangle()
03083 {
03084 #ifdef BORDERLESS_WINDOWS
03085 return
03086 #endif
03087 if (d->oldDragRect == d->dragRect)
03088 return;
03089
03090 int i;
03091 QRect oldAndNewDragRect[2];
03092 oldAndNewDragRect[0] = d->oldDragRect;
03093 oldAndNewDragRect[1] = d->dragRect;
03094
03095
03096 for (i = 0; i <= 1; i++) {
03097 if (oldAndNewDragRect[i].isEmpty())
03098 continue;
03099
03100 K3DockWidget* pDockWdgAtRect = (K3DockWidget*) QApplication::widgetAt( oldAndNewDragRect[i].topLeft() );
03101 if (!pDockWdgAtRect)
03102 continue;
03103
03104 bool isOverMainWdg = false;
03105
03106 K3DockMainWindow* pMain = 0L;
03107 K3DockWidget* pTLDockWdg = 0L;
03108 QWidget* topWdg;
03109 if (pDockWdgAtRect->topLevelWidget() == main) {
03110 isOverMainWdg = true;
03111 topWdg = pMain = (K3DockMainWindow*) main;
03112
03113
03114 }
03115 else {
03116 topWdg = pTLDockWdg = (K3DockWidget*) pDockWdgAtRect->topLevelWidget();
03117
03118
03119 }
03120
03121
03122 QPainter p;
03123 p.begin( topWdg );
03124
03125
03126
03127
03128
03129
03130
03131
03132
03133
03134 QRect r = oldAndNewDragRect[i];
03135 r.moveTopLeft( r.topLeft() - topWdg->mapToGlobal(QPoint(0,0)) );
03136 p.drawRect(r.x(), r.y(), r.width(), r.height());
03137 p.end();
03138 }
03139
03140
03141 d->oldDragRect = d->dragRect;
03142 }
03143
03144 void K3DockManager::setSpecialLeftDockContainer(K3DockWidget* container) {
03145 d->leftContainer=container;
03146 }
03147
03148 void K3DockManager::setSpecialTopDockContainer(K3DockWidget* container) {
03149 d->topContainer=container;
03150 }
03151
03152 void K3DockManager::setSpecialRightDockContainer(K3DockWidget* container) {
03153 d->rightContainer=container;
03154
03155 }
03156
03157 void K3DockManager::setSpecialBottomDockContainer(K3DockWidget* container) {
03158 d->bottomContainer=container;
03159 }
03160
03161
03162 K3DockArea::K3DockArea( QWidget* parent, const char *name)
03163 :QWidget( parent, name)
03164 {
03165 QString new_name = QString(name) + QString("_DockManager");
03166 dockManager = new K3DockManager( this, new_name.toLatin1().constData() );
03167 mainDockWidget = 0L;
03168 }
03169
03170 K3DockArea::~K3DockArea()
03171 {
03172 delete dockManager;
03173 }
03174
03175 K3DockManager* K3DockArea::manager()
03176 {
03177 return dockManager;
03178 }
03179
03180 K3DockWidget* K3DockArea::createDockWidget( const QString& name, const QPixmap &pixmap, QWidget* parent, const QString& strCaption, const QString& strTabPageLabel)
03181 {
03182 return new K3DockWidget( dockManager, name.toLatin1().constData(), pixmap, parent, strCaption, strTabPageLabel );
03183 }
03184
03185 void K3DockArea::activateDock()
03186 {
03187 dockManager->activate();
03188 }
03189
03190 Q3PopupMenu* K3DockArea::dockHideShowMenu()
03191 {
03192 return dockManager->dockHideShowMenu();
03193 }
03194
03195 void K3DockArea::makeDockVisible( K3DockWidget* dock )
03196 {
03197 if ( dock )
03198 dock->makeDockVisible();
03199 }
03200
03201 void K3DockArea::makeDockInvisible( K3DockWidget* dock )
03202 {
03203 if ( dock )
03204 dock->undock();
03205 }
03206
03207 void K3DockArea::makeWidgetDockVisible( QWidget* widget )
03208 {
03209 makeDockVisible( dockManager->findWidgetParentDock(widget) );
03210 }
03211
03212 void K3DockArea::writeDockConfig(QDomElement &base)
03213 {
03214 dockManager->writeConfig(base);
03215 }
03216
03217 void K3DockArea::readDockConfig(QDomElement &base)
03218 {
03219 dockManager->readConfig(base);
03220 }
03221
03222 void K3DockArea::slotDockWidgetUndocked()
03223 {
03224 QObject* pSender = (QObject*) sender();
03225 if (!pSender->inherits("K3DockWidget")) return;
03226 K3DockWidget* pDW = (K3DockWidget*) pSender;
03227 emit dockWidgetHasUndocked( pDW);
03228 }
03229
03230 void K3DockArea::resizeEvent(QResizeEvent *rsize)
03231 {
03232 QWidget::resizeEvent(rsize);
03233 if (!children().isEmpty()){
03234 #ifndef NO_KDE2
03235
03236 #endif
03237 QList<QWidget *> list = findChildren<QWidget*>();
03238
03239 foreach( QWidget *w, list )
03240 {
03241 w->setGeometry(QRect(QPoint(0,0),size()));
03242 }
03243 #if 0
03244 K3DockSplitter *split;
03245
03246 {
03247
03248
03249 QObject *obj=children()->getFirst();
03250 if (split = dynamic_cast<K3DockSplitter*>(obj))
03251 {
03252 split->setGeometry( QRect(QPoint(0,0), size() ));
03253
03254 }
03255 }
03256 #endif
03257 }
03258 }
03259
03260 #ifndef NO_KDE2
03261 void K3DockArea::writeDockConfig( KConfig* c, const QString &group )
03262 {
03263 dockManager->writeConfig( c, group );
03264 }
03265
03266 void K3DockArea::readDockConfig( KConfig* c, const QString &group )
03267 {
03268 dockManager->readConfig( c, group );
03269 }
03270 #endif
03271
03272 void K3DockArea::setMainDockWidget( K3DockWidget* mdw )
03273 {
03274 if ( mainDockWidget == mdw ) return;
03275 mainDockWidget = mdw;
03276 mdw->applyToWidget(this);
03277 }
03278
03279 K3DockWidget* K3DockArea::getMainDockWidget()
03280 {
03281 return mainDockWidget;
03282 }
03283
03284
03285
03286
03287 K3DockContainer::K3DockContainer(){m_overlapMode=false; m_childrenListBegin=0; m_childrenListEnd=0;}
03288 K3DockContainer::~K3DockContainer(){
03289
03290 if (m_childrenListBegin)
03291 {
03292 struct ListItem *tmp=m_childrenListBegin;
03293 while (tmp)
03294 {
03295 struct ListItem *tmp2=tmp->next;
03296 free(tmp->data);
03297 delete tmp;
03298 tmp=tmp2;
03299 }
03300 m_childrenListBegin=0;
03301 m_childrenListEnd=0;
03302 }
03303
03304 }
03305
03306 void K3DockContainer::activateOverlapMode(int nonOverlapSize) {
03307 m_nonOverlapSize=nonOverlapSize;
03308 m_overlapMode=true;
03309 if (parentDockWidget() && parentDockWidget()->parent()) {
03310 kDebug(282)<<"K3DockContainer::activateOverlapMode: recalculating sizes";
03311 K3DockSplitter *sp= qobject_cast<K3DockSplitter*>(parentDockWidget()->parent());
03312 if (sp)
03313 sp->resizeEvent(0);
03314 }
03315 }
03316
03317 void K3DockContainer::deactivateOverlapMode() {
03318 if (!m_overlapMode) return;
03319 m_overlapMode=false;
03320 if (parentDockWidget() && parentDockWidget()->parent()) {
03321 kDebug(282)<<"K3DockContainer::deactivateOverlapMode: recalculating sizes";
03322 K3DockSplitter *sp= qobject_cast<K3DockSplitter*>(parentDockWidget()->parent());
03323 if (sp)
03324 sp->resizeEvent(0);
03325 }
03326 }
03327
03328 bool K3DockContainer::isOverlapMode() {
03329 return m_overlapMode;
03330 }
03331
03332
03333 bool K3DockContainer::dockDragEnter(K3DockWidget*, QMouseEvent *) { return false;}
03334 bool K3DockContainer::dockDragMove(K3DockWidget*, QMouseEvent *) { return false;}
03335 bool K3DockContainer::dockDragLeave(K3DockWidget*, QMouseEvent *) { return false;}
03336
03337
03338 K3DockWidget *K3DockContainer::parentDockWidget(){return 0;}
03339
03340 QStringList K3DockContainer::containedWidgets() const {
03341 QStringList tmp;
03342 for (struct ListItem *it=m_childrenListBegin;it;it=it->next) {
03343 tmp<<QString(it->data);
03344 }
03345
03346 return tmp;
03347 }
03348
03349 void K3DockContainer::showWidget(K3DockWidget *) {
03350 }
03351
03352 void K3DockContainer::insertWidget (K3DockWidget *dw, const QPixmap &, const QString &, int &)
03353 {
03354 struct ListItem *it=new struct ListItem;
03355 it->data=strdup(dw->name());
03356 it->next=0;
03357
03358 if (m_childrenListEnd)
03359 {
03360 m_childrenListEnd->next=it;
03361 it->prev=m_childrenListEnd;
03362 m_childrenListEnd=it;
03363 }
03364 else
03365 {
03366 it->prev=0;
03367 m_childrenListEnd=it;
03368 m_childrenListBegin=it;
03369 }
03370 }
03371 void K3DockContainer::removeWidget (K3DockWidget *dw){
03372 for (struct ListItem *tmp=m_childrenListBegin;tmp;tmp=tmp->next)
03373 {
03374 if (!strcmp(tmp->data,dw->name()))
03375 {
03376 free(tmp->data);
03377 if (tmp->next) tmp->next->prev=tmp->prev;
03378 if (tmp->prev) tmp->prev->next=tmp->next;
03379 if (tmp==m_childrenListBegin) m_childrenListBegin=tmp->next;
03380 if (tmp==m_childrenListEnd) m_childrenListEnd=tmp->prev;
03381 delete tmp;
03382 break;
03383 }
03384 }
03385 }
03386
03387
03388 void K3DockContainer::undockWidget (K3DockWidget *){;}
03389 void K3DockContainer::setToolTip(K3DockWidget *, QString &){;}
03390 void K3DockContainer::setPixmap(K3DockWidget*,const QPixmap&){;}
03391 void K3DockContainer::load (KConfig*, const QString&){;}
03392 void K3DockContainer::save (KConfig*, const QString&){;}
03393 void K3DockContainer::load (QDomElement&){;}
03394 void K3DockContainer::save (QDomElement&){;}
03395 void K3DockContainer::prepareSave(QStringList &names)
03396 {
03397
03398 for (struct ListItem *tmp=m_childrenListBegin;tmp; tmp=tmp->next)
03399 names.removeAll(tmp->data);
03400
03401
03402
03403
03404 }
03405
03406
03407 K3DockTabGroup::K3DockTabGroup( QWidget *parent, const char *name )
03408 :QTabWidget( parent )
03409 {
03410 setObjectName( QLatin1String(name) );
03411 }
03412
03413 K3DockTabGroup::~K3DockTabGroup()
03414 {
03415 }
03416
03417 QWidget *K3DockTabGroup::transientTo() {
03418 QWidget *tT=0;
03419 for (int i=0;i<count();i++) {
03420 K3DockWidget *dw=qobject_cast<K3DockWidget*>(page(i));
03421 QWidget *tmp;
03422 if ((tmp=dw->transientTo())) {
03423 if (!tT) tT=tmp;
03424 else {
03425 if (tT!=tmp) {
03426 kDebug(282)<<"K3DockTabGroup::transientTo: widget mismatch";
03427 return 0;
03428 }
03429 }
03430 }
03431 }
03432
03433 kDebug(282)<<"K3DockTabGroup::transientTo: "<<(tT?"YES":"NO");
03434
03435 return tT;
03436 }
03437
03438 void K3DockWidgetAbstractHeader::virtual_hook( int, void* )
03439 { }
03440
03441 void K3DockWidgetAbstractHeaderDrag::virtual_hook( int, void* )
03442 { }
03443
03444 void K3DockWidgetHeaderDrag::virtual_hook( int id, void* data )
03445 { K3DockWidgetAbstractHeaderDrag::virtual_hook( id, data ); }
03446
03447 void K3DockWidgetHeader::virtual_hook( int id, void* data )
03448 { K3DockWidgetAbstractHeader::virtual_hook( id, data ); }
03449
03450 void K3DockTabGroup::virtual_hook( int, void* )
03451 { }
03452
03453 void K3DockWidget::virtual_hook( int, void* )
03454 { }
03455
03456 void K3DockManager::virtual_hook( int, void* )
03457 { }
03458
03459 void K3DockMainWindow::virtual_hook( int, void* )
03460 { }
03461
03462 void K3DockArea::virtual_hook( int, void* )
03463 { }
03464
03465
03466 #ifndef NO_INCLUDE_MOCFILES // for Qt-only projects, because tmake doesn't take this name
03467 #include "k3dockwidget.moc"
03468 #endif
03469
03470