Commit 08389d29 authored by Nicolas Jager's avatar Nicolas Jager Committed by Guillaume Roguez

Revert "fix : AvailableAccountModel uses"

This reverts commit 11241729.

Change-Id: Ia7525b63c032f76a64441e7c7a07556152d927a6
Reviewed-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Tuleap: #1579
parent 6fa2205d
......@@ -1109,8 +1109,10 @@ selected_account_changed(GtkComboBox *gtk_combo_box, RingMainWindow *self)
{
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 @@ ring_main_window_init(RingMainWindow *win)
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 @@ ring_main_window_init(RingMainWindow *win)
&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());
......
......@@ -30,9 +30,6 @@
#include <QObject>
#include <QItemSelectionModel>
// LRC
#include <availableaccountmodel.h>
struct _RingWelcomeView
{
GtkScrolledWindow parent;
......@@ -200,12 +197,17 @@ ring_welcome_view_init(RingWelcomeView *self)
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));
}
......
......@@ -20,7 +20,6 @@
#include "accounts.h"
#include <accountmodel.h>
#include <availableaccountmodel.h>
// LRC
#include <QItemSelectionModel>
......@@ -59,8 +58,6 @@ force_ring_display_name()
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;
}
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