exports.cpp
author insilmaril
Thu May 17 20:19:03 2007 +0000 (2007-05-17)
changeset 491 c58b3973337c
parent 432 f867269ab8a1
child 497 ab118b86bc54
permissions -rw-r--r--
minor bugfixes
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@440
   134
		cout << "export bo="<<bo->getHeading().ascii()<<endl;
insilmaril@254
   135
		// Make indentstring
insilmaril@254
   136
		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
insilmaril@254
   137
insilmaril@254
   138
		if (bo->getDepth()==0)
insilmaril@239
   139
		{
insilmaril@254
   140
			ts << (bo->getHeading()+ "\n");
insilmaril@254
   141
			for (j=0;j<bo->getHeading().length();j++) ts<<"=";
insilmaril@254
   142
			ts << "\n";
insilmaril@254
   143
		} else 	if (bo->getDepth()==1)
insilmaril@254
   144
			ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
insilmaril@254
   145
		else	if (bo->getDepth()==2)
insilmaril@440
   146
			ts << (actIndent + " * " + bo->getHeading()+ "\n");
insilmaril@440
   147
		else	if (bo->getDepth()==3)
insilmaril@254
   148
			ts << (actIndent + " o " + bo->getHeading()+ "\n");
insilmaril@254
   149
		else	
insilmaril@254
   150
			ts << (actIndent + " - " + bo->getHeading()+ "\n");
insilmaril@254
   151
		
insilmaril@254
   152
		// If necessary, write note
insilmaril@254
   153
		if (!bo->getNote().isEmpty())
insilmaril@254
   154
		{
insilmaril@254
   155
			s =bo->getNoteASCII();
insilmaril@254
   156
			s=s.replace ("\n","\n"+actIndent);
insilmaril@254
   157
			ts << (s+"\n\n");
insilmaril@0
   158
		}
insilmaril@0
   159
		bo=bo->next();
insilmaril@0
   160
		actIndent="";
insilmaril@0
   161
	}
insilmaril@0
   162
	file.close();
insilmaril@0
   163
}
insilmaril@0
   164
insilmaril@239
   165
////////////////////////////////////////////////////////////////////////
insilmaril@239
   166
void ExportKDEBookmarks::doExport() 
insilmaril@239
   167
{
insilmaril@239
   168
	MapEditor *me=NULL;
insilmaril@239
   169
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@239
   170
	if (me)
insilmaril@239
   171
	{
insilmaril@311
   172
		WarningDialog dia;
insilmaril@384
   173
		dia.showCancelButton (true);
insilmaril@311
   174
		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
insilmaril@311
   175
		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
insilmaril@432
   176
		dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
insilmaril@311
   177
		if (dia.exec()==QDialog::Accepted)
insilmaril@311
   178
		{
insilmaril@311
   179
			me->exportXML(tmpDir.path());
insilmaril@239
   180
insilmaril@311
   181
			XSLTProc p;
insilmaril@311
   182
			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@311
   183
			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
insilmaril@311
   184
			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@311
   185
			p.process();
insilmaril@311
   186
insilmaril@311
   187
			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@377
   188
			QProcess *proc= new QProcess ;
insilmaril@366
   189
			proc->start( ub);
insilmaril@377
   190
			if (!proc->waitForStarted())
insilmaril@311
   191
			{
insilmaril@311
   192
				QMessageBox::warning(0, 
insilmaril@311
   193
					QObject::tr("Warning"),
insilmaril@311
   194
					QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
insilmaril@311
   195
			}	
insilmaril@311
   196
		}
insilmaril@239
   197
	}
insilmaril@239
   198
insilmaril@239
   199
}
insilmaril@239
   200
insilmaril@239
   201
////////////////////////////////////////////////////////////////////////
insilmaril@311
   202
void ExportFirefoxBookmarks::doExport() 
insilmaril@311
   203
{
insilmaril@311
   204
	MapEditor *me=NULL;
insilmaril@311
   205
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@311
   206
	if (me)
insilmaril@311
   207
	{
insilmaril@311
   208
		WarningDialog dia;
insilmaril@384
   209
		dia.showCancelButton (true);
insilmaril@311
   210
		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("Firefox"));
insilmaril@311
   211
		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("Firefox"));
insilmaril@311
   212
		dia.setShowAgainName("/vym/warnings/overwriteImportBookmarks");
insilmaril@311
   213
		if (dia.exec()==QDialog::Accepted)
insilmaril@311
   214
		{
insilmaril@311
   215
			me->exportXML(tmpDir.path());
insilmaril@311
   216
insilmaril@311
   217
/*
insilmaril@311
   218
			XSLTProc p;
insilmaril@311
   219
			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@311
   220
			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
insilmaril@311
   221
			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@311
   222
			p.process();
insilmaril@311
   223
insilmaril@311
   224
			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@311
   225
			QProcess *proc = new QProcess( );
insilmaril@311
   226
			proc->addArgument(ub);
insilmaril@311
   227
insilmaril@311
   228
			if ( !proc->start() ) 
insilmaril@311
   229
			{
insilmaril@311
   230
				QMessageBox::warning(0, 
insilmaril@311
   231
					QObject::tr("Warning"),
insilmaril@311
   232
					QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
insilmaril@311
   233
			}	
insilmaril@311
   234
insilmaril@311
   235
*/
insilmaril@311
   236
insilmaril@311
   237
		}
insilmaril@311
   238
	}
