korganizer

resourceview.h
00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2003,2004 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 TQt, and distribute the resulting executable,
00023     without including the source code for TQt in the source distribution.
00024 */
00025 #ifndef KORG_RESOURCEVIEW_H
00026 #define KORG_RESOURCEVIEW_H
00027 
00028 #include "calendarview.h"
00029 
00030 #include <tqlistview.h>
00031 
00032 namespace KCal {
00033   class CalendarResources;
00034   class ResourceCalendar;
00035 }
00036 using namespace KCal;
00037 class TDEListView;
00038 class ResourceView;
00039 class TQPushButton;
00040 
00041 class ResourceViewFactory : public CalendarViewExtension::Factory
00042 {
00043   public:
00044     ResourceViewFactory( CalendarResources *calendar, CalendarView *view );
00045 
00046     CalendarViewExtension *create( TQWidget * );
00047 
00048     ResourceView *resourceView() const;
00049 
00050   private:
00051     CalendarResources *mCalendar;
00052     CalendarView *mCalendarView;
00053     ResourceView *mResourceView;
00054 };
00055 
00056 
00057 class ResourceItem : public TQCheckListItem
00058 {
00059   public:
00060     ResourceItem( ResourceCalendar *resource, ResourceView *view, TDEListView *parent );
00061     ResourceItem( ResourceCalendar *resource, const TQString &identifier,
00062                   const TQString &label, ResourceView *view, ResourceItem *parent );
00063 
00064     ResourceCalendar *resource() { return mResource; }
00065     const TQString& resourceIdentifier() { return mResourceIdentifier; }
00066     bool isSubresource() const { return mIsSubresource; }
00067     void createSubresourceItems();
00068     void setStandardResource( bool std );
00069     void update();
00070 
00071     virtual void paintCell(TQPainter *p, const TQColorGroup &cg,
00072       int column, int width, int alignment);
00073 
00074     void setResourceColor(TQColor& color);
00075     TQColor &resourceColor() {return mResourceColor;}
00076 
00077   protected:
00078     void stateChange( bool active );
00079     void setGuiState();
00080     TQColor mResourceColor;
00081 
00082   private:
00083     ResourceCalendar *mResource;
00084     ResourceView *mResourceView;
00085     bool mBlockStateChange;
00086     bool mIsSubresource;
00087     TQString mResourceIdentifier;
00088     bool mSubItemsCreated;
00089     bool mIsStandardResource;
00090 };
00091 
00095 class ResourceView : public CalendarViewExtension
00096 {
00097     Q_OBJECT
00098   
00099   public:
00100     ResourceView( CalendarResources *calendar, CalendarView *view,
00101                   TQWidget *parent = 0, const char *name = 0 );
00102     ~ResourceView();
00103 
00104     CalendarResources *calendar() const { return mCalendar; }
00105 
00106     void updateView();
00107 
00108     void emitResourcesChanged();
00109 
00110     void requestClose( ResourceCalendar *resource );
00111 
00112     void showButtons( bool visible );
00113 
00114   public slots:
00115     void addResourceItem( ResourceCalendar *resource );
00116     void updateResourceItem( ResourceCalendar *resource );
00117 
00118   signals:
00119     void resourcesChanged();
00120 
00121   protected:
00122     ResourceItem *findItem( ResourceCalendar *resource );
00123     ResourceItem *findItemByIdentifier( const TQString &identifier );
00124     ResourceItem *currentItem();
00125 
00126   protected slots:
00127     void addResource();
00128     void removeResource();
00129     void editResource();
00130     void currentChanged( TQListViewItem *lvitem );
00131     void slotSubresourceAdded( ResourceCalendar *resource, const TQString &type,
00132                                const TQString &identifier, const TQString &label );
00133 
00134     void slotSubresourceRemoved( ResourceCalendar *resource, const TQString &type,
00135                                  const TQString &identifier );
00136     void closeResource( ResourceCalendar *resource );
00137 
00138     void contextMenuRequested ( TQListViewItem *lvitem, const TQPoint &pos, int );
00139 
00140     void assignColor();
00141     void disableColor();
00142     void showInfo();
00143 
00144     void reloadResource();
00145     void saveResource();
00146 
00147     void setStandard();
00148     void updateResourceList();
00149 
00150   private:
00151     TDEListView *mListView;
00152     CalendarResources *mCalendar;
00153     CalendarView *mCalendarView;
00154     TQPushButton *mAddButton;
00155     TQPushButton *mDeleteButton;
00156     TQPushButton *mEditButton;
00157     TQPtrList<ResourceCalendar> mResourcesToClose;
00158 };
00159 
00160 #endif