// checks the given value for the integer value [ static ]
// returns -1 if item is empty or presents and invalid number
-static int checkInt( const QString& value, const int def = -1 )
+static int checkInt( const QString& value, const int def = -1, const int shift = -1 )
{
- return value.isEmpty() ? def : value.toInt();
+ bool bOk;
+ int val = value.toInt( &bOk );
+ if ( !bOk ) val = def;
+ if ( shift > 0 && bOk && val < 0 )
+ val += shift;
+ return val;
}
/*!
if ( mi ) popup = mi->popup();
if ( !popup ) {
popup = new QPopupMenu( desktop );
+ ppos = checkInt( attribute( parentElement, "pos-id" ), -1, mb->count() );
menuId = mb->insertItem( plabel, popup, pid, ppos );
myCurrentMenu.push_back( QString::number( menuId ) );
myMenuItems.append( myCurrentMenu.join( ":" ) );
if ( mi ) popup = mi->popup();
if ( !popup ) {
popup = new QPopupMenu( desktop );
+ ppos = checkInt( attribute( parentElement, "pos-id" ), -1, popup->count() );
menuId = parentPopup->insertItem( plabel, popup, pid, ppos );
myCurrentMenu.push_back( QString::number( menuId ) );
myMenuItems.append( myCurrentMenu.join( ":" ) );
if ( id != -1 ) {
if ( IsCallOldMethods ) { // __CALL_OLD_METHODS__
QIconSet iconSet = myModule->loadIcon( icon );
+ pos = checkInt( attribute( elem, "pos-id" ), -1, popup->count() );
int aid = iconSet.isNull() ? popup->insertItem( label,
myModule,
SLOT( onGUIEvent(int) ),
int group = checkInt( attribute( elem, "group-id" ),
myModule->defaultMenuGroup() );
if ( IsCallOldMethods ) { // __CALL_OLD_METHODS__
+ pos = checkInt( attribute( elem, "pos-id" ), -1, popup->count() );
int sid = popup->insertSeparator( pos );
myCurrentMenu.push_back( QString::number( sid ) );
myMenuItems.append( myCurrentMenu.join( ":" ) );