Commit 6816fd73 authored by Edric Milaret's avatar Edric Milaret

Revert "use the selection model from the recent model"

This reverts commit 7a8517d2.

Change-Id: I83d2679336c3e83c84e06559b9d27238282882c2
parent 7a8517d2
......@@ -95,6 +95,15 @@ CallWidget::CallWidget(QWidget* parent) :
RecentModel::instance().peopleProxy()->setFilterRole(static_cast<int>(Ring::Role::Name));
RecentModel::instance().peopleProxy()->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->smartList->setModel(RecentModel::instance().peopleProxy());
connect(ui->smartList->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this,
SLOT(smartListSelectionChanged(QItemSelection,QItemSelection)));
connect(ui->smartList, &QTreeView::entered, this, &CallWidget::on_entered);
smartListDelegate_ = new SmartListDelegate();
ui->smartList->setSmartListItemDelegate(smartListDelegate_);
PersonModel::instance().
addCollection<WindowsContactBackend>(LoadOptions::FORCE_ENABLED);
......@@ -120,11 +129,6 @@ CallWidget::CallWidget(QWidget* parent) :
ui->historyList->setExpanded(idx, true);
});
connect(ui->smartList, &QTreeView::entered, this, &CallWidget::on_entered);
smartListDelegate_ = new SmartListDelegate();
ui->smartList->setSmartListItemDelegate(smartListDelegate_);
ui->historyList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->historyList, &QListView::customContextMenuRequested, [=](const QPoint& pos){
if (ui->historyList->currentIndex().parent().isValid()) {
......@@ -156,21 +160,6 @@ CallWidget::CallWidget(QWidget* parent) :
setupOutOfCallIM();
setupSmartListMenu();
connect(RecentModel::instance().selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this,
SLOT(smartListSelectionChanged(QItemSelection,QItemSelection)));
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();
});
} catch (const std::exception& e) {
qDebug() << "INIT ERROR" << e.what();
}
......@@ -184,7 +173,6 @@ CallWidget::~CallWidget()
delete imDelegate_;
delete welcomePageAnim_;
delete messagingPageAnim_;
delete smartListDelegate_;
}
void
......@@ -383,7 +371,12 @@ CallWidget::callStateChanged(Call* call, Call::State previousState)
setActualCall(nullptr);
ui->instantMessagingWidget->setMediaText(nullptr);
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
RecentModel::instance().selectionModel()->clear();
//TODO : Link this so that recentModel get selected correctly
// auto onHoldCall = callModel_->getActiveCalls().first();
// if (onHoldCall != nullptr && onHoldCall->state() == Call::State::HOLD) {
// setActualCall(onHoldCall);
// onHoldCall->performAction(Call::Action::HOLD);
// }
} else if (call->state() == Call::State::CURRENT) {
ui->instantMessagingWidget->setMediaText(actualCall_);
ui->stackedWidget->setCurrentWidget(ui->videoPage);
......@@ -490,17 +483,15 @@ CallWidget::smartListSelectionChanged(const QItemSelection& newSel, const QItemS
if (not newIdx.isValid())
return;
auto newIdxCall = RecentModel::instance().getActiveCall(newIdx);
auto nodeIdx = RecentModel::instance().peopleProxy()->mapToSource(newIdx);
auto newIdxCall = RecentModel::instance().getActiveCall(nodeIdx);
if (newIdxCall && newIdxCall != actualCall_) {
setActualCall(newIdxCall);
if (newIdxCall->state() == Call::State::INCOMING
&& !newIdxCall->account()->isAutoAnswer())
ui->stackedWidget->setCurrentWidget(ui->callInvitePage);
else
ui->stackedWidget->setCurrentWidget(ui->videoPage);
ui->stackedWidget->setCurrentWidget(ui->videoPage);
} else if (newIdxCall == nullptr){
setActualCall(nullptr);
showIMOutOfCall(newIdx);
showIMOutOfCall();
} else {
setActualCall(nullptr);
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
......@@ -561,10 +552,16 @@ CallWidget::on_btnvideo_clicked()
}
void
CallWidget::showIMOutOfCall(const QModelIndex& nodeIdx)
CallWidget::showIMOutOfCall()
{
if (not highLightedIndex_.isValid())
return;
ui->smartList->selectionModel()->select(highLightedIndex_, QItemSelectionModel::ClearAndSelect);
ui->contactMethodComboBox->clear();
auto nodeIdx = RecentModel::instance().peopleProxy()->mapToSource(highLightedIndex_);
ui->imNameLabel->setText(QString(tr("Conversation with %1", "%1 is the contact name"))
.arg(nodeIdx.data(static_cast<int>(Ring::Role::Name)).toString()));
auto cmVector = RecentModel::instance().getContactMethods(nodeIdx);
......@@ -650,7 +647,6 @@ CallWidget::on_ringContactLineEdit_textChanged(const QString& text)
void
CallWidget::on_imBackButton_clicked()
{
RecentModel::instance().selectionModel()->clear();
slideToLeft(welcomePageAnim_, ui->welcomePage);
}
......@@ -675,11 +671,3 @@ CallWidget::slideToRight(QPropertyAnimation* anim, QWidget* widget)
anim->setEasingCurve(QEasingCurve::OutQuad);
anim->start();
}
void
CallWidget::on_smartList_clicked(const QModelIndex& index)
{
RecentModel::instance().selectionModel()->setCurrentIndex(
RecentModel::instance().peopleProxy()->mapToSource(index),
QItemSelectionModel::ClearAndSelect);
}
......@@ -63,7 +63,7 @@ public slots:
void on_ringContactLineEdit_returnPressed();
void on_btnCall_clicked();
void on_btnvideo_clicked();
void showIMOutOfCall(const QModelIndex& newIdx);
void showIMOutOfCall();
inline void on_entered(const QModelIndex& i){highLightedIndex_ = i;};
//UI SLOTS
......@@ -79,7 +79,6 @@ private slots:
void on_contactMethodComboBox_currentIndexChanged(const QString& number);
void on_ringContactLineEdit_textChanged(const QString& text);
void on_imBackButton_clicked();
void on_smartList_clicked(const QModelIndex &index);
private slots:
void callIncoming(Call* call);
......
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