QString menu = act->menuText();
bool res = false;
- if( !act )
+ if ( !act )
return res;
- if( hasRule( act, visibility ) )
+ if ( hasRule( act, visibility ) )
{
QtxParser* p = map( visibility )[ act ];
QStringList specific;
p->clear();
- ( ( Operations* )myOperations->operations( "custom" ) )->clear();
+ ((Operations*)myOperations->operations( "custom" ))->clear();
setParams( p, specific );
QMap<QValueList<QtxValue>,int> aCorteges;
QValueList<QtxValue> c;
- if( specific.count()>0 )
- if( myCurrentSelection )
+ if ( specific.count() )
+ {
+ if ( myCurrentSelection )
{
- res = false;
-
- for( int i=0, n=myCurrentSelection->count(); i<n && !res; i++ )
- {
- QStringList::const_iterator anIt1 = specific.begin(), aLast1 = specific.end();
- c.clear();
- for( ; anIt1!=aLast1; anIt1++ )
- c.append( myCurrentSelection->param( i, *anIt1 ) );
- aCorteges.insert( c, 0 );
- }
+ res = false;
+ if ( myCurrentSelection->count() )
+ {
+ for( int i = 0, n = myCurrentSelection->count(); i < n && !res; i++ )
+ {
+ c.clear();
+ for ( QStringList::const_iterator anIt1 = specific.begin(); anIt1 != specific.end(); anIt1++ )
+ c.append( myCurrentSelection->param( i, *anIt1 ) );
+ aCorteges.insert( c, 0 );
+ }
+ }
+ else
+ {
+ for ( QStringList::const_iterator anIt1 = specific.begin(); anIt1 != specific.end(); anIt1++ )
+ c.append( QtxValue() );
+ aCorteges.insert( c, 0 );
+ }
- //qDebug( QString( "%1 corteges" ).arg( aCorteges.count() ) );
- QMap<QValueList<QtxValue>,int>::const_iterator anIt = aCorteges.begin(), aLast = aCorteges.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QStringList::const_iterator anIt1 = specific.begin(), aLast1 = specific.end();
- const QValueList<QtxValue>& aCortege = anIt.key();
- QValueList<QtxValue>::const_iterator anIt2 = aCortege.begin();
- for( ; anIt1!=aLast1; anIt1++, anIt2++ )
- p->set( *anIt1, *anIt2 );
- res = res || result( p );
- }
+ //qDebug( QString( "%1 corteges" ).arg( aCorteges.count() ) );
+ for ( QMap<QValueList<QtxValue>,int>::const_iterator anIt = aCorteges.begin(); anIt != aCorteges.end(); anIt++ )
+ {
+ QStringList::const_iterator anIt1 = specific.begin(), aLast1 = specific.end();
+ const QValueList<QtxValue>& aCortege = anIt.key();
+ QValueList<QtxValue>::const_iterator anIt2 = aCortege.begin();
+ for ( ; anIt1 != aLast1; anIt1++, anIt2++ )
+ p->set( *anIt1, *anIt2 );
+ res = res || result( p );
+ }
/*
for( int i=0, n=myCurrentSelection->count(); i<n && !res; i++ )
}*/
}
else
- res = false;
+ res = false;
+ }
else
res = result( p );
}
if( !p || !sel )
return;
- myCurrentSelection = new QtxCacheSelection( sel );
- RulesMap::iterator anIt = myToggle.begin(),
- aLast = myToggle.end();
- for( ; anIt!=aLast; anIt++ )
- if( anIt.key()->isToggleAction() && hasRule( anIt.key(), false ) )
+ setSelection( sel );
+
+ for ( RulesMap::iterator anIt = myToggle.begin(); anIt != myToggle.end(); anIt++ )
+ {
+ if ( anIt.key()->isToggleAction() && hasRule( anIt.key(), false ) )
anIt.key()->setOn( isSatisfied( anIt.key(), false ) );
+ }
setWidget( ( QWidget* )p );
+
updateMenu();
+
QTime t2 = QTime::currentTime();
qDebug( QString( "update popup time = %1 msecs" ).arg( t1.msecsTo( t2 ) ) );
qDebug( QString( "number of objects = %1" ).arg( myCurrentSelection->count() ) );
+ setSelection( 0 );
+}
+
+void QtxPopupMgr::setSelection( Selection* s )
+{
+ if ( myCurrentSelection == s )
+ return;
+
delete myCurrentSelection;
+ myCurrentSelection = 0;
+
+ if ( s )
+ myCurrentSelection = new QtxCacheSelection( s );
}
//================================================================