Logo Search packages:      
Sourcecode: kdeadmin version File versions

KTreeView Class Reference

#include <ktreeview.h>

List of all members.


Detailed Description

A collapsible treelist widget.

1. Introduction 2. Features 3. Installation 4. Public interface

1. Introduction ================================================================================

KTreeView is a class inherited from QTableView in the Qt user interface library. It provides a way to display hierarchical data in a single-inheritance tree, similar to tree controls in Microsoft Windows and other GUI's. It is most suitable for directory trees or outlines, but I'm sure other uses will come to mind. Frankly, it was designed mostly with the above two functions in mind, but I have tried to make it as flexible as I know how to make it easy to adapt to other uses.

In case of problems, I encourage you to read all of the other documentation files in this package before contacting me as you may find the answer to your question in one of them. Also read the source code if you have time. I have tried to comment it adequately and make the source understandable.

2. Features ================================================================================

Displays both text and optional pixmap supplied by the programmer. A support class, KTreeViewItem, can be inherited and modified to draw items as needed by the programmer.

The list items can be returned by index or logical path and the tree navigated by parent, child or sibling references contained in them. Also, item information such as text, pixmap, branch level can be obtained.

Items can be inserted, changed and removed either by index in the visible structure, or by logical paths through the tree hierarchy.

The logical path through the tree for any item can be obtained with the index of the item.

Tree structure display and expanding/collapsing of sub-trees is handled with no intervention from the programmer.

entire tree can be expanded or collapsed to a specified sub-level (handy for outline views)

Configuration as follows:

enable/disable item text display (if you only want to display pixmaps)

enable/disable drawing of expand/collapse button

enable/disable drawing of tree structure

Keyboard support as follows:

up/down arrows move the highlight appropriately and scroll the list an item at a time, if necessary

pgup/pgdn move the highlight a 'page' up or down as applicable and scroll the view

+/- keys expand/collapse the highlighted item if it appropriate

enter key selects the highlighted item

Mouse support as follows:

left click on item highlights it

left click on an item "hot button" expands or collapses its sub-tree, as applicable

double click on item selects it

normal scrolling functions in conjunction with scrollbars if present

2nd scrolling with the middle mouse button: pressing MMB inserts a rubberband, showing which part of the whole tree is currently visible. moving the mouse will scroll the visible part

Signals/Slots

signal void highlighted(int) - emitted when an item in the tree is highlighted; sends the index of the item

signal void selected(int) - emitted when an item in the tree is selected; sends the index of the item

signal void expanded(int) - emitted when an item in the tree is expanded; sends the index of the item

signal void collpased(int) - emitted when an item in the tree is collapsed; sends the index of the item

Definition at line 401 of file ktreeview.h.


Signals

void collapsed (int index)
void expanded (int index)
void expanding (KTreeViewItem *item, bool &allow)
void highlighted (int index)
void popupMenu (int index, const QPoint &)
void selected (int index)

Public Member Functions

void appendChildItem (KTreeViewItem *newItem, const KPath &thePath)
void appendChildItem (KTreeViewItem *newItem, int index)
void appendChildItem (const QString &theText, const QPixmap &thePixmap, const KPath &thePath)
void appendChildItem (const QString &theText, const QPixmap &thePixmap, int index)
bool autoBottomScrollBar () const
bool autoScrollBar () const
bool autoUpdate () const
bool bottomScrollBar () const
void changeItem (const QString &newText, const QPixmap *newPixmap, const KPath &thePath)
void changeItem (const QString &newText, const QPixmap *newPixmap, int index)
void clear ()
void collapseItem (int index)
uint count ()
int currentItem () const
void expandItem (int index)
int expandLevel () const
void expandOrCollapseItem (int index)
bool forEveryItem (KForEvery func, void *user, KTreeViewItem *root=0)
bool forEveryVisibleItem (KForEvery func, void *user, KTreeViewItem *root=0)
KTreeViewItemgetCurrentItem ()
int indentSpacing ()
bool insertItem (KTreeViewItem *newItem, const KPath &thePath, bool prefix=true)
bool insertItem (KTreeViewItem *newItem, int row=-1, bool prefix=true)
bool insertItem (const QString &theText, const QPixmap &thePixmap, const KPath &thePath, bool prefix=true)
bool insertItem (const QString &theText, const QPixmap &thePixmap, int row=-1, bool prefix=true)
KTreeViewItemitemAt (const KPath &path)
KTreeViewItemitemAt (int row)
void itemPath (int row, KPath &path)
int itemRow (KTreeViewItem *item)
void join (const KPath &path)
void join (int index)
 KTreeView (QWidget *parent=0, const char *name=0, WFlags f=0)
