exports.cpp
author insilmaril
Wed, 25 Nov 2009 10:58:21 +0000
changeset 807 f9f7922989d8
parent 804 14f2b1b15242
child 815 2881c4424190
permissions -rw-r--r--
Added demos/vym-contribute.vym, fixes for selecting items
     1 #include "exports.h"
     2 
     3 #include "branchitem.h"
     4 #include "file.h"
     5 #include "linkablemapobj.h"
     6 #include "misc.h"
     7 #include "mainwindow.h"
     8 #include "warningdialog.h"
     9 #include "xsltproc.h"
    10 
    11 extern Main *mainWindow;
    12 extern QDir vymBaseDir;
    13 extern QString vymName;
    14 
    15 ExportBase::ExportBase()
    16 {
    17 	indentPerDepth="  ";
    18 	bool ok;
    19     tmpDir.setPath (makeTmpDir(ok,"vym-export"));
    20 	if (!tmpDir.exists() || !ok)
    21 		QMessageBox::critical( 0, QObject::tr( "Error" ),
    22 					   QObject::tr("Couldn't access temporary directory\n"));
    23 	cancelFlag=false;				   
    24 }
    25 
    26 ExportBase::~ExportBase()
    27 {
    28 	// Cleanup tmpdir
    29 	removeDir (tmpDir);
    30 }
    31 
    32 void ExportBase::setDir(const QDir &d)
    33 {
    34 	outDir=d;
    35 }
    36 
    37 void ExportBase::setFile (const QString &p)
    38 {
    39 	outputFile=p;
    40 }
    41 
    42 QString ExportBase::getFile ()
    43 {
    44 	return outputFile;
    45 }
    46 
    47 void ExportBase::setModel(VymModel *m)
    48 {
    49 	model=m;
    50 }
    51 
    52 void ExportBase::setCaption (const QString &s)
    53 {
    54 	caption=s;
    55 }
    56 
    57 void ExportBase::addFilter(const QString &s)
    58 {
    59 	filter=s;
    60 }
    61 
    62 bool ExportBase::execDialog()
    63 {
    64 	{
    65 		QFileDialog *fd=new QFileDialog( 0, caption);
    66 		fd->setFilter (filter);
    67 		fd->setCaption(caption);
    68 		fd->setMode( QFileDialog::AnyFile );
    69 		fd->setDir (outDir);
    70 		fd->show();
    71 
    72 		if ( fd->exec() == QDialog::Accepted )
    73 		{
    74 			if (QFile (fd->selectedFile()).exists() )
    75 			{
    76 				QMessageBox mb( vymName,
    77 					QObject::tr("The file %1 exists already.\nDo you want to overwrite it?").arg(fd->selectedFile()), 
    78 				QMessageBox::Warning,
    79 				QMessageBox::Yes | QMessageBox::Default,
    80 				QMessageBox::Cancel | QMessageBox::Escape,
    81 				Qt::NoButton );
    82 				mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") );
    83 				mb.setButtonText( QMessageBox::No, QObject::tr("Cancel"));
    84 				ExportBase ex;
    85 				switch( mb.exec() ) 
    86 				{
    87 					case QMessageBox::Yes:
    88 						// save 
    89 						break;;
    90 					case QMessageBox::Cancel:
    91 						cancelFlag=true;
    92 						return false;
    93 						break;
    94 				}
    95 			}
    96 			outputFile=fd->selectedFile();
    97 			cancelFlag=false;
    98 			return true;
    99 		}
   100 	}
   101 	return false;
   102 }
   103 
   104 bool ExportBase::canceled()
   105 {
   106 	return cancelFlag;
   107 }
   108 
   109 QString ExportBase::getSectionString(TreeItem *start)
   110 {
   111 	// Make prefix like "2.5.3" for "bo:2,bo:5,bo:3"
   112 	QString r;
   113 	TreeItem *ti=start;
   114 	int depth=ti->depth();
   115 	while (depth>0)
   116 	{
   117 		r=QString("%1").arg(1+ti->num(),0,10)+"." + r;
   118 		ti=ti->parent(); 
   119 		depth=ti->depth();
   120 	}	
   121 	if (r.isEmpty())
   122 		return r;
   123 	else	
   124 		return r + " ";
   125 }
   126 
   127 ////////////////////////////////////////////////////////////////////////
   128 ExportAO::ExportAO()
   129 {
   130 	filter="TXT (*.txt)";
   131 	caption=vymName+ " -" +QObject::tr("Export as ASCII")+" "+QObject::tr("(still experimental)");
   132 }
   133 
   134 void ExportAO::doExport()	
   135 {
   136 	QFile file (outputFile);
   137 	if ( !file.open( QIODevice::WriteOnly ) )
   138 	{
   139 		qWarning ("ExportAO::doExport couldn't open "+outputFile);
   140 		return;
   141 	}
   142 	QTextStream ts( &file );	// use LANG decoding here...
   143 
   144 	// Main loop over all branches
   145 	QString s;
   146 	QString curIndent;
   147 	int i;
   148 	BranchItem *cur=NULL;
   149 	BranchItem *prev=NULL;
   150 
   151 	QString colString;
   152 	QColor col;
   153 
   154 	cur=model->nextBranch (cur,prev);
   155 	while (cur) 
   156 	{
   157 		if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
   158 		{
   159 			// Make indentstring
   160 			curIndent="";
   161 			for (i=0;i<cur->depth()-1;i++) curIndent+= indentPerDepth;
   162 
   163 			if (!cur->hasHiddenExportParent() )
   164 			{
   165 				col=cur->getHeadingColor();
   166 				if (col==QColor (255,0,0))
   167 					colString="[R]";
   168 				else if (col==QColor (217,81,0))
   169 					colString="[O]";
   170 				else if (col==QColor (0,85,0))
   171 					colString="[G]";
   172 				else  	
   173 					colString="[?]";
   174 				switch (cur->depth())
   175 				{
   176 					case 0:
   177 						//ts << underline (cur->getHeading(),QString("="));
   178 						//ts << "\n";
   179 						break;
   180 					case 1:
   181 						//ts << "\n";
   182 						//ts << (underline ( cur->getHeading(), QString("-") ) );
   183 						//ts << "\n";
   184 						break;
   185 					case 2: // Main heading
   186 						ts << "\n";
   187 						ts << underline ( cur->getHeading(), QString("=") );
   188 						ts << "\n\n";
   189 						break;
   190 					case 3: // Achievement, Bonus, Objective ...
   191 						ts << underline ( cur->getHeading(), "-");
   192 						ts << "\n\n";
   193 						break;
   194 					case 4:	// That's the item we need to know
   195 						ts << (curIndent + "* " + colString+" "+ cur->getHeading());
   196 						if (cur->isActiveStandardFlag ("hook-green"))
   197 							ts << " [DONE] ";
   198 						else	if (cur->isActiveStandardFlag ("clock"))
   199 							ts << " [WIP] ";
   200 						else	if (cur->isActiveStandardFlag ("cross-red"))
   201 							ts << " [NOT STARTED] ";
   202 						ts << "\n";
   203 					default:
   204 						break;
   205 						ts << (curIndent + "- " + cur->getHeading());
   206 						ts << "\n";
   207 						break;
   208 				}
   209 
   210 				// If necessary, write note
   211 				if (!cur->getNoteObj().isEmpty())
   212 				{
   213 					curIndent +="  | ";
   214 					s=cur->getNoteASCII( curIndent, 80);
   215 					ts << s;
   216 				}
   217 			}
   218 		}
   219 		cur=model->nextBranch(cur,prev);
   220 	}
   221 	file.close();
   222 }
   223 
   224 QString ExportAO::underline (const QString &text, const QString &line)
   225 {
   226 	QString r=text + "\n";
   227 	for (int j=0;j<text.length();j++) r+=line;
   228 	return r;
   229 }
   230 
   231 
   232 ////////////////////////////////////////////////////////////////////////
   233 ExportASCII::ExportASCII()
   234 {
   235 	filter="TXT (*.txt)";
   236 	caption=vymName+ " -" +QObject::tr("Export as ASCII")+" "+QObject::tr("(still experimental)");
   237 }
   238 
   239 void ExportASCII::doExport()	
   240 {
   241 	QFile file (outputFile);
   242 	if ( !file.open( QIODevice::WriteOnly ) )
   243 	{
   244 		qWarning ("ExportASCII::doExport couldn't open "+outputFile);
   245 		return;
   246 	}
   247 	QTextStream ts( &file );	// use LANG decoding here...
   248 
   249 	// Main loop over all branches
   250 	QString s;
   251 	QString curIndent;
   252 	int i;
   253 	BranchItem *cur=NULL;
   254 	BranchItem *prev=NULL;
   255 
   256 	cur=model->nextBranch (cur,prev);
   257 	while (cur) 
   258 	{
   259 		if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
   260 		{
   261 			// Make indentstring
   262 			curIndent="";
   263 			for (i=0;i<cur->depth()-1;i++) curIndent+= indentPerDepth;
   264 
   265 			if (!cur->hasHiddenExportParent() )
   266 			{
   267 				//std::cout << "ExportASCII::  "<<curIndent.toStdString()<<cur->getHeading().toStdString()<<std::endl;
   268 				switch (cur->depth())
   269 				{
   270 					case 0:
   271 						ts << underline (cur->getHeading(),QString("="));
   272 						ts << "\n";
   273 						break;
   274 					case 1:
   275 						ts << "\n";
   276 						ts << (underline (getSectionString(cur) + cur->getHeading(), QString("-") ) );
   277 						ts << "\n";
   278 						break;
   279 					case 2:
   280 						ts << "\n";
   281 						ts << (curIndent + "* " + cur->getHeading());
   282 						ts << "\n";
   283 						break;
   284 					case 3:
   285 						ts << (curIndent + "- " + cur->getHeading());
   286 						ts << "\n";
   287 						break;
   288 					default:
   289 						ts << (curIndent + "- " + cur->getHeading());
   290 						ts << "\n";
   291 						break;
   292 				}
   293 
   294 				// If necessary, write note
   295 				if (!cur->getNoteObj().isEmpty())
   296 				{
   297 					curIndent +="  | ";
   298 					s=cur->getNoteASCII( curIndent, 80);
   299 					ts << s;
   300 				}
   301 			}
   302 		}
   303 		cur=model->nextBranch(cur,prev);
   304 	}
   305 	file.close();
   306 }
   307 
   308 QString ExportASCII::underline (const QString &text, const QString &line)
   309 {
   310 	QString r=text + "\n";
   311 	for (int j=0;j<text.length();j++) r+=line;
   312 	return r;
   313 }
   314 
   315 
   316 ////////////////////////////////////////////////////////////////////////
   317 void ExportCSV::doExport()
   318 {
   319 	QFile file (outputFile);
   320 	if ( !file.open( QIODevice::WriteOnly ) )
   321 	{
   322 		qWarning ("ExportBase::exportXML  couldn't open "+outputFile);
   323 		return;
   324 	}
   325 	QTextStream ts( &file );	// use LANG decoding here...
   326 
   327 	// Write header
   328 	ts << "\"Note\""  <<endl;
   329 
   330 	// Main loop over all branches
   331 	QString s;
   332 	QString curIndent("");
   333 	int i;
   334 	BranchObj *bo;  //FIXME-3 still needed?
   335 	BranchItem *cur=NULL;
   336 	BranchItem *prev=NULL;
   337 	cur=model->nextBranch (cur,prev);
   338 	while (cur) 
   339 	{
   340 		bo=(BranchObj*)(cur->getLMO());
   341 
   342 		if (!cur->hasHiddenExportParent() )
   343 		{
   344 			// If necessary, write note
   345 			if (!cur->getNoteObj().isEmpty())
   346 			{
   347 				s =cur->getNoteASCII();
   348 				s=s.replace ("\n","\n"+curIndent);
   349 				ts << ("\""+s+"\",");
   350 			} else
   351 				ts <<"\"\",";
   352 
   353 			// Make indentstring
   354 			for (i=0;i<cur->depth();i++) curIndent+= "\"\",";
   355 
   356 			// Write heading
   357 			ts << curIndent << "\"" << cur->getHeading()<<"\""<<endl;
   358 		}
   359 		
   360 		cur=model->nextBranch(cur,prev);
   361 		curIndent="";
   362 	}
   363 	file.close();
   364 }
   365 
   366 ////////////////////////////////////////////////////////////////////////
   367 void ExportKDE3Bookmarks::doExport() 
   368 {
   369 	WarningDialog dia;
   370 	dia.showCancelButton (true);
   371 	dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
   372 	dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE 3"));
   373 	dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
   374 	if (dia.exec()==QDialog::Accepted)
   375 	{
   376 		model->exportXML(tmpDir.path(),false);
   377 
   378 		XSLTProc p;
   379 		p.setInputFile (tmpDir.path()+"/"+model->getMapName()+".xml");
   380 		p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
   381 		p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
   382 		p.process();
   383 
   384 		QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
   385 		QProcess *proc= new QProcess ;
   386 		proc->start( ub);
   387 		if (!proc->waitForStarted())
   388 		{
   389 			QMessageBox::warning(0, 
   390 				QObject::tr("Warning"),
   391 				QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
   392 		}	
   393 	}
   394 }
   395 
   396 ////////////////////////////////////////////////////////////////////////
   397 void ExportKDE4Bookmarks::doExport() 
   398 {
   399 	WarningDialog dia;
   400 	dia.showCancelButton (true);
   401 	dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE 4"));
   402 	dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
   403 	dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
   404 	if (dia.exec()==QDialog::Accepted)
   405 	{
   406 		model->exportXML(tmpDir.path(),false);
   407 
   408 		XSLTProc p;
   409 		p.setInputFile (tmpDir.path()+"/"+model->getMapName()+".xml");
   410 		p.setOutputFile (tmpDir.home().path()+"/.kde4/share/apps/konqueror/bookmarks.xml");
   411 		p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
   412 		p.process();
   413 
   414 		QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
   415 		QProcess *proc= new QProcess ;
   416 		proc->start( ub);
   417 		if (!proc->waitForStarted())
   418 		{
   419 			QMessageBox::warning(0, 
   420 				QObject::tr("Warning"),
   421 				QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
   422 		}	
   423 	}
   424 }
   425 
   426 ////////////////////////////////////////////////////////////////////////
   427 void ExportFirefoxBookmarks::doExport() 
   428 {
   429 	WarningDialog dia;
   430 	dia.showCancelButton (true);
   431 	dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("Firefox"));
   432 	dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("Firefox"));
   433 	dia.setShowAgainName("/vym/warnings/overwriteImportBookmarks");
   434 	if (dia.exec()==QDialog::Accepted)
   435 	{
   436 		model->exportXML(tmpDir.path(),false);
   437 
   438 /*
   439 		XSLTProc p;
   440 		p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
   441 		p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
   442 		p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
   443 		p.process();
   444 
   445 		QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
   446 		QProcess *proc = new QProcess( );
   447 		proc->addArgument(ub);
   448 
   449 		if ( !proc->start() ) 
   450 		{
   451 			QMessageBox::warning(0, 
   452 				QObject::tr("Warning"),
   453 				QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
   454 		}	
   455 
   456 */
   457 	}
   458 }
   459 
   460 ////////////////////////////////////////////////////////////////////////
   461 void ExportTaskjuggler::doExport() 
   462 {
   463 	model->exportXML(tmpDir.path(),false);
   464 
   465 	XSLTProc p;
   466 	p.setInputFile (tmpDir.path()+"/"+model->getMapName()+".xml");
   467 	p.setOutputFile (outputFile);
   468 	p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
   469 	p.process();
   470 }
   471 
   472 ////////////////////////////////////////////////////////////////////////
   473 void ExportLaTeX::doExport() 
   474 {
   475 	// Exports a map to a LaTex file.  
   476 	// This file needs to be included 
   477 	// or inported into a LaTex document
   478 	// it will not add a preamble, or anything 
   479 	// that makes a full LaTex document.
   480   QFile file (outputFile);
   481   if ( !file.open( QIODevice::WriteOnly ) ) {
   482 	QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile));
   483 	mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
   484     return;
   485   }
   486   QTextStream ts( &file );	// use LANG decoding here...
   487   ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
   488   
   489   // Main loop over all branches
   490   QString s;
   491   // QString curIndent("");
   492   // int i;
   493   BranchObj *bo;
   494   BranchItem *cur=NULL;
   495   BranchItem *prev=NULL;
   496   model->nextBranch(cur,prev);
   497   while (cur) 
   498   {
   499 	bo=(BranchObj*)(cur->getLMO());
   500 
   501 	if (!cur->hasHiddenExportParent() )
   502 	{
   503 		switch (cur->depth() ) 
   504 		{
   505 			case 0: break;
   506 			case 1: 
   507 			  ts << ("\\chapter{" + cur->getHeading()+ "}\n");
   508 			  break;
   509 			case 2: 
   510 			  ts << ("\\section{" + cur->getHeading()+ "}\n");
   511 			  break;
   512 			case 3: 
   513 			  ts << ("\\subsection{" + cur->getHeading()+ "}\n");
   514 			  break;
   515 			case 4: 
   516 			  ts << ("\\subsubsection{" + cur->getHeading()+ "}\n");
   517 			  break;
   518 			default:
   519 			  ts << ("\\paragraph*{" + cur->getHeading()+ "}\n");
   520 			
   521 		}
   522 		// If necessary, write note
   523 		if (!cur->getNoteObj().isEmpty()) {
   524 		  ts << (cur->getNoteASCII());
   525 		  ts << ("\n");
   526 		}
   527 	}
   528     cur=model->nextBranch(cur,prev);
   529    }
   530   file.close();
   531 }
   532 
   533 ////////////////////////////////////////////////////////////////////////
   534 ExportOO::ExportOO()
   535 {
   536 	useSections=false;
   537 }
   538 
   539 ExportOO::~ExportOO()
   540 {
   541 }	
   542 
   543 QString ExportOO::buildList (TreeItem *current)
   544 {
   545     QString r;
   546 
   547     uint i=0;
   548 	BranchItem *bi=current->getFirstBranch();
   549 	if (bi)
   550     {
   551 		if (!bi->hasHiddenExportParent() )	// FIXME-3 use BranchItem...
   552 		{
   553 			// Start list
   554 			r+="<text:list text:style-name=\"vym-list\">\n";
   555 			while (bi)
   556 			{
   557 				r+="<text:list-item><text:p >";
   558 				r+=quotemeta(bi->getHeading());
   559 				// If necessary, write note
   560 				if (!bi->getNoteObj().isEmpty())
   561 					r+=bi->getNoteOpenDoc();
   562 				r+="</text:p>";
   563 				r+=buildList (bi);	// recursivly add deeper branches
   564 				r+="</text:list-item>\n";
   565 				i++;
   566 				bi=current->getBranchNum(i);
   567 			}
   568 			r+="</text:list>\n";
   569 		}
   570     }
   571     return r;
   572 }
   573 
   574 
   575 void ExportOO::exportPresentation()
   576 {
   577 	QString allPages;
   578 
   579 	BranchItem *firstMCO=(BranchItem*)(model->getRootItem()->getFirstBranch());
   580 	if (!firstMCO) 
   581 	{
   582 		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("No objects in map!"));
   583 		return;
   584 	}
   585 
   586 	// Insert new content
   587 	// FIXME add extra title in mapinfo for vym 1.13.x
   588 	content.replace ("<!-- INSERT TITLE -->",quotemeta(firstMCO->getHeading()));
   589 	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(model->getAuthor()));
   590 
   591 	QString	onePage;
   592 	QString list;
   593 	
   594 	BranchItem *sectionBI;	
   595     int i=0;
   596 	BranchItem *pagesBI;
   597     int j=0;
   598 
   599 	int mapcenters=model->getRootItem()->branchCount();
   600 
   601 	// useSections already has been set in setConfigFile 
   602 	if (mapcenters>1)	
   603 		sectionBI=firstMCO;
   604 	else
   605 		sectionBI=firstMCO->getFirstBranch();
   606 
   607 	// Walk sections
   608 	while (sectionBI && !sectionBI->hasHiddenExportParent() )
   609 	{
   610 		if (useSections)
   611 		{
   612 			// Add page with section title
   613 			onePage=sectionTemplate;
   614 			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBI->getHeading() ) );
   615 			allPages+=onePage;
   616 			pagesBI=sectionBI->getFirstBranch();
   617 		} else
   618 		{
   619 			//i=-2;	// only use inner loop to 
   620 			        // turn mainbranches into pages
   621 			//sectionBI=firstMCO;
   622 			pagesBI=sectionBI;
   623 		}
   624 
   625 		j=0;
   626 		while (pagesBI && !pagesBI->hasHiddenExportParent() )
   627 		{
   628 			// Add page with list of items
   629 			onePage=pageTemplate;
   630 			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBI->getHeading() ) );
   631 			list=buildList (pagesBI);
   632 			onePage.replace ("<!-- INSERT LIST -->", list);
   633 			allPages+=onePage;
   634 			if (pagesBI!=sectionBI)
   635 			{
   636 				j++;
   637 				pagesBI=((BranchItem*)pagesBI->parent())->getBranchNum(j);
   638 			} else
   639 				pagesBI=NULL;	// We are already iterating over the sectionBIs
   640 		}
   641 		i++;
   642 		if (mapcenters>1 )
   643 			sectionBI=model->getRootItem()->getBranchNum (i);
   644 		else
   645 			sectionBI=firstMCO->getBranchNum (i);
   646 	}
   647 	
   648 	content.replace ("<!-- INSERT PAGES -->",allPages);
   649 
   650 	// Write modified content
   651 	QFile f (contentFile);
   652     if ( !f.open( QIODevice::WriteOnly ) ) 
   653 	{
   654 		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(contentFile));
   655 		mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
   656 		return;
   657     }
   658 
   659     QTextStream t( &f );
   660     t << content;
   661     f.close();
   662 
   663 	// zip tmpdir to destination
   664 	zipDir (tmpDir,outputFile);	
   665 }
   666 
   667 bool ExportOO::setConfigFile (const QString &cf)
   668 {
   669 	configFile=cf;
   670 	int i=cf.findRev ("/");
   671 	if (i>=0) configDir=cf.left(i);
   672 	SimpleSettings set;
   673 	set.readSettings(configFile);
   674 
   675 	// set paths
   676 	templateDir=configDir+"/"+set.readEntry ("Template");
   677 
   678 	QDir d (templateDir);
   679 	if (!d.exists())
   680 	{
   681 		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Check \"%1\" in\n%2").arg("Template="+set.readEntry ("Template")).arg(configFile));
   682 		return false;
   683 
   684 	}
   685 
   686 	contentTemplateFile=templateDir+"content-template.xml";
   687 	contentFile=tmpDir.path()+"/content.xml";
   688 	pageTemplateFile=templateDir+"page-template.xml";
   689 	sectionTemplateFile=templateDir+"section-template.xml";
   690 
   691 	if (set.readEntry("useSections").contains("yes"))
   692 		useSections=true;
   693 
   694 	// Copy template to tmpdir
   695 	system ("cp -r "+templateDir+"* "+tmpDir.path());
   696 
   697 	// Read content-template
   698 	if (!loadStringFromDisk (contentTemplateFile,content))
   699 	{
   700 		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(contentTemplateFile));
   701 		return false;
   702 	}
   703 
   704 	// Read page-template
   705 	if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
   706 	{
   707 		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(pageTemplateFile));
   708 		return false;
   709 	}
   710 	
   711 	// Read section-template
   712 	if (useSections && !loadStringFromDisk (sectionTemplateFile,sectionTemplate))
   713 	{
   714 		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(sectionTemplateFile));
   715 		return false;
   716 	}
   717 	return true;
   718 }
   719