korganizer

timelineitem.h

00001 /*
00002     Copyright (c) 2007 Volker Krause <vkrause@kde.org>
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef KORG_TIMELINEITEM_H
00020 #define KORG_TIMELINEITEM_H
00021 
00022 #define private protected
00023 #include <kdgantt/KDGanttViewTaskItem.h>
00024 #undef protected
00025 
00026 #include <qmap.h>
00027 #include <qvaluelist.h>
00028 
00029 class KDGanttView;
00030 class KDCanvasPolygon;
00031 
00032 namespace KCal {
00033   class Calendar;
00034   class ResourceCalendar;
00035   class Incidence;
00036 }
00037 
00038 namespace KOrg {
00039 
00040 class TimelineSubItem;
00041 
00042 class TimelineItem : public KDGanttViewTaskItem
00043 {
00044   public:
00045     TimelineItem( const QString &label, KDGanttView* parent );
00046 
00047     void insertIncidence( KCal::Incidence *incidence,
00048                           const QDateTime &start = QDateTime(),
00049                           const QDateTime &end = QDateTime() );
00050     void removeIncidence( KCal::Incidence *incidence );
00051 
00052     void moveItems( KCal::Incidence* incidence, int delta, int duration );
00053 
00054   private:
00055     QMap<KCal::Incidence*, QValueList<TimelineSubItem*> > mItemMap;
00056 };
00057 
00058 class TimelineSubItem : public KDGanttViewTaskItem
00059 {
00060   public:
00061     TimelineSubItem( KCal::Incidence *incidence, TimelineItem *parent );
00062     ~TimelineSubItem();
00063 
00064     KCal::Incidence* incidence() const { return mIncidence; }
00065 
00066     QDateTime originalStart() const { return mStart; }
00067     void setOriginalStart( const QDateTime &dt ) { mStart = dt; }
00068 
00069   private:
00070     void showItem( bool show = true, int coordY = 0 );
00071 
00072   private:
00073     KCal::Incidence *mIncidence;
00074     QDateTime mStart;
00075     KDCanvasPolygon *mLeft, *mRight;
00076     int mMarkerWidth;
00077 };
00078 
00079 }
00080 
00081 #endif