--- /dev/null
+/*
+ Copyright (C) 2012-2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
+ Author: Kevin Krammer, kevin.krammer@kdab.com
+ Author: Tobias Koenig, tobias.koenig@kdab.com
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include "declarativestringlistmodelextension.h"
+
+#include <QStringListModel>
+
+DeclarativeStringListModelExtension::DeclarativeStringListModelExtension(QObject *parent)
+ : DeclarativeObjectExtension(parent)
+{
+}
+
+QStringListModel *DeclarativeStringListModelExtension::extendedModel() const
+{
+ QStringListModel *model = qobject_cast<QStringListModel*>(extendedObject());
+ Q_ASSERT(model);
+
+ return model;
+}
+
+void DeclarativeStringListModelExtension::setStringList(const QStringList &list)
+{
+ QStringListModel *model = extendedModel();
+ if (model->stringList() == list)
+ return;
+
+ model->setStringList(list);
+
+ emit stringListChanged(list);
+}
+
+QStringList DeclarativeStringListModelExtension::stringList() const
+{
+ return extendedModel()->stringList();
+}
--- /dev/null
+/*
+ Copyright (C) 2012-2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
+ Author: Kevin Krammer, kevin.krammer@kdab.com
+ Author: Tobias Koenig, tobias.koenig@kdab.com
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef DECLARATIVESTRINGLISTMODELEXTENSION_H
+#define DECLARATIVESTRINGLISTMODELEXTENSION_H
+
+#include "declarativeobjectextension.h"
+
+#include <QStringList>
+
+class QStringListModel;
+
+class DeclarativeStringListModelExtension : public DeclarativeObjectExtension
+{
+ Q_OBJECT
+
+ // repeat property declarations, qmlRegisterExtendedType doesn't see the ones from base class
+ Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data DESIGNABLE false)
+ Q_PROPERTY(QStringList stringList READ stringList WRITE setStringList NOTIFY stringListChanged)
+
+ Q_CLASSINFO("DefaultProperty", "data")
+
+ public:
+ explicit DeclarativeStringListModelExtension(QObject *parent = 0);
+
+ QStringListModel *extendedModel() const;
+
+ void setStringList(const QStringList &list);
+
+ QStringList stringList() const;
+
+ Q_SIGNALS:
+ void stringListChanged(const QStringList &stringList);
+};
+
+#endif // DECLARATIVESSTRINGLISTMODELEXTENSION_H
#include "declarativestackedlayout_p.h"
#include "declarativestackedwidgetextension_p.h"
#include "declarativestatusbar_p.h"
+#include "declarativestringlistmodelextension.h"
#include "declarativetabwidget_p.h"
#include "declarativetexteditextension_p.h"
#include "declarativetoolbarextension_p.h"
#include <QRadioButton>
#include <QScrollBar>
#include <QStackedWidget>
+#include <QStringListModel>
#include <QTableView>
#include <QTextBrowser>
#include <QTimer>
qmlRegisterExtendedType<QFileSystemModel, DeclarativeFileSystemModelExtension>("QtGui", 1, 0, "FileSystemModel");
qmlRegisterType<QItemSelectionModel>();
qmlRegisterExtendedType<DeclarativeSeparator, DeclarativeObjectExtension>("QtGui", 1, 0, "Separator");
+ qmlRegisterExtendedType<QStringListModel, DeclarativeStringListModelExtension>("QtCore", 1, 0, "StringListModel");
qmlRegisterType<QTextDocument>();
qmlRegisterType<QTimer>("QtCore", 1, 0, "Timer");
objectadaptors_p.h \
qmetaobjectbuilder_p.h \
staticdialogmethodattached_p.h \
- declarativefilesystemmodelextension.h
+ declarativefilesystemmodelextension.h \
+ declarativestringlistmodelextension.h
SOURCES = \
abstractdeclarativeobject.cpp \
objectadaptors.cpp \
qmetaobjectbuilder.cpp \
staticdialogmethodattached.cpp \
- declarativefilesystemmodelextension.cpp
+ declarativefilesystemmodelextension.cpp \
+ declarativestringlistmodelextension.cpp