Revert "fix : AvailableAccountModel uses"
This reverts commit 11241729d14649213b96dc4cd0ffbe88536e60f7.
Change-Id: Ia7525b63c032f76a64441e7c7a07556152d927a6
Reviewed-by: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Tuleap: #1579
diff --git a/src/ringmainwindow.cpp b/src/ringmainwindow.cpp
index ea3c370..c529f98 100644
--- a/src/ringmainwindow.cpp
+++ b/src/ringmainwindow.cpp
@@ -1109,8 +1109,10 @@
{
int nbr = gtk_combo_box_get_active(gtk_combo_box);
- const auto idx = AvailableAccountModel::instance().selectionModel()->model()->index(nbr, 0);
- AvailableAccountModel::instance().selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
+ QModelIndex idx = AccountModel::instance().userSelectionModel()->model()->index(nbr, 0);
+ auto account = AccountModel::instance().getAccountByModelIndex(idx);
+
+ AccountModel::instance().setUserChosenAccount(account);
// we closing any view opened to avoid confusion (especially between SIP and Ring protocols).
hide_view_clicked(nullptr, self);
@@ -1254,7 +1256,7 @@
gtk_container_add(GTK_CONTAINER(priv->scrolled_window_history), priv->treeview_history);
/* use this event to refresh the treeview_conversations when account selection changed */
- QObject::connect(AvailableAccountModel::instance().selectionModel(), &QItemSelectionModel::currentChanged, [priv](const QModelIndex& idx){
+ QObject::connect(AccountModel::instance().userSelectionModel(), &QItemSelectionModel::currentChanged, [priv](const QModelIndex& idx){
// next line will refresh the recentmodel so the treeview will do
RecentModel::instance().peopleProxy()->setFilterRegExp("");
@@ -1305,9 +1307,7 @@
&CallModel::incomingCall,
[priv](Call* call) {
// select the revelant account
- const auto idx = call->account()->index();
- AvailableAccountModel::instance().selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
-
+ AccountModel::instance().setUserChosenAccount(call->account());
// clear the regex to make sure the call is shown
RecentModel::instance().peopleProxy()->setFilterRegExp(QRegExp());
diff --git a/src/ringwelcomeview.cpp b/src/ringwelcomeview.cpp
index 7e673f5..7aef575 100644
--- a/src/ringwelcomeview.cpp
+++ b/src/ringwelcomeview.cpp
@@ -30,9 +30,6 @@
#include <QObject>
#include <QItemSelectionModel>
-// LRC
-#include <availableaccountmodel.h>
-
struct _RingWelcomeView
{
GtkScrolledWindow parent;
@@ -200,12 +197,17 @@
gtk_box_pack_start(GTK_BOX(box_main), priv->button_qrcode, TRUE, TRUE, 0);
priv->account_model_data_changed = QObject::connect(
- &AvailableAccountModel::instance(),
- &AvailableAccountModel::currentDefaultAccountChanged,
- [self] (Account* a)
- {
- update_view(self);
- });
+ &AccountModel::instance(),
+ &AccountModel::dataChanged,
+ [self] (const QModelIndex&, const QModelIndex&) { update_view(self); }
+ );
+
+ /* connect to the next signal to update in terms of the account selected */
+ QObject::connect(AccountModel::instance().userSelectionModel(), &QItemSelectionModel::currentChanged,
+ [self](const QModelIndex& idx){
+ Q_UNUSED(idx)
+ update_view(self);
+ });
gtk_widget_show_all(GTK_WIDGET(self));
}
diff --git a/src/utils/accounts.cpp b/src/utils/accounts.cpp
index b9aa20e..bbc182b 100644
--- a/src/utils/accounts.cpp
+++ b/src/utils/accounts.cpp
@@ -20,7 +20,6 @@
#include "accounts.h"
#include <accountmodel.h>
-#include <availableaccountmodel.h>
// LRC
#include <QItemSelectionModel>
@@ -59,8 +58,6 @@
Account*
get_active_ring_account()
{
- const auto idx = AvailableAccountModel::instance().selectionModel()->currentIndex();
- auto account = idx.data(static_cast<int>(Account::Role::Object)).value<Account*>();
-
+ auto account = AccountModel::instance().userChosenAccount();
return (account && account->protocol() == Account::Protocol::RING) ? account : nullptr;
}