From 87cd421d72df1d7706925285a48c008007471310 Mon Sep 17 00:00:00 2001 From: harlekin Date: Sun, 15 Sep 2002 21:13:47 +0000 Subject: plugins for the new today --- (limited to 'core/pim/today/plugins/datebook') diff --git a/core/pim/today/plugins/datebook/datebook.pro b/core/pim/today/plugins/datebook/datebook.pro new file mode 100644 index 0000000..615059a --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebook.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib +CONFIG -= moc +CONFIG += qt debug + +# Input +HEADERS = datebookplugin.h datebookpluginimpl.h datebookpluginconfig.h \ + datebookevent.h datebookpluginwidget.h +SOURCES = datebookplugin.cpp datebookpluginimpl.cpp datebookpluginconfig.cpp \ + datebookevent.cpp datebookpluginwidget.cpp + +INCLUDEPATH += $(OPIEDIR)/include \ + ../ ../library +DEPENDPATH += $(OPIEDIR)/include \ + ../ ../library + +LIBS+= -lqpe -lopie + +DESTDIR = $(OPIEDIR)/plugins/today +TARGET = todaydatebookplugin \ No newline at end of file diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp new file mode 100644 index 0000000..1caf061 --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookevent.cpp @@ -0,0 +1,118 @@ +/* + * datebookevent.cpp + * + * copyright : (c) 2002 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "datebookevent.h" +#include +#include +#include +#include + +DateBookEvent::DateBookEvent(const EffectiveEvent &ev, + QWidget* parent, + int show_location, + int show_notes, + // int onlyLater, + int maxCharClip, + const char* name, + WFlags fl) : + OClickableLabel(parent,name,fl), event(ev) { + + QString msg; + + Config config( "qpe" ); + config.setGroup( "Time" ); + // if 24 h format + ampm = config.readBoolEntry( "AMPM", TRUE ); + + msg += "" + (ev).description() + ""; + if ( (ev).event().hasAlarm() ) { + msg += " [with alarm]"; + } + + // include location or not + if ( show_location == 1) { + msg += "
" + (ev).location() + ""; + } + + if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) + && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59") ) { + msg += "
All day"; + } else { + // start time of event + msg += "
" + ampmTime(QTime( (ev).event().start().time() ) ) + // end time of event + + " - " + ampmTime(QTime( (ev).event().end().time() ) ); + } + + // include possible note or not + if ( show_notes == 1) { + msg += "
note:" +( (ev).notes() ).mid( 0, maxCharClip ); + } + + setText( msg ); + connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); + setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); +} + + +QString DateBookEvent::ampmTime( QTime tm ) { + + QString s; + if( ampm ) { + int hour = tm.hour(); + if ( hour == 0 ) { + hour = 12; + } + if ( hour > 12 ) { + hour -= 12; + } + s.sprintf( "%2d:%02d %s", hour, tm.minute(), + (tm.hour() >= 12) ? "PM" : "AM" ); + return s; + } else { + s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); + return s; + } + +} + + +//extern QPEApplication *todayApp; + +/* + * starts the edit dialog as known from datebook + */ +void DateBookEvent::editEventSlot( const Event &e ) { + startDatebook(); + + while( !QCopChannel::isRegistered( "QPE/Datebook" ) ) qApp->processEvents(); + QCopEnvelope env( "QPE/Datebook", "editEvent(int)" ); + env << e.uid(); +} + + +/** + * launches datebook + */ +void DateBookEvent::startDatebook() { + QCopEnvelope e("QPE/System", "execute(QString)"); + e << QString("datebook"); +} + +void DateBookEvent::editMe() { + emit editEvent(event.event()); +} + diff --git a/core/pim/today/plugins/datebook/datebookevent.h b/core/pim/today/plugins/datebook/datebookevent.h new file mode 100644 index 0000000..1168f7c --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookevent.h @@ -0,0 +1,50 @@ +/* + * datebookplugin.h + * + * copyright : (c) 2002 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DATEBOOKEVENT_PLUGIN_H +#define DATEBOOKEVENT_PLUGIN_H + +#include +#include + + +class DateBookEvent: public OClickableLabel { + + Q_OBJECT + +public: + DateBookEvent(const EffectiveEvent &ev, + QWidget* parent = 0, + int show_location = 0, + int show_notes = 0, + // int onlyLater = 0, + int maxCharClip = 0, + const char* name = 0, + WFlags fl = 0); +signals: + void editEvent(const Event &e); +private slots: + void editEventSlot(const Event &e); + void editMe(); +private: + void startDatebook(); + DateBookDB *db; + QString ampmTime(QTime); + const EffectiveEvent event; + bool ampm; +}; + +#endif diff --git a/core/pim/today/plugins/datebook/datebookplugin.cpp b/core/pim/today/plugins/datebook/datebookplugin.cpp new file mode 100644 index 0000000..d2a73df --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookplugin.cpp @@ -0,0 +1,73 @@ +/* + * datebookplugin.cpp + * + * copyright : (c) 2002 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + + +#include "datebookevent.h" +#include "datebookplugin.h" +#include "datebookpluginwidget.h" +#include "datebookpluginconfig.h" + +#include "../../configwidget.h" + +#include +#include + + +DatebookPlugin::DatebookPlugin() { +} + +DatebookPlugin::~DatebookPlugin() { +} + +QString DatebookPlugin::pluginName() const { + return "Datebook plugin"; +} + +double DatebookPlugin::versionNumber() const { + return 0.1; +} + +QString DatebookPlugin::pixmapNameWidget() const { + return "DateBook"; +} + +QWidget* DatebookPlugin::widget( QWidget* wid ) { + return new DatebookPluginWidget( wid, "Datebook" ); +} + +QString DatebookPlugin::pixmapNameConfig() const { + return "DateBook"; +} + +ConfigWidget* DatebookPlugin::configWidget( QWidget* wid ) { + return new DatebookPluginConfig( wid , "Datebook" ); +} + +QString DatebookPlugin::appName() const { + return "datebook"; +} + +int DatebookPlugin::minHeight() const { + return 10; +} + +int DatebookPlugin::maxHeight() const { + return 100; +} + + + diff --git a/core/pim/today/plugins/datebook/datebookplugin.h b/core/pim/today/plugins/datebook/datebookplugin.h new file mode 100644 index 0000000..f2c4446 --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookplugin.h @@ -0,0 +1,47 @@ +/* + * datebookplugin.h + * + * copyright : (c) 2002 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DATEBOOK_PLUGIN_H +#define DATEBOOK_PLUGIN_H + +#include +#include + +#include +#include + +#include "../../todayplugininterface.h" + +class DatebookPlugin : public TodayPluginObject { + +public: + DatebookPlugin(); + ~DatebookPlugin(); + + QString pluginName() const; + double versionNumber() const; + QString pixmapNameWidget() const; + QWidget* widget( QWidget *); + QString pixmapNameConfig() const; + ConfigWidget* configWidget( QWidget *); + QString appName() const; + virtual int minHeight() const; + virtual int maxHeight() const; + +}; + + +#endif diff --git a/core/pim/today/plugins/datebook/datebookpluginconfig.cpp b/core/pim/today/plugins/datebook/datebookpluginconfig.cpp new file mode 100644 index 0000000..7482f5e --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookpluginconfig.cpp @@ -0,0 +1,82 @@ + + +#include "datebookpluginconfig.h" + + +#include + +#include +#include +#include +#include +#include + +DatebookPluginConfig::DatebookPluginConfig( QWidget* parent, const char* name) + : ConfigWidget( parent, name ) { + + QVBoxLayout * layout = new QVBoxLayout( this ); + + QHBox *box1 = new QHBox( this ); + QLabel* TextLabel4 = new QLabel( box1, "TextLabel4" ); + TextLabel4->setText( tr( "Show location" ) ); + CheckBox1 = new QCheckBox( box1, "CheckBox1" ); + + QHBox *box2 = new QHBox( this ); + QLabel* TextLabel5 = new QLabel( box2 , "TextLabel5" ); + TextLabel5->setText( tr( "Show notes" ) ); + CheckBox2 = new QCheckBox( box2, "CheckBox2" ); + + QHBox *box3 = new QHBox( this ); + QLabel* TextLabel6 = new QLabel( box3, "All Day"); + TextLabel6->setText( tr( "Show only later\n" + "appointments") ); + CheckBox3 = new QCheckBox ( box3, "CheckBox3" ); + + QHBox *box4 = new QHBox( this ); + QLabel *TextLabel3 = new QLabel( box4, "TextLabel3" ); + TextLabel3->setText( tr( "How many \nappointment\n" + "should be \nshown?" ) ); + SpinBox1 = new QSpinBox( box4, "SpinBox1" ); + SpinBox1->setMaxValue( 10 ); + SpinBox1->setValue( 5 ); + + layout->addWidget( box1 ); + layout->addWidget( box2 ); + layout->addWidget( box3 ); + layout->addWidget( box4 ); + + readConfig(); +} + +void DatebookPluginConfig::readConfig() { + Config cfg( "todaydatebookplugin" ); + cfg.setGroup( "config" ); + + m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); + SpinBox1->setValue( m_max_lines_meet ); + m_show_location = cfg.readNumEntry( "showlocation", 1 ); + CheckBox1->setChecked( m_show_location ); + m_show_notes = cfg.readNumEntry( "shownotes", 0 ); + CheckBox2->setChecked( m_show_notes ); + m_only_later = cfg.readNumEntry( "onlylater", 1 ); + CheckBox3->setChecked( m_only_later ); +} + + +void DatebookPluginConfig::writeConfig() { + Config cfg( "todaydatebookplugin" ); + cfg.setGroup( "config" ); + + m_max_lines_meet = SpinBox1->value(); + cfg.writeEntry( "maxlinesmeet", m_max_lines_meet); + m_show_location = CheckBox1->isChecked(); + cfg.writeEntry( "showlocation", m_show_location); + m_show_notes = CheckBox2->isChecked(); + cfg.writeEntry( "shownotes", m_show_notes ); + m_only_later = CheckBox3->isChecked(); + cfg.writeEntry( "onlylater", m_only_later ); + cfg.write(); +} + +DatebookPluginConfig::~DatebookPluginConfig() { +} diff --git a/core/pim/today/plugins/datebook/datebookpluginconfig.h b/core/pim/today/plugins/datebook/datebookpluginconfig.h new file mode 100644 index 0000000..33d3c4e --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookpluginconfig.h @@ -0,0 +1,48 @@ + +#ifndef DATEBOOK_PLUGIN_CONFIG_H +#define DATEBOOK_PLUGIN_CONFIG_H + +#include +#include +#include + +#include "../../configwidget.h" + +class DatebookPluginConfig : public ConfigWidget { + + Q_OBJECT + +public: + DatebookPluginConfig( QWidget *parent, const char *name ); + ~DatebookPluginConfig(); + + void writeConfig(); +private: + /** + * if changed then save + */ + bool changed(); + void readConfig(); + + QCheckBox* CheckBox2; + QCheckBox* CheckBox1; + QCheckBox* CheckBox3; + QSpinBox* SpinBox1; + + // how many lines should be showed in the datebook section + int m_max_lines_meet; + // If location is to be showed too, 1 to activate it. + int m_show_location; + // if notes should be shown + int m_show_notes; + // should only later appointments be shown or all for the current day. + int m_only_later; + + +}; + + + + + +#endif diff --git a/core/pim/today/plugins/datebook/datebookpluginimpl.cpp b/core/pim/today/plugins/datebook/datebookpluginimpl.cpp new file mode 100644 index 0000000..4159b49 --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookpluginimpl.cpp @@ -0,0 +1,42 @@ +/* + * datebookpluginimpl.cpp + * + * copyright : (c) 2002 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "datebookplugin.h" +#include "datebookpluginimpl.h" + +DatebookPluginImpl::DatebookPluginImpl() { + datebookPlugin = new DatebookPlugin(); +} + +DatebookPluginImpl::~DatebookPluginImpl() { +} + +TodayPluginObject* DatebookPluginImpl::guiPart() { + return datebookPlugin; +} + +QRESULT DatebookPluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) { + *iface = 0; + if ( ( uuid == IID_QUnknown ) || ( uuid == IID_TodayPluginInterface ) ) { + *iface = this, (*iface)->addRef(); + } + return QS_OK; + +} + +Q_EXPORT_INTERFACE() { + Q_CREATE_INSTANCE( DatebookPluginImpl ); +} diff --git a/core/pim/today/plugins/datebook/datebookpluginimpl.h b/core/pim/today/plugins/datebook/datebookpluginimpl.h new file mode 100644 index 0000000..037dff4 --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookpluginimpl.h @@ -0,0 +1,42 @@ +/* + * datebookpluginimpl.h + * + * copyright : (c) 2002 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DATEBOOK_PLUGIN_IMPL_H +#define DATEBOOK_PLUGIN_IMPL_H + +#include "../../todayplugininterface.h" + +class DatebookPlugin; + +class DatebookPluginImpl : public TodayPluginInterface{ + +public: + DatebookPluginImpl(); + virtual ~DatebookPluginImpl(); + + QRESULT queryInterface( const QUuid &, QUnknownInterface** ); + Q_REFCOUNT + + virtual TodayPluginObject *guiPart(); + +private: + DatebookPlugin *datebookPlugin; + ulong ref; + + +}; + +#endif diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp new file mode 100644 index 0000000..e4667ae --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp @@ -0,0 +1,114 @@ +/* + * datebookpluginwidget.cpp + * + * copyright : (c) 2002 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include "datebookpluginwidget.h" +#include "datebookevent.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) + : QWidget(parent, name ) { + db = 0l; + readConfig(); + getDates(); +} + +DatebookPluginWidget::~DatebookPluginWidget() { + delete db; +} + + +void DatebookPluginWidget::readConfig() { + Config cfg( "todaydatebookplugin" ); + cfg.setGroup( "config" ); + m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); + m_show_location = cfg.readNumEntry( "showlocation", 1 ); + m_show_notes = cfg.readNumEntry( "shownotes", 0 ); + m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); +} + + +/** + * Get all events that are in the datebook xml file for today + */ +void DatebookPluginWidget::getDates() { + + + QDate date = QDate::currentDate(); + + QVBoxLayout* layoutDates = new QVBoxLayout( this ); + + if ( db ) { + delete db; + } + + db = new DateBookDB; + + QValueList list = db->getEffectiveEvents( date, date ); + + qBubbleSort( list ); + + Config config( "qpe" ); + + int count=0; + + if ( list.count() > 0 ) { + + for ( QValueList::ConstIterator it=list.begin(); it!=list.end(); ++it ) { + + if ( count <= m_max_lines_meet ) { + QTime time = QTime::currentTime(); + + if ( !m_onlyLater ) { + count++; + DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); + layoutDates->addWidget( l ); + QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); + } else if ( ( time.toString() <= TimeString::dateString( (*it).event().end() ) ) ) { + count++; + // show only later appointments + DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); + layoutDates->addWidget( l ); + QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); + } + } + } + if ( m_onlyLater && count == 0 ) { + QLabel* noMoreEvents = new QLabel( this ); + noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); + layoutDates->addWidget( noMoreEvents ); + } + } else { + QLabel* noEvents = new QLabel( this ); + noEvents->setText( QObject::tr( "No appointments today" ) ); + layoutDates->addWidget( noEvents ); + } + + layoutDates->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); + + // how often refresh - later have qcop update calls in *db + //QTimer::singleShot( 20*1000, this , SLOT( getDates() ) ); +} + diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.h b/core/pim/today/plugins/datebook/datebookpluginwidget.h new file mode 100644 index 0000000..e0213ec --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.h @@ -0,0 +1,52 @@ +/* + * datebookpluginwidget.h + * + * copyright : (c) 2002 by Maximilian Reiß + * email : harlekin@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DATEBOOK_PLUGIN_WIDGET_H +#define DATEBOOK_PLUGIN_WIDGET_H + +#include +#include + +#include +#include + + +class DatebookPluginWidget : public QWidget { + + Q_OBJECT + +public: + DatebookPluginWidget( QWidget *parent, const char *name ); + ~DatebookPluginWidget(); + + +private: + DateBookDB* db; + void readConfig(); + void getDates(); + + // how many lines should be showed in the datebook section + int m_max_lines_meet; + // If location is to be showed too, 1 to activate it. + int m_show_location; + // if notes should be shown + int m_show_notes; + // should only later appointments be shown or all for the current day. + int m_onlyLater; + +}; + +#endif diff --git a/core/pim/today/plugins/datebook/opie-today-datebookplugin.control b/core/pim/today/plugins/datebook/opie-today-datebookplugin.control new file mode 100644 index 0000000..3ee523b --- a/dev/null +++ b/core/pim/today/plugins/datebook/opie-today-datebookplugin.control @@ -0,0 +1,8 @@ +Files: $OPIEDIR/lib/today/libtodaydatebookplugin.so* +Priority: optional +Section: opie/applications +Maintainer: Maximilian Reiss +Architecture: arm +Version: $QPE_VERSION-$SUB_VERSION +Depends: qt-embedded (>=$QTE_VERSION) +Description: Datebook plugin for today -- cgit v0.9.0.2