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

datebookday.h

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C) Opie Team <opie-devel@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022 :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 */
00030 
00031 #ifndef DATEBOOKDAY_H
00032 #define DATEBOOKDAY_H
00033 
00034 #include <qpe/event.h>
00035 
00036 #include <qdatetime.h>
00037 #include <qtable.h>
00038 #include <qvbox.h>
00039 #include <qlist.h>
00040 
00041 #include "datebook.h"
00042 #include "datebooktypes.h"
00043 #include <qlineedit.h>
00044 
00045 class DateBookDayHeader;
00046 class DateBookDB;
00047 class DateBookDBHoliday;
00048 class DatebookdayAllday;
00049 class QDateTime;
00050 class QMouseEvent;
00051 class QPaintEvent;
00052 class QResizeEvent;
00053 
00054 class DateBookDayViewQuickLineEdit : public QLineEdit
00055 {
00056     Q_OBJECT
00057 public:
00058     DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0);
00059 protected:
00060     Event quickEvent;
00061     int active;
00062     void focusOutEvent( QFocusEvent *e );
00063 protected slots:
00064     void slotReturnPressed(void);
00065         void finallyCallClose();
00066 signals:
00067     void insertEvent(const Event &e);
00068 };
00069 
00070 
00071 class DateBookDayView : public QTable
00072 {
00073     Q_OBJECT
00074 public:
00075     DateBookDayView( bool hourClock, QWidget *parent, const char *name );
00076     bool whichClock() const;
00077 
00078     void setRowStyle( int style );
00079 
00080 public slots:
00081     void moveUp();
00082     void moveDown();
00083     void slotDateChanged( int year, int month, int day );
00084 
00085 signals:
00086     void sigColWidthChanged();
00087     void sigCapturedKey( const QString &txt );
00088 protected slots:
00089     void slotChangeClock( bool );
00090 protected:
00091     virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected );
00092     virtual void paintFocus( QPainter *p, const QRect &cr );
00093 
00094     virtual void resizeEvent( QResizeEvent *e );
00095     void keyPressEvent( QKeyEvent *e );
00096     void contentsMouseReleaseEvent( QMouseEvent *e );
00097     void initHeader();
00098 private:
00099     bool ampm;
00100     QDate currDate;
00101     DateBookDayViewQuickLineEdit *quickLineEdit;
00102 };
00103 
00104 class DateBookDay;
00105 class DateBookDayWidget : public QWidget
00106 {
00107     Q_OBJECT
00108 
00109 public:
00110     DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db );
00111     ~DateBookDayWidget();
00112 
00113     const QRect &geometry() { return geom; }
00114     void setGeometry( const QRect &r );
00115 
00116     const EffectiveEvent &event() const { return ev; }
00117 
00118 signals:
00119     void deleteMe( const Event &e );
00120     void duplicateMe( const Event &e );
00121     void editMe( const Event &e );
00122     void beamMe( const Event &e );
00123 
00124 protected:
00125     void paintEvent( QPaintEvent *e );
00126     void mousePressEvent( QMouseEvent *e );
00127 
00128 private:
00133     void setAllDayText( QString& text );
00134 
00139     void setEventText( QString& text );
00140     EffectiveEvent ev;
00141     DateBookDay *dateBook;
00142     QString text;
00143     QRect geom;
00144 };
00145 
00146 //Marker for current time in the dayview
00147 class DateBookDayTimeMarker : public QWidget
00148 {
00149     Q_OBJECT
00150 
00151 public:
00152     DateBookDayTimeMarker( DateBookDay *db );
00153     ~DateBookDayTimeMarker();
00154 
00155     const QRect &geometry() { return geom; }
00156     void setGeometry( const QRect &r );
00157     void setTime( const QTime &t );
00158 
00159 signals:
00160 
00161 protected:
00162     void paintEvent( QPaintEvent *e );
00163 
00164 private:
00165     QRect geom;
00166     QTime time;
00167     DateBookDay *dateBook;
00168 };
00169 
00170 //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights
00171 class WidgetListClass : public QList<DateBookDayWidget>
00172 {
00173     private:
00174 
00175     int compareItems( QCollection::Item s1, QCollection::Item s2 )
00176     {
00177         //hmm, don't punish me for that ;)
00178         if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height())
00179         {
00180             return -1;
00181         } else
00182         {
00183             return 1;
00184         }
00185     }
00186 
00187 
00188 };
00189 
00190 class DateBookDay : public QVBox
00191 {
00192     Q_OBJECT
00193 
00194     friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB
00195 public:
00196     DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb,DateBookHoliday*newHdb,
00197          QWidget *parent, const char *name );
00198     void selectedDates( QDateTime &start, QDateTime &end );
00199 
00200     QDate date() const;
00201     DateBookDayView *dayView() const { return view; }
00202     void setStartViewTime( int startHere );
00203     int startViewTime() const;
00204     void setSelectedWidget( DateBookDayWidget * );
00205     DateBookDayWidget * getSelectedWidget( void );
00206     void setJumpToCurTime( bool bJump );
00207     void setRowStyle( int style );
00208     static QDate findRealStart( int uid, const QDate& isIncluded,
00209                                 DateBookDB* );
00210 
00211 public slots:
00212     void setDate( int y, int m, int d );
00213     void setDate( QDate );
00214     void redraw();
00215     void slotWeekChanged( bool bStartOnMonday );
00216     void updateView();  //updates TimeMarker and DayWidget-colors
00217 
00218 signals:
00219     void removeEvent( const Event& );
00220     void editEvent( const Event& );
00221     void duplicateEvent( const Event& );
00222     void beamEvent( const Event& );
00223     void newEvent();
00224     void sigNewEvent( const QString & );
00225 
00226 protected slots:
00227     void keyPressEvent(QKeyEvent *);
00228 
00229 private slots:
00230     void dateChanged( int y, int m, int d );
00231     void slotColWidthChanged() { relayoutPage(); };
00232 
00233 private:
00234     void getEvents();
00235     void relayoutPage( bool fromResize = false );
00236     DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom );
00237     QDate currDate;
00238     DateBookDayView *view;
00239     DateBookDayHeader *header;
00240     DatebookdayAllday *m_allDays;
00241     DateBookDBHoliday *db;
00242     WidgetListClass widgetList; //reimplemented QList for sorting widgets by height
00243     int startTime;
00244     bool jumpToCurTime; //should we jump to current time in dayview?
00245     int rowStyle;
00246     DateBookDayWidget *selectedWidget; //actual selected widget (obviously)
00247     DateBookDayTimeMarker *timeMarker;  //marker for current time
00248     DateBookHoliday*_holiday_db;
00249 };
00250 
00251 #endif

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