-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.cpp | 36 | ||||
-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.h | 18 |
2 files changed, 49 insertions, 5 deletions
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,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/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 @@ -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& ) ; |