Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

datebookevent.cpp

Go to the documentation of this file.
00001 /*
00002  * datebookevent.cpp
00003  *
00004  * copyright   : (c) 2002, 2003, 2004 by Maximilian Reiß
00005  * email       : harlekin@handhelds.org
00006  *
00007  */
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
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     // setAlignment( AlignTop );
00039 
00040     QString msg;
00041 
00042     Config config( "qpe" );
00043     config.setGroup( "Time" );
00044     // if 24 h format
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     // include location or not
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         // start time of event
00070 //         QDate tempDate = (ev).event().start().date();
00071         msg += ampmTime( QTime( (ev).event().start().time() ) )
00072                // end time of event
00073                + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) );
00074     }
00075 
00076     if ( (ev).date() != QDate::currentDate() )  {
00077         msg += differDate( (ev).date() /* tempDate*/ );
00078     }
00079 
00080     // include possible note or not
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 //     QDate currentDate = QDate::currentDate();
00117     QString returnText = "<font color = #407DD9><b> ";
00118 //     int differDate = currentDate.daysTo( date );
00119 //     if ( currentDate.dayOfWeek() == date.dayOfWeek() ) {
00120 //         returnText += "" ;
00121 //         // not working right for recurring events
00122 //         //} else if ( differDate == 1 ) {
00123 //         //returnText += tr( "tomorrow" );
00124 //     } else {
00125 //          returnText += "   [ " + Calendar::nameOfDay( date.dayOfWeek() )  + " ] ";
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 

Generated on Sat Nov 5 16:15:55 2005 for OPIE by  doxygen 1.4.2