From c42a969b2fecc117f0c77fded008cc1b4f897bb3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 9 Jan 2012 13:01:23 +0100 Subject: [PATCH] Rename internal method check to doCheck Mac OSX has a check macro in /usr/include/AssertMacros.h which can conflict with this API if used together. http://boost.2283326.n4.nabble.com/Boost-with-Darwin-Mac-gcc-4-0-1-td2580330.html Change-Id: I93ddd08fa2b51b198bbc02ce501d79ed97a32c34 Reviewed-by: Rohan McGovern Reviewed-by: Lars Knoll --- src/widgets/itemviews/qitemdelegate.cpp | 22 +++++----------------- src/widgets/itemviews/qitemdelegate.h | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp index 200d99b212..e130953c38 100644 --- a/src/widgets/itemviews/qitemdelegate.cpp +++ b/src/widgets/itemviews/qitemdelegate.cpp @@ -468,7 +468,7 @@ void QItemDelegate::paint(QPainter *painter, value = index.data(Qt::CheckStateRole); if (value.isValid()) { checkState = static_cast(value.toInt()); - checkRect = check(opt, opt.rect, value); + checkRect = doCheck(opt, opt.rect, value); } // do the layout @@ -625,7 +625,7 @@ void QItemDelegate::updateEditorGeometry(QWidget *editor, QString text = QItemDelegatePrivate::replaceNewLine(index.data(Qt::DisplayRole).toString()); QRect pixmapRect = QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect()); QRect textRect = textRectangle(0, option.rect, option.font, text); - QRect checkRect = check(option, textRect, index.data(Qt::CheckStateRole)); + QRect checkRect = doCheck(option, textRect, index.data(Qt::CheckStateRole)); QStyleOptionViewItem opt = option; opt.showDecorationSelected = true; // let the editor take up all available space doLayout(opt, &checkRect, &pixmapRect, &textRect, false); @@ -1079,7 +1079,7 @@ QRect QItemDelegate::rect(const QStyleOptionViewItem &option, Q_D(const QItemDelegate); QVariant value = index.data(role); if (role == Qt::CheckStateRole) - return check(option, option.rect, value); + return doCheck(option, option.rect, value); if (value.isValid() && !value.isNull()) { switch (value.type()) { case QVariant::Invalid: @@ -1109,20 +1109,8 @@ QRect QItemDelegate::rect(const QStyleOptionViewItem &option, /*! \internal - - Note that on Mac, if /usr/include/AssertMacros.h is included prior - to QItemDelegate, and the application is building in debug mode, the - check(assertion) will conflict with QItemDelegate::check. - - To avoid this problem, add - - #ifdef check - #undef check - #endif - - after including AssertMacros.h */ -QRect QItemDelegate::check(const QStyleOptionViewItem &option, +QRect QItemDelegate::doCheck(const QStyleOptionViewItem &option, const QRect &bounding, const QVariant &value) const { if (value.isValid()) { @@ -1280,7 +1268,7 @@ bool QItemDelegate::editorEvent(QEvent *event, if ((event->type() == QEvent::MouseButtonRelease) || (event->type() == QEvent::MouseButtonDblClick) || (event->type() == QEvent::MouseButtonPress)) { - QRect checkRect = check(option, option.rect, Qt::Checked); + QRect checkRect = doCheck(option, option.rect, Qt::Checked); QRect emptyRect; doLayout(option, &checkRect, &emptyRect, &emptyRect, false); QMouseEvent *me = static_cast(event); diff --git a/src/widgets/itemviews/qitemdelegate.h b/src/widgets/itemviews/qitemdelegate.h index 9e21686b8b..5ea6b33f2d 100644 --- a/src/widgets/itemviews/qitemdelegate.h +++ b/src/widgets/itemviews/qitemdelegate.h @@ -120,7 +120,7 @@ protected: QPixmap decoration(const QStyleOptionViewItem &option, const QVariant &variant) const; QPixmap *selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const; - QRect check(const QStyleOptionViewItem &option, const QRect &bounding, + QRect doCheck(const QStyleOptionViewItem &option, const QRect &bounding, const QVariant &variant) const; QRect textRectangle(QPainter *painter, const QRect &rect, const QFont &font, const QString &text) const;