gSAFE  1.3.8
Public Slots | Signals | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
HTableBrowser Class Reference

#include <guilib.h>

Inherits QFrame.

Public Slots

int addElement (HTableBrowserElement *e)
 
int clear ()
 
int cursorToBegin (void)
 
int cursorToEnd (void)
 
int fulshDrawingCache (void)
 
void queryToCurrent (void)
 
void queryToStart (void)
 
void queryToTop (void)
 
int removeAllElementByKey (QString key)
 
int setCurrentElement (QString c, QString t="")
 
int setCurrentElement (int index)
 
int setHeadTexts (QStringList h)
 
int setTopElement (int index)
 
void sort (int keycol)
 

Signals

void activateItem (const QString &s)
 
void alternateActivateItem (const QString &s)
 
void itemChanged (const QString &s)
 

Public Member Functions

 HTableBrowser (QWidget *parent)
 
 ~HTableBrowser (void)
 
HTableBrowserElementcurrentElement (void)
 
QString currentKey (void)
 
HTableBrowserElementelementByIndex (int n)
 
bool hasKey (QString key)
 
QString * keyByIndex (int n)
 
int numberOfElements (void)
 
HTableBrowserElementqueryNextElement (void)
 
QString * queryNextKey (void)
 
QStringList * queryNextValues (void)
 
void setBackgroundColor (QColor c)
 
void setColumnColor (int col, QColor c)
 
void setCursorColor (QColor c)
 
void setHeaderColor (QColor c)
 
void setHeaderColorCursor (QColor c)
 
void setSpecSort (int col, QString specsortname)
 
HTableBrowserElementtopElement (void)
 
QString topKey (void)
 
QStringList * valuesByIndex (int n)
 

Public Attributes

int mouseRightClickPosX
 
int mouseRightClickPosY
 

Protected Member Functions

void keyPressEvent (QKeyEvent *e)
 
void mouseDoubleClickEvent (QMouseEvent *e)
 
void mouseMoveEvent (QMouseEvent *e)
 
bool mouseNetClick (QMouseEvent *e, int rmode=NEED_UPDATE)
 
void mousePressEvent (QMouseEvent *e)
 
void mouseReleaseEvent (QMouseEvent *e)
 
void paintEvent (QPaintEvent *e)
 
void resizeEvent (QResizeEvent *e)
 
bool stepDown (void)
 
bool stepUp (void)
 
void wheelEvent (QWheelEvent *e)
 

Protected Attributes

int col_scroll
 
QList< QColor > colc
 
QList< int > colw
 
HTableBrowserElementcur
 
int curc
 
HTableBrowserElementend
 
QFontMetrics * fm
 
QStringList head
 
bool inscroll
 
QString last_right_clicked
 
int number
 
int plusw
 
QMap< int, QColor > precolor
 
HTableBrowserElementquery_cursor
 
int rowh
 
QString seek
 
int showrow
 
QList< QString > spec_sort
 
HTableBrowserElementstart
 
HTableBrowserElementtop
 

Static Protected Attributes

static QPixmap * pix_asc = NULL
 
static QPixmap * pix_asc2 = NULL
 
static QPixmap * pix_desc = NULL
 
static QPixmap * pix_desc2 = NULL
 
static QPixmap * pix_down = NULL
 
static QPixmap * pix_up = NULL
 
static bool staticinit = false
 

Detailed Description

HTableBrowser is a table view class, which can show the list of data groups (they can be a records).
This browser is designed to show/handle really big data tables without slow down.
Shows N column and M rows.
This viewer is a readonly viewer, you can't edit the content with it. Hovewer the list is readonly there is a cursor which marked an element to currently active. The HTableBrowser holds the data in a double linked list, memorize the beginning and the end of the displayed data part, so the browsing will be same speed, when the browser hold a dozen elements or more thousends. The elements are HTableBrowserElement objects. Every record have one key value, and N(column count) displayed value.

htablebrowser.png
HTableBrowser *htb = new HTableBrowser(parentwidget);
htb->setHeadTexts(QString("Fruit;Color").split(";",QString::SkipEmptyParts));
htb->addElement(new HTableBrowserElement("001" , "Apple","Red"));
htb->addElement(new HTableBrowserElement("002" , "Pear","Green"));
htb->addElement(new HTableBrowserElement("003" , "Strawberry","Red"));

In the background this data browser uses bi-directional linked list to store the data, and handles the viewed area separatedly from the full list. There is not matter the size of the full list when drawing/scrolling or moving in the list but the displayed/drawed size only. This drawing is also fastened by pixmap caches, so a full screen scrollig is fast enough. The sorting is achived by quick sort algorithm to be the fastest as possible.

See Also
HTableBrowserElement

Definition at line 198 of file guilib.h.

Constructor & Destructor Documentation

HTableBrowser::HTableBrowser ( QWidget *  parent)

Creates a HTableBrowser class

Parameters
parentthe parent widget of the HTableBrowser

Definition at line 692 of file guilib.cpp.

HTableBrowser::~HTableBrowser ( void  )

Destructor. Deletes the elements too.

Definition at line 764 of file guilib.cpp.

Member Function Documentation

void HTableBrowser::activateItem ( const QString &  s)
signal

This signal is activated if the user click on an item. The signal will pass the key value of the activated item

int HTableBrowser::addElement ( HTableBrowserElement e)
slot

Adds a new element to the table. The new element will be placed the last position.

