know bugs fixed and added search box to do a search with a contact name develop
authorCuong Le <metacuong@gmail.com>
Fri, 30 Sep 2011 08:17:09 +0000 (15:17 +0700)
committerCuong Le <metacuong@gmail.com>
Fri, 30 Sep 2011 08:17:09 +0000 (15:17 +0700)
elv1db.cc
elv1db.h
mainwindow.cc
mainwindow.h
qtc_packaging/debian_fremantle/changelog

index 9f5f4da..d76fcb5 100644 (file)
--- a/elv1db.cc
+++ b/elv1db.cc
@@ -28,6 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 elv1db::elv1db(QObject *parent):
     QThread(parent),
     m_type_query(0),
+    m_search_val(new QString("")),
     m_db(QSqlDatabase::addDatabase("QSQLITE"))
 {
     m_db.setDatabaseName("/home/user/.rtcom-eventlogger/el-v1.db");
@@ -37,6 +38,7 @@ elv1db::elv1db(QObject *parent):
 elv1db::~elv1db(){
     if (m_db.isOpen())
         m_db.close();
+    delete this->m_search_val;
 }
 
 PhoneType elv1db::phonetype(QString metastr){
@@ -52,26 +54,36 @@ PhoneType elv1db::phonetype(QString metastr){
 }
 
 QString elv1db::calltype(){
-    return this->m_call_type==ALL_CALL?"and (event_type_id = 1 or event_type_id = 3)":
+    return this->m_call_type==ALL_CALL?"and (event_type_id = 1 or event_type_id = 2)":
                                                       this->m_call_type==INCOMING?"and event_type_id = 1  and outgoing = 0":
-                                                      this->m_call_type==OUTGOING?"and event_type_id = 1  and outgoing = 1":"and event_type_id = 3";
+                                                      this->m_call_type==OUTGOING?"and event_type_id = 1  and outgoing = 1":"and event_type_id = 2";
 }
 
 void elv1db::run(){
-    if (this->m_type_query == 0)
+    if (this->m_type_query == 0 || this->m_type_query == 2)
         emit start_indicator();
     else
         emit detail_start_indicator();
 
     sleep(1);
 
-    if (this->m_type_query == 0){
+    if (this->m_type_query == 0){ //all
         QString m_group_by_call(H_TOTAL_GROUP_BY);
         setQuery(m_group_by_call
                  .arg(this->m_all_call?"":"and E.local_uid='ring/tel/ring'")
                  .arg(calltype()));
     }
-    else{
+    else if (this->m_type_query == 2 ){ //doSearch
+        QString m_group_by_and_search_call(H_TOTAL_GROUP_BY_AND_SEARCH);
+        QString m_search_val_convert("and remote_name like '%%1%'");
+        m_search_val_convert = m_search_val_convert.arg(*this->m_search_val);
+
+        setQuery(m_group_by_and_search_call
+                 .arg(this->m_all_call?"":"and E.local_uid='ring/tel/ring'")
+                 .arg(calltype())
+                 .arg(m_search_val_convert));
+    }
+    else { // for contact details
         QString m_filter(" and remote_name = '%1' %2 ");
         m_filter = m_filter.arg(m_contact_name).arg(calltype());
         QString m_default_search = QString(H_DEFAULT_SEARCH).arg(m_filter).arg(100);
@@ -81,7 +93,7 @@ void elv1db::run(){
     QSqlQuery *query = new QSqlQuery(this->m_query);
     QSqlRecord record = query->record();
     if(record.count() > 0){
-        if (this->m_type_query == 0){
+        if (this->m_type_query == 0 || this->m_type_query == 2){
             this->m_records.clear();
               while (query->next()) {
                   elv1rec *ef=new elv1rec();
@@ -89,7 +101,8 @@ void elv1db::run(){
                   ef->set_total_call(query->value(1).value<QString>());
                   this->m_records << ef;
               }
-        }else{
+        }
+        else{
 
             this->m_detail_records.clear();
 
@@ -98,7 +111,7 @@ void elv1db::run(){
 
                 int calltype =  query->value(0).value< int >();
 
-                if (calltype == 1 || calltype == 3){
+                if (calltype == 1 || calltype == 2){
                     ef->set_phonenumber(query->value(5).value<QString>());
                     ef->set_starttime(query->value(1).value<uint>());
                     ef->set_endtime(query->value(2).value<uint>());
@@ -124,7 +137,7 @@ void elv1db::run(){
 
     delete query;
 
-    if (this->m_type_query == 0)
+    if (this->m_type_query == 0 || this->m_type_query == 2)
         emit group_by_finished();
     else
         emit detail_finished();
index d14466d..30dd304 100644 (file)
--- a/elv1db.h
+++ b/elv1db.h
@@ -24,6 +24,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 #include <QDateTime>
 
 #define H_TOTAL_GROUP_BY "select remote_name, count(*) from Events E, Remotes R where R.remote_uid=E.remote_uid and E.local_uid=R.local_uid %1 %2 group by remote_name order by start_time desc"
+#define H_TOTAL_GROUP_BY_AND_SEARCH "select remote_name, count(*) from Events E, Remotes R where R.remote_uid=E.remote_uid and E.local_uid=R.local_uid %1 %2 %3 group by remote_name order by start_time desc"
 #define H_DEFAULT_SEARCH "select event_type_id, start_time, end_time, is_read, E.local_uid, E.remote_uid, free_text, outgoing, remote_name from Events E, Remotes R where R.remote_uid=E.remote_uid and E.local_uid=R.local_uid %1 order by start_time desc limit %2"
 
 #define P_TYPE_GSM_NETWORK  "ring/tel/ring"
@@ -192,11 +193,13 @@ public:
     QList<elv1rec*> m_records;
     QList<elv1Detailrec*> m_detail_records;
 
-    bool m_type_query;
+    uint m_type_query;
 
     bool m_all_call;
     CallType m_call_type;
 
+    QString *m_search_val;
+
 signals:
     void start_indicator();
     void group_by_finished();
index fad4da9..273440e 100644 (file)
@@ -21,6 +21,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 #include <QtCore/QCoreApplication>
 #include <QDebug>
 
+#include <QInputDialog>
 
 #include "listitemdetaildelegate.h"
 
@@ -61,6 +62,9 @@ MainWindow::MainWindow(QWidget *parent):
 
         m_elv1db->m_type_query = 0;
 
+        m_in_search = false;
+        m_type_query_temp = 0;
+
         connect(m_elv1db, SIGNAL(group_by_finished()), this, SLOT(elv1db_finised()));
         connect(m_elv1db, SIGNAL(detail_finished()), this, SLOT(elv1db_detail_finised()));
         connect(m_elv1db, SIGNAL(start_indicator()), this, SLOT(start_indicator()));
@@ -86,6 +90,7 @@ MainWindow::~MainWindow()
     delete this->m_contacts_widget;
     delete this->m_contact_detail;
     delete this->m_elv1db;
+    delete this->m_no_search;
 }
 
 void MainWindow::cellClicked(int row, int col){
@@ -124,7 +129,7 @@ void MainWindow::elv1db_detail_finised(){
                   (t_cache.year()!=ef->get_startdate().year()) ){
 
             QListWidgetItem *header = new QListWidgetItem();
-            header->setData(Qt::DisplayRole, ef->get_startdate().toString());
+            header->setData(Qt::DisplayRole, ef->get_startdate().toString().toUtf8());
             m_contact_detail->addItem(header);
 
             t_cache=ef->get_startdate();
@@ -250,6 +255,12 @@ void MainWindow::setup_menu(){
     connect(m_clear_log,SIGNAL(triggered()), this, SLOT(clearLog()));
     connect(m_options, SIGNAL(triggered()), this, SLOT(dlgOptions()));*/
 
+    QAction *m_search = this->menuBar()->addAction("Search");
+    connect(m_search,SIGNAL(triggered()), this, SLOT(dlgSearch()));
+
+    m_no_search = this->menuBar()->addAction("Search is Off");
+    connect(m_no_search,SIGNAL(triggered()), this, SLOT(noSearch()));
+
     QAction *m_about = this->menuBar()->addAction("About");
     QAction *m_about_qt = this->menuBar()->addAction("About Qt");
 
@@ -258,15 +269,46 @@ void MainWindow::setup_menu(){
 
 }
 
+void MainWindow::noSearch(){
+    if (m_in_search){
+        m_contacts_widget->setEnabled(false);
+        m_no_search->setText("Search is Off");
+        m_elv1db->m_type_query = m_type_query_temp;
+        m_in_search = false;
+        m_elv1db->start();
+    }
+}
+
+void MainWindow::dlgSearch(){
+    bool ok;
+    QString text = QInputDialog::getText(this, tr("Search"),
+                                         tr("Give me a contact name to do a search :"), QLineEdit::Normal,
+                                         *m_elv1db->m_search_val, &ok);
+    if (ok && !text.isEmpty() && !text.trimmed().isEmpty()){
+        m_no_search->setText("Search is On");
+        m_in_search = true;
+        this->doSearch(text);
+    }
+}
+
+void MainWindow::doSearch(QString val){
+    m_contacts_widget->setEnabled(false);
+    *m_elv1db->m_search_val = val;
+    m_elv1db->m_type_query = 2;
+    m_elv1db->start();
+}
+
 void MainWindow::select_all_call(){ //ring/tel/ring, spirit/skype, gabble/jabber
     m_contacts_widget->setEnabled(false);
     m_elv1db->m_all_call = true;
+    m_type_query_temp = 0;
     m_elv1db->start();
 }
 
 void MainWindow::select_gsm_calls(){ //ring/tel/ring
     m_contacts_widget->setEnabled(false);
     m_elv1db->m_all_call = false;
+    m_type_query_temp = 0;
     m_elv1db->start();
 }
 
@@ -305,7 +347,7 @@ void MainWindow::dlgAbout(){
     m_about.setWindowTitle("About");
     m_about.setText(
                 "<font size=4>VN Call History</font><br>"
-                "<font size=3>Version : 0.0.1 (09/28/2011)</font><br>"
+                "<font size=3>Version : 0.0.2 (09/29/2011)</font><br>"
                 "Author : Cuong Le <a href=\"mailto:metacuong@gmail.com\">metacuong@gmail.com</a><br>"
                 "<font size=2>"
                 "Homepage : <a href=\"http://vncallhistory.garage.maemo.org/\">http://vncallhistory.garage.maemo.org/</a><br>"
index ac6be0a..1e3affe 100644 (file)
@@ -69,6 +69,9 @@ private slots:
     void select_outgoing_calls();
     void select_missed_calls();
 
+    void dlgSearch();
+    void noSearch();
+
 private:
     QTableWidget *m_contacts_widget;
     QListWidget *m_contact_detail;
@@ -78,7 +81,12 @@ private:
     void setup_menu();
     void setup_menu_detail();
 
+    void doSearch(QString val);
+
     elv1db *m_elv1db;
+    uint m_type_query_temp;
+    bool m_in_search;
+    QAction *m_no_search;
 
     QMainWindow *detail_dlg;
 
index 3479957..017fea2 100644 (file)
@@ -1,5 +1,6 @@
-vcallhistory (0.0.1) unstable; urgency=low
+vcallhistory (0.0.2) unstable; urgency=low
 
-  * First beta release.
+  * Fixes for unknow missed calls/unicode string.
+  * Added Search box
 
  -- Cuong Le <metacuong@gmail.com>  Sun, 25 Sep 2011 14:31:43 +0700