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