diff options
-rw-r--r-- | src/imports/dirmodel/qmldir | 1 | ||||
-rw-r--r-- | src/imports/folderlistmodel/folderlistmodel.pro (renamed from src/imports/dirmodel/dirmodel.pro) | 4 | ||||
-rw-r--r-- | src/imports/folderlistmodel/plugin.cpp (renamed from src/imports/dirmodel/plugin.cpp) | 4 | ||||
-rw-r--r-- | src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp (renamed from src/imports/dirmodel/qdeclarativefolderlistmodel.cpp) | 12 | ||||
-rw-r--r-- | src/imports/folderlistmodel/qdeclarativefolderlistmodel.h (renamed from src/imports/dirmodel/qdeclarativefolderlistmodel.h) | 3 | ||||
-rw-r--r-- | src/imports/folderlistmodel/qmldir | 1 | ||||
-rw-r--r-- | src/imports/imports.pro | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml | 1 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro | 17 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp | 113 |
11 files changed, 142 insertions, 21 deletions
diff --git a/src/imports/dirmodel/qmldir b/src/imports/dirmodel/qmldir deleted file mode 100644 index 0be644f..0000000 --- a/src/imports/dirmodel/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlviewerplugin diff --git a/src/imports/dirmodel/dirmodel.pro b/src/imports/folderlistmodel/folderlistmodel.pro index 03f3a1a..781dfc2 100644 --- a/src/imports/dirmodel/dirmodel.pro +++ b/src/imports/folderlistmodel/folderlistmodel.pro @@ -1,4 +1,4 @@ -TARGET = qmlviewerplugin +TARGET = qmlfolderlistmodelplugin TARGETPATH = Qt/labs/folderlistmodel include(../qimportbase.pri) @@ -17,7 +17,7 @@ symbian:{ load(data_caging_paths) include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - importFiles.sources = qmlviewerplugin.dll qmldir + importFiles.sources = qmlfolderlistmodelplugin.dll qmldir importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH DEPLOYMENT = importFiles diff --git a/src/imports/dirmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index 61bf354..b94efb0 100644 --- a/src/imports/dirmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE -class QmlViewerPlugin : public QDeclarativeExtensionPlugin +class QmlFolderListModelPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT public: @@ -61,5 +61,5 @@ QT_END_NAMESPACE #include "plugin.moc" -Q_EXPORT_PLUGIN2(qmlviewerplugin, QT_PREPEND_NAMESPACE(QmlViewerPlugin)); +Q_EXPORT_PLUGIN2(qmlfolderlistmodelplugin, QT_PREPEND_NAMESPACE(QmlFolderListModelPlugin)); diff --git a/src/imports/dirmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp index 50ef4ae..a16f0c6 100644 --- a/src/imports/dirmodel/qdeclarativefolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp @@ -147,18 +147,6 @@ QVariant QDeclarativeFolderListModel::data(const QModelIndex &index, int role) c return rv; } -QString QDeclarativeFolderListModel::fileName(int index) const -{ - QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex); - return d->model.data(modelIndex, QDirModel::FileNameRole).toString(); -} - -QUrl QDeclarativeFolderListModel::filePath(int index) const -{ - QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex); - return QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString()); -} - int QDeclarativeFolderListModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); diff --git a/src/imports/dirmodel/qdeclarativefolderlistmodel.h b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h index 86a7588..e610a14 100644 --- a/src/imports/dirmodel/qdeclarativefolderlistmodel.h +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h @@ -77,9 +77,6 @@ public: int count() const { return rowCount(QModelIndex()); } - Q_INVOKABLE QString fileName(int index) const; - Q_INVOKABLE QUrl filePath(int index) const; - QUrl folder() const; void setFolder(const QUrl &folder); diff --git a/src/imports/folderlistmodel/qmldir b/src/imports/folderlistmodel/qmldir new file mode 100644 index 0000000..6e115bb --- /dev/null +++ b/src/imports/folderlistmodel/qmldir @@ -0,0 +1 @@ +plugin qmlfolderlistmodelplugin diff --git a/src/imports/imports.pro b/src/imports/imports.pro index df43b76..e937742 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -SUBDIRS += dirmodel particles gestures +SUBDIRS += folderlistmodel particles gestures contains(QT_CONFIG, webkit): SUBDIRS += webkit contains(QT_CONFIG, mediaservices): SUBDIRS += multimedia diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml b/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml new file mode 100644 index 0000000..2c4977d --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml @@ -0,0 +1,5 @@ +import Qt.labs.folderlistmodel 1.0 + +FolderListModel { + nameFilters: [ "*.qml" ] +} diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml b/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml new file mode 100644 index 0000000..609638b --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml @@ -0,0 +1 @@ +// This file is not used, it is just content for QDirModel diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro new file mode 100644 index 0000000..487d0e1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro @@ -0,0 +1,17 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativefolderlistmodel.cpp + +# Define SRCDIR equal to test's source directory +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp new file mode 100644 index 0000000..8a8bfe7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <qtest.h> +#include <QtTest/QSignalSpy> +#include "../../../shared/util.h" +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtCore/qdir.h> +#include <QtCore/qfile.h> +#include <QtCore/qabstractitemmodel.h> +#include <QDebug> + +// From qdeclarastivefolderlistmodel.h +const int FileNameRole = Qt::UserRole+1; +const int FilePathRole = Qt::UserRole+2; +enum SortField { Unsorted, Name, Time, Size, Type }; + +class tst_qdeclarativefolderlistmodel : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativefolderlistmodel() {} + +private slots: + void basicProperties(); + +private: + void checkNoErrors(const QDeclarativeComponent& component); + QDeclarativeEngine engine; +}; + +void tst_qdeclarativefolderlistmodel::checkNoErrors(const QDeclarativeComponent& component) +{ + // Wait until the component is ready + QTRY_VERIFY(component.isReady() || component.isError()); + + if (component.isError()) { + QList<QDeclarativeError> errors = component.errors(); + for (int ii = 0; ii < errors.count(); ++ii) { + const QDeclarativeError &error = errors.at(ii); + QByteArray errorStr = QByteArray::number(error.line()) + ":" + + QByteArray::number(error.column()) + ":" + + error.description().toUtf8(); + qWarning() << errorStr; + } + } + QVERIFY(!component.isError()); +} + +void tst_qdeclarativefolderlistmodel::basicProperties() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + + + flm->setProperty("folder",QUrl::fromLocalFile(SRCDIR "/data")); + QTRY_COMPARE(flm->property("count").toInt(),2); // wait for refresh + QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(SRCDIR "/data")); + QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(SRCDIR)); + QCOMPARE(flm->property("sortField").toInt(), int(Name)); + QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml"); + QCOMPARE(flm->property("sortReversed").toBool(), false); + QCOMPARE(flm->property("showDirs").toBool(), true); + QCOMPARE(flm->property("showDotAndDotDot").toBool(), false); + QCOMPARE(flm->property("showOnlyReadable").toBool(), false); + QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml")); + QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml")); +} + +QTEST_MAIN(tst_qdeclarativefolderlistmodel) + +#include "tst_qdeclarativefolderlistmodel.moc" |