[import-backend] move gnc_import_TransInfo_remove_top_match to backend

because removing the first in a GList is a backend type action, and
converting to stl container will be easier then.
This commit is contained in:
Christopher Lam
2023-04-25 10:07:43 +08:00
parent 0fd431d09b
commit 7a2287f67c
3 changed files with 15 additions and 13 deletions

View File

@@ -128,7 +128,7 @@ gnc_import_TransInfo_get_match_list (const GNCImportTransInfo *info)
return info->match_list;
}
void
static void
gnc_import_TransInfo_set_match_list (GNCImportTransInfo *info, GList* match_list)
{
g_assert (info);
@@ -142,6 +142,14 @@ gnc_import_TransInfo_set_match_list (GNCImportTransInfo *info, GList* match_list
}
}
void
gnc_import_TransInfo_remove_top_match (GNCImportTransInfo *info)
{
GList* match_trans = gnc_import_TransInfo_get_match_list (info);
match_trans = g_list_remove (match_trans, static_cast<gpointer>(match_trans->data));
gnc_import_TransInfo_set_match_list (info, match_trans);
}
Transaction *
gnc_import_TransInfo_get_trans (const GNCImportTransInfo *info)
{

View File

@@ -182,8 +182,8 @@ void gnc_import_TransInfo_delete (GNCImportTransInfo *info);
/** Returns the stored list of possible matches. */
GList *gnc_import_TransInfo_get_match_list (const GNCImportTransInfo *info);
/** Assigns the list of possible matches. */
void gnc_import_TransInfo_set_match_list (GNCImportTransInfo *info, GList* match_list);
/** Remove the first match in the list of possible matches */
void gnc_import_TransInfo_remove_top_match (GNCImportTransInfo *info);
/** Returns the transaction of this TransInfo. */
Transaction *gnc_import_TransInfo_get_trans (const GNCImportTransInfo *info);

View File

@@ -385,16 +385,10 @@ get_conflict_list (GtkTreeModel* model, GtkTreeIter import_iter, GncGUID* id, gi
}
static void
remove_top_matches (GNCImportMainMatcher* gui, GtkTreeModel* model, GList* conflicts)
remove_top_matches (GList* conflicts)
{
GList* iter = conflicts;
for (; iter && iter->data; iter=iter->next)
{
GNCImportTransInfo* trans_info = iter->data;
GList* match_trans = gnc_import_TransInfo_get_match_list (trans_info);
match_trans = g_list_remove (match_trans, match_trans->data);
gnc_import_TransInfo_set_match_list (trans_info, match_trans);
}
for (GList* iter = conflicts; iter && iter->data; iter=iter->next)
gnc_import_TransInfo_remove_top_match (iter->data);
}
static void
@@ -426,7 +420,7 @@ resolve_conflicts (GNCImportMainMatcher *info)
if (conflicts)
{
remove_top_matches (info, model, conflicts);
remove_top_matches (conflicts);
/* Go back to the beginning here, because a nth choice
* could now conflict with a previously assigned first choice. */
valid = gtk_tree_model_get_iter_first (model, &import_iter);