exports.cpp
author insilmaril
Tue, 15 Aug 2006 11:43:21 +0000
branchqt4-port
changeset 14 f4c37956d28d
parent 9 f94317a94db1
child 16 41c3d7f9f532
permissions -rw-r--r--
removed unneeded toolbars.*
insilmaril@2
     1
#include <q3filedialog.h>
insilmaril@2
     2
#include <qmessagebox.h>
insilmaril@9
     3
#include <QProcess>
insilmaril@2
     4
//Added by qt3to4:
insilmaril@2
     5
#include <QTextStream>
insilmaril@2
     6
insilmaril@0
     7
#include "exports.h"
insilmaril@2
     8
#include "file.h"
insilmaril@2
     9
#include "linkablemapobj.h"
insilmaril@2
    10
#include "misc.h"
insilmaril@2
    11
#include "mainwindow.h"
insilmaril@2
    12
#include "warningdialog.h"
insilmaril@2
    13
#include "xsltproc.h"
insilmaril@0
    14
insilmaril@2
    15
extern Main *mainWindow;
insilmaril@2
    16
extern QDir vymBaseDir;
insilmaril@0
    17
insilmaril@0
    18
insilmaril@2
    19
ExportBase::ExportBase()
insilmaril@0
    20
{
insilmaril@0
    21
	indentPerDepth="  ";
insilmaril@2
    22
	// Create tmpdir
insilmaril@2
    23
	tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX"));
insilmaril@0
    24
}
insilmaril@0
    25
insilmaril@2
    26
ExportBase::~ExportBase()
insilmaril@0
    27
{
insilmaril@2
    28
	// Remove tmpdir
insilmaril@2
    29
	removeDir (tmpDir);
insilmaril@0
    30
}
insilmaril@0
    31
insilmaril@2
    32
void ExportBase::setDir(const QString &p)
insilmaril@0
    33
{
insilmaril@2
    34
	outputDir=p;
insilmaril@0
    35
}
insilmaril@0
    36
insilmaril@2
    37
void ExportBase::setFile (const QString &p)
insilmaril@2
    38
{
insilmaril@2
    39
	outputFile=p;
insilmaril@2
    40
}
insilmaril@2
    41
insilmaril@2
    42
void ExportBase::setMapCenter(MapCenterObj *mc)
insilmaril@0
    43
{
insilmaril@0
    44
	mapCenter=mc;
insilmaril@0
    45
}
insilmaril@0
    46
insilmaril@2
    47
void ExportBase::setCaption (const QString &s)
insilmaril@0
    48
{
insilmaril@2
    49
	caption=s;
insilmaril@0
    50
}
insilmaril@0
    51
insilmaril@2
    52
void ExportBase::addFilter(const QString &s)
insilmaril@0
    53
{
insilmaril@2
    54
	filter=s;
insilmaril@2
    55
}
insilmaril@2
    56
insilmaril@2
    57
bool ExportBase::execDialog()
insilmaril@2
    58
{
insilmaril@2
    59
	if (mapCenter && mapCenter->getMapEditor())
insilmaril@2
    60
	{
insilmaril@9
    61
		QFileDialog *fd=new QFileDialog( mapCenter->getMapEditor(), caption);
insilmaril@9
    62
		fd->setFilter (filter);
insilmaril@2
    63
		fd->setCaption(caption);
insilmaril@9
    64
		fd->setMode( QFileDialog::AnyFile );
insilmaril@2
    65
		fd->show();
insilmaril@2
    66
insilmaril@2
    67
		if ( fd->exec() == QDialog::Accepted )
insilmaril@2
    68
		{
insilmaril@2
    69
			if (QFile (fd->selectedFile()).exists() )
insilmaril@2
    70
			{
insilmaril@2
    71
				QMessageBox mb( __VYM,
insilmaril@2
    72
					QObject::tr("The file %1 exists already.\nDo you want to overwrite it?").arg(fd->selectedFile()), 
insilmaril@2
    73
				QMessageBox::Warning,
insilmaril@2
    74
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@2
    75
				QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@2
    76
				Qt::NoButton );
insilmaril@2
    77
				mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") );
insilmaril@2
    78
				mb.setButtonText( QMessageBox::No, QObject::tr("Cancel"));
insilmaril@2
    79
				ExportBase ex;
insilmaril@2
    80
				switch( mb.exec() ) 
insilmaril@2
    81
				{
insilmaril@2
    82
					case QMessageBox::Yes:
insilmaril@2
    83
						// save 
insilmaril@2
    84
						break;;
insilmaril@2
    85
					case QMessageBox::Cancel:
insilmaril@2
    86
						// return, do nothing
insilmaril@2
    87
						return false;
insilmaril@2
    88
						break;
insilmaril@2
    89
				}
insilmaril@2
    90
			}
insilmaril@2
    91
			outputFile=fd->selectedFile();
insilmaril@2
    92
			return true;
insilmaril@2
    93
		}
insilmaril@2
    94
	}
insilmaril@2
    95
	return false;
insilmaril@2
    96
}
insilmaril@2
    97
