diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-11-22 21:21:25 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-12-04 07:00:44 +0000 |
commit | 1cfe064632099e036f964832c23afe266e54d59e (patch) | |
tree | da3fe64e73993b8df89547f7db1fa53625ae04f8 /examples/widgets/itemviews/stardelegate/stardelegate.cpp | |
parent | 51f6d5d8c261fb94adc9bf5754cabf8e37236af5 (diff) |
Cleanup StarDelegate example
Cleanup the StarDelegate example:
- use QStyledItemDelegate instead QItemDelegate
- use nullptr and other useful c++11 constructs
- include the correct headers
Change-Id: If2f65fe7cbdcdd4571d10ffa98d36eeab7836bbb
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Luca Beldi <v.ronin@yahoo.it>
Diffstat (limited to 'examples/widgets/itemviews/stardelegate/stardelegate.cpp')
-rw-r--r-- | examples/widgets/itemviews/stardelegate/stardelegate.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/examples/widgets/itemviews/stardelegate/stardelegate.cpp b/examples/widgets/itemviews/stardelegate/stardelegate.cpp index da5902a160..41ae5a920f 100644 --- a/examples/widgets/itemviews/stardelegate/stardelegate.cpp +++ b/examples/widgets/itemviews/stardelegate/stardelegate.cpp @@ -65,7 +65,7 @@ void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->fillRect(option.rect, option.palette.highlight()); starRating.paint(painter, option.rect, option.palette, - StarRating::ReadOnly); + StarRating::EditMode::ReadOnly); } else { QStyledItemDelegate::paint(painter, option, index); } @@ -79,9 +79,8 @@ QSize StarDelegate::sizeHint(const QStyleOptionViewItem &option, if (index.data().canConvert<StarRating>()) { StarRating starRating = qvariant_cast<StarRating>(index.data()); return starRating.sizeHint(); - } else { - return QStyledItemDelegate::sizeHint(option, index); } + return QStyledItemDelegate::sizeHint(option, index); } //! [1] @@ -96,9 +95,8 @@ QWidget *StarDelegate::createEditor(QWidget *parent, connect(editor, &StarEditor::editingFinished, this, &StarDelegate::commitAndCloseEditor); return editor; - } else { - return QStyledItemDelegate::createEditor(parent, option, index); } + return QStyledItemDelegate::createEditor(parent, option, index); } //! [2] |