Logo Search packages:      
Sourcecode: kbear version File versions  Download package

void QextMdiMainFrm::addToolWindow ( QWidget *  pWnd,
KDockWidget::DockPosition  pos = KDockWidget::DockNone,
QWidget *  pTargetWnd = 0L,
int  percent = 50,
const QString &  tabToolTip = 0,
const QString &  tabCaption = 0 
) [protected, virtual]

Usually called from addWindow() when adding a tool view window. It reparents the given widget as toplevel and stay-on-top on the application's main widget.

Definition at line 362 of file qextmdimainfrm.cpp.

References activateView(), QextMdiChildView::caption(), childWindowCloseRequest(), QextMdiChildView::m_bToolView, and QextMdiChildView::setCaption().

Referenced by addWindow().

{
   QextMdiChildView* pToolView = 0L;
   QRect r = pWnd->geometry();

   // if pWnd is not a QextMdiChildView already, cover it by such widget
   if (pWnd->inherits("QextMdiChildView")) {
      pToolView = (QextMdiChildView*) pWnd;
   }
   else {
      pToolView = new QextMdiChildView( pWnd->caption());
      QHBoxLayout* pLayout = new QHBoxLayout( pToolView, 0, -1, "internal_qextmdichildview_layout");
      pWnd->reparent( pToolView, QPoint(0,0));
      pToolView->setName( pWnd->name());
      pToolView->setFocusPolicy( pWnd->focusPolicy());
      const QPixmap& wndIcon = pWnd->icon() ? *(pWnd->icon()) : QPixmap();
      pToolView->setIcon( wndIcon);
      pToolView->setCaption( pWnd->caption());
      QApplication::sendPostedEvents();
      pLayout->addWidget( pWnd);
   }

   // if docking is not desired, add the toolview as stay-on-top toplevel view
   if (pos == KDockWidget::DockNone) {
#if QT_VERSION < 300
      pToolView->reparent(this, WType_TopLevel | WStyle_Dialog, r.topLeft(), pToolView->isVisible());
#else
      pToolView->reparent(this, Qt::WType_TopLevel | Qt::WType_Dialog, r.topLeft(), pToolView->isVisible());
#endif
      QObject::connect( pToolView, SIGNAL(childWindowCloseRequest(QextMdiChildView*)), this, SLOT(childWindowCloseRequest(QextMdiChildView*)) );
      QObject::connect( pToolView, SIGNAL(focusInEventOccurs(QextMdiChildView*)), this, SLOT(activateView(QextMdiChildView*)) );
      m_pWinList->append(pToolView);
      pToolView->m_bToolView = TRUE;
      pToolView->setGeometry(r);
   }
   else {   // add (and dock) the toolview as DockWidget view
      const QPixmap& wndIcon = pWnd->icon() ? *(pWnd->icon()) : QPixmap();
      KDockWidget* pCover = createDockWidget( pToolView->name(),
                                              wndIcon,
                                              0L,  // parent
                                              pToolView->caption(),
                                              tabCaption );
      pCover->setWidget( pToolView);
      pCover->setToolTipString( tabToolTip);
      KDockWidget* pTargetDock = 0L;
      if ((pTargetWnd == m_pDockbaseAreaOfDocumentViews->getWidget()) || (pTargetWnd == this)) {
         pTargetDock = m_pDockbaseAreaOfDocumentViews;
      }
      else if(pTargetWnd != 0L) {
         pTargetDock = dockManager->findWidgetParentDock( pTargetWnd);
         if (!pTargetDock) {
            if (pTargetWnd->parentWidget() && pTargetWnd->parentWidget()->inherits("QextMdiChildView")) {
               pTargetDock = dockManager->findWidgetParentDock( pTargetWnd->parentWidget());
            }
         }
      }
      if (pTargetDock)
         pCover->manualDock( pTargetDock, pos, percent);
      pCover->show();
   }
}


Generated by  Doxygen 1.6.0   Back to index