author | insilmaril |
Tue, 06 Jun 2006 14:58:11 +0000 | |
branch | qt4-port |
changeset 2 | 608f976aa7bb |
child 19 | caba269c3757 |
permissions | -rw-r--r-- |
insilmaril@2 | 1 |
#include <qmessagebox.h> |
insilmaril@2 | 2 |
//Added by qt3to4: |
insilmaril@2 | 3 |
#include <QTextStream> |
insilmaril@2 | 4 |
|
insilmaril@2 | 5 |
#include "file.h" |
insilmaril@2 | 6 |
#include "imports.h" |
insilmaril@2 | 7 |
#include "linkablemapobj.h" |
insilmaril@2 | 8 |
#include "misc.h" |
insilmaril@2 | 9 |
#include "mainwindow.h" |
insilmaril@2 | 10 |
#include "xsltproc.h" |
insilmaril@2 | 11 |
|
insilmaril@2 | 12 |
extern Main *mainWindow; |
insilmaril@2 | 13 |
extern QDir vymBaseDir; |
insilmaril@2 | 14 |
|
insilmaril@2 | 15 |
ImportBase::ImportBase() |
insilmaril@2 | 16 |
{ |
insilmaril@2 | 17 |
// Create tmpdir |
insilmaril@2 | 18 |
tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX")); |
insilmaril@2 | 19 |
} |
insilmaril@2 | 20 |
|
insilmaril@2 | 21 |
|
insilmaril@2 | 22 |
ImportBase::~ImportBase() |
insilmaril@2 | 23 |
{ |
insilmaril@2 | 24 |
// Remove tmpdir |
insilmaril@2 | 25 |
removeDir (tmpDir); |
insilmaril@2 | 26 |
} |
insilmaril@2 | 27 |
|
insilmaril@2 | 28 |
void ImportBase::setDir(const QString &p) |
insilmaril@2 | 29 |
{ |
insilmaril@2 | 30 |
inputDir=p; |
insilmaril@2 | 31 |
} |
insilmaril@2 | 32 |
|
insilmaril@2 | 33 |
void ImportBase::setFile (const QString &p) |
insilmaril@2 | 34 |
{ |
insilmaril@2 | 35 |
inputFile=p; |
insilmaril@2 | 36 |
} |
insilmaril@2 | 37 |
|
insilmaril@2 | 38 |
void ImportBase::setMapCenter(MapCenterObj *mc) |
insilmaril@2 | 39 |
{ |
insilmaril@2 | 40 |
mapCenter=mc; |
insilmaril@2 | 41 |
} |
insilmaril@2 | 42 |
|
insilmaril@2 | 43 |
bool ImportBase::transform() |
insilmaril@2 | 44 |
{ |
insilmaril@2 | 45 |
return true; |
insilmaril@2 | 46 |
} |
insilmaril@2 | 47 |
|
insilmaril@2 | 48 |
QString ImportBase::getTransformedFile() |
insilmaril@2 | 49 |
{ |
insilmaril@2 | 50 |
return transformedFile; |
insilmaril@2 | 51 |
} |
insilmaril@2 | 52 |
|
insilmaril@2 | 53 |
///////////////////////////////////////////////// |
insilmaril@2 | 54 |
bool ImportKDEBookmarks::transform() |
insilmaril@2 | 55 |
{ |
insilmaril@2 | 56 |
transformedFile=tmpDir.path()+"/bookmarks.xml"; |
insilmaril@2 | 57 |
|
insilmaril@2 | 58 |
XSLTProc p; |
insilmaril@2 | 59 |
p.setInputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml"); |
insilmaril@2 | 60 |
p.setOutputFile (transformedFile); |
insilmaril@2 | 61 |
p.setXSLFile (vymBaseDir.path()+"/styles/kdebookmarks2vym.xsl"); |
insilmaril@2 | 62 |
p.process(); |
insilmaril@2 | 63 |
|
insilmaril@2 | 64 |
return true; |
insilmaril@2 | 65 |
} |
insilmaril@2 | 66 |
|
insilmaril@2 | 67 |
|
insilmaril@2 | 68 |
///////////////////////////////////////////////// |
insilmaril@2 | 69 |
bool ImportFirefoxBookmarks::transform() |
insilmaril@2 | 70 |
{ |
insilmaril@2 | 71 |
transformedFile=tmpDir.path()+"/bookmarks.xml"; |
insilmaril@2 | 72 |
|
insilmaril@2 | 73 |
QStringList lines; |
insilmaril@2 | 74 |
QFile file( inputFile ); |
insilmaril@2 | 75 |
if ( file.open( QIODevice::ReadOnly ) ) |
insilmaril@2 | 76 |
{ |
insilmaril@2 | 77 |
QTextStream stream( &file ); |
insilmaril@2 | 78 |
while ( !stream.atEnd() ) |
insilmaril@2 | 79 |
lines += stream.readLine(); // line of text excluding '\n' |
insilmaril@2 | 80 |
file.close(); |
insilmaril@2 | 81 |
} |
insilmaril@2 | 82 |
// FIXME |
insilmaril@2 | 83 |
// Generate vym from broken bookmarks above... |
insilmaril@2 | 84 |
|
insilmaril@2 | 85 |
return true; |
insilmaril@2 | 86 |
} |
insilmaril@2 | 87 |
|
insilmaril@2 | 88 |
|
insilmaril@2 | 89 |
///////////////////////////////////////////////// |
insilmaril@2 | 90 |
bool ImportMM::transform() |
insilmaril@2 | 91 |
{ |
insilmaril@2 | 92 |
// try to unzip |
insilmaril@2 | 93 |
if (success==unzipDir (tmpDir, inputFile)) |
insilmaril@2 | 94 |
{ |
insilmaril@2 | 95 |
|
insilmaril@2 | 96 |
// Set short name, too. Search from behind: |
insilmaril@2 | 97 |
transformedFile=inputFile; |
insilmaril@2 | 98 |
int i=transformedFile.findRev("/"); |
insilmaril@2 | 99 |
if (i>=0) transformedFile=transformedFile.remove (0,i+1); |
insilmaril@2 | 100 |
transformedFile.replace(".mmap",".xml"); |
insilmaril@2 | 101 |
transformedFile=tmpDir.path()+"/"+transformedFile; |
insilmaril@2 | 102 |
|
insilmaril@2 | 103 |
XSLTProc p; |
insilmaril@2 | 104 |
p.setInputFile (tmpDir.path()+"/Document.xml"); |
insilmaril@2 | 105 |
p.setOutputFile (transformedFile); |
insilmaril@2 | 106 |
p.setXSLFile (vymBaseDir.path()+"/styles/mmap2vym.xsl"); |
insilmaril@2 | 107 |
p.process(); |
insilmaril@2 | 108 |
|
insilmaril@2 | 109 |
cout << " xslt done"<<endl; |
insilmaril@2 | 110 |
|
insilmaril@2 | 111 |
return true; |
insilmaril@2 | 112 |
} else |
insilmaril@2 | 113 |
return false; |
insilmaril@2 | 114 |
|
insilmaril@2 | 115 |
} |