# HG changeset patch
# User insilmaril
# Date 1180538587 0
# Node ID ab118b86bc548956ccb6a72d7e7d5aca0bd11dff
# Parent  1fc21685e3eae2578aa4528b8f28772c5aab5710
More bugfixes, simple csv export

diff -r 1fc21685e3ea -r ab118b86bc54 demos/todo.vym
Binary file demos/todo.vym has changed
diff -r 1fc21685e3ea -r ab118b86bc54 exports.cpp
--- a/exports.cpp	Mon May 21 13:05:26 2007 +0000
+++ b/exports.cpp	Wed May 30 15:23:07 2007 +0000
@@ -111,7 +111,6 @@
 		return r + " ";
 }
 
-
 ////////////////////////////////////////////////////////////////////////
 void ExportASCII::doExport()
 {
@@ -131,7 +130,6 @@
 	bo=mapCenter->first();
 	while (bo) 
 	{
-		cout << "export bo="<<bo->getHeading().ascii()<<endl;
 		// Make indentstring
 		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
 
@@ -162,6 +160,50 @@
 	file.close();
 }
 
+
+////////////////////////////////////////////////////////////////////////
+void ExportCSV::doExport()
+{
+	QFile file (outputFile);
+	if ( !file.open( QIODevice::WriteOnly ) )
+	{
+		qWarning ("ExportBase::exportXML  couldn't open "+outputFile);
+		return;
+	}
+	QTextStream ts( &file );	// use LANG decoding here...
+
+	// Write header
+	ts << "\"Note\""  <<endl;
+
+	// Main loop over all branches
+	QString s;
+	QString actIndent("");
+	int i,j;
+	BranchObj *bo;
+	bo=mapCenter->first();
+	while (bo) 
+	{
+		// If necessary, write note
+		if (!bo->getNote().isEmpty())
+		{
+			s =bo->getNoteASCII();
+			s=s.replace ("\n","\n"+actIndent);
+			ts << ("\""+s+"\",");
+		} else
+			ts <<"\"\",";
+
+		// Make indentstring
+		for (i=0;i<bo->getDepth();i++) actIndent+= "\"\",";
+
+		// Write heading
+		ts << actIndent << "\"" << bo->getHeading()<<"\""<<endl;
+		
+		bo=bo->next();
+		actIndent="";
+	}
+	file.close();
+}
+
 ////////////////////////////////////////////////////////////////////////
 void ExportKDEBookmarks::doExport() 
 {
diff -r 1fc21685e3ea -r ab118b86bc54 exports.h
--- a/exports.h	Mon May 21 13:05:26 2007 +0000
+++ b/exports.h	Wed May 30 15:23:07 2007 +0000
@@ -45,6 +45,13 @@
 };
 
 ///////////////////////////////////////////////////////////////////////
+class ExportCSV:public ExportBase
+{
+public:
+	virtual void doExport();
+};
+
+///////////////////////////////////////////////////////////////////////
 class ExportXMLBase:public ExportBase
 {
 };
diff -r 1fc21685e3ea -r ab118b86bc54 linkablemapobj.cpp
--- a/linkablemapobj.cpp	Mon May 21 13:05:26 2007 +0000
+++ b/linkablemapobj.cpp	Wed May 30 15:23:07 2007 +0000
@@ -319,9 +319,11 @@
 			break;
 		case PolyLine:
 			p->setBrush( QBrush(col));
+			p->setPen( pen);
 			break;
 		case PolyParabel:	
 			p->setBrush( QBrush(col));
+			p->setPen( pen);
 			break;
 		default:
 			break;
diff -r 1fc21685e3ea -r ab118b86bc54 mainwindow.cpp
--- a/mainwindow.cpp	Mon May 21 13:05:26 2007 +0000
+++ b/mainwindow.cpp	Wed May 30 15:23:07 2007 +0000
@@ -341,6 +341,11 @@
     connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
 	fileExportMenu->addAction (a);
 
+    a = new QAction( "Spreadsheet (CSV)...", this);
+	a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
+    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
+	fileExportMenu->addAction (a);
+
 	a = new QAction( tr("KDE Bookmarks","File menu"), this);
 	a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
 	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
@@ -2364,6 +2369,25 @@
 	}
 }
 
