Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'KDockMainWindow (./kdelibs/kdeui/kdockwidget.h:858)
class KDockMainWindow : public KTMainWindow
{
Q_OBJECT
public:
/**
* Constructs a dockmainwindow. It calls its base class constructor and does additional things concerning
* to the dock stuff:
* <UL><LI>information about the dock state of this' children gets initialized</LI>
* <LI>a dockmanager is created...</LI>
* <LI>...and gets initialized</LI>
* <LI>the main dockwidget is set to 0L</LI></UL>
*
* @param name object name
*/
KDockMainWindow( const char *name = 0L );
/**
* Destructs a dockmainwindow.
*/
virtual ~KDockMainWindow();
/**
* Returns the dockmanager of this. (see @ref KDockManager)
* @return pointer to the wanted dockmanager
*/
KDockManager* manager(){ return dockManager; }
/**
* Sets a new main dockwidget.
* Additionally, the toolbar is re-initialized.
*
* @param _ dockwidget that become the new main dockwidget
*/
void setMainDockWidget( KDockWidget* );
/**
* Returns the main dockwidget.
*
* @return pointer to the main dockwidget
*/
KDockWidget* getMainDockWidget(){ return mainDockWidget; }
/**
* This is one of the most important methods!
* The KDockMainWindow creates a new dockwidget object here that usually should encapsulate the user's widget.
* The new dockwidget is automatically taken under control by the dockmanager of the dockmainwindow.
*
* @param name dockwidget caption (window title)
* @param pixmap window icon (for instance shown when docked as tabwidget entry)
* @param parent parent widget for the new dockwidget
* @return a pointer to the new created dockwidget
*/
KDockWidget* createDockWidget( const QString& name, const QPixmap &pixmap, QWidget* parent = 0L );
/**
* It writes the current dock state in the given section of KConfig.
*
* @param c KDE class for saving configurations
* @param group name of section to write to
*/
void writeDockConfig( KConfig* c = 0L, QString group = QString::null );
/**
* It reads the current dock state from the given section of KConfig.
*
* @param c KDE class for saving configurations
* @param group name of section to read from
*/
void readDockConfig ( KConfig* c = 0L, QString group = QString::null );
/**
* It runs through all dockwidgets which are under control of the dockmanager and calls show() for every
* encapsulated widget and show() for the dockwidget itself if it is not in tab mode.
* Additionally, if the main dockwidget is not a QDialog, it will be shown.
*/
void activateDock(){ dockManager->activate(); }
/**
* Returns a popup menu that contains entries for all controlled dockwidgets making hiding and showing
* them possible.
*
* @return the wanted popup menu
*/
QPopupMenu* dockHideShowMenu(){ return dockManager->dockHideShowMenu(); }
/**
* This method shows the given dockwidget.
* The clue is that it also considers the dockwidget could be a tab page
* and must set to be the activate one.
*
* @param dock the dockwidget that is to be shown
*/
void makeDockVisible( KDockWidget* dock );
/**
* This method hides the given dockwidget.
*
* @param dock the dockwidget that is to be shown
*/
void makeDockInvisible( KDockWidget* dock );
/**
* This is an overloaded member function, provided for convenience.
* It differs from the above function only in what argument(s) it accepts.
*/
void makeWidgetDockVisible( QWidget* widget );
/**
* This method calls the base class method.
* If the given widget inherits KDockWidget, applyToWidget(this) is called.
*
* @param _ any widget that should become the main view
*/
void setView( QWidget* );
protected slots:
/**
* Updates the dock-toolbar buttons and the internal information about the 4 dockwidgets
* that are directly docked to the main widget.
*/
void slotDockChange();
/**
* Inverts the state of the appropriate toggle-toolbutton of the dock-toolbar.
*
* @param _ index of the toolbutton
*/
void slotToggled( int );
/**
* Using the given parameters it updates the information about the 4 dockwidgets
* that are directly docked to the main widget.
*
* @param oldDock new main dockwidget
* @param newDock old main dockwidget
*/
void slotReplaceDock( KDockWidget* oldDock, KDockWidget* newDock );
protected:
/**
* Used as container for information about one of the 4 dockwidgets that are
* directly docked to the main dockwidget.
*/
struct DockPosData
{
/** A Pointer to the dockwidget at this position */
KDockWidget* dock;
KDockWidget* dropDock;
KDockWidget::DockPosition pos;
int sepPos;
};
/**
* This method docks as given in the position data, if toggled is true.
* Otherwise the dockwidget given with the position data will be undocked.
*
* @param toggled specifies if the dockwidget gets docked or undocked
* @param data reference to the struct containing information about the appropriate dockwidget
*/
void toolBarManager( bool toggled, DockPosData &data );
/** A pointer to the main dockwidget (where one can manualDock() to */
KDockWidget* mainDockWidget;
/** A pointer to the manager for the dock process */
KDockManager* dockManager;
/** Contains information about which dockwidget is docked on the left. */
DockPosData DockL;
/** Contains information about which dockwidget is docked on the right. */
DockPosData DockR;
/** Contains information about which dockwidget is docked at the top. */
DockPosData DockT;
/** Contains information about which dockwidget is docked at the bottom. */
DockPosData DockB;
/** A pointer to the dock toolbar
* (for showing or hiding the 4 docked dockwidgets that are docked to the main dockwidget).
*/
KToolBar* toolbar;
};
kdelibs'KDockMainWindow::KDockMainWindow() (./kdelibs/kdeui/kdockwidget.cpp:155)
KDockMainWindow::KDockMainWindow( const char *name )
:KTMainWindow( name )
{
DockB.dock = 0L;
DockB.pos = KDockWidget::DockBottom;
DockT.dock = 0L;
DockT.pos = KDockWidget::DockTop;
DockR.dock = 0L;
DockR.pos = KDockWidget::DockRight;
DockL.dock = 0L;
DockL.pos = KDockWidget::DockLeft;
QString new_name = QString(name) + QString::fromLatin1("_DockManager");
dockManager = new KDockManager( this, new_name.latin1());
toolbar = 0L;
mainDockWidget = 0L;
connect( dockManager, SIGNAL(change()), SLOT(slotDockChange()) );
connect( dockManager, SIGNAL(replaceDock(KDockWidget*,KDockWidget*)), SLOT(slotReplaceDock(KDockWidget*,KDockWidget*)) );
}
kdelibs'KDockMainWindow::~KDockMainWindow() (./kdelibs/kdeui/kdockwidget.cpp:179)
KDockMainWindow::~KDockMainWindow()
{
}
kdelibs'KDockMainWindow::setMainDockWidget() (./kdelibs/kdeui/kdockwidget.cpp:183)
void KDockMainWindow::setMainDockWidget( KDockWidget* mdw )
{
if ( mainDockWidget == mdw ) return;
mainDockWidget = mdw;
if ( mainDockWidget ){
if ( !toolbar ){
toolbar = new KToolBar( this );
toolbar->insertButton( QPixmap(dock_close_top), 1, true, "Close top dock" );
toolbar->insertButton( QPixmap(dock_close_left), 2, true, "Close left dock" );
toolbar->insertButton( QPixmap(dock_close_right), 3, true, "Close right dock" );
toolbar->insertButton( QPixmap(dock_close_bottom), 4, true, "Close bottom dock" );
toolbar->setToggle(1);
toolbar->setToggle(2);
toolbar->setToggle(3);
toolbar->setToggle(4);
toolbar->setButton( 1, true );
toolbar->setButton( 2, true );
toolbar->setButton( 3, true );
toolbar->setButton( 4, true );
toolbar->setFullWidth( false );
toolbar->show();
connect( toolbar, SIGNAL(toggled(int)), SLOT(slotToggled(int)) );
addToolBar( toolbar );
}
} else {
delete toolbar;
toolbar = 0L;
updateRects();
}
slotDockChange();
}
kdelibs'KDockMainWindow::setView() (./kdelibs/kdeui/kdockwidget.cpp:218)
void KDockMainWindow::setView( QWidget *view )
{
if ( view->isA("KDockWidget") ){
if ( view->parent() != this ) ((KDockWidget*)view)->applyToWidget( this );
}
KTMainWindow::setView(view);
updateRects();
}
kdelibs'KDockMainWindow::createDockWidget() (./kdelibs/kdeui/kdockwidget.cpp:227)
KDockWidget* KDockMainWindow::createDockWidget( const QString& name, const QPixmap &pixmap, QWidget* parent )
{
return new KDockWidget( dockManager, name.latin1(), pixmap, parent );
}
kdelibs'KDockMainWindow::slotDockChange() (./kdelibs/kdeui/kdockwidget.cpp:232)
void KDockMainWindow::slotDockChange()
{
if ( !mainDockWidget ) return;
KDockWidget* DL = 0L;
KDockWidget* DR = 0L;
KDockWidget* DT = 0L;
KDockWidget* DB = 0L;
if ( mainDockWidget->parent() == this || mainDockWidget->parent() == 0L ){
if ( toolbar->isButtonOn(1) ) toolbar->setItemEnabled( 1, false );
if ( toolbar->isButtonOn(2) ) toolbar->setItemEnabled( 2, false );
if ( toolbar->isButtonOn(3) ) toolbar->setItemEnabled( 3, false );
if ( toolbar->isButtonOn(4) ) toolbar->setItemEnabled( 4, false );
return;
}
KDockWidget* base = mainDockWidget;
while ( base != 0L && base->parent()!= 0L && base->parent()->inherits("KDockSplitter") )
{
KDockSplitter* s = (KDockSplitter*)base->parent();
Orientation o = ((KDockWidget*)s->parent())->splitterOrientation;
KDockWidget* another = (KDockWidget*)s->getAnother( base );
if ( o == Horizontal ){
if ( s->getFirst() == base ){
DB = DB == 0L ? another : DB;
} else {
DT = DT == 0L ? another : DT;
}
} else { //Vertical
if ( s->getFirst() == base ){
DR = DR == 0L ? another : DR;
} else {
DL = DL == 0L ? another : DL;
}
}
base = (KDockWidget*)s->parent();
}
if ( toolbar->isButtonOn(1) ) toolbar->setItemEnabled( 1, DT != 0L );
if ( toolbar->isButtonOn(2) ) toolbar->setItemEnabled( 2, DL != 0L );
if ( toolbar->isButtonOn(3) ) toolbar->setItemEnabled( 3, DR != 0L );
if ( toolbar->isButtonOn(4) ) toolbar->setItemEnabled( 4, DB != 0L );
/**********************/
if ( DB != 0L && toolbar->isButtonOn(4) ){
DockB.dock = DB;
DockB.dropDock = (KDockWidget*)((KDockSplitter*)DB->parent())->getAnother( DB );
}
if ( DB == 0L && toolbar->isButtonOn(4) ) DockB.dock = 0L;
/**********************/
if ( DR != 0L && toolbar->isButtonOn(3) ){
DockR.dock = DR;
DockR.dropDock = (KDockWidget*)((KDockSplitter*)DR->parent())->getAnother( DR );
}
if ( DR == 0L && toolbar->isButtonOn(3) ) DockR.dock = 0L;
/**********************/
if ( DL != 0L && toolbar->isButtonOn(2) ){
DockL.dock = DL;
DockL.dropDock = (KDockWidget*)((KDockSplitter*)DL->parent())->getAnother( DL );
}
if ( DL == 0L && toolbar->isButtonOn(2) ) DockL.dock = 0L;
/**********************/
if ( DT != 0L && toolbar->isButtonOn(1) ){
DockT.dock = DT;
DockT.dropDock = (KDockWidget*)((KDockSplitter*)DT->parent())->getAnother( DT );
}
if ( DT == 0L && toolbar->isButtonOn(1) ) DockT.dock = 0L;
/**********************/
}
kdelibs'KDockMainWindow::slotToggled() (./kdelibs/kdeui/kdockwidget.cpp:303)
void KDockMainWindow::slotToggled( int id )
{
switch ( id ){
case 1:
toolBarManager( toolbar->isButtonOn(1), DockT );
break;
case 2:
toolBarManager( toolbar->isButtonOn(2), DockL );
break;
case 3:
toolBarManager( toolbar->isButtonOn(3), DockR );
break;
case 4:
toolBarManager( toolbar->isButtonOn(4), DockB );
break;
default:
break;
}
}
kdelibs'KDockMainWindow::toolBarManager() (./kdelibs/kdeui/kdockwidget.cpp:323)
void KDockMainWindow::toolBarManager( bool toggled, DockPosData &data )
{
if ( data.dock == 0L || data.dropDock == 0L ) return;
if ( toggled ){
data.dock->manualDock( data.dropDock, data.pos, data.sepPos );
} else {
data.sepPos = ((KDockSplitter*)data.dock->parent())->separatorPos();
data.dock->undock();
}
}
kdelibs'KDockMainWindow::slotReplaceDock() (./kdelibs/kdeui/kdockwidget.cpp:335)
void KDockMainWindow::slotReplaceDock( KDockWidget* oldDock, KDockWidget* newDock )
{
DockB.dock = DockB.dock == oldDock ? newDock:DockB.dock;
DockT.dock = DockT.dock == oldDock ? newDock:DockT.dock;
DockR.dock = DockR.dock == oldDock ? newDock:DockR.dock;
DockL.dock = DockL.dock == oldDock ? newDock:DockL.dock;
DockB.dropDock = DockB.dropDock == oldDock ? newDock:DockB.dropDock;
DockT.dropDock = DockT.dropDock == oldDock ? newDock:DockT.dropDock;
DockR.dropDock = DockR.dropDock == oldDock ? newDock:DockR.dropDock;
DockL.dropDock = DockL.dropDock == oldDock ? newDock:DockL.dropDock;
}
kdelibs'KDockMainWindow::makeDockVisible() (./kdelibs/kdeui/kdockwidget.cpp:348)
void KDockMainWindow::makeDockVisible( KDockWidget* dock )
{
if ( !dock ) return;
if ( toolbar ){
toolbar->blockSignals( true );
QWidget* testWidget = dock;
while ( testWidget != 0L ){
if ( testWidget->isA("KDockWidget") ){
KDockWidget* test = (KDockWidget*)testWidget;
if ( !toolbar->isButtonOn(1) && DockT.dock == test ){
toolbar->toggleButton(1);
toolBarManager( true, DockT );
}
if ( !toolbar->isButtonOn(2) && DockL.dock == test ){
toolbar->toggleButton(2);
toolBarManager( true, DockL );
}
if ( !toolbar->isButtonOn(3) && DockR.dock == test ){
toolbar->toggleButton(3);
toolBarManager( true, DockR );
}
if ( !toolbar->isButtonOn(4) && DockB.dock == test ){
toolbar->toggleButton(4);
toolBarManager( true, DockB );
}
}
testWidget = testWidget->parentWidget();
}
dock->makeDockVisible();
toolbar->blockSignals( false );
} else {
dock->makeDockVisible();
}
}
kdelibs'KDockMainWindow::makeDockInvisible() (./kdelibs/kdeui/kdockwidget.cpp:388)
void KDockMainWindow::makeDockInvisible( KDockWidget* dock )
{
if ( !dock ) return;
if ( toolbar ){
toolbar->blockSignals( true );
QWidget* testWidget = dock;
while ( testWidget != 0L ){
if ( testWidget->isA("KDockWidget") ){
KDockWidget* test = (KDockWidget*)testWidget;
if ( toolbar->isButtonOn(1) && DockT.dock == test ){
toolbar->toggleButton(1);
toolBarManager( false, DockT );
}
if ( toolbar->isButtonOn(2) && DockL.dock == test ){
toolbar->toggleButton(2);
toolBarManager( false, DockL );
}
if ( toolbar->isButtonOn(3) && DockR.dock == test ){
toolbar->toggleButton(3);
toolBarManager( false, DockR );
}
if ( toolbar->isButtonOn(4) && DockB.dock == test ){
toolbar->toggleButton(4);
toolBarManager( false, DockB );
}
}
testWidget = testWidget->parentWidget();
}
toolbar->blockSignals( false );
} else {
dock->undock();
}
}
kdelibs'KDockMainWindow::makeWidgetDockVisible() (./kdelibs/kdeui/kdockwidget.cpp:426)
void KDockMainWindow::makeWidgetDockVisible( QWidget* widget )
{
makeDockVisible( dockManager->findWidgetParentDock(widget) );
}
kdelibs'KDockMainWindow::writeDockConfig() (./kdelibs/kdeui/kdockwidget.cpp:431)
void KDockMainWindow::writeDockConfig( KConfig* c, QString group )
{
if ( toolbar ){
toolbar->blockSignals( true );
if ( !toolbar->isButtonOn(1) ){
toolbar->toggleButton(1);
toolBarManager( true, DockT );
}
if ( !toolbar->isButtonOn(2) ){
toolbar->toggleButton(2);
toolBarManager( true, DockL );
}
if ( !toolbar->isButtonOn(3) ){
toolbar->toggleButton(3);
toolBarManager( true, DockR );
}
if ( !toolbar->isButtonOn(4) ){
toolbar->toggleButton(4);
toolBarManager( true, DockB );
}
dockManager->writeConfig( c, group );
toolbar->blockSignals( false );
} else {
dockManager->writeConfig( c, group );
}
}
kdelibs'KDockMainWindow::readDockConfig() (./kdelibs/kdeui/kdockwidget.cpp:460)
void KDockMainWindow::readDockConfig( KConfig* c, QString group )
{
if ( toolbar ){
toolbar->blockSignals( true );
if ( !toolbar->isButtonOn(1) ){
toolbar->toggleButton(1);
toolBarManager( true, DockT );
}
if ( !toolbar->isButtonOn(2) ){
toolbar->toggleButton(2);
toolBarManager( true, DockL );
}
if ( !toolbar->isButtonOn(3) ){
toolbar->toggleButton(3);
toolBarManager( true, DockR );
}
if ( !toolbar->isButtonOn(4) ){
toolbar->toggleButton(4);
toolBarManager( true, DockB );
}
dockManager->readConfig( c, group );
toolbar->blockSignals( false );
} else {
dockManager->readConfig( c, group );
}
}
/*************************************************************************/