-rw-r--r-- | libopie/pim/opimmainwindow.cpp | 36 | ||||
-rw-r--r-- | libopie/pim/opimmainwindow.h | 18 | ||||
-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.cpp | 36 | ||||
-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.h | 18 |
4 files changed, 98 insertions, 10 deletions
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp index d1eec19..4044bc1 100644 --- a/libopie/pim/opimmainwindow.cpp +++ b/libopie/pim/opimmainwindow.cpp | |||
@@ -1,104 +1,138 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qdatetime.h> | ||
2 | #include <qcopchannel_qws.h> | 3 | #include <qcopchannel_qws.h> |
3 | 4 | ||
5 | #include <qpe/sound.h> | ||
4 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
5 | 7 | ||
6 | #include "opimresolver.h" | 8 | #include "opimresolver.h" |
7 | #include "opimmainwindow.h" | 9 | #include "opimmainwindow.h" |
8 | 10 | ||
9 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, | 11 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, |
10 | const char* name, WFlags flag ) | 12 | const char* name, WFlags flag ) |
11 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { | 13 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { |
12 | 14 | ||
13 | /* | 15 | /* |
14 | * let's generate our QCopChannel | 16 | * let's generate our QCopChannel |
15 | */ | 17 | */ |
16 | m_str = QString("QPE/"+m_service).local8Bit(); | 18 | m_str = QString("QPE/"+m_service).local8Bit(); |
17 | m_channel= new QCopChannel(m_str, this ); | 19 | m_channel= new QCopChannel(m_str, this ); |
18 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), | 20 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), |
19 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 21 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); |
22 | connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), | ||
23 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | ||
20 | 24 | ||
21 | /* connect flush and reload */ | 25 | /* connect flush and reload */ |
22 | connect(qApp, SIGNAL(flush() ), | 26 | connect(qApp, SIGNAL(flush() ), |
23 | this, SLOT(flush() ) ); | 27 | this, SLOT(flush() ) ); |
24 | connect(qApp, SIGNAL(reload() ), | 28 | connect(qApp, SIGNAL(reload() ), |
25 | this, SLOT(reload() ) ); | 29 | this, SLOT(reload() ) ); |
26 | } | 30 | } |
27 | OPimMainWindow::~OPimMainWindow() { | 31 | OPimMainWindow::~OPimMainWindow() { |
28 | delete m_channel; | 32 | delete m_channel; |
29 | } | 33 | } |
30 | QCopChannel* OPimMainWindow::channel() { | 34 | QCopChannel* OPimMainWindow::channel() { |
31 | return m_channel; | 35 | return m_channel; |
32 | } | 36 | } |
33 | void OPimMainWindow::doSetDocument( const QString& ) { | 37 | void OPimMainWindow::doSetDocument( const QString& ) { |
34 | 38 | ||
35 | } | 39 | } |
36 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { | 40 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { |
37 | /* | 41 | /* |
38 | * create demands to create | 42 | * create demands to create |
39 | * a new record... | 43 | * a new record... |
40 | */ | 44 | */ |
41 | QDataStream stream(array, IO_ReadOnly); | 45 | QDataStream stream(array, IO_ReadOnly); |
42 | if ( cmd == "create()" ) { | 46 | if ( cmd == "create()" ) { |
43 | int uid = create(); | 47 | int uid = create(); |
44 | QCopEnvelope e(m_str, "created(int)" ); | 48 | QCopEnvelope e(m_str, "created(int)" ); |
45 | e << uid; | 49 | e << uid; |
46 | }else if ( cmd == "remove(int)" ) { | 50 | }else if ( cmd == "remove(int)" ) { |
47 | int uid; | 51 | int uid; |
48 | stream >> uid; | 52 | stream >> uid; |
49 | bool rem = remove( uid ); | 53 | bool rem = remove( uid ); |
50 | QCopEnvelope e(m_str, "removed(bool)" ); | 54 | QCopEnvelope e(m_str, "removed(bool)" ); |
51 | e << rem; | 55 | e << rem; |
52 | }else if ( cmd == "beam(int)" ) { | 56 | }else if ( cmd == "beam(int)" ) { |
53 | int uid, trans; | 57 | int uid; |
54 | stream >> uid; | 58 | stream >> uid; |
55 | beam( uid); | 59 | beam( uid); |
56 | }else if ( cmd == "show(int)" ) { | 60 | }else if ( cmd == "show(int)" ) { |
57 | int uid; | 61 | int uid; |
58 | stream >> uid; | 62 | stream >> uid; |
59 | show( uid ); | 63 | show( uid ); |
60 | }else if ( cmd == "edit(int)" ) { | 64 | }else if ( cmd == "edit(int)" ) { |
61 | int uid; | 65 | int uid; |
62 | stream >> uid; | 66 | stream >> uid; |
63 | edit( uid ); | 67 | edit( uid ); |
64 | }else if ( cmd == "add(int,QByteArray)" ) { | 68 | }else if ( cmd == "add(int,QByteArray)" ) { |
65 | int rtti; | 69 | int rtti; |
66 | QByteArray array; | 70 | QByteArray array; |
67 | stream >> rtti; | 71 | stream >> rtti; |
68 | stream >> array; | 72 | stream >> array; |
69 | m_fallBack = record(rtti, array ); | 73 | m_fallBack = record(rtti, array ); |
70 | if (!m_fallBack) return; | 74 | if (!m_fallBack) return; |
71 | add( *m_fallBack ); | 75 | add( *m_fallBack ); |
72 | delete m_fallBack; | 76 | delete m_fallBack; |
77 | }else if ( cmd == "alarm(QDateTime,int)" ) { | ||
78 | QDateTime dt; int uid; | ||
79 | stream >> dt; | ||
80 | stream >> uid; | ||
81 | qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); | ||
82 | QDateTime current = QDateTime::currentDateTime(); | ||
83 | if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) | ||
84 | return; | ||
85 | doAlarm( dt, uid ); | ||
86 | |||
73 | } | 87 | } |
74 | } | 88 | } |
75 | /* implement the url scripting here */ | 89 | /* implement the url scripting here */ |
76 | void OPimMainWindow::setDocument( const QString& str) { | 90 | void OPimMainWindow::setDocument( const QString& str) { |
77 | doSetDocument( str ); | 91 | doSetDocument( str ); |
78 | } | 92 | } |
79 | /* | 93 | /* |
80 | * we now try to get the array demarshalled | 94 | * we now try to get the array demarshalled |
81 | * check if the rtti matches this one | 95 | * check if the rtti matches this one |
82 | */ | 96 | */ |
83 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { | 97 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { |
84 | if ( service() != rtti ) | 98 | if ( service() != rtti ) |
85 | return 0l; | 99 | return 0l; |
86 | 100 | ||
87 | OPimRecord* record = OPimResolver::self()->record( rtti ); | 101 | OPimRecord* record = OPimResolver::self()->record( rtti ); |
88 | QDataStream str(array, IO_ReadOnly ); | 102 | QDataStream str(array, IO_ReadOnly ); |
89 | if ( !record || !record->loadFromStream(str) ) { | 103 | if ( !record || !record->loadFromStream(str) ) { |
90 | delete record; | 104 | delete record; |
91 | record = 0l; | 105 | record = 0l; |
92 | } | 106 | } |
93 | 107 | ||
94 | return record; | 108 | return record; |
95 | } | 109 | } |
96 | /* | 110 | /* |
97 | * get the rtti for the service | 111 | * get the rtti for the service |
98 | */ | 112 | */ |
99 | int OPimMainWindow::service() { | 113 | int OPimMainWindow::service() { |
100 | if ( m_rtti == -1 ) | 114 | if ( m_rtti == -1 ) |
101 | m_rtti = OPimResolver::self()->serviceId( m_service ); | 115 | m_rtti = OPimResolver::self()->serviceId( m_service ); |
102 | 116 | ||
103 | return m_rtti; | 117 | return m_rtti; |
104 | } | 118 | } |
119 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { | ||
120 | |||
121 | } | ||
122 | void OPimMainWindow::startAlarm(int count ) { | ||
123 | m_alarmCount = count; | ||
124 | m_playedCount = 0; | ||
125 | Sound::soundAlarm(); | ||
126 | m_timerId = startTimer( 5000 ); | ||
127 | } | ||
128 | void OPimMainWindow::killAlarm() { | ||
129 | killTimer( m_timerId ); | ||
130 | } | ||
131 | void OPimMainWindow::timerEvent( QTimerEvent* e) { | ||
132 | if ( m_playedCount <m_alarmCount ) { | ||
133 | m_playedCount++; | ||
134 | Sound::soundAlarm(); | ||
135 | }else { | ||
136 | killTimer( e->timerId() ); | ||
137 | } | ||
138 | } | ||
diff --git a/libopie/pim/opimmainwindow.h b/libopie/pim/opimmainwindow.h index dca3c82..855d364 100644 --- a/libopie/pim/opimmainwindow.h +++ b/libopie/pim/opimmainwindow.h | |||
@@ -1,89 +1,99 @@ | |||
1 | #ifndef OPIE_PIM_MAINWINDOW_H | 1 | #ifndef OPIE_PIM_MAINWINDOW_H |
2 | #define OPIE_PIM_MAINWINDOW_H | 2 | #define OPIE_PIM_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * This is a common Opie PIM MainWindow | 9 | * This is a common Opie PIM MainWindow |
10 | * it takes care of the QCOP internals | 10 | * it takes care of the QCOP internals |
11 | * and implements some functions | 11 | * and implements some functions |
12 | * for the URL scripting schema | 12 | * for the URL scripting schema |
13 | */ | 13 | */ |
14 | /* | 14 | /* |
15 | * due Qt and Templates with signal and slots | 15 | * due Qt and Templates with signal and slots |
16 | * do not work that good :( | 16 | * do not work that good :( |
17 | * (Ok how to moc a template ;) ) | 17 | * (Ok how to moc a template ;) ) |
18 | * We will have the mainwindow which calls a struct which | 18 | * We will have the mainwindow which calls a struct which |
19 | * is normally reimplemented as a template ;) | 19 | * is normally reimplemented as a template ;) |
20 | */ | 20 | */ |
21 | 21 | ||
22 | class QCopChannel; | 22 | class QCopChannel; |
23 | class QDateTime; | ||
23 | class OPimMainWindow : public QMainWindow { | 24 | class OPimMainWindow : public QMainWindow { |
24 | Q_OBJECT | 25 | Q_OBJECT |
25 | public: | 26 | public: |
26 | enum TransPort { BlueTooth=0, | 27 | enum TransPort { BlueTooth=0, |
27 | IrDa }; | 28 | IrDa }; |
28 | 29 | ||
29 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, | 30 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, |
30 | WFlags f = WType_TopLevel); | 31 | WFlags f = WType_TopLevel); |
31 | virtual ~OPimMainWindow(); | 32 | virtual ~OPimMainWindow(); |
32 | 33 | ||
33 | 34 | ||
34 | protected slots: | 35 | protected slots: |
35 | /* | 36 | /* |
36 | * called when a setDocument | 37 | * called when a setDocument |
37 | * couldn't be handled by this window | 38 | * couldn't be handled by this window |
38 | */ | 39 | */ |
39 | virtual void doSetDocument( const QString& ); | 40 | virtual void doSetDocument( const QString& ); |
40 | /* for syncing */ | 41 | /* for syncing */ |
41 | virtual void flush() = 0; | 42 | virtual void flush() = 0; |
42 | virtual void reload() = 0; | 43 | virtual void reload() = 0; |
43 | 44 | ||
44 | /** create a new Records and return the uid */ | 45 | /** create a new Records and return the uid */ |
45 | virtual int create() = 0; | 46 | virtual int create() = 0; |
46 | /** remove a record with UID == uid */ | 47 | /** remove a record with UID == uid */ |
47 | virtual bool remove( int uid ) = 0; | 48 | virtual bool remove( int uid ) = 0; |
48 | /** beam the record with UID = uid */ | 49 | /** beam the record with UID = uid */ |
49 | virtual void beam( int uid ) = 0; | 50 | virtual void beam( int uid ) = 0; |
50 | 51 | ||
51 | /** show the record with UID == uid */ | 52 | /** show the record with UID == uid */ |
52 | virtual void show( int uid ) = 0; | 53 | virtual void show( int uid ) = 0; |
53 | /** edit the record */ | 54 | /** edit the record */ |
54 | virtual void edit( int uid ) = 0; | 55 | virtual void edit( int uid ) = 0; |
55 | 56 | ||
56 | /** make a copy of it! */ | 57 | /** make a copy of it! */ |
57 | virtual void add( const OPimRecord& ) = 0; | 58 | virtual void add( const OPimRecord& ) = 0; |
58 | 59 | ||
60 | virtual void doAlarm( const QDateTime&, int uid ); | ||
59 | 61 | ||
60 | QCopChannel* channel(); | 62 | QCopChannel* channel(); |
61 | 63 | ||
64 | protected: | ||
65 | /** | ||
66 | * start to play soundAlarm() | ||
67 | * @param count How many times the alarm is played | ||
68 | */ | ||
69 | void startAlarm(int count = 10); | ||
70 | void killAlarm(); | ||
71 | void timerEvent( QTimerEvent* ); | ||
72 | |||
62 | private slots: | 73 | private slots: |
63 | void appMessage( const QCString&, const QByteArray& ); | 74 | void appMessage( const QCString&, const QByteArray& ); |
64 | void setDocument( const QString& ); | 75 | void setDocument( const QString& ); |
65 | 76 | ||
66 | 77 | ||
67 | private: | 78 | private: |
68 | class Private; | 79 | class Private; |
69 | Private* d; | 80 | Private* d; |
70 | 81 | ||
71 | int m_rtti; | 82 | int m_rtti; |
72 | QCopChannel* m_channel; | 83 | QCopChannel* m_channel; |
73 | QString m_service; | 84 | QString m_service; |
74 | QCString m_str; | 85 | QCString m_str; |
75 | OPimRecord* m_fallBack; | 86 | OPimRecord* m_fallBack; |
76 | 87 | int m_alarmCount; | |
88 | int m_playedCount; | ||
89 | int m_timerId; | ||
77 | /* I would love to do this as a template | 90 | /* I would love to do this as a template |
78 | * but can't think of a right way | 91 | * but can't think of a right way |
79 | * because I need signal and slots -zecke | 92 | * because I need signal and slots -zecke |
80 | */ | 93 | */ |
81 | /* | ||
82 | * the only pointer in the whole PIM API :( | ||
83 | */ | ||
84 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; | 94 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; |
85 | int service(); | 95 | int service(); |
86 | }; | 96 | }; |
87 | 97 | ||
88 | 98 | ||
89 | #endif | 99 | #endif |
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp index d1eec19..4044bc1 100644 --- a/libopie2/opiepim/ui/opimmainwindow.cpp +++ b/libopie2/opiepim/ui/opimmainwindow.cpp | |||
@@ -1,104 +1,138 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qdatetime.h> | ||
2 | #include <qcopchannel_qws.h> | 3 | #include <qcopchannel_qws.h> |
3 | 4 | ||
5 | #include <qpe/sound.h> | ||
4 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
5 | 7 | ||
6 | #include "opimresolver.h" | 8 | #include "opimresolver.h" |
7 | #include "opimmainwindow.h" | 9 | #include "opimmainwindow.h" |
8 | 10 | ||
9 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, | 11 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, |
10 | const char* name, WFlags flag ) | 12 | const char* name, WFlags flag ) |
11 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { | 13 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { |
12 | 14 | ||
13 | /* | 15 | /* |
14 | * let's generate our QCopChannel | 16 | * let's generate our QCopChannel |
15 | */ | 17 | */ |
16 | m_str = QString("QPE/"+m_service).local8Bit(); | 18 | m_str = QString("QPE/"+m_service).local8Bit(); |
17 | m_channel= new QCopChannel(m_str, this ); | 19 | m_channel= new QCopChannel(m_str, this ); |
18 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), | 20 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), |
19 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 21 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); |
22 | connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), | ||
23 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | ||
20 | 24 | ||
21 | /* connect flush and reload */ | 25 | /* connect flush and reload */ |
22 | connect(qApp, SIGNAL(flush() ), | 26 | connect(qApp, SIGNAL(flush() ), |
23 | this, SLOT(flush() ) ); | 27 | this, SLOT(flush() ) ); |
24 | connect(qApp, SIGNAL(reload() ), | 28 | connect(qApp, SIGNAL(reload() ), |
25 | this, SLOT(reload() ) ); | 29 | this, SLOT(reload() ) ); |
26 | } | 30 | } |
27 | OPimMainWindow::~OPimMainWindow() { | 31 | OPimMainWindow::~OPimMainWindow() { |
28 | delete m_channel; | 32 | delete m_channel; |
29 | } | 33 | } |
30 | QCopChannel* OPimMainWindow::channel() { | 34 | QCopChannel* OPimMainWindow::channel() { |
31 | return m_channel; | 35 | return m_channel; |
32 | } | 36 | } |
33 | void OPimMainWindow::doSetDocument( const QString& ) { | 37 | void OPimMainWindow::doSetDocument( const QString& ) { |
34 | 38 | ||
35 | } | 39 | } |
36 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { | 40 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { |
37 | /* | 41 | /* |
38 | * create demands to create | 42 | * create demands to create |
39 | * a new record... | 43 | * a new record... |
40 | */ | 44 | */ |
41 | QDataStream stream(array, IO_ReadOnly); | 45 | QDataStream stream(array, IO_ReadOnly); |
42 | if ( cmd == "create()" ) { | 46 | if ( cmd == "create()" ) { |
43 | int uid = create(); | 47 | int uid = create(); |
44 | QCopEnvelope e(m_str, "created(int)" ); | 48 | QCopEnvelope e(m_str, "created(int)" ); |
45 | e << uid; | 49 | e << uid; |
46 | }else if ( cmd == "remove(int)" ) { | 50 | }else if ( cmd == "remove(int)" ) { |
47 | int uid; | 51 | int uid; |
48 | stream >> uid; | 52 | stream >> uid; |
49 | bool rem = remove( uid ); | 53 | bool rem = remove( uid ); |
50 | QCopEnvelope e(m_str, "removed(bool)" ); | 54 | QCopEnvelope e(m_str, "removed(bool)" ); |
51 | e << rem; | 55 | e << rem; |
52 | }else if ( cmd == "beam(int)" ) { | 56 | }else if ( cmd == "beam(int)" ) { |
53 | int uid, trans; | 57 | int uid; |
54 | stream >> uid; | 58 | stream >> uid; |
55 | beam( uid); | 59 | beam( uid); |
56 | }else if ( cmd == "show(int)" ) { | 60 | }else if ( cmd == "show(int)" ) { |
57 | int uid; | 61 | int uid; |
58 | stream >> uid; | 62 | stream >> uid; |
59 | show( uid ); | 63 | show( uid ); |
60 | }else if ( cmd == "edit(int)" ) { | 64 | }else if ( cmd == "edit(int)" ) { |
61 | int uid; | 65 | int uid; |
62 | stream >> uid; | 66 | stream >> uid; |
63 | edit( uid ); | 67 | edit( uid ); |
64 | }else if ( cmd == "add(int,QByteArray)" ) { | 68 | }else if ( cmd == "add(int,QByteArray)" ) { |
65 | int rtti; | 69 | int rtti; |
66 | QByteArray array; | 70 | QByteArray array; |
67 | stream >> rtti; | 71 | stream >> rtti; |
68 | stream >> array; | 72 | stream >> array; |
69 | m_fallBack = record(rtti, array ); | 73 | m_fallBack = record(rtti, array ); |
70 | if (!m_fallBack) return; | 74 | if (!m_fallBack) return; |
71 | add( *m_fallBack ); | 75 | add( *m_fallBack ); |
72 | delete m_fallBack; | 76 | delete m_fallBack; |
77 | }else if ( cmd == "alarm(QDateTime,int)" ) { | ||
78 | QDateTime dt; int uid; | ||
79 | stream >> dt; | ||
80 | stream >> uid; | ||
81 | qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); | ||
82 | QDateTime current = QDateTime::currentDateTime(); | ||
83 | if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) | ||
84 | return; | ||
85 | doAlarm( dt, uid ); | ||
86 | |||
73 | } | 87 | } |
74 | } | 88 | } |
75 | /* implement the url scripting here */ | 89 | /* implement the url scripting here */ |
76 | void OPimMainWindow::setDocument( const QString& str) { | 90 | void OPimMainWindow::setDocument( const QString& str) { |
77 | doSetDocument( str ); | 91 | doSetDocument( str ); |
78 | } | 92 | } |
79 | /* | 93 | /* |
80 | * we now try to get the array demarshalled | 94 | * we now try to get the array demarshalled |
81 | * check if the rtti matches this one | 95 | * check if the rtti matches this one |
82 | */ | 96 | */ |
83 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { | 97 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { |
84 | if ( service() != rtti ) | 98 | if ( service() != rtti ) |
85 | return 0l; | 99 | return 0l; |
86 | 100 | ||
87 | OPimRecord* record = OPimResolver::self()->record( rtti ); | 101 | OPimRecord* record = OPimResolver::self()->record( rtti ); |
88 | QDataStream str(array, IO_ReadOnly ); | 102 | QDataStream str(array, IO_ReadOnly ); |
89 | if ( !record || !record->loadFromStream(str) ) { | 103 | if ( !record || !record->loadFromStream(str) ) { |
90 | delete record; | 104 | delete record; |
91 | record = 0l; | 105 | record = 0l; |
92 | } | 106 | } |
93 | 107 | ||
94 | return record; | 108 | return record; |
95 | } | 109 | } |
96 | /* | 110 | /* |
97 | * get the rtti for the service | 111 | * get the rtti for the service |
98 | */ | 112 | */ |
99 | int OPimMainWindow::service() { | 113 | int OPimMainWindow::service() { |
100 | if ( m_rtti == -1 ) | 114 | if ( m_rtti == -1 ) |
101 | m_rtti = OPimResolver::self()->serviceId( m_service ); | 115 | m_rtti = OPimResolver::self()->serviceId( m_service ); |
102 | 116 | ||
103 | return m_rtti; | 117 | return m_rtti; |
104 | } | 118 | } |
119 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { | ||
120 | |||
121 | } | ||
122 | void OPimMainWindow::startAlarm(int count ) { | ||
123 | m_alarmCount = count; | ||
124 | m_playedCount = 0; | ||
125 | Sound::soundAlarm(); | ||
126 | m_timerId = startTimer( 5000 ); | ||
127 | } | ||
128 | void OPimMainWindow::killAlarm() { | ||
129 | killTimer( m_timerId ); | ||
130 | } | ||
131 | void OPimMainWindow::timerEvent( QTimerEvent* e) { | ||
132 | if ( m_playedCount <m_alarmCount ) { | ||
133 | m_playedCount++; | ||
134 | Sound::soundAlarm(); | ||
135 | }else { | ||
136 | killTimer( e->timerId() ); | ||
137 | } | ||
138 | } | ||
diff --git a/libopie2/opiepim/ui/opimmainwindow.h b/libopie2/opiepim/ui/opimmainwindow.h index dca3c82..855d364 100644 --- a/libopie2/opiepim/ui/opimmainwindow.h +++ b/libopie2/opiepim/ui/opimmainwindow.h | |||
@@ -1,89 +1,99 @@ | |||
1 | #ifndef OPIE_PIM_MAINWINDOW_H | 1 | #ifndef OPIE_PIM_MAINWINDOW_H |
2 | #define OPIE_PIM_MAINWINDOW_H | 2 | #define OPIE_PIM_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * This is a common Opie PIM MainWindow | 9 | * This is a common Opie PIM MainWindow |
10 | * it takes care of the QCOP internals | 10 | * it takes care of the QCOP internals |
11 | * and implements some functions | 11 | * and implements some functions |
12 | * for the URL scripting schema | 12 | * for the URL scripting schema |
13 | */ | 13 | */ |
14 | /* | 14 | /* |
15 | * due Qt and Templates with signal and slots | 15 | * due Qt and Templates with signal and slots |
16 | * do not work that good :( | 16 | * do not work that good :( |
17 | * (Ok how to moc a template ;) ) | 17 | * (Ok how to moc a template ;) ) |
18 | * We will have the mainwindow which calls a struct which | 18 | * We will have the mainwindow which calls a struct which |
19 | * is normally reimplemented as a template ;) | 19 | * is normally reimplemented as a template ;) |
20 | */ | 20 | */ |
21 | 21 | ||
22 | class QCopChannel; | 22 | class QCopChannel; |
23 | class QDateTime; | ||
23 | class OPimMainWindow : public QMainWindow { | 24 | class OPimMainWindow : public QMainWindow { |
24 | Q_OBJECT | 25 | Q_OBJECT |
25 | public: | 26 | public: |
26 | enum TransPort { BlueTooth=0, | 27 | enum TransPort { BlueTooth=0, |
27 | IrDa }; | 28 | IrDa }; |
28 | 29 | ||
29 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, | 30 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, |
30 | WFlags f = WType_TopLevel); | 31 | WFlags f = WType_TopLevel); |
31 | virtual ~OPimMainWindow(); | 32 | virtual ~OPimMainWindow(); |
32 | 33 | ||
33 | 34 | ||
34 | protected slots: | 35 | protected slots: |
35 | /* | 36 | /* |
36 | * called when a setDocument | 37 | * called when a setDocument |
37 | * couldn't be handled by this window | 38 | * couldn't be handled by this window |
38 | */ | 39 | */ |
39 | virtual void doSetDocument( const QString& ); | 40 | virtual void doSetDocument( const QString& ); |
40 | /* for syncing */ | 41 | /* for syncing */ |
41 | virtual void flush() = 0; | 42 | virtual void flush() = 0; |
42 | virtual void reload() = 0; | 43 | virtual void reload() = 0; |
43 | 44 | ||
44 | /** create a new Records and return the uid */ | 45 | /** create a new Records and return the uid */ |
45 | virtual int create() = 0; | 46 | virtual int create() = 0; |
46 | /** remove a record with UID == uid */ | 47 | /** remove a record with UID == uid */ |
47 | virtual bool remove( int uid ) = 0; | 48 | virtual bool remove( int uid ) = 0; |
48 | /** beam the record with UID = uid */ | 49 | /** beam the record with UID = uid */ |
49 | virtual void beam( int uid ) = 0; | 50 | virtual void beam( int uid ) = 0; |
50 | 51 | ||
51 | /** show the record with UID == uid */ | 52 | /** show the record with UID == uid */ |
52 | virtual void show( int uid ) = 0; | 53 | virtual void show( int uid ) = 0; |
53 | /** edit the record */ | 54 | /** edit the record */ |
54 | virtual void edit( int uid ) = 0; | 55 | virtual void edit( int uid ) = 0; |
55 | 56 | ||
56 | /** make a copy of it! */ | 57 | /** make a copy of it! */ |
57 | virtual void add( const OPimRecord& ) = 0; | 58 | virtual void add( const OPimRecord& ) = 0; |
58 | 59 | ||
60 | virtual void doAlarm( const QDateTime&, int uid ); | ||
59 | 61 | ||
60 | QCopChannel* channel(); | 62 | QCopChannel* channel(); |
61 | 63 | ||
64 | protected: | ||
65 | /** | ||
66 | * start to play soundAlarm() | ||
67 | * @param count How many times the alarm is played | ||
68 | */ | ||
69 | void startAlarm(int count = 10); | ||
70 | void killAlarm(); | ||
71 | void timerEvent( QTimerEvent* ); | ||
72 | |||
62 | private slots: | 73 | private slots: |
63 | void appMessage( const QCString&, const QByteArray& ); | 74 | void appMessage( const QCString&, const QByteArray& ); |
64 | void setDocument( const QString& ); | 75 | void setDocument( const QString& ); |
65 | 76 | ||
66 | 77 | ||
67 | private: | 78 | private: |
68 | class Private; | 79 | class Private; |
69 | Private* d; | 80 | Private* d; |
70 | 81 | ||
71 | int m_rtti; | 82 | int m_rtti; |
72 | QCopChannel* m_channel; | 83 | QCopChannel* m_channel; |
73 | QString m_service; | 84 | QString m_service; |
74 | QCString m_str; | 85 | QCString m_str; |
75 | OPimRecord* m_fallBack; | 86 | OPimRecord* m_fallBack; |
76 | 87 | int m_alarmCount; | |
88 | int m_playedCount; | ||
89 | int m_timerId; | ||
77 | /* I would love to do this as a template | 90 | /* I would love to do this as a template |
78 | * but can't think of a right way | 91 | * but can't think of a right way |
79 | * because I need signal and slots -zecke | 92 | * because I need signal and slots -zecke |
80 | */ | 93 | */ |
81 | /* | ||
82 | * the only pointer in the whole PIM API :( | ||
83 | */ | ||
84 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; | 94 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; |
85 | int service(); | 95 | int service(); |
86 | }; | 96 | }; |
87 | 97 | ||
88 | 98 | ||
89 | #endif | 99 | #endif |