PCManFM-Qt
folderitemdelegate.h
1 /*
2 
3  Copyright (C) 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 
21 #ifndef FM_FOLDERITEMDELEGATE_H
22 #define FM_FOLDERITEMDELEGATE_H
23 
24 #include "libfmqtglobals.h"
25 #include <QStyledItemDelegate>
26 #include <QAbstractItemView>
27 
28 namespace Fm {
29 
30 class LIBFM_QT_API FolderItemDelegate : public QStyledItemDelegate {
31  Q_OBJECT
32 public:
33  explicit FolderItemDelegate(QAbstractItemView* view, QObject* parent = 0);
34  virtual ~FolderItemDelegate();
35 
36  void setGridSize(QSize size) {
37  gridSize_ = size;
38  }
39 
40  QSize gridSize() {
41  return gridSize_;
42  }
43 
44  virtual QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
45  virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
46 
47 private:
48  void drawText(QPainter* painter, QStyleOptionViewItemV4& opt, QRectF& textRect) const;
49  static QIcon::Mode iconModeFromState(QStyle::State state);
50 
51 private:
52  QAbstractItemView* view_;
53  QIcon symlinkIcon_;
54  QSize gridSize_;
55 };
56 
57 }
58 
59 #endif // FM_FOLDERITEMDELEGATE_H
Definition: appchoosercombobox.cpp:26
Definition: folderitemdelegate.h:30