discovery: disable invitation button when no user is selected
Change-Id: Ie9a1a51828ee05ae0140a0077587695b4a74b854
Refs: #2483
diff --git a/src/discovery-panel.cpp b/src/discovery-panel.cpp
index 20e36ab..aa91028 100644
--- a/src/discovery-panel.cpp
+++ b/src/discovery-panel.cpp
@@ -51,6 +51,7 @@
ui->join->setEnabled(false);
ui->requestInvitation->setEnabled(false);
ui->InChatroomWarning->clear();
+ m_isParticipant = false;
}
DiscoveryPanel::~DiscoveryPanel()
@@ -97,6 +98,7 @@
DiscoveryPanel::onChatroomListReady(const QStringList& list)
{
m_chatroomList = list;
+ resetPanel();
m_chatroomListModel->setStringList(m_chatroomList);
}
@@ -111,14 +113,14 @@
{
ui->TrustModelData->setText(QString("Hierarchical"));
ui->join->setEnabled(false);
- ui->requestInvitation->setEnabled(true);
+ ui->requestInvitation->setEnabled(false);
break;
}
case 1:
{
ui->TrustModelData->setText(QString("Web Of Trust"));
ui->join->setEnabled(false);
- ui->requestInvitation->setEnabled(true);
+ ui->requestInvitation->setEnabled(false);
break;
}
case 0:
@@ -136,7 +138,8 @@
}
}
ui->InChatroomWarning->clear();
- if (isParticipant) {
+ m_isParticipant = isParticipant;
+ if (m_isParticipant) {
ui->join->setEnabled(false);
ui->requestInvitation->setEnabled(false);
ui->InChatroomWarning->setText(QString("You are already in this chatroom"));
@@ -190,6 +193,9 @@
DiscoveryPanel::onSelectedParticipantChanged(const QItemSelection &selected,
const QItemSelection &deselected)
{
+ if (m_isParticipant)
+ return;
+
QModelIndexList items = selected.indexes();
QString participant = m_rosterListModel->data(items.first(), Qt::DisplayRole).toString();
@@ -201,10 +207,8 @@
break;
}
}
- if (!participantFound) {
- emit warning("This should not happen: DiscoveryPanel::onSelectedParticipantChangeds #1");
- return;
- }
+ ui->requestInvitation->setEnabled(true);
+ BOOST_ASSERT(participantFound);
}
void
diff --git a/src/discovery-panel.hpp b/src/discovery-panel.hpp
index f15906b..1b5bd92 100644
--- a/src/discovery-panel.hpp
+++ b/src/discovery-panel.hpp
@@ -138,6 +138,8 @@
QStringList m_rosterList;
QString m_chatroom;
QString m_participant;
+
+ bool m_isParticipant;
};
} // namespace chronochat