KNewStuff
itemsgridviewdelegate.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_ITEMSGRIDVIEWDELEGATE_H 00021 #define KNEWSTUFF3_UI_ITEMSGRIDVIEWDELEGATE_H 00022 00023 #include "itemsviewbasedelegate.h" 00024 class QToolButton; 00025 namespace KNS3 00026 { 00027 static const int ItemGridHeight = 202; 00028 static const int ItemGridWidth = 158; 00029 00030 static const int FrameThickness = 5; 00031 static const int ItemMargin = 2; 00032 class ItemsGridViewDelegate: public ItemsViewBaseDelegate 00033 { 00034 Q_OBJECT 00035 public: 00036 explicit ItemsGridViewDelegate(QAbstractItemView* itemView, Engine* engine, QObject* parent = 0); 00037 ~ItemsGridViewDelegate(); 00038 00039 00040 // paint the item at index with all its attributes shown 00041 virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const; 00042 00043 // get the list of widgets 00044 virtual QList<QWidget*> createItemWidgets() const; 00045 00046 // update the widgets 00047 virtual void updateItemWidgets(const QList<QWidget*> widgets, 00048 const QStyleOptionViewItem &option, 00049 const QPersistentModelIndex &index) const; 00050 00051 virtual QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; 00052 00053 private: 00054 void createOperationBar(); 00055 void displayOperationBar(const QRect &rect,const QModelIndex & index); 00056 00057 private: 00058 QWidget *m_operationBar; 00059 QToolButton *m_detailsButton; 00060 QToolButton *m_installButton; 00061 00062 QModelIndex m_oldIndex; 00063 mutable int m_elementYPos; 00064 }; 00065 } 00066 00067 #endif
KDE 4.6 API Reference