korganizer

koagendaitem.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2000,2001,2003 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 #ifndef KOAGENDAITEM_H
00026 #define KOAGENDAITEM_H
00027 
00028 #include "cellitem.h"
00029 
00030 #include <qdatetime.h>
00031 
00032 class QToolTipGroup;
00033 class QDragEnterEvent;
00034 class QDropEvent;
00035 
00036 namespace KCal {
00037 class Calendar;
00038 class Incidence;
00039 }
00040 using namespace KCal;
00041 class KOAgendaItem;
00042 
00043 struct MultiItemInfo
00044 {
00045   int mStartCellXLeft, mStartCellXRight;
00046   int mStartCellYTop, mStartCellYBottom;
00047   KOAgendaItem *mFirstMultiItem;
00048   KOAgendaItem *mPrevMultiItem;
00049   KOAgendaItem *mNextMultiItem;
00050   KOAgendaItem *mLastMultiItem;
00051 };
00052 
00053 /*
00054   The KOAgendaItem has to make sure that it receives all mouse events, which are
00055   to be used for dragging and resizing. That means it has to be installed as
00056   eventfiler for its children, if it has children, and it has to pass mouse
00057   events from the cildren to itself. See eventFilter().
00058 
00059 
00060   Some comments on the movement of multi-day items:
00061   Basically, the agenda items are arranged in two implicit double-linked lists.
00062   The mMultiItemInfo works like before to describe the currently viewed
00063   multi-item.
00064   When moving, new events might need to be added to the beginning or the end of
00065   the multi-item sequence, or events might need to be hidden. I cannot just
00066   delete this items, since I have to restore/show them if the move is reset
00067   (i.e. if a drag started). So internally, I keep another doubly-linked list
00068   which is longer than the one defined by mMultiItemInfo, but includes the
00069   multi-item sequence, too.
00070 
00071   The mStartMoveInfo stores the first and last item of the multi-item sequence
00072   when the move started. The prev and next members of mStartMoveInfo are used
00073   for that longer sequence including all (shown and hidden) items.
00074 */
00075 class KOAgendaItem : public QWidget, public KOrg::CellItem
00076 {
00077     Q_OBJECT
00078   public:
00079     KOAgendaItem( Calendar *calendar, Incidence *incidence, const QDate &qd,
00080                   QWidget *parent, const char *name=0, WFlags f=0 );
00081 
00082     int cellXLeft() const { return mCellXLeft; }
00083     int cellXRight() const { return mCellXRight; }
00084     int cellYTop() const { return mCellYTop; }
00085     int cellYBottom() const { return mCellYBottom; }
00086     int cellHeight() const;
00087     int cellWidth() const;
00088 
00089     void setCellXY(int X, int YTop, int YBottom);
00090     void setCellY(int YTop, int YBottom);
00091     void setCellX(int XLeft, int XRight);
00092     void setCellXRight(int xright);
00093 
00095     void startMove();
00097     void resetMove();
00099     void endMove();
00100 
00101     void moveRelative(int dx,int dy);
00102     void expandTop(int dy);
00103     void expandBottom(int dy);
00104     void expandLeft(int dx);
00105     void expandRight(int dx);
00106 
00107     bool isMultiItem();
00108     KOAgendaItem *prevMoveItem() const { return (mStartMoveInfo)?(mStartMoveInfo->mPrevMultiItem):0; }
00109     KOAgendaItem *nextMoveItem() const { return (mStartMoveInfo)?(mStartMoveInfo->mNextMultiItem):0; }
00110     MultiItemInfo *moveInfo() const { return mStartMoveInfo; }
00111     void setMultiItem(KOAgendaItem *first,KOAgendaItem *prev,
00112                       KOAgendaItem *next, KOAgendaItem *last);
00113     KOAgendaItem *prependMoveItem(KOAgendaItem*);
00114     KOAgendaItem *appendMoveItem(KOAgendaItem*);
00115     KOAgendaItem *removeMoveItem(KOAgendaItem*);
00116     KOAgendaItem *firstMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mFirstMultiItem):0; }
00117     KOAgendaItem *prevMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mPrevMultiItem):0; }
00118     KOAgendaItem *nextMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mNextMultiItem):0; }
00119     KOAgendaItem *lastMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mLastMultiItem):0; }
00120 
00121     bool dissociateFromMultiItem();
00122 
00123     bool setIncidence( Incidence * );
00124     Incidence *incidence() const { return mIncidence; }
00125     QDate itemDate() { return mDate; }
00126 
00128     void setItemDate( const QDate &qd );
00129 
00130     void setText ( const QString & text ) { mLabelText = text; }
00131     QString text () { return mLabelText; }
00132 
00133     static QToolTipGroup *toolTipGroup();
00134 
00135     QPtrList<KOAgendaItem> conflictItems();
00136     void setConflictItems(QPtrList<KOAgendaItem>);
00137     void addConflictItem(KOAgendaItem *ci);
00138 
00139     QString label() const;
00140 
00141     bool overlaps( KOrg::CellItem * ) const;
00142 
00143     void setResourceColor( const QColor& color ) { mResourceColor = color; }
00144     QColor resourceColor() {return mResourceColor;}
00145   signals:
00146     void removeAgendaItem( KOAgendaItem* );
00147     void showAgendaItem( KOAgendaItem* );
00148 
00149   public slots:
00150     void updateIcons();
00151     void select(bool=true);
00152     void addAttendee( const QString & );
00153 
00154   protected:
00155     void dragEnterEvent(QDragEnterEvent *e);
00156     void dropEvent(QDropEvent *e);
00157     void paintEvent(QPaintEvent *e);
00158     void paintFrame(QPainter *p, const QColor &color);
00159     void paintEventIcon(QPainter *p, int &x, int ft);
00160     void paintTodoIcon(QPainter *p, int &x, int ft);
00161     void paintAlarmIcon(QPainter *p, int &x, int ft);
00162 
00163     // paint all visible icons
00164     void paintIcons(QPainter *p, int &x, int ft);
00165 
00169     void startMovePrivate();
00170     void resetMovePrivate();
00171     void endMovePrivate();
00172 
00173 
00174   private:
00175     int mCellXLeft, mCellXRight;
00176     int mCellYTop, mCellYBottom;
00177     int mSubCell;  // subcell number of this item
00178     int mSubCells;  // Total number of subcells in cell of this item
00179 
00180     Calendar *mCalendar;
00181     Incidence *mIncidence; // corresponding event or todo
00182     QDate mDate; //date this events occurs (for recurrence)
00183     QString mLabelText;
00184     bool mIconAlarm, mIconRecur, mIconReadonly;
00185     bool mIconReply, mIconGroup, mIconGroupTentative;
00186     bool mIconOrganizer, mSpecialEvent;
00187 
00188     // Multi item pointers
00189     MultiItemInfo* mMultiItemInfo;
00190   protected:
00191     // Variables to remember start position
00192     MultiItemInfo* mStartMoveInfo;
00193     //Color of the resource
00194     QColor mResourceColor;
00195   private:
00196     static QToolTipGroup *mToolTipGroup;
00197 
00198     bool mSelected;
00199     QPtrList<KOAgendaItem> mConflictItems;
00200 
00201     static QPixmap *alarmPxmp;
00202     static QPixmap *recurPxmp;
00203     static QPixmap *readonlyPxmp;
00204     static QPixmap *replyPxmp;
00205     static QPixmap *groupPxmp;
00206     static QPixmap *groupPxmpTentative;
00207     static QPixmap *organizerPxmp;
00208 };
00209 
00210 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys