summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@sosco.com>2009-08-20 17:36:13 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2009-08-20 17:36:13 (GMT)
commit4ba5a86f530e93c179c9049d36b2f38595a5ef09 (patch)
tree6ce937f760164e2fc8822ba04625af103a49dec0 /src/corelib
parentfdda7f1dd01215e36116aa4e3428aae9f23dd711 (diff)
parentef1335b1ab76fb3ee1082b5abab66b43fa45df1d (diff)
downloadQt-4ba5a86f530e93c179c9049d36b2f38595a5ef09.zip
Qt-4ba5a86f530e93c179c9049d36b2f38595a5ef09.tar.gz
Qt-4ba5a86f530e93c179c9049d36b2f38595a5ef09.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qvariantanimation.cpp15
-rw-r--r--src/corelib/animation/qvariantanimation_p.h2
-rw-r--r--src/corelib/codecs/qtextcodec.cpp1
-rw-r--r--src/corelib/concurrent/qtconcurrentmap.cpp2
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/global/qlibraryinfo.cpp2
-rw-r--r--src/corelib/io/qdir.cpp2
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher_p.h2
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp836
-rw-r--r--src/corelib/kernel/qmetaobject.cpp102
-rw-r--r--src/corelib/kernel/qmetaobject_p.h74
-rw-r--r--src/corelib/kernel/qobject.cpp335
-rw-r--r--src/corelib/kernel/qobject_p.h3
-rw-r--r--src/corelib/kernel/qobjectdefs.h8
-rw-r--r--src/corelib/kernel/qvariant.cpp4
-rw-r--r--src/corelib/kernel/qvariant.h1
-rw-r--r--src/corelib/kernel/qvariant_p.h3
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h2
-rw-r--r--src/corelib/tools/qdatetime.cpp5
-rw-r--r--src/corelib/tools/qdatetime.h4
-rw-r--r--src/corelib/tools/qdatetime_p.h4
-rw-r--r--src/corelib/tools/qregexp.cpp3
-rw-r--r--src/corelib/tools/qshareddata.h4
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h2
-rw-r--r--src/corelib/xml/qxmlstream.cpp6
25 files changed, 815 insertions, 609 deletions
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index fc11815..696a95a 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -137,7 +137,6 @@ QT_BEGIN_NAMESPACE
\sa currentValue
*/
-
static bool animationValueLessThan(const QVariantAnimation::KeyValue &p1, const QVariantAnimation::KeyValue &p2)
{
return p1.first < p2.first;
@@ -178,11 +177,8 @@ template<> Q_INLINE_TEMPLATE QLineF _q_interpolate(const QLineF &f, const QLineF
return QLineF( _q_interpolate(f.p1(), t.p1(), progress), _q_interpolate(f.p2(), t.p2(), progress));
}
-QVariantAnimationPrivate::QVariantAnimationPrivate() : duration(250), interpolator(&defaultInterpolator),
- changedSignalMask(1 << QVariantAnimation::staticMetaObject.indexOfSignal("valueChanged(QVariant)"))
-{
- //we keep the mask so that we emit valueChanged only when needed (for performance reasons)
-}
+QVariantAnimationPrivate::QVariantAnimationPrivate() : duration(250), interpolator(&defaultInterpolator)
+{ }
void QVariantAnimationPrivate::convertValues(int t)
{
@@ -278,7 +274,12 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
localProgress);
qSwap(currentValue, ret);
q->updateCurrentValue(currentValue);
- if ((connectedSignals[0] & changedSignalMask) && currentValue != ret) {
+ static QBasicAtomicInt changedSignalIndex = Q_BASIC_ATOMIC_INITIALIZER(0);
+ if (!changedSignalIndex) {
+ //we keep the mask so that we emit valueChanged only when needed (for performance reasons)
+ changedSignalIndex.testAndSetRelaxed(0, signalIndex("valueChanged(QVariant)"));
+ }
+ if (isSignalConnected(changedSignalIndex) && currentValue != ret) {
//the value has changed
emit q->valueChanged(currentValue);
}
diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h
index ef57a4c..ce625f1 100644
--- a/src/corelib/animation/qvariantanimation_p.h
+++ b/src/corelib/animation/qvariantanimation_p.h
@@ -93,8 +93,6 @@ public:
QVariantAnimation::Interpolator interpolator;
- const quint32 changedSignalMask;
-
void setCurrentValueForProgress(const qreal progress);
void recalculateCurrentInterval(bool force=false);
void setValueAt(qreal, const QVariant &);
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 4915c39..039e801 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -709,6 +709,7 @@ static void setup()
(void)new QJisCodec;
(void)new QSjisCodec;
(void)new QEucKrCodec;
+ (void)new QCP949Codec;
(void)new QBig5Codec;
(void)new QBig5hkscsCodec;
# endif // QT_NO_ICONV && !QT_BOOTSTRAPPED
diff --git a/src/corelib/concurrent/qtconcurrentmap.cpp b/src/corelib/concurrent/qtconcurrentmap.cpp
index 3fd044d..243921a 100644
--- a/src/corelib/concurrent/qtconcurrentmap.cpp
+++ b/src/corelib/concurrent/qtconcurrentmap.cpp
@@ -1,4 +1,4 @@
- /****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 6722418..7dbbc1b 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -2026,7 +2026,7 @@ inline void qSwap(T &value1, T &value2)
template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
{ \
- qSwap<TYPE::DataPtr>(value1.data_ptr(), value2.data_ptr()); \
+ qSwap(value1.data_ptr(), value2.data_ptr()); \
}
/*
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index c8cf6dc..0e654af 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -473,7 +473,7 @@ QT_END_NAMESPACE
extern const char qt_core_interpreter[] __attribute__((section(".interp")))
= ELF_INTERPRETER;
-extern "C"
+extern "C" void qt_core_boilerplate();
void qt_core_boilerplate()
{
printf("This is the QtCore library version " QT_VERSION_STR "\n"
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 91d41f1..f9a1aca 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -2447,7 +2447,7 @@ QDebug operator<<(QDebug debug, QDir::Filters filters)
return debug;
}
-QDebug operator<<(QDebug debug, QDir::SortFlags sorting)
+static QDebug operator<<(QDebug debug, QDir::SortFlags sorting)
{
if (sorting == QDir::NoSort) {
debug << "QDir::SortFlags(NoSort)";
diff --git a/src/corelib/kernel/qabstracteventdispatcher_p.h b/src/corelib/kernel/qabstracteventdispatcher_p.h
index 86c9d79..dc69265 100644
--- a/src/corelib/kernel/qabstracteventdispatcher_p.h
+++ b/src/corelib/kernel/qabstracteventdispatcher_p.h
@@ -58,6 +58,8 @@
QT_BEGIN_NAMESPACE
+Q_CORE_EXPORT uint qGlobalPostedEventsCount();
+
class Q_CORE_EXPORT QAbstractEventDispatcherPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QAbstractEventDispatcher)
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index d6d1bcf..17af60d 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -251,8 +251,9 @@ QPersistentModelIndex::operator const QModelIndex&() const
Returns true if this persistent model index refers to the same location as
the \a other model index; otherwise returns false.
- Note that all values in the persistent model index are used when comparing
- with another model index.
+
+ All values in the persistent model index are used when comparing with
+ another model index.
*/
bool QPersistentModelIndex::operator==(const QModelIndex &other) const
@@ -335,10 +336,10 @@ qint64 QPersistentModelIndex::internalId() const
}
/*!
- Returns the parent QModelIndex for this persistent index, or
- QModelIndex() if it has no parent.
+ Returns the parent QModelIndex for this persistent index, or an invalid
+ QModelIndex if it has no parent.
- \sa child() sibling() model()
+ \sa child() sibling() model()
*/
QModelIndex QPersistentModelIndex::parent() const
{
@@ -348,10 +349,10 @@ QModelIndex QPersistentModelIndex::parent() const
}
/*!
- Returns the sibling at \a row and \a column or an invalid
- QModelIndex if there is no sibling at this position.
+ Returns the sibling at \a row and \a column or an invalid QModelIndex if
+ there is no sibling at this position.
- \sa parent() child()
+ \sa parent() child()
*/
QModelIndex QPersistentModelIndex::sibling(int row, int column) const
@@ -362,10 +363,10 @@ QModelIndex QPersistentModelIndex::sibling(int row, int column) const
}
/*!
- Returns the child of the model index that is stored in the given
- \a row and \a column.
+ Returns the child of the model index that is stored in the given \a row
+ and \a column.
- \sa parent() sibling()
+ \sa parent() sibling()
*/
QModelIndex QPersistentModelIndex::child(int row, int column) const
@@ -376,9 +377,10 @@ QModelIndex QPersistentModelIndex::child(int row, int column) const
}
/*!
- Returns the data for the given \a role for the item referred to by the index.
+ Returns the data for the given \a role for the item referred to by the
+ index.
- \sa Qt::ItemDataRole, QAbstractItemModel::setData()
+ \sa Qt::ItemDataRole, QAbstractItemModel::setData()
*/
QVariant QPersistentModelIndex::data(int role) const
{
@@ -388,9 +390,9 @@ QVariant QPersistentModelIndex::data(int role) const
}
/*!
- \since 4.2
+ \since 4.2
- Returns the flags for the item referred to by the index.
+ Returns the flags for the item referred to by the index.
*/
Qt::ItemFlags QPersistentModelIndex::flags() const
{
@@ -400,7 +402,7 @@ Qt::ItemFlags QPersistentModelIndex::flags() const
}
/*!
- Returns the model that the index belongs to.
+ Returns the model that the index belongs to.
*/
const QAbstractItemModel *QPersistentModelIndex::model() const
{
@@ -414,7 +416,9 @@ const QAbstractItemModel *QPersistentModelIndex::model() const
Returns true if this persistent model index is valid; otherwise returns
false.
- A valid index belongs to a model, and has non-negative row and column numbers.
+
+ A valid index belongs to a model, and has non-negative row and column
+ numbers.
\sa model(), row(), column()
*/
@@ -760,44 +764,42 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
selection models to locate an item in the model.
New QModelIndex objects are created by the model using the
- QAbstractItemModel::createIndex() function. An \e invalid model index
- can be constructed with the QModelIndex constructor. Invalid indexes are
- often used as parent indexes when referring to top-level items in a model.
+ QAbstractItemModel::createIndex() function. An \e invalid model index can
+ be constructed with the QModelIndex constructor. Invalid indexes are often
+ used as parent indexes when referring to top-level items in a model.
Model indexes refer to items in models, and contain all the information
required to specify their locations in those models. Each index is located
- in a given row and column, and may have a parent index; use row(), column(),
- and parent() to obtain this information. Each top-level item in a model is
- represented by a model index that does not have a parent index - in this
- case, parent() will return an invalid model index, equivalent to an index
- constructed with the zero argument form of the QModelIndex() constructor.
+ in a given row and column, and may have a parent index; use row(),
+ column(), and parent() to obtain this information. Each top-level item in a
+ model is represented by a model index that does not have a parent index -
+ in this case, parent() will return an invalid model index, equivalent to an
+ index constructed with the zero argument form of the QModelIndex()
+ constructor.
To obtain a model index that refers to an existing item in a model, call
- QAbstractItemModel::index() with the required row and column
- values, and the model index of the parent. When referring to
- top-level items in a model, supply QModelIndex() as the parent index.
+ QAbstractItemModel::index() with the required row and column values, and
+ the model index of the parent. When referring to top-level items in a
+ model, supply QModelIndex() as the parent index.
The model() function returns the model that the index references as a
- QAbstractItemModel.
- The child() function is used to examine the items held beneath the index
- in the model.
- The sibling() function allows you to traverse items in the model on the
- same level as the index.
+ QAbstractItemModel. The child() function is used to examine items held
+ under the index in the model. The sibling() function allows you to traverse
+ items in the model on the same level as the index.
\note Model indexes should be used immediately and then discarded. You
should not rely on indexes to remain valid after calling model functions
that change the structure of the model or delete items. If you need to
keep a model index over time use a QPersistentModelIndex.
- \sa \link model-view-programming.html Model/View Programming\endlink QPersistentModelIndex QAbstractItemModel
+ \sa {Model/View Programming}, QPersistentModelIndex, QAbstractItemModel
*/
/*!
\fn QModelIndex::QModelIndex()
- Creates a new empty model index.
- This type of model index is used to indicate
- that the position in the model is invalid.
+ Creates a new empty model index. This type of model index is used to
+ indicate that the position in the model is invalid.
\sa isValid() QAbstractItemModel
*/
@@ -860,7 +862,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
\fn bool QModelIndex::isValid() const
Returns true if this model index is valid; otherwise returns false.
- A valid index belongs to a model, and has non-negative row and column numbers.
+
+ A valid index belongs to a model, and has non-negative row and column
+ numbers.
\sa model(), row(), column()
*/
@@ -871,33 +875,34 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
Returns a pointer to the model containing the item that this index
refers to.
- You receive a const pointer to the model because calls to
- non-const functions of the model might invalidate the model index
- - and possibly crash your application.
+ A const pointer to the model is returned because calls to non-const
+ functions of the model might invalidate the model index and possibly
+ crash your application.
*/
/*!
\fn QModelIndex QModelIndex::sibling(int row, int column) const
- Returns the sibling at \a row and \a column or an invalid
- QModelIndex if there is no sibling at this position.
+ Returns the sibling at \a row and \a column. If there is no sibling at this
+ position, an invalid QModelIndex is returned.
- \sa parent() child()
+ \sa parent(), child()
*/
/*!
\fn QModelIndex QModelIndex::child(int row, int column) const
- Returns the child of the model index that is stored in the given
- \a row and \a column.
+ Returns the child of the model index that is stored in the given \a row and
+ \a column.
- \sa parent() sibling()
+ \sa parent(), sibling()
*/
/*!
\fn QVariant QModelIndex::data(int role) const
- Returns the data for the given \a role for the item referred to by the index.
+ Returns the data for the given \a role for the item referred to by the
+ index.
*/
/*!
@@ -910,28 +915,29 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
/*!
\fn bool QModelIndex::operator==(const QModelIndex &other) const
- Returns true if this model index refers to the same location as
- the \a other model index; otherwise returns false.
- Note that all values in the model index are used when comparing
- with another model index.
+ Returns true if this model index refers to the same location as the
+ \a other model index; otherwise returns false.
+
+ All values in the model index are used when comparing with another model
+ index.
*/
/*!
\fn bool QModelIndex::operator!=(const QModelIndex &other) const
- Returns true if this model index does not refer to the same
- location as the \a other model index; otherwise returns false.
+ Returns true if this model index does not refer to the same location as
+ the \a other model index; otherwise returns false.
*/
/*!
- \fn QModelIndex QModelIndex::parent() const
+ \fn QModelIndex QModelIndex::parent() const
- Returns the parent of the model index, or QModelIndex() if it has no
- parent.
+ Returns the parent of the model index, or QModelIndex() if it has no
+ parent.
- \sa child() sibling() model()
+ \sa child(), sibling(), model()
*/
/*!
@@ -960,7 +966,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
simple table of rows and columns. Each item has a unique index specified by
a QModelIndex.
- \img modelindex-no-parent.png
+ \image modelindex-no-parent.png
Every item of data that can be accessed via a model has an associated model
index. You can obtain this model index using the index() function. Each
@@ -1078,9 +1084,8 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
\sa {Model Classes}, {Model Subclassing Reference}, QModelIndex,
QAbstractItemView, {Using Drag and Drop with Item Views},
- {Simple DOM Model Example},
- {Simple Tree Model Example}, {Editable Tree Model Example},
- {Fetch More Example}
+ {Simple DOM Model Example}, {Simple Tree Model Example},
+ {Editable Tree Model Example}, {Fetch More Example}
*/
/*!
@@ -1089,8 +1094,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
Returns the index of the item in the model specified by the given \a row,
\a column and \a parent index.
- When reimplementing this function in a subclass, call createIndex() to generate
- model indexes that other components can use to refer to items in your model.
+ When reimplementing this function in a subclass, call createIndex() to
+ generate model indexes that other components can use to refer to items in
+ your model.
\sa createIndex()
*/
@@ -1099,8 +1105,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
\fn bool QAbstractItemModel::insertColumn(int column, const QModelIndex &parent)
Inserts a single column before the given \a column in the child items of
- the \a parent specified. Returns true if the column is inserted; otherwise
- returns false.
+ the \a parent specified.
+
+ Returns true if the column is inserted; otherwise returns false.
\sa insertColumns() insertRow() removeColumn()
*/
@@ -1109,8 +1116,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
\fn bool QAbstractItemModel::insertRow(int row, const QModelIndex &parent)
Inserts a single row before the given \a row in the child items of the
- \a parent specified. Returns true if the row is inserted; otherwise
- returns false.
+ \a parent specified.
+
+ Returns true if the row is inserted; otherwise returns false.
\sa insertRows() insertColumn() removeRow()
*/
@@ -1123,17 +1131,18 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
/*!
\fn QModelIndex QAbstractItemModel::parent(const QModelIndex &index) const = 0
- Returns the parent of the model item with the given \a index, or QModelIndex()
- if it has no parent.
+ Returns the parent of the model item with the given \a index. If the model
+ has no parent, an invalid QModelIndex is returned.
A common convention used in models that expose tree data structures is that
- only items in the first column have children. For that case, when reimplementing
- this function in a subclass the column of the returned QModelIndex would be 0.
+ only items in the first column have children. For that case, when
+ reimplementing this function in a subclass the column of the returned
+ QModelIndex would be 0.
- \note When reimplementing this function in a subclass, be careful to avoid
+ When reimplementing this function in a subclass, be careful to avoid
calling QModelIndex member functions, such as QModelIndex::parent(), since
- indexes belonging to your model will simply call your implementation, leading
- to infinite recursion.
+ indexes belonging to your model will simply call your implementation,
+ leading to infinite recursion.
\sa createIndex()
*/
@@ -1141,7 +1150,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
/*!
\fn bool QAbstractItemModel::removeColumn(int column, const QModelIndex &parent)
- Removes the given \a column from the child items of the \a parent specified.
+ Removes the given \a column from the child items of the \a parent
+ specified.
+
Returns true if the column is removed; otherwise returns false.
\sa removeColumns(), removeRow(), insertColumn()
@@ -1151,10 +1162,11 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
\fn bool QAbstractItemModel::removeRow(int row, const QModelIndex &parent)
Removes the given \a row from the child items of the \a parent specified.
+
Returns true if the row is removed; otherwise returns false.
- The removeRow() is a convenience function that calls removeRows().
- The QAbstractItemModel implementation of removeRows does nothing.
+ This is a convenience function that calls removeRows(). The
+ QAbstractItemModel implementation of removeRows() does nothing.
\sa removeRows(), removeColumn(), insertRow()
*/
@@ -1166,13 +1178,12 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
indicates whether the horizontal or vertical header has changed. The
sections in the header from the \a first to the \a last need to be updated.
- Note that this signal must be emitted explicitly when
- reimplementing the setHeaderData() function.
+ When reimplementing the setHeaderData() function, this signal must be
+ emitted explicitly.
- If you are changing the number of columns or rows you don't need
- to emit this signal, but use the begin/end functions (see the
- section on subclassing in the QAbstractItemModel class description
- for details).
+ If you are changing the number of columns or rows you do not need to emit
+ this signal, but use the begin/end functions (refer to the section on
+ subclassing in the QAbstractItemModel class description for details).
\sa headerData(), setHeaderData(), dataChanged()
*/
@@ -1182,8 +1193,8 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
\since 4.2
This signal is emitted just before the layout of a model is changed.
- Components connected to this signal use it to adapt to changes
- in the model's layout.
+ Components connected to this signal use it to adapt to changes in the
+ model's layout.
Subclasses should update any persistent model indexes after emitting
layoutAboutToBeChanged().
@@ -1195,19 +1206,20 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
\fn void QAbstractItemModel::layoutChanged()
This signal is emitted whenever the layout of items exposed by the model
- has changed; for example, when the model has been sorted. When this signal is
- received by a view, it should update the layout of items to reflect this
+ has changed; for example, when the model has been sorted. When this signal
+ is received by a view, it should update the layout of items to reflect this
change.
- When subclassing QAbstractItemModel or QAbstractProxyModel, ensure that
- you emit layoutAboutToBeChanged() before changing the order of items or
+ When subclassing QAbstractItemModel or QAbstractProxyModel, ensure that you
+ emit layoutAboutToBeChanged() before changing the order of items or
altering the structure of the data you expose to views, and emit
layoutChanged() after changing the layout.
- Subclasses should update any persistent model indexes before
- emitting layoutChanged().
+ Subclasses should update any persistent model indexes before emitting
+ layoutChanged().
- \sa layoutAboutToBeChanged(), dataChanged(), headerDataChanged(), reset(), changePersistentIndex()
+ \sa layoutAboutToBeChanged(), dataChanged(), headerDataChanged(), reset(),
+ changePersistentIndex()
*/
/*!
@@ -1237,12 +1249,12 @@ QAbstractItemModel::~QAbstractItemModel()
/*!
\fn QModelIndex QAbstractItemModel::sibling(int row, int column, const QModelIndex &index) const
- Returns the sibling at \a row and \a column for the item at \a index, or
- an invalid QModelIndex if there is no sibling at that location.
+ Returns the sibling at \a row and \a column for the item at \a index, or an
+ invalid QModelIndex if there is no sibling at that location.
sibling() is just a convenience function that finds the item's parent, and
- uses it to retrieve the index of the child item in the specified \a row
- and \a column.
+ uses it to retrieve the index of the child item in the specified \a row and
+ \a column.
\sa index(), QModelIndex::row(), QModelIndex::column()
*/
@@ -1251,11 +1263,11 @@ QAbstractItemModel::~QAbstractItemModel()
/*!
\fn int QAbstractItemModel::rowCount(const QModelIndex &parent) const
- Returns the number of rows under the given \a parent. When the parent
- is valid it means that rowCount is returning the number of children of parent.
+ Returns the number of rows under the given \a parent. When the parent is
+ valid it means that rowCount is returning the number of children of parent.
- \bold{Tip:} When implementing a table based model, rowCount() should return 0 when
- the parent is valid.
+ \note When implementing a table based model, rowCount() should return 0
+ when the parent is valid.
\sa columnCount()
*/
@@ -1265,13 +1277,14 @@ QAbstractItemModel::~QAbstractItemModel()
Returns the number of columns for the children of the given \a parent.
- In most subclasses, the number of columns is independent of the
- \a parent. For example:
+ In most subclasses, the number of columns is independent of the \a parent.
+
+ For example:
\snippet examples/itemviews/simpledommodel/dommodel.cpp 2
- \bold{Tip:} When implementing a table based model, columnCount() should return 0 when
- the parent is valid.
+ \note When implementing a table based model, columnCount() should return 0
+ when the parent is valid.
\sa rowCount()
*/
@@ -1298,8 +1311,8 @@ QAbstractItemModel::~QAbstractItemModel()
model. The new items are those between \a start and \a end
inclusive, under the given \a parent item.
- \bold{Note:} Components connected to this signal use it to adapt to changes
- in the model's dimensions. It can only be emitted by the QAbstractItemModel
+ \note Components connected to this signal use it to adapt to changes in the
+ model's dimensions. It can only be emitted by the QAbstractItemModel
implementation, and cannot be explicitly emitted in subclass code.
\sa insertRows(), beginInsertRows()
@@ -1308,11 +1321,11 @@ QAbstractItemModel::~QAbstractItemModel()
/*!
\fn void QAbstractItemModel::rowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
- This signal is emitted just before rows are inserted into the
- model. The new items will be positioned between \a start and \a end
- inclusive, under the given \a parent item.
+ This signal is emitted just before rows are inserted into the model. The
+ new items will be positioned between \a start and \a end inclusive, under
+ the given \a parent item.
- \bold{Note:} Components connected to this signal use it to adapt to changes
+ \note Components connected to this signal use it to adapt to changes
in the model's dimensions. It can only be emitted by the QAbstractItemModel
implementation, and cannot be explicitly emitted in subclass code.
@@ -1322,11 +1335,11 @@ QAbstractItemModel::~QAbstractItemModel()
/*!
\fn void QAbstractItemModel::rowsRemoved(const QModelIndex &parent, int start, int end)
- This signal is emitted after rows have been removed from the
- model. The removed items are those between \a start and \a end
- inclusive, under the given \a parent item.
+ This signal is emitted after rows have been removed from the model. The
+ removed items are those between \a start and \a end inclusive, under the
+ given \a parent item.
- \bold{Note:} Components connected to this signal use it to adapt to changes
+ \note Components connected to this signal use it to adapt to changes
in the model's dimensions. It can only be emitted by the QAbstractItemModel
implementation, and cannot be explicitly emitted in subclass code.
@@ -1336,11 +1349,11 @@ QAbstractItemModel::~QAbstractItemModel()
/*!
\fn void QAbstractItemModel::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
- This signal is emitted just before rows are removed from the
- model. The items that will be removed are those between \a start and \a end
- inclusive, under the given \a parent item.
+ This signal is emitted just before rows are removed from the model. The
+ items that will be removed are those between \a start and \a end inclusive,
+ under the given \a parent item.
- \bold{Note:} Components connected to this signal use it to adapt to changes
+ \note Components connected to this signal use it to adapt to changes
in the model's dimensions. It can only be emitted by the QAbstractItemModel
implementation, and cannot be explicitly emitted in subclass code.
@@ -1350,12 +1363,12 @@ QAbstractItemModel::~QAbstractItemModel()
/*!
\fn void QAbstractItemModel::columnsInserted(const QModelIndex &parent, int start, int end)
- This signal is emitted after columns have been inserted into the
- model. The new items are those between \a start and \a end
- inclusive, under the given \a parent item.
+ This signal is emitted after columns have been inserted into the model. The
+ new items are those between \a start and \a end inclusive, under the given
+ \a parent item.
- \bold{Note:} Components connected to this signal use it to adapt to changes
- in the model's dimensions. It can only be emitted by the QAbstractItemModel
+ \note Components connected to this signal use it to adapt to changes in the
+ model's dimensions. It can only be emitted by the QAbstractItemModel
implementation, and cannot be explicitly emitted in subclass code.
\sa insertColumns(), beginInsertColumns()
@@ -1364,12 +1377,12 @@ QAbstractItemModel::~QAbstractItemModel()
/*!
\fn void QAbstractItemModel::columnsAboutToBeInserted(const QModelIndex &parent, int start, int end)
- This signal is emitted just before columns are inserted into the
- model. The new items will be positioned between \a start and \a end
- inclusive, under the given \a parent item.
+ This signal is emitted just before columns are inserted into the model. The
+ new items will be positioned between \a start and \a end inclusive, under
+ the given \a parent item.
- \bold{Note:} Components connected to this signal use it to adapt to changes
- in the model's dimensions. It can only be emitted by the QAbstractItemModel
+ \note Components connected to this signal use it to adapt to changes in the
+ model's dimensions. It can only be emitted by the QAbstractItemModel
implementation, and cannot be explicitly emitted in subclass code.
\sa insertColumns(), beginInsertColumns()
@@ -1378,12 +1391,12 @@ QAbstractItemModel::~QAbstractItemModel()
/*!
\fn void QAbstractItemModel::columnsRemoved(const QModelIndex &parent, int start, int end)
- This signal is emitted after columns have been removed from the
- model. The removed items are those between \a start and \a end
- inclusive, under the given \a parent item.
+ This signal is emitted after columns have been removed from the model.
+ The removed items are those between \a start and \a end inclusive,
+ under the given \a parent item.
- \bold{Note:} Components connected to this signal use it to adapt to changes
- in the model's dimensions. It can only be emitted by the QAbstractItemModel
+ \note Components connected to this signal use it to adapt to changes in
+ the model's dimensions. It can only be emitted by the QAbstractItemModel
implementation, and cannot be explicitly emitted in subclass code.
\sa removeColumns(), beginRemoveColumns()
@@ -1392,20 +1405,20 @@ QAbstractItemModel::~QAbstractItemModel()
/*!
\fn void QAbstractItemModel::columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
- This signal is emitted just before columns are removed
- from the model. The items to be removed are those between \a start and
- \a end inclusive, under the given \a parent item.
+ This signal is emitted just before columns are removed from the model. The
+ items to be removed are those between \a start and \a end inclusive, under
+ the given \a parent item.
- \bold{Note:} Components connected to this signal use it to adapt to changes
- in the model's dimensions. It can only be emitted by the QAbstractItemModel
+ \note Components connected to this signal use it to adapt to changes in the
+ model's dimensions. It can only be emitted by the QAbstractItemModel
implementation, and cannot be explicitly emitted in subclass code.
\sa removeColumns(), beginRemoveColumns()
*/
/*!
- Returns true if the model returns a valid QModelIndex for \a row and
- \a column with \a parent, otherwise returns false.
+ Returns true if the model returns a valid QModelIndex for \a row and
+ \a column with \a parent, otherwise returns false.
*/
bool QAbstractItemModel::hasIndex(int row, int column, const QModelIndex &parent) const
{
@@ -1416,10 +1429,11 @@ bool QAbstractItemModel::hasIndex(int row, int column, const QModelIndex &parent
/*!
- Returns true if \a parent has any children; otherwise returns false.
- Use rowCount() on the parent to find out the number of children.
+ Returns true if \a parent has any children; otherwise returns false.
- \sa parent() index()
+ Use rowCount() on the parent to find out the number of children.
+
+ \sa parent() index()
*/
bool QAbstractItemModel::hasChildren(const QModelIndex &parent) const
{
@@ -1428,11 +1442,11 @@ bool QAbstractItemModel::hasChildren(const QModelIndex &parent) const
/*!
- Returns a map with values for all predefined roles in the model
- for the item at the given \a index.
+ Returns a map with values for all predefined roles in the model for the
+ item at the given \a index.
- Reimplemented this function if you want to extend the default behavior
- of this function to include custom roles in the map.
+ Reimplement this function if you want to extend the default behavior of
+ this function to include custom roles in the map.
\sa Qt::ItemDataRole, data()
*/
@@ -1449,14 +1463,14 @@ QMap<int, QVariant> QAbstractItemModel::itemData(const QModelIndex &index) const
/*!
Sets the \a role data for the item at \a index to \a value.
+
Returns true if successful; otherwise returns false.
- The dataChanged() signal should be emitted if the data was successfully set.
+ The dataChanged() signal should be emitted if the data was successfully
+ set.
- The base class implementation returns false. This function and
- data() must be reimplemented for editable models. Note that the
- dataChanged() signal must be emitted explicitly when
- reimplementing this function.
+ The base class implementation returns false. This function and data() must
+ be reimplemented for editable models.
\sa Qt::ItemDataRole, data(), itemData()
*/
@@ -1475,15 +1489,16 @@ bool QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value
by the \a index.
\note If you do not have a value to return, return an \bold invalid
- QVariant() instead of returning 0.
+ QVariant instead of returning 0.
\sa Qt::ItemDataRole, setData(), headerData()
*/
/*!
Sets the role data for the item at \a index to the associated value in
- \a roles, for every Qt::ItemDataRole. Returns true if successful; otherwise
- returns false.
+ \a roles, for every Qt::ItemDataRole.
+
+ Returns true if successful; otherwise returns false.
Roles that are not in \a roles will not be modified.
@@ -1498,8 +1513,8 @@ bool QAbstractItemModel::setItemData(const QModelIndex &index, const QMap<int, Q
}
/*!
- Returns a list of MIME types that can be used to describe a list of
- model indexes.
+ Returns a list of MIME types that can be used to describe a list of model
+ indexes.
\sa mimeData()
*/
@@ -1511,12 +1526,12 @@ QStringList QAbstractItemModel::mimeTypes() const
}
/*!
- Returns an object that contains serialized items of data corresponding to the
- list of \a indexes specified. The formats used to describe the encoded data
- is obtained from the mimeTypes() function.
+ Returns an object that contains serialized items of data corresponding to
+ the list of \a indexes specified. The formats used to describe the encoded
+ data is obtained from the mimeTypes() function.
- If the list of indexes is empty, or there are no supported MIME types,
- 0 is returned rather than a serialized empty list.
+ If the list of indexes is empty, or there are no supported MIME types, 0 is
+ returned rather than a serialized empty list.
\sa mimeTypes(), dropMimeData()
*/
@@ -1538,22 +1553,23 @@ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const
/*!
Handles the \a data supplied by a drag and drop operation that ended with
- the given \a action. Returns true if the data and action can be handled
- by the model; otherwise returns false.
+ the given \a action.
- Although the specified \a row, \a column and \a parent indicate the location of
- an item in the model where the operation ended, it is the responsibility of the
- view to provide a suitable location for where the data should be inserted.
+ Returns true if the data and action can be handled by the model; otherwise
+ returns false.
- For instance, a drop action on an item in a QTreeView can result in new items
- either being inserted as children of the item specified by \a row, \a column,
- and \a parent, or as siblings of the item.
+ Although the specified \a row, \a column and \a parent indicate the
+ location of an item in the model where the operation ended, it is the
+ responsibility of the view to provide a suitable location for where the
+ data should be inserted.
- When row and column are -1 it means that it is up to the model to decide
- where to place the data. This can occur in a tree when data is dropped
- on a parent. Models will usually append the data to the parent in this case.
+ For instance, a drop action on an item in a QTreeView can result in new
+ items either being inserted as children of the item specified by \a row,
+ \a column, and \a parent, or as siblings of the item.
- Returns true if the dropping was successful otherwise false.
+ When row and column are -1 it means that it is up to the model to decide
+ where to place the data. This can occur in a tree when data is dropped on
+ a parent. Models will usually append the data to the parent in this case.
\sa supportedDropActions(), {Using Drag and Drop with Item Views}
*/
@@ -1583,17 +1599,17 @@ bool QAbstractItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
}
/*!
- \since 4.2
+ \since 4.2
- Returns the drop actions supported by this model.
+ Returns the drop actions supported by this model.
- The default implementation returns Qt::CopyAction. Reimplement this
- function if you wish to support additional actions. Note that you
- must also reimplement the dropMimeData() function to handle the
- additional operations.
+ The default implementation returns Qt::CopyAction. Reimplement this
+ function if you wish to support additional actions. You must also
+ reimplement the dropMimeData() function to handle the additional
+ operations.
- \sa dropMimeData(), Qt::DropActions, {Using Drag and Drop with Item
- Views}
+ \sa dropMimeData(), Qt::DropActions, {Using Drag and Drop with Item
+ Views}
*/
Qt::DropActions QAbstractItemModel::supportedDropActions() const
{
@@ -1601,15 +1617,15 @@ Qt::DropActions QAbstractItemModel::supportedDropActions() const
}
/*!
- Returns the actions supported by the data in this model.
+ Returns the actions supported by the data in this model.
- The default implementation returns supportedDropActions() unless
- specific values have been set with setSupportedDragActions().
+ The default implementation returns supportedDropActions() unless specific
+ values have been set with setSupportedDragActions().
- supportedDragActions() is used by QAbstractItemView::startDrag() as
- the default values when a drag occurs.
+ supportedDragActions() is used by QAbstractItemView::startDrag() as the
+ default values when a drag occurs.
- \sa Qt::DropActions, {Using Drag and Drop with Item Views}
+ \sa Qt::DropActions, {Using Drag and Drop with Item Views}
*/
Qt::DropActions QAbstractItemModel::supportedDragActions() const
{
@@ -1634,25 +1650,28 @@ void QAbstractItemModel::setSupportedDragActions(Qt::DropActions actions)
}
/*!
- On models that support this, inserts \a count rows into the model before the
- given \a row. The items in the new row will be children of the item
- represented by the \a parent model index.
+ On models that support this, inserts \a count rows into the model before
+ the given \a row. Items in the new row will be children of the item
+ represented by the \a parent model index.
- If \a row is 0, the rows are prepended to any existing rows in the parent.
- If \a row is rowCount(), the rows are appended to any existing rows in the
- parent.
- If \a parent has no children, a single column with \a count rows is inserted.
+ If \a row is 0, the rows are prepended to any existing rows in the parent.
- Returns true if the rows were successfully inserted; otherwise returns
- false.
+ If \a row is rowCount(), the rows are appended to any existing rows in the
+ parent.
- The base class implementation does nothing and returns false.
+ If \a parent has no children, a single column with \a count rows is
+ inserted.
- If you implement your own model, you can reimplement this function
- if you want to support insertions. Alternatively, you can provide
- you own API for altering the data.
+ Returns true if the rows were successfully inserted; otherwise returns
+ false.
+
+ The base class implementation does nothing and returns false.
- \sa insertColumns(), removeRows(), beginInsertRows(), endInsertRows()
+ If you implement your own model, you can reimplement this function if you
+ want to support insertions. Alternatively, you can provide your own API for
+ altering the data.
+
+ \sa insertColumns(), removeRows(), beginInsertRows(), endInsertRows()
*/
bool QAbstractItemModel::insertRows(int, int, const QModelIndex &)
{
@@ -1660,25 +1679,28 @@ bool QAbstractItemModel::insertRows(int, int, const QModelIndex &)
}
/*!
- On models that support this, inserts \a count new columns into the model
- before the given \a column. The items in each new column will be children
- of the item represented by the \a parent model index.
+ On models that support this, inserts \a count new columns into the model
+ before the given \a column. The items in each new column will be children
+ of the item represented by the \a parent model index.
+
+ If \a column is 0, the columns are prepended to any existing columns.
+
+ If \a column is columnCount(), the columns are appended to any existing
+ columns.
- If \a column is 0, the columns are prepended to any existing columns.
- If \a column is columnCount(), the columns are appended to any existing
- columns.
- If \a parent has no children, a single row with \a count columns is inserted.
+ If \a parent has no children, a single row with \a count columns is
+ inserted.
- Returns true if the columns were successfully inserted; otherwise returns
- false.
+ Returns true if the columns were successfully inserted; otherwise returns
+ false.
- The base class implementation does nothing and returns false.
+ The base class implementation does nothing and returns false.
- If you implement your own model, you can reimplement this function
- if you want to support insertions. Alternatively, you can provide
- you own API for altering the data.
+ If you implement your own model, you can reimplement this function if you
+ want to support insertions. Alternatively, you can provide your own API for
+ altering the data.
- \sa insertRows(), removeColumns(), beginInsertColumns(), endInsertColumns()
+ \sa insertRows(), removeColumns(), beginInsertColumns(), endInsertColumns()
*/
bool QAbstractItemModel::insertColumns(int, int, const QModelIndex &)
{
@@ -1687,16 +1709,19 @@ bool QAbstractItemModel::insertColumns(int, int, const QModelIndex &)
/*!
On models that support this, removes \a count rows starting with the given
- \a row under parent \a parent from the model. Returns true if the rows
- were successfully removed; otherwise returns false.
+ \a row under parent \a parent from the model.
+
+ Returns true if the rows were successfully removed; otherwise returns
+ false.
The base class implementation does nothing and returns false.
- If you implement your own model, you can reimplement this function
- if you want to support removing. Alternatively, you can provide
- you own API for altering the data.
+ If you implement your own model, you can reimplement this function if you
+ want to support removing. Alternatively, you can provide your own API for
+ altering the data.
- \sa removeRow(), removeColumns(), insertColumns(), beginRemoveRows(), endRemoveRows()
+ \sa removeRow(), removeColumns(), insertColumns(), beginRemoveRows(),
+ endRemoveRows()
*/
bool QAbstractItemModel::removeRows(int, int, const QModelIndex &)
{
@@ -1705,16 +1730,19 @@ bool QAbstractItemModel::removeRows(int, int, const QModelIndex &)
/*!
On models that support this, removes \a count columns starting with the
- given \a column under parent \a parent from the model. Returns true if the
- columns were successfully removed; otherwise returns false.
+ given \a column under parent \a parent from the model.
+
+ Returns true if the columns were successfully removed; otherwise returns
+ false.
The base class implementation does nothing and returns false.
- If you implement your own model, you can reimplement this function
- if you want to support removing. Alternatively, you can provide
- you own API for altering the data.
+ If you implement your own model, you can reimplement this function if you
+ want to support removing. Alternatively, you can provide your own API for
+ altering the data.
- \sa removeColumn(), removeRows(), insertColumns(), beginRemoveColumns(), endRemoveColumns()
+ \sa removeColumn(), removeRows(), insertColumns(), beginRemoveColumns(),
+ endRemoveColumns()
*/
bool QAbstractItemModel::removeColumns(int, int, const QModelIndex &)
{
@@ -1737,9 +1765,9 @@ void QAbstractItemModel::fetchMore(const QModelIndex &)
}
/*!
- Returns true if there is more data available for \a parent; otherwise returns
- false.
-
+ Returns true if there is more data available for \a parent; otherwise
+ returns false.
+
The default implementation always returns false.
If canFetchMore() returns true, QAbstractItemView will call fetchMore().
@@ -1756,9 +1784,9 @@ bool QAbstractItemModel::canFetchMore(const QModelIndex &) const
/*!
Returns the item flags for the given \a index.
- The base class implementation returns a combination of flags that
- enables the item (\c ItemIsEnabled) and allows it to be
- selected (\c ItemIsSelectable).
+ The base class implementation returns a combination of flags that enables
+ the item (\c ItemIsEnabled) and allows it to be selected
+ (\c ItemIsSelectable).
\sa Qt::ItemFlags
*/
@@ -1784,12 +1812,13 @@ void QAbstractItemModel::sort(int column, Qt::SortOrder order)
}
/*!
- Returns a model index for the buddy of the item represented by \a index.
- When the user wants to edit an item, the view will call this function to
- check whether another item in the model should be edited instead, and
- construct a delegate using the model index returned by the buddy item.
+ Returns a model index for the buddy of the item represented by \a index.
+ When the user wants to edit an item, the view will call this function to
+ check whether another item in the model should be edited instead. Then, the
+ view will construct a delegate using the model index returned by the buddy
+ item.
- In the default implementation each item is its own buddy.
+ The default implementation of this function has each item as its own buddy.
*/
QModelIndex QAbstractItemModel::buddy(const QModelIndex &index) const
{
@@ -1797,23 +1826,23 @@ QModelIndex QAbstractItemModel::buddy(const QModelIndex &index) const
}
/*!
- Returns a list of indexes for the items in the column of the \a
- start index where the data stored under the given \a role matches
- the specified \a value. The way the search is performed is defined
- by the \a flags given. The list that is returned may be empty.
+ Returns a list of indexes for the items in the column of the \a start index
+ where data stored under the given \a role matches the specified \a value.
+ The way the search is performed is defined by the \a flags given. The list
+ that is returned may be empty.
- The search starts from the \a start index, and continues until the
- number of matching data items equals \a hits, the search reaches
- the last row, or the search reaches \a start again, depending on
- whether \c MatchWrap is specified in \a flags. If you want to search
- for all matching items, use \a hits = -1.
+ The search begins from the \a start index, and continues until the number
+ of matching data items equals \a hits, the search reaches the last row, or
+ the search reaches \a start again - depending on whether \c MatchWrap is
+ specified in \a flags. If you want to search for all matching items, use
+ \a hits = -1.
By default, this function will perform a wrapping, string-based comparison
on all items, searching for items that begin with the search term specified
by \a value.
-
- \note The default implementation of this function only searches columns,
- This function can be reimplemented to include other search behavior.
+
+ \note The default implementation of this function only searches columns.
+ Reimplement this function to include a different search behavior.
*/
QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role,
const QVariant &value, int hits,
@@ -1888,7 +1917,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role,
/*!
Returns the row and column span of the item represented by \a index.
- Note: span is not used currently, but will be in the future.
+ \note Currently, span is not used.
*/
QSize QAbstractItemModel::span(const QModelIndex &) const
@@ -1897,16 +1926,16 @@ QSize QAbstractItemModel::span(const QModelIndex &) const
}
/*!
- \since 4.6
-
- Sets the model's role names to \a roleNames.
+ \since 4.6
- This function is provided to allow mapping of role identifiers to
- role property names in Declarative UI. This function must be called
- before the model is used. Modifying the role names after the model
- has been set may result in undefined behaviour.
+ Sets the model's role names to \a roleNames.
- \sa roleNames()
+ This function allows mapping of role identifiers to role property names in
+ Declarative UI. This function must be called before the model is used.
+ Modifying the role names after the model has been set may result in
+ undefined behaviour.
+
+ \sa roleNames()
*/
void QAbstractItemModel::setRoleNames(const QHash<int,QByteArray> &roleNames)
{
@@ -1915,11 +1944,11 @@ void QAbstractItemModel::setRoleNames(const QHash<int,QByteArray> &roleNames)
}
/*!
- \since 4.6
+ \since 4.6
- Returns the model's role names.
+ Returns the model's role names.
- \sa setRoleNames()
+ \sa setRoleNames()
*/
const QHash<int,QByteArray> &QAbstractItemModel::roleNames() const
{
@@ -1928,10 +1957,12 @@ const QHash<int,QByteArray> &QAbstractItemModel::roleNames() const
}
/*!
- Called to let the model know that it should submit whatever it has cached
- to the permanent storage. Typically used for row editing.
+ Lets the model know that it should submit cached information to permanent
+ storage. This function is typically used for row editing.
+
+ Returns true if there is no error; otherwise returns false.
- Returns false on error, otherwise true.
+ \sa revert()
*/
bool QAbstractItemModel::submit()
@@ -1940,8 +1971,10 @@ bool QAbstractItemModel::submit()
}
/*!
- Called to let the model know that it should discard whatever it has cached.
- Typically used for row editing.
+ Lets the model know that it should discard cached information. This
+ function is typically used for row editing.
+
+ \sa submit()
*/
void QAbstractItemModel::revert()
@@ -1950,14 +1983,14 @@ void QAbstractItemModel::revert()
}
/*!
- Returns the data for the given \a role and \a section in the header
- with the specified \a orientation.
+ Returns the data for the given \a role and \a section in the header with
+ the specified \a orientation.
- For horizontal headers, the section number corresponds to the column
- number of items shown beneath it. For vertical headers, the section
- number typically to the row number of items shown alongside it.
+ For horizontal headers, the section number corresponds to the column
+ number. Similarly, for vertical headers, the section number corresponds to
+ the row number.
- \sa Qt::ItemDataRole, setHeaderData(), QHeaderView
+ \sa Qt::ItemDataRole, setHeaderData(), QHeaderView
*/
QVariant QAbstractItemModel::headerData(int section, Qt::Orientation orientation, int role) const
@@ -1969,14 +2002,15 @@ QVariant QAbstractItemModel::headerData(int section, Qt::Orientation orientation
}
/*!
- Sets the data for the given \a role and \a section in the header with
- the specified \a orientation to the \a value supplied.
- Returns true if the header's data was updated; otherwise returns false.
+ Sets the data for the given \a role and \a section in the header with the
+ specified \a orientation to the \a value supplied.
+
+ Returns true if the header's data was updated; otherwise returns false.
- Note that the headerDataChanged() signal must be emitted explicitly
- when reimplementing this function.
+ When reimplementing this function, the headerDataChanged() signal must be
+ emitted explicitly.
- \sa Qt::ItemDataRole, headerData()
+ \sa Qt::ItemDataRole, headerData()
*/
bool QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation,
@@ -1992,11 +2026,12 @@ bool QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation,
/*!
\fn QModelIndex QAbstractItemModel::createIndex(int row, int column, void *ptr) const
- Creates a model index for the given \a row and \a column with the internal pointer \a ptr.
+ Creates a model index for the given \a row and \a column with the internal
+ pointer \a ptr.
- Note that when you are using a QSortFilterProxyModel its indexes have their own
- internal pointer. It is not advisable to access the internal pointer in the index
- outside of the model. Use the data() function instead.
+ When using a QSortFilterProxyModel, its indexes have their own internal
+ pointer. It is not advisable to access this internal pointer outside of the
+ model. Use the data() function instead.
This function provides a consistent interface that model subclasses must
use to create model indexes.
@@ -2006,7 +2041,8 @@ bool QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation,
\fn QModelIndex QAbstractItemModel::createIndex(int row, int column, int id) const
\obsolete
- Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead.
+ Use QModelIndex
+ QAbstractItemModel::createIndex(int row, int column, quint32 id) instead.
*/
/*!
@@ -2017,6 +2053,7 @@ bool QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation,
This function provides a consistent interface that model subclasses must
use to create model indexes.
+
\sa QModelIndex::internalId()
*/
@@ -2120,34 +2157,41 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare
/*!
Begins a row insertion operation.
- When reimplementing insertRows() in a subclass, you must call this
- function \e before inserting data into the model's underlying data
- store.
+ When reimplementing insertRows() in a subclass, you must call this function
+ \e before inserting data into the model's underlying data store.
- The \a parent index corresponds to the parent into which the new
- rows are inserted; \a first and \a last are the row numbers that the
- new rows will have after they have been inserted.
+ The \a parent index corresponds to the parent into which the new rows are
+ inserted; \a first and \a last are the row numbers that the new rows will
+ have after they have been inserted.
\table 80%
- \row \o \inlineimage modelview-begin-insert-rows.png Inserting rows
- \o Specify the first and last row numbers for the span of rows
- you want to insert into an item in a model.
-
- For example, as shown in the diagram, we insert three rows before
- row 2, so \a first is 2 and \a last is 4:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 0
- This inserts the three new rows as rows 2, 3, and 4.
\row
- \o \inlineimage modelview-begin-append-rows.png Appending rows
- \o To append rows, insert them after the last row.
-
- For example, as shown in the diagram, we append two rows to a
- collection of 4 existing rows (ending in row 3), so \a first is 4
- and \a last is 5:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 1
- This appends the two new rows as rows 4 and 5.
+ \o \inlineimage modelview-begin-insert-rows.png Inserting rows
+ \o Specify the first and last row numbers for the span of rows you
+ want to insert into an item in a model.
+
+ For example, as shown in the diagram, we insert three rows before
+ row 2, so \a first is 2 and \a last is 4:
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 0
+
+ This inserts the three new rows as rows 2, 3, and 4.
+ \row
+ \o \inlineimage modelview-begin-append-rows.png Appending rows
+ \o To append rows, insert them after the last row.
+
+ For example, as shown in the diagram, we append two rows to a
+ collection of 4 existing rows (ending in row 3), so \a first is 4
+ and \a last is 5:
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 1
+
+ This appends the two new rows as rows 4 and 5.
\endtable
+ \note This function emits the rowsAboutToBeInserted() signal which
+ connected views (or proxies) must handle before the data is inserted.
+ Otherwise, the views may end up in an invalid state.
\sa endInsertRows()
*/
void QAbstractItemModel::beginInsertRows(const QModelIndex &parent, int first, int last)
@@ -2163,9 +2207,8 @@ void QAbstractItemModel::beginInsertRows(const QModelIndex &parent, int first, i
/*!
Ends a row insertion operation.
- When reimplementing insertRows() in a subclass, you must call this
- function \e after inserting data into the model's underlying data
- store.
+ When reimplementing insertRows() in a subclass, you must call this function
+ \e after inserting data into the model's underlying data store.
\sa beginInsertRows()
*/
@@ -2181,23 +2224,28 @@ void QAbstractItemModel::endInsertRows()
Begins a row removal operation.
When reimplementing removeRows() in a subclass, you must call this
- function \e before removing data from the model's underlying data
- store.
+ function \e before removing data from the model's underlying data store.
- The \a parent index corresponds to the parent from which the new
- rows are removed; \a first and \a last are the row numbers of the
- rows to be removed.
+ The \a parent index corresponds to the parent from which the new rows are
+ removed; \a first and \a last are the row numbers of the rows to be
+ removed.
\table 80%
- \row \o \inlineimage modelview-begin-remove-rows.png Removing rows
- \o Specify the first and last row numbers for the span of rows
- you want to remove from an item in a model.
+ \row
+ \o \inlineimage modelview-begin-remove-rows.png Removing rows
+ \o Specify the first and last row numbers for the span of rows you
+ want to remove from an item in a model.
+
+ For example, as shown in the diagram, we remove the two rows from
+ row 2 to row 3, so \a first is 2 and \a last is 3:
- For example, as shown in the diagram, we remove the two rows from
- row 2 to row 3, so \a first is 2 and \a last is 3:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 2
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 2
\endtable
+ \note This function emits the rowsAboutToBeRemoved() signal which connected
+ views (or proxies) must handle before the data is removed. Otherwise, the
+ views may end up in an invalid state.
+
\sa endRemoveRows()
*/
void QAbstractItemModel::beginRemoveRows(const QModelIndex &parent, int first, int last)
@@ -2213,9 +2261,8 @@ void QAbstractItemModel::beginRemoveRows(const QModelIndex &parent, int first, i
/*!
Ends a row removal operation.
- When reimplementing removeRows() in a subclass, you must call this
- function \e after removing data from the model's underlying data
- store.
+ When reimplementing removeRows() in a subclass, you must call this function
+ \e after removing data from the model's underlying data store.
\sa beginRemoveRows()
*/
@@ -2231,33 +2278,41 @@ void QAbstractItemModel::endRemoveRows()
Begins a column insertion operation.
When reimplementing insertColumns() in a subclass, you must call this
- function \e before inserting data into the model's underlying data
- store.
+ function \e before inserting data into the model's underlying data store.
- The \a parent index corresponds to the parent into which the new
- columns are inserted; \a first and \a last are the column numbers of
- the new columns will have after they have been inserted.
+ The \a parent index corresponds to the parent into which the new columns
+ are inserted; \a first and \a last are the column numbers of the new
+ columns will have after they have been inserted.
\table 80%
- \row \o \inlineimage modelview-begin-insert-columns.png Inserting columns
- \o Specify the first and last column numbers for the span of columns
- you want to insert into an item in a model.
-
- For example, as shown in the diagram, we insert three columns before
- column 4, so \a first is 4 and \a last is 6:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 3
- This inserts the three new columns as columns 4, 5, and 6.
\row
- \o \inlineimage modelview-begin-append-columns.png Appending columns
- \o To append columns, insert them after the last column.
-
- For example, as shown in the diagram, we append three columns to a
- collection of six existing columns (ending in column 5), so \a first
- is 6 and \a last is 8:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 4
- This appends the two new columns as columns 6, 7, and 8.
+ \o \inlineimage modelview-begin-insert-columns.png Inserting columns
+ \o Specify the first and last column numbers for the span of columns
+ you want to insert into an item in a model.
+
+ For example, as shown in the diagram, we insert three columns
+ before column 4, so \a first is 4 and \a last is 6:
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 3
+
+ This inserts the three new columns as columns 4, 5, and 6.
+ \row
+ \o \inlineimage modelview-begin-append-columns.png Appending columns
+ \o To append columns, insert them after the last column.
+
+ For example, as shown in the diagram, we append three columns to a
+ collection of six existing columns (ending in column 5), so
+ \a first is 6 and \a last is 8:
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 4
+
+ This appends the two new columns as columns 6, 7, and 8.
\endtable
+ \note This function emits the columnsAboutToBeInserted() signal which
+ connected views (or proxies) must handle before the data is inserted.
+ Otherwise, the views may end up in an invalid state.
+
\sa endInsertColumns()
*/
void QAbstractItemModel::beginInsertColumns(const QModelIndex &parent, int first, int last)
@@ -2291,23 +2346,28 @@ void QAbstractItemModel::endInsertColumns()
Begins a column removal operation.
When reimplementing removeColumns() in a subclass, you must call this
- function \e before removing data from the model's underlying data
- store.
+ function \e before removing data from the model's underlying data store.
- The \a parent index corresponds to the parent from which the new
- columns are removed; \a first and \a last are the column numbers of
- the first and last columns to be removed.
+ The \a parent index corresponds to the parent from which the new columns
+ are removed; \a first and \a last are the column numbers of the first and
+ last columns to be removed.
\table 80%
- \row \o \inlineimage modelview-begin-remove-columns.png Removing columns
- \o Specify the first and last column numbers for the span of columns
- you want to remove from an item in a model.
+ \row
+ \o \inlineimage modelview-begin-remove-columns.png Removing columns
+ \o Specify the first and last column numbers for the span of columns
+ you want to remove from an item in a model.
+
+ For example, as shown in the diagram, we remove the three columns
+ from column 4 to column 6, so \a first is 4 and \a last is 6:
- For example, as shown in the diagram, we remove the three columns
- from column 4 to column 6, so \a first is 4 and \a last is 6:
- \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 5
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 5
\endtable
+ \note This function emits the columnsAboutToBeRemoved() signal which
+ connected views (or proxies) must handle before the data is removed.
+ Otherwise, the views may end up in an invalid state.
+
\sa endRemoveColumns()
*/
void QAbstractItemModel::beginRemoveColumns(const QModelIndex &parent, int first, int last)
@@ -2324,8 +2384,7 @@ void QAbstractItemModel::beginRemoveColumns(const QModelIndex &parent, int first
Ends a column removal operation.
When reimplementing removeColumns() in a subclass, you must call this
- function \e after removing data from the model's underlying data
- store.
+ function \e after removing data from the model's underlying data store.
\sa beginRemoveColumns()
*/
@@ -2340,11 +2399,11 @@ void QAbstractItemModel::endRemoveColumns()
/*!
Resets the model to its original state in any attached views.
- \note The view to which the model is attached to will be reset as well.
+ The view to which the model is attached to will be reset as well.
When a model is reset it means that any previous data reported from the
- model is now invalid and has to be queried for again. This also means
- that the current item and any selected items will become invalid.
+ model is now invalid and has to be queried for again. This also means that
+ the current item and any selected items will become invalid.
When a model radically changes its data it can sometimes be easier to just
call this function rather than emit dataChanged() to inform other
@@ -2361,13 +2420,13 @@ void QAbstractItemModel::reset()
}
/*!
- Changes the QPersistentModelIndex that is equal to the given \a from
- model index to the given \a to model index.
+ Changes the QPersistentModelIndex that is equal to the given \a from model
+ index to the given \a to model index.
- If no persistent model index equal to the given \a from model index was
- found, nothing is changed.
+ If no persistent model index equal to the given \a from model index was
+ found, nothing is changed.
- \sa persistentIndexList(), changePersistentIndexList()
+ \sa persistentIndexList(), changePersistentIndexList()
*/
void QAbstractItemModel::changePersistentIndex(const QModelIndex &from, const QModelIndex &to)
{
@@ -2388,15 +2447,15 @@ void QAbstractItemModel::changePersistentIndex(const QModelIndex &from, const QM
}
/*!
- \since 4.1
+ \since 4.1
- Changes the QPersistentModelIndexes that is equal to the indexes in the given \a from
- model index list to the given \a to model index list.
+ Changes the QPersistentModelIndexes that is equal to the indexes in the
+ given \a from model index list to the given \a to model index list.
- If no persistent model indexes equal to the indexes in the given \a from model index list
- was found, nothing is changed.
+ If no persistent model indexes equal to the indexes in the given \a from
+ model index list was found, nothing is changed.
- \sa persistentIndexList(), changePersistentIndex()
+ \sa persistentIndexList(), changePersistentIndex()
*/
void QAbstractItemModel::changePersistentIndexList(const QModelIndexList &from,
const QModelIndexList &to)
@@ -2429,9 +2488,9 @@ void QAbstractItemModel::changePersistentIndexList(const QModelIndexList &from,
}
/*!
- \since 4.2
+ \since 4.2
- Returns the list of indexes stored as persistent indexes in the model.
+ Returns the list of indexes stored as persistent indexes in the model.
*/
QModelIndexList QAbstractItemModel::persistentIndexList() const
{
@@ -2458,10 +2517,10 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const
but must be subclassed.
Since the model provides a more specialized interface than
- QAbstractItemModel, it is not suitable for use with tree views, although
- it can be used to provide data to a QListView. If you need to represent
- a simple list of items, and only need a model to contain a single column
- of data, subclassing the QAbstractListModel may be more appropriate.
+ QAbstractItemModel, it is not suitable for use with tree views, although it
+ can be used to provide data to a QListView. If you need to represent a
+ simple list of items, and only need a model to contain a single column of
+ data, subclassing the QAbstractListModel may be more appropriate.
The rowCount() and columnCount() functions return the dimensions of the
table. To retrieve a model index corresponding to an item in the model, use
@@ -2469,9 +2528,6 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const
\section1 Subclassing
- \bold{Note:} Some general guidelines for subclassing models are
- available in the \l{Model Subclassing Reference}.
-
When subclassing QAbstractTableModel, you must implement rowCount(),
columnCount(), and data(). Default implementations of the index() and
parent() functions are provided by QAbstractTableModel.
@@ -2502,9 +2558,13 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const
call endRemoveColumns() \e{immediately afterwards}.
\endlist
- \sa {Model Classes}, {Model Subclassing Reference}, QAbstractItemModel,
- QAbstractListModel,
- {Pixelator Example}
+ \note Some general guidelines for subclassing models are available in the
+ \l{Model Subclassing Reference}.
+
+ \note
+
+ \sa {Model Classes}, QAbstractItemModel, QAbstractListModel,
+ {Pixelator Example}
*/
/*!
@@ -2602,9 +2662,6 @@ bool QAbstractTableModel::hasChildren(const QModelIndex &parent) const
\section1 Subclassing
- \bold{Note:} Some general guidelines for subclassing models are
- available in the \l{Model Subclassing Reference}.
-
When subclassing QAbstractListModel, you must provide implementations
of the rowCount() and data() functions. Well behaved models also provide
a headerData() implementation.
@@ -2631,6 +2688,9 @@ bool QAbstractTableModel::hasChildren(const QModelIndex &parent) const
call endRemoveRows() \e{immediately afterwards}.
\endlist
+ \note Some general guidelines for subclassing models are available in the
+ \l{Model Subclassing Reference}.
+
\sa {Model Classes}, {Model Subclassing Reference}, QAbstractItemView,
QAbstractTableModel, {Item Views Puzzle Example}
*/
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 2e4d840..3d26160 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -140,63 +140,6 @@ QT_BEGIN_NAMESPACE
\value Public
*/
-// do not touch without touching the moc as well
-enum PropertyFlags {
- Invalid = 0x00000000,
- Readable = 0x00000001,
- Writable = 0x00000002,
- Resettable = 0x00000004,
- EnumOrFlag = 0x00000008,
- StdCppSet = 0x00000100,
-// Override = 0x00000200,
- Constant = 0x00000400,
- Final = 0x00000800,
- Designable = 0x00001000,
- ResolveDesignable = 0x00002000,
- Scriptable = 0x00004000,
- ResolveScriptable = 0x00008000,
- Stored = 0x00010000,
- ResolveStored = 0x00020000,
- Editable = 0x00040000,
- ResolveEditable = 0x00080000,
- User = 0x00100000,
- ResolveUser = 0x00200000,
- Notify = 0x00400000
-};
-
-enum MethodFlags {
- AccessPrivate = 0x00,
- AccessProtected = 0x01,
- AccessPublic = 0x02,
- AccessMask = 0x03, //mask
-
- MethodMethod = 0x00,
- MethodSignal = 0x04,
- MethodSlot = 0x08,
- MethodConstructor = 0x0c,
- MethodTypeMask = 0x0c,
-
- MethodCompatibility = 0x10,
- MethodCloned = 0x20,
- MethodScriptable = 0x40
-};
-
-enum MetaObjectFlags {
- DynamicMetaObject = 0x01
-};
-
-struct QMetaObjectPrivate
-{
- int revision;
- int className;
- int classInfoCount, classInfoData;
- int methodCount, methodData;
- int propertyCount, propertyData;
- int enumeratorCount, enumeratorData;
- int constructorCount, constructorData;
- int flags;
-};
-
static inline const QMetaObjectPrivate *priv(const uint* data)
{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
@@ -599,29 +542,46 @@ int QMetaObject::indexOfMethod(const char *method) const
*/
int QMetaObject::indexOfSignal(const char *signal) const
{
- int i = -1;
const QMetaObject *m = this;
- while (m && i < 0) {
+ int i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal);
+ if (i >= 0)
+ i += m->methodOffset();
+ return i;
+}
+
+/*! \internal
+ Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object.
+
+ \a baseObject will be adjusted to the enclosing QMetaObject, or 0 if the signal is not found
+*/
+int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, const char *signal)
+{
+ int i = -1;
+ while (*baseObject) {
+ const QMetaObject *const m = *baseObject;
for (i = priv(m->d.data)->methodCount-1; i >= 0; --i)
if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSignal
&& strcmp(signal, m->d.stringdata
- + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) {
- i += m->methodOffset();
+ + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) {
break;
}
- m = m->d.superdata;
+ if (i >= 0)
+ break;
+ *baseObject = m->d.superdata;
}
#ifndef QT_NO_DEBUG
+ const QMetaObject *m = *baseObject;
if (i >= 0 && m && m->d.superdata) {
int conflict = m->d.superdata->indexOfMethod(signal);
if (conflict >= 0)
qWarning("QMetaObject::indexOfSignal:%s: Conflict with %s::%s",
- m->d.stringdata, m->d.superdata->d.stringdata, signal);
+ m->d.stringdata, m->d.superdata->d.stringdata, signal);
}
#endif
return i;
}
+
/*!
Finds \a slot and returns its index; otherwise returns -1.
@@ -2671,4 +2631,20 @@ const char* QMetaClassInfo::value() const
and \a data.
*/
+/*! \internal
+ If the local_method_index is a cloned method, return the index of the original.
+
+ Example: if the index of "destroyed()" is passed, the index of "destroyed(QObject*)" is returned
+ */
+int QMetaObjectPrivate::originalClone(const QMetaObject *mobj, int local_method_index)
+{
+ int handle = get(mobj)->methodData + 5 * local_method_index;
+ while (mobj->d.data[handle + 4] & MethodCloned) {
+ Q_ASSERT(local_method_index > 0);
+ handle -= 5;
+ local_method_index--;
+ }
+ return local_method_index;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 66ed55c..d843deb 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -54,9 +54,82 @@
//
#include <QtCore/qglobal.h>
+#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
+enum PropertyFlags {
+ Invalid = 0x00000000,
+ Readable = 0x00000001,
+ Writable = 0x00000002,
+ Resettable = 0x00000004,
+ EnumOrFlag = 0x00000008,
+ StdCppSet = 0x00000100,
+// Override = 0x00000200,
+ Constant = 0x00000400,
+ Final = 0x00000800,
+ Designable = 0x00001000,
+ ResolveDesignable = 0x00002000,
+ Scriptable = 0x00004000,
+ ResolveScriptable = 0x00008000,
+ Stored = 0x00010000,
+ ResolveStored = 0x00020000,
+ Editable = 0x00040000,
+ ResolveEditable = 0x00080000,
+ User = 0x00100000,
+ ResolveUser = 0x00200000,
+ Notify = 0x00400000
+};
+
+enum MethodFlags {
+ AccessPrivate = 0x00,
+ AccessProtected = 0x01,
+ AccessPublic = 0x02,
+ AccessMask = 0x03, //mask
+
+ MethodMethod = 0x00,
+ MethodSignal = 0x04,
+ MethodSlot = 0x08,
+ MethodConstructor = 0x0c,
+ MethodTypeMask = 0x0c,
+
+ MethodCompatibility = 0x10,
+ MethodCloned = 0x20,
+ MethodScriptable = 0x40
+};
+
+enum MetaObjectFlags {
+ DynamicMetaObject = 0x01
+};
+
+
+struct QMetaObjectPrivate
+{
+ int revision;
+ int className;
+ int classInfoCount, classInfoData;
+ int methodCount, methodData;
+ int propertyCount, propertyData;
+ int enumeratorCount, enumeratorData;
+ int constructorCount, constructorData; //since revision 2
+ int flags; //since revision 3
+ int signalCount; //since revision 4
+
+ static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject)
+ { return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); }
+
+ static int indexOfSignalRelative(const QMetaObject **baseObject, const char* name);
+ static int originalClone(const QMetaObject *obj, int local_method_index);
+
+ //defined in qobject.cpp
+ static bool connect(const QObject *sender, int signal_index,
+ const QObject *receiver, int method_index,
+ int type = 0, int *types = 0);
+ static bool disconnect(const QObject *sender, int signal_index,
+ const QObject *receiver, int method_index);
+
+};
+
#ifndef UTILS_H
// mirrored in moc's utils.h
static inline bool is_ident_char(char s)
@@ -202,6 +275,7 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc
return result;
}
+
QT_END_NAMESPACE
#endif
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 5247290..040efc9 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -41,6 +41,7 @@
#include "qobject.h"
#include "qobject_p.h"
+#include "qmetaobject_p.h"
#include "qabstracteventdispatcher.h"
#include "qcoreapplication.h"
@@ -222,12 +223,42 @@ void QObjectPrivate::removePendingChildInsertedEvents(QObject *child)
#endif
+/*!\internal
+ For a given metaobject, compute the signal offset, and the method offset (including signals)
+*/
+static void computeOffsets(const QMetaObject *metaobject, int *signalOffset, int *methodOffset)
+{
+ *signalOffset = *methodOffset = 0;
+ const QMetaObject *m = metaobject->d.superdata;
+ while (m) {
+ const QMetaObjectPrivate *d = QMetaObjectPrivate::get(m);
+ *methodOffset += d->methodCount;
+ *signalOffset += (d->revision >= 4) ? d->signalCount : d->methodCount;
+ /*Before Qt 4.6 (revision 4), the signalCount information was not generated by moc.
+ so for compatibility we consider all the method as slot for old moc output*/
+ m = m->d.superdata;
+ }
+}
+
+/*! \internal
+ This vector contains the all connections from an object.
+
+ Each object may have one vector containing the lists of connections for a given signal.
+ The index in the vector correspond to the signal index.
+ The signal index is the one returned by QObjectPrivate::signalIndex (not QMetaObject::indexOfSignal).
+ Negative index means connections to all signals.
+
+ This vector is protected by the object mutex (signalSlotMutexes())
+
+ Each Connection is also part of a 'senders' linked list. The mutex of the receiver must be locked when touching
+ the pointers of this linked list.
+*/
class QObjectConnectionListVector : public QVector<QObjectPrivate::ConnectionList>
{
public:
- bool orphaned;
- bool dirty;
- int inUse;
+ bool orphaned; //the QObject owner of this vector has been destroyed while the vector was inUse
+ bool dirty; //some Connection have been disconnected (their receiver is 0) but not removed from the list yet
+ int inUse; //number of functions that are currently accessing this object or its connections
QObjectPrivate::ConnectionList allsignals;
QObjectConnectionListVector()
@@ -252,7 +283,7 @@ public:
bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const
{
Q_Q(const QObject);
- int signal_index = q->metaObject()->indexOfSignal(signal);
+ int signal_index = signalIndex(signal);
if (signal_index < 0)
return false;
QMutexLocker locker(signalSlotLock(q));
@@ -276,7 +307,7 @@ QObjectList QObjectPrivate::receiverList(const char *signal) const
{
Q_Q(const QObject);
QObjectList returnValue;
- int signal_index = q->metaObject()->indexOfSignal(signal);
+ int signal_index = signalIndex(signal);
if (signal_index < 0)
return returnValue;
QMutexLocker locker(signalSlotLock(q));
@@ -2465,6 +2496,7 @@ QObject *QObject::sender() const
int QObject::receivers(const char *signal) const
{
+ Q_D(const QObject);
int receivers = 0;
if (signal) {
QByteArray signal_name = QMetaObject::normalizedSignature(signal);
@@ -2474,8 +2506,7 @@ int QObject::receivers(const char *signal) const
return 0;
#endif
signal++; // skip code
- const QMetaObject *smeta = this->metaObject();
- int signal_index = smeta->indexOfSignal(signal);
+ int signal_index = d->signalIndex(signal);
if (signal_index < 0) {
#ifndef QT_NO_DEBUG
err_method_notfound(this, signal-1, "receivers");
@@ -2599,19 +2630,26 @@ bool QObject::connect(const QObject *sender, const char *signal,
const QMetaObject *smeta = sender->metaObject();
const char *signal_arg = signal;
++signal; //skip code
- int signal_index = smeta->indexOfSignal(signal);
+ int signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal);
if (signal_index < 0) {
// check for normalized signatures
tmp_signal_name = QMetaObject::normalizedSignature(signal - 1);
signal = tmp_signal_name.constData() + 1;
- signal_index = smeta->indexOfSignal(signal);
+ smeta = sender->metaObject();
+ signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal);
+
if (signal_index < 0) {
err_method_notfound(sender, signal_arg, "connect");
err_info_about_objects("connect", sender, receiver);
return false;
}
}
+ signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
+ int signalOffset, methodOffset;
+ computeOffsets(smeta, &signalOffset, &methodOffset);
+ int signal_absolute_index = signal_index + methodOffset;
+ signal_index += signalOffset;
QByteArray tmp_method_name;
int membcode = extract_code(method);
@@ -2660,12 +2698,12 @@ bool QObject::connect(const QObject *sender, const char *signal,
int *types = 0;
if ((type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
- && !(types = queuedConnectionTypes(smeta->method(signal_index).parameterTypes())))
+ && !(types = queuedConnectionTypes(smeta->method(signal_absolute_index).parameterTypes())))
return false;
#ifndef QT_NO_DEBUG
{
- QMetaMethod smethod = smeta->method(signal_index);
+ QMetaMethod smethod = smeta->method(signal_absolute_index);
QMetaMethod rmethod = rmeta->method(method_index);
if (warnCompat) {
if(smethod.attributes() & QMetaMethod::Compatibility) {
@@ -2678,7 +2716,7 @@ bool QObject::connect(const QObject *sender, const char *signal,
}
}
#endif
- if (!QMetaObject::connect(sender, signal_index, receiver, method_index, type, types))
+ if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types))
return false;
const_cast<QObject*>(sender)->connectNotify(signal - 1);
return true;
@@ -2822,14 +2860,18 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
do {
int signal_index = -1;
if (signal) {
- signal_index = smeta->indexOfSignal(signal);
- if (signal_index < smeta->methodOffset())
- continue;
+ signal_index = QMetaObjectPrivate::indexOfSignalRelative(&smeta, signal);
+ if (signal_index < 0)
+ break;
+ signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
+ int signalOffset, methodOffset;
+ computeOffsets(smeta, &signalOffset, &methodOffset);
+ signal_index += signalOffset;
signal_found = true;
}
if (!method) {
- res |= QMetaObject::disconnect(sender, signal_index, receiver, -1);
+ res |= QMetaObjectPrivate::disconnect(sender, signal_index, receiver, -1);
} else {
const QMetaObject *rmeta = receiver->metaObject();
do {
@@ -2839,7 +2881,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
rmeta = rmeta->superClass();
if (method_index < 0)
break;
- res |= QMetaObject::disconnect(sender, signal_index, receiver, method_index);
+ res |= QMetaObjectPrivate::disconnect(sender, signal_index, receiver, method_index);
method_found = true;
} while ((rmeta = rmeta->superClass()));
}
@@ -2930,16 +2972,31 @@ void QObject::disconnectNotify(const char *)
}
/*!\internal
+ \a types is a 0-terminated vector of meta types for queued
+ connections.
- \a types is a 0-terminated vector of meta types for queued
- connections.
-
- if \a signal_index is -1, then we effectively connect *all* signals
- from the sender to the receiver's slot
-*/
+ if \a signal_index is -1, then we effectively connect *all* signals
+ from the sender to the receiver's slot
+ */
bool QMetaObject::connect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index, int type, int *types)
{
+ const QMetaObject *mo = sender->metaObject();
+ while (mo && mo->methodOffset() > signal_index)
+ mo = mo->superClass();
+ int signalOffset, methodOffset;
+ computeOffsets(mo, &signalOffset, &methodOffset);
+ signal_index = QMetaObjectPrivate::originalClone(mo, signal_index - methodOffset) + signalOffset;
+ return QMetaObjectPrivate::connect(sender, signal_index,
+ receiver, method_index, type, types);
+}
+
+/*! \internal
+ Same as the QMetaObject::connect, but \a signal_index must be the result of QObjectPrivate::signalIndex
+ */
+bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index,
+ const QObject *receiver, int method_index, int type, int *types)
+{
QObject *s = const_cast<QObject *>(sender);
QObject *r = const_cast<QObject *>(receiver);
@@ -2947,7 +3004,7 @@ bool QMetaObject::connect(const QObject *sender, int signal_index,
signalSlotLock(receiver));
if (type & Qt::UniqueConnection) {
- QObjectConnectionListVector *connectionLists = s->d_func()->connectionLists;
+ QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
if (connectionLists && connectionLists->count() > signal_index) {
const QObjectPrivate::Connection *c2 =
(*connectionLists)[signal_index].first;
@@ -2970,29 +3027,29 @@ bool QMetaObject::connect(const QObject *sender, int signal_index,
c->nextConnectionList = 0;
QT_TRY {
- s->d_func()->addConnection(signal_index, c);
+ QObjectPrivate::get(s)->addConnection(signal_index, c);
} QT_CATCH(...) {
delete c;
QT_RETHROW;
}
- c->prev = &r->d_func()->senders;
+ c->prev = &(QObjectPrivate::get(r)->senders);
c->next = *c->prev;
*c->prev = c;
if (c->next)
c->next->prev = &c->next;
+ QObjectPrivate *const sender_d = QObjectPrivate::get(s);
if (signal_index < 0) {
- for (uint i = 0; i < (sizeof sender->d_func()->connectedSignals
- / sizeof sender->d_func()->connectedSignals[0] ); ++i)
- sender->d_func()->connectedSignals[i] = ~0u;
- } else if (signal_index < (int)sizeof sender->d_func()->connectedSignals * 8) {
- uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0]));
- sender->d_func()->connectedSignals[n] |= (1 << (signal_index - n * 8
- * sizeof sender->d_func()->connectedSignals[0]));
+ for (uint i = 0; i < (sizeof sender_d->connectedSignals
+ / sizeof sender_d->connectedSignals[0] ); ++i)
+ sender_d->connectedSignals[i] = ~0u;
+ } else if (signal_index < (int)sizeof sender_d->connectedSignals * 8) {
+ uint n = (signal_index / (8 * sizeof sender_d->connectedSignals[0]));
+ sender_d->connectedSignals[n] |= (1 << (signal_index - n * 8
+ * sizeof sender_d->connectedSignals[0]));
}
-
return true;
}
@@ -3002,6 +3059,22 @@ bool QMetaObject::connect(const QObject *sender, int signal_index,
bool QMetaObject::disconnect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index)
{
+ const QMetaObject *mo = sender->metaObject();
+ while (mo && mo->methodOffset() > signal_index)
+ mo = mo->superClass();
+ int signalOffset, methodOffset;
+ computeOffsets(mo, &signalOffset, &methodOffset);
+ signal_index = QMetaObjectPrivate::originalClone(mo, signal_index - methodOffset) + signalOffset;
+ return QMetaObjectPrivate::disconnect(sender, signal_index,
+ receiver, method_index);
+}
+
+/*! \internal
+ Same as the QMetaObject::disconnect, but \a signal_index must be the result of QObjectPrivate::signalIndex
+ */
+bool QMetaObjectPrivate::disconnect(const QObject *sender, int signal_index,
+ const QObject *receiver, int method_index)
+{
if (!sender)
return false;
@@ -3012,7 +3085,7 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index,
QMutex *receiverMutex = receiver ? signalSlotLock(receiver) : 0;
QOrderedMutexLocker locker(senderMutex, receiverMutex);
- QObjectConnectionListVector *connectionLists = s->d_func()->connectionLists;
+ QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
if (!connectionLists)
return false;
@@ -3123,23 +3196,26 @@ void QMetaObject::connectSlotsByName(QObject *o)
int len = objName.length();
if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
continue;
- const QMetaObject *smo = co->metaObject();
- int sigIndex = smo->indexOfMethod(slot + len + 4);
+ int sigIndex = co->d_func()->signalIndex(slot + len + 4);
if (sigIndex < 0) { // search for compatible signals
+ const QMetaObject *smo = co->metaObject();
int slotlen = qstrlen(slot + len + 4) - 1;
for (int k = 0; k < co->metaObject()->methodCount(); ++k) {
- if (smo->method(k).methodType() != QMetaMethod::Signal)
+ QMetaMethod method = smo->method(k);
+ if (method.methodType() != QMetaMethod::Signal)
continue;
- if (!qstrncmp(smo->method(k).signature(), slot + len + 4, slotlen)) {
- sigIndex = k;
+ if (!qstrncmp(method.signature(), slot + len + 4, slotlen)) {
+ int signalOffset, methodOffset;
+ computeOffsets(method.enclosingMetaObject(), &signalOffset, &methodOffset);
+ sigIndex = k + - methodOffset + signalOffset;
break;
}
}
}
if (sigIndex < 0)
continue;
- if (QMetaObject::connect(co, sigIndex, o, i)) {
+ if (QMetaObjectPrivate::connect(co, sigIndex, o, i)) {
foundIt = true;
break;
}
@@ -3211,15 +3287,43 @@ static void blocking_activate(QObject *sender, int signal, QObjectPrivate::Conne
}
/*!\internal
+ \obsolete.
+ Used to be called from QMetaObject::activate(QObject *, QMetaObject *, int, int, void **) before Qt 4.6
*/
void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal_index, void **argv)
{
+ Q_UNUSED(to_signal_index);
+ activate(sender, from_signal_index, argv);
+}
+
+/*!\internal
+ */
+void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_signal_index,
+ void **argv)
+{
+ int signalOffset;
+ int methodOffset;
+ computeOffsets(m, &signalOffset, &methodOffset);
+
+ int signal_index = signalOffset + local_signal_index;
+ if (signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8
+ && !qt_signal_spy_callback_set.signal_begin_callback
+ && !qt_signal_spy_callback_set.signal_end_callback) {
+ uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0]));
+ uint m = 1 << (signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]);
+ if ((sender->d_func()->connectedSignals[n] & m) == 0)
+ // nothing connected to these signals, and no spy
+ return;
+ }
+
if (sender->d_func()->blockSig)
return;
+ int signal_absolute_index = methodOffset + local_signal_index;
+
void *empty_argv[] = { 0 };
if (qt_signal_spy_callback_set.signal_begin_callback != 0) {
- qt_signal_spy_callback_set.signal_begin_callback(sender, from_signal_index,
+ qt_signal_spy_callback_set.signal_begin_callback(sender, signal_absolute_index,
argv ? argv : empty_argv);
}
@@ -3229,26 +3333,20 @@ void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal
QObjectConnectionListVector *connectionLists = sender->d_func()->connectionLists;
if (!connectionLists) {
if (qt_signal_spy_callback_set.signal_end_callback != 0)
- qt_signal_spy_callback_set.signal_end_callback(sender, from_signal_index);
+ qt_signal_spy_callback_set.signal_end_callback(sender, signal_absolute_index);
return;
}
++connectionLists->inUse;
+ if (signal_index >= connectionLists->count()) {
+ signal_index = -2; //for "all signals";
+ }
- // emit signals in the following order: from_signal_index <= signals <= to_signal_index, signal < 0
- for (int signal = from_signal_index;
- (signal >= from_signal_index && signal <= to_signal_index) || (signal == -2);
- (signal == to_signal_index ? signal = -2 : ++signal))
- {
- if (signal >= connectionLists->count()) {
- signal = to_signal_index;
- continue;
- }
-
- QObjectPrivate::Connection *c = connectionLists->at(signal).first;
+ do {
+ QObjectPrivate::Connection *c = connectionLists->at(signal_index).first;
if (!c) continue;
// We need to check against last here to ensure that signals added
// during the signal emission are not emitted in this emission.
- QObjectPrivate::Connection *last = connectionLists->at(signal).last;
+ QObjectPrivate::Connection *last = connectionLists->at(signal_index).last;
do {
if (!c->receiver)
@@ -3262,17 +3360,17 @@ void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal
&& (currentThreadData != sender->d_func()->threadData
|| receiver->d_func()->threadData != sender->d_func()->threadData))
|| (c->connectionType == Qt::QueuedConnection)) {
- queued_activate(sender, signal, c, argv);
+ queued_activate(sender, signal_absolute_index, c, argv);
continue;
} else if (c->connectionType == Qt::BlockingQueuedConnection) {
- blocking_activate(sender, signal, c, argv);
+ blocking_activate(sender, signal_absolute_index, c, argv);
continue;
}
const int method = c->method;
QObjectPrivate::Sender currentSender;
currentSender.sender = sender;
- currentSender.signal = signal < 0 ? from_signal_index : signal;
+ currentSender.signal = signal_absolute_index;
currentSender.ref = 1;
QObjectPrivate::Sender *previousSender = 0;
if (currentThreadData == receiver->d_func()->threadData)
@@ -3316,7 +3414,7 @@ void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal
if (connectionLists->orphaned)
break;
- }
+ } while (signal_index >= 0 && (signal_index = -1)); //start over for -1 (all signal)
--connectionLists->inUse;
Q_ASSERT(connectionLists->inUse >= 0);
@@ -3330,82 +3428,50 @@ void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal
locker.unlock();
if (qt_signal_spy_callback_set.signal_end_callback != 0)
- qt_signal_spy_callback_set.signal_end_callback(sender, from_signal_index);
-}
+ qt_signal_spy_callback_set.signal_end_callback(sender, signal_absolute_index);
+}
/*!\internal
- */
+ Obsolete. (signal_index comes from indexOfMethod())
+*/
void QMetaObject::activate(QObject *sender, int signal_index, void **argv)
{
- if (signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8
- && !qt_signal_spy_callback_set.signal_begin_callback
- && !qt_signal_spy_callback_set.signal_end_callback) {
- uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0]));
- uint m = 1 << (signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]);
- if ((sender->d_func()->connectedSignals[n] & m) == 0)
- // nothing connected to these signals, and no spy
- return;
- }
- activate(sender, signal_index, signal_index, argv);
-}
-
-/*!\internal
- */
-void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_signal_index,
- void **argv)
-{
- int signal_index = m->methodOffset() + local_signal_index;
- if (signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8
- && !qt_signal_spy_callback_set.signal_begin_callback
- && !qt_signal_spy_callback_set.signal_end_callback) {
- uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0]));
- uint m = 1 << (signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]);
- if ((sender->d_func()->connectedSignals[n] & m) == 0)
- // nothing connected to these signals, and no spy
- return;
- }
- activate(sender, signal_index, signal_index, argv);
+ const QMetaObject *mo = sender->metaObject();
+ while (mo && mo->methodOffset() > signal_index)
+ mo = mo->superClass();
+ activate(sender, mo, signal_index - mo->methodOffset(), argv);
}
/*!\internal
+ Obsolete, called by moc generated code before Qt 4.6 for cloned signals
+ But since Qt 4.6, all clones are connected to their original
*/
void QMetaObject::activate(QObject *sender, const QMetaObject *m,
int from_local_signal_index, int to_local_signal_index, void **argv)
{
- Q_ASSERT(from_local_signal_index <= to_local_signal_index);
- int offset = m->methodOffset();
- int from_signal_index = offset + from_local_signal_index;
- int to_signal_index = offset + to_local_signal_index;
+ Q_UNUSED(to_local_signal_index);
+ Q_ASSERT(from_local_signal_index == QMetaObjectPrivate::originalClone(m, to_local_signal_index));
+ activate(sender, m, from_local_signal_index, argv);
+}
- if (to_signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8
- && !qt_signal_spy_callback_set.signal_begin_callback
- && !qt_signal_spy_callback_set.signal_end_callback) {
+/*! \internal
+ Returns the signal index used in the internal connectionLists vector.
- uint n = (from_signal_index / (8 * sizeof sender->d_func()->connectedSignals[0]));
- uint m = 1 << (from_signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]);
- uint nt = (to_signal_index / (8 * sizeof sender->d_func()->connectedSignals[0]));
- uint mt = 1 << (to_signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]);
- bool connected = false;
- quint32 *connectedSignals = sender->d_func()->connectedSignals;
- for (uint i = 0; !connected && i < (sizeof sender->d_func()->connectedSignals
- / sizeof sender->d_func()->connectedSignals[0]); ++i) {
- uint mask = 0;
- if (i > n)
- mask = ~0u;
- else if (i == n)
- mask = ~(m -1);
- if (i > nt)
- mask = 0;
- else if (i == nt)
- mask &= (mt << 1) - 1;
- connected = connectedSignals[i] & mask;
- }
- if (!connected)
- // nothing connected to these signals, and no spy
- return;
- }
- activate(sender, from_signal_index, to_signal_index, argv);
+ It is different from QMetaObject::indexOfSignal(): indexOfSignal is the same as indexOfMethod
+ while QObjectPrivate::signalIndex is smaller because it doesn't give index to slots.
+*/
+int QObjectPrivate::signalIndex(const char *signalName) const
+{
+ Q_Q(const QObject);
+ const QMetaObject *base = q->metaObject();
+ int relative_index = QMetaObjectPrivate::indexOfSignalRelative(&base, signalName);
+ if (relative_index < 0)
+ return relative_index;
+ relative_index = QMetaObjectPrivate::originalClone(base, relative_index);
+ int signalOffset, methodOffset;
+ computeOffsets(base, &signalOffset, &methodOffset);
+ return relative_index + signalOffset;
}
/*! \internal
@@ -3413,14 +3479,16 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m,
Returns true if the signal with index \a signal_index from object \a sender is connected.
Signals with indices above a certain range are always considered connected (see connectedSignals
in QObjectPrivate). If a signal spy is installed, all signals are considered connected.
+
+ \a signal_index must be the index returned by QObjectPrivate::signalIndex;
*/
-bool QMetaObject::isConnected(QObject *sender, int signal_index) {
- if (signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8
+bool QObjectPrivate::isSignalConnected(int signal_index) const {
+ if (signal_index < (int)sizeof(connectedSignals) * 8
&& !qt_signal_spy_callback_set.signal_begin_callback
&& !qt_signal_spy_callback_set.signal_end_callback) {
- uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0]));
- uint m = 1 << (signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]);
- if ((sender->d_func()->connectedSignals[n] & m) == 0)
+ uint n = (signal_index / (8 * sizeof connectedSignals[0]));
+ uint m = 1 << (signal_index - n * 8 * sizeof connectedSignals[0]);
+ if ((connectedSignals[n] & m) == 0)
// nothing connected to these signals, and no spy
return false;
}
@@ -3626,8 +3694,21 @@ void QObject::dumpObjectInfo()
qDebug(" SIGNALS OUT");
if (d->connectionLists) {
+ int offset = 0;
+ int offsetToNextMetaObject = 0;
for (int signal_index = 0; signal_index < d->connectionLists->count(); ++signal_index) {
- const QMetaMethod signal = metaObject()->method(signal_index);
+ if (signal_index >= offsetToNextMetaObject) {
+ const QMetaObject *mo = metaObject();
+ int signalOffset, methodOffset;
+ computeOffsets(mo, &signalOffset, &methodOffset);
+ while (mo && signalOffset > signal_index) {
+ mo = mo->superClass();
+ offsetToNextMetaObject = signalOffset;
+ computeOffsets(mo, &signalOffset, &methodOffset);
+ }
+ offset = offset - signalOffset + methodOffset;
+ }
+ const QMetaMethod signal = metaObject()->method(signal_index + offset);
qDebug(" signal: %s", signal.signature());
// receivers
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 49d8b63..9721ef8 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -169,6 +169,9 @@ public:
return o->d_func();
}
+ int signalIndex(const char *signalName) const;
+ bool isSignalConnected(int signalIdx) const;
+
public:
QString objectName;
ExtraData *extraData; // extra data set by the user
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index befd596..421617a 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -330,12 +330,10 @@ struct Q_CORE_EXPORT QMetaObject
static void connectSlotsByName(QObject *o);
// internal index-based signal activation
- static void activate(QObject *sender, int signal_index, void **argv);
- static void activate(QObject *sender, int from_signal_index, int to_signal_index, void **argv);
+ static void activate(QObject *sender, int signal_index, void **argv); //obsolete
+ static void activate(QObject *sender, int from_signal_index, int to_signal_index, void **argv); //obsolete
static void activate(QObject *sender, const QMetaObject *, int local_signal_index, void **argv);
- static void activate(QObject *sender, const QMetaObject *, int from_local_signal_index, int to_local_signal_index, void **argv);
-
- static bool isConnected(QObject *sender, int signal_index);
+ static void activate(QObject *sender, const QMetaObject *, int from_local_signal_index, int to_local_signal_index, void **argv); //obsolete
// internal guarded pointers
static void addGuard(QObject **ptr);
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index d5b2d16..ebd2e30 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -2494,7 +2494,7 @@ double QVariant::toDouble(bool *ok) const
*/
float QVariant::toFloat(bool *ok) const
{
- return qNumVariantToHelper<float>(d, handler, ok, d.data.d);
+ return qNumVariantToHelper<float>(d, handler, ok, d.data.f);
}
/*!
@@ -2511,7 +2511,7 @@ float QVariant::toFloat(bool *ok) const
*/
qreal QVariant::toReal(bool *ok) const
{
- return qNumVariantToHelper<qreal>(d, handler, ok, d.data.d);
+ return qNumVariantToHelper<qreal>(d, handler, ok, d.data.real);
}
/*!
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 79bd5b8..d6a704e 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -358,6 +358,7 @@ class Q_CORE_EXPORT QVariant
bool b;
double d;
float f;
+ qreal real;
qlonglong ll;
qulonglong ull;
QObject *o;
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index 993c43b..c36899d 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -57,6 +57,7 @@
// to a pointer of the input type
#include <QtCore/qglobal.h>
+#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE
@@ -145,6 +146,8 @@ inline void v_clear(QVariant::Private *d, T* = 0)
}
+Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler();
+
QT_END_NAMESPACE
#endif // QVARIANT_P_H
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index 2853b1a..defa7af 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -217,6 +217,8 @@ public:
static const Handler *handler;
};
+Q_CORE_EXPORT const QStateMachinePrivate::Handler *qcoreStateMachineHandler();
+
QT_END_NAMESPACE
#endif
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 8b9d202..ecb0bcb 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2231,9 +2231,8 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
*/
QDateTime::QDateTime(const QDateTime &other)
- : d(other.d.data())
+ : d(other.d)
{
- d->ref.ref();
}
/*!
@@ -2250,7 +2249,7 @@ QDateTime::~QDateTime()
QDateTime &QDateTime::operator=(const QDateTime &other)
{
- d.assign(other.d.data());
+ d = other.d;
return *this;
}
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index 84d3e83..988d1a2 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -44,7 +44,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qnamespace.h>
-#include <QtCore/qscopedpointer.h>
+#include <QtCore/qsharedpointer.h>
QT_BEGIN_HEADER
@@ -285,7 +285,7 @@ public:
private:
friend class QDateTimePrivate;
void detach();
- QScopedSharedPointer<QDateTimePrivate> d;
+ QExplicitlySharedDataPointer<QDateTimePrivate> d;
#ifndef QT_NO_DATASTREAM
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index 0284ed1..227e4fb 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -81,9 +81,9 @@ class QDateTimePrivate
public:
enum Spec { LocalUnknown = -1, LocalStandard = 0, LocalDST = 1, UTC = 2, OffsetFromUTC = 3};
- QDateTimePrivate() : ref(1), spec(LocalUnknown), utcOffset(0) {}
+ QDateTimePrivate() : spec(LocalUnknown), utcOffset(0) {}
QDateTimePrivate(const QDateTimePrivate &other)
- : ref(1), date(other.date), time(other.time), spec(other.spec), utcOffset(other.utcOffset)
+ : date(other.date), time(other.time), spec(other.spec), utcOffset(other.utcOffset)
{}
QAtomicInt ref;
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index ed7fe9e..3cec0bf 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -52,6 +52,7 @@
#include "qstringlist.h"
#include "qstringmatcher.h"
#include "qvector.h"
+#include "private/qfunctions_p.h"
#include <limits.h>
@@ -832,7 +833,7 @@ struct QRegExpEngineKey
}
};
-bool operator==(const QRegExpEngineKey &key1, const QRegExpEngineKey &key2)
+Q_STATIC_GLOBAL_OPERATOR bool operator==(const QRegExpEngineKey &key1, const QRegExpEngineKey &key2)
{
return key1.pattern == key2.pattern && key1.patternSyntax == key2.patternSyntax
&& key1.cs == key2.cs;
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index dde6e88..8aace0f 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -69,6 +69,9 @@ private:
template <class T> class QSharedDataPointer
{
public:
+ typedef T Type;
+ typedef T *pointer;
+
inline void detach() { if (d && d->ref != 1) detach_helper(); }
inline T &operator*() { detach(); return *d; }
inline const T &operator*() const { return *d; }
@@ -127,6 +130,7 @@ template <class T> class QExplicitlySharedDataPointer
{
public:
typedef T Type;
+ typedef T *pointer;
inline T &operator*() const { return *d; }
inline T *operator->() { return d; }
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index bce4c64..90ca34f 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -555,10 +555,12 @@ public:
inline QWeakPointer() : d(0), value(0) { }
inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }
+#ifndef QT_NO_QOBJECT
// special constructor that is enabled only if X derives from QObject
template <class X>
inline QWeakPointer(X *ptr) : d(ptr ? d->getAndRef(ptr) : 0), value(ptr)
{ }
+#endif
template <class X>
inline QWeakPointer &operator=(X *ptr)
{ return *this = QWeakPointer(ptr); }
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index 4eadc75..548d451 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -313,8 +313,8 @@ QXmlStreamEntityResolver *QXmlStreamReader::entityResolver() const
error handling described.
The \l{QXmlStream Bookmarks Example} illustrates how to use the
- recursive descent technique with a subclassed stream reader to read
- an XML bookmark file (XBEL).
+ recursive descent technique to read an XML bookmark file (XBEL) with
+ a stream reader.
\section1 Namespaces
@@ -2944,7 +2944,7 @@ QStringRef QXmlStreamReader::documentEncoding() const
encodings can be enforced using setCodec().
The \l{QXmlStream Bookmarks Example} illustrates how to use a
- subclassed stream writer to write an XML bookmark file (XBEL) that
+ stream writer to write an XML bookmark file (XBEL) that
was previously read in by a QXmlStreamReader.
*/