Ejemplo n.º 1
0
/*!
  This is called by parseSourceFile() to do the actual parsing
  and tree building. It only processes qdoc comments. It skips
  everything else.
 */
bool PureDocParser::processQdocComments()
{
    QSet<QString> topicCommandsAllowed = topicCommands();
    QSet<QString> otherMetacommandsAllowed = otherMetaCommands();
    QSet<QString> metacommandsAllowed = topicCommandsAllowed + otherMetacommandsAllowed;

    while (tok != Tok_Eoi) {
        if (tok == Tok_Doc) {
            /*
              lexeme() returns an entire qdoc comment.
             */
            QString comment = lexeme();
            Location start_loc(location());
            readToken();

            Doc::trimCStyleComment(start_loc,comment);
            Location end_loc(location());

            /*
              Doc parses the comment.
             */
            Doc doc(start_loc,end_loc,comment,metacommandsAllowed);

            QString topic;
            ArgList args;

            QSet<QString> topicCommandsUsed = topicCommandsAllowed & doc.metaCommandsUsed();

            /*
              There should be one topic command in the set,
              or none. If the set is empty, then the comment
              should be a function description.
             */
            if (topicCommandsUsed.count() > 0) {
                topic = *topicCommandsUsed.begin();
                args = doc.metaCommandArgs(topic);
            }

            NodeList nodes;
            QList<Doc> docs;

            if (topic.isEmpty()) {
                doc.location().warning(tr("This qdoc comment contains no topic command "
                                          "(e.g., '\\%1', '\\%2').")
                                       .arg(COMMAND_MODULE).arg(COMMAND_PAGE));
            }
            else {
                /*
                  There is a topic command. Process it.
                 */
                if ((topic == COMMAND_QMLPROPERTY) ||
                        (topic == COMMAND_QMLATTACHEDPROPERTY)) {
                    Doc nodeDoc = doc;
                    Node* node = processTopicCommandGroup(nodeDoc,topic,args);
                    if (node != 0) {
                        nodes.append(node);
                        docs.append(nodeDoc);
                    }
                }
                else {
                    ArgList::ConstIterator a = args.begin();
                    while (a != args.end()) {
                        Doc nodeDoc = doc;
                        Node* node = processTopicCommand(nodeDoc,topic,*a);
                        if (node != 0) {
                            nodes.append(node);
                            docs.append(nodeDoc);
                        }
                        ++a;
                    }
                }
            }

            Node* treeRoot = QDocDatabase::qdocDB()->treeRoot();
            NodeList::Iterator n = nodes.begin();
            QList<Doc>::Iterator d = docs.begin();
            while (n != nodes.end()) {
                processOtherMetaCommands(*d, *n);
                (*n)->setDoc(*d);
                checkModuleInclusion(*n);
                if ((*n)->isInnerNode() && ((InnerNode *)*n)->includes().isEmpty()) {
                    InnerNode *m = static_cast<InnerNode *>(*n);
                    while (m->parent() && m->parent() != treeRoot)
                        m = m->parent();
                    if (m == *n)
                        ((InnerNode *)*n)->addInclude((*n)->name());
                    else
                        ((InnerNode *)*n)->setIncludes(m->includes());
                }
                ++d;
                ++n;
            }
        }
        else {
            readToken();
        }
    }
    return true;
}
Ejemplo n.º 2
0
void Converter::convertServerService()
{
    Q_FOREACH( const Service& service, mWSDL.definitions().services() ) {
        Q_ASSERT(!service.name().isEmpty());

        QSet<QName> uniqueBindings = mWSDL.uniqueBindings( service );

        Q_FOREACH( const QName& bindingName, uniqueBindings ) {
            //qDebug() << "binding" << bindingName;
            const Binding binding = mWSDL.findBinding( bindingName );

            QString className = KODE::Style::className(service.name());
            QString nameSpace;
            if (uniqueBindings.count() > 1) {
                // Multiple bindings: use Service::Binding as classname.
                nameSpace = className;
                className = KODE::Style::className(bindingName.localName());
            }
            className += "ServerBase";

            KODE::Class serverClass(className, nameSpace);
            serverClass.addBaseClass(mQObject);
            serverClass.addBaseClass(mKDSoapServerObjectInterface);
            if (!Settings::self()->exportDeclaration().isEmpty())
                serverClass.setExportDeclaration(Settings::self()->exportDeclaration());
            serverClass.setNameSpace( Settings::self()->nameSpace() );

            // Files included in the header
            serverClass.addHeaderInclude("QtCore/QObject");
            serverClass.addHeaderInclude("KDSoapServer/KDSoapServerObjectInterface.h");

            serverClass.addDeclarationMacro("Q_OBJECT");
            serverClass.addDeclarationMacro("Q_INTERFACES(KDSoapServerObjectInterface)");

            KODE::Function processRequestMethod(QString::fromLatin1("processRequest"), QString::fromLatin1("void"));
            processRequestMethod.addArgument("const KDSoapMessage &request");
            processRequestMethod.addArgument("KDSoapMessage &response");
            processRequestMethod.addArgument("const QByteArray& soapAction");

            KODE::Code body;
            const QString responseNs = mWSDL.definitions().targetNamespace();
            body.addLine("setResponseNamespace(QLatin1String(\"" + responseNs + "\"));" + COMMENT);
            body.addLine("const QByteArray method = request.name().toLatin1();");

            PortType portType = mWSDL.findPortType( binding.portTypeName() );
            //qDebug() << portType.name();
            bool first = true;
            const Operation::List operations = portType.operations();
            Q_FOREACH( const Operation& operation, operations ) {
                const Operation::OperationType opType = operation.operationType();
                switch(opType) {
                case Operation::OneWayOperation:
                case Operation::RequestResponseOperation: // the standard case
                case Operation::SolicitResponseOperation:
                case Operation::NotificationOperation:
                    generateServerMethod(body, binding, operation, serverClass, first);
                    break;
                }
                first = false;
            }

            if (!first) {
                body += "else {";
                body.indent();
            }
            body += "KDSoapServerObjectInterface::processRequest(request, response, soapAction);"  + COMMENT;
            if (!first) {
                body.unindent();
                body += "}";
            }
            processRequestMethod.setBody(body);

            serverClass.addFunction(processRequestMethod);

            mClasses.addClass(serverClass);
        }
    }
}
Ejemplo n.º 3
0
void
ScanResultProcessor::commit()
{
    // the default for albums with several artists is that it's a compilation
    // however, some album names are unlikely to be a compilation
    static QStringList nonCompilationAlbumNames;
    if( nonCompilationAlbumNames.isEmpty() )
    {
        nonCompilationAlbumNames
                << "" // don't throw together albums without name. At least not here
                << "Best Of"
                << "Anthology"
                << "Hit collection"
                << "Greatest Hits"
                << "All Time Greatest Hits"
                << "Live";
    }

    // we are blocking the updated signal for maximum of one second.
    QDateTime blockedTime = QDateTime::currentDateTime();
    blockUpdates();

    // -- commit the directories
    foreach( CollectionScanner::Directory* dir, m_directories )
    {
        commitDirectory( dir );

        // -- sort the tracks into albums
        QSet<CollectionScanner::Album*> dirAlbums;
        QSet<QString> dirAlbumNames;
        QList<CollectionScanner::Track*> tracks = dir->tracks();

        for( int i = tracks.count() - 1; i >= 0; --i )
        {
            CollectionScanner::Album *album = sortTrack( tracks.at( i ) );
            if( album )
            {
                dirAlbums.insert( album );
                dirAlbumNames.insert( album->name() );
                tracks.removeAt( i );
            }
        }

        // -- sort the remainder
        if( dirAlbums.count() == 0 )
        {
            // -- use the directory name as album name
            QString dirAlbumName = QDir( dir->path() ).dirName();
            for( int i = tracks.count() - 1; i >= 0; --i )
            {
                CollectionScanner::Album *album = sortTrack( tracks.at( i ), dirAlbumName, QString() );
                if( album )
                {
                    dirAlbums.insert( album );
                    dirAlbumNames.insert( album->name() );
                    tracks.removeAt( i );
                }
            }
        }
        else
        {
            // -- put into the empty album
            for( int i = tracks.count() - 1; i >= 0; --i )
            {
                CollectionScanner::Album *album = sortTrack( tracks.at( i ), QString(), QString() );
                if( album )
                {
                    dirAlbums.insert( album );
                    dirAlbumNames.insert( album->name() );
                    tracks.removeAt( i );
                }
            }
        }

        // if all the tracks from this directory end up in one album
        // (or they have at least the same name) then it's likely that an image
        // from this directory could be a cover
        if( dirAlbumNames.count() == 1 )
            (*dirAlbums.begin())->setCovers( dir->covers() );
    }
Ejemplo n.º 4
0
QString SafetVariable::getXMLDocument(const QString &value, long fieldno, QString& documentid ) const {
	
	QString str, sql;	
	SafetYAWL::streamlog << SafetLog::Action << tr("Iniciando creacion del documento XML a firmar");
//	QSqlQuery query( "SELECT proveedor_cedula FROM proveedor" );
//	qDebug("...documentsource(): %s", qPrintable( documentsource() ) );
	SafetXmlObject *o = SafetXmlObject::parent();
	Q_CHECK_PTR( o );
	o = o->SafetXmlObject::parent();
	Q_CHECK_PTR( o );
	Q_ASSERT( QString(o->metaObject()->className()) == "SafetWorkflow" );
	SafetWorkflow *wf = qobject_cast<SafetWorkflow*>(o);
	Q_CHECK_PTR( wf );
	SafetSQLParser localparser;
        localparser.setWorkflow( wf );
        qDebug("...****...***...getXMLDocument...localparser.setWorkflow( wf )....");
	localparser.setStr(documentsource().toUtf8() );
	localparser.parse();
	Q_ASSERT_X(localparser.error() ==  SafetParser::CORRECT, "createXMLDocument", 
                                qPrintable(tr("NO es correcta la sentencia SQL: <%1> ").arg(documentsource())));
	QString ts = localparser.getTablesource();
	Q_CHECK_PTR( wf->getToken() );
	localparser.addField(wf->getToken()->key());	
	wf->setTablesource( ts );
	sql = localparser.dropWhereClauses();
        SafetYAWL::streamlog
                << SafetLog::Debug
                << tr("Safet Variable tokenlink: |%1|")
                .arg(tokenlink());
	QString link = wf->processTokenlink(tokenlink());
        SafetYAWL::streamlog
                << SafetLog::Debug
                << tr("Safet Variable tokenlink (procesado): |%1|")
                .arg(link);

	QString wherestring ;	
	QSet<QString> whereset = localparser.getWhereclauses();	
	if ( whereset.count() > 0 ) wherestring = " WHERE ";
	for(int i = 0; i < whereset.count(); i++) {
		wherestring = wherestring + whereset.toList().at(i);
		if (i < whereset.count()-1) wherestring += " AND ";
	}
	sql = sql + " " + link + " " + wherestring;
	SafetYAWL::streamlog << SafetLog::Debug << tr("Documento SQL a ser firmado: %1").arg(sql);
	QSqlQuery query( sql, SafetYAWL::currentDb ); // <-- puntero a db actual
	while (query.next() ) {
//		qDebug("....query.record().fieldName(fieldno): %s", qPrintable(query.record().fieldName(fieldno)));
		if ( query.value(fieldno).toString().trimmed() == value ) {
			str        = createXMLFileFromQuery(query, "::text");
            SYD << tr("......:SafetVariable::getXMLDocument....DOCUMENTID_value:|%1|")
                   .arg(value);
            SYD << tr("\n\n........GETXMLDOCUMENT...SafetWorkflow::getXMLDocument.....");
             for(int i = 0; i < query.record().count(); i++) {
                 SYD << tr("...........SafetWorkflow::getXMLDocument....fieldname:|%1|")
                        .arg(query.record().fieldName(i));
                 SYD << tr("...........SafetWorkflow::getXMLDocument....value:|%1|")
                        .arg(query.record().value(i).toString());

             }
             SYD << tr("...........SafetWorkflow::getXMLDocument.....\n\n");
                        documentid = SafetYAWL::getDocumentID(query,true);

             SYD << tr("......:SafetVariable::getXMLDocument....DOCUMENTID_documentid:|%1|")
                               .arg(documentid);

			break;
		}	
	}
	return str;
}
bool AndroidSettingsWidget::checkNDK(const Utils::FileName &location)
{
    if (location.isEmpty()) {
        m_ui->ndkWarningIconLabel->setVisible(false);
        m_ui->toolchainFoundLabel->setVisible(false);
        m_ui->kitWarningIconLabel->setVisible(false);
        m_ui->kitWarningLabel->setVisible(false);
        return false;
    }
    Utils::FileName platformPath = location;
    Utils::FileName toolChainPath = location;
    Utils::FileName sourcesPath = location;
    if (!platformPath.appendPath(QLatin1String("platforms")).toFileInfo().exists()
            || !toolChainPath.appendPath(QLatin1String("toolchains")).toFileInfo().exists()
            || !sourcesPath.appendPath(QLatin1String("sources/cxx-stl")).toFileInfo().exists()) {
        m_ui->toolchainFoundLabel->setText(tr("\"%1\" does not seem to be an Android NDK top folder.").arg(location.toUserOutput()));
        m_ui->toolchainFoundLabel->setVisible(true);
        m_ui->ndkWarningIconLabel->setVisible(true);
        return false;
    }

    // Check how many toolchains we could add...
    QList<AndroidToolChainFactory::AndroidToolChainInformation> compilerPaths = AndroidToolChainFactory::toolchainPathsForNdk(location);
    if (compilerPaths.isEmpty()) {
        m_ui->ndkWarningIconLabel->setVisible(false);
        m_ui->toolchainFoundLabel->setVisible(false);
    } else {
        m_ui->ndkWarningIconLabel->setVisible(false);
        m_ui->toolchainFoundLabel->setText(tr("Found %n toolchains for this NDK.", 0, compilerPaths.count()));
        m_ui->toolchainFoundLabel->setVisible(true);
    }

    // See if we have qt versions for those toolchains
    QSet<ProjectExplorer::Abi::Architecture> toolchainsForArch;
    foreach (const AndroidToolChainFactory::AndroidToolChainInformation &ati, compilerPaths)
        toolchainsForArch.insert(ati.architecture);

    QSet<ProjectExplorer::Abi::Architecture> qtVersionsForArch;
    foreach (QtSupport::BaseQtVersion *qtVersion, QtSupport::QtVersionManager::versions()) {
        if (qtVersion->type() != QLatin1String(Constants::ANDROIDQT) || qtVersion->qtAbis().isEmpty())
            continue;
        qtVersionsForArch.insert(qtVersion->qtAbis().first().architecture());
    }

    QSet<ProjectExplorer::Abi::Architecture> missingQtArchs = toolchainsForArch.subtract(qtVersionsForArch);
    if (missingQtArchs.isEmpty()) {
        m_ui->kitWarningIconLabel->setVisible(false);
        m_ui->kitWarningLabel->setVisible(false);
    } else {
        m_ui->kitWarningIconLabel->setVisible(true);
        m_ui->kitWarningLabel->setVisible(true);
        if (missingQtArchs.count() == 1) {
            m_ui->kitWarningLabel->setText(tr("Qt version for architecture %1 is missing.\n To add the Qt version, select Options > Build & Run > Qt Versions.")
                                           .arg(ProjectExplorer::Abi::toString((*missingQtArchs.constBegin()))));
        } else {
            QStringList missingArchs;
            foreach (ProjectExplorer::Abi::Architecture arch, missingQtArchs)
                missingArchs.append(ProjectExplorer::Abi::toString(arch));
            m_ui->kitWarningLabel->setText(tr("Qt versions for architectures %1 are missing.\n To add the Qt versions, select Options > Build & Run > Qt Versions.")
                                           .arg(missingArchs.join(QLatin1String(", "))));
        }
    }

    m_androidConfig.ndkLocation = location;
    return true;

}
Ejemplo n.º 6
0
QSet<Node*>* Nfa::traverse(QSet<Node*>* node, QString* str, int direction)
{
    QSet<Node*>* q = node; //node->rawStates(direction);

    /* 
     * We want the rest of the functions to perform only considering the
     * Possibility of FORWARDS/BACKWARDS, not -1
     */
    int trav_direction = (direction == -1 || direction == FORWARDS ? FORWARDS : BACKWARDS);

    // Epsilon closure
    QSetIterator<Node*> k(*q);
    while (k.hasNext())
    {
        Node* node = k.next();
        q->unite(*node->rawStates(trav_direction));
    }

    /*
     * Setup variables that loop will use
     */
    int incr = 1;
    int limit = str->size();
    int i = 0;
    if(direction != -1)
    {
      if(direction == FORWARDS)
      {
        limit = (str->size() % 2 == 0 ? str->size() / 2 + 1 : str->size() / 2 );
        if(VERBOSE)
          printf("FORWARDS: i: %d, limit: %d\n", i, limit);//(direction == FORWARDS ? "Forwards" : "Backwards"));
      }
      /* Backwards */
      else
      {
        limit = str->size() / 2 + 1;
        incr = -1;
        i = str->size() - 1;
        if(VERBOSE)
          printf("BACKWARDS: i: %d, limit: %d, string length: %d\n", i, limit, str->size());//(direction == FORWARDS ? "Forwards" : "Backwards"));
      }
    }

    //printf("Outside: i: %d, limit: %d\n", i, limit);//(direction == FORWARDS ? "Forwards" : "Backwards"));

    QSet<Node*>* newSet = new QSet<Node*>();
    /* You want to loop backwards sometimes, so the comparison you do depends on that */
    for (; ( trav_direction == FORWARDS ? i < limit : i >= limit ); i += incr)
    {
    //printf("i: %d, limit: %d\n", i, limit);//(direction == FORWARDS ? "Forwards" : "Backwards"));
        newSet->clear();
        QSetIterator<Node*> j(*q);
        while (j.hasNext())
        {
            Node* node = j.next();
            QString subStr(str->at(i));
            newSet->unite(*node->traverseOn(subStr, trav_direction));
        }

        // Make q eqaul newSet.
        q->clear();
        q->unite(*newSet); // Done this way for mem. management.

        // Epsilon closure.
        QSetIterator<Node*> k(*q);
        while (k.hasNext())
        {
            Node* node = k.next();
            q->unite(*node->rawStates(trav_direction));
        }

        // Break out early if the q set ends up empty.
        if (q->count() == 0)
        {
            return q;
        }
    }
    return q;
}