Commit 889fe05f authored by Edric Milaret's avatar Edric Milaret

Revert "transfer: fix segfault in ui"

This reverts commit ee249bfa.

Change-Id: I040efbcbc5b67ae3267146ee41c2e4e47ecee3c4
parent ee249bfa
......@@ -31,15 +31,13 @@ TransferDialog::TransferDialog(QWidget *parent) :
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint);
activeProxy_ = new ActiveCallsProxyModel(CallModel::instance());
activeProxy_->setDynamicSortFilter(false);
ui->activeCallsView->setModel(activeProxy_);
auto activeProxy = new ActiveCallsProxyModel(CallModel::instance());
ui->activeCallsView->setModel(activeProxy);
ui->activeCallsView->clearSelection();
}
TransferDialog::~TransferDialog()
{
removeProxyModel();
delete ui;
}
......@@ -55,10 +53,8 @@ TransferDialog::showEvent(QShowEvent *event)
void
TransferDialog::on_transferButton_clicked()
{
removeProxyModel();
auto callList = CallModel::instance()->getActiveCalls();
Q_FOREACH(Call* c, callList) {
for (auto c : callList) {
if (c->state() == Call::State::CURRENT) {
if (not ui->numberBar->text().isEmpty()) {
auto number = PhoneDirectoryModel::instance()->getNumber(ui->numberBar->text());
......@@ -72,29 +68,18 @@ TransferDialog::on_transferButton_clicked()
}
}
void TransferDialog::removeProxyModel()
{
//This prevent a crash happening in Qt5.5 in QSortFilterProxyModel
ui->activeCallsView->setModel(nullptr);
if (activeProxy_) {
delete activeProxy_;
activeProxy_ = nullptr;
}
}
void
TransferDialog::on_activeCallsView_doubleClicked(const QModelIndex &index)
{
Q_UNUSED(index)
removeProxyModel();
auto callList = CallModel::instance()->getActiveCalls();
Q_FOREACH(Call* c, callList) {
for (auto c : callList) {
if (c->state() == Call::State::CURRENT) {
CallModel::instance()->attendedTransfer(c, selectedCall_);
auto selectedCall = CallModel::instance()->getCall(index);
if (c != selectedCall) {
CallModel::instance()->attendedTransfer(c, selectedCall);
this->close();
return;
}
}
}
}
......
......@@ -36,13 +36,8 @@ public:
}
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
if (not sourceModel() || source_parent.isValid())
return false;
auto idx = sourceModel()->index(source_row,0,source_parent);
if (not idx.isValid())
return false;
return idx.data(static_cast<int>(Call::Role::State))
.value<Call::State>() != Call::State::CURRENT;
return sourceModel()->index(source_row,0,source_parent)
.data(static_cast<int>(Call::Role::State)).value<Call::State>() != Call::State::CURRENT;
}
};
......@@ -66,8 +61,5 @@ private slots:
private:
Ui::TransferDialog *ui;
Call *selectedCall_;
ActiveCallsProxyModel *activeProxy_;
void removeProxyModel();
};
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