Sophie

Sophie

distrib > Mandriva > 10.2 > i586 > media > contrib > by-pkgid > 6338fb0a19fe7b6baeca7897c46a9ee3 > files > 70

knoda-0.7.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>Data sensitive methods</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="The knoda scripting tutorial"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="General object methods- the class hk_visible"
HREF="chapter2.html"><LINK
REL="NEXT"
TITLE="Objects of type hk_dsdatavisible - the class hk_column"
HREF="hk_dsdatavisible.html"><META
HTTP-EQUIV="Content-Style-Type"
CONTENT="text/css"><LINK
REL="stylesheet"
HREF="common/kde-common.css"
TYPE="text/css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=iso-8859-1"><META
HTTP-EQUIV="Content-Language"
CONTENT="en"><LINK
REL="stylesheet"
HREF="common/kde-localised.css"
TYPE="text/css"
TITLE="KDE-English"><LINK
REL="stylesheet"
HREF="common/kde-default.css"
TYPE="text/css"
TITLE="KDE-Default"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#AA0000"
VLINK="#AA0055"
ALINK="#AA0000"
STYLE="font-family: sans-serif;"
><DIV
CLASS="logoheader"
><A
HREF="http://www.kde.org/"
></A
></DIV
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The knoda scripting tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="chapter2.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="hk_dsdatavisible.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="CHAPTER3"
></A
>Chapter 3. Data sensitive methods</H1
><P
>Before we start writing programs, we will first have some theory.  Below you see the (c++)- structure of hk_classes.  There are classes
that handle the contact to the database (see the left side of the graphic), while others handle the interaction with the user (we have already
seen the hk_visible class in the previous section).
<DIV
CLASS="FIGURE"
><HR><A
NAME="HK_CLASSESOVERVIEW"
></A
><P
><B
>Figure 3-1. hk_classes overview</B
></P
><P
><IMG
SRC="hk_classes-overview.png"></P
><HR></DIV
>
<DIV
CLASS="FIGURE"
><HR><A
NAME="HK_CLASSESOVERVIEW2"
></A
><P
><B
>Figure 3-2. description of the most important classes</B
></P
><P
><IMG
SRC="class-overview2.png"></P
><HR></DIV
></P
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="HK_DSVISIBLE"
></A
>3.1. Objects of type hk_dsvisible - the class hk_datasource</H1
><P
>All data-sensitive objects are of type <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>hk_dsvisible</I
></SPAN
> (or its child hk_dsdatavisible).  hk_dsvisible inherits from hk_visible.
The most important method of hk_dsvisible is <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>datasource()</I
></SPAN
>.  This method returns a class of type hk_datasource, representing
the whole datasource (either a table or a query)</P
><P
><DIV
CLASS="FIGURE"
><HR><A
NAME="AEN181"
></A
><P
><B
>Figure 3-3. hk_datasource methods</B
></P
><A
NAME="AEN183"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><UL
><LI
STYLE="list-style-type: disc"
><P
>name(); returns the name of the datasource</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>goto_row(rownumber); moves the row selector (row cursor) to 'rownumber'</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>goto_first()</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>goto_last()</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>goto_next()</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>goto_previous()</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>row_position(); returns the row number of the current row</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>max_rows(); returns the total number of existing rows </P
></LI
><LI
STYLE="list-style-type: disc"
><P
>enable()</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>disable()</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>set_enabled(e)</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>is_enabled()</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_column*column_by_name(name); returns an hk_column object of the column with the name 'name'</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>store_changed_data()</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_database*database()</P
></LI
></UL
></BLOCKQUOTE
><HR></DIV
>
The following example shows how to move between rows in a datasource.  For this, create a button in the form and set a datasource.  Add the script
to the "On click"-action.

<DIV
CLASS="EXAMPLE"
><HR><A
NAME="AEN215"
></A
><P
><B
>Example 3-1. rowposition</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>   1&nbsp;ds=hk_this.datasource()
   2&nbsp;ds.goto_row(ds.row_position() + 2)</PRE
></TD
></TR
></TABLE
><HR></DIV
>

How to get a specific hk_column object can be seen in the following example.  For what you can do with this object, please see the next chapter.


<DIV
CLASS="EXAMPLE"
><HR><A
NAME="AEN218"
></A
><P
><B
>Example 3-2. find  a specific column</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>   1&nbsp;col=hk_this.datasource().column_by_name("author")</PRE
></TD
></TR
></TABLE
><HR></DIV
>
&#13;</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="chapter2.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="hk_dsdatavisible.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>General object methods- the class hk_visible</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Objects of type hk_dsdatavisible - the class hk_column</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>