2 Copyright (C) 2011 by Cuong Le <metacuong@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>
22 #include <QtSql/QSqlDatabase>
26 #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"
27 #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"
28 #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"
30 #define P_TYPE_GSM_NETWORK "ring/tel/ring"
31 #define P_TYPE_SKYPE "spirit/skype"
32 #define P_TYPE_JABBER "gabble/jabber"
34 #define ICONS_ROOT_DIR "/usr/share/icons/hicolor/"
36 #define IMG_AVATAR ICONS_ROOT_DIR "48x48/hildon/general_default_avatar.png"
37 #define IMG_OUTGOING ICONS_ROOT_DIR "48x48/hildon/general_sent.png"
38 #define IMG_INCOMING ICONS_ROOT_DIR "48x48/hildon/general_received.png"
39 #define IMG_MISSED ICONS_ROOT_DIR "48x48/hildon/general_missed.png"
41 #define IMG_CELL ICONS_ROOT_DIR "32x32/hildon/call_status_cellular.png"
42 #define IMG_SKYPE ICONS_ROOT_DIR "32x32/hildon/general_skype.png"
43 #define IMG_GOOGLE ICONS_ROOT_DIR "32x32/hildon/general_gtalk.png"
44 #define IMG_SIP ICONS_ROOT_DIR "32x32/hildon/general_sip.png"
45 #define IMG_OVI ICONS_ROOT_DIR "32x32/hildon/general_ovi.png"
46 #define IMG_JABBER ICONS_ROOT_DIR "32x32/hildon/general_jabber.png"
49 The record class for group by informations first screen
51 class elv1rec : public QObject
57 m_avatar(QIcon::fromTheme( "general_default_avatar", QIcon(IMG_AVATAR)))
61 QString contact_name() const{
62 return m_contact_name;
65 QString total_call() const{
73 void set_contact_name(QString contact_name){
74 m_contact_name = contact_name;
77 void set_total_call(QString total_call){
78 m_total_call = total_call;
81 void set_avatar(QIcon avatar){
86 QString m_contact_name;
92 The record class for detail informations second screen
94 enum PhoneType { GSM_NETWORK = 0, SKYPE = 1, JABBER = 2, GOOGLE_TALK = 3, UNKNOW = 4};
95 enum CallType { OUTGOING = 0, INCOMING = 1, MISSED = 2, ALL_CALL = 3};
97 class elv1Detailrec : public QObject
106 void set_phonenumber(QString phonenumber){ m_phonenumber = phonenumber;}
107 void set_starttime(uint starttime){ m_starttime.setTime_t(starttime);}
108 void set_endtime(uint endtime){ m_endtime.setTime_t(endtime);}
109 void set_calltype(CallType calltype){
110 m_calltype = calltype;
111 m_icon = QIcon::fromTheme(calltype==OUTGOING?
112 "general_sent":calltype==INCOMING?
113 "general_received":"general_missed", QIcon(calltype==OUTGOING?
114 IMG_OUTGOING:calltype==INCOMING?
115 IMG_INCOMING:IMG_MISSED));
119 void set_phonetype(PhoneType phonetype){
120 m_phonetype = phonetype;
121 QString _m_icon_meta;
122 QString _m_icon_path;
125 _m_icon_meta = "call_status_cellular";
126 _m_icon_path = IMG_CELL;
129 _m_icon_meta = "general_skype";
130 _m_icon_path = IMG_SKYPE;
133 _m_icon_meta = "general_jabber";
134 _m_icon_path = IMG_JABBER;
137 _m_icon_meta = "general_gtalk";
138 _m_icon_path = IMG_GOOGLE;
141 _m_icon_meta = "call_status_unknow";
142 _m_icon_path = "unknow";
146 m_type_call_icon = QIcon::fromTheme(_m_icon_meta, QIcon(_m_icon_path));
149 void set_callduration(uint callduration){ m_callduration = callduration;}
151 QString get_phonenumber() const { return m_phonenumber;}
152 QIcon get_icon() const { return m_icon;}
153 QIcon get_type_call_icon() const { return m_type_call_icon;}
154 QTime get_starttime() const { return m_starttime.time();}
155 QTime get_endtime() const { return m_endtime.time();}
156 QDate get_startdate() const { return m_starttime.date();}
157 QDate get_enddate() const { return m_endtime.date();}
158 CallType get_calltype() const { return m_calltype;}
159 uint get_duration() const { return m_callduration;}
162 QIcon m_icon; //incoming/outgoing/missed call icons
163 QIcon m_type_call_icon; //cell/skype/sip/jingle/...
164 QString m_phonenumber;
165 QDateTime m_starttime;
168 PhoneType m_phonetype;
173 The main db management class
174 *MUST* be inherited QThread
178 class elv1db : public QThread
182 explicit elv1db(QObject *parent = 0);
187 void setQuery(QString o_query) {
191 QString m_contact_name;
193 QList<elv1rec*> m_records;
194 QList<elv1Detailrec*> m_detail_records;
199 CallType m_call_type;
201 QString *m_search_val;
204 void start_indicator();
205 void group_by_finished();
206 void detail_finished();
207 void detail_start_indicator();
213 PhoneType phonetype(QString metastr);