insilmaril@2
    98
QString ExportBase::getSectionString(BranchObj *bostart)
insilmaril@2
    99
{
insilmaril@2
   100
	// Make prefix like "2.5.3" for "bo:2,bo:5,bo:3"
insilmaril@0
   101
	QString r;
insilmaril@0
   102
	BranchObj *bo=bostart;
insilmaril@0
   103
	int depth=bo->getDepth();
insilmaril@0
   104
	while (depth>0)
insilmaril@0
   105
	{
insilmaril@0
   106
		r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r;
insilmaril@0
   107
		bo=(BranchObj*)(bo->getParObj());
insilmaril@0
   108
		depth=bo->getDepth();
insilmaril@0
   109
	}	
insilmaril@0
   110
	if (r.isEmpty())
insilmaril@0
   111
		return r;
insilmaril@0
   112
	else	
insilmaril@0
   113
		return r + " ";
insilmaril@0
   114
}
insilmaril@0
   115
insilmaril@2
   116
insilmaril@2
   117
////////////////////////////////////////////////////////////////////////
insilmaril@2
   118
void ExportASCII::doExport()
insilmaril@0
   119
{
insilmaril@2
   120
	QFile file (outputFile);
insilmaril@2
   121
	if ( !file.open( QIODevice::WriteOnly ) )
insilmaril@2
   122
	{
insilmaril@2
   123
		// FIXME experimental, testing
insilmaril@2
   124
		qWarning ("ExportBase::exportXML  couldn't open "+outputFile);
insilmaril@2
   125
		return;
insilmaril@2
   126
	}
insilmaril@2
   127
	QTextStream ts( &file );	// use LANG decoding here...
insilmaril@2
   128
insilmaril@0
   129
	// Main loop over all branches
insilmaril@0
   130
	QString s;
insilmaril@0
   131
	QString actIndent("");
insilmaril@0
   132
	int i;
insilmaril@2
   133
	uint j;
insilmaril@0
   134
	BranchObj *bo;
insilmaril@0
   135
	bo=mapCenter->first();
insilmaril@0
   136
	while (bo) 
insilmaril@0
   137
	{
insilmaril@0
   138
		// Make indentstring
insilmaril@0
   139
		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
insilmaril@0
   140
insilmaril@2
   141
		if (bo->getDepth()==0)
insilmaril@2
   142
		{
insilmaril@2
   143
			ts << (bo->getHeading()+ "\n");
insilmaril@2
   144
			for (j=0;j<bo->getHeading().length();j++) ts<<"=";
insilmaril@2
   145
			ts << "\n";
insilmaril@2
   146
		} else 	if (bo->getDepth()==1)
insilmaril@2
   147
			ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
insilmaril@2
   148
		else	if (bo->getDepth()==2)
insilmaril@2
   149
			ts << (actIndent + " o " + bo->getHeading()+ "\n");
insilmaril@2
   150
		else	
insilmaril@2
   151
			ts << (actIndent + " - " + bo->getHeading()+ "\n");
insilmaril@0
   152
		
insilmaril@0
   153
		// If necessary, write note
insilmaril@0
   154
		if (!bo->getNote().isEmpty())
insilmaril@0
   155
		{
insilmaril@2
   156
			s =bo->getNoteASCII();
insilmaril@2
   157
			s=s.replace ("\n","\n"+actIndent);
insilmaril@2
   158
			ts << (s+"\n\n");
insilmaril@0
   159
		}
insilmaril@0
   160
		bo=bo->next();
insilmaril@0
   161
		actIndent="";
insilmaril@0
   162
	}
insilmaril@2
   163
	file.close();
insilmaril@0
   164
}
insilmaril@0
   165
