author | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
commit | ea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (unidiff) | |
tree | f2ea22cc50e9aa8aa73ee7dea148f41c563c9666 /libopie/pim/opimmainwindow.cpp | |
parent | 1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff) | |
download | opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2 |
libopie1 goes into unsupported
Diffstat (limited to 'libopie/pim/opimmainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/opimmainwindow.cpp | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp deleted file mode 100644 index 99a0333..0000000 --- a/libopie/pim/opimmainwindow.cpp +++ b/dev/null | |||
@@ -1,150 +0,0 @@ | |||
1 | #include <qapplication.h> | ||
2 | #include <qdatetime.h> | ||
3 | #include <qcopchannel_qws.h> | ||
4 | |||
5 | #include <qpe/sound.h> | ||
6 | #include <qpe/qcopenvelope_qws.h> | ||
7 | #include <qpe/qpeapplication.h> | ||
8 | |||
9 | #include "opimresolver.h" | ||
10 | #include "opimmainwindow.h" | ||
11 | |||
12 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, | ||
13 | const char* name, WFlags flag ) | ||
14 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { | ||
15 | |||
16 | /* | ||
17 | * let's generate our QCopChannel | ||
18 | */ | ||
19 | m_str = QString("QPE/"+m_service).local8Bit(); | ||
20 | m_channel= new QCopChannel(m_str, this ); | ||
21 | connect(m_channel, SIGNAL(received(const QCString&,const QByteArray&) ), | ||
22 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); | ||
23 | connect(qApp, SIGNAL(appMessage(const QCString&,const QByteArray&) ), | ||
24 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); | ||
25 | |||
26 | /* connect flush and reload */ | ||
27 | connect(qApp, SIGNAL(flush() ), | ||
28 | this, SLOT(flush() ) ); | ||
29 | connect(qApp, SIGNAL(reload() ), | ||
30 | this, SLOT(reload() ) ); | ||
31 | } | ||
32 | OPimMainWindow::~OPimMainWindow() { | ||
33 | delete m_channel; | ||
34 | } | ||
35 | QCopChannel* OPimMainWindow::channel() { | ||
36 | return m_channel; | ||
37 | } | ||
38 | void OPimMainWindow::doSetDocument( const QString& ) { | ||
39 | |||
40 | } | ||
41 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { | ||
42 | bool needShow = false; | ||
43 | /* | ||
44 | * create demands to create | ||
45 | * a new record... | ||
46 | */ | ||
47 | QDataStream stream(array, IO_ReadOnly); | ||
48 | if ( cmd == "create()" ) { | ||
49 | raise(); | ||
50 | int uid = create(); | ||
51 | QCopEnvelope e(m_str, "created(int)" ); | ||
52 | e << uid; | ||
53 | needShow = true; | ||
54 | }else if ( cmd == "remove(int)" ) { | ||
55 | int uid; | ||
56 | stream >> uid; | ||
57 | bool rem = remove( uid ); | ||
58 | QCopEnvelope e(m_str, "removed(bool)" ); | ||
59 | e << rem; | ||
60 | needShow = true; | ||
61 | }else if ( cmd == "beam(int)" ) { | ||
62 | int uid; | ||
63 | stream >> uid; | ||
64 | beam( uid); | ||
65 | }else if ( cmd == "show(int)" ) { | ||
66 | raise(); | ||
67 | int uid; | ||
68 | stream >> uid; | ||
69 | show( uid ); | ||
70 | needShow = true; | ||
71 | }else if ( cmd == "edit(int)" ) { | ||
72 | raise(); | ||
73 | int uid; | ||
74 | stream >> uid; | ||
75 | edit( uid ); | ||
76 | }else if ( cmd == "add(int,QByteArray)" ) { | ||
77 | int rtti; | ||
78 | QByteArray array; | ||
79 | stream >> rtti; | ||
80 | stream >> array; | ||
81 | m_fallBack = record(rtti, array ); | ||
82 | if (!m_fallBack) return; | ||
83 | add( *m_fallBack ); | ||
84 | delete m_fallBack; | ||
85 | }else if ( cmd == "alarm(QDateTime,int)" ) { | ||
86 | raise(); | ||
87 | QDateTime dt; int uid; | ||
88 | stream >> dt; | ||
89 | stream >> uid; | ||
90 | qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); | ||
91 | QDateTime current = QDateTime::currentDateTime(); | ||
92 | if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) | ||
93 | return; | ||
94 | doAlarm( dt, uid ); | ||
95 | needShow = true; | ||
96 | } | ||
97 | |||
98 | if (needShow ) | ||
99 | QPEApplication::setKeepRunning(); | ||
100 | } | ||
101 | /* implement the url scripting here */ | ||
102 | void OPimMainWindow::setDocument( const QString& str) { | ||
103 | doSetDocument( str ); | ||
104 | } | ||
105 | /* | ||
106 | * we now try to get the array demarshalled | ||
107 | * check if the rtti matches this one | ||
108 | */ | ||
109 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { | ||
110 | if ( service() != rtti ) | ||
111 | return 0l; | ||
112 | |||
113 | OPimRecord* record = OPimResolver::self()->record( rtti ); | ||
114 | QDataStream str(array, IO_ReadOnly ); | ||
115 | if ( !record || !record->loadFromStream(str) ) { | ||
116 | delete record; | ||
117 | record = 0l; | ||
118 | } | ||
119 | |||
120 | return record; | ||
121 | } | ||
122 | /* | ||
123 | * get the rtti for the service | ||
124 | */ | ||
125 | int OPimMainWindow::service() { | ||
126 | if ( m_rtti == -1 ) | ||
127 | m_rtti = OPimResolver::self()->serviceId( m_service ); | ||
128 | |||
129 | return m_rtti; | ||
130 | } | ||
131 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { | ||
132 | |||
133 | } | ||
134 | void OPimMainWindow::startAlarm(int count ) { | ||
135 | m_alarmCount = count; | ||
136 | m_playedCount = 0; | ||
137 | Sound::soundAlarm(); | ||
138 | m_timerId = startTimer( 5000 ); | ||
139 | } | ||
140 | void OPimMainWindow::killAlarm() { | ||
141 | killTimer( m_timerId ); | ||
142 | } | ||
143 | void OPimMainWindow::timerEvent( QTimerEvent* e) { | ||
144 | if ( m_playedCount <m_alarmCount ) { | ||
145 | m_playedCount++; | ||
146 | Sound::soundAlarm(); | ||
147 | }else { | ||
148 | killTimer( e->timerId() ); | ||
149 | } | ||
150 | } | ||