exports.cpp
author insilmaril
Tue, 05 Jan 2010 11:23:12 +0000
changeset 820 735c7ea1d2a9
parent 819 8f987e376035
child 822 c2ce9944148c
permissions -rw-r--r--
Fixed dropping of URLs
insilmaril@0
     1
#include "exports.h"
insilmaril@750
     2
insilmaril@750
     3
#include "branchitem.h"
insilmaril@171
     4
#include "file.h"
insilmaril@171
     5
#include "linkablemapobj.h"
insilmaril@171
     6
#include "misc.h"
insilmaril@171
     7
#include "mainwindow.h"
insilmaril@311
     8
#include "warningdialog.h"
insilmaril@228
     9
#include "xsltproc.h"
insilmaril@0
    10
insilmaril@171
    11
extern Main *mainWindow;
insilmaril@228
    12
extern QDir vymBaseDir;
insilmaril@404
    13
extern QString vymName;
insilmaril@131
    14
insilmaril@171
    15
ExportBase::ExportBase()
insilmaril@0
    16
{
insilmaril@819
    17
	init();
insilmaril@819
    18
}
insilmaril@819
    19
insilmaril@819
    20
ExportBase::ExportBase(VymModel *m)
insilmaril@819
    21
{
insilmaril@819
    22
	init();
insilmaril@819
    23
	model=m;
insilmaril@819
    24
}
insilmaril@819
    25
insilmaril@819
    26
ExportBase::~ExportBase()
insilmaril@819
    27
{
insilmaril@819
    28
	// Cleanup tmpdir
insilmaril@819
    29
	removeDir (tmpDir);
insilmaril@819
    30
}
insilmaril@819
    31
insilmaril@819
    32
void ExportBase::init()
insilmaril@819
    33
{
insilmaril@0
    34
	indentPerDepth="  ";
insilmaril@377
    35
	bool ok;
insilmaril@606
    36
    tmpDir.setPath (makeTmpDir(ok,"vym-export"));
insilmaril@377
    37
	if (!tmpDir.exists() || !ok)
insilmaril@377
    38
		QMessageBox::critical( 0, QObject::tr( "Error" ),
insilmaril@377
    39
					   QObject::tr("Couldn't access temporary directory\n"));
insilmaril@512
    40
	cancelFlag=false;				   
insilmaril@228
    41
}
insilmaril@228
    42
insilmaril@424
    43
void ExportBase::setDir(const QDir &d)
insilmaril@0
    44
{
insilmaril@424
    45
	outDir=d;
insilmaril@199
    46
}
insilmaril@199
    47
insilmaril@199
    48
void ExportBase::setFile (const QString &p)
insilmaril@199
    49
{
insilmaril@199
    50
	outputFile=p;
insilmaril@0
    51
}
insilmaril@0
    52
insilmaril@512
    53
QString ExportBase::getFile ()
insilmaril@512
    54
{
insilmaril@512
    55
	return outputFile;
insilmaril@512
    56
}
insilmaril@512
    57
insilmaril@643
    58
void ExportBase::setModel(VymModel *m)
insilmaril@0
    59
{
insilmaril@643
    60
	model=m;
insilmaril@0
    61
}
insilmaril@0
    62
insilmaril@228
    63
void ExportBase::setCaption (const QString &s)
insilmaril@228
    64
{
insilmaril@228
    65
	caption=s;
insilmaril@228
    66
}
insilmaril@228
    67
insilmaril@228
    68
void ExportBase::addFilter(const QString &s)
insilmaril@228
    69
{
insilmaril@228
    70
	filter=s;
insilmaril@228
    71
}
insilmaril@228
    72
insilmaril@228
    73
bool ExportBase::execDialog()
insilmaril@228
    74
{
insilmaril@228
    75
	{
insilmaril@643
    76
		QFileDialog *fd=new QFileDialog( 0, caption);
insilmaril@366
    77
		fd->setFilter (filter);
insilmaril@228
    78
		fd->setCaption(caption);
insilmaril@228
    79
		fd->setMode( QFileDialog::AnyFile );
insilmaril@424
    80
		fd->setDir (outDir);
insilmaril@228
    81
		fd->show();
insilmaril@228
    82
insilmaril@228
    83
		if ( fd->exec() == QDialog::Accepted )
insilmaril@228
    84
		{
insilmaril@228
    85
			if (QFile (fd->selectedFile()).exists() )
insilmaril@228
    86
			{
insilmaril@404
    87
				QMessageBox mb( vymName,
insilmaril@228
    88
					QObject::tr("The file %1 exists already.\nDo you want to overwrite it?").arg(fd->selectedFile()), 
insilmaril@228
    89
				QMessageBox::Warning,
insilmaril@228
    90
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@228
    91
				QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
    92
				Qt::NoButton );
insilmaril@228
    93
				mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") );
insilmaril@228
    94
				mb.setButtonText( QMessageBox::No, QObject::tr("Cancel"));
insilmaril@228
    95
				ExportBase ex;
insilmaril@228
    96
				switch( mb.exec() ) 
insilmaril@228
    97
				{
insilmaril@228
    98
					case QMessageBox::Yes:
insilmaril@228
    99
						// save 
insilmaril@228
   100
						break;;
insilmaril@228
   101
					case QMessageBox::Cancel:
insilmaril@512
   102
						cancelFlag=true;
insilmaril@228
   103
						return false;
insilmaril@228
   104
						break;
insilmaril@228
   105
				}
insilmaril@228
   106
			}
insilmaril@228
   107
			outputFile=fd->selectedFile();
insilmaril@512
   108
			cancelFlag=false;
insilmaril@228
   109
			return true;
insilmaril@228
   110
		}
insilmaril@228
   111
	}
insilmaril@228
   112
	return false;
insilmaril@228
   113
}
insilmaril@228
   114
insilmaril@512
   115
bool ExportBase::canceled()
insilmaril@512
   116
{
insilmaril@512
   117
	return cancelFlag;
insilmaril@512
   118
}
insilmaril@512
   119
insilmaril@791
   120
