| Meta documentation | Contained in the Meta distribution. |
Meta::Widget::Gtk::SqlList - a CList widget that displays result of an SQL query.
Copyright (C) 2001, 2002 Mark Veltzer; All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
MANIFEST: SqlList.pm PROJECT: meta VERSION: 0.13
package foo; use Meta::Widget::Gtk::SqlList qw(); my($object)=Meta::Widget::Gtk::SqlList->new($def,); my($result)=$object->refresh();
Create this widget, assign an SQL statement to it and forget about it. The widget will: 0. prepare the statement so issueing refreshes to it will be easier. 1. will handle the right button mouse click and will offer the user the option to refresh whenever the mouse is on top of it. 2. will parse the SQL statement given to it and will create the columns of the list accoding to the columns which are returned from the query. 3. will display hints on column names according to descriptions in the database schema. 4. if the database updates and can send signals, this widget will automatically update the information in its display.
This now uses the new SQL::Statment version by Jeff Zucker (better).
new_statement($$$$) refresh($) TEST($)
This is a constructor for the Meta::Widget::Gtk::SqlList object. This is the constructor you should use since it gets all the parameters needed for correct construction.
This method will rerun the quest and will refresh the display. It does so by first clearing the display, then issueing the prepared statement and then appending all results to the widget.
Test suite for this module.
Gtk::CList(3)
None.
Name: Mark Veltzer Email: mailto:veltzer@cpan.org WWW: http://www.veltzer.org CPAN id: VELTZER
0.00 MV advance the contacts project 0.01 MV xml/rpc client/server 0.02 MV perl packaging 0.03 MV md5 project 0.04 MV database 0.05 MV perl module versions in files 0.06 MV movies and small fixes 0.07 MV thumbnail user interface 0.08 MV more thumbnail issues 0.09 MV website construction 0.10 MV web site automation 0.11 MV SEE ALSO section fix 0.12 MV weblog issues 0.13 MV md5 issues
Gtk(3), SQL::Statement(3), strict(3)
-add the prepare stuff.
| Meta documentation | Contained in the Meta distribution. |
#!/bin/echo This is a perl module and should not be run package Meta::Widget::Gtk::SqlList; use strict qw(vars refs subs); use Gtk qw(); use SQL::Statement qw(); our($VERSION,@ISA); $VERSION="0.13"; @ISA=qw(Gtk::CList); #sub new_statement($$$$); #sub refresh($); #sub TEST($); #__DATA__ sub new_statement($$$$) { my($clas,$dbi,$sql,$def)=@_; # parse the statement to get the number of columns my($stmt)=SQL::Statement->new($sql); my($num_columns); $num_columns=$stmt->columns(); # create the CList widget with the correct number of columns my($self)=Gtk::CList->new($num_columns); bless($self,$clas); $self->column_titles_show(); # set the attributes for later reference $self->{DBI}=$dbi; $self->{SQL}=$sql; $self->{DEF}=$def; # add the columns my(@columns)=$stmt->columns(); for(my($i)=0;$i<$num_columns;$i++) { my($ccol)=$columns[$i]; my($cnam)=$ccol->name(); my($ctab)=$ccol->table(); $self->set_column_title($i,$cnam); } #refresh to get all the items in $self->refresh(); return($self); } sub refresh($) { my($self)=@_; $self->clear(); # my($list)=$self->get_dbi()->execute_prep($self->get_prep()); my($list)=$self->{DBI}->execute_arrayref($self->{SQL}); for(my($i)=0;$i<=$#$list;$i++) { my($curr)=$list->[$i]; $self->append(@$curr); } } sub TEST($) { my($context)=@_; return(1); } 1; __END__