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