More bugfixes, simple csv export
authorinsilmaril
Wed May 30 15:23:07 2007 +0000 (2007-05-30)
changeset 497ab118b86bc54
parent 496 1fc21685e3ea
child 498 2c40ff8ca7ba
More bugfixes, simple csv export
demos/todo.vym
exports.cpp
exports.h
linkablemapobj.cpp
mainwindow.cpp
mainwindow.h
mapeditor.cpp
texteditor.cpp
     1.1 Binary file demos/todo.vym has changed
     2.1 --- a/exports.cpp	Mon May 21 13:05:26 2007 +0000
     2.2 +++ b/exports.cpp	Wed May 30 15:23:07 2007 +0000
     2.3 @@ -111,7 +111,6 @@
     2.4  		return r + " ";
     2.5  }
     2.6  
     2.7 -
     2.8  ////////////////////////////////////////////////////////////////////////
     2.9  void ExportASCII::doExport()
    2.10  {
    2.11 @@ -131,7 +130,6 @@
    2.12  	bo=mapCenter->first();
    2.13  	while (bo) 
    2.14  	{
    2.15 -		cout << "export bo="<<bo->getHeading().ascii()<<endl;
    2.16  		// Make indentstring
    2.17  		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
    2.18  
    2.19 @@ -162,6 +160,50 @@
    2.20  	file.close();
    2.21  }
    2.22  
    2.23 +
    2.24 +////////////////////////////////////////////////////////////////////////
    2.25 +void ExportCSV::doExport()
    2.26 +{
    2.27 +	QFile file (outputFile);
    2.28 +	if ( !file.open( QIODevice::WriteOnly ) )
    2.29 +	{
    2.30 +		qWarning ("ExportBase::exportXML  couldn't open "+outputFile);
    2.31 +		return;
    2.32 +	}
    2.33 +	QTextStream ts( &file );	// use LANG decoding here...
    2.34 +
    2.35 +	// Write header
    2.36 +	ts << "\"Note\""  <<endl;
    2.37 +
    2.38 +	// Main loop over all branches
    2.39 +	QString s;
    2.40 +	QString actIndent("");
    2.41 +	int i,j;
    2.42 +	BranchObj *bo;
    2.43 +	bo=mapCenter->first();
    2.44 +	while (bo) 
    2.45 +	{
    2.46 +		// If necessary, write note
    2.47 +		if (!bo->getNote().isEmpty())
    2.48 +		{
    2.49 +			s =bo->getNoteASCII();
    2.50 +			s=s.replace ("\n","\n"+actIndent);
    2.51 +			ts << ("\""+s+"\",");
    2.52 +		} else
    2.53 +			ts <<"\"\",";
    2.54 +
    2.55 +		// Make indentstring
    2.56 +		for (i=0;i<bo->getDepth();i++) actIndent+= "\"\",";
    2.57 +
    2.58 +		// Write heading
    2.59 +		ts << actIndent << "\"" << bo->getHeading()<<"\""<<endl;
    2.60 +		
    2.61 +		bo=bo->next();
    2.62 +		actIndent="";
    2.63 +	}
    2.64 +	file.close();
    2.65 +}
    2.66 +
    2.67  ////////////////////////////////////////////////////////////////////////
    2.68  void ExportKDEBookmarks::doExport() 
    2.69  {
     3.1 --- a/exports.h	Mon May 21 13:05:26 2007 +0000
     3.2 +++ b/exports.h	Wed May 30 15:23:07 2007 +0000
     3.3 @@ -45,6 +45,13 @@
     3.4  };
     3.5  
     3.6  ///////////////////////////////////////////////////////////////////////
     3.7 +class ExportCSV:public ExportBase
     3.8 +{
     3.9 +public:
    3.10 +	virtual void doExport();
    3.11 +};
    3.12 +
    3.13 +///////////////////////////////////////////////////////////////////////
    3.14  class ExportXMLBase:public ExportBase
    3.15  {
    3.16  };
     4.1 --- a/linkablemapobj.cpp	Mon May 21 13:05:26 2007 +0000
     4.2 +++ b/linkablemapobj.cpp	Wed May 30 15:23:07 2007 +0000
     4.3 @@ -319,9 +319,11 @@
     4.4  			break;
     4.5  		case PolyLine:
     4.6  			p->setBrush( QBrush(col));
     4.7 +			p->setPen( pen);
     4.8  			break;
     4.9  		case PolyParabel:	
    4.10  			p->setBrush( QBrush(col));
    4.11 +			p->setPen( pen);
    4.12  			break;
    4.13  		default:
    4.14  			break;
     5.1 --- a/mainwindow.cpp	Mon May 21 13:05:26 2007 +0000
     5.2 +++ b/mainwindow.cpp	Wed May 30 15:23:07 2007 +0000
     5.3 @@ -341,6 +341,11 @@
     5.4      connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
     5.5  	fileExportMenu->addAction (a);
     5.6  
     5.7 +    a = new QAction( "Spreadsheet (CSV)...", this);
     5.8 +	a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
     5.9 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
    5.10 +	fileExportMenu->addAction (a);
    5.11 +
    5.12  	a = new QAction( tr("KDE Bookmarks","File menu"), this);
    5.13  	a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
    5.14  	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
    5.15 @@ -2364,6 +2369,25 @@
    5.16  	}
    5.17  }
    5.18  
    5.19 +void Main::fileExportCSV()
    5.20 +{
    5.21 +	MapEditor *me=currentMapEditor();
    5.22 +	if (me)
    5.23 +	{
    5.24 +		ExportCSV ex;
    5.25 +		ex.setMapCenter(me->getMapCenter());
    5.26 +		ex.addFilter ("CSV (*.csv)");
    5.27 +		ex.setDir(lastImageDir);
    5.28 +		ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
    5.29 +		if (ex.execDialog() ) 
    5.30 +		{
    5.31 +			me->setExportMode(true);
    5.32 +			ex.doExport();
    5.33 +			me->setExportMode(false);
    5.34 +		}
    5.35 +	}
    5.36 +}
    5.37 +
    5.38  void Main::fileExportLaTeX()
    5.39  {
    5.40  	MapEditor *me=currentMapEditor();
    5.41 @@ -3297,10 +3321,10 @@
    5.42  
    5.43  void Main::windowToggleNoteEditor()
    5.44  {
    5.45 -	if (textEditor->isVisible() )
    5.46 -		textEditor->hide();
    5.47 -	else	
    5.48 -		textEditor->show();
    5.49 +	if (textEditor->showWithMain() )
    5.50 +		windowHideNoteEditor();
    5.51 +	else
    5.52 +		windowShowNoteEditor();
    5.53  }
    5.54  
    5.55  void Main::windowToggleHistory()
    5.56 @@ -3584,12 +3608,14 @@
    5.57  
    5.58  void Main::windowShowNoteEditor()
    5.59  {
    5.60 +	textEditor->setShowWithMain(true);
    5.61  	textEditor->show();
    5.62  	actionViewToggleNoteEditor->setOn (true);
    5.63  }
    5.64  
    5.65  void Main::windowHideNoteEditor()
    5.66  {
    5.67 +	textEditor->setShowWithMain(false);
    5.68  	textEditor->hide();
    5.69  	actionViewToggleNoteEditor->setOn (false);
    5.70  }
     6.1 --- a/mainwindow.h	Mon May 21 13:05:26 2007 +0000
     6.2 +++ b/mainwindow.h	Wed May 30 15:23:07 2007 +0000
     6.3 @@ -80,6 +80,7 @@
     6.4      void fileExportXHTML();
     6.5      void fileExportImage();
     6.6      void fileExportASCII();
     6.7 +    void fileExportCSV();
     6.8      void fileExportLaTeX();
     6.9      void fileExportKDEBookmarks();
    6.10      void fileExportTaskjuggler();
     7.1 --- a/mapeditor.cpp	Mon May 21 13:05:26 2007 +0000
     7.2 +++ b/mapeditor.cpp	Wed May 30 15:23:07 2007 +0000
     7.3 @@ -1910,7 +1910,7 @@
     7.4  	blockSaveState=old;
     7.5  }
     7.6  
     7.7 -void MapEditor::paste()		// FIXME no pasting of FIO ???
     7.8 +void MapEditor::paste()		
     7.9  {   
    7.10  	BranchObj *sel=xelection.getBranch();
    7.11  	if (sel)
    7.12 @@ -3193,6 +3193,13 @@
    7.13  void MapEditor::setMapDefLinkColor(QColor c)
    7.14  {
    7.15  	defLinkColor=c;
    7.16 +	BranchObj *bo;
    7.17 +	bo=mapCenter->first();
    7.18 +	while (bo) 
    7.19 +	{
    7.20 +		bo->setLinkColor();
    7.21 +		bo=bo->next();
    7.22 +	}
    7.23  	updateActions();
    7.24  }
    7.25  
    7.26 @@ -3268,7 +3275,7 @@
    7.27  		QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()),
    7.28  		mapCenter,
    7.29  		QString("setMapDefLinkColor (\"%1\")").arg(col.name()),
    7.30 -		QString("Set link color to %1").arg(col.name())
    7.31 +		QString("Set map link color to %1").arg(col.name())
    7.32  	);
    7.33  	setMapDefLinkColor( col );
    7.34  }
    7.35 @@ -4218,7 +4225,17 @@
    7.36  			dst=NULL;
    7.37  		
    7.38  		if (xelection.type() == Selection::MapCenter )
    7.39 -		{	// FIXME The MapCenter was moved, no savestate yet
    7.40 +		{	
    7.41 +			// TODO: Check for problems if graphicsview is resized for 
    7.42 +			// undo/redo...
    7.43 +		    QString pold=qpointfToString(movingObj_orgPos);
    7.44 +		    QString pnow=qpointfToString(mapCenter->getAbsPos());
    7.45 +			saveState(
    7.46 +				fo,
    7.47 +				"move "+pold,
    7.48 +				fo,
    7.49 +				"move "+pnow,
    7.50 +				QString("Move mapcenter %1 to position %2").arg(getName(mapCenter)).arg(pnow));
    7.51  		}
    7.52  		
    7.53  		if (xelection.type() == Selection::Branch )
    7.54 @@ -4355,6 +4372,12 @@
    7.55  	BranchObj *sel=xelection.getBranch();
    7.56  	if (sel)
    7.57  	{
    7.58 +		foreach (QString format,event->mimeData()->formats()) 
    7.59 +		{
    7.60 +			cout << "Dropped format: "<<format.ascii()<<endl;
    7.61 +		}
    7.62 +
    7.63 +
    7.64  		QList <QUrl> uris;
    7.65  		if (event->mimeData()->hasImage()) 
    7.66  		{
     8.1 --- a/texteditor.cpp	Mon May 21 13:05:26 2007 +0000
     8.2 +++ b/texteditor.cpp	Wed May 30 15:23:07 2007 +0000
     8.3 @@ -60,9 +60,9 @@
     8.4  	move   (settings.value ( "/satellite/noteeditor/geometry/pos", QPoint (250,50)).toPoint());
     8.5  	
     8.6  	if (settings.value ( "/satellite/noteeditor/showWithMain",true).toBool())
     8.7 -		show();
     8.8 +		setShowWithMain (true);
     8.9  	else	
    8.10 -		hide();
    8.11 +		setShowWithMain (false);
    8.12  
    8.13  	varFont.fromString( settings.value
    8.14  		("/satellite/noteeditor/fonts/varFont",
    8.15 @@ -100,7 +100,7 @@
    8.16  	settings.setValue( "/satellite/noteeditor/geometry/pos", pos() );
    8.17  	settings.setValue ("/satellite/noteeditor/state",saveState(0));
    8.18  	
    8.19 -	settings.setValue( "/satellite/noteeditor/showWithMain",isVisible());
    8.20 +	settings.setValue( "/satellite/noteeditor/showWithMain",showwithmain);
    8.21  
    8.22  	QString s;
    8.23  	if (actionSettingsFonthintDefault->isOn() )
    8.24 @@ -122,6 +122,17 @@
    8.25  		return true;
    8.26  }
    8.27  
    8.28 +void TextEditor::setShowWithMain(bool v)
    8.29 +{
    8.30 +	showwithmain=v;
    8.31 +}
    8.32 +
    8.33 +bool TextEditor::showWithMain()
    8.34 +{
    8.35 +	return showwithmain;
    8.36 +}
    8.37 +
    8.38 +
    8.39  void TextEditor::setFontHint (const QString &fh)
    8.40  {
    8.41  	if (fh=="fixed")
    8.42 @@ -489,6 +500,7 @@
    8.43  void TextEditor::closeEvent( QCloseEvent* ce )
    8.44  {
    8.45      ce->accept();	// TextEditor can be reopened with show()
    8.46 +	showwithmain=false;
    8.47  	hide();
    8.48  	emit (windowClosed() );
    8.49      return;