1 // File: QtxDockAction.cxx
2 // Author: Sergey TELKOV
4 #include "QtxDockAction.h"
6 #include "QtxResourceMgr.h"
10 #include <qdockarea.h>
11 #include <qdockwindow.h>
12 #include <qmainwindow.h>
13 #include <qapplication.h>
16 Name: QtxDockAction [public]
17 Desc: Constructs an Dock action with given main window and name.
20 QtxDockAction::QtxDockAction( QMainWindow* mw, const char* name )
21 : QtxAction( "Windows and Toolbars", "Windows and Toolbars", 0, mw, name ),
31 Name: QtxDockAction [public]
32 Desc: This constructor creates an action with the following properties: the
33 description text, the menu text and. It is a child of given main window
34 and named specified name.
37 QtxDockAction::QtxDockAction( const QString& text, const QString& menuText, QMainWindow* mw, const char* name )
38 : QtxAction( text, menuText, 0, mw, name ),
48 Name: QtxDockAction [public]
49 Desc: This constructor creates an action with the following properties: the
50 description text, the menu text, the icon or iconset icon and keyboard
51 accelerator. It is a child of given main window and named specified name.
54 QtxDockAction::QtxDockAction( const QString& text, const QIconSet& icon, const QString& menuText, QMainWindow* mw, const char* name )
55 : QtxAction( text, icon, menuText, 0, mw, name ),
65 Name: ~QtxDockAction [public]
66 Desc: Removes all added popup items.
69 QtxDockAction::~QtxDockAction()
71 for ( MenuMap::ConstIterator mIt = myMenu.begin(); mIt != myMenu.end(); ++mIt )
72 removeFrom( mIt.key() );
74 for ( InfoMap::ConstIterator iIt = myInfo.begin(); iIt != myInfo.end(); ++iIt )
79 Name: mainWindow [public]
80 Desc: Returns the main window which contains managed dock windows.
83 QMainWindow* QtxDockAction::mainWindow() const
89 Name: isAutoAdd [public]
90 Desc: Returns the auto add property. If this property is setted then all newly
91 appeared dock windows will be automatically added.
94 bool QtxDockAction::isAutoAdd() const
100 Name: setAutoAdd [public]
101 Desc: Sets the auto add property. If this property is setted then all newly
102 appeared dock windows will be automatically added.
105 void QtxDockAction::setAutoAdd( const bool on )
111 Name: isAutoPlace [public]
112 Desc: Returns the auto place property. If this property is setted then all newly
113 added dock windows will be automatically placed according stored place information.
116 bool QtxDockAction::isAutoPlace() const
122 Name: setAutoPlace [public]
123 Desc: Sets the auto place property. If this property is setted then all newly
124 added dock windows will be automatically placed according stored place
128 void QtxDockAction::setAutoPlace( const bool on )
134 Name: isSeparate [public]
135 Desc: Returns the 'separate' property.
138 bool QtxDockAction::isSeparate() const
144 Name: setSeparate [public]
145 Desc: Sets the 'separate' property. If this property is 'true' then toolbars and
146 dock windows menu items will be placed in different popup menus otherwise
147 their will be placed in one common popup menu. This property will be
148 affected in next method 'addTo'.
151 void QtxDockAction::setSeparate( const bool on )
158 Desc: Add the dock windows sub menu item to the end of specified popup.
161 bool QtxDockAction::addTo( QWidget* wid )
163 return addTo( wid, -1 );
168 Desc: Add the dock windows sub menu item to specified popup at the given index.
171 bool QtxDockAction::addTo( QWidget* wid, const int idx )
173 if ( !wid || !wid->inherits( "QPopupMenu" ) )
176 QPopupMenu* pm = (QPopupMenu*)wid;
179 if ( myMenu.contains( pm ) )
183 mInfo.dock = new QPopupMenu( pm );
184 mInfo.tool = isSeparate() ? new QPopupMenu( pm ) : 0;
187 splitMenuText( dock, tool );
189 myMenu.insert( pm, mInfo );
194 iconSet().isNull() ? pm->insertItem ( dock, mInfo.dock, -1, index ) :
195 pm->insertItem ( iconSet(), dock, mInfo.dock, -1, index );
201 iconSet().isNull() ? pm->insertItem ( tool, mInfo.tool, -1, index ) :
202 pm->insertItem ( iconSet(), tool, mInfo.tool, -1, index );
204 connect( pm, SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
205 connect( pm, SIGNAL( destroyed( QObject* ) ), this, SLOT( onPopupDestroyed( QObject* ) ) );
211 Name: removeFrom [public]
212 Desc: Removes dock window sub menu from specified popup.
215 bool QtxDockAction::removeFrom( QWidget* wid )
217 QPopupMenu* pm = (QPopupMenu*)wid;
219 if ( myMenu.contains( pm ) )
221 pm->removeItem( findId( pm, myMenu[pm].dock ) );
222 pm->removeItem( findId( pm, myMenu[pm].tool ) );
224 delete myMenu[pm].dock;
225 delete myMenu[pm].tool;
228 disconnect( pm, SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
229 disconnect( pm, SIGNAL( destroyed( QObject* ) ), this, SLOT( onPopupDestroyed( QObject* ) ) );
232 return QtxAction::removeFrom( wid );
236 Name: addDockWindow [public]
237 Desc: Add dock window to internal data structures. Action will be include all added
238 dock windows in to menu and manage their place configuration.
241 bool QtxDockAction::addDockWindow( QDockWindow* dw )
243 if ( !dw || !mainWindow() )
246 if ( myInfo.contains( dw ) )
249 myInfo.insert( dw, DockInfo() );
251 DockInfo& inf = myInfo[dw];
252 inf.name = windowName( dw );
253 QAction* a = inf.a = new QAction( mainWindow(), 0, true );
255 autoLoadPlaceInfo( dw );
257 bool block = a->signalsBlocked();
258 a->blockSignals( true );
259 a->setOn( dw->isVisibleTo( mainWindow() ) );
260 a->blockSignals( block );
265 dw->installEventFilter( this );
267 connect( a, SIGNAL( toggled( bool ) ), this, SLOT( onToggled( bool ) ) );
268 connect( dw, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWindowDestroyed( QObject* ) ) );
269 connect( dw, SIGNAL( visibilityChanged( bool ) ), this, SLOT( onVisibilityChanged( bool ) ) );
275 Name: removeDockWindow [public]
276 Desc: Remove dock window from internal data structures. Action will not manage this window.
279 bool QtxDockAction::removeDockWindow( QDockWindow* dw )
281 if ( !myInfo.contains( dw ) )
284 myGeom.remove( myInfo[dw].name );
289 dw->removeEventFilter( this );
291 disconnect( dw, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWindowDestroyed( QObject* ) ) );
292 disconnect( dw, SIGNAL( visibilityChanged( bool ) ), this, SLOT( onVisibilityChanged( bool ) ) );
298 Name: eventFilter [public]
299 Desc: Event filter process caption and icon changing of managed dock windows
300 and try to add newly appeared dock windows.
303 bool QtxDockAction::eventFilter( QObject* o, QEvent* e )
305 if ( o->inherits( "QDockWindow" ) && ( e->type() == QEvent::CaptionChange ||
306 e->type() == QEvent::IconChange ) )
307 updateInfo( (QDockWindow*)o );
309 if ( o->inherits( "QDockArea" ) && e->type() == QEvent::ChildRemoved )
311 QChildEvent* ce = (QChildEvent*)e;
312 if ( ce->child() && ce->child()->inherits( "QDockWindow" ) )
313 savePlaceInfo( (QDockWindow*)ce->child() );
316 if ( o->inherits( "QDockArea" ) && e->type() == QEvent::ChildInserted )
318 QChildEvent* ce = (QChildEvent*)e;
319 if ( ce->child() && ce->child()->inherits( "QDockWindow" ) )
320 QApplication::postEvent( this, new QCustomEvent( (QEvent::Type)AutoAdd, ce->child() ) );
327 Name: restoreGeometry [public]
328 Desc: Retrieve the dock window geometry. If dock window specified as 0
329 then all windows geometry will be restored.
332 void QtxDockAction::restoreGeometry( QDockWindow* dw ) const
341 Name: storeGeometry [public]
342 Desc: Store the dock window geometry. If dock window specified as 0
343 then all windows geometry will be stored.
346 void QtxDockAction::storeGeometry( QDockWindow* dw )
348 QPtrList<QDockWindow> dwList;
353 dockWindows( dwList );
355 for ( QPtrListIterator<QDockWindow> it( dwList ); it.current(); ++it )
356 savePlaceInfo( it.current() );
360 Name: loadGeometry [public]
361 Desc: Retrieve the dock windows geometry information from the specified resource manager section.
364 void QtxDockAction::loadGeometry( QtxResourceMgr* resMgr, const QString& section, const bool clear )
366 QString sec = section.stripWhiteSpace();
367 if ( !resMgr || sec.isEmpty() )
370 myNames = QStringList::split( "|", resMgr->stringValue( sec, "windows_list", QString::null ) );
372 QMap<QString, int> map;
373 QStringList params = resMgr->parameters( sec );
374 for ( QStringList::const_iterator it = params.begin(); it != params.end(); ++it )
376 QString p = QStringList::split( ".", *it, true ).first().stripWhiteSpace();
381 for ( QMap<QString, int>::ConstIterator itr = map.begin(); itr != map.end(); ++itr )
384 if ( !clear && myGeom.contains( itr.key() ) )
385 inf = myGeom[itr.key()];
388 inf.vis = true; inf.newLine = false; inf.place = DockTop;
389 inf.index = 0; inf.offset = 0;
390 inf.x = 0; inf.y = 0; inf.w = 0; inf.h = 0;
391 inf.fixW = -1; inf.fixH = -1;
393 if ( loadGeometry( resMgr, sec, itr.key(), inf ) )
394 myGeom.insert( itr.key(), inf );
399 Name: saveGeometry [public]
400 Desc: Store the dock windows geometry information into the specified resource manager section.
403 void QtxDockAction::saveGeometry( QtxResourceMgr* resMgr, const QString& section, const bool clear ) const
405 QString sec = section.stripWhiteSpace();
406 if ( !resMgr || sec.isEmpty() )
409 QtxDockAction* that = (QtxDockAction*)this;
410 that->storeGeometry();
412 that->myNames.clear();
413 collectNames( Minimized, that->myNames );
414 for ( int i = DockTornOff; i < Minimized; i++ )
415 collectNames( i, that->myNames );
418 resMgr->removeSection( sec );
420 resMgr->setValue( sec, "windows_list", myNames.join( "|" ) );
422 for ( GeomMap::ConstIterator it = myGeom.begin(); it != myGeom.end(); ++it )
423 saveGeometry( resMgr, sec, it.key(), it.data() );
427 Name: onAboutToShow [private slots]
428 Desc: Prepare sub popup with dock windows list when parent popup is shown.
431 void QtxDockAction::onAboutToShow()
433 const QObject* obj = sender();
434 if ( obj && obj->inherits( "QPopupMenu" ) )
436 QPopupMenu* pm = (QPopupMenu*)obj;
438 pm->setItemEnabled( findId( pm, myMenu[pm].dock ), isEnabled() && myMenu[pm].dock && myMenu[pm].dock->count() );
439 pm->setItemEnabled( findId( pm, myMenu[pm].tool ), isEnabled() && myMenu[pm].tool && myMenu[pm].tool->count() );
444 Name: onToggled [private slots]
445 Desc: Show or hide dock window when user toggled window item in popup.
448 void QtxDockAction::onToggled( bool on )
450 QDockWindow* dw = dockWindow( (QAction*)sender() );
452 on ? dw->show() : dw->hide();
456 Name: onPopupDestroyed [private slots]
457 Desc: Remove destroyed popup from data structures.
460 void QtxDockAction::onPopupDestroyed( QObject* obj )
462 myMenu.remove( (QPopupMenu*)obj );
466 Name: onWindowDestroyed [private slots]
467 Desc: Remove information about destroyed dock window.
470 void QtxDockAction::onWindowDestroyed( QObject* obj )
472 QDockWindow* dw = (QDockWindow*)obj;
473 if ( !myInfo.contains( dw ) )
481 Name: onVisibilityChanged [private slots]
482 Desc: Toggle corresponded action when visibility state of dock window changed.
485 void QtxDockAction::onVisibilityChanged( bool on )
487 const QObject* obj = sender();
488 if ( !obj || !obj->inherits( "QDockWindow" ) )
491 QDockWindow* dw = (QDockWindow*)obj;
493 QAction* a = action( dw );
494 if ( a && a->isOn() != on )
496 bool block = a->signalsBlocked();
497 a->blockSignals( true );
499 a->blockSignals( block );
506 Name: onDockWindowPositionChanged [private slots]
507 Desc: Update dock window place information
510 void QtxDockAction::onDockWindowPositionChanged( QDockWindow* dw )
516 Name: event [protected]
517 Desc: Check consistency the popup content and internal datas.
518 Synchronize internal data structures with popup content.
521 bool QtxDockAction::event( QEvent* e )
523 if ( e->type() == AutoAdd )
525 QCustomEvent* ce = (QCustomEvent*)e;
526 QDockWindow* dw = (QDockWindow*)ce->data();
527 if ( !myInfo.contains( dw ) )
529 autoAddDockWindow( dw );
530 autoLoadPlaceInfo( dw );
534 return QtxAction::event( e );
538 Name: checkPopup [private]
539 Desc: Check consistency the popup content and internal datas.
540 Synchronize internal data structures with popup content.
543 void QtxDockAction::checkPopup( QPopupMenu* pm )
545 if ( !myMenu.contains( pm ) )
548 int id = findId( pm, myMenu[pm].dock );
551 delete myMenu[pm].dock;
554 id = findId( pm, myMenu[pm].tool );
557 delete myMenu[pm].tool;
561 if ( !myMenu[pm].dock )
563 delete myMenu[pm].tool;
565 disconnect( pm, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) );
570 Name: fillPopup [private]
571 Desc: Clear the popup and the add to it required actions.
574 void QtxDockAction::fillPopup( QPopupMenu* pm ) const
576 if ( !pm || !mainWindow() )
579 if ( !myMenu.contains( pm ) )
582 QPopupMenu* dockMenu = myMenu[pm].dock;
583 QPopupMenu* toolMenu = myMenu[pm].tool;
585 for ( InfoMap::ConstIterator mit = myInfo.begin(); mit != myInfo.end(); ++mit )
587 mit.data().a->removeFrom( dockMenu );
588 mit.data().a->removeFrom( toolMenu );
597 QPtrList<QDockWindow> dockList;
598 dockWindows( dockList, mainWindow() );
600 if ( dockList.isEmpty() )
603 QPtrList<QAction> toolBars, windows;
604 for ( QPtrListIterator<QDockWindow> it( dockList ); it.current(); ++it )
606 if ( !myInfo.contains( it.current() ) )
608 QtxDockAction* that = (QtxDockAction*)this;
609 that->autoAddDockWindow( it.current() );
612 if ( !mainWindow()->appropriate( it.current() ) ||
613 it.current()->caption().isEmpty() || !action( it.current() ) )
616 if ( isToolBar( it.current() ) )
617 toolBars.append( action( it.current() ) );
619 windows.append( action( it.current() ) );
622 for ( QPtrListIterator<QAction> wit( windows ); wit.current(); ++wit )
623 wit.current()->addTo( dockMenu );
625 dockMenu->insertSeparator();
627 for ( QPtrListIterator<QAction> tit( toolBars ); tit.current(); ++tit )
628 tit.current()->addTo( toolMenu ? toolMenu : dockMenu );
630 Qtx::simplifySeparators( dockMenu );
631 Qtx::simplifySeparators( toolMenu );
635 Name: isToolBar [private]
636 Desc: Returns 'true' if dock window is a toolbar.
639 bool QtxDockAction::isToolBar( QDockWindow* dw ) const
641 return dw && dw->inherits( "QToolBar" );
645 Name: findId [private]
646 Desc: Returns identificator of popup item which contains sub popup 'pm' in the popup 'cont'.
649 int QtxDockAction::findId( QPopupMenu* cont, QPopupMenu* pm ) const
656 for ( int i = 0; i < (int)cont->count() && id == -1; i++ )
659 QMenuItem* item = cont->findItem( cont->idAt( i ), &md );
660 if ( item && md == cont && item->popup() == pm )
667 Name: dockWindows [private]
668 Desc: Returns all dock windows of the main window.
671 void QtxDockAction::dockWindows( QPtrList<QDockWindow>& lst, QMainWindow* main ) const
675 QMainWindow* mw = main ? main : mainWindow();
679 lst = mw->dockWindows();
683 Name: updateInfo [private]
684 Desc: Updates icon and caption info of dock window in the corresponded action.
687 void QtxDockAction::updateInfo( QDockWindow* dw )
689 QAction* a = action( dw );
693 a->setText( dw->caption() );
694 a->setMenuText( dw->caption() );
696 if ( isToolBar( dw ) )
697 a->setStatusTip( tr( "Toggles toolbar \"%1\" on/off" ).arg( dw->caption() ) );
699 a->setStatusTip( tr( "Toggles window \"%1\" on/off" ).arg( dw->caption() ) );
701 const QPixmap* icon = dw->icon();
703 a->setIconSet( *icon );
707 Name: savePlaceInfo [private]
708 Desc: Store the place and geometry information from specified dock window.
711 void QtxDockAction::savePlaceInfo( QDockWindow* dw )
713 if ( !myInfo.contains( dw ) )
716 if ( !myGeom.contains( myInfo[dw].name ) )
717 myGeom.insert( myInfo[dw].name, GeomInfo() );
719 GeomInfo& inf = myGeom[myInfo[dw].name];
722 inf.vis = dw->isVisibleTo( mainWindow() );
723 mainWindow()->getLocation( dw, dock, inf.index, inf.newLine, inf.offset );
729 inf.h = dw->height();
730 inf.fixW = dw->fixedExtent().width();
731 inf.fixH = dw->fixedExtent().height();
735 Name: loadPlaceInfo [private]
736 Desc: Retrieve the stored place and geometry information to specified dock window.
739 void QtxDockAction::loadPlaceInfo( QDockWindow* dw ) const
741 if ( !myInfo.contains( dw ) )
744 QString winName = myInfo[dw].name;
745 if ( winName.isEmpty() || !myGeom.contains( winName ) )
748 GeomInfo inf = myGeom[myInfo[dw].name];
750 mainWindow()->moveDockWindow( dw, (Qt::Dock)inf.place, inf.newLine, inf.index, inf.offset );
751 dw->setGeometry( inf.x, inf.y, inf.w, inf.h );
753 dw->setFixedExtentWidth( inf.fixW );
754 dw->setFixedExtentHeight( inf.fixH );
756 QtxDockAction* that = (QtxDockAction*)this;
757 that->myGeom.insert( myInfo[dw].name, inf );
761 Name: loadPlaceInfo [private]
762 Desc: Retrieve the stored place and geometry information to all dock windows.
765 void QtxDockAction::loadPlaceInfo() const
767 QMainWindow* mw = mainWindow();
771 typedef QPtrList<QDockWindow> DockWinList;
774 dockWindows( lst, mw );
776 QMap<QString, QDockWindow*> nameMap;
777 for ( QPtrListIterator<QDockWindow> itr( lst ); itr.current(); ++itr )
780 if ( myInfo.contains( itr.current() ) )
781 name = myInfo[itr.current()].name;
783 if ( !myGeom.contains( name ) )
786 nameMap.insert( name, itr.current() );
790 for ( QStringList::const_iterator iter = myNames.begin(); iter != myNames.end(); ++iter )
792 if ( nameMap.contains( *iter ) )
793 winList.append( nameMap[*iter] );
794 nameMap.remove( *iter );
797 for ( QMap<QString, QDockWindow*>::ConstIterator mIt = nameMap.begin(); mIt != nameMap.end(); ++mIt )
798 winList.append( mIt.data() );
800 QMap<int, DockWinList> winMap;
801 QMap<QDockWindow*, GeomInfo> geomMap;
803 for ( QPtrListIterator<QDockWindow> it( winList ); it.current(); ++it )
806 if ( myInfo.contains( it.current() ) )
807 name = myInfo[it.current()].name;
809 if ( !myGeom.contains( name ) )
812 GeomInfo inf( myGeom[name] );
813 geomMap.insert( it.current(), inf );
814 if ( !winMap.contains( inf.place ) )
815 winMap.insert( inf.place, DockWinList() );
816 winMap[inf.place].append( it.current() );
819 loadPlaceArea( DockMinimized, mw, 0,
820 winMap.contains( DockMinimized ) ? winMap[DockMinimized] : DockWinList(), geomMap );
821 for ( int i = DockTornOff; i < DockMinimized; i++ )
823 loadPlaceArea( i, mw, dockArea( i ), winMap.contains( i ) ? winMap[i] : DockWinList(), geomMap );
828 Name: loadPlaceArea [private]
829 Desc: Set the place and geometry information to all dock windows in the area.
832 void QtxDockAction::loadPlaceArea( const int place, QMainWindow* mw, QDockArea* area,
833 const QPtrList<QDockWindow>& dockList,
834 const QMap<QDockWindow*, GeomInfo>& geomMap ) const
836 for ( QPtrListIterator<QDockWindow> it( dockList ); it.current(); ++it )
838 if ( !geomMap.contains( it.current() ) )
841 const GeomInfo& inf = geomMap[it.current()];
842 mw->moveDockWindow( it.current(), (Qt::Dock)place, inf.newLine, inf.index, inf.offset );
848 for ( QPtrListIterator<QDockWindow> itr( dockList ); itr.current(); ++itr )
850 QDockWindow* dw = itr.current();
851 if ( !geomMap.contains( dw ) )
854 const GeomInfo& inf = geomMap[dw];
855 if ( place != DockTornOff )
857 dw->setNewLine( inf.newLine );
858 dw->setOffset( inf.offset );
859 dw->setFixedExtentWidth( inf.fixW );
860 dw->setFixedExtentHeight( inf.fixH );
862 dw->setGeometry( inf.x, inf.y, inf.w, inf.h );
864 inf.vis ? dw->show() : dw->hide();
870 wid->layout()->invalidate();
871 wid->layout()->activate();
876 Name: action [private]
877 Desc: Returns action for the given dock window.
880 QAction* QtxDockAction::action( QDockWindow* dw ) const
883 if ( myInfo.contains( dw ) )
889 Name: dockWindow [private]
890 Desc: Returns dock window for the given action.
893 QDockWindow* QtxDockAction::dockWindow( const QAction* a ) const
896 for ( InfoMap::ConstIterator it = myInfo.begin(); it != myInfo.end() && !dw; ++it )
898 if ( it.data().a == a )
905 Name: initialize [private]
906 Desc: Initialisation of the object. Sets the event filters and add existing dock windows.
909 void QtxDockAction::initialize( QMainWindow* mw )
914 QPtrList<QDockWindow> lst;
915 dockWindows( lst, mw );
917 for ( QPtrListIterator<QDockWindow> it( lst ); it.current(); ++it )
918 autoAddDockWindow( it.current() );
921 mw->topDock()->installEventFilter( this );
922 if ( mw->leftDock() )
923 mw->leftDock()->installEventFilter( this );
924 if ( mw->rightDock() )
925 mw->rightDock()->installEventFilter( this );
926 if ( mw->bottomDock() )
927 mw->bottomDock()->installEventFilter( this );
929 connect( mw, SIGNAL( dockWindowPositionChanged( QDockWindow* ) ),
930 this, SLOT( onDockWindowPositionChanged( QDockWindow* ) ) );
934 Name: windowName [private]
935 Desc: Generate the dock window name.
938 QString QtxDockAction::windowName( QDockWindow* dw ) const
944 name = dw->name( "" );
945 if ( name.isEmpty() )
946 name = dw->caption();
953 Name: autoAddDockWindow [private]
954 Desc: Add the dock window if auto add property is setted.
957 bool QtxDockAction::autoAddDockWindow( QDockWindow* dw )
962 return addDockWindow( dw );
966 Name: autoLoadPlaceInfo [private]
967 Desc: Retieve the dock window place geometry if auto place property is setted.
970 void QtxDockAction::autoLoadPlaceInfo( QDockWindow* dw )
977 Name: splitMenuText [private]
981 void QtxDockAction::splitMenuText( QString& dock, QString& tool ) const
983 dock = tool = menuText();
987 QStringList lst = splitText( menuText(), "|" );
988 if ( lst.count() < 2 )
989 lst = splitText( menuText(), "and" );
996 Name: splitText [private]
1000 QStringList QtxDockAction::splitText( const QString& str, const QString& sep ) const
1004 int idx = str.lower().find( sep.lower() );
1007 res.append( str.mid( 0, idx ).stripWhiteSpace() );
1008 res.append( str.mid( idx + sep.length() ).stripWhiteSpace() );
1015 Name: dockPlace [private]
1019 int QtxDockAction::dockPlace( const QString& dockName ) const
1021 static QMap<QString, int> dockNameMap;
1022 if ( dockNameMap.isEmpty() )
1024 dockNameMap["top"] = DockTop;
1025 dockNameMap["bottom"] = DockBottom;
1026 dockNameMap["left"] = DockLeft;
1027 dockNameMap["right"] = DockRight;
1028 dockNameMap["tornoff"] = DockTornOff;
1029 dockNameMap["torn_off"] = DockTornOff;
1030 dockNameMap["outside"] = DockTornOff;
1031 dockNameMap["undock"] = DockTornOff;
1032 dockNameMap["minimized"] = DockMinimized;
1033 dockNameMap["unmanaged"] = DockUnmanaged;
1037 if ( dockNameMap.contains( dockName.lower() ) )
1038 res = dockNameMap[dockName.lower()];
1043 Name: dockArea [private]
1047 QDockArea* QtxDockAction::dockArea( const int place ) const
1049 if ( !mainWindow() )
1052 QDockArea* area = 0;
1056 area = mainWindow()->topDock();
1059 area = mainWindow()->bottomDock();
1062 area = mainWindow()->leftDock();
1065 area = mainWindow()->rightDock();
1072 Name: loadGeometry [private]
1076 bool QtxDockAction::loadGeometry( QtxResourceMgr* resMgr, const QString& sec,
1077 const QString& name, GeomInfo& inf ) const
1079 if ( !resMgr || sec.isEmpty() || name.isEmpty() )
1082 QString tmpl = QString( "%1.%2" ).arg( name );
1084 inf.vis = resMgr->booleanValue( sec, tmpl.arg( "visible" ), inf.vis );
1085 inf.newLine = resMgr->booleanValue( sec, tmpl.arg( "new_line" ), inf.newLine );
1087 inf.index = resMgr->integerValue( sec, tmpl.arg( "index" ), inf.index );
1088 inf.offset = resMgr->integerValue( sec, tmpl.arg( "offset" ), inf.offset );
1090 inf.x = resMgr->integerValue( sec, tmpl.arg( "x" ), inf.x );
1091 inf.y = resMgr->integerValue( sec, tmpl.arg( "y" ), inf.y );
1092 inf.w = resMgr->integerValue( sec, tmpl.arg( "width" ), inf.w );
1093 inf.h = resMgr->integerValue( sec, tmpl.arg( "height" ), inf.h );
1095 inf.fixW = resMgr->integerValue( sec, tmpl.arg( "fixed_width" ), inf.fixW );
1096 inf.fixH = resMgr->integerValue( sec, tmpl.arg( "fixed_height" ), inf.fixH );
1099 if ( !resMgr->value( sec, tmpl.arg( "place" ), place ) )
1102 if ( resMgr->value( sec, tmpl.arg( "place" ), placeStr ) )
1103 place = dockPlace( placeStr );
1106 if ( place >= DockUnmanaged && place <= DockMinimized )
1113 Name: saveGeometry [private]
1117 bool QtxDockAction::saveGeometry( QtxResourceMgr* resMgr, const QString& sec,
1118 const QString& name, const GeomInfo& inf ) const
1120 if ( !resMgr || sec.isEmpty() || name.isEmpty() )
1123 QString tmpl = QString( "%1.%2" ).arg( name );
1125 resMgr->setValue( sec, tmpl.arg( "visible" ), inf.vis );
1126 resMgr->setValue( sec, tmpl.arg( "new_line" ), inf.newLine );
1127 resMgr->setValue( sec, tmpl.arg( "index" ), inf.index );
1128 resMgr->setValue( sec, tmpl.arg( "offset" ), inf.offset );
1129 resMgr->setValue( sec, tmpl.arg( "x" ), inf.x );
1130 resMgr->setValue( sec, tmpl.arg( "y" ), inf.y );
1131 resMgr->setValue( sec, tmpl.arg( "width" ), inf.w );
1132 resMgr->setValue( sec, tmpl.arg( "height" ), inf.h );
1133 resMgr->setValue( sec, tmpl.arg( "fixed_width" ), inf.fixW );
1134 resMgr->setValue( sec, tmpl.arg( "fixed_height" ), inf.fixH );
1135 resMgr->setValue( sec, tmpl.arg( "place" ), inf.place );
1141 Name: collectNames [private]
1145 void QtxDockAction::collectNames( const int place, QStringList& lst ) const
1147 QPtrList<QDockWindow> winList;
1148 QDockArea* area = dockArea( place );
1150 winList = area->dockWindowList();
1152 winList = mainWindow()->dockWindows( (Qt::Dock)place );
1154 for ( QPtrListIterator<QDockWindow> it( winList ); it.current(); ++it )
1157 if ( myInfo.contains( it.current() ) )
1158 name = myInfo[it.current()].name;
1159 if ( name.isEmpty() )
1160 name = windowName( it.current() );
1161 if ( name.isEmpty() )