Exemple #1
0
  /*!
  * \author Anders Fernstrom
  * \date 2005-11-30
  *
  * \brief Parse the xml file using OLD readmode
  *
  * \param domdoc The QDomDocument that should be parsed.
  */
  Cell *XMLParser::parseOld( QDomDocument &domdoc )
  {
    // Create a root element
    QDomElement root = domdoc.documentElement();

    // Check if correct root, otherwise throw exception
    if( root.toElement().tagName() != "Notebook" )
    {
      string msg = "Wrong root node (" + root.toElement().tagName().toStdString() +
        ") in file " + filename_.toStdString() + " (Old File)";
      throw runtime_error( msg.c_str() );
    }

    // Remove first cellgroup.
    QDomNode node = root.firstChild();
    if( !node.isNull() )
    {
      QDomElement element = node.toElement();
      if( !element.isNull() )
        if( element.tagName() == "CellGroupData" )
          node = element.firstChild();
    }

    // Create the grouppcell that will be the root parent.
    Cell *rootcell = factory_->createCell( "cellgroup", 0 );
    xmltraverse( rootcell, node );
    return rootcell;
  }
QDomElement QgsCurvePolygon::asGml2( QDomDocument &doc, int precision, const QString &ns, const AxisOrder axisOrder ) const
{
  // GML2 does not support curves
  QDomElement elemPolygon = doc.createElementNS( ns, QStringLiteral( "Polygon" ) );

  if ( isEmpty() )
    return elemPolygon;

  QDomElement elemOuterBoundaryIs = doc.createElementNS( ns, QStringLiteral( "outerBoundaryIs" ) );
  std::unique_ptr< QgsLineString > exteriorLineString( exteriorRing()->curveToLine() );
  QDomElement outerRing = exteriorLineString->asGml2( doc, precision, ns, axisOrder );
  outerRing.toElement().setTagName( QStringLiteral( "LinearRing" ) );
  elemOuterBoundaryIs.appendChild( outerRing );
  elemPolygon.appendChild( elemOuterBoundaryIs );
  std::unique_ptr< QgsLineString > interiorLineString;
  for ( int i = 0, n = numInteriorRings(); i < n; ++i )
  {
    QDomElement elemInnerBoundaryIs = doc.createElementNS( ns, QStringLiteral( "innerBoundaryIs" ) );
    interiorLineString.reset( interiorRing( i )->curveToLine() );
    QDomElement innerRing = interiorLineString->asGml2( doc, precision, ns, axisOrder );
    innerRing.toElement().setTagName( QStringLiteral( "LinearRing" ) );
    elemInnerBoundaryIs.appendChild( innerRing );
    elemPolygon.appendChild( elemInnerBoundaryIs );
  }
  return elemPolygon;
}
QList<NewsItemData> NewslineWidget::loadRSSFile(const QString& FilePath)
{
  QList<NewsItemData> News;

  QFile File(FilePath);

  if (File.open(QIODevice::ReadOnly))
  {
    QDomDocument Doc;
    QDomElement Root;

    bool Parsed = Doc.setContent(&File);
    File.close();

    if (Parsed)
    {
      Root = Doc.documentElement();

      if (!Root.isNull())
      {

        if (Root.tagName() == QString("rss"))
        {
          QDomElement ChannelNode = Root.firstChildElement("channel");

          if (!ChannelNode.isNull())
          {
            for(QDomElement CurrNode = ChannelNode.firstChildElement();
                !CurrNode.isNull();
                CurrNode = CurrNode.nextSiblingElement())
            {
              QDomElement CurrElement = CurrNode.toElement();
              if (!CurrElement.isNull() && CurrElement.tagName() == "item")
              {
                // TODO
                NewsItemData Item;
                Item.Title = CurrNode.firstChildElement("title").toElement().text();
                Item.Text = CurrNode.firstChildElement("description").toElement().text();
                Item.ISODate = CurrNode.firstChildElement("pubDate").toElement().text();

                for(QDomElement CurrTagNode = CurrNode.firstChildElement("category");
                    !CurrTagNode.isNull();
                    CurrTagNode = CurrTagNode.nextSiblingElement())
                {
                  Item.Tags.push_back(CurrTagNode.toElement().text());
                }

                if (Item.Tags.isEmpty()) Item.Tags.push_back(tr("misc"));

                News.push_back(Item);
              }
            }
          }
        }
      }
    }
  }
  return News;
}
KisKeyframeSP KisScalarKeyframeChannel::loadKeyframe(const QDomElement &keyframeNode)
{
    int time = keyframeNode.toElement().attribute("time").toUInt();
    QVariant value = keyframeNode.toElement().attribute("value");

    KUndo2Command tempParentCommand;
    KisKeyframeSP keyframe = createKeyframe(time, KisKeyframeSP(), &tempParentCommand);
    setScalarValue(keyframe, value.toReal());

    return keyframe;
}
Exemple #5
0
bool K3b::MixedDoc::loadDocumentData( QDomElement* rootElem )
{
    QDomNodeList nodes = rootElem->childNodes();

    if( nodes.length() < 4 )
        return false;

    if( nodes.item(0).nodeName() != "general" )
        return false;
    if( !readGeneralDocumentData( nodes.item(0).toElement() ) )
        return false;

    if( nodes.item(1).nodeName() != "audio" )
        return false;
    QDomElement audioElem = nodes.item(1).toElement();
    if( !m_audioDoc->loadDocumentData( &audioElem ) )
        return false;

    if( nodes.item(2).nodeName() != "data" )
        return false;
    QDomElement dataElem = nodes.item(2).toElement();
    if( !m_dataDoc->loadDocumentData( &dataElem ) )
        return false;

    if( nodes.item(3).nodeName() != "mixed" )
        return false;

    QDomNodeList optionList = nodes.item(3).childNodes();
    for( int i = 0; i < optionList.count(); i++ ) {

        QDomElement e = optionList.item(i).toElement();
        if( e.isNull() )
            return false;

        if( e.nodeName() == "remove_buffer_files" )
            setRemoveImages( e.toElement().text() == "yes" );
        else if( e.nodeName() == "image_path" )
            setTempDir( e.toElement().text() );
        else if( e.nodeName() == "mixed_type" ) {
            QString mt = e.toElement().text();
            if( mt == "last_track" )
                setMixedType( DATA_LAST_TRACK );
            else if( mt == "second_session" )
                setMixedType( DATA_SECOND_SESSION );
            else
                setMixedType( DATA_FIRST_TRACK );
        }
    }

    return true;
}
static QList<QString> fetchVariableNames
    (const QDomDocument *serviceDesc, bool eventableOnly)
{
    QList<QString> names;

    QDomNodeList variables = serviceDesc->elementsByTagName("stateVariable");
    QDomElement var = variables.at(0).toElement();
    for (; var.isNull() == false ; var = var.nextSiblingElement()) {
        QDomElement variable = var.toElement();
        if (variable.isNull())
            continue;

        QString sendEvents = variable.attribute("sendEvents");
        bool envetable =    sendEvents.compare("yes", Qt::CaseInsensitive) == 0
                         || sendEvents.compare("true", Qt::CaseInsensitive) == 0;

        if (envetable == false && eventableOnly)
            continue;

        /* TODO: each of the chained calls is failable */
        QString name
            = variable.elementsByTagName("name").at(0).toElement().text();
        names.append(name);
    }

    return names;
}
int XmlFlochaTransfer::updDomChangedVar(unsigned int *indx, QString &varname, const ArrayDimensInfo &info)
{
    int rtn = -1;
    auto it = indexVarNameNodeMap.find(*indx);


    if(it != indexVarNameNodeMap.end())
    {
        it->second.first = varname;
        it->second.second.toElement().setTagName(varname);
        setEleNodeText(it->second.second.toElement(), QString("%1,%2,%3,%4").arg(info.dimension)
                       .arg(info.dimensionSize[0]).arg(info.dimensionSize[1]).arg(info.dimensionSize[2]));
        commandManager->editVarMap(indx, varname, info);
    }
    else
    {
        QDomElement newnode;
        newnode = domDocument.createElement(varname);
        varPoolParentNode.appendChild(newnode);
        setEleNodeText(newnode.toElement(), QString("%1,%2,%3,%4").arg(info.dimension)
                       .arg(info.dimensionSize[0]).arg(info.dimensionSize[1]).arg(info.dimensionSize[2]));

        commandManager->editVarMap(indx, varname, info);
        indexVarNameNodeMap.insert(std::make_pair(*indx,std::make_pair(varname,newnode)));
        //*indx = VariableIndex;
        //++VariableIndex;

    }


    return rtn;
}
void HuggleFeedProviderWiki::Process(QString data)
{
    //QStringList lines = data.split("\n");
    QDomDocument d;
    d.setContent(data);
    QDomNodeList l = d.elementsByTagName("rc");
    int CurrentNode = l.count();
    if (l.count() == 0)
    {
        Huggle::Syslog::HuggleLogs->Log("Error, wiki provider returned: " + data);
        return;
    }
    // recursively scan all RC changes
    QDateTime t = this->LatestTime;
    bool Changed = false;
    while (CurrentNode > 0)
    {
        CurrentNode--;
        // get a time of rc change
        QDomElement item = l.at(CurrentNode).toElement();
        if (!item.attributes().contains("timestamp"))
        {
            Huggle::Syslog::HuggleLogs->Log(_l("rc-timestamp-missing", item.toElement().nodeName()));
            continue;
        }
        QDateTime time = MediaWiki::FromMWTimestamp(item.attribute("timestamp"));
        if (time < t)
        {
            // this record is older than latest parsed record, so we don't want to parse it
            continue;
        } else
        {
            Changed = true;
            t = time;
        }
        if (!item.attributes().contains("type"))
        {
            Huggle::Syslog::HuggleLogs->Log(_l("rc-type-missing", item.text()));
            continue;
        }
        if (!item.attributes().contains("title"))
        {
            Huggle::Syslog::HuggleLogs->Log(_l("rc-title-missing", item.text()));
            continue;
        }
        QString type = item.attribute("type");
        if (type == "edit" || type == "new")
        {
            ProcessEdit(item);
        }
        else if (type == "log")
        {
            ProcessLog(item);
        }
    }
    if (Changed)
    {
        this->LatestTime = t.addSecs(1);
    }
}
Exemple #9
0
// Load the DB from a DomElement
bool MemDbLoader::load(const QDomElement & elemSource, QSqlDatabase db)
{
    _lastError = "";
    
    // Login to the SQLITE memory DB

	if(db.isOpen()) {
		db.close();
		db.open();
	}

	if(db.databaseName() != memDbName) {
		_lastError = createMemoryDB();
		if(!_lastError.isEmpty()) {
			return false;
		}
		db = QSqlDatabase::database();
		if(!db.open()) {
			_lastError = "Error opening QSQLITE memory database";
			return false;
		}  
	}
	_db = db;

    QDomNodeList nlist = elemSource.childNodes();
    for(int i = 0; i < nlist.count(); i++ ) {
        QDomElement it = nlist.item(i).toElement();
        if(it.tagName()=="table") {
            parseTable(it.toElement());
        }
    }
    return _lastError.isEmpty();
}
Exemple #10
0
// Load the DB from a DomElement
bool MemDbLoader::load(const QDomElement & elemSource)
{
    _lastError = "";
    
    // Login to the SQLITE memory DB

    if(!QSqlDatabase::isDriverAvailable("QSQLITE")) {
        _lastError = "SQLITE plugin not available - data can't be loaded";
        return false;
    }
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(":memory:");

    if(!db.open()) {
        _lastError = "Error opening QSQLITE memory database";
        return false;
    }    

    QDomNodeList nlist = elemSource.childNodes();
    for(int i = 0; i < nlist.count(); i++ ) {
        QDomElement it = nlist.item(i).toElement();
        if(it.tagName()=="table") {
            parseTable(it.toElement());
        }
    }
    return _lastError.isEmpty();
}
Exemple #11
0
DataPtr DataManagerImpl::loadData(QDomElement node, QString rootPath)
{
	QString uid = node.toElement().attribute("uid");
	QString name = node.toElement().attribute("name");
	QString type = node.toElement().attribute("type");

	QDir relativePath = this->findRelativePath(node, rootPath);
	QString absolutePath = this->findAbsolutePath(relativePath, rootPath);

	if (mData.count(uid)) // dont load same image twice
		return mData[uid];

	DataPtr data = mDataFactory->create(type, uid, name);
	if (!data)
	{
		reportWarning(QString("Unknown type: %1 for file %2").arg(type).arg(absolutePath));
		return DataPtr();
	}
	bool loaded = data->load(absolutePath);

	if (!loaded)
	{
		reportWarning("Unknown file: " + absolutePath);
		return DataPtr();
	}

	if (!name.isEmpty())
		data->setName(name);
	data->setFilename(relativePath.path());

	this->loadData(data);

	// conversion for change in format 2013-10-29
	QString newPath = rootPath+"/"+data->getFilename();
	if (QDir::cleanPath(absolutePath) != QDir::cleanPath(newPath))
	{
		reportWarning(QString("Detected old data format, converting from %1 to %2").arg(absolutePath).arg(newPath));
		data->save(rootPath);
	}

	return data;
}
static QDomElement loadSingleProperty( QDomElement e, const QString& name )
{
    QDomElement n;
    for ( n = e.firstChild().toElement();
	  !n.isNull();
	  n = n.nextSibling().toElement() ) {
	if ( n.tagName() == "property" && n.toElement().attribute("name") == name )
	    return n;
    }
    return n;
}
Exemple #13
0
/*! Extracts a named object property from \a e.
 */
