1.1 --- a/version.h Mon Jul 23 12:42:02 2007 +0000
1.2 +++ b/version.h Mon Jul 23 12:42:02 2007 +0000
1.3 @@ -4,12 +4,13 @@
1.4 #include <QString>
1.5
1.6 #define __VYM_NAME "VYM"
1.7 -#define __VYM_VERSION "1.9.2"
1.8 +#define __VYM_VERSION "1.9.3"
1.9 //#define __VYM_CODENAME "Codename: 1.10.0-beta-1"
1.10 #define __VYM_CODENAME "Codename: development version"
1.11 -#define __VYM_BUILD_DATE "July 16, 2007"
1.12 +#define __VYM_BUILD_DATE "July 23, 2007"
1.13
1.14
1.15 bool checkVersion(const QString &);
1.16 +bool checkVersion(const QString &, const QString &);
1.17
1.18 #endif
2.1 --- a/vym.pro Mon Jul 23 12:42:02 2007 +0000
2.2 +++ b/vym.pro Mon Jul 23 12:42:02 2007 +0000
2.3 @@ -48,6 +48,7 @@
2.4 texteditor.h \
2.5 version.h \
2.6 xml.h \
2.7 + xml-freemind.h \
2.8 xsltproc.h \
2.9 settings.h \
2.10 warningdialog.h
2.11 @@ -93,6 +94,7 @@
2.12 texteditor.cpp \
2.13 version.cpp \
2.14 xml.cpp \
2.15 + xml-freemind.cpp \
2.16 xsltproc.cpp \
2.17 settings.cpp \
2.18 warningdialog.cpp
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/xml-freemind.cpp Mon Jul 23 12:42:02 2007 +0000
3.3 @@ -0,0 +1,330 @@
3.4 +#include "xml-freemind.h"
3.5 +
3.6 +#include <QMessageBox>
3.7 +#include <QColor>
3.8 +#include <QTextStream>
3.9 +#include <iostream>
3.10 +
3.11 +#include "misc.h"
3.12 +#include "settings.h"
3.13 +#include "linkablemapobj.h"
3.14 +#include "version.h"
3.15 +
3.16 +static BranchObj *lastBranch;
3.17 +static FloatObj *lastFloat;
3.18 +static OrnamentedObj *lastOO;
3.19 +
3.20 +extern Settings settings;
3.21 +extern QString vymVersion;
3.22 +
3.23 +extern QString flagsPath;
3.24 +
3.25 +parseFMHandler::parseFMHandler() {}
3.26 +
3.27 +parseFMHandler::~parseFMHandler() {}
3.28 +
3.29 +QString parseFMHandler::errorProtocol() { return errorProt; }
3.30 +
3.31 +
3.32 +bool parseFMHandler::startDocument()
3.33 +{
3.34 + errorProt = "";
3.35 + state = StateInit;
3.36 + laststate = StateInit;
3.37 + stateStack.clear();
3.38 + stateStack.append(StateInit);
3.39 + branchDepth=0;
3.40 + htmldata="";
3.41 + isVymPart=false;
3.42 + return true;
3.43 +}
3.44 +
3.45 +
3.46 +QString parseFMHandler::parseHREF(QString href)
3.47 +{
3.48 + QString type=href.section(":",0,0);
3.49 + QString path=href.section(":",1,1);
3.50 + if (!tmpDir.endsWith("/"))
3.51 + return tmpDir + "/" + path;
3.52 + else
3.53 + return tmpDir + path;
3.54 +}
3.55 +
3.56 +bool parseFMHandler::startElement ( const QString&, const QString&,
3.57 + const QString& eName, const QXmlAttributes& atts )
3.58 +{
3.59 + QColor col;
3.60 + /* Testing
3.61 + cout << "startElement <"<< eName.ascii()
3.62 + <<"> state="<<state
3.63 + <<" laststate="<<stateStack.last()
3.64 + <<" loadMode="<<loadMode
3.65 + // <<" line="<<QXmlDefaultHandler::lineNumber().ascii()
3.66 + <<endl;
3.67 + */
3.68 + stateStack.append (state);
3.69 + if ( state == StateInit && (eName == "map") )
3.70 + {
3.71 + state = StateMap;
3.72 + if (!atts.value( "version").isEmpty() )
3.73 + {
3.74 + QString v="0.8.0";
3.75 + if (!checkVersion(atts.value("version"),v))
3.76 + QMessageBox::warning( 0, "Warning: Version Problem" ,
3.77 + "<h3>Freemind map is newer than version " +v +" </h3>"
3.78 + "<p>The map you are just trying to load was "
3.79 + "saved using freemind " +atts.value("version")+". "
3.80 + "The version of this vym can parse freemind " + v +".");
3.81 + }
3.82 + mc->addBranch();
3.83 + lastBranch=mc->getLastBranch();
3.84 + lastBranch->move2RelPos (200,0);
3.85 + lastBranch->setHeading (" ");
3.86 + mc->addBranch();
3.87 + lastBranch=mc->getLastBranch();
3.88 + lastBranch->move2RelPos (-200,0);
3.89 + lastBranch->setHeading (" ");
3.90 + lastBranch=mc;
3.91 +
3.92 + } else if ( eName == "node" && (state == StateMap || state == StateNode ))
3.93 + {
3.94 + if (!atts.value( "POSITION").isEmpty() )
3.95 + {
3.96 + if (atts.value ("POSITION")=="left")
3.97 + {
3.98 + me->select ("bo:1");
3.99 + lastBranch=me->getSelectedBranch();
3.100 + if (lastBranch)
3.101 + {
3.102 + lastBranch->addBranch();
3.103 + lastBranch=lastBranch->getLastBranch();
3.104 + readNodeAttr (atts);
3.105 + }
3.106 + } else if (atts.value ("POSITION")=="right")
3.107 + {
3.108 + me->select ("bo:0");
3.109 + lastBranch=me->getSelectedBranch();
3.110 + if (lastBranch)
3.111 + {
3.112 + lastBranch->addBranch();
3.113 + lastBranch=lastBranch->getLastBranch();
3.114 + readNodeAttr (atts);
3.115 + }
3.116 + }
3.117 + } else
3.118 + {
3.119 + if (state!=StateMap)
3.120 + {
3.121 + lastBranch->addBranch();
3.122 + lastBranch=lastBranch->getLastBranch();
3.123 + }
3.124 + readNodeAttr (atts);
3.125 + }
3.126 + state=StateNode;
3.127 + } else if ( eName == "font" && state == StateNode)
3.128 + {
3.129 + state=StateFont;
3.130 + } else if ( eName == "edge" && state == StateNode)
3.131 + {
3.132 + state=StateEdge;
3.133 + } else if ( eName == "hook" && state == StateNode)
3.134 + {
3.135 + state=StateHook;
3.136 + } else if ( eName == "icon" && state == StateNode)
3.137 + {
3.138 + state=StateIcon;
3.139 + if (!atts.value("BUILTIN").isEmpty() )
3.140 + {
3.141 + QString f=atts.value("BUILTIN");
3.142 + QString v;
3.143 + if (f=="help")
3.144 + v="questionmark";
3.145 + else if (f=="messagebox_warning")
3.146 + v="freemind-warning";
3.147 + else if (f=="idea")
3.148 + v="lamp";
3.149 + else if (f=="button_ok")
3.150 + v="hook-green";
3.151 + else if (f=="button_cancel")
3.152 + v="cross-red";
3.153 + else if (f.contains("full-"))
3.154 + v=f.replace("full-","freemind-priority-"); //FIXME
3.155 + else if (f=="back")
3.156 + v="freemind-back";
3.157 + else if (f=="forward")
3.158 + v="freemind-forward";
3.159 + else if (f=="attach")
3.160 + v="freemind-attach";
3.161 + else if (f=="ksmiletris")
3.162 + v="smiley-good"; //
3.163 + else if (f=="clanbomber")
3.164 + v="freemind-clanbomber";
3.165 + else if (f=="desktop_new")
3.166 + v="freemind-desktopnew";
3.167 + else if (f=="flag")
3.168 + v="freemind-flag";
3.169 + else if (f=="gohome")
3.170 + v="freemind-gohome";
3.171 + else if (f=="kaddressbook")
3.172 + v="freemind-kaddressbook";
3.173 + else if (f=="knotify")
3.174 + v="freemind-knotify";
3.175 + else if (f=="korn")
3.176 + v="freemind-korn";
3.177 + else if (f=="Mail")
3.178 + v="freemind-mail";
3.179 + else if (f=="password")
3.180 + v="freemind-password";
3.181 + else if (f=="pencil")
3.182 + v="freemind-pencil";
3.183 + else if (f=="stop")
3.184 + v="freemind-stop";
3.185 + else if (f=="wizard")
3.186 + v="freemind-wizard";
3.187 + else if (f=="xmag")
3.188 + v="freemind-xmag";
3.189 + else if (f=="bell")
3.190 + v="freemind-bell";
3.191 + else if (f=="bookmark")
3.192 + v="freemind-bookmark";
3.193 + else if (f=="penguin")
3.194 + v="freemind-penguin";
3.195 + else if (f=="licq")
3.196 + v="freemind-licq";
3.197 +
3.198 + lastBranch->activateStandardFlag( v);
3.199 + }
3.200 + } else if ( eName == "arrowlink" && state == StateNode)
3.201 + {
3.202 + state=StateArrowLink;
3.203 + } else if ( eName == "cloud" && state == StateNode)
3.204 + {
3.205 + state=StateCloud;
3.206 + } else if ( eName == "text" && state == StateHook)
3.207 + {
3.208 + state=StateText;
3.209 + } else
3.210 + return false; // Error
3.211 + return true;
3.212 +}
3.213 +
3.214 +bool parseFMHandler::endElement ( const QString&, const QString&, const QString &eName)
3.215 +{
3.216 + /* Testing
3.217 + cout << "endElement </" <<eName.ascii()
3.218 + <<"> state=" <<state
3.219 + <<" laststate=" <<laststate
3.220 + <<" stateStack="<<stateStack.last()
3.221 + <<endl;
3.222 + */
3.223 + switch ( state )
3.224 + {
3.225 + case StateNode:
3.226 + lastBranch=(BranchObj*)(lastBranch->getParObj());
3.227 + break;
3.228 + default:
3.229 + break;
3.230 + }
3.231 + state=stateStack.takeLast();
3.232 + return true;
3.233 +}
3.234 +
3.235 +bool parseFMHandler::characters ( const QString& ch)
3.236 +{
3.237 + //cout << "characters \""<<ch.ascii()<<"\" state="<<state <<" laststate="<<laststate<<endl;
3.238 +
3.239 + QString ch_org=quotemeta (ch);
3.240 + QString ch_simplified=ch.simplifyWhiteSpace();
3.241 + if ( ch_simplified.isEmpty() ) return true;
3.242 +
3.243 + switch ( state )
3.244 + {
3.245 + case StateInit: break;
3.246 + case StateMap: break;
3.247 + case StateNode: break;
3.248 + case StateCloud: break;
3.249 + case StateEdge: break;
3.250 + case StateIcon: break;
3.251 + case StateArrowLink: break;
3.252 + case StateFont: break;
3.253 + case StateHook: break;
3.254 + case StateText:
3.255 + lastBranch->setNote (ch_simplified);
3.256 + break;
3.257 + default:
3.258 + return false;
3.259 + }
3.260 + return true;
3.261 +}
3.262 +
3.263 +QString parseFMHandler::errorString()
3.264 +{
3.265 + return "the document is not in the VYM file format";
3.266 +}
3.267 +
3.268 +bool parseFMHandler::fatalError( const QXmlParseException& exception )
3.269 +{
3.270 + errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
3.271 + .arg( exception.message() )
3.272 + .arg( exception.lineNumber() )
3.273 + .arg( exception.columnNumber() );
3.274 + // Try to read the bogus line
3.275 + errorProt+=QString("File is: %1\n").arg(inputFile);
3.276 + QString s;
3.277 + if (loadStringFromDisk (inputFile,s))
3.278 + {
3.279 + QStringList sl=QStringList::split ("\n",s);
3.280 + int i=1;
3.281 + QStringList::Iterator it = sl.begin();
3.282 + while (i<exception.lineNumber())
3.283 + {
3.284 + it++;
3.285 + i++;
3.286 + }
3.287 + s=*it;
3.288 + s.insert (exception.columnNumber()-1,"<ERROR>");
3.289 + errorProt+=s;
3.290 + }
3.291 + return QXmlDefaultHandler::fatalError( exception );
3.292 +}
3.293 +
3.294 +void parseFMHandler::setMapEditor (MapEditor* e)
3.295 +{
3.296 + me=e;
3.297 + mc=me->getMapCenter();
3.298 +}
3.299 +
3.300 +void parseFMHandler::setTmpDir (QString tp)
3.301 +{
3.302 + tmpDir=tp;
3.303 +}
3.304 +
3.305 +void parseFMHandler::setInputFile (QString f)
3.306 +{
3.307 + inputFile=f;
3.308 +}
3.309 +
3.310 +void parseFMHandler::setLoadMode (const LoadMode &lm)
3.311 +{
3.312 + loadMode=lm;
3.313 +}
3.314 +
3.315 +bool parseFMHandler::readNodeAttr (const QXmlAttributes& a)
3.316 +{
3.317 + lastOO=lastBranch;
3.318 +
3.319 + if (a.value( "FOLDED")=="true" )
3.320 + lastBranch->toggleScroll();
3.321 + if (!a.value( "TEXT").isEmpty() )
3.322 + lastBranch->setHeading (a.value ("TEXT"));
3.323 +
3.324 + if (!a.value( "COLOR").isEmpty() )
3.325 + lastBranch->setColor (QColor (a.value ("COLOR")));
3.326 +
3.327 + if (!a.value( "LINK").isEmpty() )
3.328 + lastBranch->setURL (a.value ("LINK"));
3.329 +
3.330 + return true;
3.331 +}
3.332 +
3.333 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/xml-freemind.h Mon Jul 23 12:42:02 2007 +0000
4.3 @@ -0,0 +1,63 @@
4.4 +#ifndef XML_FREEMIND_H
4.5 +#define XML_FREEMIND_H
4.6 +
4.7 +
4.8 +#include <QString>
4.9 +#include <QXmlAttributes>
4.10 +
4.11 +#include "file.h"
4.12 +#include "mapcenterobj.h"
4.13 +#include "mapeditor.h"
4.14 +
4.15 +
4.16 +class parseFMHandler : public QXmlDefaultHandler
4.17 +{
4.18 +public:
4.19 + parseFMHandler();
4.20 + ~parseFMHandler();
4.21 + QString errorProtocol();
4.22 + bool startDocument();
4.23 + QString parseHREF(QString);
4.24 + bool startElement ( const QString&, const QString&,
4.25 + const QString& eName, const QXmlAttributes& atts );
4.26 + bool endElement ( const QString&, const QString&, const QString& );
4.27 + bool characters ( const QString&);
4.28 + QString errorString();
4.29 + bool fatalError( const QXmlParseException&);
4.30 + void setMapEditor (MapEditor*);
4.31 + void setTmpDir (QString);
4.32 + void setInputFile (QString);
4.33 + void setLoadMode (const LoadMode &);
4.34 + bool readNodeAttr (const QXmlAttributes&);
4.35 +
4.36 +private:
4.37 + QString errorProt;
4.38 + enum State
4.39 + {
4.40 + StateInit,
4.41 + StateMap,
4.42 + StateNode,
4.43 + StateCloud,
4.44 + StateEdge,
4.45 + StateIcon,
4.46 + StateFont,
4.47 + StateArrowLink,
4.48 + StateHook,
4.49 + StateText
4.50 + };
4.51 +
4.52 +
4.53 + LoadMode loadMode;
4.54 + bool isVymPart;
4.55 + State state;
4.56 + State laststate;
4.57 + QList <State> stateStack;
4.58 + QString htmldata;
4.59 + int branchDepth;
4.60 + NoteObj no;
4.61 + MapCenterObj* mc;
4.62 + MapEditor* me;
4.63 + QString tmpDir;
4.64 + QString inputFile;
4.65 +};
4.66 +#endif