# HG changeset patch
# User insilmaril
# Date 1193228484 0
# Node ID 8fb5b3956b3e00c2d287d050407fa7c0931f3b0e
# Parent  316e9237794c7f7a046007437a4be7a76c9b59b1
Improved ascii export

diff -r 316e9237794c -r 8fb5b3956b3e exports.cpp
--- a/exports.cpp	Tue Oct 23 13:05:22 2007 +0000
+++ b/exports.cpp	Wed Oct 24 12:21:24 2007 +0000
@@ -142,45 +142,65 @@
 
 	// Main loop over all branches
 	QString s;
-	QString actIndent("");
-	int i,j;
+	QString curIndent;
+	int i;
 	BranchObj *bo;
 	bo=mapCenter->first();
 	while (bo) 
 	{
 		// Make indentstring
-		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
+		curIndent="";
+		for (i=0;i<bo->getDepth()-1;i++) curIndent+= indentPerDepth;
 
 		if (!bo->hasHiddenExportParent() )
 		{
-			if (bo->getDepth()==0)
+			switch (bo->getDepth())
 			{
-				ts << (bo->getHeading()+ "\n");
-				for (j=0;j<bo->getHeading().length();j++) ts<<"=";
-				ts << "\n";
-			} else 	if (bo->getDepth()==1)
-				ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
-			else	if (bo->getDepth()==2)
-				ts << (actIndent + " * " + bo->getHeading()+ "\n");
-			else	if (bo->getDepth()==3)
-				ts << (actIndent + " o " + bo->getHeading()+ "\n");
-			else	
-				ts << (actIndent + " - " + bo->getHeading()+ "\n");
-			
+				case 0:
+					ts << underline (bo->getHeading(),QString("="));
+					ts << "\n";
+					break;
+				case 1:
+					ts << "\n";
+					ts << (underline (getSectionString(bo) + bo->getHeading(), QString("-") ) );
+					ts << "\n";
+					break;
+				case 2:
+					ts << "\n";
+					ts << (curIndent + "* " + bo->getHeading());
+					ts << "\n";
+					break;
+				case 3:
+					ts << (curIndent + "- " + bo->getHeading());
+					ts << "\n";
+					break;
+				default:
+					ts << (curIndent + "- " + bo->getHeading());
+					ts << "\n";
+					break;
+			}
+
 			// If necessary, write note
 			if (!bo->getNote().isEmpty())
 			{
-				s =bo->getNoteASCII();
-				s=s.replace ("\n","\n"+actIndent);
-				ts << (s+"\n\n");
+				curIndent +="  | ";
+				s =curIndent + bo->getNoteASCII( curIndent, 80);
+				s=s.replace ("\n","\n"+curIndent);
+				ts << QString (s+"\n");
 			}
 		}
 		bo=bo->next();
-		actIndent="";
 	}
 	file.close();
 }
 
+QString ExportASCII::underline (const QString &text, const QString &line)
+{
+	QString r=text + "\n";
+	for (int j=0;j<text.length();j++) r+=line;
+	return r;
+}
+
 
 ////////////////////////////////////////////////////////////////////////
 void ExportCSV::doExport()
@@ -198,7 +218,7 @@
 
 	// Main loop over all branches
 	QString s;
-	QString actIndent("");
+	QString curIndent("");
 	int i;
 	BranchObj *bo;
 	bo=mapCenter->first();
@@ -210,20 +230,20 @@
 			if (!bo->getNote().isEmpty())
 			{
 				s =bo->getNoteASCII();
-				s=s.replace ("\n","\n"+actIndent);
+				s=s.replace ("\n","\n"+curIndent);
 				ts << ("\""+s+"\",");
 			} else
 				ts <<"\"\",";
 
 			// Make indentstring
-			for (i=0;i<bo->getDepth();i++) actIndent+= "\"\",";
+			for (i=0;i<bo->getDepth();i++) curIndent+= "\"\",";
 
 			// Write heading
-			ts << actIndent << "\"" << bo->getHeading()<<"\""<<endl;
+			ts << curIndent << "\"" << bo->getHeading()<<"\""<<endl;
 		}
 		
 		bo=bo->next();
-		actIndent="";
+		curIndent="";
 	}
 	file.close();
 }
@@ -341,7 +361,7 @@
   
   // Main loop over all branches
   QString s;
-  // QString actIndent("");
+  // QString curIndent("");
   // int i;
   BranchObj *bo;
   bo=mapCenter->first();
diff -r 316e9237794c -r 8fb5b3956b3e exports.h
--- a/exports.h	Tue Oct 23 13:05:22 2007 +0000
+++ b/exports.h	Wed Oct 24 12:21:24 2007 +0000
@@ -46,7 +46,7 @@
 public:
 	ExportASCII();
 	virtual void doExport();
-	virtual QString underline (QString &text, QString &line);
+	virtual QString underline (const QString &text, const QString &line);
 };
 
 ///////////////////////////////////////////////////////////////////////