QDomElement Uic::getObjectProperty( const QDomElement& e, const QString& name )
{
    QDomElement n;
    for ( n = e.firstChild().toElement();
	  !n.isNull();
	  n = n.nextSibling().toElement() ) {
	if ( n.tagName() == "property"  && n.toElement().attribute("name") == name )
	    return n;
    }
    return n;
}
Exemple #14
0
bool
NetworkObject::fromDomElement(QDomElement de)
{
  clear();

  bool ok = false;

  QString name;
  QDomNodeList dlist = de.childNodes();
  for(int i=0; i<dlist.count(); i++)
    {
      QDomElement dnode = dlist.at(i).toElement();
      QString str = dnode.toElement().text();
      if (dnode.tagName() == "name")
	ok = load(str);
      else if (dnode.tagName() == "vopacity")
	m_Vopacity = str.toFloat();
      else if (dnode.tagName() == "vstops")
	{
	  QStringList xyz = str.split(" ");
	  for(int s=0; s<xyz.count()/5; s++)
	    {
	      float pos;
	      int r,g,b,a;
	      pos = xyz[5*s+0].toFloat();
	      r = xyz[5*s+1].toInt();
	      g = xyz[5*s+2].toInt();
	      b = xyz[5*s+3].toInt();
	      a = xyz[5*s+4].toInt();
	      m_Vstops << QGradientStop(pos, QColor(r,g,b,a));
	    }
	}
      else if (dnode.tagName() == "eopacity")
	m_Eopacity = str.toFloat();
      else if (dnode.tagName() == "estops")
	{
	  QStringList xyz = str.split(" ");
	  for(int s=0; s<xyz.count()/5; s++)
	    {
	      float pos;
	      int r,g,b,a;
	      pos = xyz[5*s+0].toFloat();
	      r = xyz[5*s+1].toInt();
	      g = xyz[5*s+2].toInt();
	      b = xyz[5*s+3].toInt();
	      a = xyz[5*s+4].toInt();
	      m_Vstops << QGradientStop(pos, QColor(r,g,b,a));
	    }
	}
    }

  return ok;
}
Exemple #15
0
/**
  * @brief: Build UI element for required parameter
  * @returns: True if success, false otherwise
  */
