Qt Labs Forum » ModelTest

ModelTest Bug

(2 posts)
  • Started 3 months ago by bradhowes
  • Latest reply from Benjamin Meyer

  1. I'm using the ModelTest class from Trolltech Labs to great results. However, one failure it threw I do not think is correct. Specifically, the check for valid alignment flags from QAbstractItemModel::data() is incorrect, as it is only checking horizontal values. Instead, I think it should just check if the returned value contains bits outside of the mask created by Qt::AlignHorizontal_Mask & Qt::AlignVertical_Mask, like so:

    Index: modeltest.cpp
    ===================================================================
    --- modeltest.cpp	(revision 1436)
    +++ modeltest.cpp	(working copy)
    @@ -421,17 +421,8 @@
         QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlignmentRole);
         if (textAlignmentVariant.isValid()) {
             int alignment = textAlignmentVariant.toInt();
    -        Q_ASSERT(alignment == Qt::AlignLeft ||
    -                 alignment == Qt::AlignRight ||
    -                 alignment == Qt::AlignHCenter ||
    -                 alignment == Qt::AlignJustify ||
    -                 alignment == Qt::AlignTop ||
    -                 alignment == Qt::AlignBottom ||
    -                 alignment == Qt::AlignVCenter ||
    -                 alignment == Qt::AlignCenter ||
    -                 alignment == Qt::AlignAbsolute ||
    -                 alignment == Qt::AlignLeading ||
    -                 alignment == Qt::AlignTrailing);
    +	Q_ASSERT( alignment == ( alignment & ( Qt::AlignHorizontal_Mask |
    +					       Qt::AlignVertical_Mask ) ) );
         }
    
         // General Purpose roles that should return a QColor
    

    Brad

    Posted: 3 months #
  2. Benjamin Meyer
    Benjamin Meyer
    Administrator

    Thanks, I have updated the modeltest with that patch.

    Posted: 3 months #

RSS feed for this topic

Reply

You must log in to post.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.