insilmaril@2
   166
////////////////////////////////////////////////////////////////////////
insilmaril@2
   167
void ExportKDEBookmarks::doExport() 
insilmaril@0
   168
{
insilmaril@2
   169
	MapEditor *me=NULL;
insilmaril@2
   170
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@2
   171
	if (me)
insilmaril@2
   172
	{
insilmaril@2
   173
		WarningDialog dia;
insilmaril@2
   174
		dia.setCancelButton (true);
insilmaril@2
   175
		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
insilmaril@2
   176
		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
insilmaril@2
   177
		dia.setShowAgainName("/vym/warnings/overwriteKDEBookmarks");
insilmaril@2
   178
		if (dia.exec()==QDialog::Accepted)
insilmaril@2
   179
		{
insilmaril@2
   180
			me->exportXML(tmpDir.path());
insilmaril@2
   181
insilmaril@2
   182
			XSLTProc p;
insilmaril@2
   183
			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@2
   184
			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
insilmaril@2
   185
			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@2
   186
			p.process();
insilmaril@2
   187
insilmaril@2
   188
			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@9
   189
			QProcess *proc= new QProcess ();
insilmaril@9
   190
			proc->start( ub);
insilmaril@9
   191
			if (!proc->waitForStarted());
insilmaril@2
   192
			{
insilmaril@2
   193
				QMessageBox::warning(0, 
insilmaril@2
   194
					QObject::tr("Warning"),
insilmaril@2
   195
					QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
insilmaril@2
   196
			}	
insilmaril@2
   197
		}
insilmaril@2
   198
	}
insilmaril@2
   199
insilmaril@0
   200
}
insilmaril@0
   201
insilmaril@2
   202
////////////////////////////////////////////////////////////////////////
insilmaril@2
   203
void ExportFirefoxBookmarks::doExport() 
insilmaril@2
   204
{
insilmaril@2
   205
	MapEditor *me=NULL;
insilmaril@2
   206
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@2
   207
	if (me)
insilmaril@2
   208
	{
insilmaril@2
   209
		WarningDialog dia;
insilmaril@2
   210
		dia.setCancelButton (true);
insilmaril@2
   211
		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("Firefox"));
insilmaril@2
   212
		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("Firefox"));
insilmaril@2
   213
		dia.setShowAgainName("/vym/warnings/overwriteImportBookmarks");
insilmaril@2
   214
		if (dia.exec()==QDialog::Accepted)
insilmaril@2
   215
		{
insilmaril@2
   216
			me->exportXML(tmpDir.path());
insilmaril@2
   217
insilmaril@2
   218
/*
insilmaril@2
   219
			XSLTProc p;
insilmaril@2
   220
			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@2
   221
			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
insilmaril@2
   222
			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@2
   223
			p.process();
insilmaril@2
   224
insilmaril@2
   225
			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@2
   226
			QProcess *proc = new QProcess( );
insilmaril@2
   227
			proc->addArgument(ub);
insilmaril@2
   228
insilmaril@2
   229
			if ( !proc->start() ) 
insilmaril@2
   230
			{
insilmaril@2
   231
				QMessageBox::warning(0, 
insilmaril@2
   232
					QObject::tr("Warning"),
insilmaril@2
   233
					QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
insilmaril@2
   234
			}	
insilmaril@2
   235
insilmaril@2
   236
*/
insilmaril@2
   237
insilmaril@2
   238
		}
insilmaril@2
   239
	}
insilmaril@2
   240
}
insilmaril@2
   241
insilmaril@2
   242
////////////////////////////////////////////////////////////////////////
insilmaril@2
   243
void ExportTaskjuggler::doExport() 
insilmaril@2
   244
{
insilmaril@2
   245
	MapEditor *me=NULL;
insilmaril@2
   246
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@2
   247
	if (me)
insilmaril@2
   248
	{
insilmaril@2
   249
		me->exportXML(tmpDir.path());
insilmaril@2
   250
insilmaril@2
   251
		XSLTProc p;
insilmaril@2
   252
		p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@2
   253
		p.setOutputFile (outputFile);
insilmaril@2
   254
		p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
insilmaril@2
   255
		p.process();
insilmaril@2
   256
	}
insilmaril@2
   257
insilmaril@2
   258
}
insilmaril@2
   259
insilmaril@2
   260
////////////////////////////////////////////////////////////////////////
insilmaril@2
   261
void ExportLaTeX::doExport() 
insilmaril@2
   262
{
insilmaril@2
   263
	// Exports a map to a LaTex file.  
insilmaril@2
   264
	// This file needs to be included 
insilmaril@2
   265
	// or inported into a LaTex document
insilmaril@2
   266
	// it will not add a preamble, or anything 
insilmaril@2
   267
	// that makes a full LaTex document.
insilmaril@2
   268
  QFile file (outputFile);
insilmaril@2
   269
  if ( !file.open( QIODevice::WriteOnly ) ) {
insilmaril@2
   270
	QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile));
insilmaril@2
   271
	mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@2
   272
    return;
insilmaril@2
   273
  }
insilmaril@2
   274
  QTextStream ts( &file );	// use LANG decoding here...
insilmaril@2
   275
  ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
insilmaril@2
   276
  
insilmaril@2
   277
  // Main loop over all branches
insilmaril@2
   278
  QString s;
insilmaril@2
   279
  // QString actIndent("");
insilmaril@2
   280
  // int i;
insilmaril@2
   281
  BranchObj *bo;
insilmaril@2
   282
  bo=mapCenter->first();
insilmaril@2
   283
  while (bo) {
insilmaril@2
   284
	if (bo->getDepth()==0);
insilmaril@2
   285
	else if (bo->getDepth()==1) {
insilmaril@2
   286
	  ts << ("\\chapter{" + bo->getHeading()+ "}\n");
insilmaril@2
   287
	}
insilmaril@2
   288
	else if (bo->getDepth()==2) {
insilmaril@2
   289
	  ts << ("\\section{" + bo->getHeading()+ "}\n");
insilmaril@2
   290
	}
insilmaril@2
   291
	else if (bo->getDepth()==3) {
insilmaril@2
   292
	  ts << ("\\subsection{" + bo->getHeading()+ "}\n");
insilmaril@2
   293
	}
insilmaril@2
   294
	else if (bo->getDepth()==4) {
insilmaril@2
   295
	  ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
insilmaril@2
   296
	}
insilmaril@2
   297
	else {
insilmaril@2
   298
	  ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
insilmaril@2
   299
	}
insilmaril@2
   300
	
insilmaril@2
   301
	// If necessary, write note
insilmaril@2
   302
	if (!bo->getNote().isEmpty()) {
insilmaril@2
   303
	  ts << (bo->getNoteASCII());
insilmaril@2
   304
	  ts << ("\n");
insilmaril@2
   305
	}
insilmaril@2
   306
    bo=bo->next();
insilmaril@2
   307
   }
insilmaril@2
   308
  file.close();
insilmaril@2
   309
}
insilmaril@2
   310
insilmaril@2
   311
////////////////////////////////////////////////////////////////////////
insilmaril@2
   312
ExportOO::ExportOO()
insilmaril@2
   313
{
insilmaril@2
   314
	useSections=false;
insilmaril@2
   315
}
insilmaril@2
   316
