Hello community, here is the log from the commit of package kitemmodels for openSUSE:Factory checked in at 2014-04-02 17:22:10 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kitemmodels (Old) and /work/SRC/openSUSE:Factory/.kitemmodels.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kitemmodels" Changes: -------- --- /work/SRC/openSUSE:Factory/kitemmodels/kitemmodels.changes 2014-03-10 12:17:19.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.kitemmodels.new/kitemmodels.changes 2014-04-02 17:22:22.000000000 +0200 @@ -1,0 +2,9 @@ +Sat Mar 29 19:47:43 UTC 2014 - [email protected] + +- Update to 4.98.0 + * API improvements and cleanups + * Buildsystem fixes + * For more details please see: + http://www.kde.org/announcements/announce-frameworks5-beta1.php + +------------------------------------------------------------------- Old: ---- kitemmodels-4.97.0.tar.xz New: ---- kitemmodels-4.98.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kitemmodels.spec ++++++ --- /var/tmp/diff_new_pack.IsrBoR/_old 2014-04-02 17:22:22.000000000 +0200 +++ /var/tmp/diff_new_pack.IsrBoR/_new 2014-04-02 17:22:22.000000000 +0200 @@ -18,10 +18,10 @@ %define lname libKF5ItemModels5 Name: kitemmodels -Version: 4.97.0 +Version: 4.98.0 Release: 0 BuildRequires: cmake >= 2.8.12 -BuildRequires: extra-cmake-modules >= 0.0.11 +BuildRequires: extra-cmake-modules >= 0.0.12 BuildRequires: fdupes BuildRequires: kf5-filesystem BuildRequires: pkgconfig(Qt5Core) >= 5.2.0 ++++++ kitemmodels-4.97.0.tar.xz -> kitemmodels-4.98.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/CMakeLists.txt new/kitemmodels-4.98.0/CMakeLists.txt --- old/kitemmodels-4.97.0/CMakeLists.txt 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/CMakeLists.txt 2014-03-28 19:35:13.000000000 +0100 @@ -2,7 +2,7 @@ project(KItemModels) -find_package(ECM 0.0.11 REQUIRED NO_MODULE) +find_package(ECM 0.0.12 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) @@ -19,7 +19,7 @@ include(ECMSetupVersion) include(ECMGenerateHeaders) -set(KF5_VERSION "4.97.0") +set(KF5_VERSION "4.98.0") ecm_setup_version(${KF5_VERSION} VARIABLE_PREFIX KITEMMODELS VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kitemmodels_version.h" @@ -28,8 +28,9 @@ add_subdirectory(src) -# TODO re-enable, after grantlee is ported to Qt5 -#add_subdirectory(autotests) +if (BUILD_TESTING) + add_subdirectory(autotests) +endif() # create a Config.cmake and a ConfigVersion.cmake file and install them diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/autotests/CMakeLists.txt new/kitemmodels-4.98.0/autotests/CMakeLists.txt --- old/kitemmodels-4.97.0/autotests/CMakeLists.txt 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/autotests/CMakeLists.txt 2014-03-28 19:35:13.000000000 +0100 @@ -27,7 +27,11 @@ kitemmodels_proxymodel_tests( kdescendantsproxymodeltest klinkitemselectionmodeltest - kselectionproxymodeltest + # TODO fix this test - or the code that it tests! + # FAIL! : SelectionProxyModelTest::testMoveFromRoot(move01) 'signalList.isEmpty()' returned FALSE. () + # Loc: [/srv/jenkins/workspace/kitemmodels_master_qt5/autotests/proxymodeltestsuite/proxymodeltest.cpp(569)] + # QFATAL : SelectionProxyModelTest::testMoveFromRoot(move02) ASSERT: "m_unchangedIndexes.isEmpty()" in file proxymodeltestsuite/modelspy.cpp, line 253 + #kselectionproxymodeltest testmodelqueuedconnections ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/autotests/bihash/CMakeLists.txt new/kitemmodels-4.98.0/autotests/bihash/CMakeLists.txt --- old/kitemmodels-4.97.0/autotests/bihash/CMakeLists.txt 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/autotests/bihash/CMakeLists.txt 2014-03-28 19:35:13.000000000 +0100 @@ -2,10 +2,6 @@ cmake_minimum_required(VERSION 2.8.12) -find_package(Qt4) - -include(${QT_USE_FILE}) - set(functionalitytest_srcs functionalitytest.cpp ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/autotests/klinkitemselectionmodeltest.cpp new/kitemmodels-4.98.0/autotests/klinkitemselectionmodeltest.cpp --- old/kitemmodels-4.97.0/autotests/klinkitemselectionmodeltest.cpp 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/autotests/klinkitemselectionmodeltest.cpp 2014-03-28 19:35:13.000000000 +0100 @@ -20,14 +20,13 @@ #include "klinkitemselectionmodeltest.h" #include <klinkitemselectionmodel.h> -#include <qtest_kde.h> #include <QItemSelectionModel> #include <QSortFilterProxyModel> #include <QStandardItem> #include <QStandardItemModel> -QTEST_KDEMAIN(KLinkItemSelectionModelTest, GUI) +#include <QTest> void KLinkItemSelectionModelTest::init() { @@ -106,3 +105,5 @@ QCOMPARE(mainIndex, m_mainModel->index(m_mainModel->rowCount() - 1, 0)); } +QTEST_MAIN(KLinkItemSelectionModelTest) + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/autotests/kselectionproxymodeltestsuite.h new/kitemmodels-4.98.0/autotests/kselectionproxymodeltestsuite.h --- old/kitemmodels-4.97.0/autotests/kselectionproxymodeltestsuite.h 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/autotests/kselectionproxymodeltestsuite.h 2014-03-28 19:35:13.000000000 +0100 @@ -54,7 +54,10 @@ m_modelSelector->setWatch(true); m_proxyModel = new KSelectionProxyModel(m_selectionModel, this); - m_proxyModel->setFilterBehavior(m_modelSelector->filterBehaviour()); + QVariant filterBehaviour = m_modelSelector->property("filterBehaviour"); + if (!filterBehaviour.isNull()) { + m_proxyModel->setFilterBehavior(static_cast<KSelectionProxyModel::FilterBehavior>(filterBehaviour.toInt())); + } return m_proxyModel; } @@ -88,11 +91,7 @@ TestData(ProxyModelTest *proxyModelTest) : SelectorStrategy(proxyModelTest) { - } - - /* reimp */ KSelectionProxyModel::FilterBehavior filterBehaviour() - { - return _filterBehaviour; + SelectorStrategy::setProperty("filterBehaviour", QVariant(int(_filterBehaviour))); } /* reimp */ void testInsertWhenEmptyData() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/CMakeLists.txt new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/CMakeLists.txt --- old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/CMakeLists.txt 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/CMakeLists.txt 2014-03-28 19:35:13.000000000 +0100 @@ -1,20 +1,3 @@ -project(proxymodeltestsuite) - -if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - - # Building the test suite standalone - set(proxymodeltestsuite_standalone TRUE) - - find_package(Qt4 REQUIRED) - find_package(Automoc4 REQUIRED) - cmake_minimum_required(VERSION 2.8.12) -endif() - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/../../src - ${CMAKE_CURRENT_BINARY_DIR}/../../src -) - set(proxymodeltestsuite_SRCS dynamictreemodel.cpp dynamictreewidget.cpp @@ -37,17 +20,10 @@ ${eventlogger_RCSS} ) -if(proxymodeltestsuite_standalone) - set(GRANTLEE_FIND_ARG REQUIRED) -else () - set(GRANTLEE_FIND_ARG QUIET) -endif() - -# Grantlee is used for generating compilable code by the ModelEventLogger. -# If Grantlee is not found, the logger does nothing. -find_package(Grantlee ${GRANTLEE_FIND_ARG} NO_MODULE) - -if(NOT proxymodeltestsuite_standalone) +if(FALSE) + # Grantlee is used for generating compilable code by the ModelEventLogger. + # If Grantlee is not found, the logger does nothing. + #find_package(Grantlee QUIET NO_MODULE) # TODO: Put this part in Grantlee set_package_properties(Grantlee PROPERTIES URL "http://www.grantlee.org" @@ -84,32 +60,3 @@ ${Grantlee_CORE_LIBRARIES} ) -if(proxymodeltestsuite_standalone) - - set( LIB_SUFFIX "" CACHE STRING "Define suffix of library directory name (eg. '64')") - set( INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include ) - - install(TARGETS proxymodeltestsuite - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - COMPONENT Devel - ) - - install(FILES - dynamictreemodel.h - dynamictreewidget.h - modelcommander.h - modelspy.h - modelselector.h - modeltest.h - proxymodeltest.h - ${CMAKE_CURRENT_BINARY_DIR}/proxymodeltestsuite_export.h - modeldumper.h - modeleventlogger.h - eventloggerregister.h - indexfinder.h - DESTINATION ${INCLUDE_INSTALL_DIR} - ) -endif() - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/eventloggerregister.cpp new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/eventloggerregister.cpp --- old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/eventloggerregister.cpp 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/eventloggerregister.cpp 2014-03-28 19:35:13.000000000 +0100 @@ -64,22 +64,21 @@ } } -void myMessageOutput(QtMsgType type, const char *msg) +void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { + QByteArray localMsg = msg.toLocal8Bit(); switch (type) { case QtDebugMsg: - fprintf(stderr, "Debug: %s\n", msg); + fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); break; case QtWarningMsg: - fprintf(stderr, "Warning: %s\n", msg); + fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); break; case QtCriticalMsg: - fprintf(stderr, "Critical: %s\n", msg); + fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); break; case QtFatalMsg: - EventLoggerRegister::instance()->writeLogs(); - fprintf(stderr, "Fatal: %s\n", msg); - + fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); abort(); } } @@ -87,6 +86,6 @@ EventLoggerRegister::EventLoggerRegister(Behaviour behaviour) { if (behaviour == InstallMsgHandler) { - qInstallMsgHandler(myMessageOutput); + qInstallMessageHandler(myMessageOutput); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/modelselector.h new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/modelselector.h --- old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/modelselector.h 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/modelselector.h 2014-03-28 19:35:13.000000000 +0100 @@ -22,7 +22,7 @@ #include <QItemSelectionModel> -#include <kselectionproxymodel.h> +//#include <kselectionproxymodel.h> #include "proxymodeltest.h" @@ -55,7 +55,7 @@ void setWatch(bool watch); - virtual KSelectionProxyModel::FilterBehavior filterBehaviour() = 0; + //virtual KSelectionProxyModel::FilterBehavior filterBehaviour() = 0; public Q_SLOTS: void rowsInserted(const QModelIndex &parent, int start, int end); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/modeltest.cpp new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/modeltest.cpp --- old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/modeltest.cpp 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/modeltest.cpp 2014-03-28 19:35:13.000000000 +0100 @@ -1,121 +1,83 @@ /**************************************************************************** ** -** Copyright (C) 2007 Trolltech ASA. All rights reserved. -** Copyright (C) 2010 Stephen Kelly <[email protected]> +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal ** -** This file is part of the Qt Concurrent project on Trolltech Labs. +** This file is part of the test suite of the Qt Toolkit. ** -** This file may be used under the terms of the GNU General Public -** License version 2.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html -** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at [email protected]. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file COPYING.LIB included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ -#include <QtCore/QAbstractEventDispatcher> -#include <QtCore/QTimer> -#include <QDebug> -#include <QStringList> -#include <QSize> - #include "modeltest.h" +#include <QtCore/QtCore> +#include <QtTest/QtTest> + /*! Connect to all of the models signals. Whenever anything happens recheck everything. */ -ModelTest::ModelTest(QAbstractItemModel *_model, Mode testType, QObject *parent) - : QObject(parent), - model(_model), - fetchingMore(false), - pedantic(testType == Pedantic) -{ - init(); - if (pedantic) { - refreshStatus(); - // This is almost certainly not needed. -// connect(QAbstractEventDispatcher::instance(), SIGNAL(awake()), SLOT(ensureSteady())); - } -} - -ModelTest::ModelTest(QAbstractItemModel *_model, QObject *parent) - : QObject(parent), - model(_model), - fetchingMore(false), - pedantic(false) -{ - init(); -} - -void ModelTest::init() +ModelTest::ModelTest ( QAbstractItemModel *_model, QObject *parent ) : QObject ( parent ), model ( _model ), fetchingMore ( false ) { - Q_ASSERT(model); + if (!model) + qFatal("%s: model must not be null", Q_FUNC_INFO); connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(runAllTests())); + this, SLOT(runAllTests()) ); connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(runAllTests())); + this, SLOT(runAllTests()) ); connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)), - this, SLOT(runAllTests())); + this, SLOT(runAllTests()) ); connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), - this, SLOT(runAllTests())); + this, SLOT(runAllTests()) ); connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(runAllTests())); + this, SLOT(runAllTests()) ); connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(layoutAboutToBeChanged()), this, SLOT(runAllTests())); - connect(model, SIGNAL(layoutChanged()), this, SLOT(runAllTests())); - connect(model, SIGNAL(modelReset()), this, SLOT(runAllTests())); - connect(model, SIGNAL(modelAboutToBeReset()), this, SLOT(modelAboutToBeReset())); - connect(model, SIGNAL(modelReset()), this, SLOT(modelReset())); + this, SLOT(runAllTests()) ); + connect(model, SIGNAL(layoutAboutToBeChanged()), this, SLOT(runAllTests()) ); + connect(model, SIGNAL(layoutChanged()), this, SLOT(runAllTests()) ); + connect(model, SIGNAL(modelReset()), this, SLOT(runAllTests()) ); connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(runAllTests())); + this, SLOT(runAllTests()) ); connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(runAllTests())); + this, SLOT(runAllTests()) ); connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(runAllTests())); + this, SLOT(runAllTests()) ); connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(runAllTests())); + this, SLOT(runAllTests()) ); - // Special checks for inserting/removing + // Special checks for changes connect(model, SIGNAL(layoutAboutToBeChanged()), - this, SLOT(layoutAboutToBeChanged())); + this, SLOT(layoutAboutToBeChanged()) ); connect(model, SIGNAL(layoutChanged()), - this, SLOT(layoutChanged())); + this, SLOT(layoutChanged()) ); connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); + this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int)) ); connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); + this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)) ); connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(rowsInserted(QModelIndex,int,int))); + this, SLOT(rowsInserted(QModelIndex,int,int)) ); connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(rowsRemoved(QModelIndex,int,int))); - - connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + this, SLOT(rowsRemoved(QModelIndex,int,int)) ); + connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(dataChanged(QModelIndex,QModelIndex)) ); + connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), + this, SLOT(headerDataChanged(Qt::Orientation,int,int)) ); runAllTests(); } void ModelTest::runAllTests() { - -// qDebug() << "rats"; - if (fetchingMore) { + if ( fetchingMore ) return; - } nonDestructiveBasicTest(); rowCount(); columnCount(); @@ -131,32 +93,32 @@ */ void ModelTest::nonDestructiveBasicTest() { - Q_ASSERT(model->buddy(QModelIndex()) == QModelIndex()); - model->canFetchMore(QModelIndex()); - Q_ASSERT(model->columnCount(QModelIndex()) >= 0); - Q_ASSERT(model->data(QModelIndex()) == QVariant()); + QVERIFY( model->buddy ( QModelIndex() ) == QModelIndex() ); + model->canFetchMore ( QModelIndex() ); + QVERIFY( model->columnCount ( QModelIndex() ) >= 0 ); + QVERIFY( model->data ( QModelIndex() ) == QVariant() ); fetchingMore = true; - model->fetchMore(QModelIndex()); + model->fetchMore ( QModelIndex() ); fetchingMore = false; - Qt::ItemFlags flags = model->flags(QModelIndex()); - Q_ASSERT(flags == Qt::ItemIsDropEnabled || flags == 0); - model->hasChildren(QModelIndex()); - model->hasIndex(0, 0); - model->headerData(0, Qt::Horizontal); - model->index(0, 0); - model->itemData(QModelIndex()); + Qt::ItemFlags flags = model->flags ( QModelIndex() ); + QVERIFY( flags == Qt::ItemIsDropEnabled || flags == 0 ); + model->hasChildren ( QModelIndex() ); + model->hasIndex ( 0, 0 ); + model->headerData ( 0, Qt::Horizontal ); + model->index ( 0, 0 ); + model->itemData ( QModelIndex() ); QVariant cache; - model->match(QModelIndex(), -1, cache); + model->match ( QModelIndex(), -1, cache ); model->mimeTypes(); - Q_ASSERT(model->parent(QModelIndex()) == QModelIndex()); - Q_ASSERT(model->rowCount() >= 0); + QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() ); + QVERIFY( model->rowCount() >= 0 ); QVariant variant; - model->setData(QModelIndex(), variant, -1); - model->setHeaderData(-1, Qt::Horizontal, QVariant()); - model->setHeaderData(999999, Qt::Horizontal, QVariant()); + model->setData ( QModelIndex(), variant, -1 ); + model->setHeaderData ( -1, Qt::Horizontal, QVariant() ); + model->setHeaderData ( 999999, Qt::Horizontal, QVariant() ); QMap<int, QVariant> roles; - model->sibling(0, 0, QModelIndex()); - model->span(QModelIndex()); + model->sibling ( 0, 0, QModelIndex() ); + model->span ( QModelIndex() ); model->supportedDropActions(); } @@ -169,20 +131,19 @@ { // qDebug() << "rc"; // check top row - QModelIndex topIndex = model->index(0, 0, QModelIndex()); - int rows = model->rowCount(topIndex); - Q_ASSERT(rows >= 0); - - Q_ASSERT(model->hasChildren(topIndex) == (rows > 0)); + QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); + int rows = model->rowCount ( topIndex ); + QVERIFY( rows >= 0 ); + if ( rows > 0 ) + QVERIFY( model->hasChildren ( topIndex ) ); - QModelIndex secondLevelIndex = model->index(0, 0, topIndex); - if (secondLevelIndex.isValid()) { // not the top level + QModelIndex secondLevelIndex = model->index ( 0, 0, topIndex ); + if ( secondLevelIndex.isValid() ) { // not the top level // check a row count where parent is valid - rows = model->rowCount(secondLevelIndex); - Q_ASSERT(rows >= 0); - if (rows > 0) { - Q_ASSERT(model->hasChildren(secondLevelIndex) == true); - } + rows = model->rowCount ( secondLevelIndex ); + QVERIFY( rows >= 0 ); + if ( rows > 0 ) + QVERIFY( model->hasChildren ( secondLevelIndex ) ); } // The models rowCount() is tested more extensively in checkChildren(), @@ -195,14 +156,13 @@ void ModelTest::columnCount() { // check top row - QModelIndex topIndex = model->index(0, 0, QModelIndex()); - Q_ASSERT(model->columnCount(topIndex) >= 0); + QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); + QVERIFY( model->columnCount ( topIndex ) >= 0 ); // check a column count where parent is valid - QModelIndex childIndex = model->index(0, 0, topIndex); - if (childIndex.isValid()) { - Q_ASSERT(model->columnCount(childIndex) >= 0); - } + QModelIndex childIndex = model->index ( 0, 0, topIndex ); + if ( childIndex.isValid() ) + QVERIFY( model->columnCount ( childIndex ) >= 0 ); // columnCount() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -215,18 +175,19 @@ { // qDebug() << "hi"; // Make sure that invalid values returns an invalid index - Q_ASSERT(model->hasIndex(-2, -2) == false); - Q_ASSERT(model->hasIndex(-2, 0) == false); - Q_ASSERT(model->hasIndex(0, -2) == false); + QVERIFY( !model->hasIndex ( -2, -2 ) ); + QVERIFY( !model->hasIndex ( -2, 0 ) ); + QVERIFY( !model->hasIndex ( 0, -2 ) ); int rows = model->rowCount(); int columns = model->columnCount(); // check out of bounds - Q_ASSERT(model->hasIndex(rows, columns) == false); - Q_ASSERT(model->hasIndex(rows + 1, columns + 1) == false); + QVERIFY( !model->hasIndex ( rows, columns ) ); + QVERIFY( !model->hasIndex ( rows + 1, columns + 1 ) ); - Q_ASSERT(model->hasIndex(0, 0) == (rows > 0)); + if ( rows > 0 ) + QVERIFY( model->hasIndex ( 0, 0 ) ); // hasIndex() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -239,25 +200,24 @@ { // qDebug() << "i"; // Make sure that invalid values returns an invalid index - Q_ASSERT(model->index(-2, -2) == QModelIndex()); - Q_ASSERT(model->index(-2, 0) == QModelIndex()); - Q_ASSERT(model->index(0, -2) == QModelIndex()); + QVERIFY( model->index ( -2, -2 ) == QModelIndex() ); + QVERIFY( model->index ( -2, 0 ) == QModelIndex() ); + QVERIFY( model->index ( 0, -2 ) == QModelIndex() ); int rows = model->rowCount(); int columns = model->columnCount(); - if (rows == 0) { + if ( rows == 0 ) return; - } // Catch off by one errors - Q_ASSERT(model->index(rows, columns) == QModelIndex()); - Q_ASSERT(model->index(0, 0).isValid() == true); + QVERIFY( model->index ( rows, columns ) == QModelIndex() ); + QVERIFY( model->index ( 0, 0 ).isValid() ); // Make sure that the same index is *always* returned - QModelIndex a = model->index(0, 0); - QModelIndex b = model->index(0, 0); - Q_ASSERT(a == b); + QModelIndex a = model->index ( 0, 0 ); + QModelIndex b = model->index ( 0, 0 ); + QVERIFY( a == b ); // index() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -269,13 +229,12 @@ void ModelTest::parent() { // qDebug() << "p"; - // Make sure the model wont crash and will return an invalid QModelIndex + // Make sure the model won't crash and will return an invalid QModelIndex // when asked for the parent of an invalid index. - Q_ASSERT(model->parent(QModelIndex()) == QModelIndex()); + QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() ); - if (model->rowCount() == 0) { + if ( model->rowCount() == 0 ) return; - } // Column 0 | Column 1 | // QModelIndex() | | @@ -284,32 +243,29 @@ // Common error test #1, make sure that a top level index has a parent // that is a invalid QModelIndex. - QModelIndex topIndex = model->index(0, 0, QModelIndex()); - Q_ASSERT(model->parent(topIndex) == QModelIndex()); + QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); + QVERIFY( model->parent ( topIndex ) == QModelIndex() ); // Common error test #2, make sure that a second level index has a parent // that is the first level index. - if (model->rowCount(topIndex) > 0) { - QModelIndex childIndex = model->index(0, 0, topIndex); - if (model->parent(childIndex) != topIndex) { - qDebug() << model->parent(childIndex) << topIndex << topIndex.data(); - } - Q_ASSERT(model->parent(childIndex) == topIndex); + if ( model->rowCount ( topIndex ) > 0 ) { + QModelIndex childIndex = model->index ( 0, 0, topIndex ); + QVERIFY( model->parent ( childIndex ) == topIndex ); } // Common error test #3, the second column should NOT have the same children // as the first column in a row. // Usually the second column shouldn't have children. - QModelIndex topIndex1 = model->index(0, 1, QModelIndex()); - if (model->rowCount(topIndex1) > 0) { - QModelIndex childIndex = model->index(0, 0, topIndex); - QModelIndex childIndex1 = model->index(0, 0, topIndex1); - Q_ASSERT(childIndex != childIndex1); + QModelIndex topIndex1 = model->index ( 0, 1, QModelIndex() ); + if ( model->rowCount ( topIndex1 ) > 0 ) { + QModelIndex childIndex = model->index ( 0, 0, topIndex ); + QModelIndex childIndex1 = model->index ( 0, 0, topIndex1 ); + QVERIFY( childIndex != childIndex1 ); } // Full test, walk n levels deep through the model making sure that all // parent's children correctly specify their parent. - checkChildren(QModelIndex()); + checkChildren ( QModelIndex() ); } /*! @@ -326,96 +282,101 @@ found the basic bugs because it is easier to figure out the problem in those tests then this one. */ -void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) +void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) { // First just try walking back up the tree. QModelIndex p = parent; - while (p.isValid()) { + while ( p.isValid() ) p = p.parent(); - } // For models that are dynamically populated - if (model->canFetchMore(parent)) { + if ( model->canFetchMore ( parent ) ) { fetchingMore = true; - model->fetchMore(parent); + model->fetchMore ( parent ); fetchingMore = false; } - int rows = model->rowCount(parent); - int columns = model->columnCount(parent); + int rows = model->rowCount ( parent ); + int columns = model->columnCount ( parent ); + + if ( rows > 0 ) + QVERIFY( model->hasChildren ( parent ) ); // Some further testing against rows(), columns(), and hasChildren() - Q_ASSERT(rows >= 0); - Q_ASSERT(columns >= 0); - Q_ASSERT(model->hasChildren(parent) == (rows > 0)); - - qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows - << "columns:" << columns << "parent column:" << parent.column(); - - Q_ASSERT(model->hasIndex(rows, 0, parent) == false); - Q_ASSERT(model->index(rows, 0, parent).isValid() == false); - for (int r = 0; r < rows; ++r) { - if (model->canFetchMore(parent)) { + QVERIFY( rows >= 0 ); + QVERIFY( columns >= 0 ); + if ( rows > 0 ) + QVERIFY( model->hasChildren ( parent ) ); + + //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows + // << "columns:" << columns << "parent column:" << parent.column(); + + const QModelIndex topLeftChild = model->index( 0, 0, parent ); + + QVERIFY( !model->hasIndex ( rows + 1, 0, parent ) ); + for ( int r = 0; r < rows; ++r ) { + if ( model->canFetchMore ( parent ) ) { fetchingMore = true; - model->fetchMore(parent); + model->fetchMore ( parent ); fetchingMore = false; } - Q_ASSERT(model->hasIndex(r, columns, parent) == false); - Q_ASSERT(model->index(r, columns, parent).isValid() == false); -// qDebug() << "Cols" << columns; - for (int c = 0; c < columns; ++c) { -// qDebug() << "has" << r << c << parent; - Q_ASSERT(model->hasIndex(r, c, parent) == true); - QModelIndex index = model->index(r, c, parent); + QVERIFY( !model->hasIndex ( r, columns + 1, parent ) ); + for ( int c = 0; c < columns; ++c ) { + QVERIFY( model->hasIndex ( r, c, parent ) ); + QModelIndex index = model->index ( r, c, parent ); // rowCount() and columnCount() said that it existed... - Q_ASSERT(index.isValid() == true); + QVERIFY( index.isValid() ); // index() should always return the same index when called twice in a row - QModelIndex modifiedIndex = model->index(r, c, parent); - Q_ASSERT(index == modifiedIndex); + QModelIndex modifiedIndex = model->index ( r, c, parent ); + QVERIFY( index == modifiedIndex ); // Make sure we get the same index if we request it twice in a row - QModelIndex a = model->index(r, c, parent); - QModelIndex b = model->index(r, c, parent); - Q_ASSERT(a == b); + QModelIndex a = model->index ( r, c, parent ); + QModelIndex b = model->index ( r, c, parent ); + QVERIFY( a == b ); + + { + const QModelIndex sibling = model->sibling( r, c, topLeftChild ); + QVERIFY( index == sibling ); + } + { + const QModelIndex sibling = topLeftChild.sibling( r, c ); + QVERIFY( index == sibling ); + } // Some basic checking on the index that is returned - Q_ASSERT(index.model() == model); -// qDebug() << index.row() << r; - Q_ASSERT(index.row() == r); - Q_ASSERT(index.column() == c); + QVERIFY( index.model() == model ); + QCOMPARE( index.row(), r ); + QCOMPARE( index.column(), c ); // While you can technically return a QVariant usually this is a sign - // of an bug in data() Disable if this really is ok in your model. - if (!model->data(index, Qt::DisplayRole).isValid()) { - qDebug() << index << index.data() << index.parent(); - } - Q_ASSERT(model->data(index, Qt::DisplayRole).isValid() == true); + // of a bug in data(). Disable if this really is ok in your model. +// QVERIFY( model->data ( index, Qt::DisplayRole ).isValid() ); // If the next test fails here is some somewhat useful debug you play with. - /* + if (model->parent(index) != parent) { qDebug() << r << c << currentDepth << model->data(index).toString() << model->data(parent).toString(); qDebug() << index << parent << model->parent(index); - // And a view that you can even use to show the model. - //QTreeView view; - //view.setModel(model); - //view.show(); - }*/ +// And a view that you can even use to show the model. +// QTreeView view; +// view.setModel(model); +// view.show(); + } // Check that we can get back our real parent. -// qDebug() << index.data() << parent << model->parent ( index ) << parent.data() << model->parent ( index ).data() << r << rows << c << columns; - Q_ASSERT(model->parent(index) == parent); + QCOMPARE( model->parent ( index ), parent ); // recursively go down the children - if (model->hasChildren(index) && currentDepth < 10) { -// qDebug() << r << c << "has children" << model->rowCount(index); - checkChildren(index, ++currentDepth); + if ( model->hasChildren ( index ) && currentDepth < 10 ) { + //qDebug() << r << c << "has children" << model->rowCount(index); + checkChildren ( index, ++currentDepth ); }/* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; };*/ // make sure that after testing the children that the index doesn't change. - QModelIndex newerIndex = model->index(r, c, parent); - Q_ASSERT(index == newerIndex); + QModelIndex newerIndex = model->index ( r, c, parent ); + QVERIFY( index == newerIndex ); } } } @@ -426,69 +387,68 @@ void ModelTest::data() { // Invalid index should return an invalid qvariant - Q_ASSERT(!model->data(QModelIndex()).isValid()); + QVERIFY( !model->data ( QModelIndex() ).isValid() ); - if (model->rowCount() == 0) { + if ( model->rowCount() == 0 ) return; - } // A valid index should have a valid QVariant data - Q_ASSERT(model->index(0, 0).isValid()); + QVERIFY( model->index ( 0, 0 ).isValid() ); // shouldn't be able to set data on an invalid index - Q_ASSERT(model->setData(QModelIndex(), QLatin1String("foo"), Qt::DisplayRole) == false); + QVERIFY( !model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) ); // General Purpose roles that should return a QString - QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole); - if (variant.isValid()) { - Q_ASSERT(variant.canConvert<QString>()); - } - variant = model->data(model->index(0, 0), Qt::StatusTipRole); - if (variant.isValid()) { - Q_ASSERT(variant.canConvert<QString>()); - } - variant = model->data(model->index(0, 0), Qt::WhatsThisRole); - if (variant.isValid()) { - Q_ASSERT(variant.canConvert<QString>()); + QVariant variant = model->data ( model->index ( 0, 0 ), Qt::ToolTipRole ); + if ( variant.isValid() ) { + QVERIFY( variant.canConvert<QString>() ); + } + variant = model->data ( model->index ( 0, 0 ), Qt::StatusTipRole ); + if ( variant.isValid() ) { + QVERIFY( variant.canConvert<QString>() ); + } + variant = model->data ( model->index ( 0, 0 ), Qt::WhatsThisRole ); + if ( variant.isValid() ) { + QVERIFY( variant.canConvert<QString>() ); } // General Purpose roles that should return a QSize - variant = model->data(model->index(0, 0), Qt::SizeHintRole); - if (variant.isValid()) { - Q_ASSERT(variant.canConvert<QSize>()); + variant = model->data ( model->index ( 0, 0 ), Qt::SizeHintRole ); + if ( variant.isValid() ) { + QVERIFY( variant.canConvert<QSize>() ); } // General Purpose roles that should return a QFont - QVariant fontVariant = model->data(model->index(0, 0), Qt::FontRole); - if (fontVariant.isValid()) { - Q_ASSERT(fontVariant.canConvert<QFont>()); + QVariant fontVariant = model->data ( model->index ( 0, 0 ), Qt::FontRole ); + if ( fontVariant.isValid() ) { + QVERIFY( fontVariant.canConvert<QFont>() ); } // Check that the alignment is one we know about - QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlignmentRole); - if (textAlignmentVariant.isValid()) { + QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole ); + if ( textAlignmentVariant.isValid() ) { int alignment = textAlignmentVariant.toInt(); - Q_ASSERT(alignment == (alignment & (Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask))); + QCOMPARE( alignment, ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) ); } // General Purpose roles that should return a QColor - QVariant colorVariant = model->data(model->index(0, 0), Qt::BackgroundColorRole); - if (colorVariant.isValid()) { - Q_ASSERT(colorVariant.canConvert<QColor>()); + QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole ); + if ( colorVariant.isValid() ) { + QVERIFY( colorVariant.canConvert<QColor>() ); } - colorVariant = model->data(model->index(0, 0), Qt::TextColorRole); - if (colorVariant.isValid()) { - Q_ASSERT(colorVariant.canConvert<QColor>()); + colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole ); + if ( colorVariant.isValid() ) { + QVERIFY( colorVariant.canConvert<QColor>() ); } // Check that the "check state" is one we know about. - QVariant checkStateVariant = model->data(model->index(0, 0), Qt::CheckStateRole); - if (checkStateVariant.isValid()) { + QVariant checkStateVariant = model->data ( model->index ( 0, 0 ), Qt::CheckStateRole ); + if ( checkStateVariant.isValid() ) { int state = checkStateVariant.toInt(); - Q_ASSERT(state == Qt::Unchecked || + QVERIFY( state == Qt::Unchecked || state == Qt::PartiallyChecked || - state == Qt::Checked); + state == Qt::Checked ); } } @@ -497,23 +457,18 @@ \sa rowsInserted() */ -void ModelTest::rowsAboutToBeInserted(const QModelIndex &parent, int start, int end) +void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, int /* end */) { // Q_UNUSED(end); - qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data(parent).value<QString>() - << "current count of parent=" << model->rowCount(parent); // << "display of last=" << model->data( model->index(start-1, 0, parent) ); +// qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data ( parent ).toString() +// << "current count of parent=" << model->rowCount ( parent ); // << "display of last=" << model->data( model->index(start-1, 0, parent) ); // qDebug() << model->index(start-1, 0, parent) << model->data( model->index(start-1, 0, parent) ); Changing c; c.parent = parent; - c.oldSize = model->rowCount(parent); - c.last = model->data(model->index(start - 1, 0, parent)); - c.next = model->data(model->index(start, 0, parent)); - qDebug() << "last=" << c.last << c.next; - insert.push(c); - if (pedantic) { - ensureConsistent(); - status.type = Status::InsertingRows; - } + c.oldSize = model->rowCount ( parent ); + c.last = model->data ( model->index ( start - 1, 0, parent ) ); + c.next = model->data ( model->index ( start, 0, parent ) ); + insert.push ( c ); } /*! @@ -521,145 +476,45 @@ \sa rowsAboutToBeInserted() */ -void ModelTest::rowsInserted(const QModelIndex &parent, int start, int end) +void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) { Changing c = insert.pop(); - Q_ASSERT(c.parent == parent); - qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize - << "parent=" << model->data(parent).value<QString>() << "current rowcount=" << model->rowCount(parent); + QVERIFY( c.parent == parent ); +// qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize +// << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent ); + +// for (int ii=start; ii <= end; ii++) +// { +// qDebug() << "itemWasInserted:" << ii << model->data ( model->index ( ii, 0, parent )); +// } +// qDebug(); - for (int ii = start; ii <= end; ii++) { - qDebug() << "itemWasInserted:" << model->data(model->index(ii, 0, parent)); - } + QVERIFY( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) ); + QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); - Q_ASSERT(c.oldSize + (end - start + 1) == model->rowCount(parent)); - Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); - /* if (c.next != model->data(model->index(end + 1, 0, c.parent))) { qDebug() << start << end; for (int i=0; i < model->rowCount(); ++i) qDebug() << model->index(i, 0).data().toString(); qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent)); } - */ - qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent)); - Q_ASSERT(c.next == model->data(model->index(end + 1, 0, c.parent))); - - if (pedantic) { - Q_ASSERT(status.type == Status::InsertingRows); - refreshStatus(); - } -} - -void ModelTest::modelAboutToBeReset() -{ - qDebug() << "@@@@@@@@@@@" << "modelAboutToBeReset"; - if (pedantic) { - ensureConsistent(); - status.type = Status::Resetting; - } -} - -void ModelTest::modelReset() -{ - qDebug() << "@@@@@@@@@@@" << "modelReset"; - if (pedantic) { - Q_ASSERT(status.type == Status::Resetting); - refreshStatus(); - } + QVERIFY( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) ); } void ModelTest::layoutAboutToBeChanged() { - qDebug() << "@@@@@@@@@@@" << "layoutAboutToBeChanged"; - - if (pedantic) { - ensureConsistent(); - status.type = Status::ChangingLayout; - } - for (int i = 0; i < qBound(0, model->rowCount(), 100); ++i) { -// qDebug() << "persisting" << model->index ( i, 0 ) << model->index ( i, 0 ).data(); - changing.append(QPersistentModelIndex(model->index(i, 0))); - } + for ( int i = 0; i < qBound ( 0, model->rowCount(), 100 ); ++i ) + changing.append ( QPersistentModelIndex ( model->index ( i, 0 ) ) ); } void ModelTest::layoutChanged() { - qDebug() << "@@@@@@@@@@@" << "layoutAboutToBeChanged"; -// qDebug() << "B"; - for (int i = 0; i < changing.count(); ++i) { + for ( int i = 0; i < changing.count(); ++i ) { QPersistentModelIndex p = changing[i]; -// qDebug() << "Bp" << p; -// qDebug() << "p" << p << p.data(); -// qDebug() << "Ap"; - Q_ASSERT(p == model->index(p.row(), p.column(), p.parent())); + QVERIFY( p == model->index ( p.row(), p.column(), p.parent() ) ); } changing.clear(); - - if (pedantic) { - Q_ASSERT(status.type == Status::ChangingLayout); - refreshStatus(); - } - -// qDebug() << "A"; -} - -void ModelTest::rowsAboutToBeMoved(const QModelIndex &srcParent, int start, int end, const QModelIndex &destParent, int destinationRow) -{ - qDebug() << "rowsAboutToBeMoved" << srcParent << start << end << destParent << destinationRow; - - for (int row = start, dr = destinationRow; row <= end; ++row, ++dr) { - qDebug() << "row" << model->index(row, 0, srcParent).data() << "in " << srcParent << "will be moved to " << destParent << dr; - } - - Changing cs; - cs.parent = srcParent; - cs.oldSize = model->rowCount(srcParent); - cs.last = model->data(model->index(start - 1, 0, srcParent)); - cs.next = model->data(model->index(end + 1, 0, srcParent)); - remove.push(cs); - Changing cd; - cd.parent = destParent; - cd.oldSize = model->rowCount(destParent); - cd.last = model->data(model->index(destinationRow - 1, 0, destParent)); - cd.next = model->data(model->index(destinationRow, 0, destParent)); - insert.push(cd); -} - -void ModelTest::rowsMoved(const QModelIndex &srcParent, int start, int end, const QModelIndex &destParent, int destinationRow) -{ - qDebug() << "rowsMoved" << srcParent << start << end << destParent << destinationRow; - - Changing cd = insert.pop(); - Q_ASSERT(cd.parent == destParent); - if (srcParent == destParent) { - Q_ASSERT(cd.oldSize == model->rowCount(destParent)); - - // TODO: Find out what I can assert here about last and next. -// Q_ASSERT ( cd.last == model->data ( model->index ( destinationRow - 1, 0, cd.parent ) ) ); -// Q_ASSERT ( cd.next == model->data ( model->index ( destinationRow + (end - start + 1), 0, cd.parent ) ) ); - - } else { - qDebug() << cd.oldSize << end << start << model->rowCount(destParent) << destParent.data() << "#########"; - Q_ASSERT(cd.oldSize + (end - start + 1) == model->rowCount(destParent)); - - Q_ASSERT(cd.last == model->data(model->index(destinationRow - 1, 0, cd.parent))); - Q_ASSERT(cd.next == model->data(model->index(destinationRow + (end - start + 1), 0, cd.parent))); - } - Changing cs = remove.pop(); - - Q_ASSERT(cs.parent == srcParent); - if (srcParent == destParent) { - Q_ASSERT(cs.oldSize == model->rowCount(srcParent)); - } else { - Q_ASSERT(cs.oldSize - (end - start + 1) == model->rowCount(srcParent)); - - Q_ASSERT(cs.last == model->data(model->index(start - 1, 0, srcParent))); -// qDebug() << cs.next << model->data ( model->index ( start, 0, srcParent ) ); - Q_ASSERT(cs.next == model->data(model->index(start, 0, srcParent))); - } - } /*! @@ -667,24 +522,15 @@ \sa rowsRemoved() */ -void ModelTest::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) +void ModelTest::rowsAboutToBeRemoved ( const QModelIndex &parent, int start, int end ) { - qDebug() << "ratbr" << parent << start << end; - for (int ii = start; ii <= end; ii++) { - qDebug() << "itemwillbe removed:" << model->data(model->index(ii, 0, parent)); - } - - if (pedantic) { - ensureConsistent(); - status.type = Status::RemovingRows; - } - +qDebug() << "ratbr" << parent << start << end; Changing c; c.parent = parent; - c.oldSize = model->rowCount(parent); - c.last = model->data(model->index(start - 1, 0, parent)); - c.next = model->data(model->index(end + 1, 0, parent)); - remove.push(c); + c.oldSize = model->rowCount ( parent ); + c.last = model->data ( model->index ( start - 1, 0, parent ) ); + c.next = model->data ( model->index ( end + 1, 0, parent ) ); + remove.push ( c ); } /*! @@ -692,59 +538,37 @@ \sa rowsAboutToBeRemoved() */ -void ModelTest::rowsRemoved(const QModelIndex &parent, int start, int end) +void ModelTest::rowsRemoved ( const QModelIndex & parent, int start, int end ) { - qDebug() << "rr" << parent << start << end; + qDebug() << "rr" << parent << start << end; Changing c = remove.pop(); - Q_ASSERT(c.parent == parent); - qDebug() << (c.oldSize - (end - start + 1)) << model->rowCount(parent); - Q_ASSERT(c.oldSize - (end - start + 1) == model->rowCount(parent)); - Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); - Q_ASSERT(c.next == model->data(model->index(start, 0, c.parent))); - - if (pedantic) { - Q_ASSERT(status.type == Status::RemovingRows); - refreshStatus(); - } -} - -void ModelTest::refreshStatus() -{ - status.type = Status::Idle; - status.nonPersistent.clear(); - status.persistent.clear(); - - persistStatus(QModelIndex()); -} - -void ModelTest::persistStatus(const QModelIndex &index) -{ - const int rowCount = model->rowCount(index); - for (int row = 0; row < rowCount; ++row) { - // TODO: Test multi columns - static const int column = 0; - QPersistentModelIndex idx = model->index(row, column, index); - status.persistent.append(idx); - status.nonPersistent.append(idx); - persistStatus(idx); - } -} - -void ModelTest::ensureSteady() -{ - Q_ASSERT(insert.isEmpty()); - Q_ASSERT(remove.isEmpty()); - Q_ASSERT(changing.isEmpty()); - ensureConsistent(); -} - -void ModelTest::ensureConsistent() -{ - Q_ASSERT(status.type == Status::Idle); - - Q_ASSERT(status.nonPersistent.size() == status.persistent.size()); - for (int i = 0; i < status.nonPersistent.size(); ++i) { - Q_ASSERT(status.nonPersistent.at(i) == status.persistent.at(i)); - } + QVERIFY( c.parent == parent ); + QVERIFY( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) ); + QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); + QVERIFY( c.next == model->data ( model->index ( start, 0, c.parent ) ) ); +} + +void ModelTest::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + QVERIFY(topLeft.isValid()); + QVERIFY(bottomRight.isValid()); + QModelIndex commonParent = bottomRight.parent(); + QVERIFY(topLeft.parent() == commonParent); + QVERIFY(topLeft.row() <= bottomRight.row()); + QVERIFY(topLeft.column() <= bottomRight.column()); + int rowCount = model->rowCount(commonParent); + int columnCount = model->columnCount(commonParent); + QVERIFY(bottomRight.row() < rowCount); + QVERIFY(bottomRight.column() < columnCount); +} + +void ModelTest::headerDataChanged(Qt::Orientation orientation, int start, int end) +{ + QVERIFY(start >= 0); + QVERIFY(end >= 0); + QVERIFY(start <= end); + int itemCount = orientation == Qt::Vertical ? model->rowCount() : model->columnCount(); + QVERIFY(start < itemCount); + QVERIFY(end < itemCount); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/modeltest.h new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/modeltest.h --- old/kitemmodels-4.97.0/autotests/proxymodeltestsuite/modeltest.h 2014-03-01 12:51:06.000000000 +0100 +++ new/kitemmodels-4.98.0/autotests/proxymodeltestsuite/modeltest.h 2014-03-28 19:35:13.000000000 +0100 @@ -1,27 +1,21 @@ /**************************************************************************** ** -** Copyright (C) 2007 Trolltech ASA. All rights reserved. -** Copyright (C) 2010 Stephen Kelly <[email protected]> +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal ** -** This file is part of the Qt Concurrent project on Trolltech Labs. +** This file is part of the test suite of the Qt Toolkit. ** -** This file may be used under the terms of the GNU General Public -** License version 2.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html -** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at [email protected]. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file COPYING.LIB included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ + #ifndef MODELTEST_H #define MODELTEST_H @@ -29,83 +23,50 @@ #include <QtCore/QAbstractItemModel> #include <QtCore/QStack> -#include "proxymodeltestsuite_export.h" - -class PROXYMODELTESTSUITE_EXPORT ModelTest : public QObject +class ModelTest : public QObject { - Q_OBJECT + Q_OBJECT public: - enum Mode { - Normal, - Pedantic - }; - - ModelTest(QAbstractItemModel *model, QObject *parent = 0); - ModelTest(QAbstractItemModel *model, Mode testType, QObject *parent = 0); + ModelTest( QAbstractItemModel *model, QObject *parent = 0 ); private Q_SLOTS: - void nonDestructiveBasicTest(); - void rowCount(); - void columnCount(); - void hasIndex(); - void index(); - void parent(); - void data(); + void nonDestructiveBasicTest(); + void rowCount(); + void columnCount(); + void hasIndex(); + void index(); + void parent(); + void data(); protected Q_SLOTS: - void runAllTests(); - void layoutAboutToBeChanged(); - void layoutChanged(); - void modelAboutToBeReset(); - void modelReset(); - void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); - void rowsInserted(const QModelIndex &parent, int start, int end); - void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void rowsRemoved(const QModelIndex &parent, int start, int end); - void rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int); - void rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int); - - void ensureConsistent(); - void ensureSteady(); + void runAllTests(); + void layoutAboutToBeChanged(); + void layoutChanged(); + void rowsAboutToBeInserted( const QModelIndex &parent, int start, int end ); + void rowsInserted( const QModelIndex & parent, int start, int end ); + void rowsAboutToBeRemoved( const QModelIndex &parent, int start, int end ); + void rowsRemoved( const QModelIndex & parent, int start, int end ); + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void headerDataChanged(Qt::Orientation orientation, int start, int end); private: - void checkChildren(const QModelIndex &parent, int currentDepth = 0); - void refreshStatus(); - void persistStatus(const QModelIndex &index); - void init(); - - QAbstractItemModel *const model; - - struct Status { - enum Type { - Idle, - InsertingRows, - RemovingRows, - MovingRows, - ChangingLayout, - Resetting - }; - - Type type; - - QList<QPersistentModelIndex> persistent; - QList<QModelIndex> nonPersistent; - } status; - - struct Changing { - QPersistentModelIndex parent; - int oldSize; - QVariant last; - QVariant next; - }; - QStack<Changing> insert; - QStack<Changing> remove; + void checkChildren( const QModelIndex &parent, int currentDepth = 0 ); + + QAbstractItemModel *model; + + struct Changing { + QModelIndex parent; + int oldSize; + QVariant last; + QVariant next; + }; + QStack<Changing> insert; + QStack<Changing> remove; - bool fetchingMore; - const bool pedantic; + bool fetchingMore; - QList<QPersistentModelIndex> changing; + QList<QPersistentModelIndex> changing; }; #endif -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
