contactengine/dbtools.cpp
author John Kern <johnk@symbian.org>
Fri, 03 Sep 2010 10:47:49 -0700
changeset 43 105a16347b5a
parent 41 b56d7e268634
permissions -rw-r--r--
reverting to previous version
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
43
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
     2
#include <QtSql>
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
     3
#include <QFile>
20
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
     4
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
     5
#include "database.h"
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
     6
#include "dbtools.h"
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
     7
43
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
     8
bool DBTools::createTable(QString sqlStmt)
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
     9
{
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    10
    qDebug() << "DB: create table statement: " << sqlStmt << endl;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    11
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    12
    QSqlQuery query;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    13
    return query.exec(sqlStmt);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    14
}
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    15
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    16
int DBTools::getLastInsertRowId()
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    17
{
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    18
    int rc = -1;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    19
    QSqlQuery query;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    20
    query.exec("select last_insert_rowid()");
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    21
    if (!query.exec()) {
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    22
        QString errCode =  "last rowid query Failed: " + query.lastError().text();
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    23
        qWarning(errCode.toStdString().c_str());
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    24
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    25
    } else {
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    26
        query.next();
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    27
        rc = query.value(0).toInt();
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    28
    }
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    29
    return rc;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    30
}
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    31
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    32
void DBTools::insertContact( QString name, QString mobile, QString deskphone,
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    33
                    int xtn, QString email, QString skype,
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    34
                    QString twitter, QString title, int site,
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    35
                    int department, int floor)
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    36
{
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    37
    QSqlQuery query;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    38
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    39
    query.prepare("INSERT INTO contacts ( name, mobile, deskphone, xtn, "
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    40
                  "email, skype, twitter, title, site, department, floor) "
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    41
                  "VALUES (:name,:mobile,:deskphone,:xtn,:email,:skype, "
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    42
                  ":twitter, :title, :site, :department, :floor)");
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    43
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    44
    query.bindValue(":name", name);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    45
    query.bindValue(":mobile", mobile);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    46
    query.bindValue(":deskphone", deskphone);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    47
    query.bindValue(":xtn", xtn);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    48
    query.bindValue(":twitter", twitter);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    49
    query.bindValue(":skype", skype);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    50
    query.bindValue(":email", email);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    51
    query.bindValue(":title", title);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    52
    query.bindValue(":site", site);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    53
    query.bindValue(":department", department);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    54
    query.bindValue(":floor", floor);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    55
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    56
    if (!query.exec())
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    57
    {
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    58
        qDebug() << query.lastError();
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    59
        qFatal("Failed to add fish.");
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    60
    }
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    61
}
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    62
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    63
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    64
bool DBTools::createDB()
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    65
{
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    66
    QSqlDatabase db;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    67
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    68
    // Find QSLite driver
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    69
    db = QSqlDatabase::addDatabase("QSQLITE");
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    70
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    71
    db.setDatabaseName("C:\\contactengine.db");
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    72
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    73
    // Open databasee
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    74
    if(!db.open())
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    75
    {
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    76
        qDebug() << "DB: failed to open" << endl;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    77
        exit (1);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    78
    }
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    79
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    80
    qDebug() << "DB: database opened " << endl;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    81
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    82
    bool rc = createTable("create table contacts "
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    83
                "(cid integer primary key, "
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    84
                "name varchar(128),"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    85
                "mobile varchar(128),"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    86
                "deskphone varchar(128),"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    87
                "xtn int,"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    88
                "email varchar(128),"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    89
                "skype varchar(128),"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    90
                "twitter varchar(128),"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    91
                "title varchar(128),"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    92
                "site int,"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    93
                "department int,"
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    94
                "floor int)");
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    95
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    96
    qDebug() << "DB: create table rc=" << rc << endl;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    97
    return rc;
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    98
}
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
    99
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
   100
void DBTools::testDB()
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
   101
{
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
   102
    createDB();
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
   103
    insertContact("Tom", "12345", "45678", 22, "tom@symbian.org", "thetom", "tomtom",
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
   104
                  "Senior Tom", SITE_LONDON, DEPT_TDM, 0);
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
   105
}
20
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   106
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   107
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
   108
{
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
   109
    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
   110
    QString line;
20
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   111
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
   112
    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
   113
        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
   114
        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
   115
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
   116
        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
   117
        {
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
   118
            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
   119
            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
   120
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
   121
            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
   122
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
   123
            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
   124
            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
   125
            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
   126
            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
   127
            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
   128
            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
   129
            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
   130
            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
   131
            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
   132
            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
   133
            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
   134
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
   135
            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
   136
                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
   137
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
   138
            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
   139
                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
   140
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
   141
            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
   142
                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
   143
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
   144
            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
   145
                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
   146
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
   147
            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
   148
                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
   149
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
   150
            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
   151
                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
   152
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
   153
            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
   154
                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
   155
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
   156
            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
   157
                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
   158
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
   159
            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
   160
                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
   161
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
   162
            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
   163
                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
   164
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
   165
            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
   166
                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
   167
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
   168
            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
   169
      }
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
   170
    }
20
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   171
}
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   172
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   173
DBTools::DBTools(QObject *parent)
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   174
{
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   175
    QObject();
43
105a16347b5a reverting to previous version
John Kern <johnk@symbian.org>
parents: 41
diff changeset
   176
    createDB();
20
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   177
}
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   178
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   179
DBTools::~DBTools()
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   180
{
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   181
a7451a8eb5dc Added DB framework for CSV import - doesn't work yet though
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
diff changeset
   182
}