Parameters
ethe new element. (You have to allocate the object, don't need to delete later, automatically deleted)
See Also
HTableBrowserElement

Definition at line 830 of file guilib.cpp.

void HTableBrowser::alternateActivateItem ( const QString &  s)
signal

This signal is activated if the user right click on an item. The signal will pass the key value of the activated item

int HTableBrowser::clear ( void  )
slot

Clears every element from the table

Definition at line 786 of file guilib.cpp.

HTableBrowserElement * HTableBrowser::currentElement ( void  )

Returns the current element. Returns NULL, if there is not current. Don't delete the object!

Definition at line 1013 of file guilib.cpp.

QString HTableBrowser::currentKey ( void  )

Returns the key value of the current element

Definition at line 772 of file guilib.cpp.

int HTableBrowser::cursorToBegin ( void  )
slot

Sets the cursor to the absolute first element

Definition at line 1096 of file guilib.cpp.

int HTableBrowser::cursorToEnd ( void  )
slot

Sets the cursor to the absolute last element

Definition at line 1104 of file guilib.cpp.

HTableBrowserElement * HTableBrowser::elementByIndex ( int  n)

Returns the HTableBrowserElement pointer in the position of the required index. If the element doesn't reachable NULL returned.
You will get a direct pointer, don't delete it!

Parameters
nthe required index. (The first element is 0)
See Also
elementByIndex()
valuesByIndex()
keyByIndex()
numberOfElements()

Definition at line 1936 of file guilib.cpp.

int HTableBrowser::fulshDrawingCache ( void  )
slot

It flushes the cell drawing cache

Definition at line 1596 of file guilib.cpp.

bool HTableBrowser::hasKey ( QString  key)

Returns true if the table has an element with a key passed in parameter, otherwise return false.

Definition at line 2016 of file guilib.cpp.

void HTableBrowser::itemChanged ( const QString &  s)
signal

This signal is activated if the user changed the current element. The signal will pass the key value of the new current item

QString * HTableBrowser::keyByIndex ( int  n)

Returns the key (in a QString pointer) of HTableBrowserElement in the position of the required index. If the element doesn't reachable NULL returned.
You will get a new allocated object, you have to delete it!

Parameters
nthe required index. (The first element is 0)
See Also
elementByIndex()
valuesByIndex()
keyByIndex()
numberOfElements()

Definition at line 1958 of file guilib.cpp.

bool HTableBrowser::mouseNetClick ( QMouseEvent *  e,
int  rmode = NEED_UPDATE 
)
protected

Handle a mouse event

Definition at line 1308 of file guilib.cpp.

int HTableBrowser::numberOfElements ( void  )

Returns the number of the elements in the table (Number of rows)

Definition at line 1931 of file guilib.cpp.

HTableBrowserElement * HTableBrowser::queryNextElement ( void  )

Returns the HTableBrowserElement pointer in the position of the query cursor. After returning the pointer it steps to the next position. If we have already reached the end of the list NULL returned.
You will get a direct pointer, don't delete it!

See Also
queryToStart()
queryToTop()
queryToCurrent()

Definition at line 1979 of file guilib.cpp.

QString * HTableBrowser::queryNextKey ( void  )

Returns the key (in a QString pointer) of the HTableBrowserElement in the position of the query cursor. After returning the key value it steps to the next position. If we have already reached the end of the list NULL returned.
You will get a new allocated object, you have to delete it!

See Also
queryToStart()
queryToTop()
queryToCurrent()

Definition at line 2003 of file guilib.cpp.

QStringList * HTableBrowser::queryNextValues ( void  )

Returns the displayed values (in a QStringList pointer) of the HTableBrowserElement in the position of the query cursor. After returning the values it steps to the next position. If we have already reached the end of the list NULL returned.
You will get a new allocated object, you have to delete it!

See Also
queryToStart()
queryToTop()
queryToCurrent()

Definition at line 1989 of file guilib.cpp.

void HTableBrowser::queryToCurrent ( void  )
slot

Set the query cursor to the required position

  • queryToStart() - Sets the cursor to the absolute first element of the table.
  • queryToTop() - Set the query cursor to the first displayed element (Which is currently in the top of viewed window)
  • queryToCurrent() - Set the query cursor to the position of the cursor (Currently active element)
HTableBrowser *htb = HTableBrowser(parentwidget);
...
htb->queryToStart();
while((e = htb->queryNextElement()) != NULL)
{
do_something( e[0] );
}
See Also
queryToStart()
queryToTop()
queryToCurrent()
queryNextElement()
queryNextValues()
queryNextKey()

Definition at line 1976 of file guilib.cpp.

void HTableBrowser::queryToStart ( void  )
slot

Set the query cursor to the required position

  • queryToStart() - Sets the cursor to the absolute first element of the table.
  • queryToTop() - Set the query cursor to the first displayed element (Which is currently in the top of viewed window)
  • queryToCurrent() - Set the query cursor to the position of the cursor (Currently active element)
HTableBrowser *htb = HTableBrowser(parentwidget);
...
htb->queryToStart();
while((e = htb->queryNextElement()) != NULL)
{
do_something( e[0] );
}
See Also
queryToStart()
queryToTop()
queryToCurrent()
queryNextElement()
queryNextValues()
queryNextKey()

Definition at line 1970 of file guilib.cpp.

void HTableBrowser::queryToTop ( void  )
slot

Set the query cursor to the required position

  • queryToStart() - Sets the cursor to the absolute first element of the table.
  • queryToTop() - Set the query cursor to the first displayed element (Which is currently in the top of viewed window)
  • queryToCurrent() - Set the query cursor to the position of the cursor (Currently active element)
HTableBrowser *htb = HTableBrowser(parentwidget);
...
htb->queryToStart();
while((e = htb->queryNextElement()) != NULL)
{
do_something( e[0] );
}
See Also
queryToStart()
queryToTop()
queryToCurrent()
queryNextElement()
queryNextValues()
queryNextKey()

Definition at line 1973 of file guilib.cpp.

int HTableBrowser::removeAllElementByKey ( QString  key)
slot

Removes all elemet which have a same key passed in parameter.

Parameters
keythe key value to delete.
Returns
the number of deleted elements

Definition at line 884 of file guilib.cpp.

void HTableBrowser::setBackgroundColor ( QColor  c)

Sets the color of the backround

Definition at line 749 of file guilib.cpp.

void HTableBrowser::setColumnColor ( int  col,
QColor  c 
)

Sets the color of the specified column.

Parameters
colthe index of the column to set the color
cthe color to set

Definition at line 819 of file guilib.cpp.

int HTableBrowser::setCurrentElement ( QString  c,
QString  t = "" 
)
slot

Sets the current elements.

Parameters
therequested KEY value to be current. The first element which have the key value matched with the c will be the currrent.
t(Optional) The key value of the top element of the DISPLAYED list. We can use this parameter to avoid unnecessary scrolling. The new current element always will be visible but: If we specify the currently displayed top element in parameter t(op), the browser will examine the visibility of the new current element. If it's possible the top element won't change.

Definition at line 951 of file guilib.cpp.

int HTableBrowser::setCurrentElement ( int  index)
slot

Sets the current element by index

Definition at line 974 of file guilib.cpp.

void HTableBrowser::setCursorColor ( QColor  c)
inline

Sets the color of the cursor line (current line)

Definition at line 368 of file guilib.h.

void HTableBrowser::setHeaderColor ( QColor  c)
inline

Sets the color of the header line

Definition at line 370 of file guilib.h.

void HTableBrowser::setHeaderColorCursor ( QColor  c)
inline

Sets the color of the header line in cursor position

Definition at line 372 of file guilib.h.

int HTableBrowser::setHeadTexts ( QStringList  h)
slot

Sets the header texts of the table. You have to call this funtion before you insert any elements!

Parameters
hthe text of the headers. The QStringList have to have same number QString as the column of table.

Definition at line 758 of file guilib.cpp.

void HTableBrowser::setSpecSort ( int  col,
QString  specsortname 
)

Set a sort modifier for a specified column.

Parameters
colthe index of the modified sorting column.
specsortnamename of the sort modifier. Now only can receive one modifier: "dropchar" which means the characters are dropped from the value and the result converted to integer, then the result is sorted.
(For example if the sorted values are: id_1,id_10,id_14,id_2,id_21 will be 1,2,10,14,21

Definition at line 940 of file guilib.cpp.

int HTableBrowser::setTopElement ( int  index)
slot

Sets the displayed top element by index

Definition at line 990 of file guilib.cpp.

void HTableBrowser::sort ( int  keycol)
slot

Sets the index of the column to sort the elements. The previous column will be the secondary sorting column. If you pass same column index which already set the sort order will be changed.
Example:

  • initial (no sorting), then...
  • sort(2) - ascendig sort to 3. column, then...
  • sort(1) - ascendig sort to 2. column first secondary 3. , then...
  • sort(1) - descendig sort to 2. column first secondary 3.

Definition at line 1563 of file guilib.cpp.

bool HTableBrowser::stepDown ( void  )
protected

Step one item down

Definition at line 1047 of file guilib.cpp.

bool HTableBrowser::stepUp ( void  )
protected

Step one item up

Definition at line 1020 of file guilib.cpp.

HTableBrowserElement * HTableBrowser::topElement ( void  )

Returns the first element on the display. (Top element) Don't delete the object!

Definition at line 1006 of file guilib.cpp.

QString HTableBrowser::topKey ( void  )

Returns the key of the first element on the display.

Definition at line 779 of file guilib.cpp.

QStringList * HTableBrowser::valuesByIndex ( int  n)

Returns the displayed values (in a QStringList pointer) of HTableBrowserElement in the position of the required index. If the element doesn't reachable NULL returned.
You will get a new allocated object, you have to delete it!

Parameters
nthe required index. (The first element is 0)
See Also
elementByIndex()
valuesByIndex()
keyByIndex()
numberOfElements()

Definition at line 1946 of file guilib.cpp.


The documentation for this class was generated from the following files: