fix go to contact detail from call history

fix time zone cbox
ui fixes
This commit is contained in:
Gaelle Braud 2024-07-11 17:44:48 +02:00
parent a18d86a74c
commit a7f06efb47
12 changed files with 77 additions and 81 deletions

View file

@ -93,7 +93,7 @@ bool ConferenceInfoProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sou
return res; return res;
} else return mFilterType == -1; } else return mFilterType == -1;
} else { } else {
return !mList->haveCurrentDate() && return !mList->haveCurrentDate() && mList->getCount() > 1 &&
mList->getCount() > 1; // if mlist count == 1 there is only the dummy row which we don't display alone mSearchText.isEmpty(); // if mlist count == 1 there is only the dummy row which we don't display alone
} }
} }

View file

@ -176,15 +176,11 @@ QVariant MagicSearchList::data(const QModelIndex &index, int role) const {
int MagicSearchList::findFriendIndexByAddress(const QString &address) { int MagicSearchList::findFriendIndexByAddress(const QString &address) {
int i = 0; int i = 0;
qDebug() << "[MagicSearchList] LOOKING FOR ADDRESS" << address; for (int i = 0; i < getCount();) {
for (auto &item : mList) { auto friendCore = getAt<FriendCore>(i);
qDebug() << "item" << item; if (!friendCore) continue;
auto isFriendCore = item.objectCast<FriendCore>(); for (auto &friendAddress : friendCore->getAllAddresses()) {
if (!isFriendCore) continue;
qDebug() << "[MagicSearchList] SEARCH IN FRIEND" << isFriendCore->getDisplayName();
for (auto &friendAddress : isFriendCore->getAllAddresses()) {
auto map = friendAddress.toMap(); auto map = friendAddress.toMap();
// qDebug() << "COMPARE" << map["address"].toString();
if (map["address"].toString() == address) { if (map["address"].toString() == address) {
return i; return i;
} }

View file

@ -58,20 +58,12 @@ void TimeZoneList::initTimeZones() {
} }
} }
QHash<int, QByteArray> TimeZoneList::roleNames() const {
QHash<int, QByteArray> roles;
roles[Qt::DisplayRole] = "$modelData";
roles[Qt::DisplayRole + 1] = "$timeZoneModel";
return roles;
}
QVariant TimeZoneList::data(const QModelIndex &index, int role) const { QVariant TimeZoneList::data(const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
if (!index.isValid() || row < 0 || row >= mList.count()) return QVariant(); if (!index.isValid() || row < 0 || row >= mList.count()) return QVariant();
auto timeZoneModel = getAt<TimeZoneModel>(row); auto timeZoneModel = getAt<TimeZoneModel>(row);
if (!timeZoneModel) return QVariant(); if (!timeZoneModel) return QVariant();
if (role == Qt::DisplayRole) {
int offset = timeZoneModel->getStandardTimeOffset() / 3600; int offset = timeZoneModel->getStandardTimeOffset() / 3600;
int absOffset = std::abs(offset); int absOffset = std::abs(offset);
@ -80,13 +72,7 @@ QVariant TimeZoneList::data(const QModelIndex &index, int role) const {
.arg(absOffset < 10 ? "0" : "") .arg(absOffset < 10 ? "0" : "")
.arg(absOffset) .arg(absOffset)
.arg(timeZoneModel->getCountryName()) .arg(timeZoneModel->getCountryName())
.arg(timeZoneModel->getTimeZone().comment().isEmpty() ? "" .arg(timeZoneModel->getTimeZone().comment().isEmpty() ? "" : (" - " + timeZoneModel->getTimeZone().comment()));
: (" - " + timeZoneModel->getTimeZone().comment()));
} else {
return QVariant::fromValue(timeZoneModel.get());
}
return QVariant();
} }
int TimeZoneList::get(const QTimeZone &timeZone) const { int TimeZoneList::get(const QTimeZone &timeZone) const {

View file

@ -38,7 +38,6 @@ public:
void initTimeZones(); void initTimeZones();
int get(const QTimeZone &timeZone = QTimeZone::systemTimeZone()) const; int get(const QTimeZone &timeZone = QTimeZone::systemTimeZone()) const;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
private: private:

View file

@ -8,6 +8,11 @@ import SettingsCpp 1.0
ApplicationWindow { ApplicationWindow {
id: mainWindow id: mainWindow
MouseArea {
anchors.fill: parent
onClicked: forceActiveFocus()
}
Component { Component {
id: popupComp id: popupComp
InformationPopup{} InformationPopup{}

View file

@ -21,7 +21,7 @@ Item {
signal addAccountRequest() signal addAccountRequest()
signal openNewCall() signal openNewCall()
signal openCallHistory() signal openCallHistory()
signal displayContact(string contactAddress) signal displayContactRequested(string contactAddress)
signal createContactRequested(string name, string address) signal createContactRequested(string name, string address)
function goToNewCall() { function goToNewCall() {
@ -32,9 +32,9 @@ Item {
tabbar.currentIndex = 0 tabbar.currentIndex = 0
mainItem.openCallHistory() mainItem.openCallHistory()
} }
function goToContactPage(contactAddress) { function displayContactPage(contactAddress) {
tabbar.currentIndex = 1 tabbar.currentIndex = 1
mainItem.displayContact(contactAddress) mainItem.displayContactRequested(contactAddress)
} }
function createContact(name, address) { function createContact(name, address) {
@ -390,11 +390,11 @@ Item {
id: contactPage id: contactPage
Connections { Connections {
target: mainItem target: mainItem
function onCreateContactRequested (name, address) { function onCreateContactRequested(name, address) {
contactPage.createContact(name, address) contactPage.createContact(name, address)
} }
function onDisplayContact (contactAddress) { function onDisplayContactRequested(contactAddress) {
contactPage.displayContact(contactAddress) contactPage.initialFriendToDisplay = contactAddress
} }
} }
} }

View file

@ -33,9 +33,9 @@ AppWindow {
mainWindowStackView.replace(mainPage, StackView.Immediate) mainWindowStackView.replace(mainPage, StackView.Immediate)
mainWindowStackView.currentItem.goToNewCall() mainWindowStackView.currentItem.goToNewCall()
} }
function goToContactPage(contactAddress) { function displayContactPage(contactAddress) {
mainWindowStackView.replace(mainPage, StackView.Immediate) mainWindowStackView.replace(mainPage, StackView.Immediate)
mainWindowStackView.currentItem.goToContactPage(contactAddress) mainWindowStackView.currentItem.displayContactPage(contactAddress)
} }
function transferCallSucceed() { function transferCallSucceed() {
mainWindowStackView.replace(mainPage, StackView.Immediate) mainWindowStackView.replace(mainPage, StackView.Immediate)

View file

@ -49,12 +49,11 @@ ListView {
signal contactAddedToSelection() signal contactAddedToSelection()
function selectContact(address) { function selectContact(address) {
console.log("select", address)
var index = magicSearchProxy.findFriendIndexByAddress(address) var index = magicSearchProxy.findFriendIndexByAddress(address)
console.log("index in selection", index)
if (index != -1) { if (index != -1) {
mainItem.currentIndex = index mainItem.currentIndex = index
} }
return index
} }
function addContactToSelection(address) { function addContactToSelection(address) {
if (multiSelectionEnabled) { if (multiSelectionEnabled) {

View file

@ -293,10 +293,10 @@ ColumnLayout {
ComboBox { ComboBox {
id: timeZoneCbox id: timeZoneCbox
Layout.fillWidth: true Layout.preferredWidth: 307 * DefaultStyle.dp
Layout.preferredHeight: 30 * DefaultStyle.dp Layout.preferredHeight: 30 * DefaultStyle.dp
hoverEnabled: true hoverEnabled: true
listView.implicitHeight: 152 * DefaultStyle.dp listView.implicitHeight: 250 * DefaultStyle.dp
constantImageSource: AppIcons.globe constantImageSource: AppIcons.globe
weight: 700 * DefaultStyle.dp weight: 700 * DefaultStyle.dp
leftMargin: 0 leftMargin: 0
@ -312,33 +312,33 @@ ColumnLayout {
var modelIndex = timeZoneCbox.model.index(currentIndex, 0) var modelIndex = timeZoneCbox.model.index(currentIndex, 0)
mainItem.conferenceInfoGui.core.timeZoneModel = timeZoneCbox.model.data(modelIndex, Qt.DisplayRole + 1) mainItem.conferenceInfoGui.core.timeZoneModel = timeZoneCbox.model.data(modelIndex, Qt.DisplayRole + 1)
} }
}, }
ComboBox { // ComboBox {
id: repeaterCbox // id: repeaterCbox
enabled: false // enabled: false
Component.onCompleted: console.log("TODO : handle conf repetition") // Component.onCompleted: console.log("TODO : handle conf repetition")
constantImageSource: AppIcons.reloadArrow // constantImageSource: AppIcons.reloadArrow
Layout.fillWidth: true // Layout.fillWidth: true
Layout.preferredHeight: height // Layout.preferredHeight: height
height: 30 * DefaultStyle.dp // height: 30 * DefaultStyle.dp
width: 307 * DefaultStyle.dp // width: 307 * DefaultStyle.dp
weight: 700 * DefaultStyle.dp // weight: 700 * DefaultStyle.dp
leftMargin: 0 // leftMargin: 0
currentIndex: 0 // currentIndex: 0
background: Rectangle { // background: Rectangle {
visible: parent.hovered || parent.down // visible: parent.hovered || parent.down
anchors.fill: parent // anchors.fill: parent
color: DefaultStyle.grey_100 // color: DefaultStyle.grey_100
} // }
model: [ // model: [
{text: qsTr("Une fois")}, // {text: qsTr("Une fois")},
{text: qsTr("Tous les jours")}, // {text: qsTr("Tous les jours")},
{text: qsTr("Tous les jours de la semaine (Lun-Ven)")}, // {text: qsTr("Tous les jours de la semaine (Lun-Ven)")},
{text: qsTr("Toutes les semaines")}, // {text: qsTr("Toutes les semaines")},
{text: qsTr("Tous les mois")} // {text: qsTr("Tous les mois")}
] // ]
} // }
] ]

View file

@ -9,7 +9,7 @@ import SettingsCpp
AbstractMainPage { AbstractMainPage {
id: mainItem id: mainItem
noItemButtonText: qsTr("Nouvel appel") noItemButtonText: qsTr("Nouvel appel")
emptyListText: qsTr("Historique d'appel vide") emptyListText: qsTr("Aucun appel")
newItemIconSource: AppIcons.newCall newItemIconSource: AppIcons.newCall
property var selectedRowHistoryGui property var selectedRowHistoryGui
@ -199,6 +199,11 @@ AbstractMainPage {
} }
visible: historyListView.count === 0 visible: historyListView.count === 0
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Binding on text {
when: searchBar.text.length !== 0
value: qsTr("Aucun appel correspondant")
restoreMode: Binding.RestoreBindingOrValue
}
} }
ListView { ListView {
id: historyListView id: historyListView
@ -552,7 +557,7 @@ AbstractMainPage {
} }
onClicked: { onClicked: {
detailOptions.close() detailOptions.close()
if (detailOptions.friendGui) mainWindow.goToContactPage(contactDetail.contactAddress) if (detailOptions.friendGui) mainWindow.displayContactPage(contactDetail.contactAddress)
else mainItem.createContactRequested(contactDetail.contactName, contactDetail.contactAddress) else mainItem.createContactRequested(contactDetail.contactName, contactDetail.contactAddress)
} }
} }
@ -563,6 +568,7 @@ AbstractMainPage {
iconSource: AppIcons.copy iconSource: AppIcons.copy
} }
onClicked: { onClicked: {
detailOptions.close()
var success = UtilsCpp.copyToClipboard(mainItem.selectedRowHistoryGui && mainItem.selectedRowHistoryGui.core.remoteAddress) var success = UtilsCpp.copyToClipboard(mainItem.selectedRowHistoryGui && mainItem.selectedRowHistoryGui.core.remoteAddress)
if (success) UtilsCpp.showInformationPopup(qsTr("Copié"), qsTr("L'adresse a été copiée dans le presse-papier"), true) if (success) UtilsCpp.showInformationPopup(qsTr("Copié"), qsTr("L'adresse a été copiée dans le presse-papier"), true)
else UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Erreur lors de la copie de l'adresse"), false) else UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Erreur lors de la copie de l'adresse"), false)

View file

@ -16,6 +16,8 @@ AbstractMainPage {
// disable left panel contact list interaction while a contact is being edited // disable left panel contact list interaction while a contact is being edited
property bool leftPanelEnabled: true property bool leftPanelEnabled: true
property FriendGui selectedContact property FriendGui selectedContact
property string initialFriendToDisplay
onSelectedContactChanged: { onSelectedContactChanged: {
if (selectedContact) { if (selectedContact) {
if (!rightPanelStackView.currentItem || rightPanelStackView.currentItem.objectName != "contactDetail") rightPanelStackView.push(contactDetail) if (!rightPanelStackView.currentItem || rightPanelStackView.currentItem.objectName != "contactDetail") rightPanelStackView.push(contactDetail)
@ -42,10 +44,6 @@ AbstractMainPage {
rightPanelStackView.push(contactEdition, {"contact": friendGui, "title": qsTr("Modifier contact"), "saveButtonText": qsTr("Enregistrer")}) rightPanelStackView.push(contactEdition, {"contact": friendGui, "title": qsTr("Modifier contact"), "saveButtonText": qsTr("Enregistrer")})
} }
function displayContact(contactAddress) {
contactList.selectContact(contactAddress)
}
// rightPanelStackView.initialItem: contactDetail // rightPanelStackView.initialItem: contactDetail
Binding { Binding {
mainItem.showDefaultItem: false mainItem.showDefaultItem: false
@ -311,6 +309,11 @@ AbstractMainPage {
} }
ContactsList{ ContactsList{
id: contactList id: contactList
onCountChanged: {
if (initialFriendToDisplay.length !== 0) {
if (selectContact(initialFriendToDisplay) != -1) initialFriendToDisplay = ""
}
}
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: contentHeight Layout.preferredHeight: contentHeight
interactive: false interactive: false

View file

@ -124,12 +124,9 @@ AbstractMainPage {
property string objectName: "listLayout" property string objectName: "listLayout"
Control.StackView.onDeactivated: { Control.StackView.onDeactivated: {
mainItem.selectedConference = null mainItem.selectedConference = null
// mainItem.showDefaultItem.visible = false
// mainItem.righPanelStackView.clear()
} }
Control.StackView.onActivated: { Control.StackView.onActivated: {
mainItem.selectedConference = conferenceList.selectedConference mainItem.selectedConference = conferenceList.selectedConference
// mainItem.showDefaultItem = conferenceList.count == 0
} }
Binding { Binding {
target: mainItem target: mainItem
@ -183,6 +180,11 @@ AbstractMainPage {
weight: 800 * DefaultStyle.dp weight: 800 * DefaultStyle.dp
} }
visible: mainItem.showDefaultItem visible: mainItem.showDefaultItem
Binding on text {
when: searchBar.text.length !== 0
value: qsTr("Aucune réunion correspondante")
restoreMode: Binding.RestoreBindingOrValue
}
} }
RowLayout { RowLayout {