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