Fixed outputFile in OO export
authorinsilmaril
Wed, 25 Jan 2006 12:34:55 +0000
changeset 199202572375c98
parent 198 3f4bc2397c3c
child 200 451cab91e350
Fixed outputFile in OO export
exports.cpp
exports.h
mapeditor.cpp
     1.1 --- a/exports.cpp	Wed Jan 25 12:34:55 2006 +0000
     1.2 +++ b/exports.cpp	Wed Jan 25 12:34:55 2006 +0000
     1.3 @@ -14,9 +14,14 @@
     1.4  	indentPerDepth="  ";
     1.5  }
     1.6  
     1.7 -void ExportBase::setPath (const QString &p)
     1.8 +void ExportBase::setDir(const QString &p)
     1.9  {
    1.10 -	filepath=p;
    1.11 +	outputDir=p;
    1.12 +}
    1.13 +
    1.14 +void ExportBase::setFile (const QString &p)
    1.15 +{
    1.16 +	outputFile=p;
    1.17  }
    1.18  
    1.19  void ExportBase::setMapCenter(MapCenterObj *mc)
    1.20 @@ -43,11 +48,11 @@
    1.21  
    1.22  void ExportBase::exportXML()
    1.23  {
    1.24 -	QFile file (filepath);
    1.25 +	QFile file (outputFile);
    1.26  	if ( !file.open( IO_WriteOnly ) )
    1.27  	{
    1.28  		// FIXME experimental, testing
    1.29 -		cout << "ExportBase::exportXML  couldn't open "<<filepath<<endl;
    1.30 +		cout << "ExportBase::exportXML  couldn't open "<<outputFile<<endl;
    1.31  		return;
    1.32  	}
    1.33  	QTextStream ts( &file );	// use LANG decoding here...
    1.34 @@ -99,10 +104,10 @@
    1.35  	// or inported into a LaTex document
    1.36  	// it will not add a preamble, or anything 
    1.37  	// that makes a full LaTex document.
    1.38 -  QFile file (filepath);
    1.39 +  QFile file (outputFile);
    1.40    if ( !file.open( IO_WriteOnly ) ) {
    1.41 -    // FIXME
    1.42 -    cout << "Export::exportMap  couldn't open "<<filepath<<endl;
    1.43 +    // FIXME 
    1.44 +    cout << "Export::exportMap  couldn't open "<<outputFile<<endl;
    1.45      return;
    1.46    }
    1.47    QTextStream ts( &file );	// use LANG decoding here...
    1.48 @@ -145,6 +150,7 @@
    1.49  
    1.50  ExportOO::ExportOO()
    1.51  {
    1.52 +	useSections=false;
    1.53  	// Create tmpdir
    1.54  	tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX"));
    1.55  }
    1.56 @@ -189,8 +195,6 @@
    1.57  {
    1.58  	QString allPages;
    1.59  
    1.60 -	bool useSections=true;
    1.61 -
    1.62  	// Insert new content
    1.63  	content.replace ("<!-- INSERT TITLE -->",quotemeta(mapCenter->getHeading()));
    1.64  	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(mapCenter->getAuthor()));
    1.65 @@ -243,7 +247,7 @@
    1.66  	QFile f (contentFile);
    1.67      if ( !f.open( IO_WriteOnly ) ) 
    1.68  	{
    1.69 -		mainWindow->statusMessage(QString(QObject::tr("Could not write to %1")).arg(outputFile));
    1.70 +		mainWindow->statusMessage(QString(QObject::tr("Could not write to %1")).arg(contentFile));
    1.71  		return;
    1.72      }
    1.73  
    1.74 @@ -279,8 +283,9 @@
    1.75  	pageTemplateFile=templateDir+"page-template.xml";
    1.76  	sectionTemplateFile=templateDir+"section-template.xml";
    1.77  
    1.78 -	outputFile=tmpDir.currentDirPath()+"/vym-out.odp";
    1.79 -	
    1.80 +	if (set.readEntry("useSections").contains("yes"))
    1.81 +		useSections=true;
    1.82 +
    1.83  	// Copy template to tmpdir
    1.84  	system ("cp -r "+templateDir+"* "+tmpDir.path());
    1.85  
     2.1 --- a/exports.h	Wed Jan 25 12:34:55 2006 +0000
     2.2 +++ b/exports.h	Wed Jan 25 12:34:55 2006 +0000
     2.3 @@ -16,7 +16,8 @@
     2.4  {
     2.5  public:
     2.6  	ExportBase();
     2.7 -	void setPath(const QString &);
     2.8 +	void setDir(const QString &);
     2.9 +	void setFile(const QString &);
    2.10  	void setMapCenter (MapCenterObj*);
    2.11  	void setIndentPerDepth (QString);
    2.12  protected:  
    2.13 @@ -26,7 +27,8 @@
    2.14  
    2.15  protected:
    2.16  	QDir outdir;
    2.17 -	QString filepath;
    2.18 +	QString outputDir;
    2.19 +	QString outputFile;
    2.20  	MapCenterObj *mapCenter;
    2.21  	QString	indentPerDepth;
    2.22  };
    2.23 @@ -57,7 +59,6 @@
    2.24  	QString contentTemplate;
    2.25  	QString contentTemplateFile;
    2.26  	QString contentFile;
    2.27 -	QString outputFile;
    2.28  	QString pageTemplate;
    2.29  	QString pageTemplateFile;
    2.30  	QString sectionTemplate;
     3.1 --- a/mapeditor.cpp	Wed Jan 25 12:34:55 2006 +0000
     3.2 +++ b/mapeditor.cpp	Wed Jan 25 12:34:55 2006 +0000
     3.3 @@ -1096,7 +1096,7 @@
     3.4  					break;
     3.5  			}
     3.6  		}
     3.7 -		ex.setPath (fd->selectedFile() );
     3.8 +		ex.setFile(fd->selectedFile() );
     3.9  		ex.exportXML();
    3.10  	}
    3.11  }
    3.12 @@ -1115,8 +1115,7 @@
    3.13  		if (QFile (fd->selectedFile()).exists() )
    3.14  		{
    3.15  			QMessageBox mb( "VYM",
    3.16 -				tr("The file ") + fd->selectedFile() + 
    3.17 -				tr(" exists already. Do you want to overwrite it?"),
    3.18 +				tr("The file %1\nexists already. Do you want to overwrite it?").arg(fd->selectedFile()),
    3.19  			QMessageBox::Warning,
    3.20  			QMessageBox::Yes | QMessageBox::Default,
    3.21  			QMessageBox::Cancel | QMessageBox::Escape,
    3.22 @@ -1137,7 +1136,7 @@
    3.23  			}
    3.24  		}
    3.25  		ExportLaTeX ex;
    3.26 -		ex.setPath (fd->selectedFile() );
    3.27 +		ex.setFile (fd->selectedFile() );
    3.28  		ex.setMapCenter(mapCenter);
    3.29  		ex.exportLaTeX();
    3.30  	}
    3.31 @@ -1146,7 +1145,7 @@
    3.32  void MapEditor::exportOOPresentation(const QString &fn, const QString &cf)
    3.33  {
    3.34  	ExportOO ex;
    3.35 -	ex.setPath (fn);
    3.36 +	ex.setFile (fn);
    3.37  	ex.setMapCenter(mapCenter);
    3.38  	if (ex.setConfigFile(cf)) ex.exportPresentation();
    3.39  }