korganizer

komonthview.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
00024 */
00025 
00026 #ifndef _KOMONTHVIEW_H
00027 #define _KOMONTHVIEW_H
00028 
00029 #include <qlistbox.h>
00030 #include <qptrvector.h>
00031 #include <qtooltip.h>
00032 #include "koeventview.h"
00033 
00034 class KNoScrollListBox;
00035 
00036 class KOMonthCellToolTip : public QToolTip
00037 {
00038   public:
00039     KOMonthCellToolTip (QWidget* parent, Calendar *calendar, const QDate &date, KNoScrollListBox* lv );
00040 
00041   protected:
00042     void maybeTip( const QPoint & pos);
00043 
00044   private:
00045     Calendar *mCalendar;
00046     QDate mDate;
00047     KNoScrollListBox* eventlist;
00048 };
00049 
00050 
00051 class KNoScrollListBox: public QListBox
00052 {
00053     Q_OBJECT
00054   public:
00055     KNoScrollListBox(QWidget *parent=0, const char *name=0);
00056     ~KNoScrollListBox() {}
00057 
00058     void setBackground( bool primary, bool workday );
00059 
00060   signals:
00061     void shiftDown();
00062     void shiftUp();
00063     void rightClick();
00064 
00065   protected slots:
00066     void keyPressEvent(QKeyEvent *);
00067     void keyReleaseEvent(QKeyEvent *);
00068     void mousePressEvent(QMouseEvent *);
00069     void resizeEvent(QResizeEvent *);
00070     void contentsMouseDoubleClickEvent( QMouseEvent * e );
00071 
00072   private:
00073     bool mSqueezing;
00074 };
00075 
00076 
00077 class MonthViewItem: public QListBoxItem
00078 {
00079   public:
00080     MonthViewItem( Incidence *, const QDateTime &qd, const QString & title );
00081 
00082     void setEvent(bool on) { mEvent = on; }
00083     void setTodo(bool on)  { mTodo  = on; }
00084     void setTodoDone(bool on) { mTodoDone = on; }
00085     void setRecur(bool on) { mRecur = on; }
00086     void setAlarm(bool on) { mAlarm = on; }
00087     void setReply(bool on) { mReply = on; }
00088 
00089     void setPalette(const QPalette &p) { mPalette = p; }
00090     QPalette palette() const { return mPalette; }
00091 
00092     Incidence *incidence() const { return mIncidence; }
00093     QDateTime incidenceDateTime() { return mDateTime; }
00094 
00095     void setResourceColor( QColor& color ) { mResourceColor = color; }
00096     QColor &resourceColor() { return mResourceColor; }
00097   protected:
00098     virtual void paint(QPainter *);
00099     virtual int height(const QListBox *) const;
00100     virtual int width(const QListBox *) const;
00101     //Color of the resource
00102     QColor mResourceColor;
00103   private:
00104     bool mEvent;
00105     bool mTodo;
00106     bool mTodoDone;
00107     bool mRecur;
00108     bool mAlarm;
00109     bool mReply;
00110 
00111     QPixmap mEventPixmap;
00112     QPixmap mBirthdayPixmap;
00113     QPixmap mAnniversaryPixmap;
00114     QPixmap mTodoPixmap;
00115     QPixmap mTodoDonePixmap;
00116     QPixmap mAlarmPixmap;
00117     QPixmap mRecurPixmap;
00118     QPixmap mReplyPixmap;
00119 
00120     QPalette mPalette;
00121     QDateTime mDateTime;
00122 
00123     Incidence *mIncidence;
00124     QColor catColor() const;
00125 };
00126 
00127 
00128 class KOMonthView;
00129 
00134 class MonthViewCell : public QWidget
00135 {
00136     Q_OBJECT
00137   public:
00138     class CreateItemVisitor;
00139     MonthViewCell( KOMonthView * );
00140 
00142     void setDate( const QDate & );
00144     QDate date() const;
00145 
00147     KOMonthView *monthView() { return mMonthView; }
00148 
00156     void setPrimary( bool primary );
00160     bool isPrimary() const;
00161 
00163     void setHoliday( bool );
00169     void setHolidayString( const QString &name );
00170 
00171     void updateCell();
00179     void addIncidence( Incidence *incidence, MonthViewCell::CreateItemVisitor&v, int multiDay = 0 );
00184     void removeIncidence( Incidence * );
00185 
00186     void updateConfig();
00187 
00188     void enableScrollBars( bool );
00189 
00190     Incidence *selectedIncidence();
00191     QDate selectedIncidenceDate();
00192 
00193     void deselect();
00194 
00195   signals:
00196     void defaultAction( Incidence * );
00202     void newEventSignal( ResourceCalendar *res,const QString &subResource,
00203                          const QDate &date );
00204 
00205   public slots:
00206     void select();
00207 
00208   protected:
00209     void setFrameWidth();
00210     void resizeEvent( QResizeEvent * );
00211 
00212   protected slots:
00213     void defaultAction( QListBoxItem * );
00214     void contextMenu( QListBoxItem * );
00215 
00216   private:
00217     KOMonthView *mMonthView;
00218 
00219     QDate mDate;
00220     bool mPrimary;
00221     bool mHoliday;
00222     QString mHolidayString;
00223 
00224     QLabel *mLabel;
00225     KNoScrollListBox *mItemList;
00226 
00227     QSize mLabelSize;
00228 //    QPalette mOriginalPalette;
00229     QPalette mHolidayPalette;
00230     QPalette mStandardPalette;
00231     QPalette mTodayPalette;
00232 };
00233 
00241 class KOMonthView: public KOEventView
00242 {
00243     Q_OBJECT
00244   public:
00245     KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00246     ~KOMonthView();
00247 
00249     virtual int maxDatesHint();
00250 
00252     virtual int currentDateCount();
00253 
00255     virtual Incidence::List selectedIncidences();
00256 
00258     virtual DateList selectedDates();
00259 
00260     virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00261 
00262   public slots:
00263     virtual void updateView();
00264     virtual void updateConfig();
00265     virtual void showDates(const QDate &start, const QDate &end);
00266     virtual void showIncidences( const Incidence::List &incidenceList, const QDate &date );
00267 
00268     void changeIncidenceDisplay(Incidence *, int);
00269     void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
00270 
00271     void clearSelection();
00272 
00273     void showEventContextMenu( Calendar *, Incidence *, const QDate & );
00274     void showGeneralContextMenu();
00275 
00276     void setSelectedCell( MonthViewCell * );
00277 
00278   protected slots:
00279     void processSelectionChange();
00280 
00281   protected:
00282     void resizeEvent(QResizeEvent *);
00283 
00284     void viewChanged();
00285     void updateDayLabels();
00286 
00287   private:
00288     class GetDateVisitor;
00289     int mDaysPerWeek;
00290     int mNumWeeks;
00291     int mNumCells;
00292     int mWeekStartDay;
00293 
00294     QPtrVector<MonthViewCell> mCells;
00295     QMap<QDate,MonthViewCell *> mDateToCell;
00296     QPtrVector<QLabel> mDayLabels;
00297 
00298     bool mShortDayLabels;
00299     int mWidthLongDayLabel;
00300 
00301     QDate mStartDate;
00302     QDate mSelectedDate;
00303 
00304     MonthViewCell *mSelectedCell;
00305 
00306     KOEventPopupMenu *mEventContextMenu;
00307     QLabel *mLabel;
00308 };
00309 
00310 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys