diff options
author | Liang Qi <liang.qi@qt.io> | 2018-06-07 19:10:53 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-06-07 19:10:53 +0200 |
commit | 096e37910d93f9c52976600e985c615ea36fe291 (patch) | |
tree | 713d020f4a04f03d8ca6e111055e7eebe85953a8 /examples/sql/books/bookdelegate.cpp | |
parent | 88eda007a3b5046999dd0b287634765efcd8934d (diff) | |
parent | a14a943f9ac3d1e85514d7fb6688c84e624ac850 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
.qmake.conf
src/corelib/kernel/qeventdispatcher_cf.mm
src/gui/kernel/qguiapplication_p.h
src/gui/kernel/qwindowsysteminterface.cpp
src/gui/kernel/qwindowsysteminterface.h
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/cocoa/qnswindowdelegate.mm
src/plugins/platforms/ios/qioseventdispatcher.mm
src/plugins/platforms/windows/qwindowsdrag.h
src/plugins/platforms/windows/qwindowsinternalmimedata.h
src/plugins/platforms/windows/qwindowsmime.cpp
src/plugins/platforms/winrt/qwinrtscreen.cpp
Change-Id: Ic817f265c2386e83839d2bb9ef7419cb29705246
Diffstat (limited to 'examples/sql/books/bookdelegate.cpp')
-rw-r--r-- | examples/sql/books/bookdelegate.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/examples/sql/books/bookdelegate.cpp b/examples/sql/books/bookdelegate.cpp index 6a42fd2db7..4115f80cf3 100644 --- a/examples/sql/books/bookdelegate.cpp +++ b/examples/sql/books/bookdelegate.cpp @@ -62,15 +62,21 @@ void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, { if (index.column() != 5) { QStyleOptionViewItem opt = option; - opt.rect.adjust(0, 0, -1, -1); // since we draw the grid ourselves + // Since we draw the grid ourselves: + opt.rect.adjust(0, 0, -1, -1); QSqlRelationalDelegate::paint(painter, opt, index); } else { const QAbstractItemModel *model = index.model(); QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ? - (option.state & QStyle::State_Active) ? QPalette::Normal : QPalette::Inactive : QPalette::Disabled; + (option.state & QStyle::State_Active) ? + QPalette::Normal : + QPalette::Inactive : + QPalette::Disabled; if (option.state & QStyle::State_Selected) - painter->fillRect(option.rect, option.palette.color(cg, QPalette::Highlight)); + painter->fillRect( + option.rect, + option.palette.color(cg, QPalette::Highlight)); int rating = model->data(index, Qt::DisplayRole).toInt(); int width = star.width(); @@ -81,7 +87,8 @@ void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->drawPixmap(x, y, star); x += width; } - drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1)); // since we draw the grid ourselves + // Since we draw the grid ourselves: + drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1)); } QPen pen = painter->pen(); @@ -96,8 +103,8 @@ QSize BookDelegate::sizeHint(const QStyleOptionViewItem &option, { if (index.column() == 5) return QSize(5 * star.width(), star.height()) + QSize(1, 1); - - return QSqlRelationalDelegate::sizeHint(option, index) + QSize(1, 1); // since we draw the grid ourselves + // Since we draw the grid ourselves: + return QSqlRelationalDelegate::sizeHint(option, index) + QSize(1, 1); } bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, @@ -112,19 +119,21 @@ bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, int stars = qBound(0, int(0.7 + qreal(mouseEvent->pos().x() - option.rect.x()) / star.width()), 5); model->setData(index, QVariant(stars)); - return false; //so that the selection can change + // So that the selection can change: + return false; } return true; } -QWidget *BookDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, +QWidget *BookDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.column() != 4) return QSqlRelationalDelegate::createEditor(parent, option, index); - // for editing the year, return a spinbox with a range from -1000 to 2100. + // For editing the year, return a spinbox with a range from -1000 to 2100. QSpinBox *sb = new QSpinBox(parent); sb->setFrame(false); sb->setMaximum(2100); @@ -132,4 +141,3 @@ QWidget *BookDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem return sb; } - |