KNewStuff
itemsviewbasedelegate.h
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2008 Jeremy Whiting <jpwhiting@kde.org> 00003 Copyright (C) 2010 Reza Fatahilah Shah <rshah0385@kireihana.com> 00004 Copyright (C) 2010 Frederik Gladhorn <gladhorn@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library 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 GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef KNEWSTUFF3_UI_ITEMSVIEWBASEDELEGATE_H 00021 #define KNEWSTUFF3_UI_ITEMSVIEWBASEDELEGATE_H 00022 00023 #include <QList> 00024 #include <QtCore/QMap> 00025 #include <QtCore/QModelIndex> 00026 #include <QtCore/QObject> 00027 #include <QtGui/QImage> 00028 00029 #include "core/engine.h" 00030 #include "core/entryinternal.h" 00031 00032 #include <kicon.h> 00033 #include <kwidgetitemdelegate.h> 00034 00035 namespace KNS3 00036 { 00037 class ItemsModel; 00038 class Engine; 00039 00040 class ItemsViewBaseDelegate: public KWidgetItemDelegate 00041 { 00042 Q_OBJECT 00043 public: 00044 explicit ItemsViewBaseDelegate(QAbstractItemView* itemView, Engine* engine, QObject* parent = 0); 00045 virtual ~ItemsViewBaseDelegate(); 00046 // paint the item at index with all its attributes shown 00047 virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const = 0; 00048 00049 // get the list of widgets 00050 virtual QList<QWidget*> createItemWidgets() const = 0; 00051 00052 // update the widgets 00053 virtual void updateItemWidgets(const QList<QWidget*> widgets, 00054 const QStyleOptionViewItem &option, 00055 const QPersistentModelIndex &index) const =0; 00056 00057 virtual QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const = 0; 00058 00059 Q_SIGNALS: 00060 void signalShowDetails(const KNS3::EntryInternal& entry); 00061 00062 protected slots: 00063 bool eventFilter(QObject *watched, QEvent *event); 00064 void slotInstallClicked(); 00065 void slotInstallActionTriggered(QAction* action); 00066 void slotLinkClicked(const QString & url); 00067 void slotDetailsClicked(const QModelIndex& index); 00068 void slotDetailsClicked(); 00069 00070 protected: 00071 Engine* m_engine; 00072 QAbstractItemView *m_itemView; 00073 KIcon m_iconInvalid; 00074 KIcon m_iconDownloadable; 00075 KIcon m_iconInstall; 00076 KIcon m_iconUpdate; 00077 KIcon m_iconDelete; 00078 QPixmap m_frameImage; 00079 QPixmap m_noImage; 00080 QSize m_buttonSize; 00081 }; 00082 } 00083 #endif
KDE 4.6 API Reference