insilmaril@311
   239
}
insilmaril@311
   240
insilmaril@311
   241
////////////////////////////////////////////////////////////////////////
insilmaril@228
   242
void ExportTaskjuggler::doExport() 
insilmaril@228
   243
{
insilmaril@228
   244
	MapEditor *me=NULL;
insilmaril@228
   245
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@228
   246
	if (me)
insilmaril@228
   247
	{
insilmaril@228
   248
		me->exportXML(tmpDir.path());
insilmaril@228
   249
insilmaril@228
   250
		XSLTProc p;
insilmaril@228
   251
		p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@228
   252
		p.setOutputFile (outputFile);
insilmaril@228
   253
		p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
insilmaril@228
   254
		p.process();
insilmaril@228
   255
	}
insilmaril@228
   256
insilmaril@228
   257
}
insilmaril@228
   258
insilmaril@239
   259
////////////////////////////////////////////////////////////////////////
insilmaril@228
   260
void ExportLaTeX::doExport() 
insilmaril@0
   261
{
insilmaril@183
   262
	// Exports a map to a LaTex file.  
insilmaril@183
   263
	// This file needs to be included 
insilmaril@183
   264
	// or inported into a LaTex document
insilmaril@183
   265
	// it will not add a preamble, or anything 
insilmaril@183
   266
	// that makes a full LaTex document.
insilmaril@199
   267
  QFile file (outputFile);
insilmaril@366
   268
  if ( !file.open( QIODevice::WriteOnly ) ) {
insilmaril@205
   269
	QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile));
insilmaril@205
   270
	mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@163
   271
    return;
insilmaril@163
   272
  }
insilmaril@163
   273
  QTextStream ts( &file );	// use LANG decoding here...
insilmaril@163
   274
  ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
insilmaril@163
   275
  
insilmaril@163
   276
  // Main loop over all branches
insilmaril@163
   277
  QString s;
insilmaril@163
   278
  // QString actIndent("");
insilmaril@163
   279
  // int i;
insilmaril@163
   280
  BranchObj *bo;
insilmaril@163
   281
  bo=mapCenter->first();
insilmaril@163
   282
  while (bo) {
insilmaril@254
   283
	if (bo->getDepth()==0);
insilmaril@254
   284
	else if (bo->getDepth()==1) {
insilmaril@254
   285
	  ts << ("\\chapter{" + bo->getHeading()+ "}\n");
insilmaril@254
   286
	}
insilmaril@254
   287
	else if (bo->getDepth()==2) {
insilmaril@254
   288
	  ts << ("\\section{" + bo->getHeading()+ "}\n");
insilmaril@254
   289
	}
insilmaril@254
   290
	else if (bo->getDepth()==3) {
insilmaril@254
   291
	  ts << ("\\subsection{" + bo->getHeading()+ "}\n");
insilmaril@254
   292
	}
insilmaril@254
   293
	else if (bo->getDepth()==4) {
insilmaril@254
   294
	  ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
insilmaril@254
   295
	}
insilmaril@254
   296
	else {
insilmaril@254
   297
	  ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
insilmaril@254
   298
	}
insilmaril@254
   299
	
insilmaril@254
   300
	// If necessary, write note
insilmaril@254
   301
	if (!bo->getNote().isEmpty()) {
insilmaril@254
   302
	  ts << (bo->getNoteASCII());
insilmaril@254
   303
	  ts << ("\n");
insilmaril@254
   304
	}
insilmaril@163
   305
    bo=bo->next();
insilmaril@163
   306
   }
