Commit 703caba4 authored by Olivier SOLDANO's avatar Olivier SOLDANO

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
......@@ -172,26 +172,11 @@ CallWidget::CallWidget(QWidget* parent) :
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(),
SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this,
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&)),
this, SLOT(contactLineEdit_registeredNameFound(const Account*,NameDirectory::LookupStatus,const QString&,const QString&)));
......@@ -616,33 +601,21 @@ CallWidget::smartListCurrentChanged(const QModelIndex &currentIdx, const QModelI
if (not currentIdx.isValid())
return;
//catch call of current index
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);
} else if (currentIdxCall == nullptr){
} else if (currentIdxCall == nullptr){ // if there is no call attached to this smartlist index (contact tab)
setActualCall(nullptr);
ui->instantMessagingWidget->hide();
showIMOutOfCall(currentIdx);
} else {
showIMOutOfCall(currentIdx); //change page to messaging page with correct behaviour
} else { // if non defined behaviour disconnect instant messaging and return to welcome page
setActualCall(nullptr);
ui->instantMessagingWidget->hide();
if (imConnection_)
disconnect(imConnection_);
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
CallWidget::placeCall()
......
......@@ -90,7 +90,6 @@ private slots:
void callIncoming(Call* call);
void callStateChanged(Call* call, Call::State previousState);
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 slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
void onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment