From 87059fa345c93cea20341f57b5a64b55e6758453 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 7 Dec 2016 12:40:58 +0100 Subject: [PATCH] unstable --- tests/CMakeLists.txt | 1 + tests/src/app/AvatarProvider.cpp | 7 +---- .../src/components/contacts/ContactModel.cpp | 18 +++++++++++ .../src/components/contacts/ContactModel.hpp | 15 +++++++--- tests/ui/modules/Common/Form/ListForm.qml | 30 +++++++++++++------ tests/ui/views/App/MainWindow/ContactEdit.qml | 27 +++++------------ 6 files changed, 59 insertions(+), 39 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 50d6b9de3..ee0e9e4ce 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,6 +29,7 @@ set(CUSTOM_FLAGS "\ -Wunused \ ") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CUSTOM_FLAGS}") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG") # -------------------------------------------------------------------- # Define packages, libs, sources, headers, resources and languages diff --git a/tests/src/app/AvatarProvider.cpp b/tests/src/app/AvatarProvider.cpp index d4b1d3717..1d70f6cf5 100644 --- a/tests/src/app/AvatarProvider.cpp +++ b/tests/src/app/AvatarProvider.cpp @@ -22,10 +22,5 @@ QImage AvatarProvider::requestImage ( QSize *, const QSize & ) { - QImage image(m_avatars_path + id); - - if (image.isNull()) - qWarning() << QStringLiteral("Unable to load: `%1`.").arg(id); - - return image; + return QImage(m_avatars_path + id); } diff --git a/tests/src/components/contacts/ContactModel.cpp b/tests/src/components/contacts/ContactModel.cpp index 13aadd793..2f7508e3c 100644 --- a/tests/src/components/contacts/ContactModel.cpp +++ b/tests/src/components/contacts/ContactModel.cpp @@ -17,6 +17,11 @@ using namespace std; // =================================================================== +ContactModel::ContactModel (shared_ptr linphone_friend) { + linphone_friend->setData("contact-model", *this); + m_linphone_friend = linphone_friend; +} + Presence::PresenceStatus ContactModel::getPresenceStatus () const { return m_presence_status; } @@ -118,6 +123,19 @@ bool ContactModel::setAvatar (const QString &path) { return true; } +QVariantList ContactModel::getSipAddresses () const { + QVariantList list; + + for (const auto &address : m_linphone_friend->getAddresses()) + list.append(Utils::linphoneStringToQString(address->asString())); + + return list; +} + +void ContactModel::setSipAddresses (const QVariantList &sip_addresses) { + +} + QString ContactModel::getSipAddress () const { return Utils::linphoneStringToQString( m_linphone_friend->getAddress()->asString() diff --git a/tests/src/components/contacts/ContactModel.hpp b/tests/src/components/contacts/ContactModel.hpp index e35837e1a..0e647a67a 100644 --- a/tests/src/components/contacts/ContactModel.hpp +++ b/tests/src/components/contacts/ContactModel.hpp @@ -28,6 +28,13 @@ class ContactModel : public QObject { NOTIFY contactUpdated ); + Q_PROPERTY( + QVariantList sipAddresses + READ getSipAddresses + WRITE setSipAddresses + NOTIFY contactUpdated + ); + Q_PROPERTY( Presence::PresenceStatus presenceStatus READ getPresenceStatus @@ -47,10 +54,7 @@ class ContactModel : public QObject { ); public: - ContactModel (std::shared_ptr linphone_friend) { - linphone_friend->setData("contact-model", *this); - m_linphone_friend = linphone_friend; - } + ContactModel (std::shared_ptr linphone_friend); signals: void contactUpdated (); @@ -62,6 +66,9 @@ private: QString getAvatar () const; bool setAvatar (const QString &path); + QVariantList getSipAddresses () const; + void setSipAddresses (const QVariantList &sip_addresses); + Presence::PresenceStatus getPresenceStatus () const; Presence::PresenceLevel getPresenceLevel () const; diff --git a/tests/ui/modules/Common/Form/ListForm.qml b/tests/ui/modules/Common/Form/ListForm.qml index 5b9d7a33a..7b4a8f773 100644 --- a/tests/ui/modules/Common/Form/ListForm.qml +++ b/tests/ui/modules/Common/Form/ListForm.qml @@ -3,20 +3,19 @@ import QtQuick.Layouts 1.3 import Common 1.0 import Common.Styles 1.0 - +import Utils 1.0 // =================================================================== RowLayout { id: listForm - property alias model: values.model property alias placeholder: placeholder.text property alias title: text.text // ----------------------------------------------------------------- function _addValue (value) { - model.append({ $value: value }) + values.model.append({ $value: value }) if (value.length === 0) { addButton.enabled = false @@ -25,9 +24,11 @@ RowLayout { function _handleEditionFinished (index, text) { if (text.length === 0) { - model.remove(index) + console.log('edition end') + values.model.remove(index) } else { - model.set(index, { $value: text }) + console.log('edition end (text exists)') + values.model.set(index, { $value: text }) } addButton.enabled = true @@ -85,8 +86,11 @@ RowLayout { pointSize: ListFormStyle.value.placeholder.fontSize } - padding: ListFormStyle.value.text.padding - visible: model.count === 0 + padding: ListFormStyle.value.text.padding + visible: { + console.log('placeholder', values.model.count) + return values.model.count === 0 + } verticalAlignment: Text.AlignVCenter } @@ -100,7 +104,10 @@ RowLayout { Layout.fillWidth: true Layout.preferredHeight: count * ListFormStyle.lineHeight interactive: false - visible: count > 0 + visible: { + console.log('values', model.count) + return model.count > 0 + } delegate: Item { implicitHeight: textEdit.height @@ -143,9 +150,14 @@ RowLayout { Component.onCompleted: { if ($value.length === 0) { - textEdit.forceActiveFocus() + textEdit.forceActiveFocus() } } } + + model: ListModel { + ListElement { $value: 'merinos@sip.linphone.org' } + ListElement { $value: 'elisabeth.pro@sip.linphone.org' } + } } } diff --git a/tests/ui/views/App/MainWindow/ContactEdit.qml b/tests/ui/views/App/MainWindow/ContactEdit.qml index f977c873e..538f8df39 100644 --- a/tests/ui/views/App/MainWindow/ContactEdit.qml +++ b/tests/ui/views/App/MainWindow/ContactEdit.qml @@ -137,52 +137,39 @@ ColumnLayout { Flickable { Layout.fillHeight: true Layout.fillWidth: true - Layout.topMargin: 40 ScrollBar.vertical: ForceScrollBar {} - boundsBehavior: Flickable.StopAtBounds clip: true contentHeight: infoList.height flickableDirection: Flickable.VerticalFlick + leftMargin: 40 + rightMargin: 40 + topMargin: 40 + ColumnLayout { - anchors.left: parent.left - anchors.margins: 40 - anchors.right: parent.right id: infoList + anchors.left: parent.left + anchors.right: parent.right + ListForm { title: qsTr('sipAccounts') - model: ListModel { - ListElement { $value: 'merinos@sip.linphone.org' } - ListElement { $value: 'elisabeth.pro@sip.linphone.org' } - } placeholder: qsTr('sipAccountsInput') } ListForm { title: qsTr('address') - model: ListModel { - ListElement { $value: '312 East 10th Street - New York, NY 1009' } - } placeholder: qsTr('addressInput') } ListForm { title: qsTr('emails') - model: ListModel { - ListElement { $value: 'e.meri@gmail.com' } - ListElement { $value: 'toto@truc.machin' } - } placeholder: qsTr('emailsInput') } ListForm { title: qsTr('webSites') - model: ListModel { - ListElement { $value: 'www.totogro.com' } - ListElement { $value: 'www.404.unknown' } - } placeholder: qsTr('webSitesInput') } }