1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-02 05:45:59 +02:00

conversations: selection refinement for refuseInvitation and blockConversation

1. Decline invites now auto-select the next one and de-select the
   conversion when there are no more invites
2. Block conversations behaves the same as before

Gitlab: #402

Change-Id: Ibd3385e40cb2329d58ea90aa3347dfa4b66a4496
This commit is contained in:
Ming Rui Zhang 2021-06-07 13:33:47 -04:00 committed by Andreas Traczyk
parent f0675434b9
commit cdaa3cfeed
7 changed files with 23 additions and 46 deletions

View file

@ -56,6 +56,7 @@ ConversationsAdapter::ConversationsAdapter(SystemTray* systemTray,
// deselected
convModel_->deselect();
searchModel_->deselect();
Q_EMIT navigateToWelcomePageRequested();
} else {
// selected
const auto& convInfo = lrcInstance_->getConversationFromConvUid(convId);
@ -97,6 +98,7 @@ ConversationsAdapter::ConversationsAdapter(SystemTray* systemTray,
auto row = lrcInstance_->indexOf(convInfo.uid);
const auto index = convSrcModel_->index(row, 0);
Q_EMIT convSrcModel_->dataChanged(index, index);
lrcInstance_->set_selectedConvUid();
});
#ifdef Q_OS_LINUX
@ -174,13 +176,6 @@ ConversationsAdapter::safeInit()
set_currentTypeFilter(lrcInstance_->getCurrentAccountInfo().profileInfo.type);
}
void
ConversationsAdapter::backToWelcomePage()
{
lrcInstance_->deselectConversation();
Q_EMIT navigateToWelcomePageRequested();
}
void
ConversationsAdapter::onCurrentAccountIdChanged()
{
@ -315,12 +310,6 @@ ConversationsAdapter::onNewConversation(const QString& convUid)
updateConversationForNewContact(convUid);
}
void
ConversationsAdapter::onConversationRemoved(const QString&)
{
backToWelcomePage();
}
void
ConversationsAdapter::onConversationCleared(const QString& convUid)
{
@ -467,12 +456,6 @@ ConversationsAdapter::connectConversationModel(bool updateFilter)
&ConversationsAdapter::onNewConversation,
Qt::UniqueConnection);
QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::conversationRemoved,
this,
&ConversationsAdapter::onConversationRemoved,
Qt::UniqueConnection);
QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::conversationCleared,
this,

View file

@ -80,7 +80,6 @@ private Q_SLOTS:
void onConversationUpdated(const QString&);
void onFilterChanged();
void onNewConversation(const QString&);
void onConversationRemoved(const QString&);
void onConversationCleared(const QString&);
void onSearchStatusChanged(const QString&);
void onSearchResultUpdated();
@ -88,7 +87,6 @@ private Q_SLOTS:
void updateConversationFilterData();
private:
void backToWelcomePage();
void updateConversationForNewContact(const QString& convUid);
SmartListModel* conversationSmartListModel_;

View file

@ -419,10 +419,6 @@ Rectangle {
Connections {
target: MessagesAdapter
function onNavigateToWelcomePageRequested() {
backToMainView()
}
function onInvitationAccepted() {
mainViewSidePanel.selectTab(SidePanelTabBar.Conversations)
}

View file

@ -748,7 +748,6 @@ MessagesAdapter::refuseInvitation(const QString& convUid)
setInvitation(false);
if (convUid == currentConvUid_)
currentConvUid_.clear();
Q_EMIT navigateToWelcomePageRequested();
}
void
@ -760,7 +759,6 @@ MessagesAdapter::blockConversation(const QString& convUid)
if (convUid == currentConvUid_)
currentConvUid_.clear();
Q_EMIT contactBanned();
Q_EMIT navigateToWelcomePageRequested();
}
void

View file

@ -101,7 +101,6 @@ protected:
Q_SIGNALS:
void contactBanned();
void navigateToWelcomePageRequested();
void invitationAccepted();
void newInteraction(int type);

View file

@ -30,21 +30,24 @@ void
SelectableListProxyModel::bindSourceModel(QAbstractListModel* model)
{
setSourceModel(model);
connect(sourceModel(),
&QAbstractListModel::dataChanged,
this,
&SelectableListProxyModel::updateSelection,
Qt::UniqueConnection);
connect(model,
&QAbstractListModel::rowsInserted,
this,
&SelectableListProxyModel::updateSelection,
Qt::UniqueConnection);
connect(model,
&QAbstractListModel::rowsRemoved,
this,
&SelectableListProxyModel::updateSelection,
Qt::UniqueConnection);
connect(
sourceModel(),
&QAbstractListModel::dataChanged,
this,
[this] { updateSelection(); },
Qt::UniqueConnection);
connect(
model,
&QAbstractListModel::rowsInserted,
this,
[this] { updateSelection(); },
Qt::UniqueConnection);
connect(
model,
&QAbstractListModel::rowsRemoved,
this,
[this] { updateSelection(true); },
Qt::UniqueConnection);
connect(sourceModel(),
&QAbstractListModel::modelReset,
this,
@ -106,7 +109,7 @@ SelectableListProxyModel::updateContactAvatarUid(const QString& contactUri)
}
void
SelectableListProxyModel::updateSelection()
SelectableListProxyModel::updateSelection(bool rowsRemoved)
{
// if there has been no valid selection made, there is
// nothing to update
@ -117,7 +120,7 @@ SelectableListProxyModel::updateSelection()
auto filteredIndex = mapFromSource(selectedSourceIndex_);
// if the source model is empty, invalidate the selection
if (sourceModel()->rowCount() == 0) {
if (rowCount() == 0 && rowsRemoved) {
set_currentFilteredRow(-1);
Q_EMIT validSelectionChanged();
return;

View file

@ -47,7 +47,7 @@ public:
Q_INVOKABLE void updateContactAvatarUid(const QString& contactUri);
public Q_SLOTS:
void updateSelection();
void updateSelection(bool rowsRemoved = false);
Q_SIGNALS:
void validSelectionChanged();