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->remove( 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() == (int)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 //! collect pointer of info to have fresh info data after processEvents();
813 GeomInfo* inf = (GeomInfo*)&( myGeom[name] );
814 geomMap.insert( it.current(), inf );
815 if ( !winMap.contains( inf->place ) )
816 winMap.insert( inf->place, DockWinList() );
817 winMap[inf->place].append( it.current() );
820 loadPlaceArea( DockMinimized, mw, 0,
821 winMap.contains( DockMinimized ) ? winMap[DockMinimized] : DockWinList(), geomMap );
822 for ( int i = DockTornOff; i < DockMinimized; i++ )
824 loadPlaceArea( i, mw, dockArea( i ), winMap.contains( i ) ? winMap[i] : DockWinList(), geomMap );
829 Name: loadPlaceArea [private]
830 Desc: Set the place and geometry information to all dock windows in the area.
833 void QtxDockAction::loadPlaceArea( const int place, QMainWindow* mw, QDockArea* area,
834 const QPtrList<QDockWindow>& dockList,
835 const QMap<QDockWindow*, GeomInfo*>& geomMap ) const
837 for ( QPtrListIterator<QDockWindow> it( dockList ); it.current(); ++it )
839 if ( !geomMap.contains( it.current() ) )
842 GeomInfo* inf = geomMap[it.current()];
843 mw->moveDockWindow( it.current(), (Qt::Dock)place, inf->newLine, inf->index, inf->offset );
849 qApp->processEvents();
851 for ( QPtrListIterator<QDockWindow> itr( dockList ); itr.current(); ++itr )
853 QDockWindow* dw = itr.current();
854 if ( !geomMap.contains( dw ) )
857 GeomInfo* inf = geomMap[dw];
858 if ( place != DockTornOff )
860 dw->setNewLine( inf->newLine );
861 dw->setOffset( inf->offset );
862 dw->setFixedExtentWidth( inf->fixW );
863 dw->setFixedExtentHeight( inf->fixH );
865 dw->setGeometry( inf->x, inf->y, inf->w, inf->h );
867 inf->vis ? dw->show() : dw->hide();
873 wid->layout()->invalidate();
874 wid->layout()->activate();
879 Name: action [private]
880 Desc: Returns action for the given dock window.
883 QAction* QtxDockAction::action( QDockWindow* dw ) const
886 if ( myInfo.contains( dw ) )
892 Name: dockWindow [private]
893 Desc: Returns dock window for the given action.
896 QDockWindow* QtxDockAction::dockWindow( const QAction* a ) const
899 for ( InfoMap::ConstIterator it = myInfo.begin(); it != myInfo.end() && !dw; ++it )
901 if ( it.data().a == a )
908 Name: initialize [private]
909 Desc: Initialisation of the object. Sets the event filters and add existing dock windows.
912 void QtxDockAction::initialize( QMainWindow* mw )
917 QPtrList<QDockWindow> lst;
918 dockWindows( lst, mw );
920 for ( QPtrListIterator<QDockWindow> it( lst ); it.current(); ++it )
921 autoAddDockWindow( it.current() );
924 mw->topDock()->installEventFilter( this );
925 if ( mw->leftDock() )
926 mw->leftDock()->installEventFilter( this );
927 if ( mw->rightDock() )
928 mw->rightDock()->installEventFilter( this );
929 if ( mw->bottomDock() )
930 mw->bottomDock()->installEventFilter( this );
932 connect( mw, SIGNAL( dockWindowPositionChanged( QDockWindow* ) ),
933 this, SLOT( onDockWindowPositionChanged( QDockWindow* ) ) );
937 Name: windowName [private]
938 Desc: Generate the dock window name.
941 QString QtxDockAction::windowName( QDockWindow* dw ) const
947 name = dw->name( "" );
948 if ( name.isEmpty() )
949 name = dw->caption();
956 Name: autoAddDockWindow [private]
957 Desc: Add the dock window if auto add property is setted.
960 bool QtxDockAction::autoAddDockWindow( QDockWindow* dw )
965 return addDockWindow( dw );
969 Name: autoLoadPlaceInfo [private]
970 Desc: Retieve the dock window place geometry if auto place property is setted.
973 void QtxDockAction::autoLoadPlaceInfo( QDockWindow* dw )
980 Name: splitMenuText [private]
984 void QtxDockAction::splitMenuText( QString& dock, QString& tool ) const
986 dock = tool = menuText();
990 QStringList lst = splitText( menuText(), "|" );
991 if ( lst.count() < 2 )
992 lst = splitText( menuText(), "and" );
999 Name: splitText [private]
1003 QStringList QtxDockAction::splitText( const QString& str, const QString& sep ) const
1007 int idx = str.lower().find( sep.lower() );
1010 res.append( str.mid( 0, idx ).stripWhiteSpace() );
1011 res.append( str.mid( idx + sep.length() ).stripWhiteSpace() );
1018 Name: dockPlace [private]
1022 int QtxDockAction::dockPlace( const QString& dockName ) const
1024 static QMap<QString, int> dockNameMap;
1025 if ( dockNameMap.isEmpty() )
1027 dockNameMap["top"] = DockTop;
1028 dockNameMap["bottom"] = DockBottom;
1029 dockNameMap["left"] = DockLeft;
1030 dockNameMap["right"] = DockRight;
1031 dockNameMap["tornoff"] = DockTornOff;
1032 dockNameMap["torn_off"] = DockTornOff;
1033 dockNameMap["outside"] = DockTornOff;
1034 dockNameMap["undock"] = DockTornOff;
1035 dockNameMap["minimized"] = DockMinimized;
1036 dockNameMap["unmanaged"] = DockUnmanaged;
1040 if ( dockNameMap.contains( dockName.lower() ) )
1041 res = dockNameMap[dockName.lower()];
1046 Name: dockArea [private]
1050 QDockArea* QtxDockAction::dockArea( const int place ) const
1052 if ( !mainWindow() )
1055 QDockArea* area = 0;
1059 area = mainWindow()->topDock();
1062 area = mainWindow()->bottomDock();
1065 area = mainWindow()->leftDock();
1068 area = mainWindow()->rightDock();
1075 Name: loadGeometry [private]
1079 bool QtxDockAction::loadGeometry( QtxResourceMgr* resMgr, const QString& sec,
1080 const QString& name, GeomInfo& inf ) const
1082 if ( !resMgr || sec.isEmpty() || name.isEmpty() )
1085 QString tmpl = QString( "%1.%2" ).arg( name );
1087 inf.vis = resMgr->booleanValue( sec, tmpl.arg( "visible" ), inf.vis );
1088 inf.newLine = resMgr->booleanValue( sec, tmpl.arg( "new_line" ), inf.newLine );
1090 inf.index = resMgr->integerValue( sec, tmpl.arg( "index" ), inf.index );
1091 inf.offset = resMgr->integerValue( sec, tmpl.arg( "offset" ), inf.offset );
1093 inf.x = resMgr->integerValue( sec, tmpl.arg( "x" ), inf.x );
1094 inf.y = resMgr->integerValue( sec, tmpl.arg( "y" ), inf.y );
1095 inf.w = resMgr->integerValue( sec, tmpl.arg( "width" ), inf.w );
1096 inf.h = resMgr->integerValue( sec, tmpl.arg( "height" ), inf.h );
1098 inf.fixW = resMgr->integerValue( sec, tmpl.arg( "fixed_width" ), inf.fixW );
1099 inf.fixH = resMgr->integerValue( sec, tmpl.arg( "fixed_height" ), inf.fixH );
1102 if ( !resMgr->value( sec, tmpl.arg( "place" ), place ) )
1105 if ( resMgr->value( sec, tmpl.arg( "place" ), placeStr ) )
1106 place = dockPlace( placeStr );
1109 if ( place >= DockUnmanaged && place <= DockMinimized )
1116 Name: saveGeometry [private]
1120 bool QtxDockAction::saveGeometry( QtxResourceMgr* resMgr, const QString& sec,
1121 const QString& name, const GeomInfo& inf ) const
1123 if ( !resMgr || sec.isEmpty() || name.isEmpty() )
1126 QString tmpl = QString( "%1.%2" ).arg( name );
1128 resMgr->setValue( sec, tmpl.arg( "visible" ), inf.vis );
1129 resMgr->setValue( sec, tmpl.arg( "new_line" ), inf.newLine );
1130 resMgr->setValue( sec, tmpl.arg( "index" ), inf.index );
1131 resMgr->setValue( sec, tmpl.arg( "offset" ), inf.offset );
1132 resMgr->setValue( sec, tmpl.arg( "x" ), inf.x );
1133 resMgr->setValue( sec, tmpl.arg( "y" ), inf.y );
1134 resMgr->setValue( sec, tmpl.arg( "width" ), inf.w );
1135 resMgr->setValue( sec, tmpl.arg( "height" ), inf.h );
1136 resMgr->setValue( sec, tmpl.arg( "fixed_width" ), inf.fixW );
1137 resMgr->setValue( sec, tmpl.arg( "fixed_height" ), inf.fixH );
1138 resMgr->setValue( sec, tmpl.arg( "place" ), inf.place );
1144 Name: collectNames [private]
1148 void QtxDockAction::collectNames( const int place, QStringList& lst ) const
1150 QPtrList<QDockWindow> winList;
1151 QDockArea* area = dockArea( place );
1153 winList = area->dockWindowList();
1155 winList = mainWindow()->dockWindows( (Qt::Dock)place );
1157 for ( QPtrListIterator<QDockWindow> it( winList ); it.current(); ++it )
1160 if ( myInfo.contains( it.current() ) )
1161 name = myInfo[it.current()].name;
1162 if ( name.isEmpty() )
1163 name = windowName( it.current() );
1164 if ( name.isEmpty() )