author | insilmaril |
Mon, 24 Apr 2006 11:31:15 +0000 | |
changeset 308 | 2827ca924b18 |
parent 228 | 654ad4b03c5a |
child 312 | d1d464798f08 |
permissions | -rw-r--r-- |
insilmaril@205 | 1 |
#include <qmessagebox.h> |
insilmaril@205 | 2 |
|
insilmaril@215 | 3 |
#include "file.h" |
insilmaril@205 | 4 |
#include "imports.h" |
insilmaril@205 | 5 |
#include "linkablemapobj.h" |
insilmaril@205 | 6 |
#include "misc.h" |
insilmaril@205 | 7 |
#include "mainwindow.h" |
insilmaril@205 | 8 |
#include "xsltproc.h" |
insilmaril@205 | 9 |
|
insilmaril@205 | 10 |
extern Main *mainWindow; |
insilmaril@215 | 11 |
extern QDir vymBaseDir; |
insilmaril@205 | 12 |
|
insilmaril@205 | 13 |
ImportBase::ImportBase() |
insilmaril@205 | 14 |
{ |
insilmaril@205 | 15 |
// Create tmpdir |
insilmaril@205 | 16 |
tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX")); |
insilmaril@205 | 17 |
} |
insilmaril@205 | 18 |
|
insilmaril@205 | 19 |
|
insilmaril@205 | 20 |
ImportBase::~ImportBase() |
insilmaril@205 | 21 |
{ |
insilmaril@205 | 22 |
// Remove tmpdir |
insilmaril@228 | 23 |
removeDir (tmpDir); |
insilmaril@205 | 24 |
} |
insilmaril@205 | 25 |
|
insilmaril@205 | 26 |
void ImportBase::setDir(const QString &p) |
insilmaril@205 | 27 |
{ |
insilmaril@205 | 28 |
inputDir=p; |
insilmaril@205 | 29 |
} |
insilmaril@205 | 30 |
|
insilmaril@205 | 31 |
void ImportBase::setFile (const QString &p) |
insilmaril@205 | 32 |
{ |
insilmaril@205 | 33 |
inputFile=p; |
insilmaril@205 | 34 |
} |
insilmaril@205 | 35 |
|
insilmaril@205 | 36 |
void ImportBase::setMapCenter(MapCenterObj *mc) |
insilmaril@205 | 37 |
{ |
insilmaril@205 | 38 |
mapCenter=mc; |
insilmaril@205 | 39 |
} |
insilmaril@205 | 40 |
|
insilmaril@215 | 41 |
bool ImportBase::transform() |
insilmaril@215 | 42 |
{ |
insilmaril@215 | 43 |
return true; |
insilmaril@215 | 44 |
} |
insilmaril@215 | 45 |
|
insilmaril@215 | 46 |
QString ImportBase::getTransformedFile() |
insilmaril@215 | 47 |
{ |
insilmaril@215 | 48 |
return transformedFile; |
insilmaril@215 | 49 |
} |
insilmaril@215 | 50 |
|
insilmaril@205 | 51 |
///////////////////////////////////////////////// |
insilmaril@215 | 52 |
bool ImportKDEBookmarks::transform() |
insilmaril@205 | 53 |
{ |
insilmaril@205 | 54 |
transformedFile=tmpDir.path()+"/bookmarks.xml"; |
insilmaril@205 | 55 |
|
insilmaril@205 | 56 |
XSLTProc p; |
insilmaril@205 | 57 |
p.setInputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml"); |
insilmaril@205 | 58 |
p.setOutputFile (transformedFile); |
insilmaril@215 | 59 |
p.setXSLFile (vymBaseDir.path()+"/styles/kdebookmarks2vym.xsl"); |
insilmaril@205 | 60 |
p.process(); |
insilmaril@215 | 61 |
|
insilmaril@215 | 62 |
return true; |
insilmaril@205 | 63 |
} |
insilmaril@205 | 64 |
|
insilmaril@215 | 65 |
|
insilmaril@215 | 66 |
///////////////////////////////////////////////// |
insilmaril@215 | 67 |
bool ImportMM::transform() |
insilmaril@205 | 68 |
{ |
insilmaril@215 | 69 |
// try to unzip |
insilmaril@215 | 70 |
if (success==unzipDir (tmpDir, inputFile)) |
insilmaril@215 | 71 |
{ |
insilmaril@215 | 72 |
cout << "Unzipped "<<inputFile<<" to "<<tmpDir.path()<<endl; |
insilmaril@215 | 73 |
|
insilmaril@215 | 74 |
// Set short name, too. Search from behind: |
insilmaril@215 | 75 |
transformedFile=inputFile; |
insilmaril@215 | 76 |
int i=transformedFile.findRev("/"); |
insilmaril@215 | 77 |
if (i>=0) transformedFile=transformedFile.remove (0,i+1); |
insilmaril@215 | 78 |
transformedFile.replace(".mmap",".xml"); |
insilmaril@215 | 79 |
transformedFile=tmpDir.path()+"/"+transformedFile; |
insilmaril@215 | 80 |
cout << " transformedFile="<<transformedFile<<endl; |
insilmaril@215 | 81 |
|
insilmaril@215 | 82 |
XSLTProc p; |
insilmaril@215 | 83 |
p.setInputFile (tmpDir.path()+"/Document.xml"); |
insilmaril@215 | 84 |
p.setOutputFile (transformedFile); |
insilmaril@215 | 85 |
p.setXSLFile (vymBaseDir.path()+"/styles/mmap2vym.xsl"); |
insilmaril@215 | 86 |
p.process(); |
insilmaril@215 | 87 |
|
insilmaril@215 | 88 |
cout << " xslt done"<<endl; |
insilmaril@215 | 89 |
|
insilmaril@215 | 90 |
return true; |
insilmaril@215 | 91 |
} else |
insilmaril@215 | 92 |
return false; |
insilmaril@215 | 93 |
|
insilmaril@205 | 94 |
} |