bool PolRunTool::buildFromXMLParam(QDomElement param)
{
    QString name = param.toElement().text();
    //Create line edit box
    QLabel* label = new QLabel(name,this);
    QLineEdit* edit = new QLineEdit(this);
    QHBoxLayout* hLayout = new QHBoxLayout(this);
    QSpacerItem* s = new QSpacerItem(20,10,QSizePolicy::Minimum, QSizePolicy::Expanding);
    hLayout->addWidget(label);
    hLayout->addWidget(edit);
    hLayout->addItem(s);
    ui->layout_Parameters->addLayout(hLayout);
    return true;
}
Exemple #16
0
QDomElement Bookmarks::findChildNode(const QString &tagName, const QString &type)
{
    QDomElement n = m_domDocument.documentElement().firstChildElement(tagName);
    while (!n.isNull()) {
        //old files that their 'folder' tags don't use 'id' attribute just contain 'folder' tags of type 'Verses'!
        QString id = n.attribute("id", "Verses");
        if (id == type) {
            break;
        }

        QDomElement e = n.toElement();
        n = n.nextSiblingElement(tagName);
    }
    return n;
}
QT_BEGIN_NAMESPACE

/*! Extracts a named object property from \a e.
 */
QDomElement Ui3Reader::getObjectProperty( const QDomElement& e, const QString& name )
{
    QDomElement n;
    for ( n = e.firstChild().toElement();
          !n.isNull();
          n = n.nextSibling().toElement() ) {
        if ( n.tagName() == QLatin1String("property")  && n.toElement().attribute(QLatin1String("name")) == name )
            return n;
    }
    return n;
}
Exemple #18
0
bool WDomElem::appendChild(QDomElement &element)
{
	if (element.toElement().tagName().compare(g_strValidNodeTag, Qt::CaseInsensitive) != 0 )
	{
		return false;
	}
	// appenda at DOM tree level, WDomElem child is appended automagically in WDomElem::getChild (OR NOT ???)
	domElem.appendChild(element);
	// append at TREE level
	childWDomElems.resize(childWDomElems.size()+1);
	childWDomElems[childWDomElems.size()-1] = new WDomElem(element, childWDomElems.size()-1, this);
	// update row numbers
	updateRowNumbers();

	return true;
}
Exemple #19
0
void MyTreeModel::loadDefaultConfig()
{
	QDomElement wroot;
	// create xml doc info
	QDomProcessingInstruction metanode = domDocument.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
	domDocument.appendChild(metanode);
	// create time infof
	QDomComment datenode = domDocument.createComment(QString("Fecha: %1").arg(QDateTime::currentDateTime().toString("dd-MM-yyyy hh:mm:ss")));
	domDocument.appendChild(datenode);
	// create main element
	QDomElement mainroot = domDocument.createElement("WtCreator");
	mainroot.toElement().setAttribute("Rev", "1.0");
	domDocument.appendChild(mainroot);
	// create wroot
	wroot = domDocument.createElement("WRoot");
	mainroot.appendChild(wroot);
    wRootHiddenElem = new WDomElem(wroot,0);
}
Exemple #20
0
//-----------------------------------------------------------------------------
//! loads fr_databases.conf file and:
//! creates server nodes, fills their properties
//! creates database nodes for server nodes, fills their properties
//! returns: false if file cannot be loaded, true otherwise
//
bool Root::load()
{
	bool docIsOk = false;
    QDomDocument doc;
    QFileInfo fileName = getFileName();
    if (fileName.exists())
    {
		QFile file(fileName.absoluteFilePath());
        if (doc.setContent(&file)) {
			docIsOk = true;
		}
		file.close();
    }
    if (!docIsOk)
        return false;

    QDomElement xmlr = doc.documentElement();
    if (xmlr.tagName() != QString::fromLatin1("root"))
        return false;

    SubjectLocker locker(this);
    for (QDomElement xmln = xmlr.firstChildElement();
		 !xmln.isNull();
		 xmln = xmln.nextSiblingElement())
    {
        if (xmln.tagName() == QString::fromLatin1("server"))
            parseServer(xmln);
        if (xmln.tagName() == QString::fromLatin1("nextId"))
        {
			bool isOk = false;
            QString value = xmln.toElement().text();
            unsigned long l = value.toULong(&isOk);
            // nextIdM may have been written already (database id)
            if (!value.isEmpty() && isOk)
            {
                if (Database::getUIDGeneratorValue() < l)
                    Database::setUIDGeneratorValue(l);
            }
        }
    }
    return true;
}
void Project::loadConnections()
{
#ifndef QT_NO_SQL
    if ( dbFile.isEmpty() || !QFile::exists( makeAbsolute( dbFile ) ) )
	return;

    QFile f( makeAbsolute( dbFile ) );
    if ( f.open( IO_ReadOnly ) ) {
	QDomDocument doc;
	QString errMsg;
	int errLine;
	if ( doc.setContent( &f, &errMsg, &errLine ) ) {
	    QDomElement e;
	    e = doc.firstChild().toElement();

	    /* connections */
	    QDomNodeList connections = e.toElement().elementsByTagName( "connection" );
	    for ( uint i = 0; i <  connections.length(); i++ ) {
		QDomElement connection = connections.item(i).toElement();
		QDomElement connectionName = loadSingleProperty( connection, "name" );
		QDomElement connectionDriver = loadSingleProperty( connection, "driver" );
		QDomElement connectionDatabase = loadSingleProperty( connection,
								     "database" );
		QDomElement connectionUsername = loadSingleProperty( connection,
								     "username" );
		QDomElement connectionHostname = loadSingleProperty( connection,
								     "hostname" );
		QDomElement connectionPort = loadSingleProperty( connection,
								     "port" );

		DatabaseConnection *conn = new DatabaseConnection( this );
		conn->setName( connectionName.firstChild().firstChild().toText().data() );
		conn->setDriver( connectionDriver.firstChild().firstChild().toText().data() );
		conn->setDatabase( connectionDatabase.firstChild().firstChild().toText().data() );
		conn->setUsername( connectionUsername.firstChild().firstChild().toText().data() );
		conn->setHostname( connectionHostname.firstChild().firstChild().toText().data() );
		conn->setPort( QString( connectionPort.firstChild().firstChild().toText().data() ).toInt() );

		/* connection tables */
		QDomNodeList tables = connection.toElement().elementsByTagName( "table" );
		for ( uint j = 0; j <  tables.length(); j++ ) {
		    QDomElement table = tables.item(j).toElement();
		    QDomElement tableName = loadSingleProperty( table, "name" );
		    conn->addTable( tableName.firstChild().firstChild().toText().data() );

		    /* table fields */
		    QStringList fieldList;
		    QDomNodeList fields = table.toElement().elementsByTagName( "field" );
		    for ( uint k = 0; k <  fields.length(); k++ ) {
			QDomElement field = fields.item(k).toElement();
			QDomElement fieldName = loadSingleProperty( field, "name" );
			fieldList.append( fieldName.firstChild().firstChild().toText().data() );
		    }
		    conn->setFields( tableName.firstChild().firstChild().toText().data(),
					 fieldList );
		}

		dbConnections.append( conn );
	    }
	} else {
	    qDebug( QString("Parse error: ") + errMsg + QString(" in line %d"), errLine );
	}
	f.close();
    }
#endif
}
Exemple #22
0
QT_BEGIN_NAMESPACE

void Ui3Reader::computeDeps(const QDomElement &e,
        QStringList &globalIncludes,
        QStringList &localIncludes, bool impl)
{
    QDomNodeList nl;

    // additional includes (local or global) and forward declaractions
    nl = e.toElement().elementsByTagName(QLatin1String("include"));
    for (int i = 0; i < (int) nl.length(); i++) {
        QDomElement n2 = nl.item(i).toElement();
        QString s = n2.firstChild().toText().data();

        if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s))
            continue;

        if (impl && n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation"))
            continue;

        if (n2.attribute(QLatin1String("location")) != QLatin1String("local"))
            globalIncludes += s;
        else
            localIncludes += s;
    }

    // do the local includes afterwards, since global includes have priority on clashes
    nl = e.toElement().elementsByTagName(QLatin1String("header"));
    for (int i = 0; i < (int) nl.length(); i++) {
        QDomElement n2 = nl.item(i).toElement();
        QString s = n2.firstChild().toText().data();
        if (n2.attribute(QLatin1String("location")) == QLatin1String("local") && !globalIncludes.contains(s)) {
            if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s))
                continue;

            if (impl && n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation"))
                continue;

            localIncludes += s;
        }
    }

    // additional custom widget headers
    nl = e.toElement().elementsByTagName(QLatin1String("header"));
    for (int i = 0; i < (int) nl.length(); i++) {
        QDomElement n2 = nl.item(i).toElement();
        QString s = n2.firstChild().toText().data();

        if (n2.attribute(QLatin1String("location")) != QLatin1String("local"))
            globalIncludes += s;
        else
            localIncludes += s;
    }

    { // fix globalIncludes
        globalIncludes = unique(globalIncludes);
        QMutableStringListIterator it(globalIncludes);
        while (it.hasNext()) {
            QString v = it.next();

            if (v.isEmpty()) {
                it.remove();
                continue;
            }

            it.setValue(fixHeaderName(v));
        }
    }

    { // fix the localIncludes
        localIncludes = unique(localIncludes);
        QMutableStringListIterator it(localIncludes);
        while (it.hasNext()) {
            QString v = it.next();

            if (v.isEmpty()) {
                it.remove();
                continue;
            }

            it.setValue(fixHeaderName(v));
        }
    }
}
void
SplineTransferFunction::fromDomElement(QDomElement de)
{
  m_on.clear();
  m_name.clear();
  m_points.clear();
  m_normals.clear();
  m_rightNormals.clear();
  m_leftNormals.clear();
  m_normalWidths.clear();
  m_normalRotations.clear();
  m_gradientStops.clear();

  QDomNodeList dlist = de.childNodes();
  for(int i=0; i<dlist.count(); i++)
    {
      QDomElement dnode = dlist.at(i).toElement();
      if (dnode.tagName() == "name")
	{
	  m_name = dnode.toElement().text();
	}
      else if (dnode.tagName() == "points")
	{
	  QString str = dnode.toElement().text();
	  QStringList strlist = str.split(" ", QString::SkipEmptyParts);
	  for(int j=0; j<strlist.count()/2; j++)
	    {
	      float x,y;
	      x = strlist[2*j].toFloat();
	      y = strlist[2*j+1].toFloat();
	      m_points << QPointF(x,y);
	    }
	}
      else if (dnode.tagName() == "normalwidths")
	{
	  QString str = dnode.toElement().text();
	  QStringList strlist = str.split(" ", QString::SkipEmptyParts);
	  for(int j=0; j<strlist.count()/2; j++)
	    {
	      float x,y;
	      x = strlist[2*j].toFloat();
	      y = strlist[2*j+1].toFloat();
	      m_normalWidths << QPointF(x,y);
	    }
	}
      else if (dnode.tagName() == "normalrotations")
	{
	  QString str = dnode.toElement().text();
	  QStringList strlist = str.split(" ", QString::SkipEmptyParts);
	  for(int j=0; j<strlist.count(); j++)
	    m_normalRotations << strlist[j].toFloat();
	}
      else if (dnode.tagName() == "gradientstops")
	{
	  QString str = dnode.toElement().text();
	  QStringList strlist = str.split(" ", QString::SkipEmptyParts);
	  for(int j=0; j<strlist.count()/5; j++)
	    {
	      float pos, r,g,b,a;
	      pos = strlist[5*j].toFloat();
	      r = strlist[5*j+1].toInt();
	      g = strlist[5*j+2].toInt();
	      b = strlist[5*j+3].toInt();
	      a = strlist[5*j+4].toInt();
	      m_gradientStops << QGradientStop(pos, QColor(r,g,b,a));
	    }
	}
      else if (dnode.tagName() == "sets")
	{
	  QString str = dnode.toElement().text();
	  QStringList strlist = str.split(" ", QString::SkipEmptyParts);
	  for(int j=0; j<strlist.count(); j++)
	    m_on.append(strlist[j].toInt() > 0);
	}
    }

  updateNormals();
  updateColorMapImage();
}
QVariant parseXmlRpcValue( const QDomElement &e, QString &err )
{
    #ifdef DEBUG_XMLRPC
    qDebug() << "parseXmlRpcValue():" << e.tagName();
    #endif

    QVariant v= QVariant::Invalid;
    QString tagName= e.tagName();
    if ( tagName != "value" )
        {
            err= "first param tag is not value";
            return v;
        }

    QDomElement t= e.firstChild().toElement();
    QString type= t.tagName();
    if ( type == "int" || type == "i4" )
        {
            bool ok;
            v= t.firstChild().toText().data().toInt( &ok );
            if ( !ok )
                err= "Can't convert int text '" + t.firstChild().toText().data() + "' to number";
        }
    else if ( type == "longlong")
        {
            bool ok;
            v= t.firstChild().toText().data().toLongLong( &ok );
            if ( !ok )
                err= "Can't convert longlong text '" + t.firstChild().toText().data() + "' to number";
        }
    else if ( type == "ulonglong")
        {
            bool ok;
            v= t.firstChild().toText().data().toULongLong( &ok );
            if ( !ok )
                err= "Can't convert ulonglong text '" + t.firstChild().toText().data() + "' to number";
        }
    else if ( type == "boolean" )
        v= t.firstChild().toText().data() == "1" ? true : false;
    else if ( type == "string" )
        v= t.firstChild().toText().data();
    else if ( type == "double" )
        {
            bool ok;
            v= t.firstChild().toText().data().toDouble( &ok );
            if ( !ok )
                err= "Can't convert int text '" + t.firstChild().toText().data() + "' to number";
        }
    else if ( type == "dateTime.iso8601" )
        v= QDateTime::fromString( t.firstChild().toText().data(), "yyyyMMddTHH:mm:ss" );
    else if ( type == "date.iso8601" )
        v= QDate::fromString( t.firstChild().toText().data(), "yyyyMMdd" );
    else if ( type == "time.iso8601" )
        v= QTime::fromString( t.firstChild().toText().data(), "HH:mm:ss" );
    else if ( type == "base64" )
        v= QByteArray::fromBase64( t.firstChild().toText().data().toLatin1() );
    else if ( type == "array" )
        v= parseXmlRpcArray( t.firstChild().toElement(), err );
    else if ( type == "struct" )
        v= parseXmlRpcStruct( t.firstChild().toElement(), err );
    else if (type == "invalid" )
        v= QVariant();
    else if ( type.length() == 0 )
        v= e.toElement().firstChild().toText().data();
    else
        err= "unknown type: '" + type + "'";
    return v;
}
void cs8ModbusConfigFile::parseDocument ( QDomDocument doc )
{
  qDebug() << "content: " << doc.toString();
  itemList.clear();
  QDomElement topicsList = doc.documentElement();
  
  // read general parameters
  QDomElement generalParameters = topicsList.toElement().elementsByTagName ( "GENERAL_PARAMETERS" ).at ( 0 ).toElement();
  m_topicName = generalParameters.attribute ( "TopicName", "Modbus" );
  m_port = generalParameters.attribute ( "TCP_Port", "502" ).toInt();
  m_connections = generalParameters.attribute ( "ConnectionNumber", "2" ).toInt();
  // read items
  QDomElement topic = topicsList.toElement().elementsByTagName ( "TOPIC" ).at ( 0 ).toElement();
  QDomNode bitNode;
  QDomNode byteNode;
  QDomNode n = topic.firstChild();
  
  while ( !n.isNull() ) {
    QDomElement e = n.toElement(); // try to convert the node to an element.
    
    if ( !e.isNull() ) {
      qDebug() << e.tagName(); // the node really is an element.
      
      if ( e.attribute ( "IDModule" ) == "BOOLEAN" )
        bitNode = e;
        
      if ( e.attribute ( "IDModule" ) == "WORD" )
        byteNode = e;
    }
    
    n = n.nextSibling();
  }
  
  n = bitNode.firstChild();
  
  while ( !n.isNull() ) {
    QDomElement e = n.toElement(); // try to convert the node to an element.
    
    if ( !e.isNull() ) {
      cs8ModbusItem* item = new cs8ModbusItem ( e );
      itemList.append ( item );
    }
    
    n = n.nextSibling();
  }
  
  n = byteNode.firstChild();
  
  while ( !n.isNull() ) {
    QDomElement e = n.toElement(); // try to convert the node to an element.
    
    if ( !e.isNull() ) {
      cs8ModbusItem* item = new cs8ModbusItem ( e );
      itemList.append ( item );
    }
    
    n = n.nextSibling();
  }
  update();
  reset();
}
Exemple #26
0
void Model::deserialize(const QDomDocument &xml)
{
	const QDomNodeList worldList = xml.elementsByTagName("world");
	const QDomNodeList robotsList = xml.elementsByTagName("robots");
	const QDomElement constraints = xml.documentElement().firstChildElement("constraints");

	if (mChecker) {
		/// @todo: should we handle if it returned false?
		mChecker->parseConstraints(constraints);
	}

	if (worldList.count() != 1) {
		return;
	}

	mWorldModel.deserialize(worldList.at(0).toElement());

	if (robotsList.count() != 1) {
		// need for backward compatibility with old format
		const QDomNodeList robotList = xml.elementsByTagName("robot");

		if (robotList.count() != 1) {
			/// @todo Report error
			return;
		}

		mRobotModels.at(0)->deserialize(robotList.at(0).toElement());
		mRobotModels.at(0)->configuration().deserialize(robotList.at(0).toElement());

		return;
	}

	QMutableListIterator<RobotModel *> iterator(mRobotModels);

	const bool oneRobot = robotsList.at(0).toElement().elementsByTagName("robot").size() == 1
			&& mRobotModels.size() == 1;

	while(iterator.hasNext()) {
		bool exist = false;
		RobotModel *robotModel = iterator.next();

		for (QDomElement element = robotsList.at(0).firstChildElement("robot"); !element.isNull();
				element = element.nextSiblingElement("robot")) {
			if (robotModel->info().robotId() == element.toElement().attribute("id")) {
				robotModel->deserialize(element);
				robotModel->configuration().deserialize(element);
				exist = true;
				robotsList.at(0).removeChild(static_cast<QDomNode>(element));
				break;
			}
		}

		if (!exist && !oneRobot) {
			iterator.remove();
			emit robotRemoved(robotModel);
			delete robotModel;
		}
	}

	if (oneRobot && !robotsList.at(0).firstChildElement("robot").isNull()) {
		QDomElement element = robotsList.at(0).firstChildElement("robot");
		mRobotModels.at(0)->deserialize(element);
	} else {
		for (QDomElement element = robotsList.at(0).firstChildElement("robot"); !element.isNull();
				element = element.nextSiblingElement("robot")) {
			twoDModel::robotModel::NullTwoDRobotModel *robotModel = new twoDModel::robotModel::NullTwoDRobotModel(
					element.attribute("id"));
			addRobotModel(*robotModel);
			mRobotModels.last()->deserialize(element);
		}
	}
}
Exemple #27
0
bool DefinitionParser::getCompileArguments (CompileArguments& definition)
{
	QFile file(_targetDir.filePath(DEFINITION_NAME));
	if (!file.open(QIODevice::ReadOnly)) {
		return false;
	}
	QString error;
	if (!_definition.setContent(&file, true, &error)) {
		file.close();
		System.exit(QString(DEFINITION_NAME) + " => " + error, EXIT_FAILURE);
	}
	file.close();

	QDomElement doc = _definition.documentElement();
	QDomNode node = doc.firstChild();
	const QString root = doc.toElement().tagName();
	float player = 11.1;
	int quality = 100;
	bool hasLib = false;
	CompileMode::Mode mode = CompileMode::COMPILE_DEFINITION;

	while (!node.isNull()) {
		QDomElement e = node.toElement();
		node = node.nextSibling();

		if (e.isNull()) {
			continue;
		}

		const QString text = e.text();
		const QString tag = e.tagName();
		if (tag == DefinitionNode::LIBRARY) {
			hasLib = true;
		} else if (tag == DefinitionNode::MODE) {
			mode = CompileMode::Mode(text.toInt());
		} else if (tag == DefinitionNode::PLAYER) {
			player = text.toFloat();
		} else if (tag == DefinitionNode::QUALITY) {
			quality = text.toInt();
			if (quality < 0 || quality > 100)
				quality = 100;
		} else if (tag == DefinitionNode::NAME) {
			if (definition.name.isEmpty()) {
				definition.name = text;
			}
		} else if (tag == DefinitionNode::SWC) {
			if(text.toInt() == 1) {
				definition.swc = true;
			}
		} else {
			warnInvalidTag(tag, root);
		}
	}

	if (definition.mode == CompileMode::UNDEFINED) {
		definition.mode = hasLib ? mode : CompileMode::COMPILE_ALL;
	}
	if (definition.player < 0) {
		definition.player = player;
	}
	if (definition.quality < 0) {
		definition.quality = quality;
	}

	return true;
}
Exemple #28
0
bool
TrisetObject::fromDomElement(QDomElement de)
{
  clear();

  bool ok = false;

  QString name;
  QDomNodeList dlist = de.childNodes();
  for(int i=0; i<dlist.count(); i++)
    {
      QDomElement dnode = dlist.at(i).toElement();
      QString str = dnode.toElement().text();
      if (dnode.tagName() == "name")
	ok = load(str);
      else if (dnode.tagName() == "position")
	{
	  QStringList xyz = str.split(" ");
	  float x = 0;
	  float y = 0;
	  float z = 0;
	  if (xyz.size() > 0) x = xyz[0].toFloat();
	  if (xyz.size() > 1) y  = xyz[1].toFloat();
	  if (xyz.size() > 2) z  = xyz[2].toFloat();
	  m_position = Vec(x,y,z);
	}
      else if (dnode.tagName() == "scale")
	{
	  QStringList xyz = str.split(" ");
	  float x = 0;
	  float y = 0;
	  float z = 0;
	  if (xyz.size() > 0) x = xyz[0].toFloat();
	  if (xyz.size() > 1) y  = xyz[1].toFloat();
	  if (xyz.size() > 2) z  = xyz[2].toFloat();
	  m_scale = Vec(x,y,z);
	}
      else if (dnode.tagName() == "opacity")
	m_opacity = str.toFloat();
      else if (dnode.tagName() == "color")
	{
	  QStringList xyz = str.split(" ");
	  float x = 0;
	  float y = 0;
	  float z = 0;
	  if (xyz.size() > 0) x = xyz[0].toFloat();
	  if (xyz.size() > 1) y  = xyz[1].toFloat();
	  if (xyz.size() > 2) z  = xyz[2].toFloat();
	  m_color = Vec(x,y,z);
	}
      else if (dnode.tagName() == "cropcolor")
	{
	  QStringList xyz = str.split(" ");
	  float x = 0;
	  float y = 0;
	  float z = 0;
	  if (xyz.size() > 0) x = xyz[0].toFloat();
	  if (xyz.size() > 1) y  = xyz[1].toFloat();
	  if (xyz.size() > 2) z  = xyz[2].toFloat();
	  m_cropcolor = Vec(x,y,z);
	}
      else if (dnode.tagName() == "ambient")
	m_ambient = str.toFloat();
      else if (dnode.tagName() == "diffuse")
	m_diffuse = str.toFloat();
      else if (dnode.tagName() == "specular")
	m_specular = str.toFloat();
      else if (dnode.tagName() == "pointmode")
	{
	  if (str == "yes" || str == "1") m_pointMode = true;
	  else m_pointMode = false;
	}
      else if (dnode.tagName() == "pointsize")
	m_pointSize = str.toFloat();
      else if (dnode.tagName() == "pointstep")
	m_pointStep = str.toFloat();
      else if (dnode.tagName() == "blendmode")
	{
	  if (str == "yes" || str == "1") m_pointMode = true;
	  else m_blendMode = false;
	}
      else if (dnode.tagName() == "screendoor")
	{
	  if (str == "yes" || str == "1") m_screenDoor = true;
	  else m_screenDoor = false;
	}
      else if (dnode.tagName() == "flipnormals")
	{
	  if (str == "yes" || str == "1") m_flipNormals = true;
	  else m_flipNormals = false;
	}
    }

  return ok;
}
void MainWindow::on_actionOpen_Project_triggered()
{
    if(project_open)
        on_actionClose_Project_triggered();

    if(project_open)
        return;

    editor = new DocumentEditorView(this);
    editor->hide();

    QDomDocument doc;
    QString filename = QFileDialog::getOpenFileName(this, QString("Choose Project"), ".", "TRX Project (*.trx)");
    QFile file(filename);
    current_project_directory =  QFileInfo(filename).absoluteDir();
    current_project_name = QFileInfo(filename).baseName();

    qDebug() << "filename: " << filename;

    if (!file.open(QIODevice::ReadOnly | QFile::Text))
        return;

    QString message;

    if (!doc.setContent(&file ,false, &message)) {
        file.close();
        return;
    }

    file.close();

    QDomElement docEl = doc.documentElement();

    QString docName = docEl.toElement().firstChild().nodeValue();
    qDebug() << docEl.toElement().firstChild().nodeValue();

    QDomNode child = docEl.firstChild().nextSibling();
    qDebug() << child.toElement().firstChild().nodeValue();

    qDebug() << QFileInfo(filename).absoluteDir().filePath(child.toElement().firstChild().nodeValue());
    requirements = DocumentView::loadDocument(QFileInfo(filename).absoluteDir().filePath(child.toElement().firstChild().nodeValue()));
    requirements->hide();
    traceability = new TraceabilityView(requirements, this);
    ui->centralWidget->layout()->addWidget(traceability);

    QObject::connect(ui->showReq, SIGNAL(pressed()), this, SLOT(showRequirements()));
    QObject::connect(ui->showEdit, SIGNAL(pressed()), this, SLOT(showEditor()));
    QObject::connect(ui->showTrace, SIGNAL(pressed()), this, SLOT(showTraceability()));
    QObject::connect(editor, SIGNAL(docAdded(DocumentView*)), traceability, SLOT(addModels(DocumentView*)));
    QObject::connect(editor, SIGNAL(removeDocument(int)), traceability, SLOT(removeDocument(int)));

    QHash<DocumentView*, QStandardItemModel*> *traceModelList = traceability->getTraceModelList();
    bool modelset = false;
    child = child.nextSibling();
    while (!child.isNull())
    {
        QDomNode subchild = child.firstChild();
        qDebug() << subchild.toElement().firstChild().nodeValue();
        DocumentView* docview = DocumentView::loadDocument(current_project_directory.dirName() + "/" + subchild.toElement().firstChild().nodeValue());
        subchild = subchild.nextSibling();
        qDebug() << subchild.toElement().firstChild().nodeValue();
        QStandardItemModel *matrix = TraceabilityView::loadMatrix(current_project_directory.dirName() + "/" + subchild.toElement().firstChild().nodeValue()+ "_matrix");

        //traceability->addModels(docview, matrix);
        editor->addLoadedTab(docview);
        matrix->setHorizontalHeaderLabels(docview->getHeader());
        traceModelList->insert(docview, matrix);

        if(!modelset){
            traceability->setMatrixModel(matrix);
            modelset = true;
        }

        child = child.nextSibling();
    }


    traceability->addRowToDocument(requirements, -1);
    traceability->updateReqListModel();
    project_open = true;
    ui->frame_2->hide();
    ui->frame->show();
}
Exemple #30
0
bool EncryptedStore::doFinalize()
{
    Q_D(KOdfStore);
    if (d->good) {
        if (isOpen()) {
            close();
        }
        if (d->mode == Write) {
            // First change the manifest file and write it
            // We'll use the QDom classes here, since KXmlReader and KXmlWriter have no way of copying a complete xml-file
            // other than parsing it completely and rebuilding it.
            // Errorhandling here is done to prevent data from being lost whatever happens
            // TODO: Convert this to KoXML when KoXML is extended enough
            // Note: right now this is impossible due to lack of possibilities to copy an element as-is
            QDomDocument document;
            if (m_manifestBuffer.isEmpty()) {
                // No manifest? Better create one
                document = QDomDocument();
                QDomElement rootElement = document.createElement("manifest:manifest");
                rootElement.setAttribute("xmlns:manifest", "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
                document.appendChild(rootElement);
            }
            if (!m_manifestBuffer.isEmpty() && !document.setContent(m_manifestBuffer)) {
                // Oi! That's fresh XML we should have here!
                // This is the only case we can't fix
                KMessage::message(KMessage::Error, i18n("The manifest file seems to be corrupted. It cannot be modified and the document will remain unreadable. Please try and save the document again to prevent losing your work."));
                m_pZip->close();
                return false;
            }
            QDomElement documentElement = document.documentElement();
            QDomNodeList fileElements = documentElement.elementsByTagName("manifest:file-entry");
            // Search all files in the manifest
            QStringList foundFiles;
            for (int i = 0; i < fileElements.size(); i++) {
                QDomElement fileElement = fileElements.item(i).toElement();
                QString fullpath = fileElement.toElement().attribute("manifest:full-path");
                // See if it's encrypted
                if (fullpath.isEmpty() || !m_encryptionData.contains(fullpath)) {
                    continue;
                }
                foundFiles += fullpath;
                KoEncryptedStore_EncryptionData encData = m_encryptionData.value(fullpath);
                // Set the unencrypted size of the file
                fileElement.setAttribute("manifest:size", encData.filesize);
                // See if the user of this store has already provided (old) encryption data
                QDomNodeList childElements = fileElement.elementsByTagName("manifest:encryption-data");
                QDomElement encryptionElement;
                QDomElement algorithmElement;
                QDomElement keyDerivationElement;
                if (childElements.isEmpty()) {
                    encryptionElement = document.createElement("manifest:encryption-data");
                    fileElement.appendChild(encryptionElement);
                } else {
                    encryptionElement = childElements.item(0).toElement();
                }
                childElements = encryptionElement.elementsByTagName("manifest:algorithm");
                if (childElements.isEmpty()) {
                    algorithmElement = document.createElement("manifest:algorithm");
                    encryptionElement.appendChild(algorithmElement);
                } else {
                    algorithmElement = childElements.item(0).toElement();
                }
                childElements = encryptionElement.elementsByTagName("manifest:key-derivation");
                if (childElements.isEmpty()) {
                    keyDerivationElement = document.createElement("manifest:key-derivation");
                    encryptionElement.appendChild(keyDerivationElement);
                } else {
                    keyDerivationElement = childElements.item(0).toElement();
                }
                // Set the right encryption data
                QCA::Base64 encoder;
                QCA::SecureArray checksum = encoder.encode(encData.checksum);
                if (encData.checksumShort) {
                    encryptionElement.setAttribute("manifest:checksum-type", "SHA1/1K");
                } else {
                    encryptionElement.setAttribute("manifest:checksum-type", "SHA1");
                }
                encryptionElement.setAttribute("manifest:checksum", QString(checksum.toByteArray()));
                QCA::SecureArray initVector = encoder.encode(encData.initVector);
                algorithmElement.setAttribute("manifest:algorithm-name", "Blowfish CFB");
                algorithmElement.setAttribute("manifest:initialisation-vector", QString(initVector.toByteArray()));
                QCA::SecureArray salt = encoder.encode(encData.salt);
                keyDerivationElement.setAttribute("manifest:key-derivation-name", "PBKDF2");
                keyDerivationElement.setAttribute("manifest:iteration-count", QString::number(encData.iterationCount));
                keyDerivationElement.setAttribute("manifest:salt", QString(salt.toByteArray()));
            }
            if (foundFiles.size() < m_encryptionData.size()) {
                QList<QString> keys = m_encryptionData.keys();
                for (int i = 0; i < keys.size(); i++) {
                    if (!foundFiles.contains(keys.value(i))) {
                        KoEncryptedStore_EncryptionData encData = m_encryptionData.value(keys.value(i));
                        QDomElement fileElement = document.createElement("manifest:file-entry");
                        fileElement.setAttribute("manifest:full-path", keys.value(i));
                        fileElement.setAttribute("manifest:size", encData.filesize);
                        fileElement.setAttribute("manifest:media-type", "");
                        documentElement.appendChild(fileElement);
                        QDomElement encryptionElement = document.createElement("manifest:encryption-data");
                        QCA::Base64 encoder;
                        QCA::SecureArray checksum = encoder.encode(encData.checksum);
                        QCA::SecureArray initVector = encoder.encode(encData.initVector);
                        QCA::SecureArray salt = encoder.encode(encData.salt);
                        if (encData.checksumShort) {
                            encryptionElement.setAttribute("manifest:checksum-type", "SHA1/1K");
                        } else {
                            encryptionElement.setAttribute("manifest:checksum-type", "SHA1");
                        }
                        encryptionElement.setAttribute("manifest:checksum", QString(checksum.toByteArray()));
                        fileElement.appendChild(encryptionElement);
                        QDomElement algorithmElement = document.createElement("manifest:algorithm");
                        algorithmElement.setAttribute("manifest:algorithm-name", "Blowfish CFB");
                        algorithmElement.setAttribute("manifest:initialisation-vector", QString(initVector.toByteArray()));
                        encryptionElement.appendChild(algorithmElement);
                        QDomElement keyDerivationElement = document.createElement("manifest:key-derivation");
                        keyDerivationElement.setAttribute("manifest:key-derivation-name", "PBKDF2");
                        keyDerivationElement.setAttribute("manifest:iteration-count", QString::number(encData.iterationCount));
                        keyDerivationElement.setAttribute("manifest:salt", QString(salt.toByteArray()));
                        encryptionElement.appendChild(keyDerivationElement);
                    }
                }
            }
            m_manifestBuffer = document.toByteArray();
            m_pZip->setCompression(KZip::DeflateCompression);
            if (!m_pZip->writeFile(MANIFEST_FILE, "", "", m_manifestBuffer.data(), m_manifestBuffer.size())) {
                KMessage::message(KMessage::Error, i18n("The manifest file cannot be written. The document will remain unreadable. Please try and save the document again to prevent losing your work."));
                m_pZip->close();
                return false;
            }
        }
    }
    if (m_pZip)
        return m_pZip->close();
    else
        return true;
}