#include <qpopupmenu.h>
+//================================================================
+// Function :
+// Purpose :
+//================================================================
+QtxValue QtxPopupMgr::Selection::globalParam( const QString& str ) const
+{
+ if( str==selCountParam() )
+ return count();
+
+ else if( str[0]==equality() )
+ {
+ QtxSets::ValueSet set;
+ QString par = str.mid( 1 );
+
+ for( int i=0, n=count(); i<n; i++ )
+ {
+ QtxValue v = param( i, par );
+ if( v.isValid() )
+ QtxSets::add( set, v );
+ else
+ return QtxValue();
+ }
+ return set;
+ }
+
+ else
+ return QtxValue();
+}
+
+//================================================================
+// Function :
+// Purpose :
+//================================================================
+QChar QtxPopupMgr::Selection::equality() const
+{
+ return defEquality();
+}
+
+//================================================================
+// Function :
+// Purpose :
+//================================================================
+QString QtxPopupMgr::Selection::selCountParam() const
+{
+ return defSelCountParam();
+}
+
+//================================================================
+// Function :
+// Purpose :
+//================================================================
+QChar QtxPopupMgr::Selection::defEquality()
+{
+ return '$';
+}
+
+//================================================================
+// Function :
+// Purpose :
+//================================================================
+QString QtxPopupMgr::Selection::defSelCountParam()
+{
+ return "selcount";
+}
+
+
+
+
//================================================================
// Function :
// Purpose :
// Purpose :
//================================================================
QtxPopupMgr::QtxPopupMgr( QPopupMenu* popup, QObject* parent )
-: QtxActionMenuMgr( popup, parent )
+: QtxActionMenuMgr( popup, parent ),
+ myCurrentSelection( 0 )
{
createOperations();
}
//================================================================
void QtxPopupMgr::setParams( QtxParser* p, QStringList& specific ) const
{
- if( !p )
+ if( !p || !myCurrentSelection )
return;
QStringList params;
QStringList::const_iterator anIt = params.begin(),
aLast = params.end();
for( ; anIt!=aLast; anIt++ )
-
- if( *anIt==selCountParam() )
- {
- if( myCurrentSelection )
- p->set( *anIt, myCurrentSelection->count() );
- else
- p->set( *anIt, 0 );
- }
-
- else if( (*anIt)[0]==equality() )
- {
- QtxSets::ValueSet set;
- QString par = ( *anIt ).mid( 1 );
-
- if( myCurrentSelection && myCurrentSelection->count() > 0 )
- for( int i=0, n=myCurrentSelection->count(); i<n; i++ )
- QtxSets::add( set, myCurrentSelection->param( i, par ) );
-
- p->set( *anIt, set );
- }
- else
- specific.append( *anIt );
+ {
+ QtxValue v = myCurrentSelection->globalParam( *anIt );
+ if( v.isValid() )
+ p->set( *anIt, v );
+ else
+ specific.append( *anIt );
+ }
}
//================================================================
//================================================================
void QtxPopupMgr::updatePopup( QPopupMenu* p, Selection* sel )
{
- if( !p )
+ if( !p || !sel )
return;
myCurrentSelection = sel;
return ( RulesMap& )( visibility ? myVisibility : myToggle );
}
-//================================================================
-// Function :
-// Purpose :
-//================================================================
-QString QtxPopupMgr::selCountParam() const
-{
- return "selcount";
-}
-
-//================================================================
-// Function :
-// Purpose :
-//================================================================
-QChar QtxPopupMgr::equality() const
-{
- return '$';
-}
-
//================================================================
// Function :
// Purpose :