Commit Graph

44 Commits

Author SHA1 Message Date
Marc Mutz
15953e9503 QModelIndex: clean up integer size confusion in the API
QAIM::createIndex() took either int or quint32, but QMI::internalId()
returned qint64.

In the new interface, createIndex() takes, and internalId() provides,
integers of type quintptr.

This matches the storage size of the void* in the model index and
avoids truncation.

Remove the
  createIndex(int, int, quint32) and
  \obsolete createIndex(int,int,int)
overloads.

This makes a literal 0 in the third parameter ambiguous now.
The solutions have been noted in changes-5.0.0.

Change-Id: I0a0ecd8430eaf695129a4d09d14d4e30745485c4
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2012-09-22 20:45:12 +02:00
Iikka Eklund
be15856f61 Change copyrights from Nokia to Digia
Change copyrights and license headers from Nokia to Digia

Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
2012-09-22 19:20:11 +02:00
Stephen Kelly
d7a15fbfd9 Fix crash when invalidating a QSortFilterProxyModel
Task-number: QTBUG-27122

Change-Id: Ibca46b88442f4f92422d9b3182e4bbf25716a07f
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-09-13 16:20:11 +02:00
Stephen Kelly
2ef3ac72fc Emit layoutChange signals when changing QPersistentModelIndexes.
This is necessary whenever QPersistentModelIndexes are changed. Omitting
it means that views are not able to react to the change, such as QTreeView
clearing its (manually held) QModelIndex cache, and the QItemSelectionModel
clearing the item from its storage.

It is necessary to change a QSortFilterProxyModel test which assumed setItem
does not have any such effect. That test is ported to setData instead.

Task-number: QTBUG-18539
Change-Id: Id7a602f18b9773ba4d11019418de886860d26d3e
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2012-08-18 08:34:53 +02:00
Stephen Kelly
da64a50792 Only emit headerDataChanged for valid proxy intervals.
Modeltest asserts before the patch, and passes afterward.

Task-number: QTBUG-26515

Change-Id: I08a89cd5c9c59613badcddbd056a3d0b8fbbca13
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2012-08-15 15:04:11 +02:00
Stephen Kelly
c1df856d6b Make rowIntersectsSelection take account of the parent argument.
Task-number: QTBUG-22370

Change-Id: I497194793eab624b760deea93dac0df767850330
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-08-10 22:02:11 +02:00
Stephen Kelly
b84e180263 Avoid crashes when invalidating a proxy model filter.
Task-number: QTBUG-26107
Change-Id: I2df7ae6402136570c8469d3251edae6ca8290f1f
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-08-07 11:15:55 +02:00
Thiago Macieira
672b5b7ab6 Set the Qt API level to compatibility mode in all tests.
Qt 5.0 beta requires changing the default to the 5.0 API, disabling
the deprecated code. However, tests should test (and often do) the
compatibility API too, so turn it back on.

Task-number: QTBUG-25053
Change-Id: I8129c3ef3cb58541c95a32d083850d9e7f768927
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-08-01 15:37:46 +02:00
Marc Mutz
c76a641a27 QAbstractItemView: don't qRegisterMetaType<QModelIndex>
QModelIndex is a build-in type nowadays and doesn't
need to be registered anymore.

Also remove them from the tests.

Change-Id: I47029972651c045c880cee86fb292116a29493d5
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2012-07-24 10:46:24 +02:00
Stephen Kelly
536ec793b6 Make it possible to use new syntax to connect to model signals.
The private signals can not be used as function pointers, as
required by the new syntax, so we introduce a parameter which
can only be created privately.

Change-Id: I3d7bb8a163e764d685e8007cba831fb77e3c6855
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-07-13 01:51:44 +02:00
Stephen Kelly
648d5964ee Add a Q_PROPERTY for the sourceModel of a proxy model.
Now that Q_PROPERTY with a QObject derived type is more powerful.

This property can be used in QML so that wrappers for proxy models
do not need to be created, such as in the example
at https://codereview.qt-project.org/#change,13007

