Skip to content

Commit

Permalink
[import-main-matcher.cpp] show separate warning column with tooltip
Browse files Browse the repository at this point in the history
... instead of tacking on the end of the "Additional Comments" column
  • Loading branch information
christopherlam committed Apr 2, 2024
1 parent 6046c45 commit e2d570f
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions gnucash/import-export/import-main-matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@

#include <memory>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>

#include "import-main-matcher.h"

Expand Down Expand Up @@ -116,6 +118,7 @@ enum downloaded_cols
DOWNLOADED_COL_ACTION_UPDATE,
DOWNLOADED_COL_ACTION_INFO,
DOWNLOADED_COL_ACTION_PIXBUF,
DOWNLOADED_COL_ACTION_PIXBUF_TOOLTIP,
DOWNLOADED_COL_DATA,
DOWNLOADED_COL_COLOR,
DOWNLOADED_COL_ENABLE,
Expand Down Expand Up @@ -1559,7 +1562,7 @@ gnc_gen_trans_init_view (GNCImportMainMatcher *info,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, //memo stuff
G_TYPE_STRING, G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING,
GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_STRING,
GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING,
G_TYPE_BOOLEAN);
gtk_tree_view_set_model (view, GTK_TREE_MODEL(store));
g_object_unref (store);
Expand Down Expand Up @@ -1983,6 +1986,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
ro_text = text = NULL;
const gchar *color = NULL;
bool show_pixbuf = true;
std::vector<std::string> warnings;
switch (gnc_import_TransInfo_get_action (info))
{
case GNCImport_ADD:
Expand Down Expand Up @@ -2039,9 +2043,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
{
static const char* recn_date_warning = N_("The import date is earlier \
than destination account reconcile date. Further reconciliation may be difficult.");
auto newtext = g_strdup_printf ("%s %s", text, _(recn_date_warning));
g_free (text);
text = newtext;
warnings.emplace_back (_(recn_date_warning));
}

g_free (acct_full_name);
Expand Down Expand Up @@ -2151,6 +2153,19 @@ than destination account reconcile date. Further reconciliation may be difficult
DOWNLOADED_COL_ACTION_ADD,
gnc_import_TransInfo_get_action (info) == GNCImport_ADD,
-1);

if (gnc_import_TransInfo_get_action (info) == GNCImport_ADD && !warnings.empty())
{
auto pixbuf = gen_warning_pixbuf ();
auto warnings_str = std::accumulate (warnings.begin(), warnings.end(), std::string{},
[](const std::string& a, const std::string& b)
{ return a.empty() ? b : a + "\n" + b; });
gtk_tree_store_set (store, iter,
DOWNLOADED_COL_ACTION_PIXBUF, pixbuf,
DOWNLOADED_COL_ACTION_PIXBUF_TOOLTIP, warnings_str.c_str(),
-1);
}

if (gnc_import_TransInfo_get_action (info) == GNCImport_SKIP)
{
/*If skipping the row, there is no best match's confidence pixmap*/
Expand Down Expand Up @@ -2495,6 +2510,10 @@ query_tooltip_tree_view_cb (GtkWidget *widget, gint x, gint y,
-1);
break;
default:
if (!g_strcmp0 (gtk_tree_view_column_get_title (column), _("Info")))
gtk_tree_model_get (model, &iter,
DOWNLOADED_COL_ACTION_PIXBUF_TOOLTIP, &tooltip_text,
-1);
break;
}

Expand Down

0 comments on commit e2d570f

Please sign in to comment.