exports.cpp
author insilmaril
Fri, 16 Jun 2006 10:29:37 +0000
changeset 354 1c6c6a1c411f
parent 311 6a7db028088e
child 366 e95081c21da2
permissions -rw-r--r--
added newbranch icon to edit menu
insilmaril@228
     1
#include <qfiledialog.h>
insilmaril@194
     2
#include <qmessagebox.h>
insilmaril@311
     3
#include <qprocess.h>
insilmaril@194
     4
insilmaril@0
     5
#include "exports.h"
insilmaril@171
     6
#include "file.h"
insilmaril@171
     7
#include "linkablemapobj.h"
insilmaril@171
     8
#include "misc.h"
insilmaril@171
     9
#include "mainwindow.h"
insilmaril@311
    10
#include "warningdialog.h"
insilmaril@228
    11
#include "xsltproc.h"
insilmaril@0
    12
insilmaril@171
    13
extern Main *mainWindow;
insilmaril@228
    14
extern QDir vymBaseDir;
insilmaril@228
    15
insilmaril@131
    16
insilmaril@171
    17
ExportBase::ExportBase()
insilmaril@0
    18
{
insilmaril@0
    19
	indentPerDepth="  ";
insilmaril@228
    20
	// Create tmpdir
insilmaril@228
    21
	tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX"));
insilmaril@228
    22
}
insilmaril@228
    23
insilmaril@228
    24
ExportBase::~ExportBase()
insilmaril@228
    25
{
insilmaril@228
    26
	// Remove tmpdir
insilmaril@228
    27
	removeDir (tmpDir);
insilmaril@0
    28
}
insilmaril@0
    29
insilmaril@199
    30
void ExportBase::setDir(const QString &p)
insilmaril@0
    31
{
insilmaril@199
    32
	outputDir=p;
insilmaril@199
    33
}
insilmaril@199
    34
insilmaril@199
    35
void ExportBase::setFile (const QString &p)
insilmaril@199
    36
{
insilmaril@199
    37
	outputFile=p;
insilmaril@0
    38
}
insilmaril@0
    39
insilmaril@171
    40
void ExportBase::setMapCenter(MapCenterObj *mc)
insilmaril@0
    41
{
insilmaril@0
    42
	mapCenter=mc;
insilmaril@0
    43
}
insilmaril@0
    44
insilmaril@228
    45
void ExportBase::setCaption (const QString &s)
insilmaril@228
    46
{
insilmaril@228
    47
	caption=s;
insilmaril@228
    48
}
insilmaril@228
    49
insilmaril@228
    50
void ExportBase::addFilter(const QString &s)
insilmaril@228
    51
{
insilmaril@228
    52
	filter=s;
insilmaril@228
    53
}
insilmaril@228
    54
insilmaril@228
    55
bool ExportBase::execDialog()
insilmaril@228
    56
{
insilmaril@228
    57
	if (mapCenter && mapCenter->getMapEditor())
insilmaril@228
    58
	{
insilmaril@228
    59
		QFileDialog *fd=new QFileDialog( mapCenter->getMapEditor(), caption);
insilmaril@228
    60
		fd->addFilter (filter);
insilmaril@228
    61
		fd->setCaption(caption);
insilmaril@228
    62
		fd->setMode( QFileDialog::AnyFile );
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@228
    69
				QMessageBox mb( __VYM,
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@228
    74
				QMessageBox::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@0
   119
	if ( !file.open( IO_WriteOnly ) )
insilmaril@0
   120
	{
insilmaril@131
   121
		// FIXME experimental, testing
insilmaril@228
   122
		qWarning ("ExportBase::exportXML  couldn't open "+outputFile);
insilmaril@0
   123
		return;
insilmaril@0
   124
	}
insilmaril@0
   125
	QTextStream ts( &file );	// use LANG decoding here...
insilmaril@0
   126
insilmaril@0
   127
	// Main loop over all branches
insilmaril@0
   128
	QString s;
insilmaril@0
   129
	QString actIndent("");
insilmaril@160
   130
	int i;
insilmaril@160
   131
	uint j;
insilmaril@0
   132
	BranchObj *bo;
insilmaril@0
   133
	bo=mapCenter->first();
insilmaril@0
   134
	while (bo) 
insilmaril@0
   135
	{
insilmaril@254
   136
		// Make indentstring
insilmaril@254
   137
		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
insilmaril@254
   138
insilmaril@254
   139
		if (bo->getDepth()==0)
insilmaril@239
   140
		{
insilmaril@254
   141
			ts << (bo->getHeading()+ "\n");
insilmaril@254
   142
			for (j=0;j<bo->getHeading().length();j++) ts<<"=";
insilmaril@254
   143
			ts << "\n";
insilmaril@254
   144
		} else 	if (bo->getDepth()==1)
insilmaril@254
   145
			ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
insilmaril@254
   146
		else	if (bo->getDepth()==2)
insilmaril@254
   147
			ts << (actIndent + " o " + bo->getHeading()+ "\n");
insilmaril@254
   148
		else	
insilmaril@254
   149
			ts << (actIndent + " - " + bo->getHeading()+ "\n");
insilmaril@254
   150
		
insilmaril@254
   151
		// If necessary, write note
insilmaril@254
   152
		if (!bo->getNote().isEmpty())
insilmaril@254
   153
		{
insilmaril@254
   154
			s =bo->getNoteASCII();
insilmaril@254
   155
			s=s.replace ("\n","\n"+actIndent);
insilmaril@254
   156
			ts << (s+"\n\n");
insilmaril@0
   157
		}
insilmaril@0
   158
		bo=bo->next();
insilmaril@0
   159
		actIndent="";
insilmaril@0
   160
	}
insilmaril@0
   161
	file.close();
insilmaril@0
   162
}
insilmaril@0
   163
insilmaril@239
   164
////////////////////////////////////////////////////////////////////////
insilmaril@239
   165
void ExportKDEBookmarks::doExport() 
insilmaril@239
   166
{
insilmaril@239
   167
	MapEditor *me=NULL;
insilmaril@239
   168
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@239
   169
	if (me)
insilmaril@239
   170
	{
insilmaril@311
   171
		WarningDialog dia;
insilmaril@311
   172
		dia.setCancelButton (true);
insilmaril@311
   173
		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
insilmaril@311
   174
		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
insilmaril@311
   175
		dia.setShowAgainName("/vym/warnings/overwriteKDEBookmarks");
insilmaril@311
   176
		if (dia.exec()==QDialog::Accepted)
insilmaril@311
   177
		{
insilmaril@311
   178
			me->exportXML(tmpDir.path());
insilmaril@239
   179
insilmaril@311
   180
			XSLTProc p;
insilmaril@311
   181
			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@311
   182
			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
insilmaril@311
   183
			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@311
   184
			p.process();
insilmaril@311
   185
insilmaril@311
   186
			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@311
   187
			QProcess *proc = new QProcess( );
insilmaril@311
   188
			proc->addArgument(ub);
insilmaril@311
   189
insilmaril@311
   190
			if ( !proc->start() ) 
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@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
		//FIXME testing
insilmaril@228
   252
		cout << "tmpDir="<<tmpDir.path()<<endl;
insilmaril@228
   253
insilmaril@228
   254
		XSLTProc p;
insilmaril@228
   255
		p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@228
   256
		p.setOutputFile (outputFile);
insilmaril@228
   257
		p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
insilmaril@228
   258
		p.process();
insilmaril@228
   259
	}
insilmaril@228
   260
insilmaril@228
   261
}
insilmaril@228
   262
insilmaril@239
   263
////////////////////////////////////////////////////////////////////////
insilmaril@228
   264
void ExportLaTeX::doExport() 
insilmaril@0
   265
{
insilmaril@183
   266
	// Exports a map to a LaTex file.  
insilmaril@183
   267
	// This file needs to be included 
insilmaril@183
   268
	// or inported into a LaTex document
insilmaril@183
   269
	// it will not add a preamble, or anything 
insilmaril@183
   270
	// that makes a full LaTex document.
insilmaril@199
   271
  QFile file (outputFile);
insilmaril@163
   272
  if ( !file.open( IO_WriteOnly ) ) {
insilmaril@205
   273
	QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile));
insilmaril@205
   274
	mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@163
   275
    return;
insilmaril@163
   276
  }
insilmaril@163
   277
  QTextStream ts( &file );	// use LANG decoding here...
insilmaril@163
   278
  ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
insilmaril@163
   279
  
insilmaril@163
   280
  // Main loop over all branches
insilmaril@163
   281
  QString s;
insilmaril@163
   282
  // QString actIndent("");
insilmaril@163
   283
  // int i;
insilmaril@163
   284
  BranchObj *bo;
insilmaril@163
   285
  bo=mapCenter->first();
insilmaril@163
   286
  while (bo) {
insilmaril@254
   287
	if (bo->getDepth()==0);
insilmaril@254
   288
	else if (bo->getDepth()==1) {
insilmaril@254
   289
	  ts << ("\\chapter{" + bo->getHeading()+ "}\n");
insilmaril@254
   290
	}
insilmaril@254
   291
	else if (bo->getDepth()==2) {
insilmaril@254
   292
	  ts << ("\\section{" + bo->getHeading()+ "}\n");
insilmaril@254
   293
	}
insilmaril@254
   294
	else if (bo->getDepth()==3) {
insilmaril@254
   295
	  ts << ("\\subsection{" + bo->getHeading()+ "}\n");
insilmaril@254
   296
	}
insilmaril@254
   297
	else if (bo->getDepth()==4) {
insilmaril@254
   298
	  ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
insilmaril@254
   299
	}
insilmaril@254
   300
	else {
insilmaril@254
   301
	  ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
insilmaril@254
   302
	}
insilmaril@254
   303
	
insilmaril@254
   304
	// If necessary, write note
insilmaril@254
   305
	if (!bo->getNote().isEmpty()) {
insilmaril@254
   306
	  ts << (bo->getNoteASCII());
insilmaril@254
   307
	  ts << ("\n");
insilmaril@254
   308
	}
insilmaril@163
   309
    bo=bo->next();
insilmaril@163
   310
   }
insilmaril@163
   311
  file.close();
insilmaril@0
   312
}
insilmaril@0
   313
insilmaril@239
   314
////////////////////////////////////////////////////////////////////////
insilmaril@171
   315
ExportOO::ExportOO()
insilmaril@171
   316
{
insilmaril@199
   317
	useSections=false;
insilmaril@171
   318
}
insilmaril@163
   319
insilmaril@171
   320
ExportOO::~ExportOO()
insilmaril@171
   321
{
insilmaril@171
   322
}	
insilmaril@163
   323
insilmaril@171
   324
QString ExportOO::buildList (BranchObj *current)
insilmaril@171
   325
{
insilmaril@171
   326
    QString r;
insilmaril@171
   327
    BranchObj *bo;
insilmaril@183
   328
insilmaril@183
   329
    uint i=0;
insilmaril@171
   330
    bo=current->getFirstBranch();
insilmaril@171
   331
    if (bo)
insilmaril@171
   332
    {
insilmaril@171
   333
        // Start list
insilmaril@234
   334
        r+="<text:list text:style-name=\"vym-list\">\n";
insilmaril@171
   335
        while (bo)
insilmaril@171
   336
        {
insilmaril@254
   337
			r+="<text:list-item><text:p >";
insilmaril@254
   338
			r+=quotemeta(bo->getHeading());
insilmaril@254
   339
			// If necessary, write note
insilmaril@254
   340
			if (!bo->getNote().isEmpty())
insilmaril@254
   341
				r+=bo->getNoteOpenDoc();
insilmaril@254
   342
			r+="</text:p>";
insilmaril@254
   343
			r+=buildList (bo);	// recursivly add deeper branches
insilmaril@254
   344
			r+="</text:list-item>\n";
insilmaril@183
   345
			i++;
insilmaril@183
   346
			bo=current->getBranchNum(i);
insilmaril@171
   347
        }
insilmaril@171
   348
        r+="</text:list>\n";
insilmaril@171
   349
    }
insilmaril@171
   350
    return r;
insilmaril@171
   351
}
insilmaril@163
   352
insilmaril@171
   353
insilmaril@171
   354
void ExportOO::exportPresentation()
insilmaril@171
   355
{
insilmaril@183
   356
	QString allPages;
insilmaril@171
   357
insilmaril@163
   358
	// Insert new content
insilmaril@171
   359
	content.replace ("<!-- INSERT TITLE -->",quotemeta(mapCenter->getHeading()));
insilmaril@171
   360
	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(mapCenter->getAuthor()));
insilmaril@183
   361
insilmaril@183
   362
	QString	onePage;
insilmaril@183
   363
	QString list;
insilmaril@183
   364
	
insilmaril@194
   365
	BranchObj *sectionBO=mapCenter->getFirstBranch();
insilmaril@183
   366
    int i=0;
insilmaril@183
   367
	BranchObj *pagesBO;
insilmaril@183
   368
    int j=0;
insilmaril@183
   369
insilmaril@194
   370
	// Walk sections
insilmaril@194
   371
	while (sectionBO)
insilmaril@183
   372
	{
insilmaril@194
   373
		if (useSections)
insilmaril@183
   374
		{
insilmaril@194
   375
			// Add page with section title
insilmaril@194
   376
			onePage=sectionTemplate;
insilmaril@194
   377
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBO->getHeading() ) );
insilmaril@183
   378
			allPages+=onePage;
insilmaril@183
   379
		} else
