Skip to content
Snippets Groups Projects
Commit 703caba4 authored by Olivier SOLDANO's avatar Olivier SOLDANO
Browse files

ui: Patch callwidget because of blanck messagingPage

Due to former duplicated code (between lambda connected to smartlist selection change
and the slot of smartlist clicked) and wrong signal caught from smartlist
(selectionChanged instead of currentChanged), the messagingPage was going blank
in certain cases.

Fixed by refactoring the code and catching the signal currentChanged with
smartlistCurrentChanged slot.

Change-Id: If6d2461fc203318708e9c373c8ccb8294207db37
Tuleap: #1314
parent 4433876a
Branches
No related tags found
No related merge requests found
...@@ -172,26 +172,11 @@ CallWidget::CallWidget(QWidget* parent) : ...@@ -172,26 +172,11 @@ CallWidget::CallWidget(QWidget* parent) :
connect(ui->smartList, &SmartList::btnVideoClicked, this, &CallWidget::btnComBarVideoClicked); connect(ui->smartList, &SmartList::btnVideoClicked, this, &CallWidget::btnComBarVideoClicked);
connect(RecentModel::instance().selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this,
SLOT(smartListSelectionChanged(QItemSelection,QItemSelection)));
connect(RecentModel::instance().selectionModel(), connect(RecentModel::instance().selectionModel(),
SIGNAL(currentChanged(QModelIndex,QModelIndex)), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, this,
SLOT(smartListCurrentChanged(QModelIndex,QModelIndex))); SLOT(smartListCurrentChanged(QModelIndex,QModelIndex)));
connect(RecentModel::instance().selectionModel(), &QItemSelectionModel::selectionChanged, [=](const QItemSelection &selected, const QItemSelection &deselected) {
Q_UNUSED(deselected)
if (selected.size()) {
auto idx = selected.indexes().first();
auto realIdx = RecentModel::instance().peopleProxy()->mapFromSource(idx);
ui->smartList->selectionModel()->setCurrentIndex(realIdx, QItemSelectionModel::ClearAndSelect);
} else
ui->smartList->clearSelection();
});
connect(&NameDirectory::instance(), SIGNAL(registeredNameFound(const Account*,NameDirectory::LookupStatus,const QString&,const QString&)), connect(&NameDirectory::instance(), SIGNAL(registeredNameFound(const Account*,NameDirectory::LookupStatus,const QString&,const QString&)),
this, SLOT(contactLineEdit_registeredNameFound(const Account*,NameDirectory::LookupStatus,const QString&,const QString&))); this, SLOT(contactLineEdit_registeredNameFound(const Account*,NameDirectory::LookupStatus,const QString&,const QString&)));
...@@ -616,33 +601,21 @@ CallWidget::smartListCurrentChanged(const QModelIndex &currentIdx, const QModelI ...@@ -616,33 +601,21 @@ CallWidget::smartListCurrentChanged(const QModelIndex &currentIdx, const QModelI
if (not currentIdx.isValid()) if (not currentIdx.isValid())
return; return;
//catch call of current index
auto currentIdxCall = RecentModel::instance().getActiveCall(currentIdx); auto currentIdxCall = RecentModel::instance().getActiveCall(currentIdx);
if (currentIdxCall && currentIdxCall != actualCall_) {
if (currentIdxCall && currentIdxCall != actualCall_) { //if it is different from actual call, switch between the two
setActualCall(currentIdxCall); setActualCall(currentIdxCall);
} else if (currentIdxCall == nullptr){ } else if (currentIdxCall == nullptr){ // if there is no call attached to this smartlist index (contact tab)
setActualCall(nullptr); setActualCall(nullptr);
ui->instantMessagingWidget->hide(); showIMOutOfCall(currentIdx); //change page to messaging page with correct behaviour
showIMOutOfCall(currentIdx); } else { // if non defined behaviour disconnect instant messaging and return to welcome page
} else {
setActualCall(nullptr); setActualCall(nullptr);
ui->instantMessagingWidget->hide();
if (imConnection_) if (imConnection_)
disconnect(imConnection_); disconnect(imConnection_);
ui->stackedWidget->setCurrentWidget(ui->welcomePage); ui->stackedWidget->setCurrentWidget(ui->welcomePage);
} }
} }
void
CallWidget::smartListSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel) {
Q_UNUSED(oldSel)
if (newSel.indexes().empty()) {
setActualCall(nullptr);
return ui->stackedWidget->setCurrentWidget(ui->welcomePage);
}
auto newIdx = newSel.indexes().first();
smartListCurrentChanged(newIdx, newIdx);
}
void void
CallWidget::placeCall() CallWidget::placeCall()
......
...@@ -90,7 +90,6 @@ private slots: ...@@ -90,7 +90,6 @@ private slots:
void callIncoming(Call* call); void callIncoming(Call* call);
void callStateChanged(Call* call, Call::State previousState); void callStateChanged(Call* call, Call::State previousState);
void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec); void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
void smartListSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
void smartListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx); void smartListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir); void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
void onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm); void onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment