Populate values from queries
[Estron support library]


Files

file  report.h
 Fill in widget values based on results of database query.

Functions

DuiReport * dui_report_new (const char *name)
void dui_report_destroy (DuiReport *)
void dui_report_set_interface (DuiReport *, DuiInterface *)
void dui_report_add_resolver (DuiReport *, DuiResolverFieldFunc, gpointer user_data)
void dui_report_add_realizer (DuiReport *, DuiResolverRealizeFunc, gpointer user_data)
void dui_report_add_row (DuiReport *, DuiTxnReport *row)
void dui_report_add_term (DuiReport *rpt, DuiFieldMap *fm)
void dui_report_do_realize (DuiReport *)
const char * dui_report_get_name (DuiReport *)
int dui_report_show_data (DuiReport *, DuiDBRecordSet *)
void dui_report_set_last_action (DuiReport *, DuiAction *)
void dui_report_refresh (DuiReport *)


Function Documentation

void dui_report_add_resolver ( DuiReport *  ,
DuiResolverFieldFunc  ,
gpointer  user_data 
)

Tell the report about how to convert names into actual objects

Definition at line 224 of file report.c.

00225 {
00226    if (!rpt) return;
00227    dui_resolver_add_resolver (rpt->resolver, fn, ud);
00228 }

void dui_report_add_row ( DuiReport *  ,
DuiTxnReport *  row 
)

Add a row to the report. The row will typically hold a table widget, or possibly an object class name. If the row holds a table widget (e.g. gtklist, gtkctree, etc.), then the rows of the table will be filled in from the result of the query. If the row holds an object class, then the report will find the matching instances of that class, and fill out those instances.

Definition at line 129 of file report.c.

00130 {
00131     if (!rpt || !row ) return;
00132 
00133     rpt->rows = g_list_append (rpt->rows, row);
00134     dui_txnreport_set_resolver (row, rpt->resolver);
00135 }

void dui_report_add_term ( DuiReport *  rpt,
DuiFieldMap *  fm 
)

Add a report 'column'. The fieldmap target should probably contain a widget into which data will be copied, possibly specifying a column of a widget. The fieldmap source is probably going to be some SQL table column.

Definition at line 140 of file report.c.

00141 {
00142     if (!rpt || !fm) return;
00143 
00144     /* Its valid to have reports without a row iterator. However,
00145      * column definitions are stored with a row iterator, so ...
00146      */
00147     if (NULL == rpt->curr_row)
00148     {
00149         DuiTxnReport *row;
00150         row = dui_txnreport_new (NULL, 0);
00151         dui_report_add_row (rpt, row);
00152         rpt->curr_row = row;
00153     }
00154     dui_txnreport_add_term (rpt->curr_row, fm);
00155 }

void dui_report_do_realize ( DuiReport *   ) 

Resolve stuff; the book/window/interface must be set before calling this. The report must be realized before it can be run.

Definition at line 238 of file report.c.

00239 {
00240     if (!rpt) return;
00241     ENTER ("(rpt=%p \'%s\')", rpt, dui_report_get_name (rpt));
00242 
00243     /* Pull global stuff out of global anchor point */
00244     dui_resolver_resolve_gobj (rpt->resolver, rpt->interface);
00245     dui_resolver_resolve_hash (rpt->resolver, rpt->interface);
00246     dui_resolver_resolve (rpt->resolver);
00247 
00248     LEAVE ("(rpt=%p \'%s\')", rpt, dui_report_get_name (rpt));
00249 }

const char* dui_report_get_name ( DuiReport *   ) 

Return the name of the indicated report

Definition at line 207 of file report.c.

00208 {
00209     if (!rpt) return NULL;
00210     if (rpt->name) return (rpt->name);
00211     return NULL;
00212 }

void dui_report_refresh ( DuiReport *   ) 

Rerun it again, using old settings.

Definition at line 254 of file report.c.

00255 {
00256     GList *node;
00257     if (!rpt) return;
00258 
00259     ENTER ("(rpt=%p \'%s\')", rpt, dui_report_get_name (rpt));
00260 
00261     for (node=rpt->last_queries; node; node=node->next)
00262     {
00263         DuiAction *last_action = node->data;
00264         dui_action_rerun_last_query (last_action);
00265     }
00266     LEAVE ("(rpt=%p \'%s\')", rpt, dui_report_get_name (rpt));
00267 }

void dui_report_set_interface ( DuiReport *  ,
DuiInterface *   
)

Tell the report about where it should find 'globals' such as the kvp tree, gobjects, etc.

Definition at line 217 of file report.c.

00218 {
00219     if (!rpt) return;
00220     rpt->interface = iface;
00221 }

void dui_report_set_last_action ( DuiReport *  ,
DuiAction *   
)

Set the most recent action that generated data for this window. If this window need to be refreshed, then this action will be used to refresh it.

Definition at line 111 of file report.c.

00112 {
00113     if (!rpt) return;
00114 
00115     if (!act)
00116     {
00117         g_list_free (rpt->last_queries);
00118         rpt->last_queries = NULL;
00119     }
00120 
00121     if (!act) return;
00122 
00123     rpt->last_queries = g_list_append (rpt->last_queries,  act);
00124 }

int dui_report_show_data ( DuiReport *  ,
DuiDBRecordSet *   
)

Pull data off the indicated connection and display it. Returns a non-zero value if there was data and it was displayed. If there was no data, then no GUI element was displayed, and this retruns zero.

Definition at line 160 of file report.c.

00161 {
00162     GList *node;
00163     gint have_rows;
00164     if (!rpt) return 0;
00165 
00166     ENTER ("(rpt=%p \'%s\', recs=%p)", rpt, dui_report_get_name (rpt), recs);
00167 
00168     /* Check to see if there's any data to display at all.
00169      * If there's not, then we don't realize the report widget,
00170      * we don't show anything, we bail from here, and let the
00171      * next action in the chain take over. */
00172     have_rows = 0;
00173     for (node=rpt->rows; node; node = node->next)
00174     {
00175         DuiTxnReport *row = node->data;
00176 
00177         if (!dui_txnreport_is_empty (row, recs))
00178         {
00179             have_rows = 1;
00180             break;
00181         }
00182     }
00183     if (0 == have_rows) return 0;
00184 
00185     /* Make window that holds report show up on screen;
00186      * &c. other such intialization */
00187     dui_resolver_realize (rpt->resolver);
00188 
00189     for (node=rpt->rows; node; node = node->next)
00190     {
00191         DuiTxnReport *row = node->data;
00192 
00193         if (dui_txnreport_is_empty (row, recs)) continue;
00194 
00195         /* dui_txnreport_realize (row); */
00196         dui_txnreport_run (row, recs);
00197     }
00198 
00199     LEAVE ("(rpt=%p \'%s\', recs=%p)", rpt, dui_report_get_name (rpt), recs);
00200 
00201     return 1;
00202 }


Generated on Tue Apr 29 21:27:54 2008 for estron by  doxygen 1.5.5