korganizer

koeditorfreebusy.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2000,2001,2004 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of TQt, and distribute the resulting executable,
00022     without including the source code for TQt in the source distribution.
00023 */
00024 #ifndef KOEDITORFREEBUSY_H
00025 #define KOEDITORFREEBUSY_H
00026 
00027 #include "koattendeeeditor.h"
00028 
00029 #include <tqwidget.h>
00030 #include <tqdatetime.h>
00031 #include <tqtimer.h>
00032 
00033 class KDIntervalColorRectangle;
00034 class TQLabel;
00035 class KDGanttView;
00036 class KDGanttViewItem;
00037 class FreeBusyItem;
00038 
00039 namespace KCal {
00040   class FreeBusy;
00041   class Attendee;
00042 }
00043 
00044 
00045 class KOEditorFreeBusy : public KOAttendeeEditor
00046 {
00047     Q_OBJECT
00048   
00049   public:
00050     KOEditorFreeBusy( int spacing = 8, TQWidget *parent = 0,
00051                       const char *name = 0 );
00052     virtual ~KOEditorFreeBusy();
00053 
00054     void setUpdateEnabled( bool enabled );
00055     bool updateEnabled() const;
00056 
00057     void insertAttendee( KCal::Attendee *, bool readFBList = true );
00058     void removeAttendee( KCal::Attendee * );
00059     void clearAttendees();
00060 
00061     void readEvent( KCal::Event * );
00062     void writeEvent( KCal::Event *event );
00063 
00064     void triggerReload();
00065     void cancelReload();
00066 
00067   signals:
00068     void dateTimesChanged( const TQDateTime &, const TQDateTime & );
00069 
00070   public slots:
00071     void slotInsertFreeBusy( KCal::FreeBusy *fb, const TQString &email );
00072 
00073     void setDateTimes( const TQDateTime &, const TQDateTime & );
00074 
00075     void editFreeBusyUrl( KDGanttViewItem *item );
00076 
00077   protected slots:
00078     void slotUpdateGanttView( const TQDateTime &, const TQDateTime & );
00079     void slotScaleChanged( int );
00080     void slotCenterOnStart() ;
00081     void slotZoomToTime();
00082     void slotPickDate();
00083     void showAttendeeStatusMenu();
00084 
00085     // Force the download of FB informations
00086     void manualReload();
00087     // Only download FB if the auto-download option is set in config
00088     void autoReload();
00089     void slotIntervalColorRectangleMoved( const TQDateTime& start, const TQDateTime& end );
00090 
00091     void removeAttendee();
00092     void listViewClicked( int button, KDGanttViewItem* item );
00093 
00094   protected:
00095     void timerEvent( TQTimerEvent* );
00096     KCal::Attendee* currentAttendee() const;
00097     /* reimpl */
00098     TQListViewItem* hasExampleAttendee() const;
00099     void updateCurrentItem();
00100     void clearSelection() const;
00101     void setSelected ( int index );
00102     int selectedIndex();
00103     void changeStatusForMe( KCal::Attendee::PartStat status );
00104     virtual bool eventFilter( TQObject *watched, TQEvent *event );
00105 
00106   private slots:
00107     void slotOrganizerChanged( const TQString &newOrganizer );
00108   private:
00109     void updateFreeBusyData( FreeBusyItem * );
00110 
00111     bool findFreeSlot( TQDateTime &dtFrom, TQDateTime &dtTo );
00112     bool tryDate( TQDateTime &tryFrom, TQDateTime &tryTo );
00113     bool tryDate( FreeBusyItem *attendee,
00114                   TQDateTime &tryFrom, TQDateTime &tryTo );
00115     void updateStatusSummary();
00116     void reload();
00117     KDGanttView *mGanttView;
00118     KDIntervalColorRectangle* mEventRectangle;
00119     TQLabel *mStatusSummaryLabel;
00120     bool mIsOrganizer;
00121     TQComboBox *scaleCombo;
00122 
00123     TQDateTime mDtStart, mDtEnd;
00124 
00125     TQTimer mReloadTimer;
00126 
00127     bool mForceDownload;
00128 
00129     TQString mCurrentOrganizer;
00130 };
00131 
00132 #endif