void lowerItem (const KPath &path)
void lowerItem (int index)
void raiseItem (const KPath &path)
void raiseItem (int row)
void removeItem (const KPath &thePath)
void removeItem (int row)
bool scrollBar () const
void setAutoUpdate (bool enable)
void setBottomScrollBar (bool enable)
void setCurrentItem (int row)
void setExpandButtonDrawing (bool enable)
void setExpandLevel (int level)
void setIndentSpacing (int spacing)
void setScrollBar (bool enable)
void setShowItemText (bool enable)
void setSmoothScrolling (bool enable)
void setTreeDrawing (bool enable)
bool showItemText () const
bool smoothScrolling () const
void split (const KPath &path)
void split (int index)
void takeItem (KTreeViewItem *item)
KTreeViewItemtakeItem (const KPath &path)
KTreeViewItemtakeItem (int index)
bool treeDrawing () const
int visibleCount () const

Protected Member Functions

void appendChildItem (KTreeViewItem *theParent, KTreeViewItem *theChild)
void changeItem (KTreeViewItem *toChange, int itemRow, const QString &newText, const QPixmap *newPixmap)
void collapseSubTree (KTreeViewItem *subRoot)
bool countItem (KTreeViewItem *item, void *total)
void draw_rubberband ()
void end_rubberband ()
void expandOrCollapse (KTreeViewItem *parentItem)
void expandSubTree (KTreeViewItem *subRoot)
void fixChildren (KTreeViewItem *parentItem)
virtual void focusInEvent (QFocusEvent *e)
void forEveryItem (KForEveryM func, void *user)
void forEveryVisibleItem (KForEveryM func, void *user)
bool getMaxItemWidth (KTreeViewItem *item, void *user)
virtual int indentation (KTreeViewItem *item) const
bool insertItem (KTreeViewItem *referenceItem, KTreeViewItem *newItem, bool prefix)
void itemPath (KTreeViewItem *item, KPath &path) const
void join (KTreeViewItem *item)
virtual void keyPressEvent (QKeyEvent *e)
int level (KTreeViewItem *item) const
void lowerItem (KTreeViewItem *item)
virtual void mouseDoubleClickEvent (QMouseEvent *e)
virtual void mouseMoveEvent (QMouseEvent *e)
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
void move_rubberband (const QPoint &where)
virtual void paintCell (QPainter *p, int row, int col)
void raiseItem (KTreeViewItem *item)
KTreeViewItemrecursiveFind (KPath &path)
bool setItemExpandButtonDrawing (KTreeViewItem *item, void *)
bool setItemExpanded (KTreeViewItem *item, void *)
bool setItemShowText (KTreeViewItem *item, void *)
bool setItemTreeDrawing (KTreeViewItem *item, void *)
void split (KTreeViewItem *item)
void start_rubberband (const QPoint &where)
virtual void updateCellWidth ()
void updateVisibleItemRec (KTreeViewItem *parent, int &count, int &width)
virtual void updateVisibleItems ()

Protected Attributes

bool clearing
int current
bool drawExpandButton
bool drawTree
int expansion
bool goingDown
int itemCapacity
int itemIndent
int maxItemWidth
int rubber_height
QPoint rubber_startMouse
int rubber_startX
int rubber_startY
int rubber_width
bool rubberband_mode
bool showText
KTreeViewItemtreeRoot
KTreeViewItem ** visibleItems

Friends

class KTreeViewItem

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

Generated by  Doxygen 1.6.0   Back to index