# HG changeset patch # User insilmaril # Date 1185194522 0 # Node ID ebebedffba5089a192679ec905eb16159394430b # Parent e7f6bcdf5f6c46cbcef626e00f8c48c2e97e47bf Added import filter for Freemind diff -r e7f6bcdf5f6c -r ebebedffba50 version.h --- a/version.h Mon Jul 23 12:42:02 2007 +0000 +++ b/version.h Mon Jul 23 12:42:02 2007 +0000 @@ -4,12 +4,13 @@ #include #define __VYM_NAME "VYM" -#define __VYM_VERSION "1.9.2" +#define __VYM_VERSION "1.9.3" //#define __VYM_CODENAME "Codename: 1.10.0-beta-1" #define __VYM_CODENAME "Codename: development version" -#define __VYM_BUILD_DATE "July 16, 2007" +#define __VYM_BUILD_DATE "July 23, 2007" bool checkVersion(const QString &); +bool checkVersion(const QString &, const QString &); #endif diff -r e7f6bcdf5f6c -r ebebedffba50 vym.pro --- a/vym.pro Mon Jul 23 12:42:02 2007 +0000 +++ b/vym.pro Mon Jul 23 12:42:02 2007 +0000 @@ -48,6 +48,7 @@ texteditor.h \ version.h \ xml.h \ + xml-freemind.h \ xsltproc.h \ settings.h \ warningdialog.h @@ -93,6 +94,7 @@ texteditor.cpp \ version.cpp \ xml.cpp \ + xml-freemind.cpp \ xsltproc.cpp \ settings.cpp \ warningdialog.cpp diff -r e7f6bcdf5f6c -r ebebedffba50 xml-freemind.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xml-freemind.cpp Mon Jul 23 12:42:02 2007 +0000 @@ -0,0 +1,330 @@ +#include "xml-freemind.h" + +#include +#include +#include +#include + +#include "misc.h" +#include "settings.h" +#include "linkablemapobj.h" +#include "version.h" + +static BranchObj *lastBranch; +static FloatObj *lastFloat; +static OrnamentedObj *lastOO; + +extern Settings settings; +extern QString vymVersion; + +extern QString flagsPath; + +parseFMHandler::parseFMHandler() {} + +parseFMHandler::~parseFMHandler() {} + +QString parseFMHandler::errorProtocol() { return errorProt; } + + +bool parseFMHandler::startDocument() +{ + errorProt = ""; + state = StateInit; + laststate = StateInit; + stateStack.clear(); + stateStack.append(StateInit); + branchDepth=0; + htmldata=""; + isVymPart=false; + return true; +} + + +QString parseFMHandler::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 parseFMHandler::startElement ( const QString&, const QString&, + const QString& eName, const QXmlAttributes& atts ) +{ + QColor col; + /* Testing + cout << "startElement <"<< eName.ascii() + <<"> state="<Freemind map is newer than version " +v +" " + "

