Commit 87059fa3 authored by Ronan Abhamon's avatar Ronan Abhamon

unstable

parent 0ce9a5d5
...@@ -29,6 +29,7 @@ set(CUSTOM_FLAGS "\ ...@@ -29,6 +29,7 @@ set(CUSTOM_FLAGS "\
-Wunused \ -Wunused \
") ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CUSTOM_FLAGS}") 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 # Define packages, libs, sources, headers, resources and languages
......
...@@ -22,10 +22,5 @@ QImage AvatarProvider::requestImage ( ...@@ -22,10 +22,5 @@ QImage AvatarProvider::requestImage (
QSize *, QSize *,
const QSize & const QSize &
) { ) {
QImage image(m_avatars_path + id); return QImage(m_avatars_path + id);
if (image.isNull())
qWarning() << QStringLiteral("Unable to load: `%1`.").arg(id);
return image;
} }
...@@ -17,6 +17,11 @@ using namespace std; ...@@ -17,6 +17,11 @@ using namespace std;
// =================================================================== // ===================================================================
ContactModel::ContactModel (shared_ptr<linphone::Friend> linphone_friend) {
linphone_friend->setData("contact-model", *this);
m_linphone_friend = linphone_friend;
}
Presence::PresenceStatus ContactModel::getPresenceStatus () const { Presence::PresenceStatus ContactModel::getPresenceStatus () const {
return m_presence_status; return m_presence_status;
} }
...@@ -118,6 +123,19 @@ bool ContactModel::setAvatar (const QString &path) { ...@@ -118,6 +123,19 @@ bool ContactModel::setAvatar (const QString &path) {
return true; 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 { QString ContactModel::getSipAddress () const {
return Utils::linphoneStringToQString( return Utils::linphoneStringToQString(
m_linphone_friend->getAddress()->asString() m_linphone_friend->getAddress()->asString()
......
...@@ -28,6 +28,13 @@ class ContactModel : public QObject { ...@@ -28,6 +28,13 @@ class ContactModel : public QObject {
NOTIFY contactUpdated NOTIFY contactUpdated
); );
Q_PROPERTY(
QVariantList sipAddresses
READ getSipAddresses
WRITE setSipAddresses
NOTIFY contactUpdated
);
Q_PROPERTY( Q_PROPERTY(
Presence::PresenceStatus presenceStatus Presence::PresenceStatus presenceStatus
READ getPresenceStatus READ getPresenceStatus
...@@ -47,10 +54,7 @@ class ContactModel : public QObject { ...@@ -47,10 +54,7 @@ class ContactModel : public QObject {
); );
public: public:
ContactModel (std::shared_ptr<linphone::Friend> linphone_friend) { ContactModel (std::shared_ptr<linphone::Friend> linphone_friend);
linphone_friend->setData("contact-model", *this);
m_linphone_friend = linphone_friend;
}
signals: signals:
void contactUpdated (); void contactUpdated ();
...@@ -62,6 +66,9 @@ private: ...@@ -62,6 +66,9 @@ private:
QString getAvatar () const; QString getAvatar () const;
bool setAvatar (const QString &path); bool setAvatar (const QString &path);
QVariantList getSipAddresses () const;
void setSipAddresses (const QVariantList &sip_addresses);
Presence::PresenceStatus getPresenceStatus () const; Presence::PresenceStatus getPresenceStatus () const;
Presence::PresenceLevel getPresenceLevel () const; Presence::PresenceLevel getPresenceLevel () const;
......
...@@ -3,20 +3,19 @@ import QtQuick.Layouts 1.3 ...@@ -3,20 +3,19 @@ import QtQuick.Layouts 1.3
import Common 1.0 import Common 1.0
import Common.Styles 1.0 import Common.Styles 1.0
import Utils 1.0
// =================================================================== // ===================================================================
RowLayout { RowLayout {
id: listForm id: listForm
property alias model: values.model
property alias placeholder: placeholder.text property alias placeholder: placeholder.text
property alias title: text.text property alias title: text.text
// ----------------------------------------------------------------- // -----------------------------------------------------------------
function _addValue (value) { function _addValue (value) {
model.append({ $value: value }) values.model.append({ $value: value })
if (value.length === 0) { if (value.length === 0) {
addButton.enabled = false addButton.enabled = false
...@@ -25,9 +24,11 @@ RowLayout { ...@@ -25,9 +24,11 @@ RowLayout {
function _handleEditionFinished (index, text) { function _handleEditionFinished (index, text) {
if (text.length === 0) { if (text.length === 0) {
model.remove(index) console.log('edition end')
values.model.remove(index)
} else { } else {
model.set(index, { $value: text }) console.log('edition end (text exists)')
values.model.set(index, { $value: text })
} }
addButton.enabled = true addButton.enabled = true
...@@ -86,7 +87,10 @@ RowLayout { ...@@ -86,7 +87,10 @@ RowLayout {
} }
padding: ListFormStyle.value.text.padding padding: ListFormStyle.value.text.padding
visible: model.count === 0 visible: {
console.log('placeholder', values.model.count)
return values.model.count === 0
}
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
...@@ -100,7 +104,10 @@ RowLayout { ...@@ -100,7 +104,10 @@ RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: count * ListFormStyle.lineHeight Layout.preferredHeight: count * ListFormStyle.lineHeight
interactive: false interactive: false
visible: count > 0 visible: {
console.log('values', model.count)
return model.count > 0
}
delegate: Item { delegate: Item {
implicitHeight: textEdit.height implicitHeight: textEdit.height
...@@ -147,5 +154,10 @@ RowLayout { ...@@ -147,5 +154,10 @@ RowLayout {
} }
} }
} }
model: ListModel {
ListElement { $value: 'merinos@sip.linphone.org' }
ListElement { $value: 'elisabeth.pro@sip.linphone.org' }
}
} }
} }
...@@ -137,52 +137,39 @@ ColumnLayout { ...@@ -137,52 +137,39 @@ ColumnLayout {
Flickable { Flickable {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 40
ScrollBar.vertical: ForceScrollBar {} ScrollBar.vertical: ForceScrollBar {}
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
clip: true clip: true
contentHeight: infoList.height contentHeight: infoList.height
flickableDirection: Flickable.VerticalFlick flickableDirection: Flickable.VerticalFlick
leftMargin: 40
rightMargin: 40
topMargin: 40
ColumnLayout { ColumnLayout {
id: infoList
anchors.left: parent.left anchors.left: parent.left
anchors.margins: 40
anchors.right: parent.right anchors.right: parent.right
id: infoList
ListForm { ListForm {
title: qsTr('sipAccounts') title: qsTr('sipAccounts')
model: ListModel {
ListElement { $value: 'merinos@sip.linphone.org' }
ListElement { $value: 'elisabeth.pro@sip.linphone.org' }
}
placeholder: qsTr('sipAccountsInput') placeholder: qsTr('sipAccountsInput')
} }
ListForm { ListForm {
title: qsTr('address') title: qsTr('address')
model: ListModel {
ListElement { $value: '312 East 10th Street - New York, NY 1009' }
}
placeholder: qsTr('addressInput') placeholder: qsTr('addressInput')
} }
ListForm { ListForm {
title: qsTr('emails') title: qsTr('emails')
model: ListModel {
ListElement { $value: 'e.meri@gmail.com' }
ListElement { $value: 'toto@truc.machin' }
}
placeholder: qsTr('emailsInput') placeholder: qsTr('emailsInput')
} }
ListForm { ListForm {
title: qsTr('webSites') title: qsTr('webSites')
model: ListModel {
ListElement { $value: 'www.totogro.com' }
ListElement { $value: 'www.404.unknown' }
}
placeholder: qsTr('webSitesInput') placeholder: qsTr('webSitesInput')
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment