kaddressbook Library API Documentation

CardView Class Reference

The CardView is a method of displaying data in cards. More...

#include <cardview.h>

Inheritance diagram for CardView:

QScrollView List of all members.

Public Types

enum  SelectionMode { Single, Multi, Extended, NoSelection }

Signals

void selectionChanged ()
 Emitted whenever the selection changes.

void selectionChanged (CardViewItem *)
 Same as above method, only it carries the item that was selected.

void clicked (CardViewItem *)
 This method is emitted whenever an item is clicked.

void executed (CardViewItem *)
 Emitted whenever the user 'executes' an item.

void doubleClicked (CardViewItem *)
 Emitted whenever the user double clicks on an item.


Public Member Functions

 CardView (QWidget *parent, const char *name)
 Constructor.

void insertItem (CardViewItem *item)
 Inserts the item into the card view.

void takeItem (CardViewItem *item)
 Takes the item from the view.

void clear ()
 Clears the view and deletes all card view items.

CardViewItemitemAt (const QPoint &viewPos)
QRect itemRect (const CardViewItem *item)
void ensureItemVisible (const CardViewItem *item)
 Ensures that the given item is in the viewable area of the widget.

void setSelectionMode (SelectionMode mode)
 Sets the selection mode.

SelectionMode selectionMode () const
void setSelected (CardViewItem *item, bool selected)
 Selects or deselects the given item.

void selectAll (bool state)
 Selects or deselects all items.

bool isSelected (CardViewItem *item) const
CardViewItemselectedItem () const
CardViewItemfirstItem () const
CardViewItemitemAfter (CardViewItem *item)
int childCount () const
CardViewItemfindItem (const QString &text, const QString &label, Qt::StringComparisonMode compare=Qt::BeginsWith)
 Attempts to find the first item matching the params.

void setDrawCardBorder (bool enabled)
 Sets if the border around a card should be draw.

bool drawCardBorder () const
void setDrawColSeparators (bool enabled)
 Sets if the column separator should be drawn.

bool drawColSeparators () const
void setDrawFieldLabels (bool enabled)
 Sets if the field labels should be drawn.

bool drawFieldLabels () const

Protected Member Functions

virtual void viewportPaintEvent (QPaintEvent *)
 Repaints the whole viewport.

void resizeEvent (QResizeEvent *e)
 Sets the layout to dirty and repaints.

void setLayoutDirty (bool dirty)
 Sets the layout to dirty and calls for a repaint.

void calcLayout ()
 Does the math based on the bounding rect of the cards to properly lay the cards out on the screen.

virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
virtual void mouseDoubleClickEvent (QMouseEvent *e)
virtual void mouseMoveEvent (QMouseEvent *e)
virtual void startDrag ()
 Overload this method to be told when a drag should be started.


Friends

class CardViewItem

Detailed Description

The CardView is a method of displaying data in cards.

This idea is similar to the idea of a rolodex or business cards. Each card has a caption and a list of fields, which are label<->value pairs. The CardView displays multiple cards in a grid. The Cards are sorted based on their caption.

The CardView class is designed to mirror the API of the QListView or QIconView. The CardView is also completely independant of KAddressBook and can be used elsewhere. With the exception of a few simple config checks, the CardView is also 100% independant of KDE.

Definition at line 130 of file cardview.h.


Constructor & Destructor Documentation

CardView::CardView QWidget parent,
const char *  name
 

Constructor.

Definition at line 386 of file cardview.cpp.

References QFont::setBold(), and QScrollView::viewport().


Member Function Documentation

void CardView::insertItem CardViewItem item  ) 
 

Inserts the item into the card view.

This method does not have to be called if you created the item with a proper parent. Once inserted, the CardView takes ownership of the item.

Definition at line 417 of file cardview.cpp.

References setLayoutDirty().

void CardView::takeItem CardViewItem item  ) 
 

Takes the item from the view.

The item will not be deleted and ownership of the item is returned to the caller.

Definition at line 424 of file cardview.cpp.

References setLayoutDirty().

void CardView::clear  ) 
 

Clears the view and deletes all card view items.

Definition at line 431 of file cardview.cpp.

References setLayoutDirty().

CardViewItem * CardView::itemAt const QPoint viewPos  ) 
 

Returns:
The item found at the given point, or 0 if there is no item at that point.

Definition at line 438 of file cardview.cpp.

References QPtrListIterator::current(), CardViewItem::d, and QPtrListIterator::toFirst().

QRect CardView::itemRect const CardViewItem item  ) 
 

Returns:
The bounding rect of the given item.

Definition at line 456 of file cardview.cpp.

References CardViewItem::d.

void CardView::ensureItemVisible const CardViewItem item  ) 
 

Ensures that the given item is in the viewable area of the widget.

Definition at line 461 of file cardview.cpp.

References CardViewItem::d, QScrollView::ensureVisible(), QRect::height(), QRect::width(), QRect::x(), and QRect::y().

void CardView::setSelectionMode SelectionMode  mode  ) 
 

Sets the selection mode.

See also:
QListView

Definition at line 469 of file cardview.cpp.

References selectAll().

CardView::SelectionMode CardView::selectionMode  )  const
 

Returns:
The current selection mode.

Definition at line 476 of file cardview.cpp.

void CardView::setSelected CardViewItem item,
bool  selected
 

Selects or deselects the given item.

This method honors the current selection mode, so if other items are selected, they may be unselected.

Definition at line 514 of file cardview.cpp.

References CardViewItem::isSelected(), CardViewItem::repaintCard(), selectAll(), selectionChanged(), and CardViewItem::setSelected().

void CardView::selectAll bool  state  ) 
 

Selects or deselects all items.

Definition at line 481 of file cardview.cpp.