The map you are just trying to load was " + "saved using freemind " +atts.value("version")+". " + "The version of this vym can parse freemind " + v +"."); + } + mc->addBranch(); + lastBranch=mc->getLastBranch(); + lastBranch->move2RelPos (200,0); + lastBranch->setHeading (" "); + mc->addBranch(); + lastBranch=mc->getLastBranch(); + lastBranch->move2RelPos (-200,0); + lastBranch->setHeading (" "); + lastBranch=mc; + + } else if ( eName == "node" && (state == StateMap || state == StateNode )) + { + if (!atts.value( "POSITION").isEmpty() ) + { + if (atts.value ("POSITION")=="left") + { + me->select ("bo:1"); + lastBranch=me->getSelectedBranch(); + if (lastBranch) + { + lastBranch->addBranch(); + lastBranch=lastBranch->getLastBranch(); + readNodeAttr (atts); + } + } else if (atts.value ("POSITION")=="right") + { + me->select ("bo:0"); + lastBranch=me->getSelectedBranch(); + if (lastBranch) + { + lastBranch->addBranch(); + lastBranch=lastBranch->getLastBranch(); + readNodeAttr (atts); + } + } + } else + { + if (state!=StateMap) + { + lastBranch->addBranch(); + lastBranch=lastBranch->getLastBranch(); + } + readNodeAttr (atts); + } + state=StateNode; + } else if ( eName == "font" && state == StateNode) + { + state=StateFont; + } else if ( eName == "edge" && state == StateNode) + { + state=StateEdge; + } else if ( eName == "hook" && state == StateNode) + { + state=StateHook; + } else if ( eName == "icon" && state == StateNode) + { + state=StateIcon; + if (!atts.value("BUILTIN").isEmpty() ) + { + QString f=atts.value("BUILTIN"); + QString v; + if (f=="help") + v="questionmark"; + else if (f=="messagebox_warning") + v="freemind-warning"; + else if (f=="idea") + v="lamp"; + else if (f=="button_ok") + v="hook-green"; + else if (f=="button_cancel") + v="cross-red"; + else if (f.contains("full-")) + v=f.replace("full-","freemind-priority-"); //FIXME + else if (f=="back") + v="freemind-back"; + else if (f=="forward") + v="freemind-forward"; + else if (f=="attach") + v="freemind-attach"; + else if (f=="ksmiletris") + v="smiley-good"; // + else if (f=="clanbomber") + v="freemind-clanbomber"; + else if (f=="desktop_new") + v="freemind-desktopnew"; + else if (f=="flag") + v="freemind-flag"; + else if (f=="gohome") + v="freemind-gohome"; + else if (f=="kaddressbook") + v="freemind-kaddressbook"; + else if (f=="knotify") + v="freemind-knotify"; + else if (f=="korn") + v="freemind-korn"; + else if (f=="Mail") + v="freemind-mail"; + else if (f=="password") + v="freemind-password"; + else if (f=="pencil") + v="freemind-pencil"; + else if (f=="stop") + v="freemind-stop"; + else if (f=="wizard") + v="freemind-wizard"; + else if (f=="xmag") + v="freemind-xmag"; + else if (f=="bell") + v="freemind-bell"; + else if (f=="bookmark") + v="freemind-bookmark"; + else if (f=="penguin") + v="freemind-penguin"; + else if (f=="licq") + v="freemind-licq"; + + lastBranch->activateStandardFlag( v); + } + } else if ( eName == "arrowlink" && state == StateNode) + { + state=StateArrowLink; + } else if ( eName == "cloud" && state == StateNode) + { + state=StateCloud; + } else if ( eName == "text" && state == StateHook) + { + state=StateText; + } else + return false; // Error + return true; +} + +bool parseFMHandler::endElement ( const QString&, const QString&, const QString &eName) +{ + /* Testing + cout << "endElement state=" <"); + errorProt+=s; + } + return QXmlDefaultHandler::fatalError( exception ); +} + +void parseFMHandler::setMapEditor (MapEditor* e) +{ + me=e; + mc=me->getMapCenter(); +} + +void parseFMHandler::setTmpDir (QString tp) +{ + tmpDir=tp; +} + +void parseFMHandler::setInputFile (QString f) +{ + inputFile=f; +} + +void parseFMHandler::setLoadMode (const LoadMode &lm) +{ + loadMode=lm; +} + +bool parseFMHandler::readNodeAttr (const QXmlAttributes& a) +{ + lastOO=lastBranch; + + if (a.value( "FOLDED")=="true" ) + lastBranch->toggleScroll(); + if (!a.value( "TEXT").isEmpty() ) + lastBranch->setHeading (a.value ("TEXT")); + + if (!a.value( "COLOR").isEmpty() ) + lastBranch->setColor (QColor (a.value ("COLOR"))); + + if (!a.value( "LINK").isEmpty() ) + lastBranch->setURL (a.value ("LINK")); + + return true; +} + + diff -r e7f6bcdf5f6c -r ebebedffba50 xml-freemind.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xml-freemind.h Mon Jul 23 12:42:02 2007 +0000 @@ -0,0 +1,63 @@ +#ifndef XML_FREEMIND_H +#define XML_FREEMIND_H + + +#include +#include + +#include "file.h" +#include "mapcenterobj.h" +#include "mapeditor.h" + + +class parseFMHandler : public QXmlDefaultHandler +{ +public: + parseFMHandler(); + ~parseFMHandler(); + QString errorProtocol(); + bool startDocument(); + QString parseHREF(QString); + bool startElement ( const QString&, const QString&, + const QString& eName, const QXmlAttributes& atts ); + bool endElement ( const QString&, const QString&, const QString& ); + bool characters ( const QString&); + QString errorString(); + bool fatalError( const QXmlParseException&); + void setMapEditor (MapEditor*); + void setTmpDir (QString); + void setInputFile (QString); + void setLoadMode (const LoadMode &); + bool readNodeAttr (const QXmlAttributes&); + +private: + QString errorProt; + enum State + { + StateInit, + StateMap, + StateNode, + StateCloud, + StateEdge, + StateIcon, + StateFont, + StateArrowLink, + StateHook, + StateText + }; + + + LoadMode loadMode; + bool isVymPart; + State state; + State laststate; + QList stateStack; + QString htmldata; + int branchDepth; + NoteObj no; + MapCenterObj* mc; + MapEditor* me; + QString tmpDir; + QString inputFile; +}; +#endif