Commit 370d07c1 authored by Ronan's avatar Ronan
Browse files

feat(views/App/MainWindow/ContactEdit): view in progress

parent 87059fa3
......@@ -29,7 +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")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG")
# --------------------------------------------------------------------
# Define packages, libs, sources, headers, resources and languages
......
......@@ -116,11 +116,11 @@
</message>
<message>
<source>address</source>
<translation type="unfinished">ADDRESS</translation>
<translation type="obsolete">ADDRESS</translation>
</message>
<message>
<source>addressInput</source>
<translation type="unfinished">Address</translation>
<translation type="obsolete">Address</translation>
</message>
<message>
<source>emails</source>
......@@ -132,11 +132,11 @@
</message>
<message>
<source>webSites</source>
<translation type="unfinished">WEB SITE(S)</translation>
<translation type="obsolete">WEB SITE(S)</translation>
</message>
<message>
<source>webSitesInput</source>
<translation type="unfinished">URL</translation>
<translation type="obsolete">URL</translation>
</message>
<message>
<source>avatarChooserTitle</source>
......
......@@ -108,11 +108,11 @@
</message>
<message>
<source>address</source>
<translation type="unfinished">ADRESSE(S)</translation>
<translation type="obsolete">ADRESSE(S)</translation>
</message>
<message>
<source>addressInput</source>
<translation type="unfinished">Adresse</translation>
<translation type="obsolete">Adresse</translation>
</message>
<message>
<source>emails</source>
......@@ -124,11 +124,11 @@
</message>
<message>
<source>webSites</source>
<translation type="unfinished">SITE(S) WEB</translation>
<translation type="obsolete">SITE(S) WEB</translation>
</message>
<message>
<source>webSitesInput</source>
<translation type="unfinished">URL</translation>
<translation type="obsolete">URL</translation>
</message>
<message>
<source>avatarChooserTitle</source>
......
......@@ -22,13 +22,7 @@ ContactModel::ContactModel (shared_ptr<linphone::Friend> linphone_friend) {
m_linphone_friend = linphone_friend;
}
Presence::PresenceStatus ContactModel::getPresenceStatus () const {
return m_presence_status;
}
Presence::PresenceLevel ContactModel::getPresenceLevel () const {
return Presence::getPresenceLevel(m_presence_status);
}
// -------------------------------------------------------------------
QString ContactModel::getUsername () const {
return Utils::linphoneStringToQString(
......@@ -45,6 +39,8 @@ bool ContactModel::setUsername (const QString &username) {
);
}
// -------------------------------------------------------------------
QString ContactModel::getAvatar () const {
// Find desktop avatar.
list<shared_ptr<belcard::BelCardPhoto> > photos =
......@@ -123,6 +119,8 @@ bool ContactModel::setAvatar (const QString &path) {
return true;
}
// -------------------------------------------------------------------
QVariantList ContactModel::getSipAddresses () const {
QVariantList list;
......@@ -133,9 +131,73 @@ QVariantList ContactModel::getSipAddresses () const {
}
void ContactModel::setSipAddresses (const QVariantList &sip_addresses) {
// TODO.
}
// -------------------------------------------------------------------
QVariantList ContactModel::getCompanies () const {
QVariantList list;
for (const auto &company : m_linphone_friend->getVcard()->getBelcard()->getOrganizations())
list.append(Utils::linphoneStringToQString(company->getValue()));
return list;
}
void ContactModel::setCompanies (const QVariantList &companies) {
// TODO.
}
// -------------------------------------------------------------------
QVariantList ContactModel::getEmails () const {
QVariantList list;
for (const auto &email : m_linphone_friend->getVcard()->getBelcard()->getEmails())
list.append(Utils::linphoneStringToQString(email->getValue()));
return list;
}
void ContactModel::setEmails (const QVariantList &emails) {
// TODO.
}
// -------------------------------------------------------------------
QVariantList ContactModel::getUrls () const {
QVariantList list;
for (const auto &url : m_linphone_friend->getVcard()->getBelcard()->getURLs())
list.append(Utils::linphoneStringToQString(url->getValue()));
return list;
}
void ContactModel::setUrls (const QVariantList &urls) {
// TODO.
}
// -------------------------------------------------------------------
QList<QVariantMap> ContactModel::getAddresses () const {
}
void ContactModel::setAddresses (const QList<QVariantMap> &addresses) {
}
// -------------------------------------------------------------------
Presence::PresenceStatus ContactModel::getPresenceStatus () const {
return m_presence_status;
}
Presence::PresenceLevel ContactModel::getPresenceLevel () const {
return Presence::getPresenceLevel(m_presence_status);
}
QString ContactModel::getSipAddress () const {
return Utils::linphoneStringToQString(
m_linphone_friend->getAddress()->asString()
......
......@@ -35,6 +35,34 @@ class ContactModel : public QObject {
NOTIFY contactUpdated
);
Q_PROPERTY(
QVariantList companies
READ getCompanies
WRITE setCompanies
NOTIFY contactUpdated
);
Q_PROPERTY(
QVariantList emails
READ getEmails
WRITE setEmails
NOTIFY contactUpdated
);
Q_PROPERTY(
QVariantList urls
READ getUrls
WRITE setUrls
NOTIFY contactUpdated
);
Q_PROPERTY(
QList<QVariantMap> addresses
READ getAddresses
WRITE setAddresses
NOTIFY contactUpdated
);
Q_PROPERTY(
Presence::PresenceStatus presenceStatus
READ getPresenceStatus
......@@ -69,6 +97,18 @@ private:
QVariantList getSipAddresses () const;
void setSipAddresses (const QVariantList &sip_addresses);
QVariantList getCompanies () const;
void setCompanies (const QVariantList &companies);
QVariantList getEmails () const;
void setEmails (const QVariantList &emails);
QVariantList getUrls () const;
void setUrls (const QVariantList &urls);
QList<QVariantMap> getAddresses () const;
void setAddresses (const QList<QVariantMap> &addresses);
Presence::PresenceStatus getPresenceStatus () const;
Presence::PresenceLevel getPresenceLevel () const;
......
......@@ -11,6 +11,7 @@ RowLayout {
property alias placeholder: placeholder.text
property alias title: text.text
property var defaultData: []
// -----------------------------------------------------------------
......@@ -24,10 +25,8 @@ RowLayout {
function _handleEditionFinished (index, text) {
if (text.length === 0) {
console.log('edition end')
values.model.remove(index)
} else {
console.log('edition end (text exists)')
values.model.set(index, { $value: text })
}
......@@ -87,10 +86,7 @@ RowLayout {
}
padding: ListFormStyle.value.text.padding
visible: {
console.log('placeholder', values.model.count)
return values.model.count === 0
}
visible: values.model.count === 0
verticalAlignment: Text.AlignVCenter
}
......@@ -104,10 +100,7 @@ RowLayout {
Layout.fillWidth: true
Layout.preferredHeight: count * ListFormStyle.lineHeight
interactive: false
visible: {
console.log('values', model.count)
return model.count > 0
}
visible: model.count > 0
delegate: Item {
implicitHeight: textEdit.height
......@@ -150,14 +143,33 @@ RowLayout {
Component.onCompleted: {
if ($value.length === 0) {
// Magic code. If it's the first inserted value,
// an event or a callback steal the item focus.
// I suppose it's an internal Qt qml event...
//
// So, I choose to run a callback executed after this
// internal event.
Utils.setTimeout(listForm, 0, function () {
textEdit.forceActiveFocus()
})
}
}
}
model: ListModel {
ListElement { $value: 'merinos@sip.linphone.org' }
ListElement { $value: 'elisabeth.pro@sip.linphone.org' }
model: ListModel {}
// ---------------------------------------------------------------
// Init values.
// ---------------------------------------------------------------
Component.onCompleted: {
if (!defaultData) {
return
}
defaultData.forEach(function (data) {
model.append({ $value: data })
})
}
}
}
......@@ -154,24 +154,33 @@ ColumnLayout {
anchors.right: parent.right
ListForm {
title: qsTr('sipAccounts')
placeholder: qsTr('sipAccountsInput')
}
title: qsTr('sipAccounts')
ListForm {
title: qsTr('address')
placeholder: qsTr('addressInput')
defaultData: _contact.sipAddresses
}
ListForm {
title: qsTr('emails')
placeholder: qsTr('emailsInput')
}
ListForm {
title: qsTr('webSites')
placeholder: qsTr('webSitesInput')
defaultData: _contact.emails
}
}
}
}
/************************************************/
/* ListForm { */
/* title: qsTr('address') */
/* placeholder: qsTr('addressInput') */
/* } */
/* */
/* */
/* ListForm { */
/* title: qsTr('webSites') */
/* 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