Commit 5d1514b8 authored by Guillaume Roguez's avatar Guillaume Roguez

adapt code to LRC API change

LRC API (Singleton's implementation) has changed.
This patch adapats the code to these changes.
Moslty changes deferencement '->' for direct access '.'

Tuleap: #44
Change-Id: Ic87b1306a1239fdb8a6af0affe1ecbc1d16f609c
parent cebc592f
......@@ -106,9 +106,9 @@ update_account_model_selection(GtkTreeSelection *selection, G_GNUC_UNUSED gpoint
{
QModelIndex current = get_index_from_selection(selection);
if (current.isValid())
AccountModel::instance()->selectionModel()->setCurrentIndex(current, QItemSelectionModel::ClearAndSelect);
AccountModel::instance().selectionModel()->setCurrentIndex(current, QItemSelectionModel::ClearAndSelect);
else
AccountModel::instance()->selectionModel()->clearCurrentIndex();
AccountModel::instance().selectionModel()->clearCurrentIndex();
}
static GtkWidget *
......@@ -143,7 +143,7 @@ account_selection_changed(GtkTreeSelection *selection, AccountView *view)
gtk_stack_set_visible_child(GTK_STACK(priv->stack_account), empty_box);
priv->current_account_notebook = NULL;
} else {
Account *account = AccountModel::instance()->getAccountByModelIndex(account_idx);
Account *account = AccountModel::instance().getAccountByModelIndex(account_idx);
/* build new account view */
GtkWidget *hbox_account = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
......@@ -212,9 +212,9 @@ account_active_toggled(GtkCellRendererToggle *renderer, gchar *path, AccountView
/* check if it is the IP2IP account, as we don't want to be able to disable it */
QVariant alias = idx.data(static_cast<int>(Account::Role::Alias));
if (strcmp(alias.value<QString>().toLocal8Bit().constData(), "IP2IP") != 0) {
AccountModel::instance()->setData(idx, QVariant(toggle), Qt::CheckStateRole);
AccountModel::instance().setData(idx, QVariant(toggle), Qt::CheckStateRole);
/* save the account to apply the changed state right away */
AccountModel::instance()->getAccountByModelIndex(idx)->performAction(Account::EditAction::SAVE);
AccountModel::instance().getAccountByModelIndex(idx)->performAction(Account::EditAction::SAVE);
}
}
}
......@@ -255,7 +255,7 @@ remove_account_dialog(AccountView *view, Account *account)
static gboolean
save_account(GtkWidget *working_dialog)
{
AccountModel::instance()->save();
AccountModel::instance().save();
if (working_dialog)
gtk_widget_destroy(working_dialog);
......@@ -273,13 +273,13 @@ remove_account(G_GNUC_UNUSED GtkWidget *entry, AccountView *view)
if (idx.isValid()) {
/* this is a destructive operation, ask the user if they are sure */
Account *account = AccountModel::instance()->getAccountByModelIndex(idx);
Account *account = AccountModel::instance().getAccountByModelIndex(idx);
if (remove_account_dialog(view, account)) {
/* show working dialog in case save operation takes time */
GtkWidget *working = ring_dialog_working(GTK_WIDGET(view), NULL);
gtk_window_present(GTK_WINDOW(working));
AccountModel::instance()->remove(idx);
AccountModel::instance().remove(idx);
/* now save the time it takes to transition the account view to the new account (300ms)
* the save doesn't happen before the "working" dialog is presented
......@@ -310,7 +310,7 @@ add_account(G_GNUC_UNUSED GtkWidget *entry, AccountView *view)
GtkWidget *working = ring_dialog_working(GTK_WIDGET(view), NULL);
gtk_window_present(GTK_WINDOW(working));
auto account = AccountModel::instance()->add(QString(_("New Account")), protocol_idx);
auto account = AccountModel::instance().add(QString(_("New Account")), protocol_idx);
if (account->protocol() == Account::Protocol::RING)
account->setDisplayName(_("New Account"));
......@@ -343,7 +343,7 @@ state_to_string(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(tree_model), iter);
if (idx.isValid()) {
auto account = AccountModel::instance()->getAccountByModelIndex(idx);
auto account = AccountModel::instance().getAccountByModelIndex(idx);
auto humanState = account->toHumanStateName();
/* we want the color of the status text to be the default color if this iter is
......@@ -388,7 +388,7 @@ account_view_init(AccountView *view)
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
account_model = gtk_q_tree_model_new(AccountModel::instance(), 4,
account_model = gtk_q_tree_model_new(&AccountModel::instance(), 4,
Account::Role::Enabled, G_TYPE_BOOLEAN,
Account::Role::Alias, G_TYPE_STRING,
Account::Role::Proto, G_TYPE_STRING,
......@@ -426,7 +426,7 @@ account_view_init(AccountView *view)
/* populate account type combo box */
/* TODO: when to delete this model? */
priv->active_protocols = new ActiveItemProxyModel((QAbstractItemModel *)AccountModel::instance()->protocolModel());
priv->active_protocols = new ActiveItemProxyModel((QAbstractItemModel *)AccountModel::instance().protocolModel());
GtkQSortFilterTreeModel *protocol_model = gtk_q_sort_filter_tree_model_new(
(QSortFilterProxyModel *)priv->active_protocols,
......@@ -442,7 +442,7 @@ account_view_init(AccountView *view)
/* connect signals to and from the selection model of the account model */
priv->protocol_selection_changed = QObject::connect(
AccountModel::instance()->selectionModel(),
AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex & current, const QModelIndex & previous) {
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_account_list));
......@@ -474,7 +474,7 @@ account_view_init(AccountView *view)
g_signal_connect(account_selection, "changed", G_CALLBACK(account_selection_changed), view);
/* select the default protocol */
QModelIndex protocol_idx = AccountModel::instance()->protocolModel()->selectionModel()->currentIndex();
QModelIndex protocol_idx = AccountModel::instance().protocolModel()->selectionModel()->currentIndex();
if (protocol_idx.isValid()) {
protocol_idx = priv->active_protocols->mapFromSource(protocol_idx);
GtkTreeIter protocol_iter;
......
......@@ -47,7 +47,7 @@ client_cb(G_GNUC_UNUSED ESource *source, GAsyncResult *result, G_GNUC_UNUSED gpo
g_clear_error(&error);
} else {
/* got a client for this addressbook, add as backend */
PersonModel::instance()->addCollection<EdsContactBackend, EClient *>(
PersonModel::instance().addCollection<EdsContactBackend, EClient *>(
client, LoadOptions::FORCE_ENABLED);
}
}
......@@ -295,7 +295,7 @@ void EdsContactBackend::parseContact(EContact *contact)
gchar *uid = (gchar *)e_contact_get(contact, E_CONTACT_UID);
if (uid) {
// g_warning("got uid: %s", uid);
existing = PersonModel::instance()->getPersonByUid(uid);
existing = PersonModel::instance().getPersonByUid(uid);
g_free(uid);
}
......@@ -387,7 +387,7 @@ void EdsContactBackend::removeContacts(std::unique_ptr<GSList, void(*)(GSList *)
while(next) {
gchar *uid = (gchar *)next->data;
if (uid) {
Person *p = PersonModel::instance()->getPersonByUid(uid);
Person *p = PersonModel::instance().getPersonByUid(uid);
if (p) {
g_debug("removing: %s", p->formattedName().toUtf8().constData());
deactivate(p);
......
......@@ -137,8 +137,8 @@ choose_contact_view_init(ChooseContactView *self)
ChooseContactViewPrivate *priv = CHOOSE_CONTACT_VIEW_GET_PRIVATE(self);
priv->sorted_contacts = new QSortFilterProxyModel(PersonModel::instance());
priv->sorted_contacts->setSourceModel(PersonModel::instance());
priv->sorted_contacts = new QSortFilterProxyModel(&PersonModel::instance());
priv->sorted_contacts->setSourceModel(&PersonModel::instance());
priv->sorted_contacts->setSortCaseSensitivity(Qt::CaseInsensitive);
priv->sorted_contacts->sort(0);
......
......@@ -366,8 +366,8 @@ contacts_view_init(ContactsView *self)
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(treeview_contacts), FALSE);
/* initial set up to be categorized by name and sorted alphabetically */
priv->q_sorted_proxy = CategorizedContactModel::SortedProxy::instance();
CategorizedContactModel::instance()->setUnreachableHidden(true);
priv->q_sorted_proxy = &CategorizedContactModel::SortedProxy::instance();
CategorizedContactModel::instance().setUnreachableHidden(true);
/* for now we always want to sort by ascending order */
priv->q_sorted_proxy->model()->sort(0);
......
......@@ -465,7 +465,7 @@ void
current_call_view_set_call_info(CurrentCallView *view, const QModelIndex& idx) {
CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
priv->call = CallModel::instance()->getCall(idx);
priv->call = CallModel::instance().getCall(idx);
/* get call image */
QVariant var_i = GlobalInstances::pixmapManipulator().callPhoto(priv->call, QSize(60, 60), false);
......@@ -515,14 +515,14 @@ current_call_view_set_call_info(CurrentCallView *view, const QModelIndex& idx) {
);
/* local renderer */
if (Video::PreviewManager::instance()->isPreviewing())
if (Video::PreviewManager::instance().isPreviewing())
video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget),
Video::PreviewManager::instance()->previewRenderer(),
Video::PreviewManager::instance().previewRenderer(),
VIDEO_RENDERER_LOCAL);
/* callback for local renderer */
priv->local_renderer_connection = QObject::connect(
Video::PreviewManager::instance(),
&Video::PreviewManager::instance(),
&Video::PreviewManager::previewStarted,
[priv](Video::Renderer *renderer) {
video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget),
......
......@@ -92,7 +92,7 @@ save_cb(EditContactView *self)
/* get the selected number category */
const auto& idx = gtk_combo_box_get_index(GTK_COMBO_BOX(priv->combobox_detail));
if (idx.isValid()) {
auto category = NumberCategoryModel::instance()->getCategory(idx.data().toString());
auto category = NumberCategoryModel::instance().getCategory(idx.data().toString());
priv->cm->setCategory(category);
}
......@@ -114,7 +114,7 @@ save_cb(EditContactView *self)
numbers << priv->cm;
priv->person->setContactMethods(numbers);
PersonModel::instance()->addNewPerson(priv->person, collection);
PersonModel::instance().addNewPerson(priv->person, collection);
} else {
auto numbers = priv->person->phoneNumbers();
numbers << priv->cm;
......@@ -161,7 +161,7 @@ edit_contact_view_init(EditContactView *self)
renderer, "text", 0, NULL);
/* get all the available contact backends (addressbooks) */
const auto& collections = PersonModel::instance()->enabledCollections();
const auto& collections = PersonModel::instance().enabledCollections();
for (int i = 0; i < collections.size(); ++i) {
GtkTreeIter iter;
gtk_list_store_append(addressbook_model, &iter);
......@@ -190,10 +190,10 @@ edit_contact_view_init(EditContactView *self)
/* model for the available details to choose from */
gtk_combo_box_set_qmodel(GTK_COMBO_BOX(priv->combobox_detail),
(QAbstractItemModel *)NumberCategoryModel::instance(), NULL);
(QAbstractItemModel *)&NumberCategoryModel::instance(), NULL);
/* set "home" as the default number category */
const auto& idx = NumberCategoryModel::instance()->nameToIndex(C_("Phone number category", "home"));
const auto& idx = NumberCategoryModel::instance().nameToIndex(C_("Phone number category", "home"));
if (idx.isValid())
gtk_combo_box_set_active_index(GTK_COMBO_BOX(priv->combobox_detail), idx);
......
......@@ -79,7 +79,7 @@ static void
history_limit_changed(GtkAdjustment *adjustment, G_GNUC_UNUSED gpointer user_data)
{
int limit = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment));
CategorizedHistoryModel::instance()->setHistoryLimit(limit);
CategorizedHistoryModel::instance().setHistoryLimit(limit);
}
static gboolean
......@@ -120,7 +120,7 @@ clear_history(G_GNUC_UNUSED GtkWidget *button, GeneralSettingsView *self)
g_return_if_fail(IS_GENERAL_SETTINGS_VIEW(self));
if (clear_history_dialog(self) )
CategorizedHistoryModel::instance()->clearAllCollections();
CategorizedHistoryModel::instance().clearAllCollections();
}
static void
......@@ -145,7 +145,7 @@ general_settings_view_init(GeneralSettingsView *self)
/* history limit */
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_history_duration),
CategorizedHistoryModel::instance()->historyLimit());
CategorizedHistoryModel::instance().historyLimit());
g_signal_connect(priv->adjustment_history_duration,
"value-changed", G_CALLBACK(history_limit_changed), NULL);
......
......@@ -160,7 +160,7 @@ copy_history_item(G_GNUC_UNUSED GtkWidget *item, GtkTreeView *treeview)
*
* if (idx.isValid()) {
* g_debug("deleting history item");
* CategorizedHistoryModel::instance()->removeRow(idx.row(), idx.parent());
* CategorizedHistoryModel::instance().removeRow(idx.row(), idx.parent());
* }
* }
*/
......@@ -387,7 +387,7 @@ history_view_init(HistoryView *self)
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(treeview_history), FALSE);
/* instantiate history proxy model */
priv->q_sorted_proxy = CategorizedHistoryModel::SortedProxy::instance();
priv->q_sorted_proxy = &CategorizedHistoryModel::SortedProxy::instance();
/* for now there is no way in the UI to pick whether sorting is ascending
* or descending, so we do it in the code when the category changes */
......
......@@ -171,7 +171,7 @@ void
incoming_call_view_set_call_info(IncomingCallView *view, const QModelIndex& idx) {
IncomingCallViewPrivate *priv = INCOMING_CALL_VIEW_GET_PRIVATE(view);
Call *call = CallModel::instance()->getCall(idx);
Call *call = CallModel::instance().getCall(idx);
/* get call image */
QVariant var_i = GlobalInstances::pixmapManipulator().callPhoto(call, QSize(110, 110), false);
......
......@@ -101,7 +101,7 @@ media_settings_view_dispose(GObject *object)
/* make sure to stop the preview if this view is getting destroyed */
if (priv->video_started_by_settings) {
Video::PreviewManager::instance()->stopPreview();
Video::PreviewManager::instance().stopPreview();
priv->video_started_by_settings = FALSE;
}
......@@ -196,36 +196,36 @@ media_settings_view_init(MediaSettingsView *view)
MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(view);
priv->device_selection = connect_combo_box_qmodel(GTK_COMBO_BOX(priv->combobox_device),
Video::ConfigurationProxy::deviceModel(),
Video::ConfigurationProxy::deviceSelectionModel());
&Video::ConfigurationProxy::deviceModel(),
&Video::ConfigurationProxy::deviceSelectionModel());
priv->channel_selection = connect_combo_box_qmodel(GTK_COMBO_BOX(priv->combobox_channel),
Video::ConfigurationProxy::channelModel(),
Video::ConfigurationProxy::channelSelectionModel());
&Video::ConfigurationProxy::channelModel(),
&Video::ConfigurationProxy::channelSelectionModel());
priv->resolution_selection = connect_combo_box_qmodel(GTK_COMBO_BOX(priv->combobox_resolution),
Video::ConfigurationProxy::resolutionModel(),
Video::ConfigurationProxy::resolutionSelectionModel());
&Video::ConfigurationProxy::resolutionModel(),
&Video::ConfigurationProxy::resolutionSelectionModel());
priv->rate_selection = connect_combo_box_qmodel(GTK_COMBO_BOX(priv->combobox_framerate),
Video::ConfigurationProxy::rateModel(),
Video::ConfigurationProxy::rateSelectionModel());
&Video::ConfigurationProxy::rateModel(),
&Video::ConfigurationProxy::rateSelectionModel());
/* audio settings */
/* instantiate all the models before the manager model first */
Audio::Settings::instance()->alsaPluginModel();
Audio::Settings::instance()->ringtoneDeviceModel();
Audio::Settings::instance()->inputDeviceModel();
Audio::Settings::instance()->outputDeviceModel();
Audio::Settings::instance().alsaPluginModel();
Audio::Settings::instance().ringtoneDeviceModel();
Audio::Settings::instance().inputDeviceModel();
Audio::Settings::instance().outputDeviceModel();
priv->manager_selection = connect_combo_box_qmodel(GTK_COMBO_BOX(priv->combobox_manager),
Audio::Settings::instance()->managerModel(),
Audio::Settings::instance()->managerModel()->selectionModel());
Audio::Settings::instance().managerModel(),
Audio::Settings::instance().managerModel()->selectionModel());
priv->ringtone_selection = connect_combo_box_qmodel(GTK_COMBO_BOX(priv->combobox_ringtone),
Audio::Settings::instance()->ringtoneDeviceModel(),
Audio::Settings::instance()->ringtoneDeviceModel()->selectionModel());
Audio::Settings::instance().ringtoneDeviceModel(),
Audio::Settings::instance().ringtoneDeviceModel()->selectionModel());
priv->input_selection = connect_combo_box_qmodel(GTK_COMBO_BOX(priv->combobox_input),
Audio::Settings::instance()->inputDeviceModel(),
Audio::Settings::instance()->inputDeviceModel()->selectionModel());
Audio::Settings::instance().inputDeviceModel(),
Audio::Settings::instance().inputDeviceModel()->selectionModel());
priv->output_selection = connect_combo_box_qmodel(GTK_COMBO_BOX(priv->combobox_output),
Audio::Settings::instance()->outputDeviceModel(),
Audio::Settings::instance()->outputDeviceModel()->selectionModel());
Audio::Settings::instance().outputDeviceModel(),
Audio::Settings::instance().outputDeviceModel()->selectionModel());
}
......@@ -275,17 +275,17 @@ media_settings_view_show_preview(MediaSettingsView *self, gboolean show_preview)
gtk_widget_show_all(priv->video_widget);
gtk_box_pack_start(GTK_BOX(priv->hbox_camera), priv->video_widget, TRUE, TRUE, 0);
if (Video::PreviewManager::instance()->isPreviewing()) {
if (Video::PreviewManager::instance().isPreviewing()) {
priv->video_started_by_settings = FALSE;
/* local renderer, but set as "remote" so that it takes up the whole screen */
video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget),
Video::PreviewManager::instance()->previewRenderer(),
Video::PreviewManager::instance().previewRenderer(),
VIDEO_RENDERER_REMOTE);
} else {
priv->video_started_by_settings = TRUE;
priv->local_renderer_connection = QObject::connect(
Video::PreviewManager::instance(),
&Video::PreviewManager::instance(),
&Video::PreviewManager::previewStarted,
[=](Video::Renderer *renderer) {
video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget),
......@@ -293,11 +293,11 @@ media_settings_view_show_preview(MediaSettingsView *self, gboolean show_preview)
VIDEO_RENDERER_REMOTE);
}
);
Video::PreviewManager::instance()->startPreview();
Video::PreviewManager::instance().startPreview();
}
} else {
if (priv->video_started_by_settings) {
Video::PreviewManager::instance()->stopPreview();
Video::PreviewManager::instance().stopPreview();
QObject::disconnect(priv->local_renderer_connection);
priv->video_started_by_settings = FALSE;
}
......
......@@ -107,7 +107,7 @@ check_connection_cb(GtkWidget *warning_dialog)
gtk_widget_destroy(warning_dialog);
if ((!CallModel::instance()->isConnected()) || (!CallModel::instance()->isValid())) {
if ((!CallModel::instance().isConnected()) || (!CallModel::instance().isValid())) {
g_warning("could not reconnect to the daemon");
auto quit_dialog = ring_quitting_dialog();
......
......@@ -67,11 +67,11 @@ static void
update_call_model_selection(GtkTreeSelection *selection, G_GNUC_UNUSED gpointer user_data)
{
auto current_proxy = get_index_from_selection(selection);
auto current = RecentModel::instance()->peopleProxy()->mapToSource(current_proxy);
if (auto call_to_select = RecentModel::instance()->getActiveCall(current)) {
CallModel::instance()->selectCall(call_to_select);
auto current = RecentModel::instance().peopleProxy()->mapToSource(current_proxy);
if (auto call_to_select = RecentModel::instance().getActiveCall(current)) {
CallModel::instance().selectCall(call_to_select);
} else {
CallModel::instance()->selectionModel()->clearCurrentIndex();
CallModel::instance().selectionModel()->clearCurrentIndex();
}
}
......@@ -236,7 +236,7 @@ render_call_duration(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
{
// check if there are any children (calls); we need to convert to source model in
// case there is only one
auto idx_source = RecentModel::instance()->peopleProxy()->mapToSource(idx);
auto idx_source = RecentModel::instance().peopleProxy()->mapToSource(idx);
auto duration = idx.data(static_cast<int>(Ring::Role::Length));
if (idx_source.isValid()
&& (idx_source.model()->rowCount(idx_source) == 1)
......@@ -509,7 +509,7 @@ recent_contacts_view_init(RecentContactsView *self)
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(self), FALSE);
GtkQSortFilterTreeModel *recent_model = gtk_q_sort_filter_tree_model_new(
RecentModel::instance()->peopleProxy(),
RecentModel::instance().peopleProxy(),
1,
Qt::DisplayRole, G_TYPE_STRING);
......@@ -572,21 +572,21 @@ recent_contacts_view_init(RecentContactsView *self)
/* try to select the same call as the call model */
priv->selection_updated = QObject::connect(
CallModel::instance()->selectionModel(),
CallModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[self, recent_model](const QModelIndex current, G_GNUC_UNUSED const QModelIndex & previous) {
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self));
/* select the current */
auto call = CallModel::instance()->getCall(current);
auto recent_idx = RecentModel::instance()->getIndex(call);
auto call = CallModel::instance().getCall(current);
auto recent_idx = RecentModel::instance().getIndex(call);
if (recent_idx.isValid()) {
QModelIndex proxy_selection; // the index to select in the peopleProxy
if (RecentModel::instance()->rowCount(recent_idx.parent()) > 1) {
proxy_selection = RecentModel::instance()->peopleProxy()->mapFromSource(recent_idx);
if (RecentModel::instance().rowCount(recent_idx.parent()) > 1) {
proxy_selection = RecentModel::instance().peopleProxy()->mapFromSource(recent_idx);
} else {
// if single call, select the parent
proxy_selection = RecentModel::instance()->peopleProxy()->mapFromSource(recent_idx.parent());
proxy_selection = RecentModel::instance().peopleProxy()->mapFromSource(recent_idx.parent());
}
GtkTreeIter new_iter;
......
......@@ -182,7 +182,7 @@ activate_action(GSimpleAction *action, G_GNUC_UNUSED GVariant *parameter, gpoint
key.ptr = user_data;
UserActionModel::Action a = static_cast<UserActionModel::Action>(key.value);
UserActionModel* uam = CallModel::instance()->userActionModel();
UserActionModel* uam = CallModel::instance().userActionModel();
uam << a;
}
......@@ -324,14 +324,14 @@ ring_client_startup(GApplication *app)
/* make sure basic number categories exist, in case user has no contacts
* from which these would be automatically created
*/
NumberCategoryModel::instance()->addCategory("work", QVariant());
NumberCategoryModel::instance()->addCategory("home", QVariant());
NumberCategoryModel::instance().addCategory("work", QVariant());
NumberCategoryModel::instance().addCategory("home", QVariant());
/* add backends */
CategorizedHistoryModel::instance()->addCollection<LocalHistoryCollection>(LoadOptions::FORCE_ENABLED);
CategorizedHistoryModel::instance().addCollection<LocalHistoryCollection>(LoadOptions::FORCE_ENABLED);
/* fallback backend for vcards */
PersonModel::instance()->addCollection<FallbackPersonCollection>(LoadOptions::FORCE_ENABLED);
PersonModel::instance().addCollection<FallbackPersonCollection>(LoadOptions::FORCE_ENABLED);
/* EDS backend(s) */
load_eds_sources(priv->cancellable);
......@@ -352,7 +352,7 @@ ring_client_startup(GApplication *app)
ring_accelerators(RING_CLIENT(app));
/* Bind GActions to the UserActionModel */
UserActionModel* uam = CallModel::instance()->userActionModel();
UserActionModel* uam = CallModel::instance().userActionModel();
QHash<int, GSimpleAction*> actionHash;
actionHash[ (int)UserActionModel::Action::ACCEPT ] = G_SIMPLE_ACTION(g_action_map_lookup_action(G_ACTION_MAP(app), "accept"));
actionHash[ (int)UserActionModel::Action::HOLD ] = G_SIMPLE_ACTION(g_action_map_lookup_action(G_ACTION_MAP(app), "hold"));
......@@ -387,7 +387,7 @@ ring_client_startup(GApplication *app)
});
/* show window on incoming calls (if the option is set)*/
QObject::connect(CallModel::instance(), &CallModel::incomingCall,
QObject::connect(&CallModel::instance(), &CallModel::incomingCall,
[app] (G_GNUC_UNUSED Call *call) {
RingClient *client = RING_CLIENT(app);
RingClientPrivate *priv = RING_CLIENT_GET_PRIVATE(client);
......@@ -398,7 +398,7 @@ ring_client_startup(GApplication *app)
/* send call notifications */
ring_notify_init();
QObject::connect(CallModel::instance(), &CallModel::incomingCall,
QObject::connect(&CallModel::instance(), &CallModel::incomingCall,
[] (Call *call) { ring_notify_incoming_call(call);}
);
......
......@@ -167,13 +167,13 @@ call_selection_changed(const QModelIndex& idx, gpointer win)
new_call_view = incoming_call_view_new();
incoming_call_view_set_call_info(INCOMING_CALL_VIEW(new_call_view), idx);
/* use the pointer of the call as a unique name */
new_call_view_name = g_strdup_printf("%p_incoming", (void *)CallModel::instance()->getCall(idx));
new_call_view_name = g_strdup_printf("%p_incoming", (void *)CallModel::instance().getCall(idx));
break;
case Call::LifeCycleState::PROGRESS:
new_call_view = current_call_view_new();
current_call_view_set_call_info(CURRENT_CALL_VIEW(new_call_view), idx);
/* use the pointer of the call as a unique name */
new_call_view_name = g_strdup_printf("%p_current", (void *)CallModel::instance()->getCall(idx));
new_call_view_name = g_strdup_printf("%p_current", (void *)CallModel::instance().getCall(idx));
break;
case Call::LifeCycleState::COUNT__:
g_warning("LifeCycleState should never be COUNT");
......@@ -202,14 +202,14 @@ call_state_changed(Call *call, gpointer win)
RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(win));
/* check if the call that changed state is the same as the selected call */
QModelIndex idx_selected = CallModel::instance()->selectionModel()->currentIndex();
QModelIndex idx_selected = CallModel::instance().selectionModel()->currentIndex();
if( idx_selected.isValid() && call == CallModel::instance()->getCall(idx_selected)) {
if( idx_selected.isValid() && call == CallModel::instance().getCall(idx_selected)) {
g_debug("selected call state changed");
/* check if we need to change the view */
GtkWidget *old_call_view = gtk_bin_get_child(GTK_BIN(priv->frame_call));
GtkWidget *new_call_view = NULL;
QVariant state = CallModel::instance()->data(idx_selected, static_cast<int>(Call::Role::LifeCycleState));
QVariant state = CallModel::instance().data(idx_selected, static_cast<int>(Call::Role::LifeCycleState));
/* check what the current state is vs what is displayed */
switch(state.value<Call::LifeCycleState>()) {
......@@ -228,7 +228,7 @@ call_state_changed(Call *call, gpointer win)
current_call_view_set_call_info(CURRENT_CALL_VIEW(new_call_view), idx_selected);
/* use the pointer of the call as a unique name */
char* new_call_view_name = NULL;
new_call_view_name = g_strdup_printf("%p_current", (void *)CallModel::instance()->getCall(idx_selected));
new_call_view_name = g_strdup_printf("%p_current", (void *)CallModel::instance().getCall(idx_selected));
g_free(new_call_view_name);
gtk_container_remove(GTK_CONTAINER(priv->frame_call), old_call_view);
gtk_container_add(GTK_CONTAINER(priv->frame_call), new_call_view);
......@@ -276,8 +276,8 @@ search_entry_placecall(G_GNUC_UNUSED GtkWidget *entry, gpointer win)
call->performAction(Call::Action::ACCEPT);
/* make this the currently selected call */
QModelIndex idx = CallModel::instance()->getIndex(call);
CallModel::instance()->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
QModelIndex idx = CallModel::instance().getIndex(call);
CallModel::instance().selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
/* move focus away from entry so that DTMF tones can be entered via the keyboard */
gtk_widget_child_focus(GTK_WIDGET(win), GTK_DIR_TAB_FORWARD);
......@@ -297,7 +297,7 @@ static gboolean
save_accounts(GtkWidget *working_dialog)
{
/* save changes to accounts */
AccountModel::instance()->save();
AccountModel::instance().save();
if (working_dialog)
gtk_widget_destroy(working_dialog);
......@@ -401,7 +401,7 @@ create_ring_account(RingMainWindow *win)
/* create account and set UPnP enabled, as its not by default in the daemon */
const gchar *alias = gtk_entry_get_text(GTK_ENTRY(priv->entry_alias));
Account *account = AccountModel::instance()->add(alias, Account::Protocol::RING);
Account *account = AccountModel::instance().add(alias, Account::Protocol::RING);
account->setDisplayName(alias); // set the display name to the same as the alias
account->setUpnpEnabled(TRUE);
......@@ -563,7 +563,7 @@ search_entry_text_changed(GtkEditable *search_entry, RingMainWindow *win)
if (text && strlen(text) > 0) {
/* edit the the dialing call (or create a new one) */
if (auto call = CallModel::instance()->dialingCall()) {
if (auto call = CallModel::instance().dialingCall()) {
call->setDialNumber(text);
priv->q_completion_model->setCall(call);
}
......@@ -702,8 +702,8 @@ select_autocompletion(G_GNUC_UNUSED GtkEntryCompletion *widget,
priv->q_completion_model->callSelectedNumber();
/* make this the currently selected call */
QModelIndex idx = CallModel::instance()->getIndex(call);
CallModel::instance()->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
QModelIndex idx = CallModel::instance().getIndex(call);
CallModel::instance().selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
/* move focus away from entry so that DTMF tones can be entered via the keyboard */
gtk_widget_child_focus(GTK_WIDGET(win), GTK_DIR_TAB_FORWARD);
......@@ -731,13 +731,13 @@ dtmf_pressed(RingMainWindow *win,
return GDK_EVENT_PROPAGATE;
/* make sure that a call is selected*/
QItemSelectionModel *selection = CallModel::instance()->selectionModel();
QItemSelectionModel *selection = CallModel::instance().selectionModel();
QModelIndex idx = selection->currentIndex();
if (!idx.isValid())
return GDK_EVENT_PROPAGATE;
/* make sure that the selected call is in progress */
Call *call = CallModel::instance()->getCall(idx);
Call *call = CallModel::instance().getCall(idx);
Call::LifeCycleState state = call->lifeCycleState();
if (state != Call::LifeCycleState::PROGRESS)
return GDK_EVENT_PROPAGATE;
......@@ -847,10 +847,10 @@ ring_main_window_init(RingMainWindow *win)
/* call selection */
QObject::connect(
CallModel::instance()->selectionModel(),
CallModel::instance().selectionModel(),