insilmaril@183
   380
		{
insilmaril@183
   381
			i=-2;	// only use inner loop to 
insilmaril@183
   382
			        // turn mainbranches into pages
insilmaril@194
   383
			sectionBO=mapCenter;
insilmaril@183
   384
		}
insilmaril@183
   385
insilmaril@183
   386
		// Walk mainpages
insilmaril@194
   387
		pagesBO=sectionBO->getFirstBranch();
insilmaril@183
   388
		j=0;
insilmaril@183
   389
		while (pagesBO)
insilmaril@183
   390
		{
insilmaril@183
   391
			// Add page with list of items
insilmaril@254
   392
			onePage=pageTemplate;
insilmaril@254
   393
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
insilmaril@254
   394
			list=buildList (pagesBO);
insilmaril@254
   395
			onePage.replace ("<!-- INSERT LIST -->", list);
insilmaril@254
   396
			allPages+=onePage;
insilmaril@183
   397
			j++;
insilmaril@194
   398
			pagesBO=sectionBO->getBranchNum(j);
insilmaril@183
   399
		}
insilmaril@183
   400
		i++;
insilmaril@194
   401
		sectionBO=mapCenter->getBranchNum(i);
insilmaril@183
   402
	}
insilmaril@183
   403
	
insilmaril@171
   404
	content.replace ("<!-- INSERT PAGES -->",allPages);
