• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kaddressbook

CardView Class Reference

#include <cardview.h>

Inheritance diagram for CardView:

Inheritance graph
[legend]

List of all members.


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 independent of KAddressBook and can be used elsewhere. With the exception of a few simple config checks, the CardView is also 100% independent of KDE.

Definition at line 199 of file cardview.h.


Public Types

enum  SelectionMode { Single, Multi, Extended, NoSelection }

Signals

void clicked (CardViewItem *)
void contextMenuRequested (CardViewItem *, const QPoint &)
void currentChanged (CardViewItem *)
void doubleClicked (CardViewItem *)
void executed (CardViewItem *)
void returnPressed (CardViewItem *)
void selectionChanged (CardViewItem *)
void selectionChanged ()

Public Member Functions

 CardView (QWidget *parent, const char *name)
int childCount () const
void clear ()
uint columnWidth () const
CardViewItem * currentItem () const
bool drawCardBorder () const
bool drawColSeparators () const
bool drawFieldLabels () const
void ensureItemVisible (const CardViewItem *item)
CardViewItem * findItem (const QString &text, const QString &label, Q3ListBox::StringComparisonMode compare=Q3ListBox::BeginsWith) const
CardViewItem * firstItem () const
QFont headerFont () const
void insertItem (CardViewItem *item)
bool isSelected (CardViewItem *item) const
CardViewItem * itemAfter (const CardViewItem *item) const
CardViewItem * itemAt (const QPoint &viewPos) const
uint itemMargin () const
QRect itemRect (const CardViewItem *item) const
uint itemSpacing () const
int itemWidth () const
int maxFieldLines () const
void repaintItem (const CardViewItem *item)
void selectAll (bool state)
CardViewItem * selectedItem () const
SelectionMode selectionMode () const
int separatorWidth () const
void setCurrentItem (CardViewItem *item)
void setDrawCardBorder (bool enabled)
void setDrawColSeparators (bool enabled)
void setDrawFieldLabels (bool enabled)
void setFont (const QFont &fnt)
void setHeaderFont (const QFont &fnt)
void setItemMargin (uint margin)
void setItemSpacing (uint spacing)
void setItemWidth (int width)
void setMaxFieldLines (int howmany)
void setSelected (CardViewItem *item, bool selected)
void setSelectionMode (SelectionMode mode)
void setSeparatorWidth (int width)
void setShowEmptyFields (bool show)
bool showEmptyFields () const
void takeItem (CardViewItem *item)
virtual ~CardView ()

Protected Member Functions

void calcLayout ()
virtual void contentsMouseDoubleClickEvent (QMouseEvent *)
virtual void contentsMouseMoveEvent (QMouseEvent *)
virtual void contentsMousePressEvent (QMouseEvent *)
virtual void contentsMouseReleaseEvent (QMouseEvent *)
void contentsWheelEvent (QWheelEvent *)
void drawContents (QPainter *p, int clipx, int clipy, int clipw, int cliph)
virtual void enterEvent (QEvent *)
virtual void focusInEvent (QFocusEvent *)
virtual void focusOutEvent (QFocusEvent *)
virtual void keyPressEvent (QKeyEvent *)
virtual void leaveEvent (QEvent *)
void resizeEvent (QResizeEvent *)
void setLayoutDirty (bool dirty)
virtual void startDrag ()

Member Enumeration Documentation

enum CardView::SelectionMode

Enumerator:
Single 
Multi 
Extended 
NoSelection 

Definition at line 264 of file cardview.h.


Constructor & Destructor Documentation

CardView::CardView ( QWidget *  parent,
const char *  name 
)

Constructor.

Definition at line 584 of file cardview.cpp.

CardView::~CardView (  )  [virtual]

Definition at line 614 of file cardview.cpp.


Member Function Documentation

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 904 of file cardview.cpp.

int CardView::childCount (  )  const

Returns:
The number of items in the view.

Definition at line 815 of file cardview.cpp.

void CardView::clear (  ) 

Clears the view and deletes all card view items.

Definition at line 637 of file cardview.cpp.

void CardView::clicked ( CardViewItem *   )  [signal]

This method is emitted whenever an item is clicked.

uint CardView::columnWidth (  )  const

Returns the amounts of pixels required for one column.

