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 <libkcal/resourcecalendar.h>
00031 #include <qlistview.h>
00032 
00033 namespace KCal {
00034 class CalendarResources;
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( KCal::CalendarResources *calendar,
00045                          CalendarView *view );
00046 
00047     CalendarViewExtension *create( QWidget * );
00048 
00049     ResourceView *resourceView() const;
00050 
00051   private:
00052     KCal::CalendarResources *mCalendar;
00053     CalendarView *mView;
00054     ResourceView *mResourceView;
00055 };
00056 
00057 
00058 class ResourceItem : public QCheckListItem
00059 {
00060   public:
00061     ResourceItem( KCal::ResourceCalendar *resource, ResourceView *view,
00062                   KListView *parent );
00063     ResourceItem( KCal::ResourceCalendar *resource, const QString& sub,
00064                   const QString& label, ResourceView *view,
00065                   ResourceItem* parent );
00066 
00067     KCal::ResourceCalendar *resource() { return mResource; }
00068     const QString& resourceIdentifier() { return mResourceIdentifier; }
00069     bool isSubresource() const { return mIsSubresource; }
00070     void createSubresourceItems();
00071     void setStandardResource( bool std );
00072 
00073     void update();
00074 
00075     virtual void paintCell(QPainter *p, const QColorGroup &cg,
00076       int column, int width, int alignment);
00077 
00078     void setResourceColor(QColor& color);
00079     QColor &resourceColor() {return mResourceColor;}
00080   protected:
00081     void stateChange( bool active );
00082 
00083     void setGuiState();
00084     QColor mResourceColor;
00085 
00086   private:
00087     KCal::ResourceCalendar *mResource;
00088     ResourceView *mView;
00089     bool mBlockStateChange;
00090     bool mIsSubresource;
00091     QString mResourceIdentifier;
00092     bool mSubItemsCreated;
00093     bool mIsStandardResource;
00094 };
00095 
00099 class ResourceView : public CalendarViewExtension
00100 {
00101     Q_OBJECT
00102   public:
00103     ResourceView( KCal::CalendarResources *calendar, QWidget *parent = 0,
00104                   const char *name = 0 );
00105     ~ResourceView();
00106 
00107     KCal::CalendarResources *calendar() const { return mCalendar; }
00108 
00109     void updateView();
00110 
00111     void emitResourcesChanged();
00112 
00113     void requestClose( ResourceCalendar * );
00114 
00115     void showButtons( bool visible );
00116 
00117   public slots:
00118     void addResourceItem( ResourceCalendar * );
00119     void updateResourceItem( ResourceCalendar * );
00120 
00121   signals:
00122     void resourcesChanged();
00123 
00124   protected:
00125     ResourceItem *findItem( ResourceCalendar * );
00126     ResourceItem *findItemByIdentifier( const QString& id );
00127     ResourceItem *currentItem();
00128 
00129   protected slots:
00130     void addResource();
00131     void removeResource();
00132     void editResource();
00133     void currentChanged( QListViewItem* );
00134     void slotSubresourceAdded( ResourceCalendar *, const QString &,
00135                                const QString &resource,const QString& label );
00136     void slotSubresourceRemoved( ResourceCalendar *, const QString &,
00137                                  const QString & );
00138     void closeResource( ResourceCalendar * );
00139 
00140     void contextMenuRequested ( QListViewItem *i, const QPoint &pos, int );
00141 
00142     void assignColor();
00143     void disableColor();
00144     void showInfo();
00145 
00146     void reloadResource();
00147     void saveResource();
00148 
00149     void setStandard();
00150     void updateResourceList();
00151 
00152   private:
00153     KListView *mListView;
00154     KCal::CalendarResources *mCalendar;
00155     QPushButton *mAddButton;
00156     QPushButton *mDeleteButton;
00157     QPushButton *mEditButton;
00158     QPtrList<ResourceCalendar> mResourcesToClose;
00159 };
00160 
00161 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys