summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/ui/opimmainwindow.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/ui/opimmainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp
index 2739e26..10ed743 100644
--- a/libopie2/opiepim/ui/opimmainwindow.cpp
+++ b/libopie2/opiepim/ui/opimmainwindow.cpp
@@ -1,59 +1,88 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
1#include <qapplication.h> 29#include <qapplication.h>
2#include <qdatetime.h> 30#include <qdatetime.h>
3#include <qcopchannel_qws.h> 31#include <qcopchannel_qws.h>
4 32
5#include <qpe/sound.h> 33#include <qpe/sound.h>
6#include <qpe/qcopenvelope_qws.h> 34#include <qpe/qcopenvelope_qws.h>
7#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
8 36
9#include "opimresolver.h" 37#include <opie2/opimresolver.h>
10#include "opimmainwindow.h" 38#include "opimmainwindow.h"
11 39
40namespace Opie {
12OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, 41OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
13 const char* name, WFlags flag ) 42 const char* name, WFlags flag )
14 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { 43 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) {
15 44
16 /* 45 /*
17 * let's generate our QCopChannel 46 * let's generate our QCopChannel
18 */ 47 */
19 m_str = QString("QPE/"+m_service).local8Bit(); 48 m_str = QString("QPE/"+m_service).local8Bit();
20 m_channel= new QCopChannel(m_str, this ); 49 m_channel= new QCopChannel(m_str, this );
21 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), 50 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ),
22 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 51 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
23 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), 52 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ),
24 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 53 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
25 54
26 /* connect flush and reload */ 55 /* connect flush and reload */
27 connect(qApp, SIGNAL(flush() ), 56 connect(qApp, SIGNAL(flush() ),
28 this, SLOT(flush() ) ); 57 this, SLOT(flush() ) );
29 connect(qApp, SIGNAL(reload() ), 58 connect(qApp, SIGNAL(reload() ),
30 this, SLOT(reload() ) ); 59 this, SLOT(reload() ) );
31} 60}
32OPimMainWindow::~OPimMainWindow() { 61OPimMainWindow::~OPimMainWindow() {
33 delete m_channel; 62 delete m_channel;
34} 63}
35QCopChannel* OPimMainWindow::channel() { 64QCopChannel* OPimMainWindow::channel() {
36 return m_channel; 65 return m_channel;
37} 66}
38void OPimMainWindow::doSetDocument( const QString& ) { 67void OPimMainWindow::doSetDocument( const QString& ) {
39 68
40} 69}
41void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { 70void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
42 bool needShow = false; 71 bool needShow = false;
43 /* 72 /*
44 * create demands to create 73 * create demands to create
45 * a new record... 74 * a new record...
46 */ 75 */
47 QDataStream stream(array, IO_ReadOnly); 76 QDataStream stream(array, IO_ReadOnly);
48 if ( cmd == "create()" ) { 77 if ( cmd == "create()" ) {
49 raise(); 78 raise();
50 int uid = create(); 79 int uid = create();
51 QCopEnvelope e(m_str, "created(int)" ); 80 QCopEnvelope e(m_str, "created(int)" );
52 e << uid; 81 e << uid;
53 needShow = true; 82 needShow = true;
54 }else if ( cmd == "remove(int)" ) { 83 }else if ( cmd == "remove(int)" ) {
55 int uid; 84 int uid;
56 stream >> uid; 85 stream >> uid;
57 bool rem = remove( uid ); 86 bool rem = remove( uid );
58 QCopEnvelope e(m_str, "removed(bool)" ); 87 QCopEnvelope e(m_str, "removed(bool)" );
59 e << rem; 88 e << rem;
@@ -103,48 +132,50 @@ void OPimMainWindow::setDocument( const QString& str) {
103 doSetDocument( str ); 132 doSetDocument( str );
104} 133}
105/* 134/*
106 * we now try to get the array demarshalled 135 * we now try to get the array demarshalled
107 * check if the rtti matches this one 136 * check if the rtti matches this one
108 */ 137 */
109OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { 138OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) {
110 if ( service() != rtti ) 139 if ( service() != rtti )
111 return 0l; 140 return 0l;
112 141
113 OPimRecord* record = OPimResolver::self()->record( rtti ); 142 OPimRecord* record = OPimResolver::self()->record( rtti );
114 QDataStream str(array, IO_ReadOnly ); 143 QDataStream str(array, IO_ReadOnly );
115 if ( !record || !record->loadFromStream(str) ) { 144 if ( !record || !record->loadFromStream(str) ) {
116 delete record; 145 delete record;
117 record = 0l; 146 record = 0l;
118 } 147 }
119 148
120 return record; 149 return record;
121} 150}
122/* 151/*
123 * get the rtti for the service 152 * get the rtti for the service
124 */ 153 */
125int OPimMainWindow::service() { 154int OPimMainWindow::service() {
126 if ( m_rtti == -1 ) 155 if ( m_rtti == -1 )
127 m_rtti = OPimResolver::self()->serviceId( m_service ); 156 m_rtti = OPimResolver::self()->serviceId( m_service );
128 157
129 return m_rtti; 158 return m_rtti;
130} 159}
131void OPimMainWindow::doAlarm( const QDateTime&, int ) { 160void OPimMainWindow::doAlarm( const QDateTime&, int ) {
132 161
133} 162}
134void OPimMainWindow::startAlarm(int count ) { 163void OPimMainWindow::startAlarm(int count ) {
135 m_alarmCount = count; 164 m_alarmCount = count;
136 m_playedCount = 0; 165 m_playedCount = 0;
137 Sound::soundAlarm(); 166 Sound::soundAlarm();
138 m_timerId = startTimer( 5000 ); 167 m_timerId = startTimer( 5000 );
139} 168}
140void OPimMainWindow::killAlarm() { 169void OPimMainWindow::killAlarm() {
141 killTimer( m_timerId ); 170 killTimer( m_timerId );
142} 171}
143void OPimMainWindow::timerEvent( QTimerEvent* e) { 172void OPimMainWindow::timerEvent( QTimerEvent* e) {
144 if ( m_playedCount <m_alarmCount ) { 173 if ( m_playedCount <m_alarmCount ) {
145 m_playedCount++; 174 m_playedCount++;
146 Sound::soundAlarm(); 175 Sound::soundAlarm();
147 }else { 176 }else {
148 killTimer( e->timerId() ); 177 killTimer( e->timerId() );
149 } 178 }
150} 179}
180
181}