X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=dbthread.cpp;fp=dbthread.cpp;h=972b7ae36c0a37a2a93a439b0bb5dc34a3a0b53c;hb=f81dd90b1452c4a2622b9a63eb2d47258fe72e37;hp=0000000000000000000000000000000000000000;hpb=24e9c77bec569ed58f02b5d1c17f944648042355;p=vietkaralist diff --git a/dbthread.cpp b/dbthread.cpp new file mode 100644 index 0000000..972b7ae --- /dev/null +++ b/dbthread.cpp @@ -0,0 +1,61 @@ +/* +Copyright (C) 2011 by Cuong Le + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +#include +#include +#include +#include +#include +#include + +#include "dbthread.h" + +DBThread::DBThread() +{ + db = QSqlDatabase::addDatabase("QSQLITE"); +#if defined(Q_WS_MAEMO_5) + db.setDatabaseName("/opt/vietkaralist/db/vietkaralist.sqlite"); +#else + db.setDatabaseName("/home/cuonglb/vietkaralist.sqlite"); +#endif + db.open(); +} + +DBThread::~DBThread(){ + db.close(); +} + +void DBThread::run(){ + + QSqlQuery query(this->mm_query); + QSqlRecord record = query.record(); + + if (record.count() > 0) { + emit removeOldSongs(); + while (query.next()) { + emit addSong(query.value(0).toString(),query.value(1).toString(), query.value(4).toString(), query.value(5).toString()); + } + } + + emit stopSearch(); + +} + +void DBThread::slotExecQuery(const QString& m_query){ + this->mm_query = m_query; + this->start(); +}