#include <cardview.h>
Inherits TQScrollView.
Inherited by AddresseeCardView.
Public Types | |
enum | SelectionMode { Single , Multi , Extended , NoSelection } |
Signals | |
void | selectionChanged () |
void | selectionChanged (CardViewItem *) |
void | clicked (CardViewItem *) |
void | executed (CardViewItem *) |
void | doubleClicked (CardViewItem *) |
void | currentChanged (CardViewItem *) |
void | returnPressed (CardViewItem *) |
void | contextMenuRequested (CardViewItem *, const TQPoint &) |
Public Member Functions | |
CardView (TQWidget *parent, const char *name) | |
void | insertItem (CardViewItem *item) |
void | takeItem (CardViewItem *item) |
void | clear () |
CardViewItem * | currentItem () const |
void | setCurrentItem (CardViewItem *item) |
CardViewItem * | itemAt (const TQPoint &viewPos) const |
TQRect | itemRect (const CardViewItem *item) const |
void | ensureItemVisible (const CardViewItem *item) |
void | repaintItem (const CardViewItem *item) |
void | setSelectionMode (SelectionMode mode) |
SelectionMode | selectionMode () const |
void | setSelected (CardViewItem *item, bool selected) |
void | selectAll (bool state) |
bool | isSelected (CardViewItem *item) const |
CardViewItem * | selectedItem () const |
CardViewItem * | firstItem () const |
CardViewItem * | itemAfter (const CardViewItem *item) const |
int | childCount () const |
CardViewItem * | findItem (const TQString &text, const TQString &label, TQt::StringComparisonMode compare=TQt::BeginsWith) const |
uint | columnWidth () const |
void | setDrawCardBorder (bool enabled) |
bool | drawCardBorder () const |
void | setDrawColSeparators (bool enabled) |
bool | drawColSeparators () const |
void | setDrawFieldLabels (bool enabled) |
bool | drawFieldLabels () const |
void | setShowEmptyFields (bool show) |
bool | showEmptyFields () const |
uint | itemMargin () const |
void | setItemMargin (uint margin) |
uint | itemSpacing () const |
void | setItemSpacing (uint spacing) |
int | itemWidth () const |
void | setItemWidth (int width) |
void | setHeaderFont (const TQFont &fnt) |
TQFont | headerFont () const |
void | setFont (const TQFont &fnt) |
void | setSeparatorWidth (int width) |
int | separatorWidth () const |
void | setMaxFieldLines (int howmany) |
int | maxFieldLines () const |
Protected Member Functions | |
void | drawContents (TQPainter *p, int clipx, int clipy, int clipw, int cliph) |
void | resizeEvent (TQResizeEvent *) |
void | contentsWheelEvent (TQWheelEvent *) |
void | setLayoutDirty (bool dirty) |
void | calcLayout () |
virtual void | contentsMousePressEvent (TQMouseEvent *) |
virtual void | contentsMouseMoveEvent (TQMouseEvent *) |
virtual void | contentsMouseReleaseEvent (TQMouseEvent *) |
virtual void | contentsMouseDoubleClickEvent (TQMouseEvent *) |
virtual void | enterEvent (TQEvent *) |
virtual void | leaveEvent (TQEvent *) |
virtual void | focusInEvent (TQFocusEvent *) |
virtual void | focusOutEvent (TQFocusEvent *) |
virtual void | keyPressEvent (TQKeyEvent *) |
virtual void | startDrag () |
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 TQListView or TQIconView. 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 194 of file cardview.h.
Constructor & Destructor Documentation
◆ CardView()
CardView::CardView | ( | TQWidget * | parent, |
const char * | name | ||
) |
Constructor.
Definition at line 572 of file cardview.cpp.
Member Function Documentation
◆ 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 894 of file cardview.cpp.
◆ childCount()
int CardView::childCount | ( | ) | const |
- Returns
- The number of items in the view.
Definition at line 802 of file cardview.cpp.
◆ clear()
void CardView::clear | ( | ) |
Clears the view and deletes all card view items.
Definition at line 624 of file cardview.cpp.
◆ clicked
|
signal |
This method is emitted whenever an item is clicked.
◆ columnWidth()
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 830 of file cardview.cpp.
◆ contentsWheelEvent()
|
protected |
Changes the direction the canvas scolls.
Definition at line 1386 of file cardview.cpp.
◆ contextMenuRequested
|
signal |
Emitted when the context menu is requested in some way.
◆ currentChanged
|
signal |
Emitted when the current item changes.
◆ currentItem()
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 631 of file cardview.cpp.
◆ doubleClicked
|
signal |
Emitted whenever the user double clicks on an item.
◆ drawCardBorder()
bool CardView::drawCardBorder | ( | ) | const |
- Returns
- True if borders are drawn, false otherwise.
Definition at line 1407 of file cardview.cpp.
◆ drawColSeparators()
bool CardView::drawColSeparators | ( | ) | const |
- Returns
- True if column separators are drawn, false otherwise.
Definition at line 1420 of file cardview.cpp.
◆ drawContents()
|
protected |
Determines which cards intersect that region and tells them to paint themselves.
Definition at line 837 of file cardview.cpp.
◆ drawFieldLabels()
bool CardView::drawFieldLabels | ( | ) | const |
- Returns
- True if the field labels are drawn, false otherwise.
Definition at line 1433 of file cardview.cpp.
◆ ensureItemVisible()
void CardView::ensureItemVisible | ( | const CardViewItem * | item | ) |
Ensures that the given item is in the viewable area of the widget.
Definition at line 689 of file cardview.cpp.
◆ executed
|
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.
◆ findItem()
CardViewItem * CardView::findItem | ( | const TQString & | text, |
const TQString & | label, | ||
TQt::StringComparisonMode | compare = TQt::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 807 of file cardview.cpp.
◆ firstItem()
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 797 of file cardview.cpp.
◆ headerFont()
TQFont CardView::headerFont | ( | ) | const |
- Returns
- the header font
Definition at line 1529 of file cardview.cpp.
◆ insertItem()
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 609 of file cardview.cpp.
◆ isSelected()
bool CardView::isSelected | ( | CardViewItem * | item | ) | const |
- Returns
- True if the given item is selected, false otherwise.
Definition at line 780 of file cardview.cpp.
◆ itemAfter()
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 954 of file cardview.cpp.
◆ itemAt()
CardViewItem * CardView::itemAt | ( | const TQPoint & | viewPos | ) | const |
- Returns
- The item found at the given point, or 0 if there is no item at that point.
Definition at line 667 of file cardview.cpp.
◆ itemMargin()
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 960 of file cardview.cpp.
◆ itemRect()
TQRect CardView::itemRect | ( | const CardViewItem * | item | ) | const |
- Returns
- The bounding rect of the given item.
Definition at line 684 of file cardview.cpp.
◆ itemSpacing()
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 974 of file cardview.cpp.
◆ itemWidth()
int CardView::itemWidth | ( | ) | const |
- Returns
- the width made available to the card items.
Definition at line 1506 of file cardview.cpp.
◆ maxFieldLines()
int CardView::maxFieldLines | ( | ) | const |
- Returns
- the maximum number of lines pr field
Definition at line 1552 of file cardview.cpp.
◆ repaintItem()
void CardView::repaintItem | ( | const CardViewItem * | item | ) |
Repaints the given item.
Definition at line 695 of file cardview.cpp.
◆ resizeEvent()
|
protected |
Sets the layout to dirty and repaints.
Definition at line 887 of file cardview.cpp.
◆ returnPressed
|
signal |
Emitted when the return key is pressed in an item.
◆ selectAll()
void CardView::selectAll | ( | bool | state | ) |
Selects or deselects all items.
Definition at line 712 of file cardview.cpp.
◆ selectedItem()
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 785 of file cardview.cpp.
◆ selectionChanged [1/2]
|
signal |
Emitted whenever the selection changes.
This means a user highlighted a new item or unhighlighted a currently selected item.
◆ selectionChanged [2/2]
|
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.
◆ selectionMode()
CardView::SelectionMode CardView::selectionMode | ( | ) | const |
- Returns
- The current selection mode.
Definition at line 707 of file cardview.cpp.
◆ separatorWidth()
int CardView::separatorWidth | ( | ) | const |
- Returns
- the column separator width
Definition at line 1541 of file cardview.cpp.
◆ setCurrentItem()
void CardView::setCurrentItem | ( | CardViewItem * | item | ) |
Sets the CardViewItem item
to the current item in the view.
Definition at line 639 of file cardview.cpp.
◆ setDrawCardBorder()
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 1399 of file cardview.cpp.
◆ setDrawColSeparators()
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 1412 of file cardview.cpp.
◆ setDrawFieldLabels()
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 1425 of file cardview.cpp.
◆ setFont()
void CardView::setFont | ( | const TQFont & | fnt | ) |
Reimplementation from TQWidget.
Definition at line 1534 of file cardview.cpp.
◆ setHeaderFont()
void CardView::setHeaderFont | ( | const TQFont & | fnt | ) |
Sets the header font.
Definition at line 1522 of file cardview.cpp.
◆ setItemMargin()
void CardView::setItemMargin | ( | uint | margin | ) |
◆ setItemSpacing()
void CardView::setItemSpacing | ( | uint | spacing | ) |
◆ setItemWidth()
void CardView::setItemWidth | ( | int | width | ) |
Sets the width made available to card items.
Definition at line 1511 of file cardview.cpp.
◆ setLayoutDirty()
|
protected |
Sets the layout to dirty and calls for a repaint.
Definition at line 1391 of file cardview.cpp.
◆ setMaxFieldLines()
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 1557 of file cardview.cpp.
◆ setSelected()
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 737 of file cardview.cpp.
◆ setSelectionMode()
void CardView::setSelectionMode | ( | CardView::SelectionMode | mode | ) |
◆ setSeparatorWidth()
void CardView::setSeparatorWidth | ( | int | width | ) |
Sets the column separator width.
Definition at line 1546 of file cardview.cpp.
◆ setShowEmptyFields()
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 1438 of file cardview.cpp.
◆ showEmptyFields()
bool CardView::showEmptyFields | ( | ) | const |
- Returns
- Wheather empty fields should be shown
Definition at line 1446 of file cardview.cpp.
◆ startDrag()
|
protectedvirtual |
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 1451 of file cardview.cpp.
◆ takeItem()
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 615 of file cardview.cpp.
The documentation for this class was generated from the following files: