NAME
Gtk2::Ex::DbLinker::DatasheetHelper - Common methods for Gtk2::Ex::DbLinker::Datasheet and Wx::Perl::DbLinker::Wxdatasheet. None of these are called directly by the end user.
SYNOPSIS
See Gtk2::Ex::DbLinker::Datasheet and Wx::Perl::DbLinker::Wxdatasheet.
new
parameters:
- cols
-
Array ref of fields name
- dman
-
A xxxDataManager object
$self->{ds_helper} = Gtk2::Ex::DbLinker::DatasheetHelper->new(
cols => $self->{cols},
dman => $self->{dman},
);
init_apply
In a datasheet module, calls init_apply to pass a list of code refs that will be used when apply is called.
Mandatory parameters: a list of function references, the keys are
- next
-
returning the next row. Parameter the current iterator or row number
- set_val
-
setting the value for a given row and column. Parameters are row and column number, value
- get_val
-
returning the value for a given row and column. Parameters: row and column number
- del_row
-
deleting a row. Parameter: row and column number
- has_more_row
-
returning 1 or 0 if there are more rows after the curreont one.
- iter
-
the iterator or row position of the first row.
- status_col
-
the position of the status column or -1 if the status is set as a row label (ie a property of the row instead of a modified column).
$self->{ds_helper}->init_apply(
sig => $self->{changed_signal},
sig_block => sub { $self->{log}->debug("sig_block"); $model->signal_handler_block($_[0])},
sig_unblock => sub { $model->signal_handler_unblock($_[0]) },
next => sub {$model->iter_next($_[0])},
get_val => sub {$self->{log}->debug("get_val col: ", $_[1]);
my $x = $model->get($_[0], $_[1]);
$self->{log}->debug("get_val found ", $x);
return $x
},
set_val => sub { $self->{log}->debug("set_val", $_[2]); $model->set($_[0], $_[1], $_[2])},
del_row => sub { $model->remove($_[0]) },
has_more_row => sub { return ( defined $iter ? 1 : 0 )},
status_col => 0,
iter => $iter,
);
get_gui_type
Returns the home_made userinterface types (text, boolean, time, number) using the hash %fieldtype
Param: the type from the database (serial, integer, varchar, set, boolean ...)
colnumber_from_name
Return the column position (0 based)
Param: the name of the column.
apply
Call apply after init to transmit to the database via the datamanager, the changes (a row deletion, a row addition, a row modification) made in the datasheet
setup_fields
Must be called after new, to build the colname_to_number hash used by colnumber_from_name. Return an array ref of hash ref defining the fields of the grid + an array ref of the names of the columns of the underlying table.
Parameters
- allfields
-
A reference to an array of hash ref received in the constructor of the datasheet object. This array ref is returned completed with the
- cols
-
A array ref of the names of the columns in the table
- status_col
-
The fields definitions of the first column holding the bitmap with Gtk2. Not use with Wx.
init_combo_setup
Calls in datasheet->_set_upcombo to build the array of column names. Return the array reference.
parameters
- fields
-
Array ref of hash ref received in the datasheet constructor
- name
-
Name of the field return by the combo, corresponding to a field in the underlying table
get_liste_def
Calls by Gtk2::Ex::DbLinker:Datasheet->_set_upcombo to build the array that will construct the model. Return this array.
parameters
- fields
-
Array ref of hash ref received in the datasheet constructor
- col_ref
-
Array ref of the fields in the combo
- renderer
-
A hash reference of type return by
%fieldtype
and an array ref of two elements. The first is a code ref to a Gtk2::CellRenderer constructor of the corresponding type. The second is the corresponding Glib type. Use for the id of the combo. - default_renderer
-
A string of the Glib type to use for the the column(s) displayed in the combo.
setup_combo
Calls by datasheet->_set_upcombo in _setup_grid or _setup_treeview.
parameters
- fields
-
Array ref of hash ref received in the datasheet constructor
- name
-
Name of the field return by the combo, corresponding to a field in the underlying table
- col_ref
-
Array ref of the fields in the combo
- model
-
For
Gtk2::Ex::Datasheet
the Treemodel of the combo, or undef
Return the $model
with the combo rows if $model
was given or a list of two array ref: the rows displayed in the combo, and the id returned by the combo
_get_missing_arg
sub method
my $self = shift;
my %arg = ( ref $_[0] eq "HASH" ? %$_[0] : (@_) );
my $missing;
confess( __PACKAGE__, " method : ", join( " ", @$missing ), " keys with code ref missing" )
if ( defined( $missing = $self->_get_missing_arg
(
\%arg,
[qw(next get_val set_val del_row has_more_row iter status_col)]
)
) );
Return an array ref of missing parameters
Parameters:
A hash ref of the parameters received by the methods to check. The hash is of the form name => value, ...
An array ref of the required argument names
SUPPORT
Any Gk2::Ex::DbLinker questions or problems can be posted to me (rappazf) on my gmail account.
The current state of the source can be extract using Mercurial from http://sourceforge.net/projects/gtk2-ex-dblinker/.
AUTHOR
François Rappaz <rappazf@gmail.com>
COPYRIGHT
Copyright (c) 2016 by F. Rappaz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Gtk2::Ex::DbLinker::Datasheet Wx::Perl::DbLinker::Wxdatasheet.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 424:
You forgot a '=back' before '=head2'