QString ExportBase::getSectionString(TreeItem *start)
insilmaril@163
   121
{
insilmaril@205
   122
	// Make prefix like "2.5.3" for "bo:2,bo:5,bo:3"
insilmaril@163
   123
	QString r;
insilmaril@791
   124
	TreeItem *ti=start;
insilmaril@749
   125
	int depth=ti->depth();
insilmaril@163
   126
	while (depth>0)
insilmaril@163
   127
	{
insilmaril@749
   128
		r=QString("%1").arg(1+ti->num(),0,10)+"." + r;
insilmaril@749
   129
		ti=ti->parent(); 
insilmaril@749
   130
		depth=ti->depth();
insilmaril@163
   131
	}	
insilmaril@163
   132
	if (r.isEmpty())
insilmaril@163
   133
		return r;
insilmaril@163
   134
	else	
insilmaril@163
   135
		return r + " ";
insilmaril@163
   136
}
insilmaril@163
   137
insilmaril@239
   138
////////////////////////////////////////////////////////////////////////
insilmaril@807
   139
ExportAO::ExportAO()
insilmaril@807
   140
{
insilmaril@807
   141
	filter="TXT (*.txt)";
insilmaril@807
   142
	caption=vymName+ " -" +QObject::tr("Export as ASCII")+" "+QObject::tr("(still experimental)");
insilmaril@807
   143
}
insilmaril@807
   144
insilmaril@807
   145
void ExportAO::doExport()	
insilmaril@807
   146
{
insilmaril@807
   147
	QFile file (outputFile);
insilmaril@807
   148
	if ( !file.open( QIODevice::WriteOnly ) )
insilmaril@807
   149
	{
insilmaril@807
   150
		qWarning ("ExportAO::doExport couldn't open "+outputFile);
insilmaril@807
   151
		return;
insilmaril@807
   152
	}
insilmaril@807
   153
	QTextStream ts( &file );	// use LANG decoding here...
insilmaril@807
   154
insilmaril@807
   155
	// Main loop over all branches
insilmaril@807
   156
	QString s;
insilmaril@807
   157
	QString curIndent;
insilmaril@807
   158
	int i;
insilmaril@807
   159
	BranchItem *cur=NULL;
insilmaril@807
   160
	BranchItem *prev=NULL;
insilmaril@807
   161
insilmaril@807
   162
	QString colString;
insilmaril@807
   163
	QColor col;
insilmaril@807
   164
insilmaril@807
   165
	cur=model->nextBranch (cur,prev);
insilmaril@807
   166
	while (cur) 
insilmaril@807
   167
	{
insilmaril@807
   168
		if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
insilmaril@807
   169
		{
insilmaril@807
   170
			// Make indentstring
insilmaril@807
   171
			curIndent="";
insilmaril@807
   172
			for (i=0;i<cur->depth()-1;i++) curIndent+= indentPerDepth;
insilmaril@807
   173
insilmaril@807
   174
			if (!cur->hasHiddenExportParent() )
insilmaril@807
   175
			{
insilmaril@807
   176
				col=cur->getHeadingColor();
insilmaril@807
   177
				if (col==QColor (255,0,0))
insilmaril@807
   178
					colString="[R]";
insilmaril@807
   179
				else if (col==QColor (217,81,0))
insilmaril@807
   180
					colString="[O]";
insilmaril@807
   181
				else if (col==QColor (0,85,0))
insilmaril@807
   182
					colString="[G]";
insilmaril@807
   183
				else  	
insilmaril@807
   184
					colString="[?]";
insilmaril@807
   185
				switch (cur->depth())
insilmaril@807
   186
				{
insilmaril@807
   187
					case 0:
insilmaril@807
   188
						//ts << underline (cur->getHeading(),QString("="));
insilmaril@807
   189
						//ts << "\n";
insilmaril@807
   190
						break;
insilmaril@807
   191
					case 1:
insilmaril@807
   192
						//ts << "\n";
insilmaril@807
   193
						//ts << (underline ( cur->getHeading(), QString("-") ) );
insilmaril@807
   194
						//ts << "\n";
insilmaril@807
   195
						break;
insilmaril@807
   196
					case 2: // Main heading
insilmaril@807
   197
						ts << "\n";
insilmaril@807
   198
						ts << underline ( cur->getHeading(), QString("=") );
insilmaril@818
   199
						ts << "\n";
insilmaril@807
   200
						break;
insilmaril@807
   201
					case 3: // Achievement, Bonus, Objective ...
insilmaril@818
   202
						ts << "\n\n";
insilmaril@807
   203
						ts << underline ( cur->getHeading(), "-");
insilmaril@807
   204
						ts << "\n\n";
insilmaril@807
   205
						break;
insilmaril@807
   206
					case 4:	// That's the item we need to know
insilmaril@815
   207
						//ts << (curIndent + "* " + colString+" "+ cur->getHeading());
insilmaril@815
   208
						ts << colString+" "+ cur->getHeading();
insilmaril@807
   209
						if (cur->isActiveStandardFlag ("hook-green"))
insilmaril@807
   210
							ts << " [DONE] ";
insilmaril@815
   211
						else	if (cur->isActiveStandardFlag ("wip"))
insilmaril@807
   212
							ts << " [WIP] ";
insilmaril@807
   213
						else	if (cur->isActiveStandardFlag ("cross-red"))
insilmaril@807
   214
							ts << " [NOT STARTED] ";
insilmaril@807
   215
						ts << "\n";
insilmaril@818
   216
						break;
insilmaril@807
   217
					default:
insilmaril@807
   218
						ts << (curIndent + "- " + cur->getHeading());
insilmaril@807
   219
						ts << "\n";
insilmaril@807
   220
						break;
insilmaril@807
   221
				}
insilmaril@807
   222
insilmaril@807
   223
				// If necessary, write note
insilmaril@807
   224
				if (!cur->getNoteObj().isEmpty())
insilmaril@807
   225
				{
insilmaril@807
   226
					curIndent +="  | ";
insilmaril@807
   227
					s=cur->getNoteASCII( curIndent, 80);
insilmaril@807
   228
					ts << s;
insilmaril@807
   229
				}
insilmaril@807
   230
			}
insilmaril@807
   231
		}
insilmaril@807
   232
		cur=model->nextBranch(cur,prev);
insilmaril@807
   233
	}
insilmaril@807
   234
	file.close();
insilmaril@807
   235
}
insilmaril@807
   236
insilmaril@807
   237
QString ExportAO::underline (const QString &text, const QString &line)
insilmaril@807
   238
{
insilmaril@807
   239
	QString r=text + "\n";
insilmaril@807
   240
	for (int j=0;j<text.length();j++) r+=line;
insilmaril@807
   241
	return r;
insilmaril@807
   242
}
insilmaril@807
   243
insilmaril@807
   244
insilmaril@807
   245
////////////////////////////////////////////////////////////////////////
insilmaril@512
   246
ExportASCII::ExportASCII()
insilmaril@512
   247
{
insilmaril@512
   248
	filter="TXT (*.txt)";
insilmaril@512
   249
	caption=vymName+ " -" +QObject::tr("Export as ASCII")+" "+QObject::tr("(still experimental)");
insilmaril@512
   250
}
insilmaril@512
   251
insilmaril@777
   252
void ExportASCII::doExport()	
insilmaril@0
   253
{
insilmaril@199
   254
	QFile file (outputFile);
insilmaril@366
   255
	if ( !file.open( QIODevice::WriteOnly ) )
insilmaril@0
   256
	{
insilmaril@807
   257
		qWarning ("ExportASCII::doExport couldn't open "+outputFile);
insilmaril@0
   258
		return;
insilmaril@0
   259
	}
insilmaril@0
   260
	QTextStream ts( &file );	// use LANG decoding here...
insilmaril@0
   261
insilmaril@0
   262
	// Main loop over all branches
insilmaril@0
   263
	QString s;
insilmaril@613
   264
	QString curIndent;
insilmaril@613
   265
	int i;
insilmaril@750
   266
	BranchItem *cur=NULL;
insilmaril@750
   267
	BranchItem *prev=NULL;
insilmaril@741
   268
insilmaril@804
   269
	cur=model->nextBranch (cur,prev);
insilmaril@741
   270
	while (cur) 
insilmaril@0
   271
	{
insilmaril@741
   272
		if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
insilmaril@740
   273
		{
insilmaril@740
   274
			// Make indentstring
insilmaril@740
   275
			curIndent="";
insilmaril@819
   276
			for (i=1;i<cur->depth()-1;i++) curIndent+= indentPerDepth;
insilmaril@740
   277
insilmaril@753
   278
			if (!cur->hasHiddenExportParent() )
insilmaril@600
   279
			{
insilmaril@791
   280
				//std::cout << "ExportASCII::  "<<curIndent.toStdString()<<cur->getHeading().toStdString()<<std::endl;
insilmaril@741
   281
				switch (cur->depth())
insilmaril@740
   282
				{
insilmaril@740
   283
					case 0:
insilmaril@741
   284
						ts << underline (cur->getHeading(),QString("="));
insilmaril@740
   285
						ts << "\n";
insilmaril@740
   286
						break;
insilmaril@740
   287
					case 1:
insilmaril@740
   288
						ts << "\n";
insilmaril@791
   289
						ts << (underline (getSectionString(cur) + cur->getHeading(), QString("-") ) );
insilmaril@740
   290
						ts << "\n";
insilmaril@740
   291
						break;
insilmaril@740
   292
					case 2:
insilmaril@740
   293
						ts << "\n";
insilmaril@741
   294
						ts << (curIndent + "* " + cur->getHeading());
insilmaril@740
   295
						ts << "\n";
insilmaril@740
   296
						break;
insilmaril@740
   297
					case 3:
insilmaril@741
   298
						ts << (curIndent + "- " + cur->getHeading());
insilmaril@740
   299
						ts << "\n";
insilmaril@740
   300
						break;
insilmaril@740
   301
					default:
insilmaril@741
   302
						ts << (curIndent + "- " + cur->getHeading());
insilmaril@740
   303
						ts << "\n";
insilmaril@740
   304
						break;
insilmaril@740
   305
				}
insilmaril@613
   306
insilmaril@740
   307
				// If necessary, write note
insilmaril@746
   308
				if (!cur->getNoteObj().isEmpty())
insilmaril@740
   309
				{
insilmaril@740
   310
					curIndent +="  | ";
insilmaril@746
   311
					s=cur->getNoteASCII( curIndent, 80);
insilmaril@740
   312
					ts << s;
insilmaril@740
   313
				}
insilmaril@600
   314
			}
insilmaril@0
   315
		}
insilmaril@804
   316
		cur=model->nextBranch(cur,prev);
insilmaril@0
   317
	}
insilmaril@0
   318
	file.close();
insilmaril@0
   319
}
insilmaril@0
   320
insilmaril@613
   321
QString ExportASCII::underline (const QString &text, const QString &line)
insilmaril@613
   322
{
insilmaril@613
   323
	QString r=text + "\n";
insilmaril@613
   324
	for (int j=0;j<text.length();j++) r+=line;
insilmaril@613
   325
	return r;
insilmaril@613
   326
}
insilmaril@613
   327
insilmaril@497
   328
insilmaril@497
   329
////////////////////////////////////////////////////////////////////////
insilmaril@497
   330
