ExerciseWindow::ExerciseWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ExerciseWindow)
{
    ui->setupUi(this);
    ui->scrollArea->setWidgetResizable(false);
    QPalette Pal(palette());
    Pal.setColor(QPalette::Background, Qt::white);
    ui->scrollArea->setAutoFillBackground(true);
    ui->scrollArea->setPalette(Pal);
    openFromNewLine = ui->checkBox_newLine->isChecked();
    srand((unsigned)time (0));
    makeFlowChart();
    QString name = windowTitle();
    doc = QDomDocument("flowchart");
    generateVars();
    QDomElement domElement = doc.createElement(name);
    generateXML(domElement, doc);
    doc.appendChild(domElement);
    ui->textBrowser->setFont(QFont("Courier", 10));
    ui->textBrowser_2->setFont(QFont("Courier", 10));
    connect(ui->pushButton, SIGNAL(clicked()), SLOT(checkExercise()));
    connect(ui->checkBox_newLine, SIGNAL(clicked()), SLOT(checkExercise()));
    connect(ui->horizontalSlider, SIGNAL(valueChanged(int)), SLOT(changeFontSize(int)));
    connect(ui->checkBox, SIGNAL(toggled(bool)), wdg, SLOT(HideTexts(bool)));
}
Esempio n. 2
0
QDomDocument SecurityLabel::readData()
{
    QDomText data;
    QDomDocument doc = QDomDocument();
    if ( !useSecLabel->isChecked() ) return doc;
    QDomElement _secLabel, _label;
    QString _t, _r, _m;
    _secLabel= doc.createElement("seclabel");

    _t = type->currentText().toLower();
    if ( _t!="none" ) {
        _m = model->currentText().toLower();
         _secLabel.setAttribute("model", model->currentText().toLower());
        _r = relabel->currentText().toLower();
        if ( _r!="default" ) {
            _secLabel.setAttribute("relabel", _r);
        };
        _label =doc.createElement(labelTypeLabel->currentText().toLower());
        data = doc.createTextNode(label->text());
        _label.appendChild(data);
        _secLabel.appendChild(_label);
    };
    _secLabel.setAttribute("type", _t);
    doc.appendChild(_secLabel);
    return doc;
}
Esempio n. 3
0
bool AvolitesD4Parser::loadXML(const QString& path)
{
    m_lastError = QString();
    m_documentRoot = QDomDocument();
    m_channels.clear();

    if (path.isEmpty())
    {
        m_lastError = "filename not specified";
        return false;
    }

    m_documentRoot = QLCFile::readXML(path);
    if (m_documentRoot.isNull() == true)
    {
        m_lastError = "unable to read document";
        return false;
    }

    // check if the document has <Fixture></Fixture> if not then it's not a valid file
    QDomElement el = m_documentRoot.namedItem(KD4TagFixture).toElement();
    if (el.isNull() && (!el.hasAttribute(KD4TagName) ||
        !el.hasAttribute(KD4TagShortName) || !el.hasAttribute(KD4TagCompany)))
    {
        m_lastError = "wrong document format";
        return false;
    }

    return true;
}
Esempio n. 4
0
bool MyMoneyTemplate::exportTemplate(void(*callback)(int, int, const QString&))
{
  m_progressCallback = callback;

  m_doc = QDomDocument("KMYMONEY-TEMPLATE");

  QDomProcessingInstruction instruct = m_doc.createProcessingInstruction(QString("xml"), QString("version=\"1.0\" encoding=\"utf-8\""));
  m_doc.appendChild(instruct);

  QDomElement mainElement = m_doc.createElement("kmymoney-account-template");
  m_doc.appendChild(mainElement);

  QDomElement title = m_doc.createElement("title");
  mainElement.appendChild(title);

  QDomElement shortDesc = m_doc.createElement("shortdesc");
  mainElement.appendChild(shortDesc);

  QDomElement longDesc = m_doc.createElement("longdesc");
  mainElement.appendChild(longDesc);

  QDomElement accounts = m_doc.createElement("accounts");
  mainElement.appendChild(accounts);

  // addAccountStructure(accounts, MyMoneyFile::instance()->asset());
  // addAccountStructure(accounts, MyMoneyFile::instance()->liability());
  addAccountStructure(accounts, MyMoneyFile::instance()->income());
  addAccountStructure(accounts, MyMoneyFile::instance()->expense());
  // addAccountStructure(accounts, MyMoneyFile::instance()->equity());

  return true;
}
Esempio n. 5
0
QDomDocument QLCFile::readXML(const QString& path)
{
    if (path.isEmpty() == true)
    {
        qWarning() << Q_FUNC_INFO
                   << "Empty path given. Not attempting to load file.";
        return QDomDocument();
    }

    QDomDocument doc;
    QFile file(path);
    if (file.open(QIODevice::ReadOnly) == true)
    {
        QString msg;
        int line = 0;
        int col = 0;
        if (doc.setContent(&file, false, &msg, &line, &col) == false)
        {
            qWarning() << Q_FUNC_INFO << "Error loading file" << path
                       << ":" << msg << ", line:" << line << ", col:" << col;
        }
    }
    else
    {
        qWarning() << Q_FUNC_INFO << "Unable to open file:" << path;
    }

    file.close();

    return doc;
}
Esempio n. 6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
//	listWidget(new QListWidget),
//	ui(new Ui::MainWindow),
//	nRow(0)
	model(0)
{
//	QHBoxLayout *layout = new QHBoxLayout();
//	layout->addWidget(listWidget);

//	setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}");
//	setCentralWidget(listWidget);

//	ui->setupUi(this);
	fileMenu = menuBar()->addMenu(tr("&File"));
	fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()), QKeySequence::Open);
	fileMenu->addAction(tr("E&xit"), this, SLOT(close()), QKeySequence::Quit);

	model = new DomModel(QDomDocument(), this);
	view = new QTreeView(this);
	view->setModel(model);

	setCentralWidget(view);
	setWindowTitle(tr("Simple DOM Model"));
}
bool TestDspCmdDirGetVmList::getExpectedVmList(QList<QDomDocument>& expectedList)
{
   QString  errorMsg;
   int      errorLine, errorColumn;

   expectedList.clear();

   CAuthHelper auth(TestConfig::getUserLogin());
   if (!auth.AuthUser(TestConfig::getUserPassword()))
   {
      WRITE_TRACE(DBG_FATAL, "can't auth user[%s] on localhost ", TestConfig::getUserLogin());
      return false;
   }

	// __asm int 3;
   SmartPtr<CVmDirectory> pVmDir = GetUserVmDirectory();
   if( !pVmDir )
   {
      WRITE_TRACE(DBG_FATAL, "can't get vm directory from ");
      return false;
   }

   for (int idx=0; idx< pVmDir->m_lstVmDirectoryItems.size(); idx++)
   {
      CVmDirectoryItem* pDirItem= pVmDir->m_lstVmDirectoryItems[idx];
      QString strVmHome=pDirItem->getVmHome();
      QString strChangedBy=pDirItem->getChangedBy();
      QString strChangeDateTime=pDirItem->getChangeDateTime().toString(XML_DATETIME_FORMAT);

      //FIXME: add checking access permission to vm.xml
      // fixed: when i started as test-user it doing automatically

      if (!CFileHelper::FileCanRead(strVmHome, &auth))
         continue;

      QFile vmConfig(strVmHome);
      if(!vmConfig.open(QIODevice::ReadOnly))
      {
         WRITE_TRACE(DBG_FATAL, "can't open file [%s]", strVmHome.toUtf8().data());
         break;
      }

      expectedList.push_back(QDomDocument());
      QDomDocument& doc=expectedList[expectedList.size()-1];
      if(!doc.setContent(&vmConfig, false, &errorMsg, &errorLine, &errorColumn ))
      {
         WRITE_TRACE(DBG_FATAL, "error of parsing file: [fname=%s], errorMsg=%s, line=%d, column=%d"
            , strVmHome.toUtf8().data()
            , errorMsg.toUtf8().data(), errorLine, errorColumn);
         expectedList.clear();
         return false;
      }

      addNodeToIdentityPart(doc, XML_VM_DIR_ND_VM_HOME, strVmHome);
      addNodeToIdentityPart(doc, XML_VM_DIR_ND_CHANGED_BY, strChangedBy);
      addNodeToIdentityPart(doc, XML_VM_DIR_ND_CHANGED_DATETIME, strChangeDateTime);
   }//for
   return (true);
}
/* private slots */
void USB_Host_Device::setAvailabledUSBDevices()
{
    int i = 0;
    QStringList      devices;
    virNodeDevice  **nodeDevices = NULL;
    if ( currWorkConnect!=NULL ) {
        unsigned int flags =
                VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV;
        int ret = virConnectListAllNodeDevices(currWorkConnect, &nodeDevices, flags);
        if ( ret<0 ) {
            sendConnErrors();
        } else {
            while ( nodeDevices[i] != NULL ) {
                devices.append( QString("%1\n")
                                // flags: extra flags; not used yet,
                                // so callers should always pass 0
                                .arg(virNodeDeviceGetXMLDesc(nodeDevices[i], 0)));
                virNodeDeviceFree(nodeDevices[i]);
                i++;
            };
        };
        free(nodeDevices);
    };
    //int devs = virNodeNumOfDevices(currWorkConnect, NULL, 0);
    //qDebug()<<"Devices("<<devs<<i<<"):\n"<<devices.join("\n");
    // set unique device description to devList
    foreach (QString _dev, devices) {
        //qDebug()<<_dev;
        QString devName, devIdentity;
        QDomElement capability, product, vendor;
        QDomDocument doc = QDomDocument();
        doc.setContent(_dev);
        // filter out **** Host Controllers
        if ( !doc.
             firstChildElement("device").
             firstChildElement("parent").
             firstChild().toText().data().
             startsWith("usb") ) continue;
        //
        capability = doc.firstChildElement("device").
                firstChildElement("capability");
        product = capability.firstChildElement("product");
        vendor = capability.firstChildElement("vendor");
        // devIdentity format: <vendor:product>
        devIdentity.append(vendor.attribute("id"));
        devIdentity.append(":");
        devIdentity.append(product.attribute("id"));
        // devName format: <vendor_product>
        devName.append(vendor.firstChild().toText().data());
        devName.append("\n");
        devName.append(product.firstChild().toText().data());
        if ( devList->findItems(devName,
                                Qt::MatchExactly |
                                Qt::MatchCaseSensitive)
             .isEmpty() ) {
            devList->insertItem(0, devName);
            devList->item(0)->setData(Qt::UserRole, devIdentity);
        };
    };
Esempio n. 9
0
void ClipBoard::reset()
{
    actionCopy->setEnabled(false);
    actionCut->setEnabled(false);
    actionPaste->setEnabled(false);

    document = QDomDocument();
}
Esempio n. 10
0
const QDomDocument ServiceModel::domDocument(const QModelIndex& currentIndex) const
{
    ServiceHelper *serviceHelper;
    serviceHelper = this->serviceHelper(currentIndex);
    if (!serviceHelper)
        return QDomDocument();
    return serviceHelper->domDocument();
}
Esempio n. 11
0
QDomDocument QgsSLDConfigParser::describeLayer( QStringList& layerList, const QString& hrefString ) const
{
  if ( mFallbackParser )
  {
    return mFallbackParser->describeLayer( layerList, hrefString );
  }
  return QDomDocument();
}
Esempio n. 12
0
QString KoProperties::store(const QString &s) const
{
    QDomDocument doc = QDomDocument(s);
    QDomElement root = doc.createElement(s);
    doc.appendChild(root);

    save(root);
    return doc.toString();
}
Esempio n. 13
0
void GameControllerAttachment::createNodeAttachment()
{	
	Q_ASSERT(m_currentNode != 0);	
	QDomElement node = m_currentNode->xmlNode().insertBefore(QDomDocument().createElement("Attachment"), QDomNode()).toElement();
	node.setAttribute("type", plugInName());
	node.setAttribute("name", m_currentNode->property("Name").toString() + "_" + m_currentNode->property("ID").toString());
	initNodeAttachment(m_currentNode);
	setCurrentNode(m_currentNode);
}
Esempio n. 14
0
void genXML(QString fileName, QSqlQuery query)
{
    QDomDocument doc;
    QDomElement root;

    doc = QDomDocument("GOBLETXML");

    root = doc.createElement("SQLResultXML");
    root.setAttribute("version", "1.0");
    doc.appendChild(root);

    QDomElement varName;
    QDomText varValue;

    QDomElement querycols;
    querycols = doc.createElement("ResultColumns");
    root.appendChild(querycols);
    int pos;
    for (pos = 0; pos <= query.record().count()-1;pos++)
    {
        varName = doc.createElement("Column");
        querycols.appendChild(varName);
        varValue = doc.createTextNode(query.record().field(pos).name());
        varName.appendChild(varValue);
    }


    QDomElement querydata;
    querydata = doc.createElement("ResultData");
    root.appendChild(querydata);

    while (query.next())
    {
        QDomElement queryRow;
        queryRow = doc.createElement("Row");
        querydata.appendChild(queryRow);
        for (pos = 0; pos <= query.record().count()-1;pos++)
        {
            varName = doc.createElement("Column");
            varName.setAttribute("name",query.record().field(pos).name());
            queryRow.appendChild(varName);
            varValue = doc.createTextNode(query.value(getFieldIndex(query,query.record().field(pos).name())).toString());
            varName.appendChild(varValue);
        }
    }

    QFile file(fileName);
    if (file.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        QTextStream out(&file);
        out.setCodec("UTF-8");
        doc.save(out,1,QDomNode::EncodingFromTextStream);
        file.close();
    }

}
Esempio n. 15
0
QDomDocument LocalFileMng::openXmlDocument( const QString& filename )
{
	bool TinyXMLCompat = LocalFileMng::checkTinyXMLCompatMode( filename );

	QDomDocument doc;
	QFile file( filename );

	if ( !file.open(QIODevice::ReadOnly) )
		return QDomDocument();

	if( TinyXMLCompat ) {
	    QString enc = QTextCodec::codecForLocale()->name();
	    if( enc == QString("System") ) {
		    enc = "UTF-8";
	    }
	    QByteArray line;
	    QByteArray buf = QString("<?xml version='1.0' encoding='%1' ?>\n")
		.arg( enc )
		.toLocal8Bit();

	    //_INFOLOG( QString("Using '%1' encoding for TinyXML file").arg(enc) );

	    while( !file.atEnd() ) {
			line = file.readLine();
			LocalFileMng::convertFromTinyXMLString( &line );
			buf += line;
	    }

	    if( ! doc.setContent( buf ) ) {
			file.close();
			return QDomDocument();
	    }

	} else {
	    if( ! doc.setContent( &file ) ) {
			file.close();
			return QDomDocument();
	    }
	}
	file.close();
	
	return doc;
}
Esempio n. 16
0
void odkFormReader::processXML(QString inputFile, QString mainTable)
{
    tables.clear();
    treeItems.clear();

    doc = QDomDocument("ODKDocument");
    QFile xmlfile(inputFile);
    if (!xmlfile.open(QIODevice::ReadOnly))
        return;
    if (!doc.setContent(&xmlfile))
    {
        xmlfile.close();
        return;
    }
    xmlfile.close();

    QDomNodeList list;
    QDomElement item;
    QDomNode node;

    QDomElement mainInstance;

    list = doc.elementsByTagName("instance");
    if (list.count() > 0)
    {
        int pos;
        for (pos = 0; pos <= list.count()-1;pos++)
        {
            item = list.item(pos).toElement();
            if (item.attribute("id","NONE") == "NONE")
            {
                mainInstance = item;
                break;
            }
        }
    }
    item = mainInstance.firstChild().toElement();


    surveyID =item.tagName();


    list = doc.elementsByTagName("h:body");
    if (list.count() > 0)
    {
        node = list.item(0).firstChild();
        TtableDef nulltable;
        nulltable.name = "NULL";
        extractFields(node,mainTable,nulltable,"main",surveyID);
    }

    //Now that we have the list of tables we move the list into a tree


}
QDomDocument AccountProviderModel::domDocument(const QModelIndex& currentIndex)
{
    Q_D(AccountProviderModel);
    ProviderHelper *providerHelper;

    providerHelper = d->providerList.at(currentIndex.row());
    if (!providerHelper)
        return QDomDocument();

    return providerHelper->domDocument();
}
Esempio n. 18
0
void PlaylistHandler::checkInit() {
    if (used)
        return;
    used = true;
    doc = QDomDocument("GSPlayerPL");
    if (!QFile::exists(QApplication::applicationDirPath() + QDir::separator() + "Playlists.xml")) {
        init();
    } else {
        load();
    }
}
Esempio n. 19
0
/* Called by xml reader at start of parsing */
bool VgLogHandler::startDocument()
{
   //   vkPrintErr("VgLogHandler::startDocument()\n");
   vk_assert( logview != 0 );
   
   doc = QDomDocument();
   node = doc;
   m_fatalMsg = QString();
   m_finished = false;
   m_started = true;
   return true;
}
Esempio n. 20
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QDomDocument (doc);
    QFile file("my.xml");
    if(!file.open(QIODevice::ReadOnly))
    {
        return 0;
    }

    QString errorStr;
    int errorLine;
    int errorColumnn;

    if(!doc.setContent(&file,false,&errorStr,&errorLine,&errorColumnn))
    {
        qDebug() << "file closed";
        std::cerr << "Error: Parse error at line" << errorLine <<","
                  << "cloumn" << errorColumnn << ":"
                  << qPrintable(errorStr) << std::endl;
        file.close();
        return 0;
    }
    file.close();

    QDomNode firstNote = doc.firstChild();
    qDebug() << qPrintable(firstNote.nodeName())
                <<qPrintable(firstNote.nodeValue());

    QDomElement docElem = doc.documentElement();
    QDomNode n = docElem.firstChild();
    while(!n.isNull())
    {
        if(n.isElement())
        {
            QDomElement e = n.toElement();
            qDebug() << qPrintable(e.tagName())
                     << qPrintable(e.attribute("id"));

            QDomNodeList list = e.childNodes();
            for(int i=0; i<list.count();i++)
            {
                QDomNode node = list.at(i);
                if(node.isElement())
                    qDebug() << " " << qPrintable(node.toElement().tagName())
                             << qPrintable(node.toElement().text());

            }
        }
        n = n.nextSibling();
    }
    return a.exec();
}
Esempio n. 21
0
void Browser::save(void)
{
  std::cout << qPrintable(tr("Saving data")) << std::endl;

  QFile file( CFG_FILE );
  QDir::setCurrent( CFG_DIR );

  if( !file.open( QIODevice::WriteOnly ) )
    {
      QString strErr = QObject::tr("Error: Can't save config file !");
      std::cerr << " " << qPrintable(strErr) << std::endl;
      QMessageBox::warning(0,
                           QObject::tr("Saving config file"),
                           strErr
                          );
      file.close();
      return;
    }

  std::cout << qPrintable(tr(" ")) << qPrintable(tr("Saving...")) << std::endl;

  QDomImplementation impl = QDomDocument().implementation();

  QString name_ml = QLatin1String("BrowserML");
  QString publicId = QLatin1String("-//CELLES//DTD Browser 0.1 //EN");
  QString systemId = QLatin1String("http://www.celles.net/dtd/browser/browser_data-0_1.dtd");
  QDomDocument doc(impl.createDocumentType(name_ml,publicId,systemId));
  // add some XML comment at the beginning
  doc.appendChild(doc.createComment(QLatin1String("This file describe data for a very light browser for dynamic display")));
  doc.appendChild(doc.createTextNode(QLatin1String("\n"))); // for nicer output
  doc.appendChild(doc.createComment(QLatin1String("http://www.celles.net/wiki/Browser")));
  doc.appendChild(doc.createTextNode(QLatin1String("\n"))); // for nicer output

  QDomElement root = doc.createElement(QLatin1String("browser")); // racine
  root.setAttribute( QLatin1String("timer"), timer->interval() );
  //std::cout << "timer=" << timer->interval() << std::endl;

  doc.appendChild(root);

  for (int i=0 ; i<url_list.count() ; i++) {
    QDomElement dom_elt = doc.createElement( QLatin1String("url") );
    QDomText dom_txt = doc.createTextNode(url_list[i].toString());
    dom_elt.appendChild(dom_txt);
    root.appendChild( dom_elt );
  }

  QTextStream ts( &file );
  ts << doc.toString();

  file.close();

  std::cout << qPrintable(tr(" ")) << qPrintable(tr("Data saved")) << std::endl;
}
QDomDocument SessionStorageServiceImpl::readXmlFile(QString filename)
{
	QDomDocument retval;
	QFile file(filename);
	if (!file.open(QIODevice::ReadOnly))
	{
		reportError("Could not open XML file :" + file.fileName() + ".");
		return QDomDocument();
	}

	QString emsg;
	int eline, ecolumn;
	// Read the file
	if (!retval.setContent(&file, false, &emsg, &eline, &ecolumn))
	{
		reportError("Could not parse XML file :" + file.fileName() + " because: " + emsg + "");
		return QDomDocument();
	}

	return retval;
}
 /*public*/ void OperationsSetupXml::writeFile(QString name) //throw (FileNotFoundException, IOException)
 {
     if (log->isDebugEnabled()) {
         log->debug(tr("writeFile %1").arg(name));
     }
     // This is taken in large part from "Java and XML" page 368
     QFile* file = findFile(name);
     if (file == NULL) {
         file = new QFile(name);
     }
     // create root element
     doc = QDomDocument("operations-config");
     QDomProcessingInstruction xmlProcessingInstruction = doc.createProcessingInstruction("xml", "version=\"1.0\"  encoding=\"UTF-8\"");
     doc.appendChild(xmlProcessingInstruction);//    QDomElement root = QDomElement("operations-config"); // NOI18N
 //    QDomDocument doc = newDocument(root, dtdLocation + "operations-config.dtd"); // NOI18N
     //QDomDocument doc;

     QDomElement root = doc.createElement("operations-config");

     // add XSLT processing instruction
 //    java.util.Map<String, String> m = new java.util.HashMap<String, String>();
 //    m.put("type", "text/xsl"); // NOI18N
 //    m.put("href", xsltLocation + "operations-config.xsl"); // NOI18N
 //    ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m); // NOI18N
 //    doc.addContent(0, p);
     QDomProcessingInstruction p = doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"/xml/XSLT/operations-config.xsl\"");
     doc.appendChild(p);
     doc.appendChild(root);
     root.appendChild(doc.createComment(tr("Written by JMRI version %1 on %1").arg(Version::getCanonicalVersion()).arg(QDateTime::currentDateTime().toString())));

     // add top-level elements
     Setup::setDoc(doc);
     root.appendChild(Setup::store());

     // add manifest header text strings
     root.appendChild(TrainManifestHeaderText::store(doc));

     // add manifest text strings
     root.appendChild(TrainManifestText::store(doc));

     // add switch list text strings
     root.appendChild(TrainSwitchListText::store(doc));

     // add control elements
     Control::setDoc(doc);
     root.appendChild(Control::store());

     writeXML(file, doc);

     // done, so can't be dirty
     setDirty(false);
 }
