# HG changeset patch # User insilmaril # Date 1185194522 0 # Node ID b8f0eefe43513c7b0e39d6a79685f7cd731d03aa # Parent 9817b292f4a99af6a768634ada9f8079c61e97d3 Added import filter for Freemind diff -r 9817b292f4a9 -r b8f0eefe4351 mainwindow.cpp --- a/mainwindow.cpp Mon Jul 23 12:42:02 2007 +0000 +++ b/mainwindow.cpp Mon Jul 23 12:42:02 2007 +0000 @@ -1332,55 +1332,116 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); + fo->load(flagsPath+"flag-present.png"); - fo->setName("present"); - a=new QAction (fo->getPixmap(),fo->getName(),this); + setupFlag (fo,tb,"present",tr("Surprise!","Standardflag")); + + fo->load(flagsPath+"flag-flash.png"); + setupFlag (fo,tb,"flash",tr("Dangerous","Standardflag")); + + // Original: xsldbg_output.png + fo->load(flagsPath+"flag-info.png"); + setupFlag (fo,tb,"info",tr("Info","Standardflag")); + + // Original khelpcenter.png + fo->load(flagsPath+"flag-lifebelt.png"); + setupFlag (fo,tb,"lifebelt",tr("This will help","Standardflag")); + + // Freemind flags + + fo->load(flagsPath+"freemind/warning.png"); + setupFlag (fo,tb,"freemind-warning",tr("Important","Freemind-Flag")); + + for (int i=1; i<8; i++) + { + fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i)); + setupFlag (fo,tb,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag")); + } + + fo->load(flagsPath+"freemind/back.png"); + setupFlag (fo,tb,"freemind-back",tr("Back","Freemind-Flag")); + + fo->load(flagsPath+"freemind/forward.png"); + setupFlag (fo,tb,"freemind-forward",tr("Forward","Freemind-Flag")); + + + fo->load(flagsPath+"freemind/attach.png"); + setupFlag (fo,tb,"freemind-attach",tr("Look here","Freemind-Flag")); + + + fo->load(flagsPath+"freemind/clanbomber.png"); + setupFlag (fo,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag")); + + + fo->load(flagsPath+"freemind/desktopnew.png"); + setupFlag (fo,tb,"freemind-desktopnew",tr("Don't forget","Freemind-Flag")); + + + fo->load(flagsPath+"freemind/flag.png"); + setupFlag (fo,tb,"freemind-flag",tr("Flag","Freemind-Flag")); + + + fo->load(flagsPath+"freemind/gohome.png"); + setupFlag (fo,tb,"freemind-gohome",tr("Home","Freemind-Flag")); + + + fo->load(flagsPath+"freemind/kaddressbook.png"); + setupFlag (fo,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag")); + + + fo->load(flagsPath+"freemind/knotify.png"); + setupFlag (fo,tb,"freemind-knotify",tr("Music","Freemind-Flag")); + + + fo->load(flagsPath+"freemind/korn.png"); + setupFlag (fo,tb,"freemind-korn",tr("Mailbox","Freemind-Flag")); + + + fo->load(flagsPath+"freemind/mail.png"); + setupFlag (fo,tb,"freemind-mail",tr("Maix","Freemind-Flag")); + + fo->load(flagsPath+"freemind/password.png"); + setupFlag (fo,tb,"freemind-password",tr("Password","Freemind-Flag")); + + fo->load(flagsPath+"freemind/pencil.png"); + setupFlag (fo,tb,"freemind-pencil",tr("To be improved","Freemind-Flag")); + + fo->load(flagsPath+"freemind/stop.png"); + setupFlag (fo,tb,"freemind-stop",tr("Stop","Freemind-Flag")); + + fo->load(flagsPath+"freemind/wizard.png"); + setupFlag (fo,tb,"freemind-wizard",tr("Magic","Freemind-Flag")); + + fo->load(flagsPath+"freemind/xmag.png"); + setupFlag (fo,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag")); + + fo->load(flagsPath+"freemind/bell.png"); + setupFlag (fo,tb,"freemind-bell",tr("Reminder","Freemind-Flag")); + + fo->load(flagsPath+"freemind/bookmark.png"); + setupFlag (fo,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag")); + + fo->load(flagsPath+"freemind/penguin.png"); + setupFlag (fo,tb,"freemind-penguin",tr("Linux","Freemind-Flag")); + + fo->load(flagsPath+"freemind/licq.png"); + setupFlag (fo,tb,"freemind-licq",tr("Sweet","Freemind-Flag")); + + delete (fo); +} + +void Main::setupFlag (FlagObj *fo, QToolBar *tb, const QString &name, const QString &tooltip) +{ + fo->setName(name); + QAction *a=new QAction (fo->getPixmap(),fo->getName(),this); tb->addAction (a); fo->setAction (a); a->setCheckable(true); a->setObjectName(fo->getName()); - a->setToolTip(tr("Surprise!","Standardflag")); + a->setToolTip(tooltip); connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - - fo->load(flagsPath+"flag-flash.png"); - fo->setName("flash"); - a=new QAction (fo->getPixmap(),fo->getName(),this); - tb->addAction (a); - fo->setAction (a); - a->setCheckable(true); - a->setObjectName(fo->getName()); - a->setToolTip(tr("Dangerous","Standardflag")); - connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); - standardFlagsDefault->addFlag (fo); - - fo->load(flagsPath+"flag-info.png"); - // Original: xsldbg_output.png - fo->setName("info"); - a=new QAction (fo->getPixmap(),fo->getName(),this); - tb->addAction (a); - fo->setAction (a); - a->setCheckable(true); - a->setObjectName(fo->getName()); - a->setToolTip(tr("Info","Standardflag")); - connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); - standardFlagsDefault->addFlag (fo); - - fo->load(flagsPath+"flag-lifebelt.png"); - // Original khelpcenter.png - fo->setName("lifebelt"); - a=new QAction (fo->getPixmap(),fo->getName(),this); - tb->addAction (a); - fo->setAction (a); - a->setCheckable(true); - a->setObjectName(fo->getName()); - a->setToolTip(tr("This will help","Standardflag")); - connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); - standardFlagsDefault->addFlag (fo); - - delete (fo); } - // Network Actions void Main::setupNetworkActions() { @@ -3649,13 +3710,13 @@ void Main::testFunction1() { if (!currentMapEditor()) return; - currentMapEditor()->newServer(); + currentMapEditor()->testFunction1(); } void Main::testFunction2() { if (!currentMapEditor()) return; - currentMapEditor()->connectToServer(); + currentMapEditor()->testFunction2(); } void Main::testCommand() diff -r 9817b292f4a9 -r b8f0eefe4351 mainwindow.h --- a/mainwindow.h Mon Jul 23 12:42:02 2007 +0000 +++ b/mainwindow.h Mon Jul 23 12:42:02 2007 +0000 @@ -44,6 +44,7 @@ void setupViewActions(); void setupModeActions(); void setupWindowActions(); + void setupFlag(FlagObj *fo, QToolBar *tb, const QString &name, const QString &tooltip); void setupFlagActions(); void setupNetworkActions(); void setupSettingsActions(); diff -r 9817b292f4a9 -r b8f0eefe4351 mapeditor.cpp --- a/mapeditor.cpp Mon Jul 23 12:42:02 2007 +0000 +++ b/mapeditor.cpp Mon Jul 23 12:42:02 2007 +0000 @@ -20,6 +20,7 @@ #include "texteditor.h" #include "warningdialog.h" #include "xml.h" +#include "xml-fm.h" extern TextEditor *textEditor; @@ -1514,7 +1515,7 @@ } - mapBuilderHandler handler; + parseVYMHandler handler; QFile file( fname ); // I am paranoid: file should exist anyway @@ -1721,7 +1722,7 @@ QPixmap MapEditor::getPixmap() { QRectF mapRect=mapCenter->getTotalBBox(); - QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+2); + QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+1); QPainter pp (&pix); pp.setRenderHints(renderHints()); @@ -2132,7 +2133,7 @@ if (d.exists() ) { // We need to parse saved XML data - mapBuilderHandler handler; + parseVYMHandler handler; QXmlInputSource source( file); QXmlSimpleReader reader; reader.setContentHandler( &handler ); @@ -2174,7 +2175,7 @@ if (d.exists() ) { // We need to parse saved XML data - mapBuilderHandler handler; + parseVYMHandler handler; QXmlInputSource source( file); QXmlSimpleReader reader; reader.setContentHandler( &handler ); @@ -4110,7 +4111,64 @@ void MapEditor::testFunction1() { - + ErrorCode err=success; + LoadMode lmode=NewMap; + + //QString fname="test/freemind/doc/freemind.xml"; + QString fname="test/freemind/doc/icons.mm"; + parseFMHandler handler; + QFile file( fname ); + + // I am paranoid: file should exist anyway + // according to check in mainwindow. + if (!file.exists() ) + { + QMessageBox::critical( 0, tr( "Critical Parse Error" ), + tr("Couldn't open map " +fname)+"."); + err=aborted; + } else + { + bool blockSaveStateOrg=blockSaveState; + blockReposition=true; + blockSaveState=true; + QXmlInputSource source( file); + QXmlSimpleReader reader; + reader.setContentHandler( &handler ); + reader.setErrorHandler( &handler ); + handler.setMapEditor( this ); + + + // We need to set the tmpDir in order to load files with rel. path + QString tmpdir= fname.left(fname.findRev("/",-1)); + handler.setTmpDir (tmpdir); + handler.setInputFile (file.name()); + //handler.setLoadMode (lmode); + bool ok = reader.parse( source ); + blockReposition=false; + blockSaveState=blockSaveStateOrg; + file.close(); + if ( ok ) + { + mapCenter->reposition(); + xelection.update(); + if (lmode==NewMap) + { + mapDefault=false; + mapChanged=false; + mapUnsaved=false; + autosaveTimer->stop(); + } + } else + { + QMessageBox::critical( 0, tr( "Critical Parse Error" ), + tr( handler.errorProtocol() ) ); + // returnCode=1; + // Still return "success": the map maybe at least + // partially read by the parser + } + } + updateActions(); + //return err; /* BranchObj *bo=xelection.getBranch(); if (bo) animObjList.append( bo );