korganizer Library API Documentation

koagendaitem.h

00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2000,2001,2003 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 00023 */ 00024 #ifndef KOAGENDAITEM_H 00025 #define KOAGENDAITEM_H 00026 00027 #include "cellitem.h" 00028 00029 #include <qdatetime.h> 00030 00031 class QToolTipGroup; 00032 class QDragEnterEvent; 00033 class QDropEvent; 00034 00035 namespace KCal { 00036 class Incidence; 00037 } 00038 using namespace KCal; 00039 class KOAgendaItem; 00040 00041 struct MultiItemInfo 00042 { 00043 int mStartCellXLeft, mStartCellXRight; 00044 int mStartCellYTop, mStartCellYBottom; 00045 KOAgendaItem *mFirstMultiItem; 00046 KOAgendaItem *mPrevMultiItem; 00047 KOAgendaItem *mNextMultiItem; 00048 KOAgendaItem *mLastMultiItem; 00049 }; 00050 00051 /* 00052 The KOAgendaItem has to make sure that it receives all mouse events, which are 00053 to be used for dragging and resizing. That means it has to be installed as 00054 eventfiler for its children, if it has children, and it has to pass mouse 00055 events from the cildren to itself. See eventFilter(). 00056 00057 00058 Some comments on the movement of multi-day items: 00059 Basically, the agenda items are arranged in two implicit double-linked lists. 00060 The mMultiItemInfo works like before to describe the currently viewed 00061 multi-item. 00062 When moving, new events might need to be added to the beginning or the end of 00063 the multi-item sequence, or events might need to be hidden. I cannot just 00064 delete this items, since I have to restore/show them if the move is reset 00065 (i.e. if a drag started). So internally, I keep another doubly-linked list 00066 which is longer than the one defined by mMultiItemInfo, but includes the 00067 multi-item sequence, too. 00068 00069 The mStartMoveInfo stores the first and last item of the multi-item sequence 00070 when the move started. The prev and next members of mStartMoveInfo are used 00071 for that longer sequence including all (shown and hidden) items. 00072 */ 00073 class KOAgendaItem : public QWidget, public KOrg::CellItem 00074 { 00075 Q_OBJECT 00076 public: 00077 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, const char *name=0, 00078 WFlags f=0 ); 00079 00080 int cellXLeft() const { return mCellXLeft; } 00081 int cellXRight() const { return mCellXRight; } 00082 int cellYTop() const { return mCellYTop; } 00083 int cellYBottom() const { return mCellYBottom; } 00084 int cellHeight() const; 00085 int cellWidth() const; 00086 00087 void setCellXY(int X, int YTop, int YBottom); 00088 void setCellY(int YTop, int YBottom); 00089 void setCellX(int XLeft, int XRight); 00090 void setCellXRight(int xright); 00091 00093 void startMove(); 00095 void resetMove(); 00097 void endMove(); 00098 00099 void moveRelative(int dx,int dy); 00100 void expandTop(int dy); 00101 void expandBottom(int dy); 00102 void expandLeft(int dx); 00103 void expandRight(int dx); 00104 00105 bool isMultiItem(); 00106 KOAgendaItem *prevMoveItem() const { return (mStartMoveInfo)?(mStartMoveInfo->mPrevMultiItem):0; } 00107 KOAgendaItem *nextMoveItem() const { return (mStartMoveInfo)?(mStartMoveInfo->mNextMultiItem):0; } 00108 MultiItemInfo *moveInfo() const { return mStartMoveInfo; } 00109 void setMultiItem(KOAgendaItem *first,KOAgendaItem *prev, 00110 KOAgendaItem *next, KOAgendaItem *last); 00111 KOAgendaItem *prependMoveItem(KOAgendaItem*); 00112 KOAgendaItem *appendMoveItem(KOAgendaItem*); 00113 KOAgendaItem *removeMoveItem(KOAgendaItem*); 00114 KOAgendaItem *firstMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mFirstMultiItem):0; } 00115 KOAgendaItem *prevMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mPrevMultiItem):0; } 00116 KOAgendaItem *nextMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mNextMultiItem):0; } 00117 KOAgendaItem *lastMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mLastMultiItem):0; } 00118 00119 bool setIncidence( Incidence * ); 00120 Incidence *incidence() const { return mIncidence; } 00121 QDate itemDate() { return mDate; } 00122 00124 void setItemDate(QDate qd); 00125 00126 void setText ( const QString & text ) { mLabelText = text; } 00127 QString text () { return mLabelText; } 00128 00129 static QToolTipGroup *toolTipGroup(); 00130 00131 QPtrList<KOAgendaItem> conflictItems(); 00132 void setConflictItems(QPtrList<KOAgendaItem>); 00133 void addConflictItem(KOAgendaItem *ci); 00134 00135 QString label() const; 00136 00137 bool overlaps( KOrg::CellItem * ) const; 00138 00139 signals: 00140 void removeAgendaItem( KOAgendaItem* ); 00141 void showAgendaItem( KOAgendaItem* ); 00142 00143 public slots: 00144 void updateIcons(); 00145 void select(bool=true); 00146 void addAttendee(QString); 00147 00148 protected: 00149 void dragEnterEvent(QDragEnterEvent *e); 00150 void dropEvent(QDropEvent *e); 00151 void paintEvent(QPaintEvent *e); 00152 void paintFrame(QPainter *p, const QColor &color); 00153 void paintTodoIcon(QPainter *p, int &x, int ft); 00157 void startMovePrivate(); 00158 void resetMovePrivate(); 00159 void endMovePrivate(); 00160 00161 00162 private: 00163 int mCellXLeft, mCellXRight; 00164 int mCellYTop, mCellYBottom; 00165 int mSubCell; // subcell number of this item 00166 int mSubCells; // Total number of subcells in cell of this item 00167 00168 Incidence *mIncidence; // corresponding event or todo 00169 QDate mDate; //date this events occurs (for recurrence) 00170 QString mLabelText; 00171 bool mIconAlarm, mIconRecur, mIconReadonly; 00172 bool mIconReply, mIconGroup, mIconOrganizer; 00173 00174 // Multi item pointers 00175 MultiItemInfo* mMultiItemInfo; 00176 protected: 00177 // Variables to remember start position 00178 MultiItemInfo* mStartMoveInfo; 00179 00180 private: 00181 static QToolTipGroup *mToolTipGroup; 00182 00183 bool mSelected; 00184 QPtrList<KOAgendaItem> mConflictItems; 00185 }; 00186 00187 #endif
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:53:21 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003