Change-Id: I6ba676549d2135585d429a28e214fef0b2a6b1f9
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-07-04 15:51:50 +02:00
Giuseppe D'Angelo
985292b0a3 QAbstractProxyModel autotest doesn't need widgets
After the QStandardItemModel move to QtGui.

Change-Id: I2be82d89518ff97cf164026ee8b13a41f9c93d4a
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
2012-06-29 22:42:23 +02:00
Giuseppe D'Angelo
dba22bc036 Move QStandardItem/QStandardItemModel to QtGui
The dependencies on QFont, QBrush, QIcon are all in QtGui, so there's
little sense to still have these classes in QtWidgets.

This also copies and pastes a version of QWidgetItemData as
QStandardItemData inside qstandarditemmodel_p.h.

Change-Id: Ibafc5a30748e7ce0b54753309ae6dc4a797fc20e
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
2012-06-29 22:42:19 +02:00
Stephen Kelly
f9caf48bee Use a QVector<int> instead of a QSet<int> in itemviews/models.
The QSet<int> is a more expensive container to use and create, so
it should be avoided.

This is source incompatible compared to earlier Qt 5 for
QAbstractItemView subclasses which reimplement dataChanged, but this
patch changes nothing compared to already-present SiC compared
to Qt 4.

Change-Id: Id95391dfd62a0a7f487a8765790b007badefb937
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-06-12 04:30:07 +02:00
Kent Hansen
6f297d9dd4 Remove widgets dependency from qstringlistmodel autotest
Change-Id: I9678f9ee3fd8b01648cf2524452145568cf6fb4f
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-06-07 00:38:58 +02:00
Kent Hansen
bb10660bea Make itemmodels autotest build without widgets
Change-Id: I7ff1a575c111452397c3461842c15bb01105cf95
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-06-07 00:38:44 +02:00
Rohan McGovern
177070cb7b Add CONFIG+=parallel_test to suspected parallel-safe tests.
These tests have passed a parallel stress test on all three of Linux,
Mac, Windows.  Mark them with CONFIG+=parallel_test to allow CI to run
them in parallel, saving time.

Change-Id: I19fd333c3c645a67374ca998f6c8530dd236b0f8
Reviewed-by: Toby Tomkins <toby.tomkins@nokia.com>
2012-05-28 07:33:01 +02:00
Debao Zhang
ade8888603 Don't use obsolete qVariantValue, qVariantCanConvert, etc.
qVariantValue and qVariantCanConvert are Compatibility members, while in
Qt4.8 they are marked as Qt 3 Support Members.

qVariantFromValue and qVariantSetValue are Obsolete members.

Change-Id: Ie8505cad1e0950e40c6f6710fde9f6fb2ac670fd
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
2012-05-02 08:30:59 +02:00
Jason McDonald
1eebbacb86 Remove insignification from qabstractitemmodel test on Mac OS X.
Since this test began to run again on Mac, it has been passing
consistently.

Task-number: QTBUG-22748
Change-Id: Ia81cf60b11d45fb331b5eca5d13df00556c18e07
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
2012-04-24 19:36:55 +02:00
Jason McDonald
d7a102ac65 Start running some disabled tests again on Mac OS.
These tests were disabled when trying to get CI working on Mac OS
because they asserted or crashed.  Now that CI is working well on Mac
OS, start running these tests again, initially as insignificant tests.
CI results will then be used to determine whether the tests can be made
significant.

Change-Id: Ife411e6b8c84ade45c865ef35f3ae0071d6f8d2b
Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-04-23 09:46:22 +02:00
Stephen Kelly
da7880b0f0 Update parent indexes first with changePersistentIndex.
Otherwise, the order of updating of the indexes will cause
inconsistent results because it will rely on ordering within a
QHash (which is indeterminate).

Task-number: QTBUG-25325

