Exemple #1
0
	Document::Document (const QString& filename, QObject *plugin)
	: DocURL_ (QUrl::fromLocalFile (filename))
	, Plugin_ (plugin)
	{
		QFile file (filename);
		if (!file.open (QIODevice::ReadOnly))
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to open file"
					<< file.fileName ()
					<< file.errorString ();
			return;
		}

		QDomDocument doc;
		if (!doc.setContent (file.readAll (), true))
		{
			qWarning () << Q_FUNC_INFO
					<< "malformed XML in"
					<< filename;
			return;
		}

		FB2Converter conv (this, doc);
		auto textDoc = conv.GetResult ();
		SetDocument (textDoc);
		Info_ = conv.GetDocumentInfo ();
		TOC_ = conv.GetTOC ();
	}
Exemple #2
0
	Document::Document (const QString& filename, QObject *plugin)
	: DocURL_ (QUrl::fromLocalFile (filename))
	, Plugin_ (plugin)
	{
		SetSettings ();

		QFile file (filename);
		if (!file.open (QIODevice::ReadOnly))
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to open file"
					<< file.fileName ()
					<< file.errorString ();
			return;
		}

		QDomDocument doc;
		if (!doc.setContent (file.readAll (), true))
		{
			qWarning () << Q_FUNC_INFO
					<< "malformed XML in"
					<< filename;
			return;
		}

		FB2Converter conv (this, doc);
		auto textDoc = conv.GetResult ();

		const auto& defaultFont = XmlSettingsManager::Instance ()
				.property ("DefaultFont").value<QFont> ();
		textDoc->setDefaultFont (defaultFont);

		textDoc->setPageSize (QSize {
				XmlSettingsManager::Instance ().property ("PageWidth").toInt (),
				XmlSettingsManager::Instance ().property ("PageHeight").toInt ()
			});

		SetDocument (textDoc);
		Info_ = conv.GetDocumentInfo ();
		TOC_ = conv.GetTOC ();
	}