summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-23 03:01:51 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-23 03:01:51 (GMT)
commite488b62271d89bb4056ad9b98903f8530917a4a0 (patch)
tree90f7e6d0ba3ff56c47e42848ae5eb33af45b135b /src/gui/itemviews
parent3fa7e7d082de97abfb50d28f25f22185deabd82d (diff)
parentf50f94512a22b311277ba07e09cf59e2c73bb25c (diff)
downloadQt-e488b62271d89bb4056ad9b98903f8530917a4a0.zip
Qt-e488b62271d89bb4056ad9b98903f8530917a4a0.tar.gz
Qt-e488b62271d89bb4056ad9b98903f8530917a4a0.tar.bz2
Merge remote branch 'origin/4.7' into oslo-staging-1
Conflicts: src/gui/itemviews/qabstractitemview.cpp
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp4
-rw-r--r--src/gui/itemviews/qitemselectionmodel.cpp88
-rw-r--r--src/gui/itemviews/qitemselectionmodel_p.h2
3 files changed, 31 insertions, 63 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 7a1ea10..d7ddf4e 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -104,7 +104,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()
horizontalScrollMode(QAbstractItemView::ScrollPerItem),
currentIndexSet(false),
wrapItemText(false),
- delayedPendingLayout(false),
+ delayedPendingLayout(true)
moveCursorUpdatedView(false)
{
}
@@ -132,8 +132,6 @@ void QAbstractItemViewPrivate::init()
viewport->setBackgroundRole(QPalette::Base);
- doDelayedItemsLayout();
-
q->setAttribute(Qt::WA_InputMethodEnabled);
#ifdef QT_SOFTKEYS_ENABLED
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index cab002e..d6e68f6 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -527,6 +527,27 @@ void QItemSelection::split(const QItemSelectionRange &range,
}
}
+
+void QItemSelectionModelPrivate::initModel(QAbstractItemModel *model)
+{
+ this->model = model;
+ if (model) {
+ Q_Q(QItemSelectionModel);
+ QObject::connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+ q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+ QObject::connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
+ q, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));
+ QObject::connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
+ q, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int)));
+ QObject::connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
+ q, SLOT(_q_columnsAboutToBeInserted(QModelIndex,int,int)));
+ QObject::connect(model, SIGNAL(layoutAboutToBeChanged()),
+ q, SLOT(_q_layoutAboutToBeChanged()));
+ QObject::connect(model, SIGNAL(layoutChanged()),
+ q, SLOT(_q_layoutChanged()));
+ }
+}
+
/*!
\internal
@@ -793,6 +814,10 @@ static QItemSelection mergeIndexes(const QList<QPersistentModelIndex> &indexes)
while (++i < colSpans.count()) {
QModelIndex nextTl = colSpans.at(i).topLeft();
QModelIndex nextBr = colSpans.at(i).bottomRight();
+
+ if (nextTl.parent() != tl.parent())
+ break; // we can't merge selection ranges from different parents
+
if ((nextTl.column() == prevTl.column()) && (nextBr.column() == br.column())
&& (nextTl.row() == prevTl.row() + 1) && (nextBr.row() == br.row() + 1)) {
br = nextBr;
@@ -890,21 +915,7 @@ void QItemSelectionModelPrivate::_q_layoutChanged()
QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model)
: QObject(*new QItemSelectionModelPrivate, model)
{
- d_func()->model = model;
- if (model) {
- connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
- connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));
- connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int)));
- connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(_q_columnsAboutToBeInserted(QModelIndex,int,int)));
- connect(model, SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(_q_layoutAboutToBeChanged()));
- connect(model, SIGNAL(layoutChanged()),
- this, SLOT(_q_layoutChanged()));
- }
+ d_func()->initModel(model);
}
/*!
@@ -913,21 +924,7 @@ QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model)
QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model, QObject *parent)
: QObject(*new QItemSelectionModelPrivate, parent)
{
- d_func()->model = model;
- if (model) {
- connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
- connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));
- connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int)));
- connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(_q_columnsAboutToBeInserted(QModelIndex,int,int)));
- connect(model, SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(_q_layoutAboutToBeChanged()));
- connect(model, SIGNAL(layoutChanged()),
- this, SLOT(_q_layoutChanged()));
- }
+ d_func()->initModel(model);
}
/*!
@@ -936,21 +933,7 @@ QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model, QObject *par
QItemSelectionModel::QItemSelectionModel(QItemSelectionModelPrivate &dd, QAbstractItemModel *model)
: QObject(dd, model)
{
- d_func()->model = model;
- if (model) {
- connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
- connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));
- connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int)));
- connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(_q_columnsAboutToBeInserted(QModelIndex,int,int)));
- connect(model, SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(_q_layoutAboutToBeChanged()));
- connect(model, SIGNAL(layoutChanged()),
- this, SLOT(_q_layoutChanged()));
- }
+ dd.initModel(model);
}
/*!
@@ -958,21 +941,6 @@ QItemSelectionModel::QItemSelectionModel(QItemSelectionModelPrivate &dd, QAbstra
*/
QItemSelectionModel::~QItemSelectionModel()
{
- Q_D(QItemSelectionModel);
- if (d->model) {
- disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
- disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));
- disconnect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int)));
- disconnect(d->model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(_q_columnsAboutToBeInserted(QModelIndex,int,int)));
- disconnect(d->model, SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(_q_layoutAboutToBeChanged()));
- disconnect(d->model, SIGNAL(layoutChanged()),
- this, SLOT(_q_layoutChanged()));
- }
}
/*!
diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/gui/itemviews/qitemselectionmodel_p.h
index 30583b2..5afa90d 100644
--- a/src/gui/itemviews/qitemselectionmodel_p.h
+++ b/src/gui/itemviews/qitemselectionmodel_p.h
@@ -70,6 +70,8 @@ public:
QItemSelection expandSelection(const QItemSelection &selection,
QItemSelectionModel::SelectionFlags command) const;
+ void initModel(QAbstractItemModel *model);
+
void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
void _q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
void _q_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);