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