This depends on wheather drawSeparators is enabled: If so, it is itemWidth + 2*itemSpacing + separatorWidth If not, it is itemWidth + itemSpacing

See also:
itemWidth(), setItemWidth(), itemSpacing() and setItemSpacing()

Definition at line 843 of file cardview.cpp.

void CardView::contentsMouseDoubleClickEvent ( QMouseEvent *  e  )  [protected, virtual]

Reimplemented from Q3ScrollView.

Definition at line 1140 of file cardview.cpp.

void CardView::contentsMouseMoveEvent ( QMouseEvent *  e  )  [protected, virtual]

Reimplemented from Q3ScrollView.

Definition at line 1155 of file cardview.cpp.

void CardView::contentsMousePressEvent ( QMouseEvent *  e  )  [protected, virtual]

Reimplemented from Q3ScrollView.

Definition at line 998 of file cardview.cpp.

void CardView::contentsMouseReleaseEvent ( QMouseEvent *  e  )  [protected, virtual]

Reimplemented from Q3ScrollView.

Definition at line 1107 of file cardview.cpp.

void CardView::contentsWheelEvent ( QWheelEvent *  e  )  [protected]

Changes the direction the canvas scolls.

Reimplemented from Q3ScrollView.

Definition at line 1390 of file cardview.cpp.

void CardView::contextMenuRequested ( CardViewItem *  ,
const QPoint &   
) [signal]

Emitted when the context menu is requested in some way.

void CardView::currentChanged ( CardViewItem *   )  [signal]

Emitted when the current item changes.

CardViewItem * CardView::currentItem (  )  const

Returns:
The current item, the item that has the focus.

Whenever the view has focus, this item has a focus rectangle painted at it's border.

See also:
setCurrentItem()

Definition at line 644 of file cardview.cpp.

void CardView::doubleClicked ( CardViewItem *   )  [signal]

Emitted whenever the user double clicks on an item.

bool CardView::drawCardBorder (  )  const

Returns:
True if borders are drawn, false otherwise.

Definition at line 1411 of file cardview.cpp.

bool CardView::drawColSeparators (  )  const

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

Definition at line 1424 of file cardview.cpp.

void CardView::drawContents ( QPainter *  p,
int  clipx,
int  clipy,
int  clipw,
int  cliph 
) [protected]

Determines which cards intersect that region and tells them to paint themselves.

Reimplemented from Q3ScrollView.

Definition at line 850 of file cardview.cpp.

bool CardView::drawFieldLabels (  )  const

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

Definition at line 1437 of file cardview.cpp.

void CardView::ensureItemVisible ( const CardViewItem *  item  ) 

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

Definition at line 702 of file cardview.cpp.

void CardView::enterEvent ( QEvent *   )  [protected, virtual]

Definition at line 1190 of file cardview.cpp.

void CardView::executed ( CardViewItem *   )  [signal]

Emitted whenever the user 'executes' an item.

This is dependant on the KDE global config. This could be a single click or a doubleclick. Also emitted when the return key is pressed on an item.

CardViewItem * CardView::findItem ( const QString &  text,
const QString &  label,
Q3ListBox::StringComparisonMode  compare = Q3ListBox::BeginsWith 
) const

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 820 of file cardview.cpp.

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 810 of file cardview.cpp.

void CardView::focusInEvent ( QFocusEvent *   )  [protected, virtual]

Definition at line 1204 of file cardview.cpp.

void CardView::focusOutEvent ( QFocusEvent *   )  [protected, virtual]

Definition at line 1212 of file cardview.cpp.

QFont CardView::headerFont (  )  const

Returns:
the header font

Definition at line 1533 of file cardview.cpp.

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 622 of file cardview.cpp.

bool CardView::isSelected ( CardViewItem *  item  )  const

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

Definition at line 793 of file cardview.cpp.

CardViewItem * CardView::itemAfter ( const CardViewItem *  item  )  const

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

Definition at line 964 of file cardview.cpp.

CardViewItem * CardView::itemAt ( const QPoint &  viewPos  )  const

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

Definition at line 680 of file cardview.cpp.

uint CardView::itemMargin (  )  const

Returns:
the advisory internal margin in items.

Setting a value above 1 means a space between the item contents and the focus recttangle drawn around the current item. The default value is 0. The value should be used by CardViewItem and derived classes. Note that this should not be greater than half of the minimal item width, which is 80. It is currently not checked, so setting a value greater than 40 will probably mean a crash in the items painting routine.