insilmaril@163
   307
  file.close();
insilmaril@0
   308
}
insilmaril@0
   309
insilmaril@239
   310
////////////////////////////////////////////////////////////////////////
insilmaril@171
   311
ExportOO::ExportOO()
insilmaril@171
   312
{
insilmaril@199
   313
	useSections=false;
insilmaril@171
   314
}
insilmaril@163
   315
insilmaril@171
   316
ExportOO::~ExportOO()
insilmaril@171
   317
{
insilmaril@171
   318
}	
insilmaril@163
   319
insilmaril@171
   320
QString ExportOO::buildList (BranchObj *current)
insilmaril@171
   321
{
insilmaril@171
   322
    QString r;
insilmaril@171
   323
    BranchObj *bo;
insilmaril@183
   324
insilmaril@183
   325
    uint i=0;
insilmaril@171
   326
    bo=current->getFirstBranch();
insilmaril@171
   327
    if (bo)
insilmaril@171
   328
    {
insilmaril@171
   329
        // Start list
insilmaril@234
   330
        r+="<text:list text:style-name=\"vym-list\">\n";
insilmaril@171
   331
        while (bo)
insilmaril@171
   332
        {
insilmaril@254
   333
			r+="<text:list-item><text:p >";
insilmaril@254
   334
			r+=quotemeta(bo->getHeading());
insilmaril@254
   335
			// If necessary, write note
insilmaril@254
   336
			if (!bo->getNote().isEmpty())
insilmaril@254
   337
				r+=bo->getNoteOpenDoc();
insilmaril@254
   338
			r+="</text:p>";
insilmaril@254
   339
			r+=buildList (bo);	// recursivly add deeper branches
insilmaril@254
   340
			r+="</text:list-item>\n";
insilmaril@183
   341
			i++;
insilmaril@183
   342
			bo=current->getBranchNum(i);
insilmaril@171
   343
        }
insilmaril@171
   344
        r+="</text:list>\n";
insilmaril@171
   345
    }
insilmaril@171
   346
    return r;
insilmaril@171
   347
}
insilmaril@163
   348
insilmaril@171
   349
insilmaril@171
   350
void ExportOO::exportPresentation()
insilmaril@171
   351
{
insilmaril@183
   352
	QString allPages;
insilmaril@171
   353
insilmaril@163
   354
	// Insert new content
insilmaril@171
   355
	content.replace ("<!-- INSERT TITLE -->",quotemeta(mapCenter->getHeading()));
insilmaril@171
   356
	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(mapCenter->getAuthor()));
insilmaril@183
   357
insilmaril@183
   358
	QString	onePage;
insilmaril@183
   359
	QString list;
insilmaril@183
   360
	
insilmaril@194
   361
	BranchObj *sectionBO=mapCenter->getFirstBranch();
insilmaril@183
   362
    int i=0;
insilmaril@183
   363
	BranchObj *pagesBO;
insilmaril@183
   364
    int j=0;
insilmaril@183
   365
insilmaril@194
   366
	// Walk sections
insilmaril@194
   367
	while (sectionBO)
insilmaril@183
   368
	{
insilmaril@194
   369
		if (useSections)
insilmaril@183
   370
		{
insilmaril@194
   371
			// Add page with section title
insilmaril@194
   372
			onePage=sectionTemplate;
insilmaril@194
   373
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBO->getHeading() ) );
insilmaril@183
   374
			allPages+=onePage;
insilmaril@183
   375
		} else
insilmaril@183
   376
		{
insilmaril@183
   377
			i=-2;	// only use inner loop to 
insilmaril@183
   378
			        // turn mainbranches into pages
insilmaril@194
   379
			sectionBO=mapCenter;
insilmaril@183
   380
		}
insilmaril@183
   381
insilmaril@183
   382
		// Walk mainpages
insilmaril@194
   383
		pagesBO=sectionBO->getFirstBranch();
insilmaril@183
   384
		j=0;
insilmaril@183
   385
		while (pagesBO)
insilmaril@183
   386
		{
insilmaril@183
   387
			// Add page with list of items
insilmaril@254
   388
			onePage=pageTemplate;
insilmaril@254
   389
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
insilmaril@254
   390
			list=buildList (pagesBO);
insilmaril@254
   391
			onePage.replace ("<!-- INSERT LIST -->", list);
insilmaril@254
   392
			allPages+=onePage;
insilmaril@183
   393
			j++;
insilmaril@194
   394
			pagesBO=sectionBO->getBranchNum(j);
insilmaril@183
   395
		}
insilmaril@183
   396
		i++;
insilmaril@194
   397
		sectionBO=mapCenter->getBranchNum(i);
insilmaril@183
   398
	}
insilmaril@183
   399
	
insilmaril@171
   400
	content.replace ("<!-- INSERT PAGES -->",allPages);
insilmaril@171
   401
insilmaril@171
   402
	// Write modified content
insilmaril@171
   403
	QFile f (contentFile);
insilmaril@366
   404
    if ( !f.open( QIODevice::WriteOnly ) ) 
insilmaril@171
   405
	{
insilmaril@205
   406
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(contentFile));
insilmaril@205
   407
		mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@171
   408
		return;
insilmaril@171
   409
    }
insilmaril@171
   410
insilmaril@171
   411
    QTextStream t( &f );
insilmaril@171
   412
    t << content;
insilmaril@171
   413
    f.close();
insilmaril@171
   414
insilmaril@163
   415
	// zip tmpdir to destination
insilmaril@171
   416
	zipDir (tmpDir,outputFile);	
insilmaril@163
   417
}
insilmaril@163
   418
insilmaril@194
   419
bool ExportOO::setConfigFile (const QString &cf)
insilmaril@183
   420
{
insilmaril@183
   421
	configFile=cf;
insilmaril@183
   422
	int i=cf.findRev ("/");
insilmaril@183
   423
	if (i>=0) configDir=cf.left(i);
insilmaril@183
   424
	SimpleSettings set;
insilmaril@183
   425
	set.readSettings(configFile);
insilmaril@183
   426
insilmaril@183
   427
	// set paths
insilmaril@183
   428
	templateDir=configDir+"/"+set.readEntry ("Template");
insilmaril@183
   429
insilmaril@194
   430
	QDir d (templateDir);
insilmaril@194
   431
	if (!d.exists())
insilmaril@194
   432
	{
insilmaril@194
   433
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Check \"%1\" in\n%2").arg("Template="+set.readEntry ("Template")).arg(configFile));
insilmaril@194
   434
		return false;
insilmaril@194
   435
insilmaril@194
   436
	}
insilmaril@183
   437
insilmaril@183
   438
	contentTemplateFile=templateDir+"content-template.xml";
insilmaril@183
   439
	contentFile=tmpDir.path()+"/content.xml";
insilmaril@183
   440
	pageTemplateFile=templateDir+"page-template.xml";
insilmaril@194
   441
	sectionTemplateFile=templateDir+"section-template.xml";
insilmaril@183
   442
insilmaril@199
   443
	if (set.readEntry("useSections").contains("yes"))
insilmaril@199
   444
		useSections=true;
insilmaril@199
   445
insilmaril@183
   446
	// Copy template to tmpdir
insilmaril@183
   447
	system ("cp -r "+templateDir+"* "+tmpDir.path());
insilmaril@183
   448
insilmaril@183
   449
	// Read content-template
insilmaril@183
   450
	if (!loadStringFromDisk (contentTemplateFile,content))
insilmaril@183
   451
	{
insilmaril@194
   452
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(contentTemplateFile));
insilmaril@194
   453
		return false;
insilmaril@183
   454
	}
insilmaril@183
   455
insilmaril@183
   456
	// Read page-template
insilmaril@183
   457
	if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
insilmaril@183
   458
	{
insilmaril@194
   459
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(pageTemplateFile));
insilmaril@194
   460
		return false;
insilmaril@183
   461
	}
insilmaril@183
   462
	
insilmaril@194
   463
	// Read section-template
insilmaril@201
   464
	if (useSections && !loadStringFromDisk (sectionTemplateFile,sectionTemplate))
insilmaril@183
   465
	{
insilmaril@194
   466
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(sectionTemplateFile));
insilmaril@194
   467
		return false;
insilmaril@183
   468
	}
insilmaril@194
   469
	return true;
insilmaril@183
   470
}
insilmaril@183
   471