void ExportCSV::doExport()
insilmaril@497
   331
{
insilmaril@497
   332
	QFile file (outputFile);
insilmaril@497
   333
	if ( !file.open( QIODevice::WriteOnly ) )
insilmaril@497
   334
	{
insilmaril@497
   335
		qWarning ("ExportBase::exportXML  couldn't open "+outputFile);
insilmaril@497
   336
		return;
insilmaril@497
   337
	}
insilmaril@497
   338
	QTextStream ts( &file );	// use LANG decoding here...
insilmaril@497
   339
insilmaril@497
   340
	// Write header
insilmaril@497
   341
	ts << "\"Note\""  <<endl;
insilmaril@497
   342
insilmaril@497
   343
	// Main loop over all branches
insilmaril@497
   344
	QString s;
insilmaril@613
   345
	QString curIndent("");
insilmaril@512
   346
	int i;
insilmaril@753
   347
	BranchObj *bo;  //FIXME-3 still needed?
insilmaril@750
   348
	BranchItem *cur=NULL;
insilmaril@750
   349
	BranchItem *prev=NULL;
insilmaril@804
   350
	cur=model->nextBranch (cur,prev);
insilmaril@741
   351
	while (cur) 
insilmaril@497
   352
	{
insilmaril@741
   353
		bo=(BranchObj*)(cur->getLMO());
insilmaril@740
   354
insilmaril@753
   355
		if (!cur->hasHiddenExportParent() )
insilmaril@497
   356
		{
insilmaril@600
   357
			// If necessary, write note
insilmaril@746
   358
			if (!cur->getNoteObj().isEmpty())
insilmaril@600
   359
			{
insilmaril@746
   360
				s =cur->getNoteASCII();
insilmaril@613
   361
				s=s.replace ("\n","\n"+curIndent);
insilmaril@600
   362
				ts << ("\""+s+"\",");
insilmaril@600
   363
			} else
insilmaril@600
   364
				ts <<"\"\",";
insilmaril@497
   365
insilmaril@600
   366
			// Make indentstring
insilmaril@741
   367
			for (i=0;i<cur->depth();i++) curIndent+= "\"\",";
insilmaril@497
   368
insilmaril@600
   369
			// Write heading
insilmaril@741
   370
			ts << curIndent << "\"" << cur->getHeading()<<"\""<<endl;
insilmaril@600
   371
		}
insilmaril@497
   372
		
insilmaril@804
   373
		cur=model->nextBranch(cur,prev);
insilmaril@613
   374
		curIndent="";
insilmaril@497
   375
	}
insilmaril@497
   376
	file.close();
insilmaril@497
   377
}
insilmaril@497
   378
insilmaril@239
   379
////////////////////////////////////////////////////////////////////////
insilmaril@742
   380
void ExportKDE3Bookmarks::doExport() 
insilmaril@239
   381
{
insilmaril@721
   382
	WarningDialog dia;
insilmaril@721
   383
	dia.showCancelButton (true);
insilmaril@721
   384
	dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
insilmaril@742
   385
	dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE 3"));
insilmaril@742
   386
	dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
insilmaril@742
   387
	if (dia.exec()==QDialog::Accepted)
insilmaril@742
   388
	{
insilmaril@742
   389
		model->exportXML(tmpDir.path(),false);
insilmaril@742
   390
insilmaril@742
   391
		XSLTProc p;
insilmaril@742
   392
		p.setInputFile (tmpDir.path()+"/"+model->getMapName()+".xml");
insilmaril@742
   393
		p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
insilmaril@742
   394
		p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@742
   395
		p.process();
insilmaril@742
   396
insilmaril@742
   397
		QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@742
   398
		QProcess *proc= new QProcess ;
insilmaril@742
   399
		proc->start( ub);
insilmaril@742
   400
		if (!proc->waitForStarted())
insilmaril@742
   401
		{
insilmaril@742
   402
			QMessageBox::warning(0, 
insilmaril@742
   403
				QObject::tr("Warning"),
insilmaril@742
   404
				QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
insilmaril@742
   405
		}	
insilmaril@742
   406
	}
insilmaril@742
   407
}
insilmaril@742
   408
insilmaril@742
   409
////////////////////////////////////////////////////////////////////////
insilmaril@742
   410
void ExportKDE4Bookmarks::doExport() 
insilmaril@742
   411
{
insilmaril@742
   412
	WarningDialog dia;
insilmaril@742
   413
	dia.showCancelButton (true);
insilmaril@742
   414
	dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE 4"));
insilmaril@721
   415
	dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
insilmaril@721
   416
	dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
insilmaril@721
   417
	if (dia.exec()==QDialog::Accepted)
insilmaril@239
   418
	{
insilmaril@721
   419
		model->exportXML(tmpDir.path(),false);
insilmaril@721
   420
insilmaril@721
   421
		XSLTProc p;
insilmaril@721
   422
		p.setInputFile (tmpDir.path()+"/"+model->getMapName()+".xml");
insilmaril@742
   423
		p.setOutputFile (tmpDir.home().path()+"/.kde4/share/apps/konqueror/bookmarks.xml");
insilmaril@721
   424
		p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@721
   425
		p.process();
insilmaril@721
   426
insilmaril@721
   427
		QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@721
   428
		QProcess *proc= new QProcess ;
insilmaril@721
   429
		proc->start( ub);
insilmaril@721
   430
		if (!proc->waitForStarted())
insilmaril@311
   431
		{
insilmaril@721
   432
			QMessageBox::warning(0, 
insilmaril@721
   433
				QObject::tr("Warning"),
insilmaril@721
   434
				QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
insilmaril@721
   435
		}	
insilmaril@239
   436
	}
insilmaril@239
   437
}
insilmaril@239
   438
insilmaril@239
   439
////////////////////////////////////////////////////////////////////////
insilmaril@311
   440
void ExportFirefoxBookmarks::doExport() 
insilmaril@311
   441
{
insilmaril@721
   442
	WarningDialog dia;
insilmaril@721
   443
	dia.showCancelButton (true);
insilmaril@721
   444
	dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("Firefox"));
insilmaril@721
   445
	dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("Firefox"));
insilmaril@721
   446
	dia.setShowAgainName("/vym/warnings/overwriteImportBookmarks");
insilmaril@721
   447
	if (dia.exec()==QDialog::Accepted)
insilmaril@311
   448
	{
insilmaril@721
   449
		model->exportXML(tmpDir.path(),false);
insilmaril@311
   450
insilmaril@311
   451
/*
insilmaril@721
   452
		XSLTProc p;
insilmaril@721
   453
		p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@721
   454
		p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
insilmaril@721
   455
		p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@721
   456
		p.process();
insilmaril@311
   457
insilmaril@721
   458
		QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@721
   459
		QProcess *proc = new QProcess( );
insilmaril@721
   460
		proc->addArgument(ub);
insilmaril@311
   461
insilmaril@721
   462
		if ( !proc->start() ) 
insilmaril@721
   463
		{
insilmaril@721
   464
			QMessageBox::warning(0, 
insilmaril@721
   465
				QObject::tr("Warning"),
insilmaril@721
   466
				QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
insilmaril@721
   467
		}	
insilmaril@311
   468
insilmaril@311
   469
*/
insilmaril@311
   470
	}
insilmaril@311
   471
}
insilmaril@311
   472