bool KFormula13ContentHandler::startDocument()
{

    QDomDocumentType dt = QDomImplementation().createDocumentType("math",
                          "-//W3C//DTD MathML 2.0//EN",
                          "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd");
    m_mathMlDocument = QDomDocument(dt);
    QDomProcessingInstruction in = m_mathMlDocument.createProcessingInstruction("xml",
                                   "version=\"1.0\" encoding=\"UTF-8\"");
    m_mathMlDocument.insertBefore(in, m_mathMlDocument.documentElement());
    m_currentElement = m_mathMlDocument.documentElement();

    return true;
}
Esempio n. 25
0
QDomDocument QLCFile::getXMLHeader(const QString& content, const QString& author)
{
    if (content.isEmpty() == true)
        return QDomDocument();

    QDomImplementation dom;
    QDomDocument doc(dom.createDocumentType(content, QString(), QString()));

    QDomProcessingInstruction instr = doc.createProcessingInstruction( 
        "xml", "version='1.0' encoding='UTF-8'");

    doc.appendChild(instr);

    QDomElement root;
    QDomElement tag;
    QDomElement subtag;
    QDomText text;

    root = doc.createElement(content);
    root.setAttribute("xmlns", KXMLQLCplusNamespace + content);

    doc.appendChild(root);

    /* Creator tag */
    tag = doc.createElement(KXMLQLCCreator);
    root.appendChild(tag);

    /* Creator name */
    subtag = doc.createElement(KXMLQLCCreatorName);
    tag.appendChild(subtag);
    text = doc.createTextNode(APPNAME);
    subtag.appendChild(text);

    /* Creator version */
    subtag = doc.createElement(KXMLQLCCreatorVersion);
    tag.appendChild(subtag);
    text = doc.createTextNode(QString(APPVERSION));
    subtag.appendChild(text);

    /* Author */
    subtag = doc.createElement(KXMLQLCCreatorAuthor);
    tag.appendChild(subtag);
    if (author.isEmpty() == true)
        text = doc.createTextNode(currentUserName());
    else
        text = doc.createTextNode(author);
    subtag.appendChild(text);

    return doc;
}
Esempio n. 26
0
void Data::save(void)
{
  std::cout << qPrintable(tr("Saving data")) << std::endl;

  QFile file( OC_CFG_FILE );
  QDir::setCurrent( OC_CFG_DIR );

  if( !file.open( QIODevice::WriteOnly ) )
    {
      QString strErr = QObject::tr("Error: Can't save config file !");
      std::cerr << " " << qPrintable(strErr) << std::endl;
      QMessageBox::warning(0,
                           QObject::tr("Saving config file"),
                           strErr
                          );
      file.close();
      return;
    }

  std::cout << qPrintable(tr(" ")) << qPrintable(tr("Saving...")) << std::endl;

  QDomImplementation impl = QDomDocument().implementation();

  QString name_ml = QLatin1String("OpenChronoML");
  QString publicId = QLatin1String("-//CELLES//DTD OpenChrono 0.1 //EN");
  QString systemId = QLatin1String("http://www.celles.net/dtd/openchrono/openchrono_data-0_1.dtd");
  QDomDocument doc(impl.createDocumentType(name_ml,publicId,systemId));
  // add some XML comment at the beginning
  doc.appendChild(doc.createComment(QLatin1String("This file describe data for OpenChrono a chronometer for mechanical sports")));
  doc.appendChild(doc.createTextNode(QLatin1String("\n"))); // for nicer output
  doc.appendChild(doc.createComment(QLatin1String("http://www.celles.net/wikini/wakka.php?wiki=OpenChrono")));
  doc.appendChild(doc.createTextNode(QLatin1String("\n"))); // for nicer output

  QDomElement root = doc.createElement(QLatin1String("ocdata")); // racine

  doc.appendChild(root);
  root.appendChild( track.to_node(doc) );
  root.appendChild( position.to_node(doc) );
  root.appendChild( vehicule.to_node(doc) );
  root.appendChild( chrono.to_node(doc) );

  QTextStream ts( &file );
  ts << doc.toString();
  //std::cout << doc.toString();

  file.close();

  std::cout << qPrintable(tr(" ")) << qPrintable(tr("Data saved")) << std::endl;
}
Esempio n. 27
0
MessageParser::MessageParser(QByteArray datagram) {
    doc = QDomDocument("mydocument");
    if (!doc.setContent(datagram)) {
        std::cout << "Can't parse message" << std::endl;
        std::cout << QString(datagram).toUtf8().constData()  << std::endl;
    }

    // No chance at this stage, connect is way too slow  --cgloor 2014-05-21
    //    QObject::connect(this, SIGNAL(updateAgentPosition(int, double, double)),
    //                     &agentcontainer, SLOT(updatePosition(int, double, double)));
    //    QObject::connect(this, SIGNAL(updateObstaclePosition(int, double, double)),
    //                     &obstaclecontainer, SLOT(updatePosition(int, double, double)));

    return;
}
WriteToDbaFormat::WriteToDbaFormat()
{
    _doc = QDomDocument("DatabaseAnime");
    _dom = _doc.createElement("DatabaseAnime");
    _doc.appendChild(_dom);

    _domAnime = _doc.createElement("Anime");
    _dom.appendChild(_domAnime);
    _domManga = _doc.createElement("Manga");
    _dom.appendChild(_domManga);
    _domAmv = _doc.createElement("Amv");
    _dom.appendChild(_domAmv);
    _domDorama = _doc.createElement("Dorama");
    _dom.appendChild(_domDorama);
}
MainWindow::MainWindow() : QMainWindow(), model(0)
{
    fileMenu = menuBar()->addMenu(tr("&File"));
    fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
                        QKeySequence::Open);
    fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
                        QKeySequence::Quit);

    model = new DomModel(QDomDocument(), this);
    view = new QTreeView(this);
    view->setModel(model);

    setCentralWidget(view);
    setWindowTitle(tr("Simple DOM Model"));
}
Esempio n. 30
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;
}