Rename internal method check to doCheck
authorStephen Kelly <stephen.kelly@kdab.com>
Mon, 9 Jan 2012 12:01:23 +0000 (13:01 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 10 Jan 2012 15:11:59 +0000 (16:11 +0100)
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 <rohan.mcgovern@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/widgets/itemviews/qitemdelegate.cpp
src/widgets/itemviews/qitemdelegate.h

index 200d99b..e130953 100644 (file)
@@ -468,7 +468,7 @@ void QItemDelegate::paint(QPainter *painter,
     value = index.data(Qt::CheckStateRole);
     if (value.isValid()) {
         checkState = static_cast<Qt::CheckState>(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<QMouseEvent*>(event);
index 9e21686..5ea6b33 100644 (file)
@@ -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;