Improved ascii export
authorinsilmaril
Wed, 24 Oct 2007 12:21:24 +0000
changeset 6138fb5b3956b3e
parent 612 316e9237794c
child 614 040f32294895
Improved ascii export
exports.cpp
exports.h
mainwindow.cpp
mapeditor.cpp
noteobj.cpp
noteobj.h
ornamentedobj.cpp
ornamentedobj.h
tex/vym.changelog
     1.1 --- a/exports.cpp	Tue Oct 23 13:05:22 2007 +0000
     1.2 +++ b/exports.cpp	Wed Oct 24 12:21:24 2007 +0000
     1.3 @@ -142,45 +142,65 @@
     1.4  
     1.5  	// Main loop over all branches
     1.6  	QString s;
     1.7 -	QString actIndent("");
     1.8 -	int i,j;
     1.9 +	QString curIndent;
    1.10 +	int i;
    1.11  	BranchObj *bo;
    1.12  	bo=mapCenter->first();
    1.13  	while (bo) 
    1.14  	{
    1.15  		// Make indentstring
    1.16 -		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
    1.17 +		curIndent="";
    1.18 +		for (i=0;i<bo->getDepth()-1;i++) curIndent+= indentPerDepth;
    1.19  
    1.20  		if (!bo->hasHiddenExportParent() )
    1.21  		{
    1.22 -			if (bo->getDepth()==0)
    1.23 +			switch (bo->getDepth())
    1.24  			{
    1.25 -				ts << (bo->getHeading()+ "\n");
    1.26 -				for (j=0;j<bo->getHeading().length();j++) ts<<"=";
    1.27 -				ts << "\n";
    1.28 -			} else 	if (bo->getDepth()==1)
    1.29 -				ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
    1.30 -			else	if (bo->getDepth()==2)
    1.31 -				ts << (actIndent + " * " + bo->getHeading()+ "\n");
    1.32 -			else	if (bo->getDepth()==3)
    1.33 -				ts << (actIndent + " o " + bo->getHeading()+ "\n");
    1.34 -			else	
    1.35 -				ts << (actIndent + " - " + bo->getHeading()+ "\n");
    1.36 -			
    1.37 +				case 0:
    1.38 +					ts << underline (bo->getHeading(),QString("="));
    1.39 +					ts << "\n";
    1.40 +					break;
    1.41 +				case 1:
    1.42 +					ts << "\n";
    1.43 +					ts << (underline (getSectionString(bo) + bo->getHeading(), QString("-") ) );
    1.44 +					ts << "\n";
    1.45 +					break;
    1.46 +				case 2:
    1.47 +					ts << "\n";
    1.48 +					ts << (curIndent + "* " + bo->getHeading());
    1.49 +					ts << "\n";
    1.50 +					break;
    1.51 +				case 3:
    1.52 +					ts << (curIndent + "- " + bo->getHeading());
    1.53 +					ts << "\n";
    1.54 +					break;
    1.55 +				default:
    1.56 +					ts << (curIndent + "- " + bo->getHeading());
    1.57 +					ts << "\n";
    1.58 +					break;
    1.59 +			}
    1.60 +
    1.61  			// If necessary, write note
    1.62  			if (!bo->getNote().isEmpty())
    1.63  			{
    1.64 -				s =bo->getNoteASCII();
    1.65 -				s=s.replace ("\n","\n"+actIndent);
    1.66 -				ts << (s+"\n\n");
    1.67 +				curIndent +="  | ";
    1.68 +				s =curIndent + bo->getNoteASCII( curIndent, 80);
    1.69 +				s=s.replace ("\n","\n"+curIndent);
    1.70 +				ts << QString (s+"\n");
    1.71  			}
    1.72  		}
    1.73  		bo=bo->next();
    1.74 -		actIndent="";
    1.75  	}
    1.76  	file.close();
    1.77  }
    1.78  
    1.79 +QString ExportASCII::underline (const QString &text, const QString &line)
    1.80 +{
    1.81 +	QString r=text + "\n";
    1.82 +	for (int j=0;j<text.length();j++) r+=line;
    1.83 +	return r;
    1.84 +}
    1.85 +
    1.86  
    1.87  ////////////////////////////////////////////////////////////////////////
    1.88  void ExportCSV::doExport()
    1.89 @@ -198,7 +218,7 @@
    1.90  
    1.91  	// Main loop over all branches
    1.92  	QString s;
    1.93 -	QString actIndent("");
    1.94 +	QString curIndent("");
    1.95  	int i;
    1.96  	BranchObj *bo;
    1.97  	bo=mapCenter->first();
    1.98 @@ -210,20 +230,20 @@
    1.99  			if (!bo->getNote().isEmpty())
   1.100  			{
   1.101  				s =bo->getNoteASCII();
   1.102 -				s=s.replace ("\n","\n"+actIndent);
   1.103 +				s=s.replace ("\n","\n"+curIndent);
   1.104  				ts << ("\""+s+"\",");
   1.105  			} else
   1.106  				ts <<"\"\",";
   1.107  
   1.108  			// Make indentstring
   1.109 -			for (i=0;i<bo->getDepth();i++) actIndent+= "\"\",";
   1.110 +			for (i=0;i<bo->getDepth();i++) curIndent+= "\"\",";
   1.111  
   1.112  			// Write heading
   1.113 -			ts << actIndent << "\"" << bo->getHeading()<<"\""<<endl;
   1.114 +			ts << curIndent << "\"" << bo->getHeading()<<"\""<<endl;
   1.115  		}
   1.116  		
   1.117  		bo=bo->next();
   1.118 -		actIndent="";
   1.119 +		curIndent="";
   1.120  	}
   1.121  	file.close();
   1.122  }
   1.123 @@ -341,7 +361,7 @@
   1.124    
   1.125    // Main loop over all branches
   1.126    QString s;
   1.127 -  // QString actIndent("");
   1.128 +  // QString curIndent("");
   1.129    // int i;
   1.130    BranchObj *bo;
   1.131    bo=mapCenter->first();
     2.1 --- a/exports.h	Tue Oct 23 13:05:22 2007 +0000
     2.2 +++ b/exports.h	Wed Oct 24 12:21:24 2007 +0000
     2.3 @@ -46,7 +46,7 @@
     2.4  public:
     2.5  	ExportASCII();
     2.6  	virtual void doExport();
     2.7 -	virtual QString underline (QString &text, QString &line);
     2.8 +	virtual QString underline (const QString &text, const QString &line);
     2.9  };
    2.10  
    2.11  ///////////////////////////////////////////////////////////////////////
     3.1 --- a/mainwindow.cpp	Tue Oct 23 13:05:22 2007 +0000
     3.2 +++ b/mainwindow.cpp	Wed Oct 24 12:21:24 2007 +0000
     3.3 @@ -608,6 +608,7 @@
     3.4  	connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
     3.5  	a->setEnabled (true);
     3.6  	a->addTo( tb );
     3.7 +	editMenu->addAction (a);
     3.8  	actionEditSortChildren=a;
     3.9  
    3.10  	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
     4.1 --- a/mapeditor.cpp	Tue Oct 23 13:05:22 2007 +0000
     4.2 +++ b/mapeditor.cpp	Wed Oct 24 12:21:24 2007 +0000
     4.3 @@ -681,9 +681,9 @@
     4.4  	{
     4.5  		QString fname="";
     4.6  		ok=true;
     4.7 -		if (parser.parCount()>=2)
     4.8 +		if (parser.parCount()>=1)
     4.9  			// Hey, we even have a filename
    4.10 -			fname=parser.parString(ok,1); 
    4.11 +			fname=parser.parString(ok,0); 
    4.12  		if (!ok)
    4.13  		{
    4.14  			parser.setError (Aborted,"Could not read filename");
    4.15 @@ -698,16 +698,16 @@
    4.16  		ok=true;
    4.17  		if (parser.parCount()>=2)
    4.18  			// Hey, we even have a filename
    4.19 -			fname=parser.parString(ok,1); 
    4.20 +			fname=parser.parString(ok,0); 
    4.21  		if (!ok)
    4.22  		{
    4.23  			parser.setError (Aborted,"Could not read filename");
    4.24  		} else
    4.25  		{
    4.26  			QString format="PNG";
    4.27 -			if (parser.parCount()>2)
    4.28 +			if (parser.parCount()>=2)
    4.29  			{
    4.30 -				format=parser.parString(ok,2);
    4.31 +				format=parser.parString(ok,1);
    4.32  			}
    4.33  			exportImage (fname,false,format);
    4.34  		}
    4.35 @@ -1383,7 +1383,7 @@
    4.36  	// Any errors?
    4.37  	if (parser.errorLevel()==NoError)
    4.38  	{
    4.39 -		setChanged();
    4.40 +		// setChanged();  FIXME should not be called e.g. for export?!
    4.41  		mapCenter->reposition();
    4.42  	}	
    4.43  	else	
     5.1 --- a/noteobj.cpp	Tue Oct 23 13:05:22 2007 +0000
     5.2 +++ b/noteobj.cpp	Wed Oct 24 12:21:24 2007 +0000
     5.3 @@ -46,6 +46,11 @@
     5.4  
     5.5  QString NoteObj::getNoteASCII()
     5.6  {
     5.7 +	return getNoteASCII (QString(""),80);
     5.8 +}
     5.9 +
    5.10 +QString NoteObj::getNoteASCII(const QString &indent, const int &width)
    5.11 +{
    5.12  	QString r=note;
    5.13  
    5.14  	// Remove all <style...> ...</style>
    5.15 @@ -79,6 +84,12 @@
    5.16  	rx.setPattern ("&quot;");
    5.17  	r.replace (rx,"\"");
    5.18  
    5.19 +/* FIXME
    5.20 +	if (fonthint !="fixed")
    5.21 +	{
    5.22 +		// wrap text at width
    5.23 +	}
    5.24 +*/	
    5.25  	return r;
    5.26  }
    5.27  
     6.1 --- a/noteobj.h	Tue Oct 23 13:05:22 2007 +0000
     6.2 +++ b/noteobj.h	Wed Oct 24 12:21:24 2007 +0000
     6.3 @@ -20,6 +20,7 @@
     6.4  	void setNote (const QString&);
     6.5  	QString getNote();
     6.6  	QString getNoteASCII();
     6.7 +	QString getNoteASCII(const QString &indent, const int &width);
     6.8  	QString getNoteOpenDoc();
     6.9  	void setFontHint (const QString&);
    6.10  	QString getFontHint ();
     7.1 --- a/ornamentedobj.cpp	Tue Oct 23 13:05:22 2007 +0000
     7.2 +++ b/ornamentedobj.cpp	Wed Oct 24 12:21:24 2007 +0000
     7.3 @@ -275,6 +275,11 @@
     7.4      return note.getNote();
     7.5  }
     7.6  
     7.7 +QString OrnamentedObj::getNoteASCII(const QString &indent, const int &width)
     7.8 +{
     7.9 +    return note.getNoteASCII();
    7.10 +}
    7.11 +
    7.12  QString OrnamentedObj::getNoteASCII()
    7.13  {
    7.14      return note.getNoteASCII();
     8.1 --- a/ornamentedobj.h	Tue Oct 23 13:05:22 2007 +0000
     8.2 +++ b/ornamentedobj.h	Wed Oct 24 12:21:24 2007 +0000
     8.3 @@ -54,6 +54,7 @@
     8.4      virtual void setNote(QString);			// set note
     8.5      virtual void setNote(NoteObj);			// set note
     8.6      virtual QString getNote();				// returns note	(HTML)
     8.7 +    virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
     8.8      virtual QString getNoteASCII();			// returns note	(ASCII)
     8.9      virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
    8.10      virtual void setURL (QString);
     9.1 --- a/tex/vym.changelog	Tue Oct 23 13:05:22 2007 +0000
     9.2 +++ b/tex/vym.changelog	Wed Oct 24 12:21:24 2007 +0000
     9.3 @@ -1,3 +1,8 @@
     9.4 +-------------------------------------------------------------------
     9.5 +Wed Oct 24 14:11:36 CEST 2007 - uwedr@suse.de
     9.6 +
     9.7 +- Feature: Improved ascii export 
     9.8 +
     9.9  -------------------------------------------------------------------
    9.10  Tue Oct 23 13:11:52 CEST 2007 - uwedr@suse.de
    9.11