From 1eeeca9d202ceaf11b2935ebe590a85145d33ef5 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 18 Nov 2016 14:06:19 +0100 Subject: Overhaul the Contact List example Some renames, API tweaks, and structural changes. Glue the pieces (view/model/dialog) together in contactlist.qml. Change-Id: Id3a31248b391838c6d39f2f0f355e1c35456ccf5 Reviewed-by: Mitch Curtis --- .../quickcontrols2/contactlist/ContactDialog.qml | 49 ++++----- .../contactlist/ContactDialogForm.ui.qml | 119 --------------------- .../quickcontrols2/contactlist/ContactForm.ui.qml | 119 +++++++++++++++++++++ .../quickcontrols2/contactlist/ContactView.ui.qml | 116 ++++++++++++++++++++ .../quickcontrols2/contactlist/MainForm.ui.qml | 110 ------------------- .../quickcontrols2/contactlist/contactlist.qml | 22 +++- .../quickcontrols2/contactlist/contactmodel.cpp | 59 ++++------ examples/quickcontrols2/contactlist/contactmodel.h | 11 +- 8 files changed, 303 insertions(+), 302 deletions(-) delete mode 100644 examples/quickcontrols2/contactlist/ContactDialogForm.ui.qml create mode 100644 examples/quickcontrols2/contactlist/ContactForm.ui.qml create mode 100644 examples/quickcontrols2/contactlist/ContactView.ui.qml delete mode 100644 examples/quickcontrols2/contactlist/MainForm.ui.qml (limited to 'examples') diff --git a/examples/quickcontrols2/contactlist/ContactDialog.qml b/examples/quickcontrols2/contactlist/ContactDialog.qml index fd0ddbfd..1836ea28 100644 --- a/examples/quickcontrols2/contactlist/ContactDialog.qml +++ b/examples/quickcontrols2/contactlist/ContactDialog.qml @@ -49,52 +49,47 @@ ****************************************************************************/ import QtQuick 2.7 -import QtQuick.Window 2.2 import QtQuick.Controls 2.1 Dialog { id: dialog - x: parent.width / 2 - width / 2 - y: parent.height / 2 - height / 2 - standardButtons: Dialog.Ok | Dialog.Cancel - modal: true - focus: true - - property int lastIndex - property QtObject lastModel - - 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.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.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/ContactDialogForm.ui.qml deleted file mode 100644 index f3397bb0..00000000 --- a/examples/quickcontrols2/contactlist/ContactDialogForm.ui.qml +++ /dev/null @@ -1,119 +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$ -** -****************************************************************************/ - -import QtQuick 2.7 -import QtQuick.Layouts 1.0 -import QtQuick.Controls 2.1 - -GridLayout { - id: grid - property alias fullName: fullName - property alias address: address - property alias city: city - property alias number: number - property int minimumInputSize: 120 - property string placeholderText: qsTr("") - - rows: 4 - columns: 2 - - Label { - 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 - placeholderText: grid.placeholderText - } - - Label { - text: qsTr("Address") - Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline - } - - TextField { - id: address - Layout.fillWidth: true - Layout.minimumWidth: grid.minimumInputSize - Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline - placeholderText: grid.placeholderText - } - - Label { - text: qsTr("City") - Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline - } - - TextField { - id: city - Layout.fillWidth: true - Layout.minimumWidth: grid.minimumInputSize - Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline - placeholderText: grid.placeholderText - } - - Label { - text: qsTr("Number") - Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline - } - - TextField { - id: number - Layout.fillWidth: true - Layout.minimumWidth: grid.minimumInputSize - Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline - placeholderText: grid.placeholderText - } -} diff --git a/examples/quickcontrols2/contactlist/ContactForm.ui.qml b/examples/quickcontrols2/contactlist/ContactForm.ui.qml new file mode 100644 index 00000000..f3397bb0 --- /dev/null +++ b/examples/quickcontrols2/contactlist/ContactForm.ui.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 2.1 + +GridLayout { + id: grid + property alias fullName: fullName + property alias address: address + property alias city: city + property alias number: number + property int minimumInputSize: 120 + property string placeholderText: qsTr("") + + rows: 4 + columns: 2 + + Label { + 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 + placeholderText: grid.placeholderText + } + + Label { + text: qsTr("Address") + Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline + } + + TextField { + id: address + Layout.fillWidth: true + Layout.minimumWidth: grid.minimumInputSize + Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline + placeholderText: grid.placeholderText + } + + Label { + text: qsTr("City") + Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline + } + + TextField { + id: city + Layout.fillWidth: true + Layout.minimumWidth: grid.minimumInputSize + Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline + placeholderText: grid.placeholderText + } + + Label { + text: qsTr("Number") + Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline + } + + TextField { + id: number + Layout.fillWidth: true + Layout.minimumWidth: grid.minimumInputSize + Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline + placeholderText: grid.placeholderText + } +} diff --git a/examples/quickcontrols2/contactlist/ContactView.ui.qml b/examples/quickcontrols2/contactlist/ContactView.ui.qml new file mode 100644 index 00000000..30a72b65 --- /dev/null +++ b/examples/quickcontrols2/contactlist/ContactView.ui.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Controls 2.1 +import Backend 1.0 + +Page { + id: page + + signal addContact() + signal editContact(int index) + signal removeContact(int index) + + property alias model: contactModel + + width: 320 + height: 480 + + ListView { + id: listView + anchors.fill: parent + + focus: true + boundsBehavior: Flickable.StopAtBounds + + section.property: "fullName" + section.criteria: ViewSection.FirstCharacter + section.delegate: SectionDelegate { + width: listView.width + } + + delegate: ContactDelegate { + id: delegate + width: listView.width + + Connections { + target: delegate.edit + onClicked: page.editContact(index) + } + + Connections { + target: delegate.remove + onClicked: page.removeContact(index) + } + } + + model: ContactModel { + id: contactModel + } + + ScrollBar.vertical: ScrollBar { } + } + + footer: ToolBar { + id: footer + + ToolButton { + id: addButton + text: qsTr("Add Contact") + anchors.right: parent.right + + Connections { + target: addButton + onClicked: page.addContact() + } + } + } +} diff --git a/examples/quickcontrols2/contactlist/MainForm.ui.qml b/examples/quickcontrols2/contactlist/MainForm.ui.qml deleted file mode 100644 index 1639ecc8..00000000 --- a/examples/quickcontrols2/contactlist/MainForm.ui.qml +++ /dev/null @@ -1,110 +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$ -** -****************************************************************************/ - -import QtQuick 2.7 -import Backend 1.0 -import QtQuick.Controls 2.1 - -Page { - id: form - - width: 320 - height: 480 - - property alias button: button - property alias listView: listView - - property ContactDialog dialog: ContactDialog { - } - - ListView { - id: listView - - focus: true - anchors.fill: parent - snapMode: ListView.SnapToItem - boundsBehavior: Flickable.StopAtBounds - - section.property: "fullName" - section.criteria: ViewSection.FirstCharacter - section.delegate: SectionDelegate { - width: listView.width - } - - delegate: ContactDelegate { - id: delegate - width: listView.width - - Connections { - target: delegate.edit - onClicked: dialog.editContact(listView.model, index) - } - - Connections { - target: delegate.remove - onClicked: listView.model.removeContact(index) - } - } - - model: ContactModel { - } - - ScrollBar.vertical: ScrollBar { - } - } - - footer: ToolBar { - ToolButton { - id: button - text: "Add Contact" - anchors.right: parent.right - } - } -} 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 index 1f435a56..308da2da 100644 --- a/examples/quickcontrols2/contactlist/contactmodel.cpp +++ b/examples/quickcontrols2/contactlist/contactmodel.cpp @@ -85,59 +85,46 @@ QVariant ContactModel::data(const QModelIndex &index, int role) const QHash ContactModel::roleNames() const { - static QHash roleNames { + static const QHash roles { { FullNameRole, "fullName" }, { AddressRole, "address" }, { CityRole, "city" }, { NumberRole, "number" } }; - return roleNames; + return roles; } -void ContactModel::updateContact(int row, - const QString &fullName, - const QString &address, - const QString &city, - const QString &number) +QVariantMap ContactModel::get(int row) const { - if (row >= 0 && row < rowCount()) { - m_contacts.replace(row, { fullName, address, city, number }); - dataChanged(index(row, 0), index(row, 0), { FullNameRole, AddressRole, CityRole, NumberRole }); - } else if (row < 0) { - 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(); - } + const Contact contact = m_contacts.value(row); + return { {"fullName", contact.fullName}, {"address", contact.address}, {"city", contact.city}, {"number", contact.number} }; } -void ContactModel::removeContact(int row) +void ContactModel::append(const QString &fullName, const QString &address, const QString &city, const QString &number) { - if (row >= 0 && row < rowCount()) { - beginRemoveRows(QModelIndex(), row, row); - m_contacts.removeAt(row); - endRemoveRows(); - } + 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(); } -QString ContactModel::getFullName(int row) const +void ContactModel::set(int row, const QString &fullName, const QString &address, const QString &city, const QString &number) { - return m_contacts.value(row).fullName; -} + if (row < 0 || row >= m_contacts.count()) + return; -QString ContactModel::getAddress(int row) const -{ - return m_contacts.value(row).address; + m_contacts.replace(row, { fullName, address, city, number }); + dataChanged(index(row, 0), index(row, 0), { FullNameRole, AddressRole, CityRole, NumberRole }); } -QString ContactModel::getCity(int row) const +void ContactModel::remove(int row) { - return m_contacts.value(row).city; -} + if (row < 0 || row >= m_contacts.count()) + return; -QString ContactModel::getNumber(int row) const -{ - return m_contacts.value(row).number; + beginRemoveRows(QModelIndex(), row, row); + m_contacts.removeAt(row); + endRemoveRows(); } diff --git a/examples/quickcontrols2/contactlist/contactmodel.h b/examples/quickcontrols2/contactlist/contactmodel.h index 2776905f..d09602c4 100644 --- a/examples/quickcontrols2/contactlist/contactmodel.h +++ b/examples/quickcontrols2/contactlist/contactmodel.h @@ -72,13 +72,10 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QHash 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 Contact { -- cgit v1.2.3