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