Menu

[c54480]: / imports.cpp  Maximize  Restore  History

Download this file

93 lines (75 with data), 1.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "file.h"
#include "imports.h"
#include "linkablemapobj.h"
#include "misc.h"
#include "mainwindow.h"
#include "xsltproc.h"
#include <QMessageBox>
extern Main *mainWindow;
extern QDir vymBaseDir;
ImportBase::ImportBase()
{
bool ok;
tmpDir.setPath (makeTmpDir(ok,"vym-import"));
if (!tmpDir.exists() || !ok)
QMessageBox::critical( 0, QObject::tr( "Error" ),
QObject::tr("Couldn't access temporary directory\n"));
}
ImportBase::~ImportBase()
{
// Remove tmpdir
removeDir (tmpDir);
}
void ImportBase::setDir(const QString &p)
{
inputDir=p;
}
void ImportBase::setFile (const QString &p)
{
inputFile=p;
}
bool ImportBase::transform()
{
return true;
}
QString ImportBase::getTransformedFile()
{
return transformedFile;
}
/////////////////////////////////////////////////
bool ImportFirefoxBookmarks::transform()
{
transformedFile=tmpDir.path()+"/bookmarks.xml";
QStringList lines;
QFile file( inputFile );
if ( file.open( QIODevice::ReadOnly ) )
{
QTextStream stream( &file );
while ( !stream.atEnd() )
lines += stream.readLine(); // line of text excluding '\n'
file.close();
}
// TODO Generate vym from broken bookmarks above...
return true;
}
/////////////////////////////////////////////////
bool ImportMM::transform()
{
// try to unzip
if (File::Success==unzipDir (tmpDir, inputFile))
{
// Set short name, too. Search from behind:
transformedFile=inputFile;
int i=transformedFile.lastIndexOf ("/");
if (i>=0) transformedFile=transformedFile.remove (0,i+1);
transformedFile.replace(".mmap",".xml");
transformedFile=tmpDir.path()+"/"+transformedFile;
XSLTProc p;
p.setInputFile (tmpDir.path()+"/Document.xml");
p.setOutputFile (transformedFile);
p.setXSLFile (vymBaseDir.path()+"/styles/mmap2vym.xsl");
p.process();
return true;
} else
return false;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.