xml-base.cpp
author insilmaril
Wed, 09 Sep 2009 12:57:06 +0000
changeset 793 cac93797c580
parent 760 59614eaf5fbb
child 847 43268373032d
permissions -rw-r--r--
more fixes for collision detection
     1 #include "xml-base.h"
     2 
     3 #include <QMessageBox>
     4 #include <QColor>
     5 #include <QTextStream>
     6 #include <iostream>
     7 
     8 #include "misc.h"
     9 #include "settings.h"
    10 #include "linkablemapobj.h"
    11 
    12 /*
    13 static BranchObj *lastBranch;
    14 static FloatObj *lastFloat;
    15 static OrnamentedObj *lastOO;
    16 
    17 extern Settings settings;
    18 extern QString vymVersion;
    19 */
    20 
    21 parseBaseHandler::parseBaseHandler() {}
    22 
    23 parseBaseHandler::~parseBaseHandler() {}
    24 
    25 QString parseBaseHandler::errorProtocol() { return errorProt; }
    26 
    27 
    28 /*
    29 bool parseBaseHandler::startDocument()
    30 {
    31     errorProt = "";
    32     state = StateInit;
    33     laststate = StateInit;
    34 	stateStack.clear();
    35 	stateStack.append(StateInit);
    36     branchDepth=0;
    37 	htmldata="";
    38 	isVymPart=false;
    39     return true;
    40 }
    41 */
    42 
    43 QString parseBaseHandler::parseHREF(QString href)
    44 {
    45 	QString type=href.section(":",0,0);
    46 	QString path=href.section(":",1,1);
    47 	if (!tmpDir.endsWith("/"))
    48 		return tmpDir + "/" + path;
    49 	else	
    50 		return tmpDir + path;
    51 }
    52 
    53 
    54 /*
    55 QString parseBaseHandler::errorString() 
    56 {
    57     return "the document is not in the VYM file format";
    58 }
    59 */
    60 
    61 bool parseBaseHandler::fatalError( const QXmlParseException& exception ) 
    62 {
    63     errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
    64     .arg( exception.message() )
    65     .arg( exception.lineNumber() )
    66     .arg( exception.columnNumber() );
    67 	// Try to read the bogus line
    68 	errorProt+=QString("File is: %1\n").arg(inputFile);
    69 	QString s;
    70 	if (loadStringFromDisk (inputFile,s))
    71 	{
    72 		QStringList sl=QStringList::split ("\n",s);
    73 		int i=1;
    74 		QStringList::Iterator it = sl.begin();
    75 		while (i<exception.lineNumber())
    76 		{
    77 			it++;
    78 			i++;
    79 		}
    80 		s=*it;
    81 		s.insert (exception.columnNumber()-1,"<ERROR>");
    82 		errorProt+=s;
    83     }
    84     return QXmlDefaultHandler::fatalError( exception );
    85 }
    86 
    87 void parseBaseHandler::setModel (VymModel *m)
    88 {
    89 	model=m;
    90 }
    91 
    92 void parseBaseHandler::setTmpDir (QString tp)
    93 {
    94 	tmpDir=tp;
    95 }
    96 
    97 void parseBaseHandler::setInputFile (QString f)
    98 {
    99 	inputFile=f;
   100 }
   101 
   102 void parseBaseHandler::setLoadMode (const LoadMode &lm)
   103 {
   104 	loadMode=lm;
   105 }
   106