gnome: addapt to LRC api changes
Use the NumberCompletion selection model
Refs #71640
Change-Id: Iae6113599920e2f21cf7729f0d6fa0437d47a53b
diff --git a/src/ringmainwindow.cpp b/src/ringmainwindow.cpp
index 19f262e..6e49aa2 100644
--- a/src/ringmainwindow.cpp
+++ b/src/ringmainwindow.cpp
@@ -295,17 +295,20 @@
number = "ring:" + number;
g_debug("dialing to number: %s", number.toUtf8().constData());
- Call *call = CallModel::instance()->dialingCall();
+
+ Call *call = priv->q_completion_model->call();
call->setDialNumber(number);
call->performAction(Call::Action::ACCEPT);
/* make this the currently selected call */
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);
+ /* 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);
+ /* clear the entry */
+ gtk_entry_set_text(GTK_ENTRY(priv->search_entry), "");
+ }
}
static void
@@ -709,11 +712,15 @@
/* get the text from the entry */
const gchar *text = gtk_entry_get_text(GTK_ENTRY(search_entry));
- if (text) {
+ if (text && strlen(text) > 0) {
/* edit the the dialing call (or create a new one) */
Call *call = CallModel::instance()->dialingCall();
call->setDialNumber(text);
priv->q_completion_model->setCall(call);
+ } else {
+ Call *call = priv->q_completion_model->call();
+ if (call->lifeCycleState() == Call::LifeCycleState::CREATION)
+ call->performAction(Call::Action::REFUSE);
}
}
@@ -840,20 +847,19 @@
QModelIndex idx = gtk_q_tree_model_get_source_idx(GTK_Q_TREE_MODEL(model), iter);
if (idx.isValid()) {
- ContactMethod *n = priv->q_completion_model->number(idx);
- /* check if using a specific account */
- QVariant var_acc = idx.data(NumberCompletionModel::Role::ACCOUNT);
- Account *acc = var_acc.value<Account *>();
- if (acc) {
- g_debug("using account: %s", acc->alias().toUtf8().constData());
- }
- place_new_call(n, acc);
+ priv->q_completion_model->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
+ Call *call = priv->q_completion_model->call();
+ priv->q_completion_model->callSelectedNumber();
- /* clear the entry */
- gtk_entry_set_text(GTK_ENTRY(priv->search_entry), "");
+ /* make this the currently selected call */
+ 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);
+
+ /* clear the entry */
+ gtk_entry_set_text(GTK_ENTRY(priv->search_entry), "");
} else {
g_warning("autocompletion selection is not a valid index!");
}