diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
commit | e38d2351b83fa65c66ccde443777647ef5cb6cff (patch) | |
tree | 1897fc20e9f73a81c520a5b9f76f8ed042124883 /src/translators/xmlimporter.cpp | |
download | tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.tar.gz tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.zip |
Added KDE3 version of Tellico
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1097620 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/translators/xmlimporter.cpp')
-rw-r--r-- | src/translators/xmlimporter.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/translators/xmlimporter.cpp b/src/translators/xmlimporter.cpp new file mode 100644 index 0000000..ce345c4 --- /dev/null +++ b/src/translators/xmlimporter.cpp @@ -0,0 +1,72 @@ +/*************************************************************************** + copyright : (C) 2003-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "xmlimporter.h" +#include "../filehandler.h" +#include "../collection.h" + +#include <klocale.h> + +using Tellico::Import::XMLImporter; + +XMLImporter::XMLImporter(const KURL& url_) : Import::Importer(url_) { + if(!url_.isEmpty() && url_.isValid()) { + m_dom = FileHandler::readXMLFile(url_, true); + } +} + +XMLImporter::XMLImporter(const QString& text_) : Import::Importer(text_) { + if(text_.isEmpty()) { + return; + } + setText(text_); +} + +XMLImporter::XMLImporter(const QByteArray& data_) : Import::Importer(KURL()) { + if(data_.isEmpty()) { + return; + } + + QString errorMsg; + int errorLine, errorColumn; + if(!m_dom.setContent(data_, true, &errorMsg, &errorLine, &errorColumn)) { + QString str = i18n("There is an XML parsing error in line %1, column %2.").arg(errorLine).arg(errorColumn); + str += QString::fromLatin1("\n"); + str += i18n("The error message from Qt is:"); + str += QString::fromLatin1("\n\t") + errorMsg; + setStatusMessage(str); + return; + } +} + +XMLImporter::XMLImporter(const QDomDocument& dom_) : Import::Importer(KURL()), m_dom(dom_) { +} + +void XMLImporter::setText(const QString& text_) { + Importer::setText(text_); + QString errorMsg; + int errorLine, errorColumn; + if(!m_dom.setContent(text_, true, &errorMsg, &errorLine, &errorColumn)) { + QString str = i18n("There is an XML parsing error in line %1, column %2.").arg(errorLine).arg(errorColumn); + str += QString::fromLatin1("\n"); + str += i18n("The error message from Qt is:"); + str += QString::fromLatin1("\n\t") + errorMsg; + setStatusMessage(str); + } +} + +Tellico::Data::CollPtr XMLImporter::collection() { + return 0; +} + +#include "xmlimporter.moc" |