1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#include "xml-base.h"
#include "vymmodel.h"
parseBaseHandler::parseBaseHandler() {}
parseBaseHandler::~parseBaseHandler() {}
QString parseBaseHandler::errorProtocol() { return errorProt; }
QString parseBaseHandler::parseHREF(QString href)
{
QString type=href.section(":",0,0);
QString path=href.section(":",1,1);
if (!tmpDir.endsWith("/"))
return tmpDir + "/" + path;
else
return tmpDir + path;
}
bool parseBaseHandler::fatalError( const QXmlParseException& exception )
{
errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
.arg( exception.message() )
.arg( exception.lineNumber() )
.arg( exception.columnNumber() );
// Try to read the bogus line
errorProt += QString("File is: %1\n").arg(inputFile);
if (!inputFile.isEmpty() )
{ // Input was from file
if (!loadStringFromDisk (inputFile, inputString))
{
qWarning()<<"parseBaseHandler::fatalError Couldn't read from "<<inputFile;
return QXmlDefaultHandler::fatalError( exception );
}
}
QString s;
QStringList sl = inputString.split ("\n");
int i = 1;
QStringList::Iterator it = sl.begin();
while (i < exception.lineNumber())
{
it++;
i++;
}
s =*it;
s.insert (exception.columnNumber()-1,"<ERROR>");
errorProt += s;
return QXmlDefaultHandler::fatalError( exception );
}
void parseBaseHandler::setModel (VymModel *m)
{
model=m;
}
void parseBaseHandler::setTmpDir (QString tp)
{
tmpDir=tp;
}
void parseBaseHandler::setInputFile (const QString &s)
{
inputFile = s;
}
void parseBaseHandler::setInputString ( const QString &s)
{
inputString = s;
}
void parseBaseHandler::setLoadMode (const LoadMode &lm, int p)
{
loadMode=lm;
insertPos=p;
}
bool parseBaseHandler::readHtmlAttr (const QXmlAttributes& a)
{
for (int i=1; i<=a.count(); i++)
htmldata+=" "+a.localName(i-1)+"=\""+a.value(i-1)+"\"";
return true;
}
|