summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/itemviews.pri8
-rw-r--r--src/widgets/itemviews/qidentityproxymodel.cpp582
-rw-r--r--src/widgets/itemviews/qidentityproxymodel.h115
-rw-r--r--src/widgets/itemviews/qsortfilterproxymodel.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp20
-rw-r--r--src/widgets/kernel/qwidget_p.h1
-rw-r--r--src/widgets/platforms/s60/qwidget_s60.cpp5
-rw-r--r--src/widgets/to_be_moved/qlinecontrol.cpp2
-rw-r--r--src/widgets/to_be_moved/qlinecontrol_p.h8
-rw-r--r--src/widgets/widgets.pro2
-rw-r--r--src/widgets/widgets/qlineedit.cpp8
-rw-r--r--src/widgets/widgets/qlineedit.h5
12 files changed, 743 insertions, 15 deletions
diff --git a/src/widgets/itemviews/itemviews.pri b/src/widgets/itemviews/itemviews.pri
index bbc1e983ba..7ef704546e 100644
--- a/src/widgets/itemviews/itemviews.pri
+++ b/src/widgets/itemviews/itemviews.pri
@@ -4,6 +4,7 @@ HEADERS += \
itemviews/qabstractitemview.h \
itemviews/qabstractitemview_p.h \
itemviews/qheaderview.h \
+ itemviews/qidentityproxymodel.h \
itemviews/qlistview.h \
itemviews/qlistview_p.h \
itemviews/qbsptree_p.h \
@@ -12,14 +13,14 @@ HEADERS += \
itemviews/qtreeview.h \
itemviews/qtreeview_p.h \
itemviews/qabstractitemdelegate.h \
- itemviews/qitemdelegate.h \
+ itemviews/qitemdelegate.h \
itemviews/qitemselectionmodel.h \
itemviews/qitemselectionmodel_p.h \
itemviews/qdirmodel.h \
itemviews/qlistwidget.h \
itemviews/qlistwidget_p.h \
itemviews/qtablewidget.h \
- itemviews/qtablewidget_p.h \
+ itemviews/qtablewidget_p.h \
itemviews/qtreewidget.h \
itemviews/qtreewidget_p.h \
itemviews/qwidgetitemdata_p.h \
@@ -44,12 +45,13 @@ HEADERS += \
SOURCES += \
itemviews/qabstractitemview.cpp \
itemviews/qheaderview.cpp \
+ itemviews/qidentityproxymodel.cpp \
itemviews/qlistview.cpp \
itemviews/qbsptree.cpp \
itemviews/qtableview.cpp \
itemviews/qtreeview.cpp \
itemviews/qabstractitemdelegate.cpp \
- itemviews/qitemdelegate.cpp \
+ itemviews/qitemdelegate.cpp \
itemviews/qitemselectionmodel.cpp \
itemviews/qdirmodel.cpp \
itemviews/qlistwidget.cpp \
diff --git a/src/widgets/itemviews/qidentityproxymodel.cpp b/src/widgets/itemviews/qidentityproxymodel.cpp
new file mode 100644
index 0000000000..9396e6199a
--- /dev/null
+++ b/src/widgets/itemviews/qidentityproxymodel.cpp
@@ -0,0 +1,582 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB,
+** a KDAB Group company, info@kdab.com,
+** author Stephen Kelly <stephen.kelly@kdab.com>
+** All rights reserved.
+** Contact: Nokia Corporation (info@qt.nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+****************************************************************************/
+
+#include "qidentityproxymodel.h"
+
+#ifndef QT_NO_IDENTITYPROXYMODEL
+
+#include "qitemselectionmodel.h"
+#include <private/qabstractproxymodel_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QIdentityProxyModelPrivate : public QAbstractProxyModelPrivate
+{
+ QIdentityProxyModelPrivate()
+ : ignoreNextLayoutAboutToBeChanged(false),
+ ignoreNextLayoutChanged(false)
+ {
+
+ }
+
+ Q_DECLARE_PUBLIC(QIdentityProxyModel)
+
+ bool ignoreNextLayoutAboutToBeChanged;
+ bool ignoreNextLayoutChanged;
+ QList<QPersistentModelIndex> layoutChangePersistentIndexes;
+ QModelIndexList proxyIndexes;
+
+ void _q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+ void _q_sourceRowsInserted(const QModelIndex &parent, int start, int end);
+ void _q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+ void _q_sourceRowsRemoved(const QModelIndex &parent, int start, int end);
+ void _q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
+ void _q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
+
+ void _q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+ void _q_sourceColumnsInserted(const QModelIndex &parent, int start, int end);
+ void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+ void _q_sourceColumnsRemoved(const QModelIndex &parent, int start, int end);
+ void _q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
+ void _q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
+
+ void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last);
+
+ void _q_sourceLayoutAboutToBeChanged();
+ void _q_sourceLayoutChanged();
+ void _q_sourceModelAboutToBeReset();
+ void _q_sourceModelReset();
+
+};
+
+/*!
+ \since 4.8
+ \class QIdentityProxyModel
+ \brief The QIdentityProxyModel class proxies its source model unmodified
+
+ \ingroup model-view
+
+ QIdentityProxyModel can be used to forward the structure of a source model exactly, with no sorting, filtering or other transformation.
+ This is similar in concept to an identity matrix where A.I = A.
+
+ Because it does no sorting or filtering, this class is most suitable to proxy models which transform the data() of the source model.
+ For example, a proxy model could be created to define the font used, or the background colour, or the tooltip etc. This removes the
+ need to implement all data handling in the same class that creates the structure of the model, and can also be used to create
+ re-usable components.
+
+ This also provides a way to change the data in the case where a source model is supplied by a third party which can not be modified.
+
+ \snippet doc/src/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp 0
+
+ \sa QAbstractProxyModel, {Model/View Programming}, QAbstractItemModel
+
+*/
+
+/*!
+ Constructs an identity model with the given \a parent.
+*/
+QIdentityProxyModel::QIdentityProxyModel(QObject* parent)
+ : QAbstractProxyModel(*new QIdentityProxyModelPrivate, parent)
+{
+
+}
+
+/*! \internal
+ */
+QIdentityProxyModel::QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent)
+ : QAbstractProxyModel(dd, parent)
+{
+
+}
+
+/*!
+ Destroys this identity model.
+*/
+QIdentityProxyModel::~QIdentityProxyModel()
+{
+}
+
+/*!
+ \reimp
+ */
+int QIdentityProxyModel::columnCount(const QModelIndex& parent) const
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(const QIdentityProxyModel);
+ return d->model->columnCount(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->dropMimeData(data, action, row, column, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex& parent) const
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(const QIdentityProxyModel);
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+ const QModelIndex sourceParent = mapToSource(parent);
+ const QModelIndex sourceIndex = d->model->index(row, column, sourceParent);
+ Q_ASSERT(sourceIndex.isValid());
+ return mapFromSource(sourceIndex);
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->insertColumns(column, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->insertRows(row, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex& sourceIndex) const
+{
+ Q_D(const QIdentityProxyModel);
+ if (!d->model || !sourceIndex.isValid())
+ return QModelIndex();
+
+ Q_ASSERT(sourceIndex.model() == d->model);
+ return createIndex(sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer());
+}
+
+/*!
+ \reimp
+ */
+QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection& selection) const
+{
+ Q_D(const QIdentityProxyModel);
+ QItemSelection proxySelection;
+
+ if (!d->model)
+ return proxySelection;
+
+ QItemSelection::const_iterator it = selection.constBegin();
+ const QItemSelection::const_iterator end = selection.constEnd();
+ for ( ; it != end; ++it) {
+ Q_ASSERT(it->model() == d->model);
+ const QItemSelectionRange range(mapFromSource(it->topLeft()), mapFromSource(it->bottomRight()));
+ proxySelection.append(range);
+ }
+
+ return proxySelection;
+}
+
+/*!
+ \reimp
+ */
+QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection& selection) const
+{
+ Q_D(const QIdentityProxyModel);
+ QItemSelection sourceSelection;
+
+ if (!d->model)
+ return sourceSelection;
+
+ QItemSelection::const_iterator it = selection.constBegin();
+ const QItemSelection::const_iterator end = selection.constEnd();
+ for ( ; it != end; ++it) {
+ Q_ASSERT(it->model() == this);
+ const QItemSelectionRange range(mapToSource(it->topLeft()), mapToSource(it->bottomRight()));
+ sourceSelection.append(range);
+ }
+
+ return sourceSelection;
+}
+
+/*!
+ \reimp
+ */
+QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex& proxyIndex) const
+{
+ Q_D(const QIdentityProxyModel);
+ if (!d->model || !proxyIndex.isValid())
+ return QModelIndex();
+ Q_ASSERT(proxyIndex.model() == this);
+ return d->model->createIndex(proxyIndex.row(), proxyIndex.column(), proxyIndex.internalPointer());
+}
+
+/*!
+ \reimp
+ */
+QModelIndexList QIdentityProxyModel::match(const QModelIndex& start, int role, const QVariant& value, int hits, Qt::MatchFlags flags) const
+{
+ Q_D(const QIdentityProxyModel);
+ Q_ASSERT(start.isValid() ? start.model() == this : true);
+ if (!d->model)
+ return QModelIndexList();
+
+ const QModelIndexList sourceList = d->model->match(mapToSource(start), role, value, hits, flags);
+ QModelIndexList::const_iterator it = sourceList.constBegin();
+ const QModelIndexList::const_iterator end = sourceList.constEnd();
+ QModelIndexList proxyList;
+ for ( ; it != end; ++it)
+ proxyList.append(mapFromSource(*it));
+ return proxyList;
+}
+
+/*!
+ \reimp
+ */
+QModelIndex QIdentityProxyModel::parent(const QModelIndex& child) const
+{
+ Q_ASSERT(child.isValid() ? child.model() == this : true);
+ const QModelIndex sourceIndex = mapToSource(child);
+ const QModelIndex sourceParent = sourceIndex.parent();
+ return mapFromSource(sourceParent);
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->removeColumns(column, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->removeRows(row, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+int QIdentityProxyModel::rowCount(const QModelIndex& parent) const
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(const QIdentityProxyModel);
+ return d->model->rowCount(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+void QIdentityProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
+{
+ beginResetModel();
+
+ if (sourceModel) {
+ disconnect(sourceModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceRowsAboutToBeInserted(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceRowsInserted(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceRowsAboutToBeRemoved(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceRowsRemoved(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ this, SLOT(_q_sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ disconnect(sourceModel, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ this, SLOT(_q_sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ disconnect(sourceModel, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceColumnsAboutToBeInserted(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(columnsInserted(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceColumnsInserted(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceColumnsAboutToBeRemoved(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(columnsRemoved(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceColumnsRemoved(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ this, SLOT(_q_sourceColumnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ disconnect(sourceModel, SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ this, SLOT(_q_sourceColumnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ disconnect(sourceModel, SIGNAL(modelAboutToBeReset()),
+ this, SLOT(_q_sourceModelAboutToBeReset()));
+ disconnect(sourceModel, SIGNAL(modelReset()),
+ this, SLOT(_q_sourceModelReset()));
+ disconnect(sourceModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(_q_sourceDataChanged(const QModelIndex &, const QModelIndex &)));
+ disconnect(sourceModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+ this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
+ disconnect(sourceModel, SIGNAL(layoutAboutToBeChanged()),
+ this, SLOT(_q_sourceLayoutAboutToBeChanged()));
+ disconnect(sourceModel, SIGNAL(layoutChanged()),
+ this, SLOT(_q_sourceLayoutChanged()));
+ }
+
+ QAbstractProxyModel::setSourceModel(sourceModel);
+
+ if (sourceModel) {
+ connect(sourceModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
+ SLOT(_q_sourceRowsAboutToBeInserted(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
+ SLOT(_q_sourceRowsInserted(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
+ SLOT(_q_sourceRowsAboutToBeRemoved(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
+ SLOT(_q_sourceRowsRemoved(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ SLOT(_q_sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ connect(sourceModel, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ SLOT(_q_sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ connect(sourceModel, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)),
+ SLOT(_q_sourceColumnsAboutToBeInserted(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(columnsInserted(const QModelIndex &, int, int)),
+ SLOT(_q_sourceColumnsInserted(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)),
+ SLOT(_q_sourceColumnsAboutToBeRemoved(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(columnsRemoved(const QModelIndex &, int, int)),
+ SLOT(_q_sourceColumnsRemoved(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ SLOT(_q_sourceColumnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ connect(sourceModel, SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ SLOT(_q_sourceColumnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ connect(sourceModel, SIGNAL(modelAboutToBeReset()),
+ SLOT(_q_sourceModelAboutToBeReset()));
+ connect(sourceModel, SIGNAL(modelReset()),
+ SLOT(_q_sourceModelReset()));
+ connect(sourceModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
+ SLOT(_q_sourceDataChanged(const QModelIndex &, const QModelIndex &)));
+ connect(sourceModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+ SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
+ connect(sourceModel, SIGNAL(layoutAboutToBeChanged()),
+ SLOT(_q_sourceLayoutAboutToBeChanged()));
+ connect(sourceModel, SIGNAL(layoutChanged()),
+ SLOT(_q_sourceLayoutChanged()));
+ }
+
+ endResetModel();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginInsertColumns(q->mapFromSource(parent), start, end);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
+{
+ Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true);
+ Q_ASSERT(destParent.isValid() ? destParent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginMoveColumns(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginRemoveColumns(q->mapFromSource(parent), start, end);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(parent)
+ Q_UNUSED(start)
+ Q_UNUSED(end)
+ q->endInsertColumns();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
+{
+ Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true);
+ Q_ASSERT(destParent.isValid() ? destParent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(sourceParent)
+ Q_UNUSED(sourceStart)
+ Q_UNUSED(sourceEnd)
+ Q_UNUSED(destParent)
+ Q_UNUSED(dest)
+ q->endMoveColumns();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(parent)
+ Q_UNUSED(start)
+ Q_UNUSED(end)
+ q->endRemoveColumns();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{
+ Q_ASSERT(topLeft.isValid() ? topLeft.model() == model : true);
+ Q_ASSERT(bottomRight.isValid() ? bottomRight.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->dataChanged(q->mapFromSource(topLeft), q->mapFromSource(bottomRight));
+}
+
+void QIdentityProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last)
+{
+ Q_Q(QIdentityProxyModel);
+ q->headerDataChanged(orientation, first, last);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged()
+{
+ if (ignoreNextLayoutAboutToBeChanged)
+ return;
+
+ Q_Q(QIdentityProxyModel);
+
+ foreach(const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) {
+ proxyIndexes << proxyPersistentIndex;
+ Q_ASSERT(proxyPersistentIndex.isValid());
+ const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
+ Q_ASSERT(srcPersistentIndex.isValid());
+ layoutChangePersistentIndexes << srcPersistentIndex;
+ }
+
+ q->layoutAboutToBeChanged();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceLayoutChanged()
+{
+ if (ignoreNextLayoutChanged)
+ return;
+
+ Q_Q(QIdentityProxyModel);
+
+ for (int i = 0; i < proxyIndexes.size(); ++i) {
+ q->changePersistentIndex(proxyIndexes.at(i), q->mapFromSource(layoutChangePersistentIndexes.at(i)));
+ }
+
+ layoutChangePersistentIndexes.clear();
+ proxyIndexes.clear();
+
+ q->layoutChanged();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceModelAboutToBeReset()
+{
+ Q_Q(QIdentityProxyModel);
+ q->beginResetModel();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceModelReset()
+{
+ Q_Q(QIdentityProxyModel);
+ q->endResetModel();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginInsertRows(q->mapFromSource(parent), start, end);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
+{
+ Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true);
+ Q_ASSERT(destParent.isValid() ? destParent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginMoveRows(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginRemoveRows(q->mapFromSource(parent), start, end);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(parent)
+ Q_UNUSED(start)
+ Q_UNUSED(end)
+ q->endInsertRows();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
+{
+ Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true);
+ Q_ASSERT(destParent.isValid() ? destParent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(sourceParent)
+ Q_UNUSED(sourceStart)
+ Q_UNUSED(sourceEnd)
+ Q_UNUSED(destParent)
+ Q_UNUSED(dest)
+ q->endMoveRows();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(parent)
+ Q_UNUSED(start)
+ Q_UNUSED(end)
+ q->endRemoveRows();
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qidentityproxymodel.cpp"
+
+#endif // QT_NO_IDENTITYPROXYMODEL
diff --git a/src/widgets/itemviews/qidentityproxymodel.h b/src/widgets/itemviews/qidentityproxymodel.h
new file mode 100644
index 0000000000..9e38e747ea
--- /dev/null
+++ b/src/widgets/itemviews/qidentityproxymodel.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB,
+** a KDAB Group company, info@kdab.com,
+** author Stephen Kelly <stephen.kelly@kdab.com>
+** All rights reserved.
+** Contact: Nokia Corporation (info@qt.nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+****************************************************************************/
+
+
+#ifndef QIDENTITYPROXYMODEL_H
+#define QIDENTITYPROXYMODEL_H
+
+#include <QtWidgets/qabstractproxymodel.h>
+
+#ifndef QT_NO_IDENTITYPROXYMODEL
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QIdentityProxyModelPrivate;
+
+class Q_GUI_EXPORT QIdentityProxyModel : public QAbstractProxyModel
+{
+ Q_OBJECT
+public:
+ explicit QIdentityProxyModel(QObject* parent = 0);
+ ~QIdentityProxyModel();
+
+ int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
+ QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
+ QModelIndex mapToSource(const QModelIndex& proxyIndex) const;
+ QModelIndex parent(const QModelIndex& child) const;
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
+
+ QItemSelection mapSelectionFromSource(const QItemSelection& selection) const;
+ QItemSelection mapSelectionToSource(const QItemSelection& selection) const;
+ QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
+ void setSourceModel(QAbstractItemModel* sourceModel);
+
+ bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex());
+ bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
+ bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex());
+ bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
+
+protected:
+ QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent);
+
+private:
+ Q_DECLARE_PRIVATE(QIdentityProxyModel)
+ Q_DISABLE_COPY(QIdentityProxyModel)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex,QModelIndex))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last))
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceModelAboutToBeReset())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceModelReset())
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_IDENTITYPROXYMODEL
+
+#endif // QIDENTITYPROXYMODEL_H
+
diff --git a/src/widgets/itemviews/qsortfilterproxymodel.cpp b/src/widgets/itemviews/qsortfilterproxymodel.cpp
index eb56f56ed4..f73607ba8d 100644
--- a/src/widgets/itemviews/qsortfilterproxymodel.cpp
+++ b/src/widgets/itemviews/qsortfilterproxymodel.cpp
@@ -1502,7 +1502,7 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsRemoved(
\l{Model Subclassing Reference}.
\sa QAbstractProxyModel, QAbstractItemModel, {Model/View Programming},
- {Basic Sort/Filter Model Example}, {Custom Sort/Filter Model Example}
+ {Basic Sort/Filter Model Example}, {Custom Sort/Filter Model Example}, QIdentityProxyModel
*/
/*!
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 1728cfa57c..8c7e47cfdf 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -295,6 +295,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
#ifndef QT_NO_IM
, inheritsInputMethodHints(0)
#endif
+ , inSetParent(0)
#if defined(Q_WS_X11)
, picture(0)
#elif defined(Q_WS_WIN)
@@ -2568,6 +2569,22 @@ WId QWidget::effectiveWinId() const
if (id || !testAttribute(Qt::WA_WState_Created))
return id;
QWidget *realParent = nativeParentWidget();
+ if (!realParent && d_func()->inSetParent) {
+ // In transitional state. This is really just a workaround. The real problem
+ // is that QWidgetPrivate::setParent_sys (platform specific code) first sets
+ // the window id to 0 (setWinId(0)) before it sets the Qt::WA_WState_Created
+ // attribute to false. The correct way is to do it the other way around, and
+ // in that case the Qt::WA_WState_Created logic above will kick in and
+ // return 0 whenever the widget is in a transitional state. However, changing
+ // the original logic for all platforms is far more intrusive and might
+ // break existing applications.
+ // Note: The widget can only be in a transitional state when changing its
+ // parent -- everything else is an internal error -- hence explicitly checking
+ // against 'inSetParent' rather than doing an unconditional return whenever
+ // 'realParent' is 0 (which may cause strange artifacts and headache later).
+ return 0;
+ }
+ // This widget *must* have a native parent widget.
Q_ASSERT(realParent);
Q_ASSERT(realParent->internalWinId());
return realParent->internalWinId();
@@ -10080,6 +10097,7 @@ void QWidget::setParent(QWidget *parent)
void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
{
Q_D(QWidget);
+ d->inSetParent = true;
bool resized = testAttribute(Qt::WA_Resized);
bool wasCreated = testAttribute(Qt::WA_WState_Created);
QWidget *oldtlw = window();
@@ -10240,6 +10258,8 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
ancestorProxy->d_func()->embedSubWindow(this);
}
#endif
+
+ d->inSetParent = false;
}
/*!
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index e9d7682289..bb67efd090 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -769,6 +769,7 @@ public:
#ifndef QT_NO_IM
uint inheritsInputMethodHints : 1;
#endif
+ uint inSetParent : 1;
// *************************** Platform specific ************************************
#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
diff --git a/src/widgets/platforms/s60/qwidget_s60.cpp b/src/widgets/platforms/s60/qwidget_s60.cpp
index 12bcc4b4cc..24dd00a770 100644
--- a/src/widgets/platforms/s60/qwidget_s60.cpp
+++ b/src/widgets/platforms/s60/qwidget_s60.cpp
@@ -576,6 +576,11 @@ void QWidgetPrivate::show_sys()
if (isFullscreen) {
const bool cbaVisible = S60->buttonGroupContainer() && S60->buttonGroupContainer()->IsVisible();
S60->setStatusPaneAndButtonGroupVisibility(false, cbaVisible);
+ if (cbaVisible) {
+ // Fix window dimensions as without screen furniture they will have
+ // defaulted to full screen dimensions initially.
+ id->handleClientAreaChange();
+ }
}
}
}
diff --git a/src/widgets/to_be_moved/qlinecontrol.cpp b/src/widgets/to_be_moved/qlinecontrol.cpp
index eb4e142328..40ebb65d0a 100644
--- a/src/widgets/to_be_moved/qlinecontrol.cpp
+++ b/src/widgets/to_be_moved/qlinecontrol.cpp
@@ -1585,7 +1585,7 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
}
bool unknown = false;
- bool visual = cursorMoveStyle() == QTextCursor::Visual;
+ bool visual = cursorMoveStyle() == Qt::VisualMoveStyle;
if (false) {
}
diff --git a/src/widgets/to_be_moved/qlinecontrol_p.h b/src/widgets/to_be_moved/qlinecontrol_p.h
index a5de15ff8b..9e1adb6792 100644
--- a/src/widgets/to_be_moved/qlinecontrol_p.h
+++ b/src/widgets/to_be_moved/qlinecontrol_p.h
@@ -160,8 +160,8 @@ public:
int cursorWidth() const { return m_cursorWidth; }
void setCursorWidth(int value) { m_cursorWidth = value; }
- QTextCursor::MoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
- void setCursorMoveStyle(QTextCursor::MoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
+ Qt::CursorMoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
+ void setCursorMoveStyle(Qt::CursorMoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
void moveCursor(int pos, bool mark = false);
void cursorForward(bool mark, int steps)
@@ -169,11 +169,11 @@ public:
int c = m_cursor;
if (steps > 0) {
while (steps--)
- c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.rightCursorPosition(c)
+ c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c)
: m_textLayout.nextCursorPosition(c);
} else if (steps < 0) {
while (steps++)
- c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.leftCursorPosition(c)
+ c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c)
: m_textLayout.previousCursorPosition(c);
}
moveCursor(c, mark);
diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro
index d46e20fc32..671d7d3759 100644
--- a/src/widgets/widgets.pro
+++ b/src/widgets/widgets.pro
@@ -13,6 +13,8 @@ irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused
unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
+HEADERS += $$QT_SOURCE_TREE/src/widgets/qtwidgetsversion.h
+
include(../qbase.pri)
contains(QT_CONFIG, x11sm):CONFIG += x11sm
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 43c3f52d2b..3c9874ea4e 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1116,24 +1116,24 @@ void QLineEdit::setDragEnabled(bool b)
\brief the movement style of cursor in this line edit
\since 4.8
- When this property is set to QTextCursor::Visual, the line edit will use visual
+ When this property is set to Qt::VisualMoveStyle, the line edit will use visual
movement style. Pressing the left arrow key will always cause the cursor to move
left, regardless of the text's writing direction. The same behavior applies to
right arrow key.
- When the property is QTextCursor::Logical (the default), within a LTR text block,
+ When the property is Qt::LogicalMoveStyle (the default), within a LTR text block,
increase cursor position when pressing left arrow key, decrease cursor position
when pressing the right arrow key. If the text block is right to left, the opposite
behavior applies.
*/
-QTextCursor::MoveStyle QLineEdit::cursorMoveStyle() const
+Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const
{
Q_D(const QLineEdit);
return d->control->cursorMoveStyle();
}
-void QLineEdit::setCursorMoveStyle(QTextCursor::MoveStyle style)
+void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style)
{
Q_D(QLineEdit);
d->control->setCursorMoveStyle(style);
diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h
index 7f7a7287fb..2718f71549 100644
--- a/src/widgets/widgets/qlineedit.h
+++ b/src/widgets/widgets/qlineedit.h
@@ -85,6 +85,7 @@ class Q_GUI_EXPORT QLineEdit : public QWidget
Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
+ Q_PROPERTY(Qt::CursorMoveStyle cursorMoveStyle READ cursorMoveStyle WRITE setCursorMoveStyle)
public:
explicit QLineEdit(QWidget* parent=0);
@@ -159,8 +160,8 @@ public:
void setDragEnabled(bool b);
bool dragEnabled() const;
- void setCursorMoveStyle(QTextCursor::MoveStyle style);
- QTextCursor::MoveStyle cursorMoveStyle() const;
+ void setCursorMoveStyle(Qt::CursorMoveStyle style);
+ Qt::CursorMoveStyle cursorMoveStyle() const;
QString inputMask() const;
void setInputMask(const QString &inputMask);