Change-Id: I7d99578c8ee2954b8562dc5aff7dc32e74d41fb5
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-04-17 00:47:49 +02:00
Giuseppe D'Angelo
51fecf80b7 Mark tst_qabstractitemmodel as insignificant after QHash randomization
The testChildrenLayoutsChanged fails randomly. This happens rarely,
f.i. wasn't spotted by CI when QHash randomization itself was merged;
but is indeed reproducible by running the test a few times in a row.

This is now blocking api_merges integration, and I have no idea
how to fix it.

This patch marks the test as insignificant for now (the bug
tracking this test failure is QTBUG-25325), and switches the failing
tests from QVERIFY(a == b) to a proper QCOMPARE (so that the
expected values do show up in the build logs).

Change-Id: I16f0e28bcbb06dbac2e7169f4676a19ccf626a92
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2012-04-15 21:00:52 +02:00
Jason McDonald
ab9be7cc23 Eliminate duplicate data row names from corelib autotests.
Change-Id: I57a37f19746b76c6c9c3534f5c66c5a5478dae24
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-02-14 06:19:16 +01:00
Mark Brand
6466314625 tst_qabstractitemmodel does not need QT += widgets
Change-Id: I6f615f849f77df19129efb82acaae387b17a787b
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2012-01-31 04:55:47 +01:00
Stephen Kelly
be1867b6c4 Add the QAbstractItemModel::canDropMimeData method.
Can be used by views to indicate whether a drop is allowed (eg
adequete permissions in a filesystem model).

Change-Id: Iefedb5399e44c8edc5f5df1403c8d5c0da618612
Reviewed-by: Peter Penz <peter.penz19@gmail.com>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-01-30 16:24:57 +01:00
Jason McDonald
5635823e17 Remove "All rights reserved" line from license headers.
As in the past, to avoid rewriting various autotests that contain
line-number information, an extra blank line has been inserted at the
end of the license text to ensure that this commit does not change the
total number of lines in the license header.

Change-Id: I311e001373776812699d6efc045b5f742890c689
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-01-30 03:54:59 +01:00
Mark Brand
764840ec0e add missing move* methods to QAbstractItemModel
The existence of QAbstractItemModel virtual methods
    moveRow, moveColumn, moveRows, and moveColumns
is implied by the existence of
   beginMoveRows, endMoveRows, beginMoveColumns and endMoveColumns.
However, these were not actually provided by QAbstractItemModel.

With this change, subclasses can implement support for moving rows
and columns following the same pattern as for insert* and remove*.

Change-Id: Iad8b2223d4b9303abb6459c174a82ffed71a0fdf
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
2012-01-24 19:12:23 +01:00
Jason McDonald
629d6eda5c Update contact information in license headers.
Replace Nokia contact email address with Qt Project website.

Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-01-23 04:04:33 +01:00
Stephen Kelly
6acdb32561 Clarify docs that everything must be re-queried on model reset.
Change-Id: I05970302d4f52d092a7c65a45b9e5a3570b1d144
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-01-16 17:07:12 +01:00
Kurt Korbatits
990e890b9e Changed unittests in corelib to use specific headers instead of super-headers.
Modified unittests to use specific class headers instead of
using super-headers like QtCore that pull in all the headers for
the module.
- Decreasing build time.

