void KMouthApp::slotFileQuit() { slotStatusMsg(i18nc("Shutting down the application", "Exiting...")); saveOptions(); // close the first window, the list makes the next one the first again. // This ensures that queryClose() is called on each window to ask for closing KMainWindow* w; if (!memberList().isEmpty()) { for (int i = 0; i < memberList().size(); ++i) { // only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog, // the window and the application stay open. w = memberList().at(i); if (!w->close()) break; #ifdef __GNUC__ #warning "kde4: how remove it ?.???" #endif //memberList()->removeRef(w); } } }
bool ConnectionModel::setData(const QModelIndex &index, const QVariant &data, int) { if (!index.isValid()) return false; if (data.type() != QVariant::String) return false; SignalSlotConnection *con = static_cast<SignalSlotConnection*>(m_editor->connection(index.row())); QDesignerFormWindowInterface *form = m_editor->formWindow(); QString s = data.toString(); switch (index.column()) { case 0: { if (!s.isEmpty() && !objectNameList(form).contains(s)) s.clear(); m_editor->setSource(con, s); break; } case 1: { if (!memberList(form, con->object(CETypes::EndPoint::Source), SignalMember).contains(s)) s.clear(); m_editor->setSignal(con, s); break; } case 2: { if (!s.isEmpty() && !objectNameList(form).contains(s)) s.clear(); m_editor->setTarget(con, s); break; } case 3: { if (!memberList(form, con->object(CETypes::EndPoint::Target), SlotMember).contains(s)) s.clear(); m_editor->setSlot(con, s); break; } } return true; }
void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) const { const int guildId = msg.readInt32(); const int emblem = msg.readInt32(); const int posMode = msg.readInt32(); msg.readInt32(); // Unused msg.readInt8(); // Unused std::string guildName = msg.readString(24); Guild *const g = Guild::getGuild(static_cast<int16_t>(guildId)); if (!g) return; g->setName(guildName); g->setEmblemId(emblem); if (!taGuild) taGuild = g; if (!guildTab && chatWindow) { guildTab = new GuildTab(chatWindow); if (config.getBoolValue("showChatHistory")) guildTab->loadFromLogFile("#Guild"); if (player_node) player_node->addGuild(taGuild); memberList(guildId); } if (player_node) { player_node->setGuild(g); player_node->setGuildName(g->getName()); } logger->log("Guild position info: %d %d %d %s\n", guildId, emblem, posMode, guildName.c_str()); }
void RubySupportPart::parse(const QString &fileName) { QFile f(QFile::encodeName(fileName)); if (!f.open(IO_ReadOnly)) return; QTextStream stream(&f); QRegExp classre("^\\s*(class|module)\\s+([A-Z][A-Za-z0-9_]+::)*([A-Z][A-Za-z0-9_]+)\\s*(<\\s*([A-Z][A-Za-z0-9_:]+))?$"); QRegExp methodre("^(\\s*)def\\s+(([A-Z][A-Za-z0-9_:]+|self)\\.)?([A-Za-z0-9_]+[!?=]?|\\[\\]=?|\\*\\*||\\-|[!~+*/%&|><^]|>>|<<||<=>|<=|>=|==|===|!=|=~|!~).*$"); QRegExp accessre("^\\s*(private|protected|public)\\s*((:([A-Za-z0-9_]+[!?=]?|\\[\\]=?|\\*\\*||\\-|[!~+*/%&|><^]|>>|<<||<=>|<=|>=|==|===|!=|=~|!~),?\\s*)*)$"); QRegExp attr_accessorre("^\\s*(attr_accessor|attr_reader|attr_writer)\\s*((:([A-Za-z0-9_]+),?\\s*)*)$"); QRegExp symbolre(":([^,]+),?"); QRegExp line_contre(",\\s*$"); QRegExp slot_signalre("^\\s*(slots|signals|k_dcop|k_dcop_signals)\\s*(('[^)]+\\)',?\\s*)*)$"); QRegExp memberre("'([A-Za-z0-9_ &*]+\\s)?([A-Za-z0-9_]+)\\([^)]*\\)',?"); QRegExp begin_commentre("^*=begin"); QRegExp end_commentre("^*=end"); QRegExp variablere("(@@?[A-Za-z0-9_]+)\\s*=\\s*((?:([A-Za-z0-9_:.]+)\\.new)|[\\[\"'%:/\\?\\{]|%r|<<|true|false|^\\?|0[0-7]+|[-+]?0b[01]+|[-+]?0x[1-9a-fA-F]+|[-+]?[0-9_\\.e]+|nil)?"); QRegExp endre("^(\\s*)end\\s*$"); FileDom m_file = codeModel()->create<FileModel>(); m_file->setName(fileName); ClassDom lastClass; FunctionDom lastMethod; QString lastMethodIndentation; int lastAccess = CodeModelItem::Public; QString rawline; QCString line; int lineNo = 0; while (!stream.atEnd()) { rawline = stream.readLine(); line = rawline.stripWhiteSpace().local8Bit(); if (classre.search(line) != -1) { if (m_file->hasClass(classre.cap(3))) { lastClass = m_file->classByName( classre.cap(3) )[ 0 ]; } else { lastClass = codeModel()->create<ClassModel>(); lastClass->setName(classre.cap(3)); lastClass->setFileName( fileName ); lastClass->setStartPosition( lineNo, 0 ); m_file->addClass( lastClass ); } QString parent = classre.cap(5); if (!parent.isEmpty()) { kdDebug() << "Add parent " << parent << endl; lastClass->addBaseClass( parent ); } lastAccess = CodeModelItem::Public; } else if (methodre.search(line) != -1) { FunctionDom methodDecl; if ( lastClass != 0 && lastClass->hasFunction( methodre.cap(4) ) ) { FunctionList methods = lastClass->functionByName( methodre.cap(4) ); methodDecl = methods[0]; } else { methodDecl = codeModel()->create<FunctionModel>(); methodDecl->setFileName( fileName ); methodDecl->setStartPosition( lineNo, 0 ); methodDecl->setName(methodre.cap(4)); } FunctionDefinitionDom method = codeModel()->create<FunctionDefinitionModel>(); method->setName(methodre.cap(4)); kdDebug() << "Add method: " << method->name() << endl; method->setFileName( fileName ); method->setStartPosition( lineNo, 0 ); if (methodDecl->name() == "initialize") { // Ruby constructors are alway private methodDecl->setAccess( CodeModelItem::Private ); } else { methodDecl->setAccess( lastAccess ); } if (methodre.cap(2) != "") { // A ruby class/singleton method of the form <classname>.<methodname> methodDecl->setStatic( true ); } lastMethodIndentation = methodre.cap(1); lastMethod = method; if (lastClass != 0) { QStringList scope( lastClass->name() ); method->setScope( scope ); methodDecl->setScope( scope ); if( !lastClass->hasFunction(methodDecl->name()) ) { lastClass->addFunction( methodDecl ); } if( !lastClass->hasFunctionDefinition(method->name()) ) { lastClass->addFunctionDefinition( method ); } } else if( !m_file->hasFunctionDefinition(method->name()) ){ m_file->addFunction( methodDecl ); m_file->addFunctionDefinition( method ); lastClass = 0; } } else if (endre.search(line) != -1 && lastMethod != 0 && endre.cap(1) == lastMethodIndentation ) { int endCol, endLine; lastMethod->getEndPosition(&endCol, &endLine); if (endLine == 0) { //hack to set end position of the previous method to the line //where its corresponding "end" is found //there's an assumption that method's "def" statement will have the same //indentation level as method's "end" lastMethod->setEndPosition(lineNo, 0); } } else if (accessre.search(line) != -1 && lastClass != 0) { int currentAccess = lastAccess; if (accessre.cap(1) == "public") { currentAccess = CodeModelItem::Public; } else if (accessre.cap(1) == "protected") { currentAccess = CodeModelItem::Protected; } else if (accessre.cap(1) == "private") { currentAccess = CodeModelItem::Private; } if (accessre.cap(2) == "") { lastAccess = currentAccess; } else { QString symbolList( accessre.cap(2) ); int pos = 0; while ( pos >= 0 ) { pos = symbolre.search( symbolList, pos ); if (pos == -1) { if (line_contre.search(line) != -1) { rawline = stream.readLine(); if (!stream.atEnd()) { line = rawline.stripWhiteSpace().local8Bit(); ++lineNo; symbolList = line; pos = 0; } } } else { if ( lastClass->hasFunction( symbolre.cap(1) ) ) { FunctionList methods = lastClass->functionByName( symbolre.cap(1) ); methods[0]->setAccess( currentAccess ); } pos += symbolre.matchedLength(); } } } } else if (slot_signalre.search(line) != -1 && lastClass != 0) { QString memberList( slot_signalre.cap(2) ); int pos = 0; while ( pos >= 0 ) { pos = memberre.search( memberList, pos ); if (pos == -1) { if (line_contre.search(line) != -1) { rawline = stream.readLine(); if (!stream.atEnd()) { line = rawline.stripWhiteSpace().local8Bit(); ++lineNo; memberList = line; pos = 0; } } } else { FunctionDom method; if ( lastClass->hasFunction( memberre.cap(2) ) ) { FunctionList methods = lastClass->functionByName( memberre.cap(2) ); method = methods[0]; } else { method = codeModel()->create<FunctionModel>(); } QStringList scope( lastClass->name() ); method->setScope( scope ); method->setName(memberre.cap(2)); method->setFileName( fileName ); method->setStartPosition( lineNo, 0 ); if (slot_signalre.cap(1) == "slots" || slot_signalre.cap(1) == "k_dcop") { method->setSlot( true ); } else { method->setSignal( true ); } if ( !lastClass->hasFunction(method->name()) ) { lastClass->addFunction( method ); } pos += memberre.matchedLength(); } } } else if (attr_accessorre.search(line) != -1 && lastClass != 0) { QString attr( attr_accessorre.cap(1) ); QString symbolList( attr_accessorre.cap(2) ); int pos = 0; while ( pos >= 0 ) { pos = symbolre.search( symbolList, pos ); if (pos == -1) { if (line_contre.search(line) != -1) { rawline = stream.readLine(); if (!stream.atEnd()) { line = rawline.stripWhiteSpace().local8Bit(); ++lineNo; symbolList = line; pos = 0; } } } else { QStringList scope( lastClass->name() ); if ( !lastClass->hasFunction(symbolre.cap(1)) && (attr == "attr_accessor" || attr == "attr_reader") ) { FunctionDefinitionDom method = codeModel()->create<FunctionDefinitionModel>(); method->setName(symbolre.cap(1)); kdDebug() << "Add method: " << method->name() << endl; method->setFileName( fileName ); method->setStartPosition( lineNo, 0 ); method->setScope(scope); lastClass->addFunction( model_cast<FunctionDom>(method) ); lastClass->addFunctionDefinition( method ); } if ( !lastClass->hasFunction(symbolre.cap(1) + "=") && (attr == "attr_accessor" || attr == "attr_writer") ) { FunctionDefinitionDom method = codeModel()->create<FunctionDefinitionModel>(); method->setName(symbolre.cap(1) + "="); kdDebug() << "Add method: " << method->name() << endl; method->setFileName( fileName ); method->setStartPosition( lineNo, 0 ); method->setScope(scope); lastClass->addFunction( model_cast<FunctionDom>(method) ); lastClass->addFunctionDefinition( method ); } pos += symbolre.matchedLength(); } } } else if (variablere.search(line) != -1 && lastClass != 0) { VariableDom attr; if ( lastClass->hasVariable( variablere.cap(1) ) ) { attr = lastClass->variableByName( variablere.cap(1) ); } else { attr = codeModel()->create<VariableModel>(); attr->setName( variablere.cap(1) ); attr->setFileName( fileName ); attr->setStartPosition( lineNo, 0 ); attr->setAccess( CodeModelItem::Private ); if (QRegExp("^@@").search(attr->name()) != -1) { attr->setStatic( true ); } lastClass->addVariable( attr ); } // Give priority to any variable initialized in the constructor // Otherwise, take the first one found in the source file if (lastMethod != 0 && lastMethod->name() == "initialize") { attr->setFileName( fileName ); attr->setStartPosition( lineNo, 0 ); } if (QRegExp("^(/|%r)").search(variablere.cap(2)) != -1) { attr->setType( "Regexp" ); } else if (QRegExp("^[\"'%<]").search(variablere.cap(2)) != -1) { attr->setType( "String" ); } else if (QRegExp("^\\[").search(variablere.cap(2)) != -1) { attr->setType( "Array" ); } else if (QRegExp("^\\{").search(variablere.cap(2)) != -1) { attr->setType( "Hash" ); } else if (QRegExp("^:").search(variablere.cap(2)) != -1) { attr->setType( "Symbol" ); } else if (QRegExp("\\.\\.").search(variablere.cap(2)) != -1) { attr->setType( "Range" ); } else if (variablere.cap(2) == "true" || variablere.cap(2) == "false") { attr->setType( "Boolean" ); } else if ( QRegExp("^[-+]?[0-9_]+").exactMatch(variablere.cap(2)) || QRegExp("^[-+]?(0x|0|0b|\\?)").search(variablere.cap(2)) != -1 ) { attr->setType( "Integer" ); } else if (QRegExp("[0-9._]+(e[-+0-9]+)?").exactMatch(variablere.cap(2))) { attr->setType( "Float" ); } else if (variablere.cap(2) != "nil" && variablere.cap(3) != "") { attr->setType( variablere.cap(3) ); } } else if (begin_commentre.search(line) != -1) { while (!stream.atEnd() && end_commentre.search(line) == -1) { rawline = stream.readLine(); line = rawline.stripWhiteSpace().local8Bit(); ++lineNo; } } ++lineNo; } f.close(); codeModel()->addFile( m_file ); }