mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[import-main-matcher.cpp] convert to cpp
This commit is contained in:
parent
c405ba2cc0
commit
ea6181fdf7
@ -22,7 +22,7 @@ set (generic_import_SOURCES
|
||||
import-parse.c
|
||||
import-utilities.c
|
||||
import-settings.c
|
||||
import-main-matcher.c
|
||||
import-main-matcher.cpp
|
||||
import-pending-matches.c
|
||||
)
|
||||
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-gtk-utils.h"
|
||||
#include "import-settings.h"
|
||||
#include "import-match-picker.h"
|
||||
#include "import-backend.h"
|
||||
#include "import-account-matcher.h"
|
||||
#include "import-pending-matches.h"
|
||||
@ -131,11 +130,13 @@ static QofLogModule log_module = G_MOD_IMPORT_MATCHER;
|
||||
|
||||
static const gpointer one = GINT_TO_POINTER (1);
|
||||
|
||||
extern "C" {
|
||||
void on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info);
|
||||
void on_matcher_cancel_clicked (GtkButton *button, gpointer user_data);
|
||||
bool on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data);
|
||||
void on_matcher_help_clicked (GtkButton *button, gpointer user_data);
|
||||
void on_matcher_help_close_clicked (GtkButton *button, gpointer user_data);
|
||||
}
|
||||
|
||||
static void gnc_gen_trans_list_create_matches (GNCImportMainMatcher *gui);
|
||||
|
||||
@ -171,8 +172,9 @@ update_all_balances (GNCImportMainMatcher *info)
|
||||
{
|
||||
for (GSList* iter = info->edited_accounts; iter; iter=iter->next)
|
||||
{
|
||||
gnc_account_set_defer_bal_computation (iter->data,false);
|
||||
xaccAccountRecomputeBalance (iter->data);
|
||||
auto acct = static_cast<Account*>(iter->data);
|
||||
gnc_account_set_defer_bal_computation (acct, false);
|
||||
xaccAccountRecomputeBalance (acct);
|
||||
}
|
||||
g_slist_free (info->edited_accounts);
|
||||
info->edited_accounts = NULL;
|
||||
@ -307,7 +309,7 @@ static const GncGUID*
|
||||
get_top_trans_match_id (GList* match_list)
|
||||
{
|
||||
if (!match_list || !match_list->data) return NULL;
|
||||
GNCImportMatchInfo *match_info = match_list->data;
|
||||
auto match_info = static_cast<GNCImportMatchInfo *>(match_list->data);
|
||||
Transaction *trans = match_info->trans;
|
||||
return xaccTransGetGUID (trans);
|
||||
}
|
||||
@ -317,7 +319,7 @@ static gint
|
||||
get_top_trans_match_score (GList* match_list)
|
||||
{
|
||||
if (!match_list || !match_list->data) return 0;
|
||||
GNCImportMatchInfo *match_info = match_list->data;
|
||||
auto match_info = static_cast<GNCImportMatchInfo *>(match_list->data);
|
||||
return match_info->probability;
|
||||
}
|
||||
|
||||
@ -388,7 +390,7 @@ static void
|
||||
remove_top_matches (GList* conflicts)
|
||||
{
|
||||
for (GList* iter = conflicts; iter && iter->data; iter=iter->next)
|
||||
gnc_import_TransInfo_remove_top_match (iter->data);
|
||||
gnc_import_TransInfo_remove_top_match (static_cast<GNCImportTransInfo*>(iter->data));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -461,9 +463,9 @@ load_hash_tables (GNCImportMainMatcher *info)
|
||||
}
|
||||
for (GList *m = accounts_list; m; m = m->next)
|
||||
{
|
||||
for (GList *n = xaccAccountGetSplitList (m->data); n; n = n->next)
|
||||
for (GList *n = xaccAccountGetSplitList (static_cast<Account*>(m->data)); n; n = n->next)
|
||||
{
|
||||
const Split *s = n->data;
|
||||
auto s = static_cast<const Split*>(n->data);
|
||||
const Transaction *t = xaccSplitGetParent (s);
|
||||
|
||||
const gchar *key = xaccTransGetDescription (t);
|
||||
@ -492,10 +494,10 @@ gnc_gen_trans_list_show_all (GNCImportMainMatcher *info)
|
||||
GSList *temp_trans_list = info->temp_trans_list;
|
||||
if (!temp_trans_list)
|
||||
{
|
||||
gnc_info_dialog (GTK_WINDOW (info->main_widget), _("No new transactions were found in this import."));
|
||||
gnc_info_dialog (GTK_WINDOW (info->main_widget), "%s", _("No new transactions were found in this import."));
|
||||
return;
|
||||
}
|
||||
GNCImportTransInfo *trans_info = temp_trans_list->data;
|
||||
auto trans_info = static_cast<GNCImportTransInfo *>(temp_trans_list->data);
|
||||
Split *first_split = gnc_import_TransInfo_get_fsplit (trans_info);
|
||||
Account *account = xaccSplitGetAccount(first_split);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (info->append_text),
|
||||
@ -550,7 +552,7 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
|
||||
Transaction *trans = xaccSplitGetParent (first_split);
|
||||
|
||||
for (GList *n = xaccTransGetSplitList (trans); n; n = g_list_next (n))
|
||||
acc_begin_edit (&accounts_modified, xaccSplitGetAccount (n->data));
|
||||
acc_begin_edit (&accounts_modified, xaccSplitGetAccount (static_cast<Split*>(n->data)));
|
||||
|
||||
// Allow the backend to know if the Append checkbox is ticked or unticked
|
||||
// by propagating info->append_text to every trans_info->append_text
|
||||
@ -592,14 +594,14 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
|
||||
void
|
||||
on_matcher_cancel_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
GNCImportMainMatcher *info = user_data;
|
||||
auto info = static_cast<GNCImportMainMatcher *>(user_data);
|
||||
gnc_gen_trans_list_delete (info);
|
||||
}
|
||||
|
||||
bool
|
||||
on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
GNCImportMainMatcher *info = data;
|
||||
auto info = static_cast<GNCImportMainMatcher *>(data);
|
||||
gnc_gen_trans_list_delete (info);
|
||||
return false;
|
||||
}
|
||||
@ -607,7 +609,7 @@ on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
void
|
||||
on_matcher_help_close_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
GtkWidget *help_dialog = user_data;
|
||||
auto help_dialog = static_cast<GtkWidget *>(user_data);
|
||||
|
||||
gtk_widget_destroy (help_dialog);
|
||||
}
|
||||
@ -615,7 +617,7 @@ on_matcher_help_close_clicked (GtkButton *button, gpointer user_data)
|
||||
void
|
||||
on_matcher_help_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
GNCImportMainMatcher *info = user_data;
|
||||
auto info = static_cast<GNCImportMainMatcher*>(user_data);
|
||||
|
||||
GtkBuilder *builder = gtk_builder_new ();
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer2");
|
||||
@ -837,15 +839,16 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem,
|
||||
GList *refs = NULL;
|
||||
for (GList *l = selected_rows; l; l = l->next)
|
||||
{
|
||||
gchar *path_str = gtk_tree_path_to_string (l->data);
|
||||
GtkTreeRowReference *ref = gtk_tree_row_reference_new (model, l->data);
|
||||
auto path = static_cast<GtkTreePath*>(l->data);
|
||||
gchar *path_str = gtk_tree_path_to_string (path);
|
||||
GtkTreeRowReference *ref = gtk_tree_row_reference_new (model, path);
|
||||
DEBUG("passing first = %s", first ? "true" : "false");
|
||||
DEBUG("passing is_selection = %s", is_selection ? "true" : "false");
|
||||
DEBUG("passing path = %s", path_str);
|
||||
g_free (path_str);
|
||||
refs = g_list_prepend (refs, ref);
|
||||
gnc_gen_trans_assign_transfer_account (treeview,
|
||||
&first, is_selection, l->data,
|
||||
&first, is_selection, path,
|
||||
&assigned_account, info);
|
||||
gchar *fullname = gnc_account_get_full_name (assigned_account);
|
||||
DEBUG("returned value of account = %s", fullname);
|
||||
@ -859,10 +862,11 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem,
|
||||
// now reselect the transaction rows. This is very slow if there are lots of transactions.
|
||||
for (GList *l = refs; l; l = l->next)
|
||||
{
|
||||
GtkTreePath *path = gtk_tree_row_reference_get_path (l->data);
|
||||
auto ref = static_cast<GtkTreeRowReference*>(l->data);
|
||||
GtkTreePath *path = gtk_tree_row_reference_get_path (ref);
|
||||
gtk_tree_selection_select_path (selection, path);
|
||||
gtk_tree_path_free (path);
|
||||
gtk_tree_row_reference_free (l->data);
|
||||
gtk_tree_row_reference_free (ref);
|
||||
}
|
||||
g_list_free (refs);
|
||||
|
||||
@ -888,7 +892,7 @@ static RowInfo * row_get_info (gpointer row, GNCImportMainMatcher *info)
|
||||
{
|
||||
GtkTreeModel *model = gtk_tree_view_get_model (info->view);
|
||||
RowInfo *retval = g_new (RowInfo, 1);
|
||||
gtk_tree_model_get_iter (model, &retval->iter, row);
|
||||
gtk_tree_model_get_iter (model, &retval->iter, static_cast<GtkTreePath*>(row));
|
||||
gtk_tree_model_get (model, &retval->iter,
|
||||
DOWNLOADED_COL_DATA, &retval->trans_info,
|
||||
DOWNLOADED_COL_DESCRIPTION_ORIGINAL, &retval->orig_desc,
|
||||
@ -908,7 +912,7 @@ enum
|
||||
static void populate_list (gpointer key, gpointer value, GtkListStore *list)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
const char *original = key;
|
||||
auto original = static_cast<const char*>(key);
|
||||
char *normalized = g_utf8_normalize (original, -1, G_NORMALIZE_NFC);
|
||||
char *normalized_folded = normalized ? g_utf8_casefold (normalized, -1) : NULL;
|
||||
gtk_list_store_append (list, &iter);
|
||||
@ -924,7 +928,7 @@ static bool
|
||||
match_func (GtkEntryCompletion *completion, const char *entry_str,
|
||||
GtkTreeIter *iter, gpointer user_data)
|
||||
{
|
||||
GtkTreeModel *model = user_data;
|
||||
auto model = static_cast<GtkTreeModel*>(user_data);
|
||||
gchar *existing_str = NULL;
|
||||
bool ret = false;
|
||||
gtk_tree_model_get (model, iter,
|
||||
@ -1084,7 +1088,7 @@ gnc_gen_trans_set_price_to_selection_cb (GtkMenuItem *menuitem,
|
||||
GList *row_info_list = gnc_g_list_map (selected_rows, (GncGMapFunc) row_get_info, info);
|
||||
for (GList *n = row_info_list; n; n = g_list_next (n))
|
||||
{
|
||||
RowInfo *row = n->data;
|
||||
auto row = static_cast<RowInfo*>(n->data);
|
||||
Transaction *trans = gnc_import_TransInfo_get_trans (row->trans_info);
|
||||
time64 post_date = xaccTransGetDate(trans);
|
||||
Split *split = gnc_import_TransInfo_get_fsplit (row->trans_info);
|
||||
@ -1137,12 +1141,12 @@ gnc_gen_trans_edit_fields (GtkMenuItem *menuitem, GNCImportMainMatcher *info)
|
||||
|
||||
char *new_desc = NULL, *new_notes = NULL, *new_memo = NULL;
|
||||
GList *row_info_list = gnc_g_list_map (selected_rows, (GncGMapFunc) row_get_info, info);
|
||||
if (input_new_fields (info, row_info_list->data,
|
||||
if (input_new_fields (info, static_cast<RowInfo*>(row_info_list->data),
|
||||
&new_desc, &new_notes, &new_memo))
|
||||
{
|
||||
for (GList *n = row_info_list; n; n = g_list_next (n))
|
||||
{
|
||||
RowInfo *row = n->data;
|
||||
auto row = static_cast<RowInfo*>(n->data);
|
||||
Transaction *trans = gnc_import_TransInfo_get_trans (row->trans_info);
|
||||
Split *split = gnc_import_TransInfo_get_fsplit (row->trans_info);
|
||||
if (info->can_edit_desc)
|
||||
@ -1273,8 +1277,9 @@ gnc_gen_trans_row_changed_cb (GtkTreeSelection *selection,
|
||||
GList* list = gtk_tree_selection_get_selected_rows (selection, &model);
|
||||
for (GList *n = list; n; n = n->next)
|
||||
{
|
||||
if (get_action_for_path (n->data, model) != GNCImport_ADD)
|
||||
gtk_tree_selection_unselect_path (selection, n->data);
|
||||
auto path = static_cast<GtkTreePath*>(n->data);
|
||||
if (get_action_for_path (path, model) != GNCImport_ADD)
|
||||
gtk_tree_selection_unselect_path (selection, path);
|
||||
}
|
||||
g_list_free_full (list, (GDestroyNotify)gtk_tree_path_free);
|
||||
}
|
||||
@ -1317,7 +1322,7 @@ gnc_gen_trans_view_popup_menu (GtkTreeView *treeview,
|
||||
const char *desc = NULL, *memo = NULL, *notes = NULL;
|
||||
if (row_info_list) /* should never be NULL. collect from first row. */
|
||||
{
|
||||
RowInfo* first_rowinfo = row_info_list->data;
|
||||
auto first_rowinfo = static_cast<RowInfo*>(row_info_list->data);
|
||||
Transaction *trans = gnc_import_TransInfo_get_trans (first_rowinfo->trans_info);
|
||||
Split *split = gnc_import_TransInfo_get_fsplit (first_rowinfo->trans_info);
|
||||
desc = xaccTransGetDescription (trans);
|
||||
@ -1334,7 +1339,7 @@ gnc_gen_trans_view_popup_menu (GtkTreeView *treeview,
|
||||
bool can_assign_acct = true;
|
||||
for (GList *n = row_info_list; n; n = g_list_next(n))
|
||||
{
|
||||
RowInfo *rowinfo = n->data;
|
||||
auto rowinfo = static_cast<RowInfo*>(n->data);
|
||||
|
||||
/* Only allow assigning a destination account for unbalanced transactions */
|
||||
if (can_assign_acct)
|
||||
@ -1448,7 +1453,7 @@ gnc_gen_trans_onButtonPressed_cb (GtkTreeView *treeview,
|
||||
GList* selected;
|
||||
GtkTreeModel *model;
|
||||
selected = gtk_tree_selection_get_selected_rows (selection, &model);
|
||||
if (get_action_for_path (selected->data, model) == GNCImport_ADD)
|
||||
if (get_action_for_path (static_cast<GtkTreePath*>(selected->data), model) == GNCImport_ADD)
|
||||
gnc_gen_trans_view_popup_menu (treeview, event, info);
|
||||
g_list_free_full (selected, (GDestroyNotify)gtk_tree_path_free);
|
||||
}
|
||||
@ -1893,7 +1898,7 @@ get_peer_acct_names (Split *split)
|
||||
GList *names = NULL, *accounts_seen = NULL;
|
||||
for (GList *n = xaccTransGetSplitList (xaccSplitGetParent (split)); n; n = n->next)
|
||||
{
|
||||
Account *account = xaccSplitGetAccount (n->data);
|
||||
Account *account = xaccSplitGetAccount (static_cast<Split*>(n->data));
|
||||
if ((n->data == split) ||
|
||||
(xaccAccountGetType (account) == ACCT_TYPE_TRADING) ||
|
||||
(g_list_find (accounts_seen, account)))
|
||||
@ -2277,7 +2282,7 @@ filter_existing_splits_on_account_and_date (GNCImportMainMatcher *gui)
|
||||
for (GSList* txn = gui->temp_trans_list; txn != NULL;
|
||||
txn = g_slist_next (txn))
|
||||
{
|
||||
GNCImportTransInfo* txn_info = txn->data;
|
||||
auto txn_info = static_cast<GNCImportTransInfo*>(txn->data);
|
||||
Account *txn_account =
|
||||
xaccSplitGetAccount (gnc_import_TransInfo_get_fsplit (txn_info));
|
||||
time64 txn_time =
|
||||
@ -2314,19 +2319,20 @@ create_hash_of_potential_matches (GList *candidate_splits,
|
||||
for (GList* candidate = candidate_splits; candidate != NULL;
|
||||
candidate = g_list_next (candidate))
|
||||
{
|
||||
if (gnc_import_split_has_online_id (candidate->data))
|
||||
auto split = static_cast<Split*>(candidate->data);
|
||||
if (gnc_import_split_has_online_id (split))
|
||||
continue;
|
||||
/* In this context an open transaction represents a freshly
|
||||
* downloaded one. That can't possibly be a match yet */
|
||||
if (xaccTransIsOpen(xaccSplitGetParent(candidate->data)))
|
||||
if (xaccTransIsOpen(xaccSplitGetParent(split)))
|
||||
continue;
|
||||
Account *split_account = xaccSplitGetAccount (candidate->data);
|
||||
Account *split_account = xaccSplitGetAccount (split);
|
||||
/* g_hash_table_steal_extended would do the two calls in one shot but is
|
||||
* not available until GLib 2.58.
|
||||
*/
|
||||
GSList *split_list = g_hash_table_lookup (account_hash, split_account);
|
||||
auto split_list = static_cast<GSList*>(g_hash_table_lookup (account_hash, split_account));
|
||||
g_hash_table_steal (account_hash, split_account);
|
||||
split_list = g_slist_prepend (split_list, candidate->data);
|
||||
split_list = g_slist_prepend (split_list, split);
|
||||
g_hash_table_insert (account_hash, split_account, split_list);
|
||||
}
|
||||
return account_hash;
|
||||
@ -2372,11 +2378,11 @@ perform_matching (GNCImportMainMatcher *gui, GHashTable *account_hash)
|
||||
for (GSList *imported_txn = gui->temp_trans_list; imported_txn !=NULL;
|
||||
imported_txn = g_slist_next (imported_txn))
|
||||
{
|
||||
GNCImportTransInfo* txn_info = imported_txn->data;
|
||||
auto txn_info = static_cast<GNCImportTransInfo*>(imported_txn->data);
|
||||
Account *importaccount = xaccSplitGetAccount (gnc_import_TransInfo_get_fsplit (txn_info));
|
||||
match_struct s = {txn_info, display_threshold, date_threshold, date_not_threshold, fuzzy_amount};
|
||||
|
||||
g_slist_foreach (g_hash_table_lookup (account_hash, importaccount),
|
||||
g_slist_foreach (static_cast<GSList*>(g_hash_table_lookup (account_hash, importaccount)),
|
||||
(GFunc) match_helper, &s);
|
||||
|
||||
// Sort the matches, select the best match, and set the action.
|
@ -33,15 +33,16 @@
|
||||
#ifndef GNC_IMPORT_MAIN_MATCHER_H
|
||||
#define GNC_IMPORT_MAIN_MATCHER_H
|
||||
|
||||
#include "Transaction.h"
|
||||
#include "import-backend.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "Transaction.h"
|
||||
#include "import-backend.h"
|
||||
#include "import-match-picker.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct _main_matcher_info GNCImportMainMatcher;
|
||||
|
||||
typedef void (*GNCTransactionProcessedCB) (GNCImportTransInfo *trans_info,
|
||||
|
@ -350,7 +350,7 @@ gnucash/import-export/import-account-matcher.c
|
||||
gnucash/import-export/import-backend.cpp
|
||||
gnucash/import-export/import-commodity-matcher.c
|
||||
gnucash/import-export/import-format-dialog.c
|
||||
gnucash/import-export/import-main-matcher.c
|
||||
gnucash/import-export/import-main-matcher.cpp
|
||||
gnucash/import-export/import-match-picker.c
|
||||
gnucash/import-export/import-parse.c
|
||||
gnucash/import-export/import-pending-matches.c
|
||||
|
Loading…
Reference in New Issue
Block a user