Change-Id: I9c3fd0767be15205893bb406f609c8283a2a3a5a
Reviewed-by: Kurt Korbatits  <kurt.korbatits@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-01-16 01:55:22 +01:00
Stephen Kelly
20abd88e71 Make the supportedDragActions a virtual accessor.
Change-Id: I4001fcabc67e5b46465b3c9111c33247c52e5788
Reviewed-by: David Faure <faure@kde.org>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2012-01-10 16:11:43 +01:00
Stephen Kelly
c3ad8c1c06 Make the roleNames a virtual accessor.
This is consistent with the rest of the API of QAbstractItemModel
(which is virtual) and removes the need for code like this
in the constructor (where it doesn't belong):

QHash<int, QByteArray> myRoleNames = roleNames();
myRoleNames.insert(Qt::UserRole + 1, "myCustomRole");
setRoleNames(myRoleNames);

in favor of

MyModel::roleNames() const {
  QHash<int, QByteArray> myRoleNames = QAbstractItemModel::roleNames();
  myRoleNames.insert(Qt::UserRole + 1, "myCustomRole");
  return myRoleNames;
}

which is consistent with all other QAIM API (eg, flags()).

This is a source compatible change.

Change-Id: I7e1ce17f8dab2292c4c7b6dbd3c09ec71b5c793b
Reviewed-by: David Faure <faure@kde.org>
Reviewed-by: Marius Bugge Monsen <marius@cutehacks.com>
2012-01-10 11:37:28 +01:00
Stephen Kelly
9eacf32de9 Move the qitemmodel test to the itemmodels directory.
Change-Id: I67e1008bea0d94ffbc52aad453a29645261e109e
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2012-01-06 17:21:25 +01:00
Jason McDonald
1fdfc2abfe Update copyright year in license headers.
Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-01-05 06:36:56 +01:00
Jason McDonald
f599b5cd30 Fix memory leak in QAbstractItemModel autotest.
The test was allocating a new model on the heap each time init() was
invoked, but none of these models were deleted.

Change-Id: Ibe107b2dbc949a5f72940f67c08f4b0f46256c09
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-01-05 03:49:45 +01:00
Stephen Kelly
f29e55448b Change the default value of QSortFilterProxyModel::dynamicSortFilter
The value is changed to true. It is a common bug that developers expect
this proxy model to reflect the source model when the source changes.
That requires setDynamicSortFilter(true), so we change the default to
optimize for the common case.

Change-Id: I9bf7efdbda10309fa77aed9391c33054aaae4a29
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2012-01-02 16:43:02 +01:00
Jason McDonald
79b64957b0 Cleanup itemmodel autotests.
Avoid using bug tracker identifiers in test function names.  These
identifiers lose their meaning when the bug tracker is replaced.

Change-Id: Ia867f7c2ec2ab9ed546588843d532ac615a34031
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-12-28 06:34:02 +01:00
Jason McDonald
4ae3fea163 Remove old debug code from itemmodel tests.
Change-Id: I7c6aeed2d3b593a4dac89e54ef22743d5f736d42
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-12-28 06:33:50 +01:00
Jason McDonald
6b6406d659 Reinstate commented test data in QItemSelectionModel test.
The restored test data was marked as failing, but appears to pass, and
the available history does not explain why it was commented out.

Change-Id: I7e9e3ba72fc8fef42c91ee882efa98d25b3d8317
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-12-28 06:33:42 +01:00
Jason McDonald
613d0e407e Cleanup itemmodel autotests.
Bring the code closer to compliance with Qt's coding style guidelines
and eliminate excessive vertical whitespace.

Change-Id: Iaa29f8edf326ddb80cbadb6c18cca4fea88fd9b2
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-12-28 06:33:32 +01:00
Jason McDonald
9f843918f2 Remove empty functions from itemmodels tests.
Change-Id: I23775a334812b096192c7f44c4a3cb06f4b08705
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-12-28 04:50:35 +01:00
Jason McDonald
ea415e2060 Cleanup corelib autotests.
When using QSignalSpy, always verify that the signal spy is valid.  This
will cause the test to give a meaningful failure when spying on a
non-existant signal.  Without this change, tests that spy on a signal to
ensure that it is not emitted (i.e. by comparing the spy count to zero)
could pass erroneously if something went wrong when creating the signal
spy, as an invalid QSignalSpy will always return a count of zero.

Change-Id: I41f4a63d9f0de9190a86de237662dc96be802446
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2011-12-28 04:48:11 +01:00
Stephen Kelly
211e434a05 Move proxy and selection models to QtCore.
Change-Id: I71097855cb9e28105238e496778f29f99f7fc84e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2011-12-16 13:00:57 +01:00
Stephen Kelly
309cdc358e Move QAbstractItemModel into a separate directory.
Change-Id: Ib505520dd5b52743634befbf3f148d7f8c21ec44
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2011-12-13 02:23:42 +01:00