diff --git a/src/gnome-utils/gnc-entry-quickfill.c b/src/gnome-utils/gnc-entry-quickfill.c index 76fd56395a..bb568aa5f5 100644 --- a/src/gnome-utils/gnc-entry-quickfill.c +++ b/src/gnome-utils/gnc-entry-quickfill.c @@ -34,6 +34,7 @@ typedef struct QuickFillSort qf_sort; QofBook *book; gint listener; + gboolean using_invoices; } EntryQF; static void @@ -91,7 +92,12 @@ static void entry_cb(gpointer data, gpointer user_data) { const GncEntry* entry = data; EntryQF *s = (EntryQF *) user_data; - gnc_quickfill_insert (s->qf, gncEntryGetDescription(entry), s->qf_sort); + if (s->using_invoices == (gncEntryGetInvAccount(entry) != NULL)) + { + gnc_quickfill_insert (s->qf, + gncEntryGetDescription(entry), + s->qf_sort); + } } /** Creates a new query that searches for all GncEntry items in the @@ -104,7 +110,7 @@ static QofQuery *new_query_for_entrys(QofBook *book) return query; } -static EntryQF* build_shared_quickfill (QofBook *book, const char * key) +static EntryQF* build_shared_quickfill (QofBook *book, const char * key, gboolean use_invoices) { EntryQF *result; QofQuery *query = new_query_for_entrys(book); @@ -114,6 +120,7 @@ static EntryQF* build_shared_quickfill (QofBook *book, const char * key) result = g_new0(EntryQF, 1); + result->using_invoices = use_invoices; result->qf = gnc_quickfill_new(); result->qf_sort = QUICKFILL_LIFO; result->book = book; @@ -132,7 +139,7 @@ static EntryQF* build_shared_quickfill (QofBook *book, const char * key) } QuickFill * gnc_get_shared_entry_desc_quickfill (QofBook *book, - const char * key) + const char * key, gboolean use_invoices) { EntryQF *qfb; @@ -142,8 +149,11 @@ QuickFill * gnc_get_shared_entry_desc_quickfill (QofBook *book, qfb = qof_book_get_data (book, key); if (qfb) + { + g_assert(use_invoices == qfb->using_invoices); return qfb->qf; + } - qfb = build_shared_quickfill(book, key); + qfb = build_shared_quickfill(book, key, use_invoices); return qfb->qf; } diff --git a/src/gnome-utils/gnc-entry-quickfill.h b/src/gnome-utils/gnc-entry-quickfill.h index ad7e0b0a80..24a959450b 100644 --- a/src/gnome-utils/gnc-entry-quickfill.h +++ b/src/gnome-utils/gnc-entry-quickfill.h @@ -45,9 +45,22 @@ * listens to the entry's deletion events and removes those * descriptions from the quickfill; however, this does not yet seem * to fully remove them from the GUI. + * + * \param book The book + * \param key The identifier to look up the shared object in the book + * + * \param use_invoices If TRUE, this quickfill considers only the + * entries from GncInvoice objects. If FALSE, this quickfill considers + * only the entries from bills/expense vouchers. Watch out: This + * parameter must be identical each time the same key is used for + * lookup, or otherwise an assertion will fail. + * + * \return The shared QuickFill object which is created on first + * calling of this function and subsequently looked up in the book by + * using the key. */ QuickFill * gnc_get_shared_entry_desc_quickfill (QofBook *book, - const char * key); + const char * key, gboolean use_invoices); #endif