+void Main::fileExportCSV()
+{
+	MapEditor *me=currentMapEditor();
+	if (me)
+	{
+		ExportCSV ex;
+		ex.setMapCenter(me->getMapCenter());
+		ex.addFilter ("CSV (*.csv)");
+		ex.setDir(lastImageDir);
+		ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
+		if (ex.execDialog() ) 
+		{
+			me->setExportMode(true);
+			ex.doExport();
+			me->setExportMode(false);
+		}
+	}
+}
+
 void Main::fileExportLaTeX()
 {
 	MapEditor *me=currentMapEditor();
@@ -3297,10 +3321,10 @@
 
 void Main::windowToggleNoteEditor()
 {
-	if (textEditor->isVisible() )
-		textEditor->hide();
-	else	
-		textEditor->show();
+	if (textEditor->showWithMain() )
+		windowHideNoteEditor();
+	else
+		windowShowNoteEditor();
 }
 
 void Main::windowToggleHistory()
@@ -3584,12 +3608,14 @@
 
 void Main::windowShowNoteEditor()
 {
+	textEditor->setShowWithMain(true);
 	textEditor->show();
 	actionViewToggleNoteEditor->setOn (true);
 }
 
 void Main::windowHideNoteEditor()
 {
+	textEditor->setShowWithMain(false);
 	textEditor->hide();
 	actionViewToggleNoteEditor->setOn (false);
 }
diff -r 1fc21685e3ea -r ab118b86bc54 mainwindow.h
--- a/mainwindow.h	Mon May 21 13:05:26 2007 +0000
+++ b/mainwindow.h	Wed May 30 15:23:07 2007 +0000
@@ -80,6 +80,7 @@
     void fileExportXHTML();
     void fileExportImage();
     void fileExportASCII();
+    void fileExportCSV();
     void fileExportLaTeX();
     void fileExportKDEBookmarks();
     void fileExportTaskjuggler();
diff -r 1fc21685e3ea -r ab118b86bc54 mapeditor.cpp
--- a/mapeditor.cpp	Mon May 21 13:05:26 2007 +0000
+++ b/mapeditor.cpp	Wed May 30 15:23:07 2007 +0000
@@ -1910,7 +1910,7 @@
 	blockSaveState=old;
 }
 
-void MapEditor::paste()		// FIXME no pasting of FIO ???
+void MapEditor::paste()		
 {   
 	BranchObj *sel=xelection.getBranch();
 	if (sel)
@@ -3193,6 +3193,13 @@
 void MapEditor::setMapDefLinkColor(QColor c)
 {
 	defLinkColor=c;
+	BranchObj *bo;
+	bo=mapCenter->first();
+	while (bo) 
+	{
+		bo->setLinkColor();
+		bo=bo->next();
+	}
 	updateActions();
 }
 
@@ -3268,7 +3275,7 @@
 		QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()),
 		mapCenter,
 		QString("setMapDefLinkColor (\"%1\")").arg(col.name()),
-		QString("Set link color to %1").arg(col.name())
+		QString("Set map link color to %1").arg(col.name())
 	);
 	setMapDefLinkColor( col );
 }
@@ -4218,7 +4225,17 @@
 			dst=NULL;
 		
 		if (xelection.type() == Selection::MapCenter )
-		{	// FIXME The MapCenter was moved, no savestate yet
+		{	
+			// TODO: Check for problems if graphicsview is resized for 
+			// undo/redo...
+		    QString pold=qpointfToString(movingObj_orgPos);
+		    QString pnow=qpointfToString(mapCenter->getAbsPos());
+			saveState(
+				fo,
+				"move "+pold,
+				fo,
+				"move "+pnow,
+				QString("Move mapcenter %1 to position %2").arg(getName(mapCenter)).arg(pnow));
 		}
 		
 		if (xelection.type() == Selection::Branch )
@@ -4355,6 +4372,12 @@
 	BranchObj *sel=xelection.getBranch();
 	if (sel)
 	{
+		foreach (QString format,event->mimeData()->formats()) 
+		{
+			cout << "Dropped format: "<<format.ascii()<<endl;
+		}
+
+
 		QList <QUrl> uris;
 		if (event->mimeData()->hasImage()) 
 		{
diff -r 1fc21685e3ea -r ab118b86bc54 texteditor.cpp
--- a/texteditor.cpp	Mon May 21 13:05:26 2007 +0000
+++ b/texteditor.cpp	Wed May 30 15:23:07 2007 +0000
@@ -60,9 +60,9 @@
 	move   (settings.value ( "/satellite/noteeditor/geometry/pos", QPoint (250,50)).toPoint());
 	
 	if (settings.value ( "/satellite/noteeditor/showWithMain",true).toBool())
-		show();
+		setShowWithMain (true);
 	else	
-		hide();
+		setShowWithMain (false);
 
 	varFont.fromString( settings.value
 		("/satellite/noteeditor/fonts/varFont",
@@ -100,7 +100,7 @@
 	settings.setValue( "/satellite/noteeditor/geometry/pos", pos() );
 	settings.setValue ("/satellite/noteeditor/state",saveState(0));
 	
-	settings.setValue( "/satellite/noteeditor/showWithMain",isVisible());
+	settings.setValue( "/satellite/noteeditor/showWithMain",showwithmain);
 
 	QString s;
 	if (actionSettingsFonthintDefault->isOn() )
@@ -122,6 +122,17 @@
 		return true;
 }
 
+void TextEditor::setShowWithMain(bool v)
+{
+	showwithmain=v;
+}
+
+bool TextEditor::showWithMain()
+{
+	return showwithmain;
+}
+
+
 void TextEditor::setFontHint (const QString &fh)
 {
 	if (fh=="fixed")
@@ -489,6 +500,7 @@
 void TextEditor::closeEvent( QCloseEvent* ce )
 {
     ce->accept();	// TextEditor can be reopened with show()
+	showwithmain=false;
 	hide();
 	emit (windowClosed() );
     return;