fix ui contact edition

fix new address contact edition
fix history filter
fix auto change end date meeting creation
fix contact with phone number only
fix windows warning
This commit is contained in:
Gaelle Braud 2024-07-22 12:06:50 +02:00
parent cd45e786df
commit cddaa90dcb
5 changed files with 152 additions and 108 deletions

View file

@ -73,7 +73,7 @@ bool CallHistoryProxy::filterAcceptsRow(int sourceRow, const QModelIndex &source
QRegularExpression::CaseInsensitiveOption | QRegularExpression::CaseInsensitiveOption |
QRegularExpression::UseUnicodePropertiesOption); QRegularExpression::UseUnicodePropertiesOption);
auto callLog = qobject_cast<CallHistoryList *>(sourceModel())->getAt<CallHistoryCore>(sourceRow); auto callLog = qobject_cast<CallHistoryList *>(sourceModel())->getAt<CallHistoryCore>(sourceRow);
show = callLog->mRemoteAddress.contains(search); show = callLog->mRemoteAddress.contains(search) || callLog->mDisplayName.contains(search);
} }
return show; return show;

View file

@ -373,9 +373,13 @@ void FriendCore::removeAddress(int index) {
void FriendCore::appendAddress(const QString &addr) { void FriendCore::appendAddress(const QString &addr) {
if (addr.isEmpty()) return; if (addr.isEmpty()) return;
mAddressList.append(createFriendAddressVariant(addressLabel, addr)); auto linAddr = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(addr));
if (mDefaultAddress.isEmpty()) mDefaultAddress = addr; if (!linAddr) Utils::showInformationPopup(tr("Erreur"), tr("Adresse invalide"), false);
emit addressChanged(); else {
mAddressList.append(createFriendAddressVariant(addressLabel, addr));
if (mDefaultAddress.isEmpty()) mDefaultAddress = addr;
emit addressChanged();
}
} }
void FriendCore::resetAddresses(QList<QVariant> newList) { void FriendCore::resetAddresses(QList<QVariant> newList) {
@ -482,9 +486,9 @@ void FriendCore::writeIntoModel(std::shared_ptr<FriendModel> model) const {
std::list<std::shared_ptr<linphone::Address>> addresses; std::list<std::shared_ptr<linphone::Address>> addresses;
for (auto &addr : mAddressList) { for (auto &addr : mAddressList) {
auto friendAddress = addr.toMap(); auto friendAddress = addr.toMap();
auto num = auto address =
linphone::Factory::get()->createAddress(Utils::appStringToCoreString(friendAddress["address"].toString())); linphone::Factory::get()->createAddress(Utils::appStringToCoreString(friendAddress["address"].toString()));
addresses.push_back(num); addresses.push_back(address);
} }
model->resetAddresses(addresses); model->resetAddresses(addresses);

View file

@ -65,9 +65,10 @@ RightPanelLayout {
] ]
content: ColumnLayout { content: ColumnLayout {
anchors.centerIn: parent anchors.fill: parent
// anchors.leftMargin: 103 * DefaultStyle.dp spacing: 63 * DefaultStyle.dp
ColumnLayout { ColumnLayout {
spacing: 8 * DefaultStyle.dp
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 69 * DefaultStyle.dp Layout.topMargin: 69 * DefaultStyle.dp
Avatar { Avatar {
@ -118,58 +119,96 @@ RightPanelLayout {
} }
} }
RowLayout { RowLayout {
Layout.alignment: Qt.AlignHCenter
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
spacing: 100 * DefaultStyle.dp Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 50 * DefaultStyle.dp Layout.topMargin: 50 * DefaultStyle.dp
Layout.bottomMargin: 50 * DefaultStyle.dp Layout.bottomMargin: 50 * DefaultStyle.dp
ColumnLayout { spacing: 100 * DefaultStyle.dp
spacing: 20 * DefaultStyle.dp Flickable {
FormItemLayout { Layout.preferredWidth: contentWidth
id: givenName
enableErrorText: true
label: qsTr("Prénom")
contentItem: TextField {
id: givenNameEdit
initialText: contact.core.givenName
onTextEdited: contact.core.givenName = text
backgroundColor: DefaultStyle.grey_0
backgroundBorderColor: givenName.errorTextItem.opacity != 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200
}
}
FormItemLayout {
label: qsTr("Nom")
contentItem: TextField {
initialText: contact.core.familyName
onTextEdited: contact.core.familyName = text
backgroundColor: DefaultStyle.grey_0
}
}
FormItemLayout {
label: qsTr("Entreprise")
contentItem: TextField {
initialText: contact.core.organization
onTextEdited: contact.core.organization = text
backgroundColor: DefaultStyle.grey_0
}
}
FormItemLayout {
label: qsTr("Fonction")
contentItem: TextField {
initialText: contact.core.job
onTextEdited: contact.core.job = text
backgroundColor: DefaultStyle.grey_0
}
}
Item{Layout.fillHeight: true}
}
Control.ScrollView {
Layout.fillHeight: true Layout.fillHeight: true
Layout.leftMargin: 100 * DefaultStyle.dp
contentWidth: content.implicitWidth
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout {
spacing: 20 * DefaultStyle.dp
anchors.fill: parent
FormItemLayout {
id: givenName
enableErrorText: true
label: qsTr("Prénom")
contentItem: TextField {
id: givenNameEdit
initialText: contact.core.givenName
onTextEdited: contact.core.givenName = text
backgroundColor: DefaultStyle.grey_0
backgroundBorderColor: givenName.errorTextItem.opacity != 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200
}
}
FormItemLayout {
label: qsTr("Nom")
contentItem: TextField {
initialText: contact.core.familyName
onTextEdited: contact.core.familyName = text
backgroundColor: DefaultStyle.grey_0
}
}
FormItemLayout {
label: qsTr("Entreprise")
contentItem: TextField {
initialText: contact.core.organization
onTextEdited: contact.core.organization = text
backgroundColor: DefaultStyle.grey_0
}
}
FormItemLayout {
label: qsTr("Fonction")
contentItem: TextField {
initialText: contact.core.job
onTextEdited: contact.core.job = text
backgroundColor: DefaultStyle.grey_0
}
}
Item{Layout.fillHeight: true}
}
}
Flickable {
id: addressesFlickable
Layout.preferredWidth: contentWidth
Layout.fillHeight: true
Layout.rightMargin: 76 * DefaultStyle.dp
contentWidth: content.implicitWidth
contentHeight: content.implicitHeight
clip: true
flickableDirection: Flickable.VerticalFlick
function ensureVisible(r)
{
if (contentY >= r.y)
contentY = r.y;
else if (contentY+height <= r.y+r.height+content.spacing)
contentY = r.y+r.height-height;
}
Control.ScrollBar.vertical: Control.ScrollBar{
id: scrollbar
active: true
interactive: true
policy: Control.ScrollBar.AlwaysOff
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.leftMargin: 15 * DefaultStyle.dp
}
Control.ScrollBar.horizontal: Control.ScrollBar{
visible: false
}
ColumnLayout { ColumnLayout {
id: content id: content
anchors.rightMargin: 10 * DefaultStyle.dp anchors.fill: parent
spacing: 20 * DefaultStyle.dp spacing: 20 * DefaultStyle.dp
Repeater { Repeater {
id: addressesList id: addressesList
@ -177,41 +216,45 @@ RightPanelLayout {
model: mainItem.contact && mainItem.contact.core.addresses || [] model: mainItem.contact && mainItem.contact.core.addresses || []
} }
delegate: FormItemLayout { delegate: FormItemLayout {
label: modelData.label label: modelData.label
contentItem: RowLayout { contentItem: RowLayout {
TextField { spacing: 10 * DefaultStyle.dp
onTextEdited: { TextField {
if (text.length != 0) mainItem.contact.core.setAddressAt(index, qsTr("Adresse SIP"), text) onTextEdited: {
} if (text.length != 0) mainItem.contact.core.setAddressAt(index, qsTr("Adresse SIP"), text)
property string _initialText: modelData.address
initialText: SettingsCpp.onlyDisplaySipUriUsername ? UtilsCpp.getUsername(_initialText) : _initialText
backgroundColor: DefaultStyle.grey_0
Layout.preferredWidth: width
Layout.preferredHeight: height
}
Button {
Layout.preferredWidth: 24 * DefaultStyle.dp
Layout.preferredHeight: 24 * DefaultStyle.dp
Layout.alignment: Qt.AlignVCenter
background: Item{}
icon.source: AppIcons.closeX
width: 24 * DefaultStyle.dp
height: 24 * DefaultStyle.dp
icon.width: 24 * DefaultStyle.dp
icon.height: 24 * DefaultStyle.dp
onClicked: mainItem.contact.core.removeAddress(index)
} }
property string _initialText: modelData.address
initialText: SettingsCpp.onlyDisplaySipUriUsername ? UtilsCpp.getUsername(_initialText) : _initialText
backgroundColor: DefaultStyle.grey_0
Layout.preferredWidth: width
Layout.preferredHeight: height
}
Button {
Layout.preferredWidth: 24 * DefaultStyle.dp
Layout.preferredHeight: 24 * DefaultStyle.dp
Layout.alignment: Qt.AlignVCenter
background: Item{}
icon.source: AppIcons.closeX
width: 24 * DefaultStyle.dp
height: 24 * DefaultStyle.dp
icon.width: 24 * DefaultStyle.dp
icon.height: 24 * DefaultStyle.dp
onClicked: mainItem.contact.core.removeAddress(index)
} }
} }
}
} }
RowLayout { RowLayout {
onYChanged: addressesFlickable.ensureVisible(this)
spacing: 10 * DefaultStyle.dp
FormItemLayout { FormItemLayout {
label: qsTr("Adresse SIP") label: qsTr("Adresse SIP")
contentItem: TextField { contentItem: TextField {
backgroundColor: DefaultStyle.grey_0 backgroundColor: DefaultStyle.grey_0
Component.onCompleted: text = "sip:"
onEditingFinished: { onEditingFinished: {
if (text.length != 0) mainItem.contact.core.appendAddress(text) if (text.length != 0) mainItem.contact.core.appendAddress(text)
text = "" text = "sip:"
} }
} }
} }
@ -222,34 +265,41 @@ RightPanelLayout {
} }
Repeater { Repeater {
// phone numbers // phone numbers
id: phoneNumberList
model: VariantList { model: VariantList {
model: mainItem.contact && mainItem.contact.core.phoneNumbers || [] model: mainItem.contact && mainItem.contact.core.phoneNumbers || []
} }
delegate: RowLayout { delegate: FormItemLayout {
FormItemLayout { label: modelData.label
label: modelData.label contentItem: RowLayout {
contentItem: TextField { spacing: 10 * DefaultStyle.dp
TextField {
initialText: modelData.address initialText: modelData.address
onTextEdited: { onTextEdited: {
if (text.length != 0) mainItem.contact.core.setPhoneNumberAt(index, qsTr("Téléphone"), text) if (text.length != 0) mainItem.contact.core.setPhoneNumberAt(index, qsTr("Téléphone"), text)
} }
backgroundColor: DefaultStyle.grey_0 backgroundColor: DefaultStyle.grey_0
Layout.preferredWidth: width
Layout.preferredHeight: height
}
Button {
Layout.preferredWidth: 24 * DefaultStyle.dp
Layout.preferredHeight: 24 * DefaultStyle.dp
Layout.alignment: Qt.AlignVCenter
background: Item{}
icon.source: AppIcons.closeX
width: 24 * DefaultStyle.dp
height: 24 * DefaultStyle.dp
icon.width: 24 * DefaultStyle.dp
icon.height: 24 * DefaultStyle.dp
onClicked: mainItem.contact.core.removePhoneNumber(index)
} }
}
Button {
Layout.preferredWidth: 24 * DefaultStyle.dp
Layout.preferredHeight: 24 * DefaultStyle.dp
background: Item{}
icon.source: AppIcons.closeX
width: 24 * DefaultStyle.dp
height: 24 * DefaultStyle.dp
icon.width: 24 * DefaultStyle.dp
icon.height: 24 * DefaultStyle.dp
onClicked: mainItem.contact.core.removePhoneNumber(index)
} }
} }
} }
RowLayout { RowLayout {
onYChanged: addressesFlickable.ensureVisible(this)
spacing: 10 * DefaultStyle.dp
FormItemLayout { FormItemLayout {
id: phoneNumberInput id: phoneNumberInput
label: qsTr("Phone") label: qsTr("Phone")
@ -274,19 +324,6 @@ RightPanelLayout {
} }
Item{Layout.fillHeight: true} Item{Layout.fillHeight: true}
} }
Control.ScrollBar.vertical: Control.ScrollBar{
id: scrollbar
active: true
interactive: true
policy: Control.ScrollBar.AsNeeded
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.leftMargin: 15 * DefaultStyle.dp
}
Control.ScrollBar.horizontal: Control.ScrollBar{
visible: false
}
} }
} }
@ -301,9 +338,9 @@ RightPanelLayout {
topPadding: 11 * DefaultStyle.dp topPadding: 11 * DefaultStyle.dp
bottomPadding: 11 * DefaultStyle.dp bottomPadding: 11 * DefaultStyle.dp
onClicked: { onClicked: {
if (givenNameEdit.text.length === 0 || addressesList.count === 0) { if (givenNameEdit.text.length === 0 || (addressesList.count === 0 && phoneNumberList.count === 0)) {
if (givenNameEdit.text.length === 0) givenName.errorMessage = qsTr("Veuillez saisir un prénom") if (givenNameEdit.text.length === 0) givenName.errorMessage = qsTr("Veuillez saisir un prénom")
if (addressesList.count === 0) addressesErrorText.text = qsTr("Veuillez saisir une adresse ou un numéro de téléphone") if (addressesList.count === 0 && phoneNumberList.count === 0) addressesErrorText.text = qsTr("Veuillez saisir une adresse ou un numéro de téléphone")
return return
} }
mainItem.contact.core.save() mainItem.contact.core.save()

View file

@ -147,7 +147,8 @@ ColumnLayout {
if (!selectedDate || selectedDate == mainItem.conferenceInfoGui.core.dateTime) return if (!selectedDate || selectedDate == mainItem.conferenceInfoGui.core.dateTime) return
mainItem.conferenceInfoGui.core.dateTime = UtilsCpp.createDateTime(selectedDate, allDaySwitch.isAllDay ? 0 : startHour.selectedHour, allDaySwitch.isAllDay ? 0 : startHour.selectedMin) mainItem.conferenceInfoGui.core.dateTime = UtilsCpp.createDateTime(selectedDate, allDaySwitch.isAllDay ? 0 : startHour.selectedHour, allDaySwitch.isAllDay ? 0 : startHour.selectedMin)
if (isCreation) { if (isCreation) {
if (allDaySwitch.position === 0) endDate.calendar.selectedDate = UtilsCpp.addSecs(selectedDate, 3600) startHour.selectedDateTime = UtilsCpp.createDateTime(selectedDate, startHour.selectedHour, startHour.selectedMin)
if (allDaySwitch.position === 0) endDate.calendar.selectedDate = UtilsCpp.addSecs(startHour.selectedDateTime, 3600)
else endDate.calendar.selectedDate = UtilsCpp.createDateTime(selectedDate, 23, 59) else endDate.calendar.selectedDate = UtilsCpp.createDateTime(selectedDate, 23, 59)
} }
} }
@ -164,10 +165,12 @@ ColumnLayout {
contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp
onSelectedHourChanged: { onSelectedHourChanged: {
mainItem.conferenceInfoGui.core.dateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin) mainItem.conferenceInfoGui.core.dateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin)
endDate.calendar.selectedDate = UtilsCpp.addSecs(selectedDateTime, 3600)
endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)//Qt.formatDateTime(UtilsCpp.createDateTime(new Date(), selectedHour == 23 ? 23 : selectedHour + 1, selectedHour == 23 ? 59 : selectedMin), "hh:mm") endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)//Qt.formatDateTime(UtilsCpp.createDateTime(new Date(), selectedHour == 23 ? 23 : selectedHour + 1, selectedHour == 23 ? 59 : selectedMin), "hh:mm")
} }
onSelectedMinChanged: { onSelectedMinChanged: {
mainItem.conferenceInfoGui.core.dateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin) mainItem.conferenceInfoGui.core.dateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin)
endDate.calendar.selectedDate = UtilsCpp.addSecs(selectedDateTime, 3600)
endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)//UtilsCpp.createDateTime(selectedDateTime, selectedHour == 23 ? 23 : selectedHour + 1, selectedHour == 23 ? 59 : selectedMin) endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)//UtilsCpp.createDateTime(selectedDateTime, selectedHour == 23 ? 23 : selectedHour + 1, selectedHour == 23 ? 59 : selectedMin)
} }
} }

View file

@ -1,5 +1,5 @@
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.2 as Control import QtQuick.Controls.Basic 2.2 as Control
import QtQuick.Effects import QtQuick.Effects
import QtQuick.Layouts import QtQuick.Layouts
import Linphone import Linphone