-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.cpp | 33 | ||||
-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.h | 36 | ||||
-rw-r--r-- | libopie2/opiepim/ui/ui.pro | 3 |
3 files changed, 68 insertions, 4 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,35 +1,64 @@ | |||
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 | ||
40 | namespace Opie { | ||
12 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, | 41 | OPimMainWindow::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 | } |
32 | OPimMainWindow::~OPimMainWindow() { | 61 | OPimMainWindow::~OPimMainWindow() { |
33 | delete m_channel; | 62 | delete m_channel; |
34 | } | 63 | } |
35 | QCopChannel* OPimMainWindow::channel() { | 64 | QCopChannel* OPimMainWindow::channel() { |
@@ -127,24 +156,26 @@ int OPimMainWindow::service() { | |||
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 | } |
131 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { | 160 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { |
132 | 161 | ||
133 | } | 162 | } |
134 | void OPimMainWindow::startAlarm(int count ) { | 163 | void 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 | } |
140 | void OPimMainWindow::killAlarm() { | 169 | void OPimMainWindow::killAlarm() { |
141 | killTimer( m_timerId ); | 170 | killTimer( m_timerId ); |
142 | } | 171 | } |
143 | void OPimMainWindow::timerEvent( QTimerEvent* e) { | 172 | void 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 | } | ||
diff --git a/libopie2/opiepim/ui/opimmainwindow.h b/libopie2/opiepim/ui/opimmainwindow.h index 855d364..abad630 100644 --- a/libopie2/opiepim/ui/opimmainwindow.h +++ b/libopie2/opiepim/ui/opimmainwindow.h | |||
@@ -1,47 +1,76 @@ | |||
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 | #ifndef OPIE_PIM_MAINWINDOW_H | 29 | #ifndef OPIE_PIM_MAINWINDOW_H |
2 | #define OPIE_PIM_MAINWINDOW_H | 30 | #define OPIE_PIM_MAINWINDOW_H |
3 | 31 | ||
4 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
5 | 33 | ||
6 | #include <opie/opimrecord.h> | 34 | #include <opie2/opimrecord.h> |
35 | class QCopChannel; | ||
36 | class QDateTime; | ||
7 | 37 | ||
38 | namespace Opie { | ||
8 | /** | 39 | /** |
9 | * This is a common Opie PIM MainWindow | 40 | * This is a common Opie PIM MainWindow |
10 | * it takes care of the QCOP internals | 41 | * it takes care of the QCOP internals |
11 | * and implements some functions | 42 | * and implements some functions |
12 | * for the URL scripting schema | 43 | * for the URL scripting schema |
13 | */ | 44 | */ |
14 | /* | 45 | /* |
15 | * due Qt and Templates with signal and slots | 46 | * due Qt and Templates with signal and slots |
16 | * do not work that good :( | 47 | * do not work that good :( |
17 | * (Ok how to moc a template ;) ) | 48 | * (Ok how to moc a template ;) ) |
18 | * We will have the mainwindow which calls a struct which | 49 | * We will have the mainwindow which calls a struct which |
19 | * is normally reimplemented as a template ;) | 50 | * is normally reimplemented as a template ;) |
20 | */ | 51 | */ |
21 | 52 | ||
22 | class QCopChannel; | ||
23 | class QDateTime; | ||
24 | class OPimMainWindow : public QMainWindow { | 53 | class OPimMainWindow : public QMainWindow { |
25 | Q_OBJECT | 54 | Q_OBJECT |
26 | public: | 55 | public: |
27 | enum TransPort { BlueTooth=0, | 56 | enum TransPort { BlueTooth=0, |
28 | IrDa }; | 57 | IrDa }; |
29 | 58 | ||
30 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, | 59 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, |
31 | WFlags f = WType_TopLevel); | 60 | WFlags f = WType_TopLevel); |
32 | virtual ~OPimMainWindow(); | 61 | virtual ~OPimMainWindow(); |
33 | 62 | ||
34 | 63 | ||
35 | protected slots: | 64 | protected slots: |
36 | /* | 65 | /* |
37 | * called when a setDocument | 66 | * called when a setDocument |
38 | * couldn't be handled by this window | 67 | * couldn't be handled by this window |
39 | */ | 68 | */ |
40 | virtual void doSetDocument( const QString& ); | 69 | virtual void doSetDocument( const QString& ); |
41 | /* for syncing */ | 70 | /* for syncing */ |
42 | virtual void flush() = 0; | 71 | virtual void flush() = 0; |
43 | virtual void reload() = 0; | 72 | virtual void reload() = 0; |
44 | 73 | ||
45 | /** create a new Records and return the uid */ | 74 | /** create a new Records and return the uid */ |
46 | virtual int create() = 0; | 75 | virtual int create() = 0; |
47 | /** remove a record with UID == uid */ | 76 | /** remove a record with UID == uid */ |
@@ -74,26 +103,27 @@ private slots: | |||
74 | void appMessage( const QCString&, const QByteArray& ); | 103 | void appMessage( const QCString&, const QByteArray& ); |
75 | void setDocument( const QString& ); | 104 | void setDocument( const QString& ); |
76 | 105 | ||
77 | 106 | ||
78 | private: | 107 | private: |
79 | class Private; | 108 | class Private; |
80 | Private* d; | 109 | Private* d; |
81 | 110 | ||
82 | int m_rtti; | 111 | int m_rtti; |
83 | QCopChannel* m_channel; | 112 | QCopChannel* m_channel; |
84 | QString m_service; | 113 | QString m_service; |
85 | QCString m_str; | 114 | QCString m_str; |
86 | OPimRecord* m_fallBack; | 115 | OPimRecord* m_fallBack; |
87 | int m_alarmCount; | 116 | int m_alarmCount; |
88 | int m_playedCount; | 117 | int m_playedCount; |
89 | int m_timerId; | 118 | int m_timerId; |
90 | /* I would love to do this as a template | 119 | /* I would love to do this as a template |
91 | * but can't think of a right way | 120 | * but can't think of a right way |
92 | * because I need signal and slots -zecke | 121 | * because I need signal and slots -zecke |
93 | */ | 122 | */ |
94 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; | 123 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; |
95 | int service(); | 124 | int service(); |
96 | }; | 125 | }; |
97 | 126 | ||
127 | } | ||
98 | 128 | ||
99 | #endif | 129 | #endif |
diff --git a/libopie2/opiepim/ui/ui.pro b/libopie2/opiepim/ui/ui.pro new file mode 100644 index 0000000..db19bca --- a/dev/null +++ b/libopie2/opiepim/ui/ui.pro | |||
@@ -0,0 +1,3 @@ | |||
1 | HEADERS += ui/opimmainwindow.h | ||
2 | |||
3 | SOURCES += ui/opimmainwindow.cpp | ||