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;
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,14 +119,23 @@ 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
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
@ -164,12 +174,41 @@ RightPanelLayout {
}
Item{Layout.fillHeight: true}
}
Control.ScrollView {
}
Flickable {
id: addressesFlickable
Layout.preferredWidth: contentWidth
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 {
id: content
anchors.rightMargin: 10 * DefaultStyle.dp
anchors.fill: parent
spacing: 20 * DefaultStyle.dp
Repeater {
id: addressesList
@ -179,6 +218,7 @@ RightPanelLayout {
delegate: FormItemLayout {
label: modelData.label
contentItem: RowLayout {
spacing: 10 * DefaultStyle.dp
TextField {
onTextEdited: {
if (text.length != 0) mainItem.contact.core.setAddressAt(index, qsTr("Adresse SIP"), text)
@ -205,13 +245,16 @@ RightPanelLayout {
}
}
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,23 +265,27 @@ RightPanelLayout {
}
Repeater {
// phone numbers
id: phoneNumberList
model: VariantList {
model: mainItem.contact && mainItem.contact.core.phoneNumbers || []
}
delegate: RowLayout {
FormItemLayout {
delegate: FormItemLayout {
label: modelData.label
contentItem: TextField {
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
@ -249,7 +296,10 @@ RightPanelLayout {
}
}
}
}
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