diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-11-21 12:29:55 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-11-21 12:30:11 +0100 |
commit | 88edd02b2bf872af5348531d05a47d7e15a61702 (patch) | |
tree | 9abfa0fe13296d6035970581aab4b35a43ac1691 | |
parent | 244f144e332ca70033eba8b8536535008d2b215b (diff) | |
parent | de4ff95cd166b13fb4818ada5493d913345ef0ef (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Change-Id: If96a7e488b7964e56c06c9e367ff9c91f1bba526
17 files changed, 242 insertions, 273 deletions
diff --git a/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml b/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml index 8c8c4722..cab26e63 100644 --- a/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml +++ b/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml @@ -52,16 +52,16 @@ import QtQuick 2.7 import QtQuick.Controls 2.1 AbstractButton { - clip: true - checkable: true - autoExclusive: true - id: delegate - height: 50 property alias remove: remove property alias edit: edit + width: 300 + height: 50 + clip: true + checkable: true + autoExclusive: true Column { id: column1 @@ -158,10 +158,6 @@ AbstractButton { states: [ State { - name: "collapsed" - when: !delegate.checked - }, - State { name: "expanded" when: delegate.checked diff --git a/examples/quickcontrols2/contactlist/ContactDialog.qml b/examples/quickcontrols2/contactlist/ContactDialog.qml index ed781282..1836ea28 100644 --- a/examples/quickcontrols2/contactlist/ContactDialog.qml +++ b/examples/quickcontrols2/contactlist/ContactDialog.qml @@ -49,48 +49,47 @@ ****************************************************************************/ import QtQuick 2.7 -import QtQuick.Window 2.2 import QtQuick.Controls 2.1 Dialog { - standardButtons: Dialog.Ok | Dialog.Cancel - modal: true - - x: parent.width / 2 - width / 2 - y: parent.height / 2 - height / 2 - - property int lastIndex - property QtObject lastModel + id: dialog - property alias form: form + property int index: -1 + signal finished(string fullName, string address, string city, string number) - function addContact(model) { + function createContact() { form.fullName.clear(); form.address.clear(); form.city.clear(); form.number.clear(); - lastIndex = -1; - lastModel = model; + dialog.title = qsTr("Add Contact"); + dialog.index = -1; dialog.open(); } - function editContact(model, index) { - form.fullName.text = model.getFullName(index); - form.address.text = model.getAddress(index); - form.city.text = model.getCity(index); - form.number.text = model.getNumber(index); - lastIndex = index; - lastModel = model; + function editContact(index, contact) { + form.fullName.text = contact.fullName; + form.address.text = contact.address; + form.city.text = contact.city; + form.number.text = contact.number; + dialog.title = qsTr("Edit Contact"); + dialog.index = index; dialog.open(); } - contentItem: ContactDialogForm { + x: parent.width / 2 - width / 2 + y: parent.height / 2 - height / 2 + + focus: true + modal: true + title: qsTr("Add Contact") + standardButtons: Dialog.Ok | Dialog.Cancel + + contentItem: ContactForm { id: form } - onAccepted: lastModel.updateContact(lastIndex, form.fullName.text, - form.address.text, form.city.text, - form.number.text) + onAccepted: finished(form.fullName.text, form.address.text, form.city.text, form.number.text) } diff --git a/examples/quickcontrols2/contactlist/ContactDialogForm.ui.qml b/examples/quickcontrols2/contactlist/ContactForm.ui.qml index e1f31943..f3397bb0 100644 --- a/examples/quickcontrols2/contactlist/ContactDialogForm.ui.qml +++ b/examples/quickcontrols2/contactlist/ContactForm.ui.qml @@ -1,4 +1,3 @@ - /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. @@ -66,12 +65,13 @@ GridLayout { columns: 2 Label { - text: qsTr("Full Name:") + text: qsTr("Full Name") Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline } TextField { id: fullName + focus: true Layout.fillWidth: true Layout.minimumWidth: grid.minimumInputSize Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline @@ -117,4 +117,3 @@ GridLayout { placeholderText: grid.placeholderText } } - diff --git a/examples/quickcontrols2/contactlist/MainForm.ui.qml b/examples/quickcontrols2/contactlist/ContactView.ui.qml index 634398bd..30a72b65 100644 --- a/examples/quickcontrols2/contactlist/MainForm.ui.qml +++ b/examples/quickcontrols2/contactlist/ContactView.ui.qml @@ -49,33 +49,30 @@ ****************************************************************************/ import QtQuick 2.7 -import Backend 1.0 import QtQuick.Controls 2.1 +import Backend 1.0 Page { - id: form + id: page - width: 320 - height: 480 + signal addContact() + signal editContact(int index) + signal removeContact(int index) - property alias button: button - property alias listView: listView + property alias model: contactModel - property ContactDialog dialog: ContactDialog { - } + width: 320 + height: 480 ListView { id: listView + anchors.fill: parent - currentIndex: -1 - boundsBehavior: Flickable.StopAtBounds - clip: true focus: true - anchors.fill: parent - section.criteria: ViewSection.FirstCharacter - section.property: "fullName" - snapMode: ListView.SnapToItem + boundsBehavior: Flickable.StopAtBounds + section.property: "fullName" + section.criteria: ViewSection.FirstCharacter section.delegate: SectionDelegate { width: listView.width } @@ -83,31 +80,37 @@ Page { delegate: ContactDelegate { id: delegate width: listView.width - x: 5 Connections { target: delegate.edit - onClicked: dialog.editContact(listView.model, index) + onClicked: page.editContact(index) } Connections { target: delegate.remove - onClicked: listView.model.removeContact(index) + onClicked: page.removeContact(index) } } - model: AddressModel { + model: ContactModel { + id: contactModel } - ScrollBar.vertical: ScrollBar { - } + ScrollBar.vertical: ScrollBar { } } footer: ToolBar { + id: footer + ToolButton { - id: button - text: "Add Contact" + id: addButton + text: qsTr("Add Contact") anchors.right: parent.right + + Connections { + target: addButton + onClicked: page.addContact() + } } } } diff --git a/examples/quickcontrols2/contactlist/SectionDelegate.ui.qml b/examples/quickcontrols2/contactlist/SectionDelegate.ui.qml index 3b9f7dc5..fa64ffbf 100644 --- a/examples/quickcontrols2/contactlist/SectionDelegate.ui.qml +++ b/examples/quickcontrols2/contactlist/SectionDelegate.ui.qml @@ -51,27 +51,14 @@ import QtQuick 2.7 import QtQuick.Controls 2.1 -Rectangle { - height: 20 - width: 120 - gradient: Gradient { - GradientStop { - position: 0 - color: "#dddddd" - } - - GradientStop { - position: 1 - color: "blue" - } - } +ToolBar { + id: background Label { - x: 12 - color: "white" + id: label text: section - style: Text.Raised - font.pixelSize: 18 - font.bold: true + anchors.fill: parent + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter } } diff --git a/examples/quickcontrols2/contactlist/addressmodel.cpp b/examples/quickcontrols2/contactlist/addressmodel.cpp deleted file mode 100644 index fb83186e..00000000 --- a/examples/quickcontrols2/contactlist/addressmodel.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "addressmodel.h" - -AddressModel::AddressModel(QObject *parent ) : QAbstractListModel(parent) -{ - m_data.append({ "Angel Hogan", "Chapel St. 368 ", "Clearwater" , "0311 1823993" }); - m_data.append({ "Felicia Patton", "Annadale Lane 2", "Knoxville" , "0368 1244494" }); - m_data.append({ "Grant Crawford", "Windsor Drive 34", "Riverdale" , "0351 7826892" }); - m_data.append({ "Gretchen Little", "Sunset Drive 348", "Virginia Beach" , "0343 1234991" }); - m_data.append({ "Geoffrey Richards", "University Lane 54", "Trussville" , "0423 2144944" }); - m_data.append({ "Henrietta Chavez", "Via Volto San Luca 3", "Piobesi Torinese" , "0399 2826994" }); - m_data.append({ "Harvey Chandler", "North Squaw Creek 11", "Madisonville" , "0343 1244492" }); - m_data.append({ "Miguel Gomez", "Wild Rose Street 13", "Trussville" , "0343 9826996" }); - m_data.append({ "Norma Rodriguez", " Glen Eagles Street 53", "Buffalo" , "0241 5826596" }); - m_data.append({ "Shelia Ramirez", "East Miller Ave 68", "Pickerington" , "0346 4844556" }); - m_data.append({ "Stephanie Moss", "Piazza Trieste e Trento 77", "Roata Chiusani" , "0363 0510490" }); -} - -int AddressModel::rowCount(const QModelIndex &) const -{ - return m_data.count(); -} - -QVariant AddressModel::data(const QModelIndex &index, int role) const -{ - if (index.row() < rowCount()) - switch (role) { - case FullNameRole: return m_data.at(index.row()).fullName; - case AddressRole: return m_data.at(index.row()).address; - case CityRole: return m_data.at(index.row()).city; - case NumberRole: return m_data.at(index.row()).number; - default: return QVariant(); - - } - return QVariant(); -} - -QHash<int, QByteArray> AddressModel::roleNames() const -{ - static QHash<int, QByteArray> roleNames { - { FullNameRole, "fullName" }, - { AddressRole, "address" }, - { CityRole, "city" }, - { NumberRole, "number" } - }; - return roleNames; -} - -void AddressModel::updateContact(int row, - const QString &fullName, - const QString &address, - const QString &city, - const QString &number) -{ - if (row >= 0 && row < rowCount()) { - m_data.replace(row, { fullName, address, city, number }); - dataChanged(index(row, 0), index(row, 0), { FullNameRole, AddressRole, CityRole, NumberRole }); - } else if (row < 0) { - beginInsertRows(QModelIndex(), rowCount() - 1, rowCount() - 1); - m_data.append({fullName, address, city, number}); - endInsertRows(); - dataChanged(index(rowCount() - 1, 0), index(rowCount() - 1, 0), { FullNameRole, AddressRole, CityRole, NumberRole }); - } -} - -void AddressModel::removeContact(int row) -{ - if (row >= 0 && row < rowCount()) { - beginRemoveRows(QModelIndex(), row, row); - m_data.removeAt(row); - endRemoveRows(); - } -} - -QString AddressModel::getFullName(int row) const -{ - if (row >= 0 && row < rowCount()) - return m_data.at(row).fullName; - return QString(); -} - -QString AddressModel::getAddress(int row) const -{ - if (row >= 0 && row < rowCount()) - return m_data.at(row).address; - return QString(); -} - -QString AddressModel::getCity(int row) const -{ - if (row >= 0 && row < rowCount()) - return m_data.at(row).city; - return QString(); -} - -QString AddressModel::getNumber(int row) const -{ - if (row >= 0 && row < rowCount()) - return m_data.at(row).number; - return QString(); -} diff --git a/examples/quickcontrols2/contactlist/contactlist.pro b/examples/quickcontrols2/contactlist/contactlist.pro index 8125d020..9025dbde 100644 --- a/examples/quickcontrols2/contactlist/contactlist.pro +++ b/examples/quickcontrols2/contactlist/contactlist.pro @@ -1,23 +1,19 @@ TEMPLATE = app TARGET = contactlist - -QT += quick quickcontrols2 -CONFIG += c++11 +QT += quick HEADERS += \ - addressmodel.h + contactmodel.h -SOURCES += main.cpp \ - addressmodel.cpp +SOURCES += \ + main.cpp \ + contactmodel.cpp RESOURCES += \ - $$files(*.qml) \ - -# Additional import path used to resolve QML modules in Qt Creator's code model -QML_IMPORT_PATH=$$PWD/imports + $$files(*.qml) # Additional import path used to resolve QML modules just for Qt Quick Designer -QML_DESIGNER_IMPORT_PATH=$$PWD/designer +QML_DESIGNER_IMPORT_PATH = $$PWD/designer OTHER_FILES += \ designer/Backend/*.qml diff --git a/examples/quickcontrols2/contactlist/contactlist.qml b/examples/quickcontrols2/contactlist/contactlist.qml index 7ace67fa..04382407 100644 --- a/examples/quickcontrols2/contactlist/contactlist.qml +++ b/examples/quickcontrols2/contactlist/contactlist.qml @@ -52,13 +52,29 @@ import QtQuick 2.7 import QtQuick.Controls 2.1 ApplicationWindow { - visible: true + id: window + width: 320 height: 480 + visible: true title: qsTr("Contact List") - MainForm { - button.onClicked: dialog.addContact(listView.model) + ContactDialog { + id: contactDialog + onFinished: { + if (index === -1) + contactView.model.append(fullName, address, city, number) + else + contactView.model.set(index, fullName, address, city, number) + } + } + + ContactView { + id: contactView anchors.fill: parent + + onAddContact: contactDialog.createContact() + onEditContact: contactDialog.editContact(index, model.get(index)) + onRemoveContact: model.remove(index) } } diff --git a/examples/quickcontrols2/contactlist/contactmodel.cpp b/examples/quickcontrols2/contactlist/contactmodel.cpp new file mode 100644 index 00000000..308da2da --- /dev/null +++ b/examples/quickcontrols2/contactlist/contactmodel.cpp @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "contactmodel.h" + +ContactModel::ContactModel(QObject *parent ) : QAbstractListModel(parent) +{ + m_contacts.append({ "Angel Hogan", "Chapel St. 368 ", "Clearwater" , "0311 1823993" }); + m_contacts.append({ "Felicia Patton", "Annadale Lane 2", "Knoxville" , "0368 1244494" }); + m_contacts.append({ "Grant Crawford", "Windsor Drive 34", "Riverdale" , "0351 7826892" }); + m_contacts.append({ "Gretchen Little", "Sunset Drive 348", "Virginia Beach" , "0343 1234991" }); + m_contacts.append({ "Geoffrey Richards", "University Lane 54", "Trussville" , "0423 2144944" }); + m_contacts.append({ "Henrietta Chavez", "Via Volto San Luca 3", "Piobesi Torinese" , "0399 2826994" }); + m_contacts.append({ "Harvey Chandler", "North Squaw Creek 11", "Madisonville" , "0343 1244492" }); + m_contacts.append({ "Miguel Gomez", "Wild Rose Street 13", "Trussville" , "0343 9826996" }); + m_contacts.append({ "Norma Rodriguez", " Glen Eagles Street 53", "Buffalo" , "0241 5826596" }); + m_contacts.append({ "Shelia Ramirez", "East Miller Ave 68", "Pickerington" , "0346 4844556" }); + m_contacts.append({ "Stephanie Moss", "Piazza Trieste e Trento 77", "Roata Chiusani" , "0363 0510490" }); +} + +int ContactModel::rowCount(const QModelIndex &) const +{ + return m_contacts.count(); +} + +QVariant ContactModel::data(const QModelIndex &index, int role) const +{ + if (index.row() < rowCount()) + switch (role) { + case FullNameRole: return m_contacts.at(index.row()).fullName; + case AddressRole: return m_contacts.at(index.row()).address; + case CityRole: return m_contacts.at(index.row()).city; + case NumberRole: return m_contacts.at(index.row()).number; + default: return QVariant(); + } + return QVariant(); +} + +QHash<int, QByteArray> ContactModel::roleNames() const +{ + static const QHash<int, QByteArray> roles { + { FullNameRole, "fullName" }, + { AddressRole, "address" }, + { CityRole, "city" }, + { NumberRole, "number" } + }; + return roles; +} + +QVariantMap ContactModel::get(int row) const +{ + const Contact contact = m_contacts.value(row); + return { {"fullName", contact.fullName}, {"address", contact.address}, {"city", contact.city}, {"number", contact.number} }; +} + +void ContactModel::append(const QString &fullName, const QString &address, const QString &city, const QString &number) +{ + int row = 0; + while (row < m_contacts.count() && fullName > m_contacts.at(row).fullName) + ++row; + beginInsertRows(QModelIndex(), row, row); + m_contacts.insert(row, {fullName, address, city, number}); + endInsertRows(); +} + +void ContactModel::set(int row, const QString &fullName, const QString &address, const QString &city, const QString &number) +{ + if (row < 0 || row >= m_contacts.count()) + return; + + m_contacts.replace(row, { fullName, address, city, number }); + dataChanged(index(row, 0), index(row, 0), { FullNameRole, AddressRole, CityRole, NumberRole }); +} + +void ContactModel::remove(int row) +{ + if (row < 0 || row >= m_contacts.count()) + return; + + beginRemoveRows(QModelIndex(), row, row); + m_contacts.removeAt(row); + endRemoveRows(); +} diff --git a/examples/quickcontrols2/contactlist/addressmodel.h b/examples/quickcontrols2/contactlist/contactmodel.h index 04417b95..d09602c4 100644 --- a/examples/quickcontrols2/contactlist/addressmodel.h +++ b/examples/quickcontrols2/contactlist/contactmodel.h @@ -48,48 +48,44 @@ ** ****************************************************************************/ -#ifndef ADDRESSMODEL_H -#define ADDRESSMODEL_H +#ifndef CONTACTMODEL_H +#define CONTACTMODEL_H #include <QAbstractListModel> -class AddressModel : public QAbstractListModel +class ContactModel : public QAbstractListModel { Q_OBJECT public: - enum AdressModelRoles { + enum ContactRole { FullNameRole = Qt::DisplayRole, AddressRole = Qt::UserRole, CityRole, NumberRole }; + Q_ENUM(ContactRole) - Q_ENUM(AdressModelRoles) - - AddressModel(QObject *parent = nullptr); + ContactModel(QObject *parent = nullptr); int rowCount(const QModelIndex & = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QHash<int, QByteArray> roleNames() const; - Q_INVOKABLE QString getFullName(int row) const; - Q_INVOKABLE QString getAddress(int row) const; - Q_INVOKABLE QString getCity(int row) const; - Q_INVOKABLE QString getNumber(int row) const; - - Q_INVOKABLE void updateContact(int row, const QString &fullName, const QString &address, const QString &city, const QString &number); - Q_INVOKABLE void removeContact(int row); + Q_INVOKABLE QVariantMap get(int row) const; + Q_INVOKABLE void append(const QString &fullName, const QString &address, const QString &city, const QString &number); + Q_INVOKABLE void set(int row, const QString &fullName, const QString &address, const QString &city, const QString &number); + Q_INVOKABLE void remove(int row); private: - struct Data { + struct Contact { QString fullName; QString address; QString city; QString number; }; - QList<Data> m_data; + QList<Contact> m_contacts; }; -#endif // ADDRESSMODEL_H +#endif // CONTACTMODEL_H diff --git a/examples/quickcontrols2/contactlist/designer/Backend/AddressModel.qml b/examples/quickcontrols2/contactlist/designer/Backend/ContactModel.qml index b9570934..b9570934 100644 --- a/examples/quickcontrols2/contactlist/designer/Backend/AddressModel.qml +++ b/examples/quickcontrols2/contactlist/designer/Backend/ContactModel.qml diff --git a/examples/quickcontrols2/contactlist/designer/Backend/qmldir b/examples/quickcontrols2/contactlist/designer/Backend/qmldir index 45552843..8e2037d4 100644 --- a/examples/quickcontrols2/contactlist/designer/Backend/qmldir +++ b/examples/quickcontrols2/contactlist/designer/Backend/qmldir @@ -1,2 +1,2 @@ module Backend -AddressModel 1.0 AddressModel.qml +ContactModel 1.0 ContactModel.qml diff --git a/examples/quickcontrols2/contactlist/doc/src/qtquickcontrols2-contactlist.qdoc b/examples/quickcontrols2/contactlist/doc/src/qtquickcontrols2-contactlist.qdoc index 93ef569d..2b4de68b 100644 --- a/examples/quickcontrols2/contactlist/doc/src/qtquickcontrols2-contactlist.qdoc +++ b/examples/quickcontrols2/contactlist/doc/src/qtquickcontrols2-contactlist.qdoc @@ -38,32 +38,32 @@ \section1 C++ Backend - \borderedimage image qtquickcontrols2-contactlist.png + \borderedimage qtquickcontrols2-contactlist.png The contact list application allows the user to add, edit, and remove contacts. The actual implementation is done in C++ and exposed as a QAbstractListModel. - The AdressModel C++ class is registered under a namespace and later + The ContactModel C++ class is registered under a namespace and later imported and instantiated by \e MainForm.ui.qml. For more information about registering C++ classes as QML types, see \l {Defining QML Types from C++}. \code #include <QtQml/qqml.h> ... - qmlRegisterType<AdressModel>("Backend", 1, 0, "AdressModel"); + qmlRegisterType<ContactModel>("Backend", 1, 0, "ContactModel"); ... \endcode \section1 Designer Support - In the designer subdirectory, we create a plugin that replaces the AdressModel + In the designer subdirectory, we create a plugin that replaces the ContactModel in Qt Quick Designer. For this to work we add the following line to \e contactlist.pro. \code - QML_DESIGNER_IMPORT_PATH=$$PWD/designer + QML_DESIGNER_IMPORT_PATH = $$PWD/designer \endcode - Because Qt Quick Designer cannot instantiate the AdressModel C++ class, we define + Because Qt Quick Designer cannot instantiate the ContactModel C++ class, we define a mockup using a ListModel. This ensures that the ListView using the model shows something in Qt Quick Designer. diff --git a/examples/quickcontrols2/contactlist/main.cpp b/examples/quickcontrols2/contactlist/main.cpp index 9c75d7b3..ccad6ff3 100644 --- a/examples/quickcontrols2/contactlist/main.cpp +++ b/examples/quickcontrols2/contactlist/main.cpp @@ -48,19 +48,18 @@ ** ****************************************************************************/ -#include "addressmodel.h" - #include <QGuiApplication> #include <QQmlApplicationEngine> +#include "contactmodel.h" + int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType<AddressModel>("Backend", 1, 0, "AddressModel"); + qmlRegisterType<ContactModel>("Backend", 1, 0, "ContactModel"); QQmlApplicationEngine engine; - engine.addImportPath(":/imports"); engine.load(QUrl(QStringLiteral("qrc:/contactlist.qml"))); return app.exec(); diff --git a/src/quicktemplates2/qquickbusyindicator.cpp b/src/quicktemplates2/qquickbusyindicator.cpp index 2cd3f62d..a59a8e5f 100644 --- a/src/quicktemplates2/qquickbusyindicator.cpp +++ b/src/quicktemplates2/qquickbusyindicator.cpp @@ -98,7 +98,6 @@ QQuickBusyIndicator::QQuickBusyIndicator(QQuickItem *parent) : \note The indicator is only visible when this property is set to \c true. The default value is \c true. - */ bool QQuickBusyIndicator::isRunning() const { diff --git a/src/quicktemplates2/qquickprogressbar.cpp b/src/quicktemplates2/qquickprogressbar.cpp index d8ada6f4..9c198312 100644 --- a/src/quicktemplates2/qquickprogressbar.cpp +++ b/src/quicktemplates2/qquickprogressbar.cpp @@ -234,7 +234,6 @@ qreal QQuickProgressBar::visualPosition() const doesn't show how much progress has been made. \image qtquickcontrols2-progressbar-indeterminate.gif - */ bool QQuickProgressBar::isIndeterminate() const { diff --git a/src/quicktemplates2/qquickswipedelegate_p.h b/src/quicktemplates2/qquickswipedelegate_p.h index 49f6c939..ae23672b 100644 --- a/src/quicktemplates2/qquickswipedelegate_p.h +++ b/src/quicktemplates2/qquickswipedelegate_p.h @@ -134,7 +134,7 @@ public: Q_SIGNALS: void positionChanged(); void completeChanged(); - Q_REVISION(1) void completed(); + /*Q_REVISION(1)*/ void completed(); void leftChanged(); void behindChanged(); void rightChanged(); |