chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | #ifndef SKLISTWIDGET_H_ |
| 11 | #define SKLISTWIDGET_H_ |
| 12 | |
| 13 | #include <QAbstractItemDelegate> |
| 14 | #include <QPainter> |
| 15 | |
| 16 | /** \class SkListWidget |
| 17 | |
| 18 | This widget contains the draw commands. |
| 19 | */ |
| 20 | class SkListWidget : public QAbstractItemDelegate { |
| 21 | public: |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 22 | enum IndexStyle { |
| 23 | kIndex_IndexStyle, |
| 24 | kOffset_IndexStyle, |
| 25 | }; |
| 26 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 27 | /** |
| 28 | Constructs the list widget with the specified parent for layout purposes. |
| 29 | @param parent The parent container of this widget |
| 30 | */ |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 31 | SkListWidget(QObject* parent = NULL) : fIndexStyle(kIndex_IndexStyle) {} |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 32 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 33 | virtual ~SkListWidget() {} |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | Draws the current state of the widget. Overriden from QWidget. |
| 37 | */ |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 38 | void paint(QPainter* painter, const QStyleOptionViewItem& option, |
| 39 | const QModelIndex& index ) const; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | Returns the default size of the widget. Overriden from QWidget. |
| 43 | */ |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 44 | QSize sizeHint(const QStyleOptionViewItem& option, |
| 45 | const QModelIndex& index) const; |
| 46 | |
| 47 | |
| 48 | void setIndexStyle(IndexStyle indexStyle) { |
| 49 | fIndexStyle = indexStyle; |
| 50 | } |
| 51 | |
| 52 | protected: |
| 53 | IndexStyle fIndexStyle; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | #endif |