insilmaril@171
   405
insilmaril@171
   406
	// Write modified content
insilmaril@171
   407
	QFile f (contentFile);
insilmaril@171
   408
    if ( !f.open( IO_WriteOnly ) ) 
insilmaril@171
   409
	{
insilmaril@205
   410
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(contentFile));
insilmaril@205
   411
		mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@171
   412
		return;
insilmaril@171
   413
    }
insilmaril@171
   414
insilmaril@171
   415
    QTextStream t( &f );
insilmaril@171
   416
    t << content;
insilmaril@171
   417
    f.close();
insilmaril@171
   418
insilmaril@163
   419
	// zip tmpdir to destination
insilmaril@171
   420
	zipDir (tmpDir,outputFile);	
insilmaril@163
   421
}
insilmaril@163
   422
insilmaril@194
   423
bool ExportOO::setConfigFile (const QString &cf)
insilmaril@183
   424
{
insilmaril@183
   425
	configFile=cf;
insilmaril@183
   426
	int i=cf.findRev ("/");
insilmaril@183
   427
	if (i>=0) configDir=cf.left(i);
insilmaril@183
   428
	SimpleSettings set;
insilmaril@183
   429
	set.readSettings(configFile);
insilmaril@183
   430
insilmaril@183
   431
	// set paths
insilmaril@183
   432
	templateDir=configDir+"/"+set.readEntry ("Template");
insilmaril@183
   433
insilmaril@194
   434
	QDir d (templateDir);
insilmaril@194
   435
	if (!d.exists())
insilmaril@194
   436
	{
insilmaril@194
   437
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Check \"%1\" in\n%2").arg("Template="+set.readEntry ("Template")).arg(configFile));
insilmaril@194
   438
		return false;
insilmaril@194
   439
insilmaril@194
   440
	}
insilmaril@183
   441
insilmaril@183
   442
	contentTemplateFile=templateDir+"content-template.xml";
insilmaril@183
   443
	contentFile=tmpDir.path()+"/content.xml";
insilmaril@183
   444
	pageTemplateFile=templateDir+"page-template.xml";
insilmaril@194
   445
	sectionTemplateFile=templateDir+"section-template.xml";
insilmaril@183
   446
insilmaril@199
   447
	if (set.readEntry("useSections").contains("yes"))
insilmaril@199
   448
		useSections=true;
insilmaril@199
   449
insilmaril@183
   450
	// Copy template to tmpdir
insilmaril@183
   451
	system ("cp -r "+templateDir+"* "+tmpDir.path());
insilmaril@183
   452
insilmaril@183
   453
	// Read content-template
insilmaril@183
   454
	if (!loadStringFromDisk (contentTemplateFile,content))
insilmaril@183
   455
	{
insilmaril@194
   456
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(contentTemplateFile));
insilmaril@194
   457
		return false;
insilmaril@183
   458
	}
insilmaril@183
   459
insilmaril@183
   460
	// Read page-template
insilmaril@183
   461
	if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
insilmaril@183
   462
	{
insilmaril@194
   463
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(pageTemplateFile));
insilmaril@194
   464
		return false;
insilmaril@183
   465
	}
insilmaril@183
   466
	
insilmaril@194
   467
	// Read section-template
insilmaril@201
   468
	if (useSections && !loadStringFromDisk (sectionTemplateFile,sectionTemplate))
insilmaril@183
   469
	{
insilmaril@194
   470
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(sectionTemplateFile));
insilmaril@194
   471
		return false;
insilmaril@183
   472
	}
insilmaril@194
   473
	return true;
insilmaril@183
   474
}
insilmaril@183
   475