-rw-r--r-- | libopie/pim/ocontactaccess.cpp | 13 | ||||
-rw-r--r-- | libopie/pim/opimmainwindow.cpp | 8 |
2 files changed, 13 insertions, 8 deletions
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp index 2e3ec1f..bc359f7 100644 --- a/libopie/pim/ocontactaccess.cpp +++ b/libopie/pim/ocontactaccess.cpp | |||
@@ -1,168 +1,173 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | * Class to manage the Contacts. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * Info: This class could just work with a change in the header-file | 12 | * Info: This class could just work with a change in the header-file |
13 | * of the Contact class ! Therefore our libopie only compiles | 13 | * of the Contact class ! Therefore our libopie only compiles |
14 | * with our version of libqpe | 14 | * with our version of libqpe |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * ToDo: XML-Backend: Automatic reload if something was changed... | 16 | * ToDo: XML-Backend: Automatic reload if something was changed... |
17 | * | 17 | * |
18 | * | 18 | * |
19 | * ===================================================================== | 19 | * ===================================================================== |
20 | * Version: $Id$ | 20 | * Version: $Id$ |
21 | * ===================================================================== | 21 | * ===================================================================== |
22 | * History: | 22 | * History: |
23 | * $Log$ | 23 | * $Log$ |
24 | * Revision 1.9 2004/03/02 12:14:22 alwin | ||
25 | * run the optimize_connect script | ||
26 | * the whole cvs is tagged with "before_optimize_connect" if there are problems you | ||
27 | * can check the diff (but it had compiled and run here) | ||
28 | * | ||
24 | * Revision 1.8 2003/05/08 13:55:09 tille | 29 | * Revision 1.8 2003/05/08 13:55:09 tille |
25 | * search stuff | 30 | * search stuff |
26 | * and match, toRichText & toShortText in oevent | 31 | * and match, toRichText & toShortText in oevent |
27 | * | 32 | * |
28 | * Revision 1.7 2002/11/13 14:14:51 eilers | 33 | * Revision 1.7 2002/11/13 14:14:51 eilers |
29 | * Added sorted for Contacts.. | 34 | * Added sorted for Contacts.. |
30 | * | 35 | * |
31 | * Revision 1.6 2002/11/01 15:10:42 eilers | 36 | * Revision 1.6 2002/11/01 15:10:42 eilers |
32 | * Added regExp-search in database for all fields in a contact. | 37 | * Added regExp-search in database for all fields in a contact. |
33 | * | 38 | * |
34 | * Revision 1.5 2002/10/16 10:52:40 eilers | 39 | * Revision 1.5 2002/10/16 10:52:40 eilers |
35 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 40 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
36 | * | 41 | * |
37 | * Revision 1.4 2002/10/14 16:21:54 eilers | 42 | * Revision 1.4 2002/10/14 16:21:54 eilers |
38 | * Some minor interface updates | 43 | * Some minor interface updates |
39 | * | 44 | * |
40 | * Revision 1.3 2002/10/07 17:34:24 eilers | 45 | * Revision 1.3 2002/10/07 17:34:24 eilers |
41 | * added OBackendFactory for advanced backend access | 46 | * added OBackendFactory for advanced backend access |
42 | * | 47 | * |
43 | * Revision 1.2 2002/10/02 16:18:11 eilers | 48 | * Revision 1.2 2002/10/02 16:18:11 eilers |
44 | * debugged and seems to work almost perfectly .. | 49 | * debugged and seems to work almost perfectly .. |
45 | * | 50 | * |
46 | * Revision 1.1 2002/09/27 17:11:44 eilers | 51 | * Revision 1.1 2002/09/27 17:11:44 eilers |
47 | * Added API for accessing the Contact-Database ! It is compiling, but | 52 | * Added API for accessing the Contact-Database ! It is compiling, but |
48 | * please do not expect that anything is working ! | 53 | * please do not expect that anything is working ! |
49 | * I will debug that stuff in the next time .. | 54 | * I will debug that stuff in the next time .. |
50 | * Please read README_COMPILE for compiling ! | 55 | * Please read README_COMPILE for compiling ! |
51 | * | 56 | * |
52 | * | 57 | * |
53 | */ | 58 | */ |
54 | 59 | ||
55 | #include "ocontactaccess.h" | 60 | #include "ocontactaccess.h" |
56 | #include "obackendfactory.h" | 61 | #include "obackendfactory.h" |
57 | 62 | ||
58 | #include <qasciidict.h> | 63 | #include <qasciidict.h> |
59 | #include <qdatetime.h> | 64 | #include <qdatetime.h> |
60 | #include <qfile.h> | 65 | #include <qfile.h> |
61 | #include <qregexp.h> | 66 | #include <qregexp.h> |
62 | #include <qlist.h> | 67 | #include <qlist.h> |
63 | #include <qcopchannel_qws.h> | 68 | #include <qcopchannel_qws.h> |
64 | 69 | ||
65 | //#include <qpe/qcopenvelope_qws.h> | 70 | //#include <qpe/qcopenvelope_qws.h> |
66 | #include <qpe/global.h> | 71 | #include <qpe/global.h> |
67 | 72 | ||
68 | #include <errno.h> | 73 | #include <errno.h> |
69 | #include <fcntl.h> | 74 | #include <fcntl.h> |
70 | #include <unistd.h> | 75 | #include <unistd.h> |
71 | #include <stdlib.h> | 76 | #include <stdlib.h> |
72 | 77 | ||
73 | #include "ocontactaccessbackend_xml.h" | 78 | #include "ocontactaccessbackend_xml.h" |
74 | 79 | ||
75 | 80 | ||
76 | OContactAccess::OContactAccess ( const QString appname, const QString , | 81 | OContactAccess::OContactAccess ( const QString appname, const QString , |
77 | OContactAccessBackend* end, bool autosync ): | 82 | OContactAccessBackend* end, bool autosync ): |
78 | OPimAccessTemplate<OContact>( end ) | 83 | OPimAccessTemplate<OContact>( end ) |
79 | { | 84 | { |
80 | /* take care of the backend. If there is no one defined, we | 85 | /* take care of the backend. If there is no one defined, we |
81 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 86 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
82 | */ | 87 | */ |
83 | if( end == 0 ) { | 88 | if( end == 0 ) { |
84 | qWarning ("Using BackendFactory !"); | 89 | qWarning ("Using BackendFactory !"); |
85 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); | 90 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); |
86 | } | 91 | } |
87 | // Set backend locally and in template | 92 | // Set backend locally and in template |
88 | m_backEnd = end; | 93 | m_backEnd = end; |
89 | OPimAccessTemplate<OContact>::setBackEnd (end); | 94 | OPimAccessTemplate<OContact>::setBackEnd (end); |
90 | 95 | ||
91 | 96 | ||
92 | /* Connect signal of external db change to function */ | 97 | /* Connect signal of external db change to function */ |
93 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 98 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
94 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 99 | connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
95 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 100 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
96 | if ( autosync ){ | 101 | if ( autosync ){ |
97 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 102 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
98 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 103 | connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
99 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 104 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
100 | } | 105 | } |
101 | 106 | ||
102 | 107 | ||
103 | } | 108 | } |
104 | OContactAccess::~OContactAccess () | 109 | OContactAccess::~OContactAccess () |
105 | { | 110 | { |
106 | /* The user may forget to save the changed database, therefore try to | 111 | /* The user may forget to save the changed database, therefore try to |
107 | * do it for him.. | 112 | * do it for him.. |
108 | */ | 113 | */ |
109 | save(); | 114 | save(); |
110 | // delete m_backEnd; is done by template.. | 115 | // delete m_backEnd; is done by template.. |
111 | } | 116 | } |
112 | 117 | ||
113 | 118 | ||
114 | bool OContactAccess::save () | 119 | bool OContactAccess::save () |
115 | { | 120 | { |
116 | /* If the database was changed externally, we could not save the | 121 | /* If the database was changed externally, we could not save the |
117 | * Data. This will remove added items which is unacceptable ! | 122 | * Data. This will remove added items which is unacceptable ! |
118 | * Therefore: Reload database and merge the data... | 123 | * Therefore: Reload database and merge the data... |
119 | */ | 124 | */ |
120 | if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) | 125 | if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) |
121 | reload(); | 126 | reload(); |
122 | 127 | ||
123 | bool status = OPimAccessTemplate<OContact>::save(); | 128 | bool status = OPimAccessTemplate<OContact>::save(); |
124 | if ( !status ) return false; | 129 | if ( !status ) return false; |
125 | 130 | ||
126 | /* Now tell everyone that new data is available. | 131 | /* Now tell everyone that new data is available. |
127 | */ | 132 | */ |
128 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); | 133 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); |
129 | 134 | ||
130 | return true; | 135 | return true; |
131 | } | 136 | } |
132 | 137 | ||
133 | const uint OContactAccess::querySettings() | 138 | const uint OContactAccess::querySettings() |
134 | { | 139 | { |
135 | return ( m_backEnd->querySettings() ); | 140 | return ( m_backEnd->querySettings() ); |
136 | } | 141 | } |
137 | 142 | ||
138 | bool OContactAccess::hasQuerySettings ( int querySettings ) const | 143 | bool OContactAccess::hasQuerySettings ( int querySettings ) const |
139 | { | 144 | { |
140 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | 145 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); |
141 | } | 146 | } |
142 | ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const | 147 | ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const |
143 | { | 148 | { |
144 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); | 149 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); |
145 | return ( ORecordList<OContact>(matchingContacts, this) ); | 150 | return ( ORecordList<OContact>(matchingContacts, this) ); |
146 | } | 151 | } |
147 | 152 | ||
148 | 153 | ||
149 | bool OContactAccess::wasChangedExternally()const | 154 | bool OContactAccess::wasChangedExternally()const |
150 | { | 155 | { |
151 | return ( m_backEnd->wasChangedExternally() ); | 156 | return ( m_backEnd->wasChangedExternally() ); |
152 | } | 157 | } |
153 | 158 | ||
154 | 159 | ||
155 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 160 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) |
156 | { | 161 | { |
157 | if ( msg == "addressbookUpdated()" ){ | 162 | if ( msg == "addressbookUpdated()" ){ |
158 | qWarning ("OContactAccess: Received addressbokUpdated()"); | 163 | qWarning ("OContactAccess: Received addressbokUpdated()"); |
159 | emit signalChanged ( this ); | 164 | emit signalChanged ( this ); |
160 | } else if ( msg == "flush()" ) { | 165 | } else if ( msg == "flush()" ) { |
161 | qWarning ("OContactAccess: Received flush()"); | 166 | qWarning ("OContactAccess: Received flush()"); |
162 | save (); | 167 | save (); |
163 | } else if ( msg == "reload()" ) { | 168 | } else if ( msg == "reload()" ) { |
164 | qWarning ("OContactAccess: Received reload()"); | 169 | qWarning ("OContactAccess: Received reload()"); |
165 | reload (); | 170 | reload (); |
166 | emit signalChanged ( this ); | 171 | emit signalChanged ( this ); |
167 | } | 172 | } |
168 | } | 173 | } |
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp index 2739e26..99a0333 100644 --- a/libopie/pim/opimmainwindow.cpp +++ b/libopie/pim/opimmainwindow.cpp | |||
@@ -1,150 +1,150 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | #include <qcopchannel_qws.h> | 3 | #include <qcopchannel_qws.h> |
4 | 4 | ||
5 | #include <qpe/sound.h> | 5 | #include <qpe/sound.h> |
6 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | #include "opimresolver.h" | 9 | #include "opimresolver.h" |
10 | #include "opimmainwindow.h" | 10 | #include "opimmainwindow.h" |
11 | 11 | ||
12 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, | 12 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, |
13 | const char* name, WFlags flag ) | 13 | const char* name, WFlags flag ) |
14 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { | 14 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { |
15 | 15 | ||
16 | /* | 16 | /* |
17 | * let's generate our QCopChannel | 17 | * let's generate our QCopChannel |
18 | */ | 18 | */ |
19 | m_str = QString("QPE/"+m_service).local8Bit(); | 19 | m_str = QString("QPE/"+m_service).local8Bit(); |
20 | m_channel= new QCopChannel(m_str, this ); | 20 | m_channel= new QCopChannel(m_str, this ); |
21 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), | 21 | connect(m_channel, SIGNAL(received(const QCString&,const QByteArray&) ), |
22 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 22 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); |
23 | connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), | 23 | connect(qApp, SIGNAL(appMessage(const QCString&,const QByteArray&) ), |
24 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 24 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); |
25 | 25 | ||
26 | /* connect flush and reload */ | 26 | /* connect flush and reload */ |
27 | connect(qApp, SIGNAL(flush() ), | 27 | connect(qApp, SIGNAL(flush() ), |
28 | this, SLOT(flush() ) ); | 28 | this, SLOT(flush() ) ); |
29 | connect(qApp, SIGNAL(reload() ), | 29 | connect(qApp, SIGNAL(reload() ), |
30 | this, SLOT(reload() ) ); | 30 | this, SLOT(reload() ) ); |
31 | } | 31 | } |
32 | OPimMainWindow::~OPimMainWindow() { | 32 | OPimMainWindow::~OPimMainWindow() { |
33 | delete m_channel; | 33 | delete m_channel; |
34 | } | 34 | } |
35 | QCopChannel* OPimMainWindow::channel() { | 35 | QCopChannel* OPimMainWindow::channel() { |
36 | return m_channel; | 36 | return m_channel; |
37 | } | 37 | } |
38 | void OPimMainWindow::doSetDocument( const QString& ) { | 38 | void OPimMainWindow::doSetDocument( const QString& ) { |
39 | 39 | ||
40 | } | 40 | } |
41 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { | 41 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { |
42 | bool needShow = false; | 42 | bool needShow = false; |
43 | /* | 43 | /* |
44 | * create demands to create | 44 | * create demands to create |
45 | * a new record... | 45 | * a new record... |
46 | */ | 46 | */ |
47 | QDataStream stream(array, IO_ReadOnly); | 47 | QDataStream stream(array, IO_ReadOnly); |
48 | if ( cmd == "create()" ) { | 48 | if ( cmd == "create()" ) { |
49 | raise(); | 49 | raise(); |
50 | int uid = create(); | 50 | int uid = create(); |
51 | QCopEnvelope e(m_str, "created(int)" ); | 51 | QCopEnvelope e(m_str, "created(int)" ); |
52 | e << uid; | 52 | e << uid; |
53 | needShow = true; | 53 | needShow = true; |
54 | }else if ( cmd == "remove(int)" ) { | 54 | }else if ( cmd == "remove(int)" ) { |
55 | int uid; | 55 | int uid; |
56 | stream >> uid; | 56 | stream >> uid; |
57 | bool rem = remove( uid ); | 57 | bool rem = remove( uid ); |
58 | QCopEnvelope e(m_str, "removed(bool)" ); | 58 | QCopEnvelope e(m_str, "removed(bool)" ); |
59 | e << rem; | 59 | e << rem; |
60 | needShow = true; | 60 | needShow = true; |
61 | }else if ( cmd == "beam(int)" ) { | 61 | }else if ( cmd == "beam(int)" ) { |
62 | int uid; | 62 | int uid; |
63 | stream >> uid; | 63 | stream >> uid; |
64 | beam( uid); | 64 | beam( uid); |
65 | }else if ( cmd == "show(int)" ) { | 65 | }else if ( cmd == "show(int)" ) { |
66 | raise(); | 66 | raise(); |
67 | int uid; | 67 | int uid; |
68 | stream >> uid; | 68 | stream >> uid; |
69 | show( uid ); | 69 | show( uid ); |
70 | needShow = true; | 70 | needShow = true; |
71 | }else if ( cmd == "edit(int)" ) { | 71 | }else if ( cmd == "edit(int)" ) { |
72 | raise(); | 72 | raise(); |
73 | int uid; | 73 | int uid; |
74 | stream >> uid; | 74 | stream >> uid; |
75 | edit( uid ); | 75 | edit( uid ); |
76 | }else if ( cmd == "add(int,QByteArray)" ) { | 76 | }else if ( cmd == "add(int,QByteArray)" ) { |
77 | int rtti; | 77 | int rtti; |
78 | QByteArray array; | 78 | QByteArray array; |
79 | stream >> rtti; | 79 | stream >> rtti; |
80 | stream >> array; | 80 | stream >> array; |
81 | m_fallBack = record(rtti, array ); | 81 | m_fallBack = record(rtti, array ); |
82 | if (!m_fallBack) return; | 82 | if (!m_fallBack) return; |
83 | add( *m_fallBack ); | 83 | add( *m_fallBack ); |
84 | delete m_fallBack; | 84 | delete m_fallBack; |
85 | }else if ( cmd == "alarm(QDateTime,int)" ) { | 85 | }else if ( cmd == "alarm(QDateTime,int)" ) { |
86 | raise(); | 86 | raise(); |
87 | QDateTime dt; int uid; | 87 | QDateTime dt; int uid; |
88 | stream >> dt; | 88 | stream >> dt; |
89 | stream >> uid; | 89 | stream >> uid; |
90 | qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); | 90 | qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); |
91 | QDateTime current = QDateTime::currentDateTime(); | 91 | QDateTime current = QDateTime::currentDateTime(); |
92 | if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) | 92 | if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) |
93 | return; | 93 | return; |
94 | doAlarm( dt, uid ); | 94 | doAlarm( dt, uid ); |
95 | needShow = true; | 95 | needShow = true; |
96 | } | 96 | } |
97 | 97 | ||
98 | if (needShow ) | 98 | if (needShow ) |
99 | QPEApplication::setKeepRunning(); | 99 | QPEApplication::setKeepRunning(); |
100 | } | 100 | } |
101 | /* implement the url scripting here */ | 101 | /* implement the url scripting here */ |
102 | void OPimMainWindow::setDocument( const QString& str) { | 102 | void OPimMainWindow::setDocument( const QString& str) { |
103 | doSetDocument( str ); | 103 | doSetDocument( str ); |
104 | } | 104 | } |
105 | /* | 105 | /* |
106 | * we now try to get the array demarshalled | 106 | * we now try to get the array demarshalled |
107 | * check if the rtti matches this one | 107 | * check if the rtti matches this one |
108 | */ | 108 | */ |
109 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { | 109 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { |
110 | if ( service() != rtti ) | 110 | if ( service() != rtti ) |
111 | return 0l; | 111 | return 0l; |
112 | 112 | ||
113 | OPimRecord* record = OPimResolver::self()->record( rtti ); | 113 | OPimRecord* record = OPimResolver::self()->record( rtti ); |
114 | QDataStream str(array, IO_ReadOnly ); | 114 | QDataStream str(array, IO_ReadOnly ); |
115 | if ( !record || !record->loadFromStream(str) ) { | 115 | if ( !record || !record->loadFromStream(str) ) { |
116 | delete record; | 116 | delete record; |
117 | record = 0l; | 117 | record = 0l; |
118 | } | 118 | } |
119 | 119 | ||
120 | return record; | 120 | return record; |
121 | } | 121 | } |
122 | /* | 122 | /* |
123 | * get the rtti for the service | 123 | * get the rtti for the service |
124 | */ | 124 | */ |
125 | int OPimMainWindow::service() { | 125 | int OPimMainWindow::service() { |
126 | if ( m_rtti == -1 ) | 126 | if ( m_rtti == -1 ) |
127 | m_rtti = OPimResolver::self()->serviceId( m_service ); | 127 | m_rtti = OPimResolver::self()->serviceId( m_service ); |
128 | 128 | ||
129 | return m_rtti; | 129 | return m_rtti; |
130 | } | 130 | } |
131 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { | 131 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { |
132 | 132 | ||
133 | } | 133 | } |
134 | void OPimMainWindow::startAlarm(int count ) { | 134 | void OPimMainWindow::startAlarm(int count ) { |
135 | m_alarmCount = count; | 135 | m_alarmCount = count; |
136 | m_playedCount = 0; | 136 | m_playedCount = 0; |
137 | Sound::soundAlarm(); | 137 | Sound::soundAlarm(); |
138 | m_timerId = startTimer( 5000 ); | 138 | m_timerId = startTimer( 5000 ); |
139 | } | 139 | } |
140 | void OPimMainWindow::killAlarm() { | 140 | void OPimMainWindow::killAlarm() { |
141 | killTimer( m_timerId ); | 141 | killTimer( m_timerId ); |
142 | } | 142 | } |
143 | void OPimMainWindow::timerEvent( QTimerEvent* e) { | 143 | void OPimMainWindow::timerEvent( QTimerEvent* e) { |
144 | if ( m_playedCount <m_alarmCount ) { | 144 | if ( m_playedCount <m_alarmCount ) { |
145 | m_playedCount++; | 145 | m_playedCount++; |
146 | Sound::soundAlarm(); | 146 | Sound::soundAlarm(); |
147 | }else { | 147 | }else { |
148 | killTimer( e->timerId() ); | 148 | killTimer( e->timerId() ); |
149 | } | 149 | } |
150 | } | 150 | } |