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;
auto linAddr = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(addr));
if (!linAddr) Utils::showInformationPopup(tr("Erreur"), tr("Adresse invalide"), false);
else {
mAddressList.append(createFriendAddressVariant(addressLabel, addr)); mAddressList.append(createFriendAddressVariant(addressLabel, addr));
if (mDefaultAddress.isEmpty()) mDefaultAddress = addr; if (mDefaultAddress.isEmpty()) mDefaultAddress = addr;
emit addressChanged(); 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,14 +119,23 @@ 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
spacing: 100 * DefaultStyle.dp
Flickable {
Layout.preferredWidth: contentWidth
Layout.fillHeight: true
Layout.leftMargin: 100 * DefaultStyle.dp
contentWidth: content.implicitWidth
contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
spacing: 20 * DefaultStyle.dp spacing: 20 * DefaultStyle.dp
anchors.fill: parent
FormItemLayout { FormItemLayout {
id: givenName id: givenName
enableErrorText: true enableErrorText: true
@ -164,12 +174,41 @@ RightPanelLayout {
} }
Item{Layout.fillHeight: true} Item{Layout.fillHeight: true}
} }
Control.ScrollView { }
Flickable {
id: addressesFlickable
Layout.preferredWidth: contentWidth
Layout.fillHeight: true Layout.fillHeight: true
contentHeight: content.height 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
@ -179,6 +218,7 @@ RightPanelLayout {
delegate: FormItemLayout { delegate: FormItemLayout {
label: modelData.label label: modelData.label
contentItem: RowLayout { contentItem: RowLayout {
spacing: 10 * DefaultStyle.dp
TextField { TextField {
onTextEdited: { onTextEdited: {
if (text.length != 0) mainItem.contact.core.setAddressAt(index, qsTr("Adresse SIP"), text) if (text.length != 0) mainItem.contact.core.setAddressAt(index, qsTr("Adresse SIP"), text)
@ -205,13 +245,16 @@ RightPanelLayout {
} }
} }
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,23 +265,27 @@ 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: TextField { contentItem: RowLayout {
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 { Button {
Layout.preferredWidth: 24 * DefaultStyle.dp Layout.preferredWidth: 24 * DefaultStyle.dp
Layout.preferredHeight: 24 * DefaultStyle.dp Layout.preferredHeight: 24 * DefaultStyle.dp
Layout.alignment: Qt.AlignVCenter
background: Item{} background: Item{}
icon.source: AppIcons.closeX icon.source: AppIcons.closeX
width: 24 * DefaultStyle.dp width: 24 * DefaultStyle.dp
@ -249,7 +296,10 @@ RightPanelLayout {
} }
} }
} }
}
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