void QtxDockAction::setSeparate( const bool on )
{
+ if ( mySeparate == on )
+ return;
+
mySeparate = on;
+ updateMenus();
}
/*!
return QtxAction::removeFrom( wid );
}
+void QtxDockAction::setMenuText( const QString& txt )
+{
+ if ( menuText() == txt )
+ return;
+
+ QtxAction::setMenuText( txt );
+ updateMenus();
+}
+
/*!
Name: addDockWindow [public]
Desc: Add dock window to internal data structures. Action will be include all added
collectNames( i, that->myNames );
if ( clear )
- resMgr->removeSection( sec );
+ resMgr->remove( sec );
resMgr->setValue( sec, "windows_list", myNames.join( "|" ) );
winList.append( mIt.data() );
QMap<int, DockWinList> winMap;
- QMap<QDockWindow*, GeomInfo> geomMap;
+ QMap<QDockWindow*, GeomInfo*> geomMap;
for ( QPtrListIterator<QDockWindow> it( winList ); it.current(); ++it )
{
if ( !myGeom.contains( name ) )
continue;
- GeomInfo inf( myGeom[name] );
+ //! collect pointer of info to have fresh info data after processEvents();
+ GeomInfo* inf = (GeomInfo*)&( myGeom[name] );
geomMap.insert( it.current(), inf );
- if ( !winMap.contains( inf.place ) )
- winMap.insert( inf.place, DockWinList() );
- winMap[inf.place].append( it.current() );
+ if ( !winMap.contains( inf->place ) )
+ winMap.insert( inf->place, DockWinList() );
+ winMap[inf->place].append( it.current() );
}
loadPlaceArea( DockMinimized, mw, 0,
void QtxDockAction::loadPlaceArea( const int place, QMainWindow* mw, QDockArea* area,
const QPtrList<QDockWindow>& dockList,
- const QMap<QDockWindow*, GeomInfo>& geomMap ) const
+ 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 );
+ GeomInfo* inf = geomMap[it.current()];
+ mw->moveDockWindow( it.current(), (Qt::Dock)place, inf->newLine, inf->index, inf->offset );
}
if ( !area )
if ( !geomMap.contains( dw ) )
continue;
- const GeomInfo& inf = geomMap[dw];
+ GeomInfo* inf = geomMap[dw];
if ( place != DockTornOff )
{
- dw->setNewLine( inf.newLine );
- dw->setOffset( inf.offset );
- dw->setFixedExtentWidth( inf.fixW );
- dw->setFixedExtentHeight( inf.fixH );
+ 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 );
+ dw->setGeometry( inf->x, inf->y, inf->w, inf->h );
- inf.vis ? dw->show() : dw->hide();
+ inf->vis ? dw->show() : dw->hide();
}
QWidget* wid = area;
lst.append( name );
}
}
+
+void QtxDockAction::updateMenus()
+{
+ for ( MenuMap::Iterator it = myMenu.begin(); it != myMenu.end(); ++it )
+ {
+ QPopupMenu* pm = it.key();
+ MenuInfo& inf = it.data();
+
+ int toolId = findId( pm, inf.tool );
+ int dockId = findId( pm, inf.dock );
+
+ int index = pm->indexOf( dockId );
+
+ if ( isSeparate() && !inf.tool )
+ inf.tool = new QPopupMenu( pm );
+
+ pm->removeItem( dockId );
+ pm->removeItem( toolId );
+
+ if ( !isSeparate() && inf.tool )
+ {
+ delete inf.tool;
+ inf.tool = 0;
+ }
+
+ QString dock, tool;
+ splitMenuText( dock, tool );
+
+ if ( inf.dock )
+ iconSet().isNull() ? pm->insertItem ( dock, inf.dock, -1, index ) :
+ pm->insertItem ( iconSet(), dock, inf.dock, -1, index );
+
+ if ( index >= 0 )
+ index++;
+
+ if ( inf.tool )
+ iconSet().isNull() ? pm->insertItem ( tool, inf.tool, -1, index ) :
+ pm->insertItem ( iconSet(), tool, inf.tool, -1, index );
+ }
+}