insilmaril@2
   317
ExportOO::~ExportOO()
insilmaril@2
   318
{
insilmaril@2
   319
}	
insilmaril@2
   320
insilmaril@2
   321
QString ExportOO::buildList (BranchObj *current)
insilmaril@2
   322
{
insilmaril@2
   323
    QString r;
insilmaril@2
   324
    BranchObj *bo;
insilmaril@2
   325
insilmaril@2
   326
    uint i=0;
insilmaril@2
   327
    bo=current->getFirstBranch();
insilmaril@2
   328
    if (bo)
insilmaril@2
   329
    {
insilmaril@2
   330
        // Start list
insilmaril@2
   331
        r+="<text:list text:style-name=\"vym-list\">\n";
insilmaril@2
   332
        while (bo)
insilmaril@2
   333
        {
insilmaril@2
   334
			r+="<text:list-item><text:p >";
insilmaril@2
   335
			r+=quotemeta(bo->getHeading());
insilmaril@2
   336
			// If necessary, write note
insilmaril@2
   337
			if (!bo->getNote().isEmpty())
insilmaril@2
   338
				r+=bo->getNoteOpenDoc();
insilmaril@2
   339
			r+="</text:p>";
insilmaril@2
   340
			r+=buildList (bo);	// recursivly add deeper branches
insilmaril@2
   341
			r+="</text:list-item>\n";
insilmaril@2
   342
			i++;
insilmaril@2
   343
			bo=current->getBranchNum(i);
insilmaril@2
   344
        }
insilmaril@2
   345
        r+="</text:list>\n";
insilmaril@2
   346
    }
insilmaril@2
   347
    return r;
insilmaril@2
   348
}
insilmaril@2
   349
insilmaril@2
   350
insilmaril@2
   351
void ExportOO::exportPresentation()
insilmaril@2
   352
{
insilmaril@2
   353
	QString allPages;
insilmaril@2
   354
insilmaril@2
   355
	// Insert new content
insilmaril@2
   356
	content.replace ("<!-- INSERT TITLE -->",quotemeta(mapCenter->getHeading()));
insilmaril@2
   357
	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(mapCenter->getAuthor()));
insilmaril@2
   358
insilmaril@2
   359
	QString	onePage;
insilmaril@2
   360
	QString list;
insilmaril@2
   361
	
insilmaril@2
   362
	BranchObj *sectionBO=mapCenter->getFirstBranch();
insilmaril@2
   363
    int i=0;
insilmaril@2
   364
	BranchObj *pagesBO;
insilmaril@2
   365
    int j=0;
insilmaril@2
   366
insilmaril@2
   367
	// Walk sections
insilmaril@2
   368
	while (sectionBO)
insilmaril@2
   369
	{
insilmaril@2
   370
		if (useSections)
insilmaril@2
   371
		{
insilmaril@2
   372
			// Add page with section title
insilmaril@2
   373
			onePage=sectionTemplate;
insilmaril@2
   374
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBO->getHeading() ) );
insilmaril@2
   375
			allPages+=onePage;
insilmaril@2
   376
		} else
insilmaril@2
   377
		{
insilmaril@2
   378
			i=-2;	// only use inner loop to 
insilmaril@2
   379
			        // turn mainbranches into pages
insilmaril@2
   380
			sectionBO=mapCenter;
insilmaril@2
   381
		}
insilmaril@2
   382
insilmaril@2
   383
		// Walk mainpages
insilmaril@2
   384
		pagesBO=sectionBO->getFirstBranch();
insilmaril@2
   385
		j=0;
insilmaril@2
   386
		while (pagesBO)
insilmaril@2
   387
		{
insilmaril@2
   388
			// Add page with list of items
insilmaril@2
   389
			onePage=pageTemplate;
insilmaril@2
   390
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
insilmaril@2
   391
			list=buildList (pagesBO);
insilmaril@2
   392
			onePage.replace ("<!-- INSERT LIST -->", list);
insilmaril@2
   393
			allPages+=onePage;
insilmaril@2
   394
			j++;
insilmaril@2
   395
			pagesBO=sectionBO->getBranchNum(j);
insilmaril@2
   396
		}
