if ( !w )
return;
- if ( !w->inherits( "QPopupMenu" ) && !w->inherits( "QMenuBar" ) )
- return; // unsupported widget type
+ QMenuData* pmd = 0;
+
+ if ( w->inherits( "QPopupMenu" ) )
+ pmd = ::qt_cast<QPopupMenu*>( w );
+ else if ( w->inherits( "QMenuBar" ) )
+ pmd = ::qt_cast<QMenuBar*>( w );
- QMenuData* md = 0;
- QMenuData* pmd = dynamic_cast<QMenuData*>( w );
if ( !pmd )
return; // bad widget
-
+
+ QMenuData* md = 0;
QMenuItem* item = pmd->findItem( id, &md );
if ( !item || md != pmd )
return; // item is not found
QValueList<int> l;
const QMenuData* md = 0;
if ( w->inherits( "QMenuBar" ) )
- md = dynamic_cast<const QMenuData*>( w );
+ md = ::qt_cast<QMenuBar*>( w );
else if ( w->inherits( "QPopupMenu" ) )
- md = dynamic_cast<const QMenuData*>( w );
+ md = ::qt_cast<QPopupMenu*>( w );
if ( md ) {
- for ( int i=0; i < md->count(); i++ )
- l.append( md->idAt( i ) );
+ for ( uint i = 0; i < md->count(); i++ )
+ l.append( md->idAt( i ) );
}
return l;
}
{
const QMenuData* md = 0;
if ( w->inherits( "QMenuBar" ) )
- md = dynamic_cast<const QMenuData*>( w );
+ md = ::qt_cast<QMenuBar*>( w );
else if ( w->inherits( "QPopupMenu" ) )
- md = dynamic_cast<const QMenuData*>( w );
- if ( md ) {
- for ( int i=0, j=0; i < md->count() && j < l.count(); i++, j++ )
- if ( md->idAt( i ) != l[ j ] ) return retId ? md->idAt( i ) : i;
- if ( md->count() > l.count() ) return retId ? md->idAt( md->count()-1 ) : md->count()-1;
+ md = ::qt_cast<QPopupMenu*>( w );
+ if ( md )
+ {
+ for ( uint i = 0, j = 0; i < md->count() && j < l.count(); i++, j++ )
+ if ( md->idAt( i ) != l[ j ] )
+ return retId ? md->idAt( i ) : i;
+ if ( md->count() > l.count() )
+ return retId ? md->idAt( md->count()-1 ) : md->count() - 1;
}
return -1;
}
void dumpMenu( QWidget* w, bool before )
{
- QMenuData* md = dynamic_cast<QMenuData*>( w );
- if ( !w ) return;
- printf(">>> start dump menu (%s) >>>\n", before ? "before" : "after" );
- for( int i = 0; i < md->count(); i++ )
- printf("%d: %d: %s\n",i,md->idAt(i),md->text(md->idAt(i)).latin1() );
- printf("<<< end dump menu (%s) <<<\n", before ? "before" : "after" );
+ if ( !w )
+ return;
+
+ QMenuData* md = 0;
+ if ( w->inherits( "QMenuBar" ) )
+ md = ::qt_cast<QMenuBar*>( w );
+ else if ( w->inherits( "QPopupMenu" ) )
+ md = ::qt_cast<QPopupMenu*>( w );
+
+ if ( !md )
+ return;
+
+ printf( ">>> start dump menu (%s) >>>\n", before ? "before" : "after" );
+ for ( uint i = 0; i < md->count(); i++ )
+ printf( "%d: %d: %s\n", i, md->idAt( i ), md->text( md->idAt( i ) ).latin1() );
+ printf( "<<< end dump menu (%s) <<<\n", before ? "before" : "after" );
}
};
{
NodeList& lst = idMap[it2.current()->group];
int idx = it2.current()->idx;
- if ( idx < 0 || idx >= lst.count() )
+ if ( idx < 0 || idx >= (int)lst.count() )
lst.append( it2.current() );
else
lst.insert( idx, it2.current() );
*/
void QtxWorkstack::onContextMenuRequested( QWidget* w, QPoint p )
{
- QtxWorkstackArea* anArea = dynamic_cast<QtxWorkstackArea*>( (QObject*)sender() );
+ QtxWorkstackArea* anArea = ::qt_cast<QtxWorkstackArea*>( (QObject*)sender() );
if ( !anArea )
anArea = activeArea();
int i = 1,
nOpen = 1, // count brackets: '(' increments nOpen, ')' decrements
start = 0;
- while ( i < str.length() ) {
- if ( str[i] == '(' ) {
+ while ( i < (int)str.length() )
+ {
+ if ( str[i] == '(' )
+ {
nOpen++;
if ( nOpen == 1 )
- start = i;
+ start = i;
}
- else if ( str[i] == ')' ) {
+ else if ( str[i] == ')' )
+ {
nOpen--;
if ( nOpen == 0 )
- lst.append( str.mid( start, i-start+1 ) );
+ lst.append( str.mid( start, i-start+1 ) );
}
i++;
}
QWidget* view = 0;
QObjectList *l = parent->topLevelWidget()->queryList( "QWidget", aName, false, true );
if ( !l->isEmpty() )
- view = dynamic_cast<QWidget*>( l->first() );
+ view = ::qt_cast<QWidget*>( l->first() );
delete l;
return view;
}