summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views/cardview.h
Side-by-side diff
Diffstat (limited to 'kaddressbook/views/cardview.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/cardview.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/kaddressbook/views/cardview.h b/kaddressbook/views/cardview.h
index 2ea3771..9c245ea 100644
--- a/kaddressbook/views/cardview.h
+++ b/kaddressbook/views/cardview.h
@@ -1,73 +1,81 @@
#ifndef CARDVIEW_H
#define CARDVIEW_H
-#include <qscrollview.h>
-#include <qptrlist.h>
+#include <q3scrollview.h>
+#include <q3ptrlist.h>
#include <qstring.h>
#include <qrect.h>
#include <qpair.h>
#include <qpoint.h>
+//Added by qt3to4:
+#include <QWheelEvent>
+#include <QResizeEvent>
+#include <QFocusEvent>
+#include <QLabel>
+#include <QMouseEvent>
+#include <QKeyEvent>
+#include <QEvent>
class QLabel;
class QPainter;
class QResizeEvent;
class QMouseEvent;
class CardView;
class CardViewPrivate;
class CardViewItemPrivate;
class CardViewTip;
/** 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.
*/
class CardViewItem
{
friend class CardView;
public:
/** A single field in the card view. The first item is the label
* and the second item is the value.
*/
typedef QPair<QString, QString> Field;
/** Constructor.
*
* @param parent The CardView that this card should be displayed on.
* @param 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.
*/
CardViewItem(CardView *parent, QString caption = QString::null);
virtual ~CardViewItem();
/** @return The caption of the card, or QString::null if none was ever
* set.
*/
const QString &caption() const;
/** 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.
*/
void setCaption(const QString &caption);
/** Paints the card using the given painter and color group. The
* card will handle painting itself selected if it is selected.
*/
virtual void paintCard(QPainter *p, QColorGroup &cg);
/** Repaints the card. This is done by sending a repaint event to the
* view with the clip rect defined as this card.
*/
virtual void repaintCard();
/** Adds a field to the card.
*
* @param label The label of the field. The field labels must be unique
* within a card.
* @param The value of the field.
*/
void insertField(const QString &label, const QString &value);
/** Removes the field with label <i>label</i> from the card.
@@ -87,129 +95,129 @@ class CardViewItem
* last card.
*/
CardViewItem *nextItem();
/** @return True if this card is currently selected, false otherwise.
*/
bool isSelected() const;
/** 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.
*/
void showFullString( const QPoint &pos, CardViewTip *tip );
/** @return a pointer to the Field at the position itempos
* in this item. 0 is returned if itempos is in the caption.
* @param itempos the position in item coordinates
*/
Field *fieldAt( const QPoint &itempos ) const;
CardView *cardView() { return mView; };
/** @return The height of this item as rendered, in pixels.
if @p 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
*/
int height( bool allowCache=true ) const;
protected:
/** Sets the card as selected. This is usually only called from the
* card view.
*/
void setSelected(bool selected);
private:
/** Sets the default values.
*/
void initialize();
/** Trims a string to the width <i>width</i> using the font metrics
* to determine the width of each char. If the string is longer than
* <i>width</i>, then the string will be trimmed and a '...' will
* be appended.
*/
QString trimString(const QString &text, int width, QFontMetrics &fm);
CardViewItemPrivate *d;
CardView *mView;
};
/** 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.
*/
-class CardView : public QScrollView
+class CardView : public Q3ScrollView
{
friend class CardViewItem;
Q_OBJECT
public:
/** Constructor.
*/
CardView(QWidget *parent, const char *name);
virtual ~CardView();
/** 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.
*/
void insertItem(CardViewItem *item);
/** Takes the item from the view. The item will not be deleted and
* ownership of the item is returned to the caller.
*/
void takeItem(CardViewItem *item);
/** Clears the view and deletes all card view items
*/
void clear();
/** @return 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.
* @sa setCurrentItem()
*/
CardViewItem *currentItem();
/** Sets the CardViewItem @p item to the current item in the view.
*/
void setCurrentItem( CardViewItem *item );
/** @return The item found at the given point, or 0 if there is no item
* at that point.
*/
CardViewItem *itemAt(const QPoint &viewPos);
/** @return The bounding rect of the given item.
*/
QRect itemRect(const CardViewItem *item);
/** Ensures that the given item is in the viewable area of the widget
*/
void ensureItemVisible(const CardViewItem *item);
/** Repaints the given item.
*/
void repaintItem(const CardViewItem *item);
enum SelectionMode { Single, Multi, Extended, NoSelection };
/** Sets the selection mode.
*
* @see QListView
*/
void setSelectionMode(SelectionMode mode);
/** @return The current selection mode.
*/