insilmaril@2
   397
		i++;
insilmaril@2
   398
		sectionBO=mapCenter->getBranchNum(i);
insilmaril@2
   399
	}
insilmaril@2
   400
	
insilmaril@2
   401
	content.replace ("<!-- INSERT PAGES -->",allPages);
insilmaril@2
   402
insilmaril@2
   403
	// Write modified content
insilmaril@2
   404
	QFile f (contentFile);
insilmaril@2
   405
    if ( !f.open( QIODevice::WriteOnly ) ) 
insilmaril@2
   406
	{
insilmaril@2
   407
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(contentFile));
insilmaril@2
   408
		mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@2
   409
		return;
insilmaril@2
   410
    }
insilmaril@2
   411
insilmaril@2
   412
    QTextStream t( &f );
insilmaril@2
   413
    t << content;
insilmaril@2
   414
    f.close();
insilmaril@2
   415
insilmaril@2
   416
	// zip tmpdir to destination
insilmaril@2
   417
	zipDir (tmpDir,outputFile);	
insilmaril@2
   418
}
insilmaril@2
   419
insilmaril@2
   420
bool ExportOO::setConfigFile (const QString &cf)
insilmaril@2
   421
{
insilmaril@2
   422
	configFile=cf;
insilmaril@2
   423
	int i=cf.findRev ("/");
insilmaril@2
   424
	if (i>=0) configDir=cf.left(i);
insilmaril@2
   425
	SimpleSettings set;
insilmaril@2
   426
	set.readSettings(configFile);
insilmaril@2
   427
insilmaril@2
   428
	// set paths
insilmaril@2
   429
	templateDir=configDir+"/"+set.readEntry ("Template");
insilmaril@2
   430
insilmaril@2
   431
	QDir d (templateDir);
insilmaril@2
   432
	if (!d.exists())
insilmaril@2
   433
	{
insilmaril@2
   434
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Check \"%1\" in\n%2").arg("Template="+set.readEntry ("Template")).arg(configFile));
insilmaril@2
   435
		return false;
insilmaril@2
   436
insilmaril@2
   437
	}
insilmaril@2
   438
insilmaril@2
   439
	contentTemplateFile=templateDir+"content-template.xml";
insilmaril@2
   440
	contentFile=tmpDir.path()+"/content.xml";
insilmaril@2
   441
	pageTemplateFile=templateDir+"page-template.xml";
insilmaril@2
   442
	sectionTemplateFile=templateDir+"section-template.xml";
insilmaril@2
   443
insilmaril@2
   444
	if (set.readEntry("useSections").contains("yes"))
insilmaril@2
   445
		useSections=true;
insilmaril@2
   446
insilmaril@2
   447
	// Copy template to tmpdir
insilmaril@2
   448
	system ("cp -r "+templateDir+"* "+tmpDir.path());
insilmaril@2
   449
insilmaril@2
   450
	// Read content-template
insilmaril@2
   451
	if (!loadStringFromDisk (contentTemplateFile,content))
insilmaril@2
   452
	{
insilmaril@2
   453
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(contentTemplateFile));
insilmaril@2
   454
		return false;
insilmaril@2
   455
	}
insilmaril@2
   456
insilmaril@2
   457
	// Read page-template
insilmaril@2
   458
	if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
insilmaril@2
   459
	{
insilmaril@2
   460
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(pageTemplateFile));
insilmaril@2
   461
		return false;
insilmaril@2
   462
	}
insilmaril@2
   463
	
insilmaril@2
   464
	// Read section-template
insilmaril@2
   465
	if (useSections && !loadStringFromDisk (sectionTemplateFile,sectionTemplate))
insilmaril@2
   466
	{
insilmaril@2
   467
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(sectionTemplateFile));
insilmaril@2
   468
		return false;
insilmaril@2
   469
	}
insilmaril@2
   470
	return true;
insilmaril@2
   471
}
insilmaril@2
   472