diff --git a/callwidget.cpp b/callwidget.cpp index 382f8f26e968f8725927ec324d3033ca3995b560..cb10747f8263e900289537ea6efe180b6927d243 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -98,11 +98,6 @@ CallWidget::CallWidget(QWidget* parent) : connect(callModel_, SIGNAL(callStateChanged(Call*, Call::State)), this, SLOT(callStateChanged(Call*, Call::State))); - connect(&AccountModel::instance() - , SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)) - , this - , SLOT(findRingAccount(QModelIndex, QModelIndex, QVector<int>))); - RecentModel::instance().peopleProxy()->setFilterRole(static_cast<int>(Ring::Role::Name)); RecentModel::instance().peopleProxy()->setFilterCaseSensitivity(Qt::CaseInsensitive); ui->smartList->setModel(RecentModel::instance().peopleProxy()); @@ -291,33 +286,6 @@ CallWidget::setupSmartListMenu() }); } -void -CallWidget::findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec) -{ - Q_UNUSED(idx1) - Q_UNUSED(idx2) - Q_UNUSED(vec) - - auto a_count = AccountModel::instance().rowCount(); - for (int i = 0; i < a_count; ++i) { - auto idx = AccountModel::instance().index(i, 0); - auto protocol = idx.data(static_cast<int>(Account::Role::Proto)); - if (static_cast<Account::Protocol>(protocol.toUInt()) == Account::Protocol::RING) { - auto account = AccountModel::instance().getAccountByModelIndex(idx); - auto registeredName = account->registeredName(); - auto username = idx.data(static_cast<int>(Account::Role::Username)); - if (registeredName.isEmpty()) { - ui->ringIdLabel->setText(username.toString()); - } else - ui->ringIdLabel->setText(registeredName); - setupQRCode(username.toString()); - - return; - } - } - ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND")); -} - void CallWidget::setupQRCode(QString ringID) { auto rcode = QRcode_encodeString(ringID.toStdString().c_str(), @@ -358,13 +326,14 @@ void CallWidget::setupQRCode(QString ringID) void CallWidget::findRingAccount() { - ui->ringIdLabel->clear(); + bool ringAccountFound = false; auto a_count = AccountModel::instance().rowCount(); for (int i = 0; i < a_count; ++i) { auto idx = AccountModel::instance().index(i, 0); auto protocol = idx.data(static_cast<int>(Account::Role::Proto)); if (static_cast<Account::Protocol>(protocol.toUInt()) == Account::Protocol::RING) { + ringAccountFound = true; auto account = AccountModel::instance().getAccountByModelIndex(idx); if (account->displayName().isEmpty()) account->displayName() = account->alias(); @@ -372,16 +341,9 @@ CallWidget::findRingAccount() WizardDialog dlg(WizardDialog::MIGRATION, account); dlg.exec(); } - if (ui->ringIdLabel->text().isEmpty()) { - auto registeredName = account->registeredName(); - ui->ringIdLabel->setText((registeredName.isEmpty())?account->username():registeredName); - setupQRCode(account->username()); - } } } - - if (ui->ringIdLabel->text().isEmpty()) { - ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND")); + if (!ringAccountFound) { WizardDialog wizardDialog; wizardDialog.exec(); } @@ -718,6 +680,15 @@ CallWidget::selectedAccountChanged(const QModelIndex ¤t, const QModelIndex slidePage(ui->welcomePage); } + // We setup the ringIdLabel and the QRCode + auto protocol = ac->protocol(); + if (protocol == Account::Protocol::RING) { + ui->ringIdLabel->setText((ac->registeredName().isEmpty())?ac->username():ac->registeredName()); + setupQRCode(ac->username()); + } else { + ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND")); + } + // Then, we update the pending CR list with those from the newly selected account if (disconnect(crListSelectionConnection_)) { // The selection model must be deleted by the application (see QT doc). diff --git a/callwidget.h b/callwidget.h index 59bc496279149039af1770e2b2fd152d01f756b8..374ad5635e18f0c4e31e9543445d631fcc6f3898 100644 --- a/callwidget.h +++ b/callwidget.h @@ -87,7 +87,6 @@ private slots: private slots: void callIncoming(Call* call); void callStateChanged(Call* call, Call::State previousState); - void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec); void smartListCurrentChanged(const QModelIndex ¤tIdx, const QModelIndex &previousIdx); void contactReqListCurrentChanged(const QModelIndex ¤tIdx, const QModelIndex &previousIdx); void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);