insilmaril@311
   473
////////////////////////////////////////////////////////////////////////
insilmaril@819
   474
ExportHTML::ExportHTML():ExportBase()
insilmaril@819
   475
{
insilmaril@819
   476
	init();
insilmaril@819
   477
}
insilmaril@819
   478
insilmaril@819
   479
ExportHTML::ExportHTML(VymModel *m):ExportBase(m)
insilmaril@819
   480
{
insilmaril@819
   481
	init();
insilmaril@819
   482
}
insilmaril@819
   483
insilmaril@819
   484
void ExportHTML::init()
insilmaril@819
   485
{
insilmaril@819
   486
	singularDelimiter=": ";
insilmaril@819
   487
	noSingulars=true;	
insilmaril@819
   488
	frameURLs=true;
insilmaril@819
   489
	useMapColors=true;
insilmaril@819
   490
insilmaril@819
   491
	if (model &&model->getMapEditor()) 
insilmaril@819
   492
		offset=model->getMapEditor()->getTotalBBox().topLeft();
insilmaril@819
   493
}
insilmaril@819
   494
insilmaril@819
   495
QString ExportHTML::getBranchText(BranchItem *current)
insilmaril@819
   496
{
insilmaril@819
   497
	if (current)
insilmaril@819
   498
	{
insilmaril@819
   499
		bool vis=false;
insilmaril@819
   500
		QRectF hr;
insilmaril@819
   501
		LinkableMapObj *lmo=current->getLMO();
insilmaril@819
   502
		if (lmo)
insilmaril@819
   503
		{
insilmaril@819
   504
			hr=((BranchObj*)lmo)->getBBoxHeading();
insilmaril@819
   505
			if (lmo->isVisibleObj()) vis=true;
insilmaril@819
   506
		}
insilmaril@819
   507
		QString col;
insilmaril@819
   508
		QString id=model->getSelectString(current);
insilmaril@819
   509
		if (useMapColors)
insilmaril@819
   510
			col=QString("style='color:%1'").arg(current->getHeadingColor().name());
insilmaril@819
   511
		QString s=QString("<span class='vym-branch%1' %2 id='%3'>")
insilmaril@819
   512
			.arg(current->depth())
insilmaril@819
   513
			.arg(col)
insilmaril@819
   514
			.arg(id);
insilmaril@819
   515
		QString url=current->getURL();	
insilmaril@819
   516
		if (!url.isEmpty())
insilmaril@819
   517
		{
insilmaril@819
   518
			s+=QString ("<a href=\"%1\">").arg(url);
insilmaril@819
   519
			s+=QString ("<img src=\"flags/flag-url-16x16.png\">%1</a>").arg(quotemeta(current->getHeading()));
insilmaril@819
   520
			s+="</a>";
insilmaril@819
   521
			
insilmaril@819
   522
			QRectF fbox=current->getBBoxFlag ("system-url");
insilmaril@819
   523
			if (vis)
insilmaril@819
   524
				imageMap+=QString("  <area shape='rect' coords='%1,%2,%3,%4' href='%5'>\n")
insilmaril@819
   525
					.arg(fbox.left()-offset.x())
insilmaril@819
   526
					.arg(fbox.top()-offset.y())
insilmaril@819
   527
					.arg(fbox.right()-offset.x())
insilmaril@819
   528
					.arg(fbox.bottom()-offset.y())
insilmaril@819
   529
					.arg(url);
insilmaril@819
   530
		} else	
insilmaril@819
   531
			s+=quotemeta(current->getHeading());
insilmaril@819
   532
		s+="</span>";
insilmaril@819
   533
insilmaril@819
   534
		if (vis)
insilmaril@819
   535
			imageMap+=QString("  <area shape='rect' coords='%1,%2,%3,%4' href='#%5'>\n")
insilmaril@819
   536
				.arg(hr.left()-offset.x())
insilmaril@819
   537
				.arg(hr.top()-offset.y())
insilmaril@819
   538
				.arg(hr.right()-offset.x())
insilmaril@819
   539
				.arg(hr.bottom()-offset.y())
insilmaril@819
   540
				.arg(id);
insilmaril@819
   541
insilmaril@819
   542
		// Include note
insilmaril@819
   543
		if (!current->getNoteObj().isEmpty())
insilmaril@819
   544
			s+="<table border=1><tr><td>"+current->getNote()+"</td></tr></table>";
insilmaril@819
   545
insilmaril@819
   546
		return s;
insilmaril@819
   547
	} 
insilmaril@819
   548
	return QString();
insilmaril@819
   549
}
insilmaril@819
   550
insilmaril@819
   551
QString ExportHTML::buildList (BranchItem *current)
insilmaril@819
   552
{
insilmaril@819
   553
    QString r;
insilmaril@819
   554
insilmaril@819
   555
    uint i=0;
insilmaril@819
   556
	BranchItem *bi=current->getFirstBranch();
insilmaril@819
   557
insilmaril@819
   558
	// Only add itemized list, if we have more than one subitem.
insilmaril@819
   559
	// For only one subitem, just add a separator to keep page more compact
insilmaril@819
   560
	bool noSingularsHere=false;
insilmaril@819
   561
	if (current->branchCount()<2 && noSingulars) noSingularsHere=true;
insilmaril@819
   562
insilmaril@819
   563
	if (bi)
insilmaril@819
   564
    {
insilmaril@819
   565
		if (!noSingularsHere)
insilmaril@819
   566
			r+="<ul>\n";
insilmaril@819
   567
		else
insilmaril@819
   568
			r+=singularDelimiter;
insilmaril@819
   569
insilmaril@819
   570
		while (bi)
insilmaril@819
   571
		{
insilmaril@819
   572
			if (!bi->hasHiddenExportParent() )	
insilmaril@819
   573
			{
insilmaril@819
   574
				if (!noSingularsHere) r+="<li>";
insilmaril@819
   575
				r+=getBranchText (bi);
insilmaril@819
   576
				if (!bi->getURL().isEmpty() && frameURLs && noSingularsHere)
insilmaril@819
   577
					// Add frame, if we have subitems to an URL
insilmaril@819
   578
					r+="<table border=1><tr><td>"+buildList (bi)+"</td></tr></table>";	// recursivly add deeper branches
insilmaril@819
   579
				else
insilmaril@819
   580
					r+=buildList (bi);	// recursivly add deeper branches
insilmaril@819
   581
				if (!noSingularsHere) r+="</li>";
insilmaril@819
   582
				r+="\n";
insilmaril@819
   583
			}
insilmaril@819
   584
			i++;
insilmaril@819
   585
			bi=current->getBranchNum(i);
insilmaril@819
   586
		}
insilmaril@819
   587
insilmaril@819
   588
		if (!noSingularsHere) r+="</ul>\n";
insilmaril@819
   589
	}
insilmaril@819
   590
    return r;
insilmaril@819
   591
}
insilmaril@819
   592
insilmaril@819
   593
void ExportHTML::doExport() 
insilmaril@819
   594
{
insilmaril@819
   595
	QFile file (outputFile);
insilmaril@819
   596
	if ( !file.open( QIODevice::WriteOnly ) ) 
insilmaril@819
   597
	{
insilmaril@819
   598
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile));
insilmaril@819
   599
		mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@819
   600
		return;
insilmaril@819
   601
	}
insilmaril@819
   602
	QTextStream ts( &file );	// use LANG decoding here...
insilmaril@819
   603
	ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
insilmaril@819
   604
insilmaril@819
   605
	// Write header
insilmaril@819
   606
	ts<<"<html><title>"+model->getMapName()<<"</title><body>";
insilmaril@819
   607
	ts<<" <link rel='stylesheet' id='css.stylesheet' href='vym.css' />\n";
insilmaril@819
   608
insilmaril@819
   609
	// Include image
insilmaril@819
   610
	ts<<"<center><img src=\"xxx.png\" usemap='#imagemap'></center>\n";
insilmaril@819
   611
insilmaril@819
   612
insilmaril@819
   613
	// Main loop over all mapcenters
insilmaril@819
   614
	QString s;
insilmaril@819
   615
	TreeItem *rootItem=model->getRootItem();
insilmaril@819
   616
	BranchItem *bi;
insilmaril@819
   617
	for (int i=0; i<rootItem->branchCount(); i++)
insilmaril@819
   618
	{
insilmaril@819
   619
		bi=rootItem->getBranchNum(i);
insilmaril@819
   620
		if (!bi->hasHiddenExportParent())
insilmaril@819
   621
		{
insilmaril@819
   622
			ts<<getBranchText (bi);
insilmaril@819
   623
			ts<<buildList (bi);
insilmaril@819
   624
		}
insilmaril@819
   625
	}	
insilmaril@819
   626
insilmaril@819
   627
	// Imagemap
insilmaril@819
   628
	ts<<"<map name='imagemap'>\n"+imageMap+"</map>\n";
insilmaril@819
   629
insilmaril@819
   630
	// Write footer 
insilmaril@819
   631
	ts<<"<hr/>\n";
insilmaril@819
   632
	ts<<"<table class=\"vym-footer\">   \n\
insilmaril@819
   633
      <tr> \n\
insilmaril@819
   634
        <td class=\"vym-footerL\">"+model->getFileName()+"</td> \n\
insilmaril@819
   635
        <td class=\"vym-footerC\">"+model->getDate()+"</td> \n\
insilmaril@819
   636
        <td class=\"vym-footerR\"> vym "+model->getVersion()+"</td> \n\
insilmaril@819
   637
      </tr> \n \
insilmaril@819
   638
    </table>\n";
insilmaril@819
   639
	ts<<"</body></html>";
insilmaril@819
   640
	file.close();
insilmaril@819
   641
}
insilmaril@819
   642
insilmaril@819
   643
////////////////////////////////////////////////////////////////////////
insilmaril@228
   644
void ExportTaskjuggler::doExport() 
insilmaril@228
   645
{
insilmaril@721
   646
	model->exportXML(tmpDir.path(),false);
insilmaril@228
   647
insilmaril@721
   648
	XSLTProc p;
insilmaril@721
   649
	p.setInputFile (tmpDir.path()+"/"+model->getMapName()+".xml");
insilmaril@721
   650
	p.setOutputFile (outputFile);
insilmaril@721
   651
	p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
insilmaril@721
   652
	p.process();
insilmaril@228
   653
}
insilmaril@228
   654
insilmaril@239
   655
////////////////////////////////////////////////////////////////////////
insilmaril@228
   656
void ExportLaTeX::doExport() 
insilmaril@0
   657
{
insilmaril@183
   658
	// Exports a map to a LaTex file.  
insilmaril@183
   659
	// This file needs to be included 
insilmaril@183
   660
	// or inported into a LaTex document
insilmaril@183
   661
	// it will not add a preamble, or anything 
insilmaril@183
   662
	// that makes a full LaTex document.
insilmaril@199
   663
  QFile file (outputFile);
insilmaril@366
   664
  if ( !file.open( QIODevice::WriteOnly ) ) {
insilmaril@205
   665
	QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile));
insilmaril@205
   666
	mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@163
   667
    return;
insilmaril@163
   668
  }
insilmaril@163
   669
  QTextStream ts( &file );	// use LANG decoding here...
insilmaril@163
   670
  ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
insilmaril@163
   671
  
insilmaril@163
   672
  // Main loop over all branches
insilmaril@163
   673
  QString s;
insilmaril@613
   674
  // QString curIndent("");
insilmaril@163
   675
  // int i;
insilmaril@163
   676
  BranchObj *bo;
insilmaril@750
   677
  BranchItem *cur=NULL;
insilmaril@750
   678
  BranchItem *prev=NULL;
insilmaril@804
   679
  model->nextBranch(cur,prev);
insilmaril@741
   680
  while (cur) 
insilmaril@740
   681
  {
insilmaril@741
   682
	bo=(BranchObj*)(cur->getLMO());
insilmaril@740
   683
insilmaril@753
   684
	if (!cur->hasHiddenExportParent() )
insilmaril@600
   685
	{
insilmaril@741
   686
		switch (cur->depth() ) 
insilmaril@740
   687
		{
insilmaril@740
   688
			case 0: break;
insilmaril@740
   689
			case 1: 
insilmaril@753
   690
			  ts << ("\\chapter{" + cur->getHeading()+ "}\n");
insilmaril@740
   691
			  break;
insilmaril@740
   692
			case 2: 
insilmaril@753
   693
			  ts << ("\\section{" + cur->getHeading()+ "}\n");
insilmaril@740
   694
			  break;
insilmaril@740
   695
			case 3: 
insilmaril@753
   696
			  ts << ("\\subsection{" + cur->getHeading()+ "}\n");
insilmaril@740
   697
			  break;
insilmaril@740
   698
			case 4: 
insilmaril@753
   699
			  ts << ("\\subsubsection{" + cur->getHeading()+ "}\n");
insilmaril@740
   700
			  break;
insilmaril@740
   701
			default:
insilmaril@753
   702
			  ts << ("\\paragraph*{" + cur->getHeading()+ "}\n");
insilmaril@740
   703
			
insilmaril@600
   704
		}
insilmaril@600
   705
		// If necessary, write note
insilmaril@746
   706
		if (!cur->getNoteObj().isEmpty()) {
insilmaril@746
   707
		  ts << (cur->getNoteASCII());
insilmaril@600
   708
		  ts << ("\n");
insilmaril@600
   709
		}
insilmaril@254
   710
	}
insilmaril@804
   711
    cur=model->nextBranch(cur,prev);
insilmaril@163
   712
   }
insilmaril@163
   713
  file.close();
insilmaril@0
   714
}
insilmaril@0
   715
insilmaril@239
   716
////////////////////////////////////////////////////////////////////////
insilmaril@171
   717
ExportOO::ExportOO()
insilmaril@171
   718
{
insilmaril@199
   719
	useSections=false;
insilmaril@171
   720
}
insilmaril@163
   721
insilmaril@171
   722
ExportOO::~ExportOO()
insilmaril@171
   723
{
insilmaril@171
   724
}	
insilmaril@163
   725
insilmaril@750
   726
QString ExportOO::buildList (TreeItem *current)
insilmaril@171
   727
{
insilmaril@171
   728
    QString r;
insilmaril@183
   729
insilmaril@183
   730
    uint i=0;
insilmaril@750
   731
	BranchItem *bi=current->getFirstBranch();
insilmaril@750
   732
	if (bi)
insilmaril@171
   733
    {
insilmaril@819
   734
		// Start list
insilmaril@819
   735
		r+="<text:list text:style-name=\"vym-list\">\n";
insilmaril@819
   736
		while (bi)
insilmaril@600
   737
		{
insilmaril@819
   738
			if (!bi->hasHiddenExportParent() )	
insilmaril@600
   739
			{
insilmaril@600
   740
				r+="<text:list-item><text:p >";
insilmaril@750
   741
				r+=quotemeta(bi->getHeading());
insilmaril@600
   742
				// If necessary, write note
insilmaril@750
   743
				if (!bi->getNoteObj().isEmpty())
insilmaril@750
   744
					r+=bi->getNoteOpenDoc();
insilmaril@600
   745
				r+="</text:p>";
insilmaril@750
   746
				r+=buildList (bi);	// recursivly add deeper branches
insilmaril@600
   747
				r+="</text:list-item>\n";
insilmaril@600
   748
			}
insilmaril@819
   749
			i++;
insilmaril@819
   750
			bi=current->getBranchNum(i);
insilmaril@600
   751
		}
insilmaril@819
   752
		r+="</text:list>\n";
insilmaril@171
   753
    }
insilmaril@171
   754
    return r;
insilmaril@171
   755
}
insilmaril@163
   756
insilmaril@171
   757
insilmaril@171
   758
void ExportOO::exportPresentation()
insilmaril@171
   759
{
insilmaril@183
   760
	QString allPages;
insilmaril@171
   761
insilmaril@804
   762
	BranchItem *firstMCO=(BranchItem*)(model->getRootItem()->getFirstBranch());
insilmaril@804
   763
	if (!firstMCO) 
insilmaril@804
   764
	{
insilmaril@804
   765
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("No objects in map!"));
insilmaril@804
   766
		return;
insilmaril@804
   767
	}
insilmaril@804
   768
insilmaril@163
   769
	// Insert new content
insilmaril@804
   770
	// FIXME add extra title in mapinfo for vym 1.13.x
insilmaril@804
   771
	content.replace ("<!-- INSERT TITLE -->",quotemeta(firstMCO->getHeading()));
insilmaril@804
   772
	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(model->getAuthor()));
insilmaril@183
   773
insilmaril@183
   774
	QString	onePage;
insilmaril@183
   775
	QString list;
insilmaril@183
   776
	
insilmaril@804
   777
	BranchItem *sectionBI;	
insilmaril@183
   778
    int i=0;
insilmaril@804
   779
	BranchItem *pagesBI;
insilmaril@183
   780
    int j=0;
insilmaril@183
   781
insilmaril@804
   782
	int mapcenters=model->getRootItem()->branchCount();
insilmaril@804
   783
insilmaril@804
   784
	// useSections already has been set in setConfigFile 
insilmaril@804
   785
	if (mapcenters>1)	
insilmaril@804
   786
		sectionBI=firstMCO;
insilmaril@804
   787
	else
insilmaril@804
   788
		sectionBI=firstMCO->getFirstBranch();
