Diffstat (limited to 'kaddressbook/views/cardview.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/cardview.h | 14 |
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,41 +1,49 @@ | |||
1 | #ifndef CARDVIEW_H | 1 | #ifndef CARDVIEW_H |
2 | #define CARDVIEW_H | 2 | #define CARDVIEW_H |
3 | 3 | ||
4 | #include <qscrollview.h> | 4 | #include <q3scrollview.h> |
5 | #include <qptrlist.h> | 5 | #include <q3ptrlist.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qrect.h> | 7 | #include <qrect.h> |
8 | #include <qpair.h> | 8 | #include <qpair.h> |
9 | #include <qpoint.h> | 9 | #include <qpoint.h> |
10 | //Added by qt3to4: | ||
11 | #include <QWheelEvent> | ||
12 | #include <QResizeEvent> | ||
13 | #include <QFocusEvent> | ||
14 | #include <QLabel> | ||
15 | #include <QMouseEvent> | ||
16 | #include <QKeyEvent> | ||
17 | #include <QEvent> | ||
10 | 18 | ||
11 | class QLabel; | 19 | class QLabel; |
12 | class QPainter; | 20 | class QPainter; |
13 | class QResizeEvent; | 21 | class QResizeEvent; |
14 | class QMouseEvent; | 22 | class QMouseEvent; |
15 | class CardView; | 23 | class CardView; |
16 | class CardViewPrivate; | 24 | class CardViewPrivate; |
17 | class CardViewItemPrivate; | 25 | class CardViewItemPrivate; |
18 | class CardViewTip; | 26 | class CardViewTip; |
19 | 27 | ||
20 | /** Represents a single card (item) in the card view. A card has a caption | 28 | /** Represents a single card (item) in the card view. A card has a caption |
21 | * and a list of fields. A Field is a label<->value pair. The labels in a | 29 | * and a list of fields. A Field is a label<->value pair. The labels in a |
22 | * card should be unique, since they will be used to index the values. | 30 | * card should be unique, since they will be used to index the values. |
23 | */ | 31 | */ |
24 | class CardViewItem | 32 | class CardViewItem |
25 | { | 33 | { |
26 | friend class CardView; | 34 | friend class CardView; |
27 | 35 | ||
28 | public: | 36 | public: |
29 | /** A single field in the card view. The first item is the label | 37 | /** A single field in the card view. The first item is the label |
30 | * and the second item is the value. | 38 | * and the second item is the value. |
31 | */ | 39 | */ |
32 | typedef QPair<QString, QString> Field; | 40 | typedef QPair<QString, QString> Field; |
33 | 41 | ||
34 | /** Constructor. | 42 | /** Constructor. |
35 | * | 43 | * |
36 | * @param parent The CardView that this card should be displayed on. | 44 | * @param parent The CardView that this card should be displayed on. |
37 | * @param caption The caption of the card. This is the text that will | 45 | * @param caption The caption of the card. This is the text that will |
38 | * appear at the top of the card. This is also the string that will | 46 | * appear at the top of the card. This is also the string that will |
39 | * be used to sort the cards in the view. | 47 | * be used to sort the cards in the view. |
40 | */ | 48 | */ |
41 | CardViewItem(CardView *parent, QString caption = QString::null); | 49 | CardViewItem(CardView *parent, QString caption = QString::null); |
@@ -119,65 +127,65 @@ class CardViewItem | |||
119 | /** Sets the card as selected. This is usually only called from the | 127 | /** Sets the card as selected. This is usually only called from the |
120 | * card view. | 128 | * card view. |
121 | */ | 129 | */ |
122 | void setSelected(bool selected); | 130 | void setSelected(bool selected); |
123 | 131 | ||
124 | private: | 132 | private: |
125 | /** Sets the default values. | 133 | /** Sets the default values. |
126 | */ | 134 | */ |
127 | void initialize(); | 135 | void initialize(); |
128 | 136 | ||
129 | /** Trims a string to the width <i>width</i> using the font metrics | 137 | /** Trims a string to the width <i>width</i> using the font metrics |
130 | * to determine the width of each char. If the string is longer than | 138 | * to determine the width of each char. If the string is longer than |
131 | * <i>width</i>, then the string will be trimmed and a '...' will | 139 | * <i>width</i>, then the string will be trimmed and a '...' will |
132 | * be appended. | 140 | * be appended. |
133 | */ | 141 | */ |
134 | QString trimString(const QString &text, int width, QFontMetrics &fm); | 142 | QString trimString(const QString &text, int width, QFontMetrics &fm); |
135 | 143 | ||
136 | CardViewItemPrivate *d; | 144 | CardViewItemPrivate *d; |
137 | CardView *mView; | 145 | CardView *mView; |
138 | }; | 146 | }; |
139 | 147 | ||
140 | /** The CardView is a method of displaying data in cards. This idea is | 148 | /** The CardView is a method of displaying data in cards. This idea is |
141 | * similar to the idea of a rolodex or business cards. Each card has a | 149 | * similar to the idea of a rolodex or business cards. Each card has a |
142 | * caption and a list of fields, which are label<->value pairs. The CardView | 150 | * caption and a list of fields, which are label<->value pairs. The CardView |
143 | * displays multiple cards in a grid. The Cards are sorted based on their | 151 | * displays multiple cards in a grid. The Cards are sorted based on their |
144 | * caption. | 152 | * caption. |
145 | * | 153 | * |
146 | * The CardView class is designed to mirror the API of the QListView or | 154 | * The CardView class is designed to mirror the API of the QListView or |
147 | * QIconView. The CardView is also completely independant of KAddressBook and | 155 | * QIconView. The CardView is also completely independant of KAddressBook and |
148 | * can be used elsewhere. With the exception of a few simple config checks, | 156 | * can be used elsewhere. With the exception of a few simple config checks, |
149 | * the CardView is also 100% independant of KDE. | 157 | * the CardView is also 100% independant of KDE. |
150 | */ | 158 | */ |
151 | class CardView : public QScrollView | 159 | class CardView : public Q3ScrollView |
152 | { | 160 | { |
153 | friend class CardViewItem; | 161 | friend class CardViewItem; |
154 | 162 | ||
155 | Q_OBJECT | 163 | Q_OBJECT |
156 | 164 | ||
157 | public: | 165 | public: |
158 | /** Constructor. | 166 | /** Constructor. |
159 | */ | 167 | */ |
160 | CardView(QWidget *parent, const char *name); | 168 | CardView(QWidget *parent, const char *name); |
161 | virtual ~CardView(); | 169 | virtual ~CardView(); |
162 | 170 | ||
163 | /** Inserts the item into the card view. This method does not have | 171 | /** Inserts the item into the card view. This method does not have |
164 | * to be called if you created the item with a proper parent. Once | 172 | * to be called if you created the item with a proper parent. Once |
165 | * inserted, the CardView takes ownership of the item. | 173 | * inserted, the CardView takes ownership of the item. |
166 | */ | 174 | */ |
167 | void insertItem(CardViewItem *item); | 175 | void insertItem(CardViewItem *item); |
168 | 176 | ||
169 | /** Takes the item from the view. The item will not be deleted and | 177 | /** Takes the item from the view. The item will not be deleted and |
170 | * ownership of the item is returned to the caller. | 178 | * ownership of the item is returned to the caller. |
171 | */ | 179 | */ |
172 | void takeItem(CardViewItem *item); | 180 | void takeItem(CardViewItem *item); |
173 | 181 | ||
174 | /** Clears the view and deletes all card view items | 182 | /** Clears the view and deletes all card view items |
175 | */ | 183 | */ |
176 | void clear(); | 184 | void clear(); |
177 | 185 | ||
178 | /** @return The current item, the item that has the focus. | 186 | /** @return The current item, the item that has the focus. |
179 | * Whenever the view has focus, this item has a focus rectangle painted | 187 | * Whenever the view has focus, this item has a focus rectangle painted |
180 | * at it's border. | 188 | * at it's border. |
181 | * @sa setCurrentItem() | 189 | * @sa setCurrentItem() |
182 | */ | 190 | */ |
183 | CardViewItem *currentItem(); | 191 | CardViewItem *currentItem(); |