diff -r 316e9237794c -r 8fb5b3956b3e mainwindow.cpp
--- a/mainwindow.cpp	Tue Oct 23 13:05:22 2007 +0000
+++ b/mainwindow.cpp	Wed Oct 24 12:21:24 2007 +0000
@@ -608,6 +608,7 @@
 	connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
 	a->setEnabled (true);
 	a->addTo( tb );
+	editMenu->addAction (a);
 	actionEditSortChildren=a;
 
 	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
diff -r 316e9237794c -r 8fb5b3956b3e mapeditor.cpp
--- a/mapeditor.cpp	Tue Oct 23 13:05:22 2007 +0000
+++ b/mapeditor.cpp	Wed Oct 24 12:21:24 2007 +0000
@@ -681,9 +681,9 @@
 	{
 		QString fname="";
 		ok=true;
-		if (parser.parCount()>=2)
+		if (parser.parCount()>=1)
 			// Hey, we even have a filename
-			fname=parser.parString(ok,1); 
+			fname=parser.parString(ok,0); 
 		if (!ok)
 		{
 			parser.setError (Aborted,"Could not read filename");
@@ -698,16 +698,16 @@
 		ok=true;
 		if (parser.parCount()>=2)
 			// Hey, we even have a filename
-			fname=parser.parString(ok,1); 
+			fname=parser.parString(ok,0); 
 		if (!ok)
 		{
 			parser.setError (Aborted,"Could not read filename");
 		} else
 		{
 			QString format="PNG";
-			if (parser.parCount()>2)
+			if (parser.parCount()>=2)
 			{
-				format=parser.parString(ok,2);
+				format=parser.parString(ok,1);
 			}
 			exportImage (fname,false,format);
 		}
@@ -1383,7 +1383,7 @@
 	// Any errors?
 	if (parser.errorLevel()==NoError)
 	{
-		setChanged();
+		// setChanged();  FIXME should not be called e.g. for export?!
 		mapCenter->reposition();
 	}	
 	else	
diff -r 316e9237794c -r 8fb5b3956b3e noteobj.cpp
--- a/noteobj.cpp	Tue Oct 23 13:05:22 2007 +0000
+++ b/noteobj.cpp	Wed Oct 24 12:21:24 2007 +0000
@@ -46,6 +46,11 @@
 
 QString NoteObj::getNoteASCII()
 {
+	return getNoteASCII (QString(""),80);
+}
+
+QString NoteObj::getNoteASCII(const QString &indent, const int &width)
+{
 	QString r=note;
 
 	// Remove all <style...> ...</style>
@@ -79,6 +84,12 @@
 	rx.setPattern ("&quot;");
 	r.replace (rx,"\"");
 
+/* FIXME
+	if (fonthint !="fixed")
+	{
+		// wrap text at width
+	}
+*/	
 	return r;
 }
 
diff -r 316e9237794c -r 8fb5b3956b3e noteobj.h
--- a/noteobj.h	Tue Oct 23 13:05:22 2007 +0000
+++ b/noteobj.h	Wed Oct 24 12:21:24 2007 +0000
@@ -20,6 +20,7 @@
 	void setNote (const QString&);
 	QString getNote();
 	QString getNoteASCII();
+	QString getNoteASCII(const QString &indent, const int &width);
 	QString getNoteOpenDoc();
 	void setFontHint (const QString&);
 	QString getFontHint ();
diff -r 316e9237794c -r 8fb5b3956b3e ornamentedobj.cpp
--- a/ornamentedobj.cpp	Tue Oct 23 13:05:22 2007 +0000
+++ b/ornamentedobj.cpp	Wed Oct 24 12:21:24 2007 +0000
@@ -275,6 +275,11 @@
     return note.getNote();
 }
 
+QString OrnamentedObj::getNoteASCII(const QString &indent, const int &width)
+{
+    return note.getNoteASCII();
+}
+
 QString OrnamentedObj::getNoteASCII()
 {
     return note.getNoteASCII();
diff -r 316e9237794c -r 8fb5b3956b3e ornamentedobj.h
--- a/ornamentedobj.h	Tue Oct 23 13:05:22 2007 +0000
+++ b/ornamentedobj.h	Wed Oct 24 12:21:24 2007 +0000
@@ -54,6 +54,7 @@
     virtual void setNote(QString);			// set note
     virtual void setNote(NoteObj);			// set note
     virtual QString getNote();				// returns note	(HTML)
+    virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
     virtual QString getNoteASCII();			// returns note	(ASCII)
     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
     virtual void setURL (QString);
diff -r 316e9237794c -r 8fb5b3956b3e tex/vym.changelog
--- a/tex/vym.changelog	Tue Oct 23 13:05:22 2007 +0000
+++ b/tex/vym.changelog	Wed Oct 24 12:21:24 2007 +0000
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Wed Oct 24 14:11:36 CEST 2007 - uwedr@suse.de
+
+- Feature: Improved ascii export 
+
 -------------------------------------------------------------------
 Tue Oct 23 13:11:52 CEST 2007 - uwedr@suse.de