insilmaril@804
   789
insilmaril@194
   790
	// Walk sections
insilmaril@804
   791
	while (sectionBI && !sectionBI->hasHiddenExportParent() )
insilmaril@183
   792
	{
insilmaril@194
   793
		if (useSections)
insilmaril@183
   794
		{
insilmaril@194
   795
			// Add page with section title
insilmaril@194
   796
			onePage=sectionTemplate;
insilmaril@804
   797
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBI->getHeading() ) );
insilmaril@183
   798
			allPages+=onePage;
insilmaril@804
   799
			pagesBI=sectionBI->getFirstBranch();
insilmaril@183
   800
		} else
insilmaril@183
   801
		{
insilmaril@804
   802
			//i=-2;	// only use inner loop to 
insilmaril@183
   803
			        // turn mainbranches into pages
insilmaril@804
   804
			//sectionBI=firstMCO;
insilmaril@804
   805
			pagesBI=sectionBI;
insilmaril@183
   806
		}
insilmaril@183
   807
insilmaril@183
   808
		j=0;
insilmaril@804
   809
		while (pagesBI && !pagesBI->hasHiddenExportParent() )
insilmaril@183
   810
		{
insilmaril@183
   811
			// Add page with list of items
insilmaril@254
   812
			onePage=pageTemplate;
insilmaril@804
   813
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBI->getHeading() ) );
insilmaril@804
   814
			list=buildList (pagesBI);
insilmaril@254
   815
			onePage.replace ("<!-- INSERT LIST -->", list);
insilmaril@254
   816
			allPages+=onePage;
insilmaril@804
   817
			if (pagesBI!=sectionBI)
insilmaril@804
   818
			{
insilmaril@804
   819
				j++;
insilmaril@804
   820
				pagesBI=((BranchItem*)pagesBI->parent())->getBranchNum(j);
insilmaril@804
   821
			} else
insilmaril@804
   822
				pagesBI=NULL;	// We are already iterating over the sectionBIs
insilmaril@183
   823
		}
insilmaril@183
   824
		i++;
insilmaril@804
   825
		if (mapcenters>1 )
insilmaril@804
   826
			sectionBI=model->getRootItem()->getBranchNum (i);
insilmaril@804
   827
		else
insilmaril@804
   828
			sectionBI=firstMCO->getBranchNum (i);
insilmaril@183
   829
	}
insilmaril@183
   830
	
insilmaril@171
   831
	content.replace ("<!-- INSERT PAGES -->",allPages);
insilmaril@171
   832
insilmaril@171
   833
	// Write modified content
insilmaril@171
   834
	QFile f (contentFile);
insilmaril@366
   835
    if ( !f.open( QIODevice::WriteOnly ) ) 
insilmaril@171
   836
	{
insilmaril@205
   837
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(contentFile));
insilmaril@205
   838
		mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@171
   839
		return;
insilmaril@171
   840
    }
insilmaril@171
   841
insilmaril@171
   842
    QTextStream t( &f );
insilmaril@171
   843
    t << content;
insilmaril@171
   844
    f.close();
insilmaril@171
   845
insilmaril@163
   846
	// zip tmpdir to destination
insilmaril@171
   847
	zipDir (tmpDir,outputFile);	
insilmaril@163
   848
}
insilmaril@163
   849
insilmaril@194
   850
bool ExportOO::setConfigFile (const QString &cf)
insilmaril@183
   851
{
insilmaril@183
   852
	configFile=cf;
insilmaril@183
   853
	int i=cf.findRev ("/");
insilmaril@183
   854
	if (i>=0) configDir=cf.left(i);
insilmaril@183
   855
	SimpleSettings set;
insilmaril@183
   856
	set.readSettings(configFile);
insilmaril@183
   857
insilmaril@183
   858
	// set paths
insilmaril@183
   859
	templateDir=configDir+"/"+set.readEntry ("Template");
insilmaril@183
   860
insilmaril@194
   861
	QDir d (templateDir);
insilmaril@194
   862
	if (!d.exists())
insilmaril@194
   863
	{
insilmaril@194
   864
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Check \"%1\" in\n%2").arg("Template="+set.readEntry ("Template")).arg(configFile));
insilmaril@194
   865
		return false;
insilmaril@194
   866
insilmaril@194
   867
	}
insilmaril@183
   868
insilmaril@183
   869
	contentTemplateFile=templateDir+"content-template.xml";
insilmaril@183
   870
	contentFile=tmpDir.path()+"/content.xml";
insilmaril@183
   871
	pageTemplateFile=templateDir+"page-template.xml";
insilmaril@194
   872
	sectionTemplateFile=templateDir+"section-template.xml";
insilmaril@183
   873
insilmaril@199
   874
	if (set.readEntry("useSections").contains("yes"))
insilmaril@199
   875
		useSections=true;
insilmaril@199
   876
insilmaril@183
   877
	// Copy template to tmpdir
insilmaril@183
   878
	system ("cp -r "+templateDir+"* "+tmpDir.path());
insilmaril@183
   879
insilmaril@183
   880
	// Read content-template
insilmaril@183
   881
	if (!loadStringFromDisk (contentTemplateFile,content))
insilmaril@183
   882
	{
insilmaril@194
   883
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(contentTemplateFile));
insilmaril@194
   884
		return false;
insilmaril@183
   885
	}
insilmaril@183
   886
insilmaril@183
   887
	// Read page-template
insilmaril@183
   888
	if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
insilmaril@183
   889
	{
insilmaril@194
   890
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(pageTemplateFile));
insilmaril@194
   891
		return false;
insilmaril@183
   892
	}
insilmaril@183
   893
	
insilmaril@194
   894
	// Read section-template
insilmaril@201
   895
	if (useSections && !loadStringFromDisk (sectionTemplateFile,sectionTemplate))
insilmaril@183
   896
	{
insilmaril@194
   897
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(sectionTemplateFile));
insilmaril@194
   898
		return false;
insilmaril@183
   899
	}
insilmaril@194
   900
	return true;
insilmaril@183
   901
}
insilmaril@183
   902