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::UseUnicodePropertiesOption);
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;

View file

@ -373,9 +373,13 @@ void FriendCore::removeAddress(int index) {
void FriendCore::appendAddress(const QString &addr) {
if (addr.isEmpty()) return;
mAddressList.append(createFriendAddressVariant(addressLabel, addr));
if (mDefaultAddress.isEmpty()) mDefaultAddress = addr;
emit addressChanged();
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));
if (mDefaultAddress.isEmpty()) mDefaultAddress = addr;
emit addressChanged();
}
}
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;
for (auto &addr : mAddressList) {
auto friendAddress = addr.toMap();
auto num =
auto address =
linphone::Factory::get()->createAddress(Utils::appStringToCoreString(friendAddress["address"].toString()));
addresses.push_back(num);
addresses.push_back(address);
}
model->resetAddresses(addresses);

View file

@ -65,9 +65,10 @@ RightPanelLayout {
]
content: ColumnLayout {
anchors.centerIn: parent
// anchors.leftMargin: 103 * DefaultStyle.dp
anchors.fill: parent
spacing: 63 * DefaultStyle.dp
ColumnLayout {
spacing: 8 * DefaultStyle.dp
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 69 * DefaultStyle.dp
Avatar {
@ -118,58 +119,96 @@ RightPanelLayout {
}
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
Layout.fillHeight: true
Layout.fillWidth: true
spacing: 100 * DefaultStyle.dp
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 50 * DefaultStyle.dp
Layout.bottomMargin: 50 * DefaultStyle.dp
ColumnLayout {
spacing: 20 * DefaultStyle.dp
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}
}
Control.ScrollView {
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 {
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 {
id: content
anchors.rightMargin: 10 * DefaultStyle.dp
anchors.fill: parent
spacing: 20 * DefaultStyle.dp
Repeater {
id: addressesList
@ -177,41 +216,45 @@ RightPanelLayout {
model: mainItem.contact && mainItem.contact.core.addresses || []
}
delegate: FormItemLayout {
label: modelData.label
contentItem: RowLayout {
TextField {
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)
label: modelData.label
contentItem: RowLayout {
spacing: 10 * DefaultStyle.dp
TextField {
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)
}
}
}
}
RowLayout {
onYChanged: addressesFlickable.ensureVisible(this)
spacing: 10 * DefaultStyle.dp
FormItemLayout {
label: qsTr("Adresse SIP")
contentItem: TextField {
backgroundColor: DefaultStyle.grey_0
Component.onCompleted: text = "sip:"
onEditingFinished: {
if (text.length != 0) mainItem.contact.core.appendAddress(text)
text = ""
text = "sip:"
}
}
}
@ -222,34 +265,41 @@ RightPanelLayout {
}
Repeater {
// phone numbers
id: phoneNumberList
model: VariantList {
model: mainItem.contact && mainItem.contact.core.phoneNumbers || []
}
delegate: RowLayout {
FormItemLayout {
label: modelData.label
contentItem: TextField {
delegate: FormItemLayout {
label: modelData.label
contentItem: RowLayout {
spacing: 10 * DefaultStyle.dp
TextField {
initialText: modelData.address
onTextEdited: {
if (text.length != 0) mainItem.contact.core.setPhoneNumberAt(index, qsTr("Téléphone"), text)
}
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 {
onYChanged: addressesFlickable.ensureVisible(this)
spacing: 10 * DefaultStyle.dp
FormItemLayout {
id: phoneNumberInput
label: qsTr("Phone")
@ -274,19 +324,6 @@ RightPanelLayout {
}
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
bottomPadding: 11 * DefaultStyle.dp
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 (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
}
mainItem.contact.core.save()

View file

@ -147,7 +147,8 @@ ColumnLayout {
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)
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)
}
}
@ -164,10 +165,12 @@ ColumnLayout {
contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp
onSelectedHourChanged: {
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")
}
onSelectedMinChanged: {
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)
}
}

View file

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