static void clearAlignList( QStrList &l ) { if ( l.count() == 1 ) return; if ( l.find( "AlignAuto" ) != -1 ) l.remove( "AlignAuto" ); if ( l.find( "WordBreak" ) != -1 ) l.remove( "WordBreak" ); }
void MetaDataBase::doConnections( QObject *o ) { setupDataBase(); MetaDataBaseRecord *r = db->find( (void*)o ); if ( !r ) { qWarning( "No entry for %p (%s, %s) found in MetaDataBase", o, o->name(), o->className() ); return; } QObject *sender = 0, *receiver = 0; QObjectList *l = 0; QValueList<Connection>::Iterator it = r->connections.begin(); for ( ; it != r->connections.end(); ++it ) { Connection conn = *it; if ( qstrcmp( conn.sender->name(), o->name() ) == 0 ) { sender = o; } else { l = o->queryList( 0, conn.sender->name(), false ); if ( !l || !l->first() ) { delete l; continue; } sender = l->first(); delete l; } if ( qstrcmp( conn.receiver->name(), o->name() ) == 0 ) { receiver = o; } else { l = o->queryList( 0, conn.receiver->name(), false ); if ( !l || !l->first() ) { delete l; continue; } receiver = l->first(); delete l; } QString s = "2""%1"; s = s.arg( conn.signal ); QString s2 = "1""%1"; s2 = s2.arg( conn.slot ); QStrList signalList = sender->metaObject()->signalNames( true ); QStrList slotList = receiver->metaObject()->slotNames( true ); // avoid warnings if ( signalList.find( conn.signal ) == -1 || slotList.find( conn.slot ) == -1 ) continue; QObject::connect( sender, s, receiver, s2 ); } }
void QSPixmapClass::save( QSEnv *env ) { if ( env->numArgs() < 1 || env->numArgs() > 2 ) { env->throwError( QString::fromLatin1( "Pixmap.save() called with %1 arguments. 1 or 2 argument expected." ). arg( env->numArgs() ) ); return; } QSObject t = env->thisValue(); QSPixmapClass *pac = (QSPixmapClass*)t.objectType(); QPixmap *pix = pac->pixmap( &t ); if ( !env->arg( 0 ).isString() ) { env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. " "Type String is expeced" ). arg( env->arg( 0 ).typeName() ) ); return; } QString format = QFileInfo( env->arg( 0 ).toString() ).extension().upper(); QStrList l = QImageIO::outputFormats(); if ( l.find( format.latin1() ) == -1 ) format = QString::fromLatin1("PNG"); if ( env->numArgs() == 2 ) { if ( !env->arg( 1 ).isString() ) { env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. " "as second argument. Type String is expeced" ). arg( env->arg( 1 ).typeName() ) ); return; } format = env->arg( 1 ).toString(); } pix->save( env->arg( 0 ).toString(), format.latin1() ); }
bool MetaDataBase::hasSlot( QObject *o, const QCString &slot, bool onlyCustom ) { setupDataBase(); MetaDataBaseRecord *r = db->find( (void*)o ); if ( !r ) { qWarning( "No entry for %p (%s, %s) found in MetaDataBase", o, o->name(), o->className() ); return false; } if ( !onlyCustom ) { QStrList slotList = o->metaObject()->slotNames( true ); if ( slotList.find( slot ) != -1 ) return true; if ( o->inherits( "FormWindow" ) ) { o = ( (FormWindow*)o )->mainContainer(); slotList = o->metaObject()->slotNames( true ); if ( slotList.find( slot ) != -1 ) return true; } if ( o->inherits( "CustomWidget" ) ) { MetaDataBase::CustomWidget *w = ( (::CustomWidget*)o )->customWidget(); for ( QValueList<Slot>::Iterator it = w->lstSlots.begin(); it != w->lstSlots.end(); ++it ) { QCString s = (*it).slot; if ( !s.data() ) continue; if ( s == slot ) return true; } } } for ( QValueList<Slot>::Iterator it = r->slotList.begin(); it != r->slotList.end(); ++it ) { Slot s = *it; if ( normalizeSlot( s.slot ) == normalizeSlot( slot ) ) return true; } return false; }
bool MetaDataBase::CustomWidget::hasSignal( const QCString &signal ) const { QStrList sigList = QWidget::staticMetaObject()->signalNames( true ); if ( sigList.find( signal ) != -1 ) return true; for ( QValueList<QCString>::ConstIterator it = lstSignals.begin(); it != lstSignals.end(); ++it ) { if ( normalizeSlot( *it ) == normalizeSlot( signal ) ) return true; } return false; }
bool MetaDataBase::CustomWidget::hasProperty( const QCString &prop ) const { QStrList propList = QWidget::staticMetaObject()->propertyNames( true ); if ( propList.find( prop ) != -1 ) return true; for ( QValueList<MetaDataBase::Property>::ConstIterator it = lstProperties.begin(); it != lstProperties.end(); ++it ) { if ( (*it).property == prop ) return true; } return false; }
bool MetaDataBase::CustomWidget::hasSlot( const QCString &slot ) const { QStrList slotList = QWidget::staticMetaObject()->slotNames( true ); if ( slotList.find( normalizeSlot( slot ) ) != -1 ) return true; for ( QValueList<MetaDataBase::Slot>::ConstIterator it = lstSlots.begin(); it != lstSlots.end(); ++it ) { if ( normalizeSlot( (*it).slot ) == normalizeSlot( slot ) ) return true; } return false; }
bool KHost::WriteConfig() { KConfig *config = ((KConnection*) topLevelWidget())->GetConfig(); QStrList List; const char *Value; int i; if (config == NULL) return FALSE; hostChanged(0); portChanged(0); config->setGroup(KI_SEC_HOSTS); if ((Value = hostCombo->currentText()) != NULL && *Value != '\0' && List.find(Value) == -1) List.append(Value); for (i = 0; i < hostCombo->count(); i++) if (List.find(hostCombo->text(i)) == -1) List.append(hostCombo->text(i)); config->writeEntry(KI_ENT_HOSTS,List); List.clear(); if ((Value = portCombo->currentText()) != NULL && *Value != '\0' && List.find(Value) == -1) List.append(Value); for (i = 0; i < portCombo->count(); i++) if (List.find(portCombo->text(i)) == -1) List.append(portCombo->text(i)); config->writeEntry(KI_ENT_PORTS,List); config->writeEntry(KI_ENT_LAST_HOST,hostCombo->currentText()); config->writeEntry(KI_ENT_LAST_PORT,portCombo->currentText()); return TRUE; }
void Rule::save(const char *name) { ruleFile->setGroup("Index"); QStrList names; ruleFile->readListEntry("RuleNames",names); if (names.find(name)==-1) { names.append(name); ruleFile->writeEntry("RuleNames",names); } ruleFile->setGroup(name); ruleFile->writeEntry("Name",name); ruleFile->writeEntry("Regexp",regex.pattern()); ruleFile->writeEntry("Field",field); ruleFile->writeEntry("WildCard",regex.wildcard()); ruleFile->writeEntry("CaseSensitive",regex.caseSensitive()); ruleFile->writeEntry("Value",value); ruleFile->sync(); }
void EditFunctions::okClicked() { QValueList<MetaDataBase::Function> functionList = MetaDataBase::functionList( formWindow ); QString n = tr( "Add/Remove functions of '%1'" ).arg( formWindow->name() ); QPtrList<Command> commands; QValueList<MetaDataBase::Function>::Iterator fit; if ( !functionList.isEmpty() ) { for ( fit = functionList.begin(); fit != functionList.end(); ++fit ) { bool functionFound = FALSE; QValueList<FunctItem>::Iterator it = functList.begin(); for ( ; it != functList.end(); ++it ) { if ( MetaDataBase::normalizeFunction( (*it).oldName ) == MetaDataBase::normalizeFunction( (*fit).function ) ) { functionFound = TRUE; break; } } if ( !functionFound ) commands.append( new RemoveFunctionCommand( tr( "Remove function" ), formWindow, (*fit).function, (*fit).specifier, (*fit).access, (*fit).type, formWindow->project()->language(), (*fit).returnType ) ); } } bool invalidFunctions = FALSE; QValueList<FunctItem> invalidItems; if ( !functList.isEmpty() ) { QStrList lst; QValueList<FunctItem>::Iterator it = functList.begin(); for ( ; it != functList.end(); ++it ) { MetaDataBase::Function function; function.function = (*it).newName; function.returnType = (*it).retTyp; function.specifier = (*it).spec; function.access = (*it).access; function.type = (*it).type; function.language = formWindow->project()->language(); if ( function.returnType.isEmpty() ) function.returnType = "void"; QString s = function.function; s = s.simplifyWhiteSpace(); bool startNum = s[ 0 ] >= '0' && s[ 0 ] <= '9'; bool noParens = s.contains( '(' ) != 1 || s.contains( ')' ) != 1; bool illegalSpace = s.find( ' ' ) != -1 && s.find( ' ' ) < s.find( '(' ); if ( startNum || noParens || illegalSpace || lst.find( function.function ) != -1 ) { invalidFunctions = TRUE; invalidItems.append( (*it) ); continue; } bool functionFound = FALSE; for ( fit = functionList.begin(); fit != functionList.end(); ++fit ) { if ( MetaDataBase::normalizeFunction( (*fit).function ) == MetaDataBase::normalizeFunction( (*it).oldName ) ) { functionFound = TRUE; break; } } if ( !functionFound ) commands.append( new AddFunctionCommand( tr( "Add function" ), formWindow, function.function, function.specifier, function.access, function.type, formWindow->project()->language(), function.returnType ) ); if ( MetaDataBase::normalizeFunction( (*it).newName ) != MetaDataBase::normalizeFunction( (*it).oldName ) || (*it).spec != (*it).oldSpec || (*it).access != (*it).oldAccess || (*it).type != (*it).oldType || (*it).retTyp != (*it).oldRetTyp ) { QString normalizedOldName = MetaDataBase::normalizeFunction( (*it).oldName ); if ((*it).oldName.endsWith("const")) // make sure we get the 'const' when we remove the old name normalizedOldName += " const"; commands.append( new ChangeFunctionAttribCommand( tr( "Change function attributes" ), formWindow, function, normalizedOldName, (*it).oldSpec, (*it).oldAccess, (*it).oldType, formWindow->project()->language(), (*it).oldRetTyp ) ); } lst.append( function.function ); } } if ( invalidFunctions ) { if ( QMessageBox::information( this, tr( "Edit Functions" ), tr( "Some syntactically incorrect functions have been defined.\n" "Remove these functions?" ), tr( "&Yes" ), tr( "&No" ) ) == 0 ) { QValueList<FunctItem>::Iterator it = functList.begin(); while ( it != functList.end() ) { bool found = FALSE; QValueList<FunctItem>::Iterator vit = invalidItems.begin(); for ( ; vit != invalidItems.end(); ++vit ) { if ( (*vit).newName == (*it).newName ) { invalidItems.remove( vit ); found = TRUE; break; } } if ( found ) { int delId = (*it).id; it = functList.remove( it ); QMap<QListViewItem*, int>::Iterator fit = functionIds.begin(); while ( fit != functionIds.end() ) { if ( *fit == delId ) { QListViewItem *litem = fit.key(); functionIds.remove( fit ); delete litem; if ( functionListView->currentItem() ) functionListView->setSelected( functionListView->currentItem(), TRUE ); currentItemChanged( functionListView->currentItem() ); break; } ++fit; } } else ++it; } if ( functionListView->firstChild() ) { functionListView->setCurrentItem( functionListView->firstChild() ); functionListView->setSelected( functionListView->firstChild(), TRUE ); } } formWindow->mainWindow()->objectHierarchy()->updateFormDefinitionView(); return; } if ( !commands.isEmpty() ) { MacroCommand *cmd = new MacroCommand( n, formWindow, commands ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); } formWindow->mainWindow()->objectHierarchy()->updateFormDefinitionView(); accept(); }