author | John Kern <johnk@symbian.org> |
Fri, 03 Sep 2010 07:59:16 -0700 | |
changeset 41 | b56d7e268634 |
parent 24 | 2e833c2a6782 |
child 43 | 105a16347b5a |
permissions | -rw-r--r-- |
20
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
1 |
#include <QtCore/QCoreApplication> |
21
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
2 |
#include <QFile> |
20
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
3 |
|
41 | 4 |
#include <QDebug> |
5 |
#include <QStringList> |
|
6 |
||
20
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
7 |
#include "database.h" |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
8 |
#include "dbtools.h" |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
9 |
|
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
10 |
|
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
11 |
void DBTools::importCSV(QString fileName) |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
12 |
{ |
21
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
13 |
QFile file(fileName); |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
14 |
QString line; |
20
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
15 |
|
21
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
16 |
if (file.open(QFile::ReadOnly)) { |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
17 |
qDebug() << "importCSV file open OK" << endl; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
18 |
char buf[1024]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
19 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
20 |
while(!file.atEnd()) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
21 |
{ |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
22 |
file.readLine(buf, sizeof(buf)); |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
23 |
QString string(buf); |
24
2e833c2a6782
Added csv file to sis exports; improved csv file location in main.cpp
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
21
diff
changeset
|
24 |
|
21
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
25 |
QStringList stringList = string.split(","); |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
26 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
27 |
QString strName; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
28 |
QString strMobile; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
29 |
QString strDeskphone; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
30 |
QString strXtn; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
31 |
QString strEmail; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
32 |
QString strFloor; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
33 |
QString strSkype; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
34 |
QString strTwitter; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
35 |
QString strTitle; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
36 |
QString strSite; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
37 |
QString strDepartment; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
38 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
39 |
if (stringList.count() > 0) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
40 |
strName = stringList[0]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
41 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
42 |
if (stringList.count() > 1) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
43 |
strMobile = stringList[1]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
44 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
45 |
if (stringList.count() > 2) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
46 |
strDeskphone = stringList[2]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
47 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
48 |
if (stringList.count() > 3) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
49 |
strXtn = stringList[3]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
50 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
51 |
if (stringList.count() > 4) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
52 |
strEmail = stringList[4]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
53 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
54 |
if (stringList.count() > 5) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
55 |
strSkype = stringList[5]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
56 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
57 |
if (stringList.count() > 6) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
58 |
strTwitter = stringList[6]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
59 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
60 |
if (stringList.count() > 7) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
61 |
strTitle = stringList[7]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
62 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
63 |
if (stringList.count() > 8) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
64 |
strSite = stringList[8]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
65 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
66 |
if (stringList.count() > 9) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
67 |
strDepartment = stringList[9]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
68 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
69 |
if (stringList.count() > 10) |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
70 |
strFloor =stringList[10]; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
71 |
|
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
72 |
qDebug() << strName << strTitle << endl; |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
73 |
} |
3bfc3227045d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
20
diff
changeset
|
74 |
} |
20
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
75 |
} |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
76 |
|
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
77 |
DBTools::DBTools(QObject *parent) |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
78 |
{ |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
79 |
QObject(); |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
80 |
} |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
81 |
|
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
82 |
DBTools::~DBTools() |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
83 |
{ |
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
84 |
|
a7451a8eb5dc
Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff
changeset
|
85 |
} |