src/gui/itemviews/qitemselectionmodel.cpp File Reference

#include "qitemselectionmodel.h"
#include <private/qitemselectionmodel_p.h>
#include <qdebug.h>
#include "moc_qitemselectionmodel.cpp"

Include dependency graph for qitemselectionmodel.cpp:

Go to the source code of this file.

Functions

static QItemSelection mergeIndexes (const QList< QPersistentModelIndex > &indexes)
QDebug operator<< (QDebug dbg, const QItemSelectionRange &range)


Function Documentation

static QItemSelection mergeIndexes ( const QList< QPersistentModelIndex > &  indexes  )  [static]

Definition at line 684 of file qitemselectionmodel.cpp.

References QList< T >::append(), QList< T >::at(), QItemSelectionRange::bottomRight(), QModelIndex::column(), QList< T >::count(), i, next, QModelIndex::parent(), QModelIndex::row(), and QItemSelectionRange::topLeft().

Referenced by QItemSelectionModelPrivate::_q_layoutChanged().

00685 {
00686     QItemSelection colSpans;
00687     // merge columns
00688     int i = 0;
00689     while (i < indexes.count()) {
00690         QModelIndex tl = indexes.at(i);
00691         QModelIndex br = tl;
00692         while (++i < indexes.count()) {
00693             QModelIndex next = indexes.at(i);
00694             if ((next.parent() == br.parent())
00695                  && (next.row() == br.row())
00696                  && (next.column() == br.column() + 1))
00697                 br = next;
00698             else
00699                 break;
00700         }
00701         colSpans.append(QItemSelectionRange(tl, br));
00702     }
00703     // merge rows
00704     QItemSelection rowSpans;
00705     i = 0;
00706     while (i < colSpans.count()) {
00707         QModelIndex tl = colSpans.at(i).topLeft();
00708         QModelIndex br = colSpans.at(i).bottomRight();
00709         QModelIndex prevTl = tl;
00710         while (++i < colSpans.count()) {
00711             QModelIndex nextTl = colSpans.at(i).topLeft();
00712             QModelIndex nextBr = colSpans.at(i).bottomRight();
00713             if ((nextTl.column() == prevTl.column()) && (nextBr.column() == br.column())
00714                 && (nextTl.row() == prevTl.row() + 1) && (nextBr.row() == br.row() + 1)) {
00715                 br = nextBr;
00716                 prevTl = nextTl;
00717             } else {
00718                 break;
00719             }
00720         }
00721         rowSpans.append(QItemSelectionRange(tl, br));
00722     }
00723     return rowSpans;
00724 }

Here is the call graph for this function:

QDebug operator<< ( QDebug  dbg,
const QItemSelectionRange range 
)

Definition at line 1428 of file qitemselectionmodel.cpp.

01429 {
01430 #ifndef Q_BROKEN_DEBUG_STREAM
01431     dbg.nospace() << "QItemSelectionRange(" << range.topLeft()
01432                   << "," << range.bottomRight() << ")";
01433     return dbg.space();
01434 #else
01435     qWarning("This compiler doesn't support streaming QItemSelectionRange to QDebug");
01436     return dbg;
01437     Q_UNUSED(range);
01438 #endif
01439 }


Generated on Thu Mar 15 13:22:48 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1