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, KNoScrollListBox* lv );
00040 
00041   protected:
00042     void maybeTip( const QPoint & pos);
00043 
00044   private:
00045     Calendar *mCalendar;
00046     KNoScrollListBox* eventlist;
00047 };
00048 
00049 
00050 class KNoScrollListBox: public QListBox
00051 {
00052     Q_OBJECT
00053   public:
00054     KNoScrollListBox(QWidget *parent=0, const char *name=0);
00055     ~KNoScrollListBox() {}
00056 
00057     void setBackground( bool primary, bool workday );
00058 
00059   signals:
00060     void shiftDown();
00061     void shiftUp();
00062     void rightClick();
00063 
00064   protected slots:
00065     void keyPressEvent(QKeyEvent *);
00066     void keyReleaseEvent(QKeyEvent *);
00067     void mousePressEvent(QMouseEvent *);
00068     void resizeEvent(QResizeEvent *);
00069     void contentsMouseDoubleClickEvent( QMouseEvent * e );
00070 
00071   private:
00072     bool mSqueezing;
00073 };
00074 
00075 
00076 class MonthViewItem: public QListBoxItem
00077 {
00078   public:
00079     MonthViewItem( Incidence *, const QDateTime &qd, const QString & title );
00080 
00081     void setEvent(bool on) { mEvent = on; }
00082     void setTodo(bool on)  { mTodo  = on; }
00083     void setTodoDone(bool on) { mTodoDone = on; }
00084     void setRecur(bool on) { mRecur = on; }
00085     void setAlarm(bool on) { mAlarm = on; }
00086     void setReply(bool on) { mReply = on; }
00087 
00088     void setPalette(const QPalette &p) { mPalette = p; }
00089     QPalette palette() const { return mPalette; }
00090 
00091     Incidence *incidence() const { return mIncidence; }
00092     QDateTime incidenceDateTime() { return mDateTime; }
00093 
00094     void setResourceColor( QColor& color ) { mResourceColor = color; }
00095     QColor &resourceColor() { return mResourceColor; }
00096   protected:
00097     virtual void paint(QPainter *);
00098     virtual int height(const QListBox *) const;
00099     virtual int width(const QListBox *) const;
00100     //Color of the resource
00101     QColor mResourceColor;
00102   private:
00103     bool mEvent;
00104     bool mTodo;
00105     bool mTodoDone;
00106     bool mRecur;
00107     bool mAlarm;
00108     bool mReply;
00109 
00110     QPixmap mEventPixmap;
00111     QPixmap mTodoPixmap;
00112     QPixmap mTodoDonePixmap;
00113     QPixmap mAlarmPixmap;
00114     QPixmap mRecurPixmap;
00115     QPixmap mReplyPixmap;
00116 
00117     QPalette mPalette;
00118     QDateTime mDateTime;
00119 
00120     Incidence *mIncidence;
00121     QColor catColor() const;
00122 };
00123 
00124 
00125 class KOMonthView;
00126 
00131 class MonthViewCell : public QWidget
00132 {
00133     Q_OBJECT
00134   public:
00135     class CreateItemVisitor;
00136     MonthViewCell( KOMonthView * );
00137 
00139     void setDate( const QDate & );
00141     QDate date() const;
00142 
00150     void setPrimary( bool primary );
00154     bool isPrimary() const;
00155 
00157     void setHoliday( bool );
00163     void setHolidayString( const QString &name );
00164 
00165     void updateCell();
00173     void addIncidence( Incidence *incidence, MonthViewCell::CreateItemVisitor&v, int multiDay = 0 );
00178     void removeIncidence( Incidence * );
00179 
00180     void updateConfig();
00181 
00182     void enableScrollBars( bool );
00183 
00184     Incidence *selectedIncidence();
00185     QDate selectedIncidenceDate();
00186 
00187     void deselect();
00188 
00189     void setCalendar( Calendar *cal ) { mCalendar = cal; }
00190 
00191   signals:
00192     void defaultAction( Incidence * );
00198     void newEventSignal( const QDate &date );
00199 
00200   public slots:
00201     void select();
00202 
00203   protected:
00204     void setFrameWidth();
00205     void resizeEvent( QResizeEvent * );
00206 
00207   protected slots:
00208     void defaultAction( QListBoxItem * );
00209     void contextMenu( QListBoxItem * );
00210 
00211   private:
00212     KOMonthView *mMonthView;
00213    // We need the calendar for paint the ResourceColor
00214     Calendar *mCalendar;
00215 
00216     QDate mDate;
00217     bool mPrimary;
00218     bool mHoliday;
00219     QString mHolidayString;
00220 
00221     QLabel *mLabel;
00222     KNoScrollListBox *mItemList;
00223 
00224     QSize mLabelSize;
00225 //    QPalette mOriginalPalette;
00226     QPalette mHolidayPalette;
00227     QPalette mStandardPalette;
00228     QPalette mTodayPalette;
00229 };
00230 
00238 class KOMonthView: public KOEventView
00239 {
00240     Q_OBJECT
00241   public:
00242     KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00243     ~KOMonthView();
00244 
00246     virtual int maxDatesHint();
00247 
00249     virtual int currentDateCount();
00250 
00252     virtual Incidence::List selectedIncidences();
00253 
00255     virtual DateList selectedDates();
00256 
00257     virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00258 
00259   public slots:
00260     virtual void updateView();
00261     virtual void updateConfig();
00262     virtual void showDates(const QDate &start, const QDate &end);
00263     virtual void showIncidences( const Incidence::List &incidenceList );
00264 
00265     void changeIncidenceDisplay(Incidence *, int);
00266     void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
00267 
00268     void clearSelection();
00269 
00270     void showEventContextMenu( Incidence *, const QDate & );
00271     void showGeneralContextMenu();
00272 
00273     void setSelectedCell( MonthViewCell * );
00274 
00275   protected slots:
00276     void processSelectionChange();
00277 
00278   protected:
00279     void resizeEvent(QResizeEvent *);
00280 
00281     void viewChanged();
00282     void updateDayLabels();
00283 
00284   private:
00285     class GetDateVisitor;
00286     int mDaysPerWeek;
00287     int mNumWeeks;
00288     int mNumCells;
00289     int mWeekStartDay;
00290 
00291     QPtrVector<MonthViewCell> mCells;
00292     QMap<QDate,MonthViewCell *> mDateToCell;
00293     QPtrVector<QLabel> mDayLabels;
00294 
00295     bool mShortDayLabels;
00296     int mWidthLongDayLabel;
00297 
00298     QDate mStartDate;
00299     QDate mSelectedDate;
00300 
00301     MonthViewCell *mSelectedCell;
00302 
00303     KOEventPopupMenu *mEventContextMenu;
00304     QLabel *mLabel;
00305 };
00306 
00307 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys