Exemplo n.º 1
0
	void WriteChannel (QXmlStreamWriter& w,
			const ChannelShort& cs, const QList<Item_ptr>& items)
	{
		w.writeStartElement ("section");
			w.writeAttribute ("id", QString::number (cs.ChannelID_));
			w.writeStartElement ("title");
				w.writeTextElement ("p", FixContents (cs.Title_));
			w.writeEndElement ();
			w.writeTextElement ("annotation",
					Export2FB2Dialog::tr ("%n unread item(s)", "", cs.Unread_));
			Q_FOREACH (Item_ptr item, items)
			{
				w.writeStartElement ("title");
					w.writeStartElement ("p");
					w.writeComment ("p");
					w.device ()->write (FixContents (item->Title_).toUtf8 ());
					w.writeEndElement ();
				w.writeEndElement ();

				bool hasDate = item->PubDate_.isValid ();
				bool hasAuthor = item->Author_.size ();
				if (hasDate || hasAuthor)
				{
					w.writeStartElement ("epigraph");
						if (hasDate)
							w.writeTextElement ("p",
									Export2FB2Dialog::tr ("Published on %1")
										.arg (item->PubDate_.toString ()));
						if (hasAuthor)
							w.writeTextElement ("p",
									Export2FB2Dialog::tr ("By %1")
										.arg (item->Author_));
					w.writeEndElement ();
					w.writeEmptyElement ("empty-line");
				}

				w.writeStartElement ("p");
					w.writeComment ("p");
					w.device ()->write (FixContents (item->Description_).toUtf8 ());
				w.writeEndElement ();

				w.writeEmptyElement ("empty-line");
			}
Exemplo n.º 2
0
	void appendComponent( QXmlStreamWriter &stream, const Billon &billon, const uint &firstSlicePos, const int &index )
	{
		const uint &width = billon.n_cols;
		const uint &height = billon.n_rows;
		const uint &depth = billon.n_slices;

		uint i, j, k;

		stream.writeStartElement("component");
		stream.writeAttribute("id",QString::number(index));
		stream.writeAttribute("valmax",QString::number(billon.maxValue()));
		stream.writeAttribute("valmin",QString::number(billon.minValue()));

		//coord minimum
		stream.writeStartElement("coord");
		stream.writeAttribute("name","minimum");
		stream.writeTextElement("x",QString::number(0));
		stream.writeTextElement("y",QString::number(0));
		stream.writeTextElement("z",QString::number(firstSlicePos));
		stream.writeEndElement();

		//coord maximum
		stream.writeStartElement("coord");
		stream.writeAttribute("name","maximum");
		stream.writeTextElement("x",QString::number(width-1));
		stream.writeTextElement("y",QString::number(height-1));
		stream.writeTextElement("z",QString::number(firstSlicePos+billon.n_slices-1));
		stream.writeEndElement();

		//binarydata
		stream.writeStartElement("binarydata");
		stream.writeAttribute("encoding","16");
		stream.writeCharacters("");
		QDataStream voxelStream(stream.device());
		for ( k=0; k<depth; ++k )
		{
			const Slice &slice = billon.slice(k);
			for ( j=0; j<height; ++j )
			{
				for ( i=0; i<width; ++i )
				{
					voxelStream << (qint16)(slice.at(j,i));
				}
			}
		}
		stream.writeEndElement();

		stream.writeEndElement();
	}
static PyObject *meth_QXmlStreamWriter_device(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QXmlStreamWriter *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QXmlStreamWriter, &sipCpp))
        {
            QIODevice *sipRes;

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->device();
            Py_END_ALLOW_THREADS

            return sipConvertFromType(sipRes,sipType_QIODevice,NULL);
        }
    }