00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "datebookevent.h"
00018
00019 #include <qpe/config.h>
00020 #include <qpe/qcopenvelope_qws.h>
00021 #include <qpe/calendar.h>
00022
00023 #include <opie2/odevice.h>
00024
00025 using namespace Opie::Ui;
00026 using namespace Opie::Core;
00027
00028 DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
00029 QWidget* parent,
00030 bool show_location,
00031 bool show_notes,
00032 bool timeExtraLine,
00033 int maxCharClip,
00034 const char* name,
00035 WFlags fl) :
00036 OClickableLabel(parent,name,fl), event(ev) {
00037
00038
00039
00040 QString msg;
00041
00042 Config config( "qpe" );
00043 config.setGroup( "Time" );
00044
00045 ampm = config.readBoolEntry( "AMPM", TRUE );
00046
00047 msg += "<B>" + (ev).description() + "</B>";
00048 if ( (ev).event().hasAlarm() ) {
00049 msg += " <b>" + tr("[with alarm]") +"</b>";
00050 }
00051
00052
00053 if ( show_location && !(ev).location().isEmpty() ) {
00054 if ( (ev).location() != tr("(Unknown)") )
00055 msg += "<BR><i>" + (ev).location() + "</i>";
00056 }
00057
00058 QString timeSpacer = " ";
00059 if ( timeExtraLine ) {
00060 timeSpacer = "<br>";
00061 }
00062
00063 msg += timeSpacer;
00064
00065 if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" )
00066 && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) {
00067 msg += tr ( "All day" );
00068 } else {
00069
00070
00071 msg += ampmTime( QTime( (ev).event().start().time() ) )
00072
00073 + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) );
00074 }
00075
00076 if ( (ev).date() != QDate::currentDate() ) {
00077 msg += differDate( (ev).date() );
00078 }
00079
00080
00081 if ( show_notes ) {
00082 msg += "<br> <i>" + tr("note") + "</i>:" +( (ev).notes() ).mid( 0, maxCharClip );
00083 }
00084 setText( msg );
00085 connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) );
00086 }
00087
00088 DateBookEvent::~DateBookEvent() {
00089 }
00090
00096 QString DateBookEvent::ampmTime( QTime tm ) {
00097 QString s;
00098 if( ampm ) {
00099 int hour = tm.hour();
00100 if ( hour == 0 ) {
00101 hour = 12;
00102 }
00103 if ( hour > 12 ) {
00104 hour -= 12;
00105 }
00106 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
00107 (tm.hour() >= 12) ? "PM" : "AM" );
00108 return s;
00109 } else {
00110 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
00111 return s;
00112 }
00113 }
00114
00115 QString DateBookEvent::differDate( QDate date ) {
00116
00117 QString returnText = "<font color = #407DD9><b> ";
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 returnText += " [ " + Calendar::nameOfDay( date.dayOfWeek() ) + " ] ";
00128 returnText += "</b></font>";
00129 return returnText;
00130 }
00131
00132
00136 void DateBookEvent::editEventSlot( const Event &e ) {
00137
00138 if ( ODevice::inst()->system() == System_Zaurus ) {
00139 QCopEnvelope env( "QPE/Application/datebook", "raise()" );
00140 } else {
00141 QCopEnvelope env( "QPE/Application/datebook", "editEvent(int)" );
00142 env << e.uid();
00143 }
00144 }
00145
00146
00147 void DateBookEvent::editMe() {
00148 emit editEvent( event.event() );
00149 }
00150