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