Exemplo n.º 1
0
void QLCFile_Test::readXML()
{
    QDomDocument doc;

    doc = QLCFile::readXML(QString());
    QVERIFY(doc.isNull() == true);

    doc = QLCFile::readXML("foobar");
    QVERIFY(doc.isNull() == true);

    doc = QLCFile::readXML("broken.xml");
    QVERIFY(doc.isNull() == false);
    QCOMPARE(doc.firstChild().toElement().tagName(), QString("Workspace"));
    QCOMPARE(doc.firstChild().firstChild().toElement().tagName(), QString("Creator"));

	QString path("readonly.xml");
#ifndef WIN32
	QFile::Permissions perms = QFile::permissions(path);
	QFile::setPermissions(path, 0);
    doc = QLCFile::readXML(path);
    QVERIFY(doc.isNull() == true);
	QFile::setPermissions(path, perms);
#endif

    doc = QLCFile::readXML(path);
    QVERIFY(doc.isNull() == false);
    QCOMPARE(doc.firstChild().toElement().tagName(), QString("Workspace"));
    QCOMPARE(doc.firstChild().firstChild().toElement().tagName(), QString("Creator"));
}
Exemplo n.º 2
0
void UpdateInfoPlugin::reactOnUpdaterOutput()
{
    QDomDocument updatesDomDocument = d->checkUpdateInfoWatcher->result();

    if (updatesDomDocument.isNull() ||
        !updatesDomDocument.firstChildElement().hasChildNodes())
    { // no updates are available
        startCheckTimer(60 * OneMinute);
    } else {
        //added the current almost finished task to the progressmanager
        d->updateInfoProgress = Core::ICore::instance()->progressManager()->addTask(
                d->lastCheckUpdateInfoTask, tr("Update"), QLatin1String("Update.GetInfo"), Core::ProgressManager::KeepOnFinish);

        d->updateInfoProgress->setKeepOnFinish(Core::FutureProgress::KeepOnFinish);

        d->progressUpdateInfoButton = new UpdateInfoButton();
        //the old widget is deleted inside this function
        //and the current widget becomes a child of updateInfoProgress
        d->updateInfoProgress->setWidget(d->progressUpdateInfoButton);

        //d->progressUpdateInfoButton->setText(tr("Update")); //we have this information over the progressbar
        connect(d->progressUpdateInfoButton, SIGNAL(released()),
                this, SLOT(startUpdaterUiApplication()));
    }
}
Exemplo n.º 3
0
void eGuiOpPage::saveToXml(QDomElement &node) const
{
    QDomDocument xml = node.ownerDocument();
    eASSERT(!xml.isNull());

    QDomElement pageEl = xml.createElement("page");
    pageEl.setAttribute("id", m_opPage->getId());
    pageEl.setAttribute("name", QString(m_opPage->getUserName()));
    node.appendChild(pageEl);

    for (eInt i=0; i<items().size(); i++)
    {
        QGraphicsItem *item = items().at(i);
        eASSERT(item != eNULL);

        if (item->type() == QGraphicsTextItem::Type)
        {
            // Save comment item.
            QDomElement cmtEl = xml.createElement("comment");
            cmtEl.setAttribute("xpos", item->pos().x());
            cmtEl.setAttribute("ypos", item->pos().y());
            cmtEl.setAttribute("text", ((QGraphicsTextItem *)item)->toPlainText());
            pageEl.appendChild(cmtEl);
        }
        else
        {
            // Save GUI operator.
            ((eGuiOperator *)item)->saveToXml(pageEl);
        }
    }
}
Exemplo n.º 4
0
bool QDomDocumentProto::isNull() const
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->isNull();
    return false;
}
Exemplo n.º 5
0
void ValgrindPart::savePartialProjectSession( QDomElement* el )
{
  QDomDocument domDoc = el->ownerDocument();
  if ( domDoc.isNull() )
    return;

  QDomElement execElem = domDoc.createElement( "executable" );
  execElem.setAttribute( "path", _lastExec );
  execElem.setAttribute( "params", _lastParams );

  QDomElement valElem = domDoc.createElement( "valgrind" );
  valElem.setAttribute( "path", _lastValExec );
  valElem.setAttribute( "params", _lastValParams );

  QDomElement ctElem = domDoc.createElement( "calltree" );
  ctElem.setAttribute( "path", _lastCtExec );
  ctElem.setAttribute( "params", _lastCtParams );

  QDomElement kcElem = domDoc.createElement( "kcachegrind" );
  kcElem.setAttribute( "path", _lastKcExec );

  el->appendChild( execElem );
  el->appendChild( valElem );
  el->appendChild( ctElem );
  el->appendChild( kcElem );
}
Exemplo n.º 6
0
QFile::FileError QLCFixtureDef::loadXML(const QString& fileName)
{
    QFile::FileError error = QFile::NoError;

    if (fileName.isEmpty() == true)
        return QFile::OpenError;

    QDomDocument doc = QLCFile::readXML(fileName);
    if (doc.isNull() == true)
    {
        qWarning() << Q_FUNC_INFO << "Unable to read from" << fileName;
        return QFile::ReadError;
    }

    if (doc.doctype().name() == KXMLQLCFixtureDefDocument)
    {
        if (loadXML(doc) == true)
            error = QFile::NoError;
        else
            error = QFile::ReadError;
    }
    else
    {
        error = QFile::ReadError;
        qWarning() << Q_FUNC_INFO << fileName
                   << "is not a fixture definition file";
    }

    return error;
}
Exemplo n.º 7
0
void BenchmarkTests::parsingBenchmarkComparison()
{
    const KMime::Message::Ptr kolabItem = readMimeFile( TESTFILEDIR+QString::fromLatin1("/v2/event/complex.ics.mime") );
    KMime::Content *xmlContent = findContentByType( kolabItem, "application/x-vnd.kolab.event" );
    QVERIFY ( xmlContent );
    const QByteArray xmlData = xmlContent->decodedContent();
    //     qDebug() << xmlData;
    const QDomDocument xmlDoc = KolabV2::Event::loadDocument( QString::fromUtf8(xmlData) );
    QVERIFY ( !xmlDoc.isNull() );
    const KCalCore::Event::Ptr i = KolabV2::Event::fromXml( xmlDoc, QString::fromLatin1("Europe/Berlin") );
    QVERIFY ( i );
    const Kolab::Event &event = Kolab::Conversion::fromKCalCore(*i);
    const std::string &v3String = Kolab::writeEvent(event);
    
    QFETCH(bool, v2Parser);
    
    //     Kolab::readEvent(v3String, false); //init parser (doesn't really change the results it seems)
    //     qDebug() << QString::fromUtf8(xmlData);
    //     qDebug() << "------------------------------------------------------------------------------------";
    //     qDebug() << QString::fromStdString(v3String);
    if (v2Parser) {
        QBENCHMARK {
            KolabV2::Event::fromXml( KolabV2::Event::loadDocument( QString::fromUtf8(xmlData) ), QString::fromLatin1("Europe/Berlin") );
        }
    } else {
Exemplo n.º 8
0
int api_validate_barcode(QString data){
	QMap <QString, QString> map;
	map["barcode"] = data;
	map["token"] = g_token;

	QDomDocument doc;
	int http = api_request(&doc, "/api/tickets/validate-barcode/", map);
	

	if(doc.isNull() || http != STATUS_HTTP_OK) return MAKELRESULT(0, http);

	QDomElement root = doc.documentElement();
	
	
	QDomElement statusText = root.firstChildElement("statusText");
	if(!statusText.isNull()){
		printf("[api_login] found statusText node\n");
		if(statusText.text().compare("OK_VALID")){
			printf("[api_validate_barcode] fail");
			return MAKELRESULT(STATUS_GENERAL_FAILURE, http);
		}
	}

	QDomElement edata = root.firstChildElement("data");
	if(!data.isNull()){
		QDomElement ticketStatusCode = edata.firstChildElement("ticketStatusCode");
		if(!ticketStatusCode.isNull()){
			std::cout << "[api_validate_barcode] http code = " << http << "\n";
			std::cout << "[api_validate_barcode] return code = " << MAKELRESULT(ticketStatusCode.text().toStdString().at(0) - '0', http) << "\n";
			return MAKELRESULT(ticketStatusCode.text().toStdString().at(0) - '0', http);
		}
	}

	return MAKELRESULT(STATUS_GENERAL_FAILURE, http);
}
Exemplo n.º 9
0
/* public slots */
QDomDocument ChannelDevice::getDataDocument() const
{
    QDomDocument doc;
    CharDevice *wdg = static_cast<CharDevice*>(charDevWdg->currentWidget());
    doc = wdg->getDataDocument();
    if ( doc.isNull() ) {
        QDomElement _device, _devDesc;
        _device = doc.createElement("device");
        _devDesc = doc.createElement("channel");
        _device.appendChild(_devDesc);
        doc.appendChild(_device);
    };
    QDomElement _target = doc.createElement("target");
    _target.setAttribute("type", "virtio");
    _target.setAttribute("name", chanType->currentText());
    doc.firstChildElement("device")
            .firstChildElement("channel")
            .appendChild(_target);
    QString _type = devType->itemData(
                devType->currentIndex(),
                Qt::UserRole).toString();
    doc.firstChildElement("device")
            .firstChildElement("channel")
            .setAttribute("type", _type);
    return doc;
}
Exemplo n.º 10
0
bool QgsWFSProvider::transactionSuccess( const QDomDocument& serverResponse ) const
{
  if ( serverResponse.isNull() )
  {
    return false;
  }

  QDomElement documentElem = serverResponse.documentElement();
  if ( documentElem.isNull() )
  {
    return false;
  }

  QDomNodeList transactionResultList = documentElem.elementsByTagNameNS( QgsWFSConstants::WFS_NAMESPACE, "TransactionResult" );
  if ( transactionResultList.size() < 1 )
  {
    return false;
  }

  QDomNodeList statusList = transactionResultList.at( 0 ).toElement().elementsByTagNameNS( QgsWFSConstants::WFS_NAMESPACE, "Status" );
  if ( statusList.size() < 1 )
  {
    return false;
  }

  if ( statusList.at( 0 ).firstChildElement().localName() == "SUCCESS" )
  {
    return true;
  }
  else
  {
    return false;
  }
}
Exemplo n.º 11
0
QStringList QgsWFSProvider::insertedFeatureIds( const QDomDocument& serverResponse ) const
{
  QStringList ids;
  if ( serverResponse.isNull() )
  {
    return ids;
  }

  QDomElement rootElem = serverResponse.documentElement();
  if ( rootElem.isNull() )
  {
    return ids;
  }

  QDomNodeList insertResultList = rootElem.elementsByTagNameNS( QgsWFSConstants::WFS_NAMESPACE, "InsertResult" );
  for ( int i = 0; i < insertResultList.size(); ++i )
  {
    QDomNodeList featureIdList = insertResultList.at( i ).toElement().elementsByTagNameNS( QgsWFSConstants::OGC_NAMESPACE, "FeatureId" );
    for ( int j = 0; j < featureIdList.size(); ++j )
    {
      QString fidString = featureIdList.at( j ).toElement().attribute( "fid" );
      if ( !fidString.isEmpty() )
      {
        ids << fidString;
      }
    }
  }
  return ids;
}
Exemplo n.º 12
0
void GLDMaskWidget::parseXMl(const GString& filename)
{
    if(nullptr == filename)
    {
        return;
    }

    QFile file(filename);
    if(!file.open(QFile::ReadOnly | QFile::Text))
    {
        return;
    }

    QString strError;
    QDomDocument document;
    int errLin = 0, errCol = 0;

    if(!document.setContent(&file, false, &strError, &errLin, &errCol))
    {
        return;
    }

    if(document.isNull())
    {
        return;
    }

    QDomElement root = document.documentElement();
    GString elementTagName = root.firstChildElement().tagName();
    QDomNodeList nodeList = root.elementsByTagName(elementTagName);

    for (int i = 0; i < nodeList.size(); ++i)
    {
        GLDGuideInfo guideInfo;

        QDomElement element = nodeList.item(i).firstChildElement();

        while (!element.isNull())
        {
            GLDGuideInfoItem guideInfoItem = parseNodeItem(element);

            if (element.tagName() == "mask")
            {
                guideInfo.m_maskWidgetItem = guideInfoItem;
            }
            else if (element.tagName() == "close")
            {
                guideInfo.m_closeButtonItem = guideInfoItem;
            }
            else if (element.tagName() == "next")
            {
                guideInfo.m_nextButtonItem = guideInfoItem;
            }

            element = element.nextSiblingElement();
        }

        doRegisterGuideInfo(guideInfo);
    }
}
Exemplo n.º 13
0
QStringList OsdParser::parseStructureNames() const
{
    QStringList ret;
    QScopedPointer<ScriptLogger> rootLogger(new ScriptLogger); //only needed if we get an error right now
    rootLogger->setLogToStdOut(true); //we cannot get our messages into the script console, so do this instead
    QDomDocument document = openDoc(rootLogger.data());
    if (document.isNull())
        return QStringList();
    QDomElement rootElem = document.firstChildElement(QStringLiteral("data"));
    if (rootElem.isNull())
        return QStringList();
    for (QDomElement childElement = rootElem.firstChildElement();
            !childElement.isNull(); childElement = childElement.nextSiblingElement())
    {
        QString tag = childElement.tagName();
        if (tag == TYPE_STRUCT || tag == TYPE_ARRAY || tag == TYPE_BITFIELD || tag == TYPE_PRIMITIVE
                || tag == TYPE_UNION || tag == TYPE_ENUM || tag == TYPE_FLAGS || tag == TYPE_STRING)
        {
            //TODO allow e.g. <uint8 name="asfd">
            ret.append(readProperty(childElement, PROPERTY_NAME, i18n("<invalid name>")));
        }
        else
        {
            rootLogger->error(QString()).nospace() << "Unknown tag name in plugin " << mPluginName << " :"
                    << tag;
        }
    }
    return ret;
}
Exemplo n.º 14
0
//==============================================================
//  Запись в XML
//==============================================================
void SettingAnimation::writeToXml(QDomDocument doc, QDomElement &root)
{
    Q_ASSERT(!doc.isNull());
    Q_ASSERT(!root.isNull());

    writeFpsToXml(doc, root);
    writeFrameCountToXml(doc, root);
    writeLoopToXml(doc, root);
}
Exemplo n.º 15
0
bool QgsWFSProvider::sendTransactionDocument( const QDomDocument& doc, QDomDocument& serverResponse )
{
  if ( doc.isNull() )
  {
    return false;
  }

  QgsWFSTransactionRequest request( mShared->mURI.uri() );
  return request.send( doc, serverResponse );
}
Exemplo n.º 16
0
int CDownLoadHandleVersionFile::OnEnd(int nErrorCode)
{
    if(m_szFile.isEmpty())
        return -1;

    if(nErrorCode)
    {
        LOG_MODEL_ERROR("Update", "Don't open version configure file:%s", m_szFile.toStdString().c_str());
        return -2;
    }

    QFile file(m_szFile);
    if(!file.open(QIODevice::ReadOnly))
    {
        LOG_MODEL_ERROR("Update", "Don't open version configure file:%s", m_szFile.toStdString().c_str());
        return -3;
    }

    QString szErr;
    QDomDocument doc;
    if(!doc.setContent(&file, &szErr))
    {
        LOG_MODEL_ERROR("Update", "doc.setContent error:%s", szErr.toStdString().c_str());
        return -4;
    }

    file.close();

    if(doc.isNull())
    {
        LOG_MODEL_ERROR("Update", "doc is null");
        return -5;
    }

    CGlobal::Instance()->SetUpdateDate(QDateTime::currentDateTime());

    QDomElement startElem = doc.documentElement();
    QString szMajorVersion = startElem.firstChildElement("MAJOR_VERSION_NUMBER").text();
    QString szMinorVersion = startElem.firstChildElement("MINOR_VERSION_NUMBER").text();
    QString szRevisionVersion = startElem.firstChildElement("REVISION_VERSION_NUMBER").text();
    if(szMajorVersion.toInt() <= MAJOR_VERSION_NUMBER)
    {
        if(szMinorVersion.toInt() <= MINOR_VERSION_NUMBER)
        {
            if(szRevisionVersion.toInt() <= REVISION_VERSION_NUMBER)
            {
                LOG_MODEL_DEBUG("Update", "Is already the newest version.");
                return 0;
            }
        }
    }

    emit GET_MAINWINDOW->sigUpdateExec(nErrorCode, m_szFile);
    return 0;
}
Exemplo n.º 17
0
// mrml-document in the bytearray
void MrmlPart::slotData( KIO::Job *, const QByteArray& data )
{
    if ( data.isEmpty() )
        return;

    QDomDocument doc;
    doc.setContent( data );

    if ( !doc.isNull() )
        parseMrml( doc );
}
Exemplo n.º 18
0
void QLCFile_Test::getXMLHeader()
{
    bool insideCreatorTag = false, author = false, appname = false,
         appversion = false;
    QDomDocument doc;

    doc = QLCFile::getXMLHeader(QString());
    QVERIFY(doc.isNull() == true);

    doc = QLCFile::getXMLHeader("Settings");
    QVERIFY(doc.isNull() == false);
    QCOMPARE(doc.doctype().name(), QString("Settings"));

    QDomNode node(doc.firstChild());
    QCOMPARE(node.toElement().tagName(), QString("Settings"));
    node = node.firstChild();
    QCOMPARE(node.toElement().tagName(), QString("Creator"));
    node = node.firstChild();
    while (node.isNull() == false)
    {
        // Verify that program enters this while loop
        insideCreatorTag = true;

        QDomElement tag(node.toElement());
        if (tag.tagName() == KXMLQLCCreatorAuthor)
            author = true; // User might not have a full name so don't check the contents
        else if (tag.tagName() == KXMLQLCCreatorName)
            appname = true;
        else if (tag.tagName() == KXMLQLCCreatorVersion)
            appversion = true;
        else
            QFAIL(QString("Unrecognized tag: %1").arg(tag.tagName()).toUtf8().constData());

        node = node.nextSibling();
    }

    QCOMPARE(insideCreatorTag, true);
    QCOMPARE(author, true);
    QCOMPARE(appname, true);
    QCOMPARE(appversion, true);
}
Exemplo n.º 19
0
void Updater::readAnswer()
{
	const QString output = mUpdaterProcess->readAllStandardOutput();
	// Checking that output is a valid XML
	QDomDocument parser;
	parser.setContent(output);
	QLOG_INFO() << "Updater output:" << output;
	if (!output.isEmpty() && !parser.isNull() && output.trimmed().startsWith("<")) {
		emit newVersionAvailable();
	} else {
		emit noNewVersionAvailable();
	}
}
Exemplo n.º 20
0
//==============================================================
//  Запись QPolygonF в XML
//==============================================================
void writePolygonfToXml(QPolygonF polygon, QDomDocument doc, QDomElement &root)
{
    Q_ASSERT(!doc.isNull());
    Q_ASSERT(!root.isNull());

    for (const QPointF &pt: polygon)
    {
        QDomElement elemPoint = doc.createElement("Point");
        writePointfToXml(pt, elemPoint);

        root.appendChild(elemPoint);
    }
}
Exemplo n.º 21
0
QList<Status*> XmlParser::parseFriendsTimeLine(const QString &data){
    QList<Status*> listStatus;
    QDomDocument doc;
     doc.setContent(data);
     if(!doc.isNull()){
        QDomNodeList nodeList = doc.elementsByTagName("status");
        for(int i = 0; i != nodeList.size(); i++){
          // Status *status = new Status;
           Status *status = parseStatus(nodeList.at(i));
           listStatus.append(status);
        }
     }
     return listStatus;
}
Exemplo n.º 22
0
QDomDocument StyleNode::openStyleDoc(const QString& path)
{
    QDomDocument doc = QDomDocument(XML_DOM_TYPE);
    QFile file(path);
    if ( !file.open(QIODevice::ReadOnly) ) throw VisualizationException("Could not open style file " + file.fileName() + ".");

    if ( !doc.setContent(&file) || doc.isNull() )
    {
        file.close();
        throw VisualizationException("Reading of the XML structure of file " + file.fileName() + " failed.");
    }

    file.close();
    return doc;
}
Exemplo n.º 23
0
void QtUpnpServiceInfo::scpdReceived(QNetworkReply* reply)
{
    if (!reply->error()) {
        QDomDocument doc;
        doc.setContent(networkReply->device(), true);

        if (!doc.isNull()) {
            m_introspection = new QtUpnpServiceIntrospection(doc);
            gotIntrospection();
        }
    }

    m_pendingRequest.removeAll(reply);
    reply->deleteLater();
}
Exemplo n.º 24
0
void UpdateInfoPlugin::parseUpdates()
{
    QDomDocument updatesDomDocument = d->checkUpdateInfoWatcher->result();
    if (updatesDomDocument.isNull() || !updatesDomDocument.firstChildElement().hasChildNodes())
        return;

    // add the finished task to the progress manager
    d->updateInfoProgress = ProgressManager::addTask(d->lastCheckUpdateInfoTask, tr("Updates "
        "available"), "Update.GetInfo", ProgressManager::KeepOnFinish);
    d->updateInfoProgress->setKeepOnFinish(FutureProgress::KeepOnFinish);

    d->progressUpdateInfoButton = new UpdateInfoButton();
    d->updateInfoProgress->setWidget(d->progressUpdateInfoButton);
    connect(d->progressUpdateInfoButton, SIGNAL(released()), this, SLOT(startUpdaterUiApplication()));
}
Exemplo n.º 25
0
QObject * LanguageResource::resource()
{
    if (d->m_languageResource != 0) {
        return d->m_languageResource;
    }

    if (!d->m_path.isLocalFile()) {
        qWarning() << "Cannot open language file at " << d->m_path.toLocalFile() << ", aborting.";
        return 0;
    }

    QXmlSchema schema = loadXmlSchema("language");
    if (!schema.isValid()) {
        return 0;
    }

    QDomDocument document = loadDomDocument(d->m_path, schema);
    if (document.isNull()) {
        qWarning() << "Could not parse document " << d->m_path.toLocalFile() << ", aborting.";
        return 0;
    }

    QDomElement root(document.documentElement());
    d->m_languageResource = new Language(this);
    d->m_languageResource->setFile(d->m_path);
    d->m_languageResource->setId(root.firstChildElement("id").text());
    d->m_languageResource->setTitle(root.firstChildElement("title").text());
    d->m_languageResource->seti18nTitle(root.firstChildElement("i18nTitle").text());
    // create phoneme groups
    for (QDomElement groupNode = root.firstChildElement("phonemeGroups").firstChildElement();
         !groupNode.isNull();
         groupNode = groupNode.nextSiblingElement())
    {
        PhonemeGroup *group = d->m_languageResource->addPhonemeGroup(
            groupNode.firstChildElement("id").text(),
            groupNode.firstChildElement("title").text());
        group->setDescription(groupNode.attribute("description"));
        // register phonemes
        for (QDomElement phonemeNode = groupNode.firstChildElement("phonemes").firstChildElement();
            !phonemeNode.isNull();
            phonemeNode = phonemeNode.nextSiblingElement())
        {
            group->addPhoneme(phonemeNode.firstChildElement("id").text(), phonemeNode.firstChildElement("title").text());
        }
    }

    return d->m_languageResource;
}
Exemplo n.º 26
0
void WatchRoot::restorePartialProjectSession(const QDomElement* el)
{
    QDomDocument domDoc = el->ownerDocument();
    if (domDoc.isNull()) {
        return;
	}
	
    QDomElement watchEl = el->namedItem("watchExpressions").toElement();
    QDomElement subEl = watchEl.firstChild().toElement();
	
    while (!subEl.isNull()) {
		new WatchVarItem(this, subEl.firstChild().toText().data(), UNKNOWN_TYPE);
		
        subEl = subEl.nextSibling().toElement();
    }
	
	return;
}
Exemplo n.º 27
0
void UpdateInfoPlugin::checkForUpdatesFinished()
{
    setLastCheckDate(QDate::currentDate());

    QDomDocument document;
    document.setContent(d->m_collectedOutput);

    stopCheckForUpdates();

    if (!document.isNull() && document.firstChildElement().hasChildNodes()) {
        emit newUpdatesAvailable(true);
        if (QMessageBox::question(0, tr("Updater"),
                                  tr("New updates are available. Do you want to start update?"))
                == QMessageBox::Yes)
            startUpdater();
    } else {
        emit newUpdatesAvailable(false);
    }
}
Exemplo n.º 28
0
int Update::fastParseVersion(QString strVersionXml)
{
    if (strVersionXml.isEmpty()) return 0;

    QDomDocument doc;
    doc.setContent(strVersionXml);

    if (doc.isNull()) return 0;

    QString strVersion = doc.elementsByTagName("version").item(0).toElement().text();

    if (strVersion.isEmpty()) return 0;

    QStringList lVersion = strVersion.split(".");
    int iMajor = lVersion.at(0).toInt();
    int iMinor = lVersion.at(1).toInt();
    int iPatch = lVersion.at(2).toInt();
    return (QString("%1%2%3").arg(iMajor).arg(iMinor).arg(iPatch)).toInt();
}
Exemplo n.º 29
0
/*! \brief Writes the result data to xml node.
 *
 *  \author Vikas Pachdha
 *
 *  \param[in] element : Xml node to write data under.
 *
 *  \return bool : Returns whether write was a success.
 *  \retval success status.
 *                      <ul>
 *                         <li> False = Failure
 *                         <li> True = Success
 *                      </ul>
 ******************************************************************************/
bool Result_C::write(QDomElement &element)
{
    bool success = false;

    if( !element.isNull()) {
        QDomDocument domDocument = element.ownerDocument();

        if(!domDocument.isNull()) {
            QDomElement dom_result = domDocument.createElement("Result");

            QDomElement dom_date_time = domDocument.createElement("DateTime");
            QDomText text_date_time = domDocument.createTextNode(QString::number(_result_date_time.toMSecsSinceEpoch()));
            dom_date_time.appendChild(text_date_time);
            dom_result.appendChild(dom_date_time);

            QDomElement dom_score = domDocument.createElement("Score");
            QDomText text_score = domDocument.createTextNode(QString::number(_score,'f',2));
            dom_score.appendChild(text_score);
            dom_result.appendChild(dom_score);

            QDomElement dom_correct_count = domDocument.createElement("CorrectCount");
            QDomText text_correct_count = domDocument.createTextNode(QString::number(_correct_word_count));
            dom_correct_count.appendChild(text_correct_count);
            dom_result.appendChild(dom_correct_count);

            QDomElement dom_mistakes_count = domDocument.createElement("MistakesCount");
            QDomText text_mistakes_count = domDocument.createTextNode(QString::number(_mistakes_count));
            dom_mistakes_count.appendChild(text_mistakes_count);
            dom_result.appendChild(dom_mistakes_count);

            QDomElement dom_unplayed_count = domDocument.createElement("UnplayedCount");
            QDomText text_unplayed_count = domDocument.createTextNode(QString::number(_unplayed_count));
            dom_unplayed_count.appendChild(text_unplayed_count);
            dom_result.appendChild(dom_unplayed_count);

            element.appendChild(dom_result);

            success = true;
        }
    }

    return success;
}
Exemplo n.º 30
0
void AStylePart::savePartialProjectSession(QDomElement * el)
{
	QDomDocument domDoc = el->ownerDocument();
	if (domDoc.isNull())
		return;

	QDomElement style = domDoc.createElement("AStyle");
	style.setAttribute("FStyle", m_project["FStyle"].toString());
	if (m_project["FStyle"] != "GLOBAL")
	{
		 for (QMap<QString, QVariant>::iterator iter = m_project.begin();iter != m_project.end();iter++)
        {
              style.setAttribute(iter.key(),iter.data().toString());
		}
		QDomElement exten = domDoc.createElement ( "Extensions" );
		exten.setAttribute ( "ext", m_projectExtensions.join(",").simplifyWhiteSpace() );
		el->appendChild(exten);
	}
	el->appendChild(style);
}