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
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 );
+ }
+}
virtual bool addTo( QWidget* );
virtual bool addTo( QWidget*, const int );
virtual bool removeFrom( QWidget* );
+ virtual void setMenuText( const QString& );
bool addDockWindow( QDockWindow* );
bool removeDockWindow( QDockWindow* );
void collectNames( const int, QStringList& ) const;
+ void updateMenus();
+
private:
enum { AutoAdd = QEvent::User, LoadArea };