Definition at line 970 of file cardview.cpp.

QRect CardView::itemRect ( const CardViewItem *  item  )  const

Returns:
The bounding rect of the given item.

Definition at line 697 of file cardview.cpp.

uint CardView::itemSpacing (  )  const

Returns:
the item spacing.

The item spacing is the space (in pixels) between each item in a column, between the items and column separators if drawn, and between the items and the borders of the widget. The default value is set to 10.

Definition at line 984 of file cardview.cpp.

int CardView::itemWidth (  )  const

Returns:
the width made available to the card items.

Definition at line 1510 of file cardview.cpp.

void CardView::keyPressEvent ( QKeyEvent *  e  )  [protected, virtual]

Definition at line 1218 of file cardview.cpp.

void CardView::leaveEvent ( QEvent *   )  [protected, virtual]

Definition at line 1195 of file cardview.cpp.

int CardView::maxFieldLines (  )  const

Returns:
the maximum number of lines pr field

Definition at line 1556 of file cardview.cpp.

void CardView::repaintItem ( const CardViewItem *  item  ) 

Repaints the given item.

Definition at line 708 of file cardview.cpp.

void CardView::resizeEvent ( QResizeEvent *  event  )  [protected]

Sets the layout to dirty and repaints.

Definition at line 897 of file cardview.cpp.

void CardView::returnPressed ( CardViewItem *   )  [signal]

Emitted when the return key is pressed in an item.

void CardView::selectAll ( bool  state  ) 

Selects or deselects all items.

Definition at line 725 of file cardview.cpp.

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 798 of file cardview.cpp.

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::selectionChanged (  )  [signal]

Emitted whenever the selection changes.

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

CardView::SelectionMode CardView::selectionMode (  )  const

Returns:
The current selection mode.

Definition at line 720 of file cardview.cpp.

int CardView::separatorWidth (  )  const

Returns:
the column separator width

Definition at line 1545 of file cardview.cpp.

void CardView::setCurrentItem ( CardViewItem *  item  ) 

Sets the CardViewItem item to the current item in the view.

Definition at line 652 of file cardview.cpp.

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 1403 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 1416 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 1429 of file cardview.cpp.

void CardView::setFont ( const QFont &  fnt  ) 

Reimplementation from QWidget.

Definition at line 1538 of file cardview.cpp.

void CardView::setHeaderFont ( const QFont &  fnt  ) 

Sets the header font.

Definition at line 1526 of file cardview.cpp.

void CardView::setItemMargin ( uint  margin  ) 

Sets the internal item margin.

See itemMargin().

Definition at line 975 of file cardview.cpp.

void CardView::setItemSpacing ( uint  spacing  ) 

Sets the item spacing.

See also:
itemSpacing()

Definition at line 989 of file cardview.cpp.

void CardView::setItemWidth ( int  width  ) 

Sets the width made available to card items.

Definition at line 1515 of file cardview.cpp.

void CardView::setLayoutDirty ( bool  dirty  )  [protected]

Sets the layout to dirty and calls for a repaint.

Definition at line 1395 of file cardview.cpp.

void CardView::setMaxFieldLines ( int  howmany  ) 

Sets the maximum number of lines to display pr field.

If set to 0 (the default) all lines will be displayed.

Definition at line 1561 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 750 of file cardview.cpp.

void CardView::setSelectionMode ( CardView::SelectionMode  mode  ) 

Sets the selection mode.

See also:
QListView

Definition at line 713 of file cardview.cpp.

void CardView::setSeparatorWidth ( int  width  ) 

Sets the column separator width.

Definition at line 1550 of file cardview.cpp.

void CardView::setShowEmptyFields ( bool  show  ) 

Sets if fields with no value should be drawn (of cause the label only, but it allows for embedded editing sometimes.

..)

Definition at line 1442 of file cardview.cpp.

bool CardView::showEmptyFields (  )  const

Returns:
Wheather empty fields should be shown

Definition at line 1450 of file cardview.cpp.

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.

Reimplemented in AddresseeCardView.

Definition at line 1455 of file cardview.cpp.

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 628 of file cardview.cpp.


The documentation for this class was generated from the following files:
  • cardview.h
  • cardview.cpp

kaddressbook

Skip menu "kaddressbook"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal