* src/engine/QueryNew.h: add QUERY_PARAM_ACTIVE

* src/business/business-core/gncCustomer.c:
	* src/business/business-core/gncEmployee.c:
	* src/business/business-core/gncInvoice.c:
	* src/business/business-core/gncJob.c:
	* src/business/business-core/gncOrder.c:
	* src/business/business-core/gncVendor.c:
	  add the QUERY_PARAM_ACTIVE parameter support
	* src/app-util/prefs.scm: add hidden preference to store
	  the user's choice of searchin
	* src/gnome-search/search.glade: add a checkbox to search-for-all
	* src/gnome-search/dialog-search.c -- add preliminary support to
	  limit searches to only "active" objects.  Fixes bug #103506


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7833 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2003-01-15 03:49:51 +00:00
parent 8e00dd0826
commit 198f41ee89
12 changed files with 96 additions and 2 deletions

View File

@ -1,3 +1,19 @@
2003-01-14 Derek Atkins <derek@ihtfp.com>
* src/engine/QueryNew.h: add QUERY_PARAM_ACTIVE
* src/business/business-core/gncCustomer.c:
* src/business/business-core/gncEmployee.c:
* src/business/business-core/gncInvoice.c:
* src/business/business-core/gncJob.c:
* src/business/business-core/gncOrder.c:
* src/business/business-core/gncVendor.c:
add the QUERY_PARAM_ACTIVE parameter support
* src/app-util/prefs.scm: add hidden preference to store
the user's choice of searchin
* src/gnome-search/search.glade: add a checkbox to search-for-all
* src/gnome-search/dialog-search.c -- add preliminary support to
limit searches to only "active" objects. Fixes bug #103506
2003-01-13 David Hampton <hampton@employees.org> 2003-01-13 David Hampton <hampton@employees.org>
* src/engine/engine-helpers.c: Make the gnc_scm_to_gint64() * src/engine/engine-helpers.c: Make the gnc_scm_to_gint64()

View File

@ -747,3 +747,9 @@ without one.")
(gnc:register-configuration-option (gnc:register-configuration-option
(gnc:make-internal-option (gnc:make-internal-option
"__paths" "Import OFX" #f)) "__paths" "Import OFX" #f))
(gnc:register-configuration-option
(gnc:make-simple-boolean-option
"__gui" "search_for_active_only"
"" ""
#t))

View File

@ -536,6 +536,7 @@ gboolean gncCustomerRegister (void)
{ CUSTOMER_SHIPADDR, GNC_ADDRESS_MODULE_NAME, (QueryAccess)gncCustomerGetShipAddr }, { CUSTOMER_SHIPADDR, GNC_ADDRESS_MODULE_NAME, (QueryAccess)gncCustomerGetShipAddr },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncCustomerGetBook }, { QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncCustomerGetBook },
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncCustomerGetGUID }, { QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncCustomerGetGUID },
{ QUERY_PARAM_ACTIVE, QUERYCORE_BOOLEAN, (QueryAccess)gncCustomerGetActive },
{ NULL }, { NULL },
}; };

View File

@ -399,6 +399,7 @@ gboolean gncEmployeeRegister (void)
{ EMPLOYEE_ADDR, GNC_ADDRESS_MODULE_NAME, (QueryAccess)gncEmployeeGetAddr }, { EMPLOYEE_ADDR, GNC_ADDRESS_MODULE_NAME, (QueryAccess)gncEmployeeGetAddr },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncEmployeeGetBook }, { QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncEmployeeGetBook },
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncEmployeeGetGUID }, { QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncEmployeeGetGUID },
{ QUERY_PARAM_ACTIVE, QUERYCORE_BOOLEAN, (QueryAccess)gncEmployeeGetActive },
{ NULL }, { NULL },
}; };

View File

@ -1262,6 +1262,7 @@ gboolean gncInvoiceRegister (void)
{ INVOICE_BILLTO, GNC_OWNER_MODULE_NAME, (QueryAccess)gncInvoiceGetBillTo }, { INVOICE_BILLTO, GNC_OWNER_MODULE_NAME, (QueryAccess)gncInvoiceGetBillTo },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncInvoiceGetBook }, { QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncInvoiceGetBook },
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncInvoiceGetGUID }, { QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncInvoiceGetGUID },
{ QUERY_PARAM_ACTIVE, QUERYCORE_BOOLEAN, (QueryAccess)gncInvoiceGetActive },
{ NULL }, { NULL },
}; };

View File

@ -387,6 +387,7 @@ gboolean gncJobRegister (void)
{ JOB_ACTIVE, QUERYCORE_BOOLEAN, (QueryAccess)gncJobGetActive }, { JOB_ACTIVE, QUERYCORE_BOOLEAN, (QueryAccess)gncJobGetActive },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncJobGetBook }, { QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncJobGetBook },
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncJobGetGUID }, { QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncJobGetGUID },
{ QUERY_PARAM_ACTIVE, QUERYCORE_BOOLEAN, (QueryAccess)gncJobGetActive },
{ NULL }, { NULL },
}; };

View File

@ -443,6 +443,7 @@ gboolean gncOrderRegister (void)
{ ORDER_NOTES, QUERYCORE_STRING, (QueryAccess)gncOrderGetNotes }, { ORDER_NOTES, QUERYCORE_STRING, (QueryAccess)gncOrderGetNotes },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncOrderGetBook }, { QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncOrderGetBook },
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncOrderGetGUID }, { QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncOrderGetGUID },
{ QUERY_PARAM_ACTIVE, QUERYCORE_BOOLEAN, (QueryAccess)gncOrderGetActive },
{ NULL }, { NULL },
}; };

View File

@ -487,6 +487,7 @@ gboolean gncVendorRegister (void)
{ VENDOR_ADDR, GNC_ADDRESS_MODULE_NAME, (QueryAccess)gncVendorGetAddr }, { VENDOR_ADDR, GNC_ADDRESS_MODULE_NAME, (QueryAccess)gncVendorGetAddr },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncVendorGetBook }, { QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncVendorGetBook },
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncVendorGetGUID }, { QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncVendorGetGUID },
{ QUERY_PARAM_ACTIVE, QUERYCORE_BOOLEAN, (QueryAccess)gncVendorGetActive },
{ NULL }, { NULL },
}; };

View File

@ -28,6 +28,8 @@ typedef enum {
/* "Known" Object Parameters -- all objects must support these */ /* "Known" Object Parameters -- all objects must support these */
#define QUERY_PARAM_BOOK "book" #define QUERY_PARAM_BOOK "book"
#define QUERY_PARAM_GUID "guid" #define QUERY_PARAM_GUID "guid"
#define QUERY_PARAM_ACTIVE "active" /* it's ok if an object does
* not support this */
/* Basic API Functions */ /* Basic API Functions */

View File

@ -727,6 +727,7 @@ gnc_numeric_lcd(gnc_numeric a, gnc_numeric b) {
* as the output denominator. * as the output denominator.
********************************************************************/ ********************************************************************/
#if 1
gnc_numeric gnc_numeric
gnc_numeric_reduce(gnc_numeric in) { gnc_numeric_reduce(gnc_numeric in) {
gint64 t; gint64 t;
@ -753,7 +754,7 @@ gnc_numeric_reduce(gnc_numeric in) {
return out; return out;
} }
#if 0 #else
gnc_numeric gnc_numeric
gnc_numeric_reduce(gnc_numeric in) { gnc_numeric_reduce(gnc_numeric in) {

View File

@ -15,6 +15,7 @@
#include "gnc-ui-util.h" #include "gnc-ui-util.h"
#include "gnc-ui.h" #include "gnc-ui.h"
#include "gnc-gui-query.h" #include "gnc-gui-query.h"
#include "global-options.h"
#include "gncObject.h" #include "gncObject.h"
#include "QueryNew.h" #include "QueryNew.h"
#include "QueryObject.h" #include "QueryObject.h"
@ -48,6 +49,8 @@ struct _GNCSearchWindow {
GtkWidget * add_rb; GtkWidget * add_rb;
GtkWidget * del_rb; GtkWidget * del_rb;
GtkWidget * active_only_check;
/* The Select button */ /* The Select button */
GtkWidget * select_button; GtkWidget * select_button;
@ -387,30 +390,45 @@ search_type_cb (GtkToggleButton *button, GNCSearchWindow *sw)
} }
} }
static void
search_active_only_cb (GtkToggleButton *button, GNCSearchWindow *sw)
{
gnc_set_boolean_option("__gui", "search_for_active_only",
gtk_toggle_button_get_active (button));
}
static void static void
search_update_query (GNCSearchWindow *sw) search_update_query (GNCSearchWindow *sw)
{ {
static GSList *active_params = NULL;
QueryNew *q, *q2, *new_q; QueryNew *q, *q2, *new_q;
GList *node; GList *node;
QueryOp op; QueryOp op;
QueryPredData_t pdata;
if (sw->grouping == GNC_SEARCH_MATCH_ANY) if (sw->grouping == GNC_SEARCH_MATCH_ANY)
op = QUERY_OR; op = QUERY_OR;
else else
op = QUERY_AND; op = QUERY_AND;
if (active_params == NULL)
active_params = g_slist_prepend (NULL, QUERY_PARAM_ACTIVE);
/* Make sure we supply a book! */ /* Make sure we supply a book! */
if (sw->start_q == NULL) { if (sw->start_q == NULL) {
sw->start_q = gncQueryCreateFor (sw->search_for); sw->start_q = gncQueryCreateFor (sw->search_for);
gncQuerySetBook (sw->start_q, gnc_get_current_book ()); gncQuerySetBook (sw->start_q, gnc_get_current_book ());
} else {
/* We've got a query -- purge it of any "active" parameters */
gncQueryPurgeTerms (sw->start_q, active_params);
} }
/* Now create a new query to work from */
q = gncQueryCreateFor (sw->search_for); q = gncQueryCreateFor (sw->search_for);
/* Walk the list of criteria */ /* Walk the list of criteria */
for (node = sw->crit_list; node; node = node->next) { for (node = sw->crit_list; node; node = node->next) {
struct _crit_data *data = node->data; struct _crit_data *data = node->data;
QueryPredData_t pdata;
pdata = gnc_search_core_type_get_predicate (data->element); pdata = gnc_search_core_type_get_predicate (data->element);
if (pdata) if (pdata)
@ -448,6 +466,11 @@ search_update_query (GNCSearchWindow *sw)
break; break;
} }
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sw->active_only_check))) {
gncQueryAddBooleanMatch (new_q, active_params, TRUE, QUERY_AND);
active_params = NULL;
}
/* Destroy the old query */ /* Destroy the old query */
if (sw->q) if (sw->q)
gncQueryDestroy (sw->q); gncQueryDestroy (sw->q);
@ -848,6 +871,12 @@ gnc_search_dialog_init_widgets (GNCSearchWindow *sw)
sw->add_rb = glade_xml_get_widget (xml, "add_search_radiobutton"); sw->add_rb = glade_xml_get_widget (xml, "add_search_radiobutton");
sw->del_rb = glade_xml_get_widget (xml, "delete_search_radiobutton"); sw->del_rb = glade_xml_get_widget (xml, "delete_search_radiobutton");
sw->active_only_check = glade_xml_get_widget (xml, "active_only_check");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sw->active_only_check),
gnc_lookup_boolean_option ("__gui",
"search_for_active_only",
TRUE));
/* Deal with the cancel button */ /* Deal with the cancel button */
sw->cancel_button = glade_xml_get_widget (xml, "cancel_button"); sw->cancel_button = glade_xml_get_widget (xml, "cancel_button");
sw->close_button = glade_xml_get_widget (xml, "close_button"); sw->close_button = glade_xml_get_widget (xml, "close_button");
@ -877,6 +906,9 @@ gnc_search_dialog_init_widgets (GNCSearchWindow *sw)
glade_xml_signal_connect_data (xml, "gnc_ui_search_type_cb", glade_xml_signal_connect_data (xml, "gnc_ui_search_type_cb",
GTK_SIGNAL_FUNC (search_type_cb), sw); GTK_SIGNAL_FUNC (search_type_cb), sw);
glade_xml_signal_connect_data (xml, "gnc_ui_search_active_cb",
GTK_SIGNAL_FUNC (search_active_only_cb), sw);
glade_xml_signal_connect_data (xml, "gnc_ui_search_new_cb", glade_xml_signal_connect_data (xml, "gnc_ui_search_new_cb",
GTK_SIGNAL_FUNC (search_new_item_cb), sw); GTK_SIGNAL_FUNC (search_new_item_cb), sw);

View File

@ -443,6 +443,37 @@
<fill>False</fill> <fill>False</fill>
</child> </child>
</widget> </widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator1</name>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>active_only_check</name>
<tooltip>Choose whether to search all your data or only that marked as &quot;active&quot;</tooltip>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>gnc_ui_search_active_cb</handler>
<data>Search Dialog</data>
<last_modification_time>Wed, 15 Jan 2003 03:21:35 GMT</last_modification_time>
</signal>
<label>Search only active data</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget> </widget>
</widget> </widget>
</widget> </widget>