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