References QPtrListIterator::current(), selectionChanged(), and QPtrListIterator::toFirst().

Referenced by setSelected(), and setSelectionMode().

bool CardView::isSelected CardViewItem item  )  const
 

Returns:
True if the given item is selected, false otherwise.

Definition at line 558 of file cardview.cpp.

References CardViewItem::isSelected().

CardViewItem * CardView::selectedItem  )  const
 

Returns:
The first selected item. In single select mode, this will be the only selected item, in other modes this will be the first selected item, but others may exist. 0 if no item is selected.

Definition at line 563 of file cardview.cpp.

References QPtrListIterator::current(), and QPtrListIterator::toFirst().

CardViewItem * CardView::firstItem  )  const
 

Returns:
The first item in the view. This may be 0 if no items have been inserted. This method combined with CardViewItem::nextItem() can be used to iterator through the list of items.

Definition at line 576 of file cardview.cpp.

CardViewItem * CardView::itemAfter CardViewItem item  ) 
 

Returns:
The item after the given item or 0 if the item is the last item.

Definition at line 733 of file cardview.cpp.

Referenced by CardViewItem::nextItem().

int CardView::childCount  )  const
 

Returns:
The number of items in the view.

Definition at line 581 of file cardview.cpp.

CardViewItem * CardView::findItem const QString text,
const QString label,
Qt::StringComparisonMode  compare = Qt::BeginsWith
 

Attempts to find the first item matching the params.

Parameters:
text The text to match.
label The label of the field to match against.
compare The compare method to use in doing the search.
Returns:
The first matching item, or 0 if no items match.

Definition at line 586 of file cardview.cpp.

References QPtrListIterator::current(), QString::isEmpty(), QString::startsWith(), QPtrListIterator::toFirst(), and QString::upper().

void CardView::setDrawCardBorder bool  enabled  ) 
 

Sets if the border around a card should be draw.

The border is a thing (1 or 2 pixel) line that bounds the card. When drawn, it shows when a card is highlighted and when it isn't.

Definition at line 860 of file cardview.cpp.

bool CardView::drawCardBorder  )  const
 

Returns:
True if borders are drawn, false otherwise.

Definition at line 869 of file cardview.cpp.

void CardView::setDrawColSeparators bool  enabled  ) 
 

Sets if the column separator should be drawn.

The column separator is a thin verticle line (1 or 2 pixels) that is used to separate the columns in the list view. The separator is just for esthetics and it does not serve a functional purpose.

Definition at line 874 of file cardview.cpp.

References setLayoutDirty().

bool CardView::drawColSeparators  )  const
 

Returns:
True if column separators are drawn, false otherwise.

Definition at line 883 of file cardview.cpp.

void CardView::setDrawFieldLabels bool  enabled  ) 
 

Sets if the field labels should be drawn.

The field labels are the unique strings used to identify the fields. Sometimes drawing these labels makes sense as a source of clarity for the user, othertimes they waste too much space and do not assist the user.

Definition at line 888 of file cardview.cpp.

bool CardView::drawFieldLabels  )  const
 

Returns:
True if the field labels are drawn, false otherwise.

Definition at line 897 of file cardview.cpp.

void CardView::selectionChanged  )  [signal]
 

Emitted whenever the selection changes.

This means a user highlighted a new item or unhighlighted a currently selected item.

Referenced by selectAll(), and setSelected().

void CardView::selectionChanged CardViewItem  )  [signal]
 

Same as above method, only it carries the item that was selected.

This method will only be emitted in single select mode, since it defineds which item was selected.

void CardView::clicked CardViewItem  )  [signal]
 

This method is emitted whenever an item is clicked.

void CardView::executed CardViewItem  )  [signal]
 

Emitted whenever the user 'executes' an item.

This is dependant on the KDE global config. This could be a signal click or a doubleclick.

void CardView::doubleClicked CardViewItem  )  [signal]
 

Emitted whenever the user double clicks on an item.

void CardView::viewportPaintEvent QPaintEvent  )  [protected, virtual]
 

Repaints the whole viewport.

We use a double buffer to avoid flickering.

Reimplemented from QScrollView.

Definition at line 613 of file cardview.cpp.

References QPainter::begin(), calcLayout(), QColorGroup::color(), QScrollView::contentsX(), QScrollView::contentsY(), QPtrListIterator::current(), CardViewItem::d, QPainter::end(), QPixmap::fill(), CardViewItem::paintCard(), QPainter::restore(), QPainter::save(), QPtrListIterator::toFirst(), QPainter::translate(), QScrollView::viewport(), QRect::x(), and QRect::y().

void CardView::resizeEvent QResizeEvent e  )  [protected]
 

Sets the layout to dirty and repaints.

Definition at line 660 of file cardview.cpp.

References setLayoutDirty().

void CardView::setLayoutDirty bool  dirty  )  [protected]
 

Sets the layout to dirty and calls for a repaint.

Definition at line 851 of file cardview.cpp.

Referenced by clear(), CardViewItem::clearFields(), CardViewItem::insertField(), insertItem(), CardViewItem::removeField(), resizeEvent(), setDrawColSeparators(), and takeItem().

void CardView::calcLayout  )  [protected]
 

Does the math based on the bounding rect of the cards to properly lay the cards out on the screen.

This is only done if the layout is marked as dirty.

Definition at line 667 of file cardview.cpp.

References QPtrListIterator::current(), CardViewItem::d, QScrollView::resizeContents(), QPtrListIterator::toFirst(), and QScrollView::viewport().

Referenced by viewportPaintEvent().

void CardView::startDrag  )  [protected, virtual]
 

Overload this method to be told when a drag should be started.

In most cases you will want to start a drag event with the currently selected item.

Definition at line 902 of file cardview.cpp.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:38 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001