PCManFM-Qt
 All Classes
desktopitemdelegate.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 PCMANFM_DESKTOPITEMDELEGATE_H
22 #define PCMANFM_DESKTOPITEMDELEGATE_H
23 
24 #include <QStyledItemDelegate>
25 #include <QColor>
26 
27 class QListView;
28 class QTextOption;
29 class QTextLayout;
30 
31 namespace PCManFM {
32 
33 class DesktopItemDelegate : public QStyledItemDelegate
34 {
35 Q_OBJECT
36 public:
37  explicit DesktopItemDelegate(QListView* view, QObject* parent = 0);
38  virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
39  virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
40  virtual ~DesktopItemDelegate();
41 
42  void setShadowColor(const QColor& shadowColor) {
43  shadowColor_ = shadowColor;
44  }
45  const QColor& shadowColor() const {
46  return shadowColor_;
47  }
48  void setMargins(QSize margins) {
49  margins_ = margins.expandedTo(QSize(0, 0));
50  }
51 
52 private:
53  void drawText(QPainter* painter, QStyleOptionViewItem& opt, QRectF& textRect) const;
54 
55 private:
56  QListView* view_;
57  QIcon symlinkIcon_;
58  QColor shadowColor_;
59  QSize margins_;
60 };
61 
62 }
63 
64 #endif // PCMANFM_DESKTOPITEMDELEGATE_H
Definition: desktopitemdelegate.h:33