Added import filter for Freemind
authorinsilmaril
Mon Jul 23 12:42:02 2007 +0000 (2007-07-23)
changeset 564b8f0eefe4351
parent 563 9817b292f4a9
child 565 e7f6bcdf5f6c
Added import filter for Freemind
mainwindow.cpp
mainwindow.h
mapeditor.cpp
     1.1 --- a/mainwindow.cpp	Mon Jul 23 12:42:02 2007 +0000
     1.2 +++ b/mainwindow.cpp	Mon Jul 23 12:42:02 2007 +0000
     1.3 @@ -1332,55 +1332,116 @@
     1.4  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
     1.5  	standardFlagsDefault->addFlag (fo);	
     1.6  
     1.7 +
     1.8  	fo->load(flagsPath+"flag-present.png");
     1.9 -	fo->setName("present");
    1.10 -	a=new QAction (fo->getPixmap(),fo->getName(),this);
    1.11 +	setupFlag (fo,tb,"present",tr("Surprise!","Standardflag"));
    1.12 +
    1.13 +	fo->load(flagsPath+"flag-flash.png");
    1.14 +	setupFlag (fo,tb,"flash",tr("Dangerous","Standardflag"));
    1.15 +	
    1.16 +	// Original: xsldbg_output.png
    1.17 +	fo->load(flagsPath+"flag-info.png");
    1.18 +	setupFlag (fo,tb,"info",tr("Info","Standardflag"));
    1.19 +
    1.20 +	// Original khelpcenter.png
    1.21 +	fo->load(flagsPath+"flag-lifebelt.png");
    1.22 +	setupFlag (fo,tb,"lifebelt",tr("This will help","Standardflag"));
    1.23 +
    1.24 +	// Freemind flags
    1.25 +
    1.26 +	fo->load(flagsPath+"freemind/warning.png");
    1.27 +	setupFlag (fo,tb,"freemind-warning",tr("Important","Freemind-Flag"));
    1.28 +
    1.29 +	for (int i=1; i<8; i++)
    1.30 +	{
    1.31 +		fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
    1.32 +		setupFlag (fo,tb,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
    1.33 +	}
    1.34 +
    1.35 +	fo->load(flagsPath+"freemind/back.png");
    1.36 +	setupFlag (fo,tb,"freemind-back",tr("Back","Freemind-Flag"));
    1.37 +
    1.38 +	fo->load(flagsPath+"freemind/forward.png");
    1.39 +	setupFlag (fo,tb,"freemind-forward",tr("Forward","Freemind-Flag"));
    1.40 +
    1.41 +
    1.42 +	fo->load(flagsPath+"freemind/attach.png");
    1.43 +	setupFlag (fo,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
    1.44 +
    1.45 +
    1.46 +	fo->load(flagsPath+"freemind/clanbomber.png");
    1.47 +	setupFlag (fo,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
    1.48 +
    1.49 +
    1.50 +	fo->load(flagsPath+"freemind/desktopnew.png");
    1.51 +	setupFlag (fo,tb,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
    1.52 +
    1.53 +
    1.54 +	fo->load(flagsPath+"freemind/flag.png");
    1.55 +	setupFlag (fo,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
    1.56 +
    1.57 +
    1.58 +	fo->load(flagsPath+"freemind/gohome.png");
    1.59 +	setupFlag (fo,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
    1.60 +
    1.61 +
    1.62 +	fo->load(flagsPath+"freemind/kaddressbook.png");
    1.63 +	setupFlag (fo,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
    1.64 +
    1.65 +
    1.66 +	fo->load(flagsPath+"freemind/knotify.png");
    1.67 +	setupFlag (fo,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
    1.68 +
    1.69 +
    1.70 +	fo->load(flagsPath+"freemind/korn.png");
    1.71 +	setupFlag (fo,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
    1.72 +
    1.73 +
    1.74 +	fo->load(flagsPath+"freemind/mail.png");
    1.75 +	setupFlag (fo,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
    1.76 +
    1.77 +	fo->load(flagsPath+"freemind/password.png");
    1.78 +	setupFlag (fo,tb,"freemind-password",tr("Password","Freemind-Flag"));
    1.79 +
    1.80 +	fo->load(flagsPath+"freemind/pencil.png");
    1.81 +	setupFlag (fo,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
    1.82 +
    1.83 +	fo->load(flagsPath+"freemind/stop.png");
    1.84 +	setupFlag (fo,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
    1.85 +
    1.86 +	fo->load(flagsPath+"freemind/wizard.png");
    1.87 +	setupFlag (fo,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
    1.88 +
    1.89 +	fo->load(flagsPath+"freemind/xmag.png");
    1.90 +	setupFlag (fo,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
    1.91 +
    1.92 +	fo->load(flagsPath+"freemind/bell.png");
    1.93 +	setupFlag (fo,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
    1.94 +
    1.95 +	fo->load(flagsPath+"freemind/bookmark.png");
    1.96 +	setupFlag (fo,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
    1.97 +
    1.98 +	fo->load(flagsPath+"freemind/penguin.png");
    1.99 +	setupFlag (fo,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
   1.100 +
   1.101 +	fo->load(flagsPath+"freemind/licq.png");
   1.102 +	setupFlag (fo,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
   1.103 +
   1.104 +	delete (fo);
   1.105 +}
   1.106 +
   1.107 +void Main::setupFlag (FlagObj *fo, QToolBar *tb, const QString &name, const QString &tooltip)
   1.108 +{
   1.109 +	fo->setName(name);
   1.110 +	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.111  	tb->addAction (a);
   1.112  	fo->setAction (a);
   1.113  	a->setCheckable(true);
   1.114  	a->setObjectName(fo->getName());
   1.115 -	a->setToolTip(tr("Surprise!","Standardflag"));
   1.116 +	a->setToolTip(tooltip);
   1.117  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.118  	standardFlagsDefault->addFlag (fo);	
   1.119 -
   1.120 -	fo->load(flagsPath+"flag-flash.png");
   1.121 -	fo->setName("flash");
   1.122 -	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.123 -	tb->addAction (a);
   1.124 -	fo->setAction (a);
   1.125 -	a->setCheckable(true);
   1.126 -	a->setObjectName(fo->getName());
   1.127 -	a->setToolTip(tr("Dangerous","Standardflag"));
   1.128 -	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.129 -	standardFlagsDefault->addFlag (fo);	
   1.130 -	
   1.131 -	fo->load(flagsPath+"flag-info.png");
   1.132 -	// Original: xsldbg_output.png
   1.133 -	fo->setName("info");
   1.134 -	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.135 -	tb->addAction (a);
   1.136 -	fo->setAction (a);
   1.137 -	a->setCheckable(true);
   1.138 -	a->setObjectName(fo->getName());
   1.139 -	a->setToolTip(tr("Info","Standardflag"));
   1.140 -	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.141 -	standardFlagsDefault->addFlag (fo);	
   1.142 -
   1.143 -	fo->load(flagsPath+"flag-lifebelt.png");
   1.144 -	// Original khelpcenter.png
   1.145 -	fo->setName("lifebelt");
   1.146 -	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.147 -	tb->addAction (a);
   1.148 -	fo->setAction (a);
   1.149 -	a->setCheckable(true);
   1.150 -	a->setObjectName(fo->getName());
   1.151 -	a->setToolTip(tr("This will help","Standardflag"));
   1.152 -	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.153 -	standardFlagsDefault->addFlag (fo);	
   1.154 -
   1.155 -	delete (fo);
   1.156  }
   1.157 -
   1.158  // Network Actions
   1.159  void Main::setupNetworkActions()
   1.160  {
   1.161 @@ -3649,13 +3710,13 @@
   1.162  void Main::testFunction1()
   1.163  {
   1.164  	if (!currentMapEditor()) return;
   1.165 -	currentMapEditor()->newServer();
   1.166 +	currentMapEditor()->testFunction1();
   1.167  }
   1.168  
   1.169  void Main::testFunction2()
   1.170  {
   1.171  	if (!currentMapEditor()) return;
   1.172 -	currentMapEditor()->connectToServer();
   1.173 +	currentMapEditor()->testFunction2();
   1.174  }
   1.175  
   1.176  void Main::testCommand()
     2.1 --- a/mainwindow.h	Mon Jul 23 12:42:02 2007 +0000
     2.2 +++ b/mainwindow.h	Mon Jul 23 12:42:02 2007 +0000
     2.3 @@ -44,6 +44,7 @@
     2.4      void setupViewActions();
     2.5      void setupModeActions();
     2.6      void setupWindowActions();
     2.7 +    void setupFlag(FlagObj *fo, QToolBar *tb, const QString &name, const QString &tooltip);
     2.8      void setupFlagActions();
     2.9      void setupNetworkActions();
    2.10      void setupSettingsActions();
     3.1 --- a/mapeditor.cpp	Mon Jul 23 12:42:02 2007 +0000
     3.2 +++ b/mapeditor.cpp	Mon Jul 23 12:42:02 2007 +0000
     3.3 @@ -20,6 +20,7 @@
     3.4  #include "texteditor.h"
     3.5  #include "warningdialog.h"
     3.6  #include "xml.h"
     3.7 +#include "xml-fm.h"
     3.8  
     3.9  
    3.10  extern TextEditor *textEditor;
    3.11 @@ -1514,7 +1515,7 @@
    3.12  	}	
    3.13  	
    3.14      
    3.15 -    mapBuilderHandler handler;
    3.16 +    parseVYMHandler handler;
    3.17  	QFile file( fname );
    3.18  
    3.19  	// I am paranoid: file should exist anyway
    3.20 @@ -1721,7 +1722,7 @@
    3.21  QPixmap MapEditor::getPixmap()
    3.22  {
    3.23  	QRectF mapRect=mapCenter->getTotalBBox();
    3.24 -	QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+2);
    3.25 +	QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+1);
    3.26  	QPainter pp (&pix);
    3.27  	
    3.28  	pp.setRenderHints(renderHints());
    3.29 @@ -2132,7 +2133,7 @@
    3.30  	if (d.exists() )
    3.31  	{
    3.32  		// We need to parse saved XML data
    3.33 -		mapBuilderHandler handler;
    3.34 +		parseVYMHandler handler;
    3.35  		QXmlInputSource source( file);
    3.36  		QXmlSimpleReader reader;
    3.37  		reader.setContentHandler( &handler );
    3.38 @@ -2174,7 +2175,7 @@
    3.39  		if (d.exists() )
    3.40  		{
    3.41  			// We need to parse saved XML data
    3.42 -			mapBuilderHandler handler;
    3.43 +			parseVYMHandler handler;
    3.44  			QXmlInputSource source( file);
    3.45  			QXmlSimpleReader reader;
    3.46  			reader.setContentHandler( &handler );
    3.47 @@ -4110,7 +4111,64 @@
    3.48  
    3.49  void MapEditor::testFunction1()
    3.50  {
    3.51 -
    3.52 +	ErrorCode err=success;
    3.53 +	LoadMode lmode=NewMap;
    3.54 +
    3.55 +	//QString fname="test/freemind/doc/freemind.xml";
    3.56 +	QString fname="test/freemind/doc/icons.mm";
    3.57 +    parseFMHandler handler;
    3.58 +	QFile file( fname );
    3.59 +
    3.60 +	// I am paranoid: file should exist anyway
    3.61 +	// according to check in mainwindow.
    3.62 +	if (!file.exists() )
    3.63 +	{
    3.64 +		QMessageBox::critical( 0, tr( "Critical Parse Error" ),
    3.65 +				   tr("Couldn't open map " +fname)+".");
    3.66 +		err=aborted;	
    3.67 +	} else
    3.68 +	{
    3.69 +		bool blockSaveStateOrg=blockSaveState;
    3.70 +		blockReposition=true;
    3.71 +		blockSaveState=true;
    3.72 +		QXmlInputSource source( file);
    3.73 +		QXmlSimpleReader reader;
    3.74 +		reader.setContentHandler( &handler );
    3.75 +		reader.setErrorHandler( &handler );
    3.76 +		handler.setMapEditor( this );
    3.77 +
    3.78 +
    3.79 +		// We need to set the tmpDir in order  to load files with rel. path
    3.80 +		QString tmpdir= fname.left(fname.findRev("/",-1));	
    3.81 +		handler.setTmpDir (tmpdir);
    3.82 +		handler.setInputFile (file.name());
    3.83 +		//handler.setLoadMode (lmode);
    3.84 +		bool ok = reader.parse( source );
    3.85 +		blockReposition=false;
    3.86 +		blockSaveState=blockSaveStateOrg;
    3.87 +		file.close();
    3.88 +		if ( ok ) 
    3.89 +		{
    3.90 +			mapCenter->reposition();
    3.91 +			xelection.update();
    3.92 +			if (lmode==NewMap)
    3.93 +			{
    3.94 +				mapDefault=false;
    3.95 +				mapChanged=false;
    3.96 +				mapUnsaved=false;
    3.97 +				autosaveTimer->stop();
    3.98 +			}
    3.99 +		} else 
   3.100 +		{
   3.101 +			QMessageBox::critical( 0, tr( "Critical Parse Error" ),
   3.102 +					   tr( handler.errorProtocol() ) );
   3.103 +			// returnCode=1;	
   3.104 +			// Still return "success": the map maybe at least
   3.105 +			// partially read by the parser
   3.106 +		}	
   3.107 +	}	
   3.108 +	updateActions();
   3.109 +	//return err;
   3.110  /*
   3.111  	BranchObj *bo=xelection.getBranch();
   3.112  	if (bo) animObjList.append( bo );