myMain( mw ),
myAutoAdd( true ),
mySeparate( true ),
-myAutoPlace( true )
+myAutoPlace( false )
{
initialize( mw );
}
myMain( mw ),
myAutoAdd( true ),
mySeparate( true ),
-myAutoPlace( true )
+myAutoPlace( false )
{
initialize( mw );
}
myMain( mw ),
myAutoAdd( true ),
mySeparate( true ),
-myAutoPlace( true )
+myAutoPlace( false )
{
initialize( mw );
}
void QtxDockAction::restoreGeometry( QDockWindow* dw ) const
{
- QPtrList<QDockWindow> dwList;
-
- if ( dw )
- dwList.append( dw );
+ if ( !dw )
+ loadPlaceInfo();
else
- dockWindows( dwList );
-
- for ( QPtrListIterator<QDockWindow> it( dwList ); it.current(); ++it )
- loadPlaceInfo( it.current() );
+ loadPlaceInfo( dw );
}
/*!
if ( !resMgr || sec.isEmpty() )
return;
+ myNames = QStringList::split( "|", resMgr->stringValue( sec, "windows_list", QString::null ) );
+
QMap<QString, int> map;
QStringList params = resMgr->parameters( sec );
for ( QStringList::const_iterator it = params.begin(); it != params.end(); ++it )
if ( !resMgr || sec.isEmpty() )
return;
+ QtxDockAction* that = (QtxDockAction*)this;
+ that->storeGeometry();
+
+ that->myNames.clear();
+ collectNames( Minimized, that->myNames );
+ for ( int i = DockTornOff; i < Minimized; i++ )
+ collectNames( i, that->myNames );
+
if ( clear )
resMgr->removeSection( sec );
+ resMgr->setValue( sec, "windows_list", myNames.join( "|" ) );
+
for ( GeomMap::ConstIterator it = myGeom.begin(); it != myGeom.end(); ++it )
saveGeometry( resMgr, sec, it.key(), it.data() );
}
that->myGeom.insert( myInfo[dw].name, inf );
}
+/*!
+ Name: loadPlaceInfo [private]
+ Desc: Retrieve the stored place and geometry information to all dock windows.
+*/
+
+void QtxDockAction::loadPlaceInfo() const
+{
+ QMainWindow* mw = mainWindow();
+ if ( !mw )
+ return;
+
+ typedef QPtrList<QDockWindow> DockWinList;
+
+ DockWinList lst;
+ dockWindows( lst, mw );
+
+ QMap<QString, QDockWindow*> nameMap;
+ for ( QPtrListIterator<QDockWindow> itr( lst ); itr.current(); ++itr )
+ {
+ QString name;
+ if ( myInfo.contains( itr.current() ) )
+ name = myInfo[itr.current()].name;
+
+ if ( !myGeom.contains( name ) )
+ continue;
+
+ nameMap.insert( name, itr.current() );
+ }
+
+ DockWinList winList;
+ for ( QStringList::const_iterator iter = myNames.begin(); iter != myNames.end(); ++iter )
+ {
+ if ( nameMap.contains( *iter ) )
+ winList.append( nameMap[*iter] );
+ nameMap.remove( *iter );
+ }
+
+ for ( QMap<QString, QDockWindow*>::ConstIterator mIt = nameMap.begin(); mIt != nameMap.end(); ++mIt )
+ winList.append( mIt.data() );
+
+ QMap<int, DockWinList> winMap;
+ QMap<QDockWindow*, GeomInfo> geomMap;
+
+ for ( QPtrListIterator<QDockWindow> it( winList ); it.current(); ++it )
+ {
+ QString name;
+ if ( myInfo.contains( it.current() ) )
+ name = myInfo[it.current()].name;
+
+ if ( !myGeom.contains( name ) )
+ continue;
+
+ GeomInfo inf( myGeom[name] );
+ geomMap.insert( it.current(), inf );
+ if ( !winMap.contains( inf.place ) )
+ winMap.insert( inf.place, DockWinList() );
+ winMap[inf.place].append( it.current() );
+ }
+
+ loadPlaceArea( DockMinimized, mw, 0,
+ winMap.contains( DockMinimized ) ? winMap[DockMinimized] : DockWinList(), geomMap );
+ for ( int i = DockTornOff; i < DockMinimized; i++ )
+ {
+ loadPlaceArea( i, mw, dockArea( i ), winMap.contains( i ) ? winMap[i] : DockWinList(), geomMap );
+ }
+}
+
+/*!
+ Name: loadPlaceArea [private]
+ Desc: Set the place and geometry information to all dock windows in the area.
+*/
+
+void QtxDockAction::loadPlaceArea( const int place, QMainWindow* mw, QDockArea* area,
+ const QPtrList<QDockWindow>& dockList,
+ const QMap<QDockWindow*, GeomInfo>& geomMap ) const
+{
+ for ( QPtrListIterator<QDockWindow> it( dockList ); it.current(); ++it )
+ {
+ if ( !geomMap.contains( it.current() ) )
+ continue;
+
+ const GeomInfo& inf = geomMap[it.current()];
+ mw->moveDockWindow( it.current(), (Qt::Dock)place, inf.newLine, inf.index, inf.offset );
+ }
+
+ if ( !area )
+ return;
+
+ for ( QPtrListIterator<QDockWindow> itr( dockList ); itr.current(); ++itr )
+ {
+ QDockWindow* dw = itr.current();
+ if ( !geomMap.contains( dw ) )
+ continue;
+
+ const GeomInfo& inf = geomMap[dw];
+ if ( place != DockTornOff )
+ {
+ dw->setNewLine( inf.newLine );
+ dw->setOffset( inf.offset );
+ dw->setFixedExtentWidth( inf.fixW );
+ dw->setFixedExtentHeight( inf.fixH );
+ }
+ dw->setGeometry( inf.x, inf.y, inf.w, inf.h );
+
+ inf.vis ? dw->show() : dw->hide();
+ }
+
+ QWidget* wid = area;
+ if ( wid->layout() )
+ {
+ wid->layout()->invalidate();
+ wid->layout()->activate();
+ }
+}
+
/*!
Name: action [private]
Desc: Returns action for the given dock window.
return res;
}
+/*!
+ Name: dockArea [private]
+ Desc:
+*/
+
+QDockArea* QtxDockAction::dockArea( const int place ) const
+{
+ if ( !mainWindow() )
+ return 0;
+
+ QDockArea* area = 0;
+ switch ( place )
+ {
+ case DockTop:
+ area = mainWindow()->topDock();
+ break;
+ case DockBottom:
+ area = mainWindow()->bottomDock();
+ break;
+ case DockLeft:
+ area = mainWindow()->leftDock();
+ break;
+ case DockRight:
+ area = mainWindow()->rightDock();
+ break;
+ }
+ return area;
+}
+
+/*!
+ Name: loadGeometry [private]
+ Desc:
+*/
+
bool QtxDockAction::loadGeometry( QtxResourceMgr* resMgr, const QString& sec,
const QString& name, GeomInfo& inf ) const
{
return true;
}
+/*!
+ Name: saveGeometry [private]
+ Desc:
+*/
+
bool QtxDockAction::saveGeometry( QtxResourceMgr* resMgr, const QString& sec,
const QString& name, const GeomInfo& inf ) const
{
return true;
}
+
+/*!
+ Name: collectNames [private]
+ Desc:
+*/
+
+void QtxDockAction::collectNames( const int place, QStringList& lst ) const
+{
+ QPtrList<QDockWindow> winList;
+ QDockArea* area = dockArea( place );
+ if ( area )
+ winList = area->dockWindowList();
+ else
+ winList = mainWindow()->dockWindows( (Qt::Dock)place );
+
+ for ( QPtrListIterator<QDockWindow> it( winList ); it.current(); ++it )
+ {
+ QString name;
+ if ( myInfo.contains( it.current() ) )
+ name = myInfo[it.current()].name;
+ if ( name.isEmpty() )
+ name = windowName( it.current() );
+ if ( name.isEmpty() )
+ continue;
+
+ lst.append( name );
+ }
+}
#include <qpopupmenu.h>
class QAction;
-class QMainWindow;
+class QDockArea;
class QDockWindow;
+class QMainWindow;
class QtxResourceMgr;
#ifdef WIN32
QString windowName( QDockWindow* ) const;
void savePlaceInfo( QDockWindow* );
void loadPlaceInfo( QDockWindow* ) const;
+ void loadPlaceInfo() const;
bool autoAddDockWindow( QDockWindow* );
void autoLoadPlaceInfo( QDockWindow* );
void splitMenuText( QString&, QString& ) const;
QStringList splitText( const QString&, const QString& ) const;
+ QDockArea* dockArea( const int ) const;
int dockPlace( const QString& ) const;
+ void collectNames( const int, QStringList& ) const;
+
private:
- enum { AutoAdd = QEvent::User };
+ enum { AutoAdd = QEvent::User, LoadArea };
typedef struct { bool vis, newLine;
int place, index, offset;
const QString&, GeomInfo& ) const;
bool saveGeometry( QtxResourceMgr*, const QString&,
const QString&, const GeomInfo& ) const;
+ void loadPlaceArea( const int, QMainWindow*, QDockArea*,
+ const QPtrList<QDockWindow>&,
+ const QMap<QDockWindow*, GeomInfo>& ) const;
private:
InfoMap myInfo;
MenuMap myMenu;
GeomMap myGeom;
QMainWindow* myMain;
+ QStringList myNames;
bool myAutoAdd;
bool mySeparate;