kaddressbook Library API Documentation

CardViewItem Class Reference

Represents a single card (item) in the card view. More...

#include <cardview.h>

List of all members.

Public Types

typedef QPair< QString, QStringField

Public Methods

 CardViewItem (CardView *parent, QString caption=QString::null)
virtual ~CardViewItem ()
const QStringcaption () const
void setCaption (const QString &caption)
virtual void paintCard (QPainter *p, QColorGroup &cg)
virtual void repaintCard ()
void insertField (const QString &label, const QString &value)
void removeField (const QString &label)
QString fieldValue (const QString &label)
void clearFields ()
CardViewItem * nextItem ()
bool isSelected () const
void showFullString (const QPoint &pos, CardViewTip *tip)
FieldfieldAt (const QPoint &itempos) const
CardViewcardView ()
int height (bool allowCache=true) const

Protected Methods

void setSelected (bool selected)

Friends

class CardView


Detailed Description

Represents a single card (item) in the card view.

A card has a caption and a list of fields. A Field is a label<->value pair. The labels in a card should be unique, since they will be used to index the values.

Definition at line 47 of file cardview.h.


Member Typedef Documentation

typedef QPair<QString, QString> CardViewItem::Field
 

A single field in the card view.

The first item is the label and the second item is the value.

Definition at line 55 of file cardview.h.

Referenced by fieldAt(), insertField(), and removeField().


Constructor & Destructor Documentation

CardViewItem::CardViewItem CardView   parent,
QString    caption = QString::null
 

Constructor.

Parameters:
parent  The CardView that this card should be displayed on.
caption  The caption of the card. This is the text that will appear at the top of the card. This is also the string that will be used to sort the cards in the view.

Definition at line 215 of file cardview.cpp.

References caption().


Member Function Documentation

const QString & CardViewItem::caption   const
 

Returns:
The caption of the card, or QString::null if none was ever set.

Definition at line 351 of file cardview.cpp.

Referenced by CardViewItem(), and showFullString().

void CardViewItem::setCaption const QString   caption
 

Sets the caption of the card.

This is the text that will appear at the top of the card. This is also the string that will be used to sort the cards in the view.

Definition at line 488 of file cardview.cpp.

References repaintCard().

void CardViewItem::paintCard QPainter   p,
QColorGroup   cg
[virtual]
 

Paints the card using the given painter and color group.

The card will handle painting itself selected if it is selected.

Definition at line 247 of file cardview.cpp.

References QFontMetrics::ascent(), QColorGroup::base(), QColorGroup::brush(), QColorGroup::button(), QColorGroup::buttonText(), QPtrListIterator::current(), CardView::currentItem(), CardView::d, QPainter::drawRect(), QPainter::drawText(), QPainter::fillRect(), CardView::headerFont(), QFontMetrics::height(), height(), QColorGroup::highlight(), QColorGroup::highlightedText(), QString::isEmpty(), isSelected(), CardView::itemMargin(), CardView::itemWidth(), CardView::maxFieldLines(), QPainter::restore(), QPainter::save(), QString::section(), QPainter::setFont(), QPainter::setPen(), QColorGroup::text(), QPtrListIterator::toFirst(), and QFontMetrics::width().

Referenced by CardView::drawContents().

void CardViewItem::repaintCard   [virtual]
 

Repaints the card.

This is done by sending a repaint event to the view with the clip rect defined as this card.

Definition at line 482 of file cardview.cpp.

References CardView::repaintItem().

Referenced by setCaption(), CardView::setCurrentItem(), and CardView::setSelected().

void CardViewItem::insertField const QString   label,
const QString   value
 

Adds a field to the card.

Parameters:
label  The label of the field. The field labels must be unique within a card.
The  value of the field.

Definition at line 406 of file cardview.cpp.

References CardView::d, Field, and CardView::setLayoutDirty().

void CardViewItem::removeField const QString   label
 

Removes the field with label label from the card.

Definition at line 419 of file cardview.cpp.

References QPtrListIterator::current(), Field, CardView::setLayoutDirty(), and QPtrListIterator::toFirst().

QString CardViewItem::fieldValue const QString   label
 

Returns:
The value of the field with label label.

Definition at line 494 of file cardview.cpp.

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

void CardViewItem::clearFields  
 

Removes all the fields from this card.

Definition at line 439 of file cardview.cpp.

References CardView::setLayoutDirty().

CardViewItem * CardViewItem::nextItem  
 

Returns:
The next card item. The order of the items will be the same as the display order in the view. 0 will be returned if this is the last card.

Definition at line 472 of file cardview.cpp.

References CardView::itemAfter().

Referenced by KAddressBookCardView::refresh(), KAddressBookCardView::selectedUids(), KAddressBookCardView::setSelected(), and CardView::takeItem().

bool CardViewItem::isSelected   const
 

Returns:
True if this card is currently selected, false otherwise.

Definition at line 396 of file cardview.cpp.

Referenced by CardView::isSelected(), paintCard(), KAddressBookCardView::selectedUids(), and CardView::setSelected().

void CardViewItem::showFullString const QPoint   pos,
CardViewTip *    tip
 

Called by the parent card view when the mouse has been resting for a certain amount of time.

If the label or value at pos is obscured (trimmed) make the label display the full text.

Definition at line 505 of file cardview.cpp.

References caption(), QString::contains(), QScrollView::contentsToViewport(), CardView::d, CardView::drawFieldLabels(), fieldAt(), CardView::headerFont(), QRect::height(), CardView::itemMargin(), CardView::itemWidth(), CardView::maxFieldLines(), QLabel::setFont(), QLabel::setText(), QPoint::setX(), QPoint::setY(), CardView::showEmptyFields(), QScrollView::visibleHeight(), QScrollView::visibleWidth(), QRect::width(), QPoint::x(), and QPoint::y().

CardViewItem::Field * CardViewItem::fieldAt const QPoint   itempos const
 

Returns:
a pointer to the Field at the position itempos in this item. 0 is returned if itempos is in the caption.
Parameters:
itempos  the position in item coordinates

Definition at line 584 of file cardview.cpp.

References CardView::d, Field, CardView::maxFieldLines(), CardView::showEmptyFields(), and QPoint::y().

Referenced by showFullString().

int CardViewItem::height bool    allowCache = true const
 

Returns:
The height of this item as rendered, in pixels.
if allowCache is true, the item may use an internally cached value rather than recalculating from scratch. The argument is mainly to allow the cardView to change global settings (like maxFieldLines) that might influence the items heights

Definition at line 357 of file cardview.cpp.

References QPtrListIterator::current(), CardView::d, CardView::itemMargin(), CardView::maxFieldLines(), CardView::showEmptyFields(), and QPtrListIterator::toFirst().

Referenced by CardView::calcLayout(), CardView::drawContents(), CardView::itemAt(), CardView::itemRect(), paintCard(), and CardView::repaintItem().

void CardViewItem::setSelected bool    selected [protected]
 

Sets the card as selected.

This is usually only called from the card view.

Definition at line 401 of file cardview.cpp.

Referenced by CardView::setSelected().


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