kpilot Library API Documentation

ListCategorizer Class Reference

This Widget extends KListView for a particular purpose: sorting some items into some bins. More...

#include <listCat.h>

List of all members.

Public Methods

 ListCategorizer (QWidget *parent, const char *name=0)
 ListCategorizer (const QStringList &categories, bool startOpen, QWidget *parent, const char *name=0)
void addCategories (const QStringList &)
QListViewItemaddCategory (const QString &name, const QString &description=QString::null)
QStringList categories () const
QListViewItemaddItem (const QString &category, const QString &name, const QString &description=QString::null)
QStringList items (const QString &category, int column=0) const
QListViewItemfindCategory (const QString &categoryName) const


Detailed Description

This Widget extends KListView for a particular purpose: sorting some items into some bins.

This can be useful for putting items in an enabled / disabled state, or into categories, or configuring toolbars (putting icons onto toolbars).

You can use all of the standard KListView signals and slots. You may in particular want to change the names of the columns, for example:

 ListCategorizer *lc = new ListCategorizer(this,colors);
 lc->setColumnText(0,i18n("Color"));
 lc->setColumnText(1,i18n("HTML"));
 QListViewItem *stdKDE = lc->addCategory(i18n("Standard KDE"));
 (void) new QListViewItem(stdKDE,i18n("red"),"FF0000");
 
to set sensible column headers for a list of colors and their HTML equivalents (although why you would want to categorize colors is beyond me).

Version:
Id:
listCat.h,v 1.11 2003/03/20 21:08:56 adridg Exp

Definition at line 62 of file listCat.h.


Constructor & Destructor Documentation

ListCategorizer::ListCategorizer QWidget   parent,
const char *    name = 0
 

Constructor.

This creates a new empty ListCategorizer with startOpen set to false. The parameters parent and name are the usual Qt ones.

Definition at line 42 of file listCat.cc.

ListCategorizer::ListCategorizer const QStringList   categories,
bool    startOpen,
QWidget   parent,
const char *    name = 0
 

Constructor.

This creates a ListCategorizer with the given categories already inserted. In addition, this constructor lets you specify whether or not startOpen is set.

Definition at line 52 of file listCat.cc.

References addCategories().


Member Function Documentation

void ListCategorizer::addCategories const QStringList  
 

Add a list of categories to the ListCategorizer.

All the categories are added without descriptions; use @addCategory on a per-category basis for that.

Definition at line 63 of file listCat.cc.

References addCategory().

Referenced by ListCategorizer().

QListViewItem * ListCategorizer::addCategory const QString   name,
const QString   description = QString::null
 

Add a category with name name and optional description.

This can be useful if you want either a description for the category or want to refer to this category in the future without using findCategory().

@ret the QListViewItem created for the category

Definition at line 74 of file listCat.cc.

References QListViewItem::setOpen(), and QListViewItem::setSelectable().

Referenced by addCategories().

QStringList ListCategorizer::categories   const [inline]
 

Returns the list of names of the categories in the ListCategorizer.

Definition at line 109 of file listCat.h.

QListViewItem * ListCategorizer::addItem const QString   category,
const QString   name,
const QString   description = QString::null
 

Add a single item to the category named category, with name name and description set to description.

This might be a convenience function, but it's probably more convenient to just use QListViewItem's constructor. That way you can also hide more data in the remaining columns.

Definition at line 178 of file listCat.cc.

References findCategory().

QStringList ListCategorizer::items const QString   category,
int    column = 0
const [inline]
 

Returns the list of strings in column column under category category.

You can do this to get, for example the names of all the items categorized under a given category, or, more usefully, set column to something other that 0 (name) or 1 (description) to return the QStringList hidden in the non-visible columns.

Definition at line 133 of file listCat.h.

References findCategory().

QListViewItem * ListCategorizer::findCategory const QString   categoryName const
 

Given a category @categoryName return the QListViewItem that represents that category.

Probably a useless function, since just remembering the pointer addCategory gives you is faster and uses hardly any memory.

Definition at line 163 of file listCat.cc.

References QListViewItem::nextSibling(), and QListViewItem::text().

Referenced by addItem(), and items().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:50 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003