author | zecke <zecke> | 2003-05-12 13:17:48 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-05-12 13:17:48 (UTC) |
commit | d6e4c1a54185b1aa4443cb79a36acc637acf84ac (patch) (side-by-side diff) | |
tree | bff7f62a0a06cbcd3d1492b37c297e9133dacff4 /libopie | |
parent | abfe4c66be60075a518d4918d603bb8033bc5ac4 (diff) | |
download | opie-d6e4c1a54185b1aa4443cb79a36acc637acf84ac.zip opie-d6e4c1a54185b1aa4443cb79a36acc637acf84ac.tar.gz opie-d6e4c1a54185b1aa4443cb79a36acc637acf84ac.tar.bz2 |
Add handling of alarm() message
play and killAlarm... added as well
-rw-r--r-- | libopie/pim/opimmainwindow.cpp | 36 | ||||
-rw-r--r-- | libopie/pim/opimmainwindow.h | 18 |
2 files changed, 49 insertions, 5 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,4 +1,6 @@ #include <qapplication.h> +#include <qdatetime.h> #include <qcopchannel_qws.h> +#include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> @@ -19,2 +21,4 @@ OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); + connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), + this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); @@ -52,3 +56,3 @@ void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) }else if ( cmd == "beam(int)" ) { - int uid, trans; + int uid; stream >> uid; @@ -72,2 +76,12 @@ void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) delete m_fallBack; + }else if ( cmd == "alarm(QDateTime,int)" ) { + QDateTime dt; int uid; + stream >> dt; + stream >> uid; + qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); + QDateTime current = QDateTime::currentDateTime(); + if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) + return; + doAlarm( dt, uid ); + } @@ -104 +118,21 @@ int OPimMainWindow::service() { } +void OPimMainWindow::doAlarm( const QDateTime&, int ) { + +} +void OPimMainWindow::startAlarm(int count ) { + m_alarmCount = count; + m_playedCount = 0; + Sound::soundAlarm(); + m_timerId = startTimer( 5000 ); +} +void OPimMainWindow::killAlarm() { + killTimer( m_timerId ); +} +void OPimMainWindow::timerEvent( QTimerEvent* e) { + if ( m_playedCount <m_alarmCount ) { + m_playedCount++; + Sound::soundAlarm(); + }else { + killTimer( e->timerId() ); + } +} 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 @@ -22,2 +22,3 @@ class QCopChannel; +class QDateTime; class OPimMainWindow : public QMainWindow { @@ -58,2 +59,3 @@ protected slots: + virtual void doAlarm( const QDateTime&, int uid ); @@ -61,2 +63,11 @@ protected slots: +protected: + /** + * start to play soundAlarm() + * @param count How many times the alarm is played + */ + void startAlarm(int count = 10); + void killAlarm(); + void timerEvent( QTimerEvent* ); + private slots: @@ -75,3 +86,5 @@ private: OPimRecord* m_fallBack; - + int m_alarmCount; + int m_playedCount; + int m_timerId; /* I would love to do this as a template @@ -80,5 +93,2 @@ private: */ - /* - * the only pointer in the whole PIM API :( - */ virtual OPimRecord* record( int rtti, const QByteArray& ) ; |