1QIconViewItem(3qt)                                          QIconViewItem(3qt)
2
3
4

NAME

6       QIconViewItem - Single item in a QIconView
7

SYNOPSIS

9       #include <qiconview.h>
10
11       Inherits Qt.
12
13   Public Members
14       QIconViewItem ( QIconView * parent )
15       QIconViewItem ( QIconView * parent, QIconViewItem * after )
16       QIconViewItem ( QIconView * parent, const QString & text )
17       QIconViewItem ( QIconView * parent, QIconViewItem * after, const
18           QString & text )
19       QIconViewItem ( QIconView * parent, const QString & text, const QPixmap
20           & icon )
21       QIconViewItem ( QIconView * parent, QIconViewItem * after, const
22           QString & text, const QPixmap & icon )
23       QIconViewItem ( QIconView * parent, const QString & text, const
24           QPicture & picture )
25       QIconViewItem ( QIconView * parent, QIconViewItem * after, const
26           QString & text, const QPicture & picture )
27       virtual ~QIconViewItem ()
28       virtual void setRenameEnabled ( bool allow )
29       virtual void setDragEnabled ( bool allow )
30       virtual void setDropEnabled ( bool allow )
31       virtual QString text () const
32       virtual QPixmap * pixmap () const
33       virtual QPicture * picture () const
34       virtual QString key () const
35       bool renameEnabled () const
36       bool dragEnabled () const
37       bool dropEnabled () const
38       QIconView * iconView () const
39       QIconViewItem * prevItem () const
40       QIconViewItem * nextItem () const
41       int index () const
42       virtual void setSelected ( bool s, bool cb )
43       virtual void setSelected ( bool s )
44       virtual void setSelectable ( bool enable )
45       bool isSelected () const
46       bool isSelectable () const
47       virtual void repaint ()
48       virtual bool move ( int x, int y )
49       virtual void moveBy ( int dx, int dy )
50       virtual bool move ( const QPoint & pnt )
51       virtual void moveBy ( const QPoint & pnt )
52       QRect rect () const
53       int x () const
54       int y () const
55       int width () const
56       int height () const
57       QSize size () const
58       QPoint pos () const
59       QRect textRect ( bool relative = TRUE ) const
60       QRect pixmapRect ( bool relative = TRUE ) const
61       bool contains ( const QPoint & pnt ) const
62       bool intersects ( const QRect & r ) const
63       virtual bool acceptDrop ( const QMimeSource * mime ) const
64       void rename ()
65       virtual int compare ( QIconViewItem * i ) const
66       virtual void setText ( const QString & text )
67       virtual void setPixmap ( const QPixmap & icon )
68       virtual void setPicture ( const QPicture & icon )
69       virtual void setText ( const QString & text, bool recalc, bool redraw =
70           TRUE )
71       virtual void setPixmap ( const QPixmap & icon, bool recalc, bool redraw
72           = TRUE )
73       virtual void setKey ( const QString & k )
74       virtual int rtti () const
75
76   Protected Members
77       virtual void removeRenameBox ()
78       virtual void calcRect ( const QString & text_ = QString::null )
79       virtual void paintItem ( QPainter * p, const QColorGroup & cg )
80       virtual void paintFocus ( QPainter * p, const QColorGroup & cg )
81       virtual void dropped ( QDropEvent * e, const QValueList<QIconDragItem>
82           & lst )
83       virtual void dragEntered ()
84       virtual void dragLeft ()
85       void setItemRect ( const QRect & r )
86       void setTextRect ( const QRect & r )
87       void setPixmapRect ( const QRect & r )
88

DESCRIPTION

90       The QIconViewItem class provides a single item in a QIconView.
91
92       A QIconViewItem contains an icon, a string and optionally a sort key,
93       and can display itself in a QIconView. The class is designed to be very
94       similar to QListView and QListBox in use, both via instantiation and
95       subclassing.
96
97       The simplest way to create a QIconViewItem and insert it into a
98       QIconView is to construct the item passing the constructor a pointer to
99       the icon view, a string and an icon:
100
101           (void) new QIconViewItem(
102                           iconView,   // A pointer to a QIconView
103                           "This is the text of the item",
104                           aPixmap );
105
106       By default the text of an icon view item may not be edited by the user
107       but calling setRenameEnabled(TRUE) will allow the user to perform in-
108       place editing of the item's text.
109
110       When the icon view is deleted all items in it are deleted
111       automatically.
112
113       The QIconView::firstItem() and QIconViewItem::nextItem() functions
114       provide a means of iterating over all the items in a QIconView:
115
116           QIconViewItem *item;
117           for ( item = iconView->firstItem(); item; item = item->nextItem() )
118               do_something_with( item );
119
120       The item's icon view is available from iconView(), and its position in
121       the icon view from index().
122
123       The item's selection status is available from isSelected() and is set
124       and controlled by setSelected() and isSelectable().
125
126       The text and icon can be set with setText() and setPixmap() and
127       retrieved with text() and pixmap(). The item's sort key defaults to
128       text() but may be set with setKey() and retrieved with key(). The
129       comparison function, compare() uses key().
130
131       Items may be repositioned with move() and moveBy(). An item's geometry
132       is available from rect(), x(), y(), width(), height(), size(), pos(),
133       textRect() and pixmapRect(). You can also test against the position of
134       a point with contains() and intersects().
135
136       To remove an item from an icon view, just delete the item. The
137       QIconViewItem destructor removes it cleanly from its icon view.
138
139       Because the icon view is designed to use drag-and-drop, the icon view
140       item also has functions for drag-and-drop which may be reimplemented.
141
142       Note: Pixmaps with individual dimensions larger than 300 pixels may not
143       be displayed properly, depending on the arrangement in use. For
144       example, pixmaps wider than 300 pixels will not be arranged correctly
145       if the icon view uses a QIconView::TopToBottom arrangement, and pixmaps
146       taller than 300 pixels will not be arranged correctly if the icon view
147       uses a QIconView::LeftToRight arrangement.
148
149       See also Advanced Widgets.
150

MEMBER FUNCTION DOCUMENTATION

QIconViewItem::QIconViewItem ( QIconView * parent )

153       Constructs a QIconViewItem and inserts it into icon view parent with no
154       text and a default icon.
155

QIconViewItem::QIconViewItem ( QIconView * parent, QIconViewItem * after )

157       Constructs a QIconViewItem and inserts it into the icon view parent
158       with no text and a default icon, after the icon view item after.
159

QIconViewItem::QIconViewItem ( QIconView * parent, const QString & text )

161       Constructs an icon view item and inserts it into the icon view parent
162       using text as the text and a default icon.
163

QIconViewItem::QIconViewItem ( QIconView * parent, QIconViewItem * after,

165       const QString & text )
166       Constructs an icon view item and inserts it into the icon view parent
167       using text as the text and a default icon, after the icon view item
168       after.
169

QIconViewItem::QIconViewItem ( QIconView * parent, const QString & text, const

171       QPixmap & icon )
172       Constructs an icon view item and inserts it into the icon view parent
173       using text as the text and icon as the icon.
174

QIconViewItem::QIconViewItem ( QIconView * parent, QIconViewItem * after,

176       const QString & text, const QPixmap & icon )
177       Constructs an icon view item and inserts it into the icon view parent
178       using text as the text and icon as the icon, after the icon view item
179       after.
180
181       See also setPixmap().
182

QIconViewItem::QIconViewItem ( QIconView * parent, const QString & text, const

184       QPicture & picture )
185       Constructs an icon view item and inserts it into the icon view parent
186       using text as the text and picture as the icon.
187

QIconViewItem::QIconViewItem ( QIconView * parent, QIconViewItem * after,

189       const QString & text, const QPicture & picture )
190       Constructs an icon view item and inserts it into the icon view parent
191       using text as the text and picture as the icon, after the icon view
192       item after.
193

QIconViewItem::~QIconViewItem () [virtual]

195       Destroys the icon view item and tells the parent icon view that the
196       item has been destroyed.
197

bool QIconViewItem::acceptDrop ( const QMimeSource * mime ) const [virtual]

199       Returns TRUE if you can drop things with a QMimeSource of mime onto
200       this item; otherwise returns FALSE.
201
202       The default implementation always returns FALSE. You must subclass
203       QIconViewItem and reimplement acceptDrop() to accept drops.
204
205       Examples:
206

void QIconViewItem::calcRect ( const QString & text_ = QString::null )

208       [virtual protected]
209       This virtual function is responsible for calculating the rectangles
210       returned by rect(), textRect() and pixmapRect(). setRect(),
211       setTextRect() and setPixmapRect() are provided mainly for
212       reimplementations of this function.
213
214       text_ is an internal parameter which defaults to QString::null.
215

int QIconViewItem::compare ( QIconViewItem * i ) const [virtual]

217       Compares this icon view item to i. Returns -1 if this item is less than
218       i, 0 if they are equal, and 1 if this icon view item is greater than i.
219
220       The default implementation compares the item keys (key()) using
221       QString::localeAwareCompare(). A reimplementation may use different
222       values and a different comparison function. Here is a reimplementation
223       that uses plain Unicode comparison:
224
225               int MyIconViewItem::compare( QIconViewItem *i ) const
226               {
227                   return key().compare( i->key() );
228               }
229
230       See also key(), QString::localeAwareCompare(), and QString::compare().
231

bool QIconViewItem::contains ( const QPoint & pnt ) const

233       Returns TRUE if the item contains the point pnt (in contents
234       coordinates); otherwise returns FALSE.
235

bool QIconViewItem::dragEnabled () const

237       Returns TRUE if the user is allowed to drag the icon view item;
238       otherwise returns FALSE.
239
240       See also setDragEnabled().
241

void QIconViewItem::dragEntered () [virtual protected]

243       This function is called when a drag enters the item's bounding
244       rectangle.
245
246       The default implementation does nothing; subclasses may reimplement
247       this function.
248
249       Example: fileiconview/qfileiconview.cpp.
250

void QIconViewItem::dragLeft () [virtual protected]

252       This function is called when a drag leaves the item's bounding
253       rectangle.
254
255       The default implementation does nothing; subclasses may reimplement
256       this function.
257
258       Example: fileiconview/qfileiconview.cpp.
259

bool QIconViewItem::dropEnabled () const

261       Returns TRUE if the user is allowed to drop something onto the item;
262       otherwise returns FALSE.
263
264       See also setDropEnabled().
265

void QIconViewItem::dropped ( QDropEvent * e, const QValueList<QIconDragItem>

267       & lst ) [virtual protected]
268       This function is called when something is dropped on the item. e
269       provides all the information about the drop. If the drag object of the
270       drop was a QIconDrag, lst contains the list of the dropped items. You
271       can get the data by calling QIconDragItem::data() on each item. If the
272       lst is empty, i.e. the drag was not a QIconDrag, you must decode the
273       data in e and work with that.
274
275       The default implementation does nothing; subclasses may reimplement
276       this function.
277
278       Examples:
279

int QIconViewItem::height () const

281       Returns the height of the item.
282

QIconView * QIconViewItem::iconView () const

284       Returns a pointer to this item's icon view parent.
285

int QIconViewItem::index () const

287       Returns the index of this item in the icon view, or -1 if an error
288       occurred.
289

bool QIconViewItem::intersects ( const QRect & r ) const

291       Returns TRUE if the item intersects the rectangle r (in contents
292       coordinates); otherwise returns FALSE.
293

bool QIconViewItem::isSelectable () const

295       Returns TRUE if the item is selectable; otherwise returns FALSE.
296
297       See also setSelectable().
298

bool QIconViewItem::isSelected () const

300       Returns TRUE if the item is selected; otherwise returns FALSE.
301
302       See also setSelected().
303
304       Example: fileiconview/qfileiconview.cpp.
305

QString QIconViewItem::key () const [virtual]

307       Returns the key of the icon view item or text() if no key has been
308       explicitly set.
309
310       See also setKey() and compare().
311

bool QIconViewItem::move ( int x, int y ) [virtual]

313       Moves the item to position (x, y) in the icon view (these are contents
314       coordinates).
315

bool QIconViewItem::move ( const QPoint & pnt ) [virtual]

317       This is an overloaded member function, provided for convenience. It
318       behaves essentially like the above function.
319
320       Moves the item to the point pnt.
321

void QIconViewItem::moveBy ( int dx, int dy ) [virtual]

323       Moves the item dx pixels in the x-direction and dy pixels in the y-
324       direction.
325

void QIconViewItem::moveBy ( const QPoint & pnt ) [virtual]

327       This is an overloaded member function, provided for convenience. It
328       behaves essentially like the above function.
329
330       Moves the item by the x, y values in point pnt.
331

QIconViewItem * QIconViewItem::nextItem () const

333       Returns a pointer to the next item, or 0 if this is the last item in
334       the icon view.
335
336       To find the first item use QIconView::firstItem().
337
338       Example:
339
340           QIconViewItem *item;
341           for ( item = iconView->firstItem(); item; item = item->nextItem() )
342               do_something_with( item );
343
344       See also prevItem().
345
346       Example: fileiconview/qfileiconview.cpp.
347

void QIconViewItem::paintFocus ( QPainter * p, const QColorGroup & cg )

349       [virtual protected]
350       Paints the focus rectangle of the item using the painter p and the
351       color group cg.
352

void QIconViewItem::paintItem ( QPainter * p, const QColorGroup & cg )

354       [virtual protected]
355       Paints the item using the painter p and the color group cg. If you want
356       the item to be drawn with a different font or color, reimplement this
357       function, change the values of the color group or the painter's font,
358       and then call the QIconViewItem::paintItem() with the changed values.
359
360       Example: fileiconview/qfileiconview.cpp.
361

QPicture * QIconViewItem::picture () const [virtual]

363       Returns the icon of the icon view item if it is a picture, or 0 if it
364       is a pixmap. In the latter case use pixmap() instead. Normally you set
365       the picture of the item with setPicture(), but sometimes it's
366       inconvenient to call setPicture() for every item. So you can subclass
367       QIconViewItem, reimplement this function and return a pointer to the
368       item's picture. If you do this, you must call calcRect() manually each
369       time the size of this picture changes.
370
371       See also setPicture().
372

QPixmap * QIconViewItem::pixmap () const [virtual]

374       Returns the icon of the icon view item if it is a pixmap, or 0 if it is
375       a picture. In the latter case use picture() instead. Normally you set
376       the pixmap of the item with setPixmap(), but sometimes it's
377       inconvenient to call setPixmap() for every item. So you can subclass
378       QIconViewItem, reimplement this function and return a pointer to the
379       item's pixmap. If you do this, you must call calcRect() manually each
380       time the size of this pixmap changes.
381
382       See also setPixmap().
383
384       Example: fileiconview/qfileiconview.cpp.
385

QRect QIconViewItem::pixmapRect ( bool relative = TRUE ) const

387       Returns the bounding rectangle of the item's icon.
388
389       If relative is TRUE, (the default), the rectangle is relative to the
390       origin of the item's rectangle. If relative is FALSE, the returned
391       rectangle is relative to the origin of the icon view's contents
392       coordinate system.
393
394       Example: fileiconview/qfileiconview.cpp.
395

QPoint QIconViewItem::pos () const

397       Returns the position of the item (in contents coordinates).
398

QIconViewItem * QIconViewItem::prevItem () const

400       Returns a pointer to the previous item, or 0 if this is the first item
401       in the icon view.
402
403       See also nextItem() and QIconView::firstItem().
404

QRect QIconViewItem::rect () const

406       Returns the bounding rectangle of the item (in contents coordinates).
407

void QIconViewItem::removeRenameBox () [virtual protected]

409       Removes the editbox that is used for in-place renaming.
410

void QIconViewItem::rename ()

412       Starts in-place renaming of an icon, if allowed.
413
414       This function sets up the icon view so that the user can edit the item
415       text, and then returns. When the user is done, setText() will be called
416       and QIconView::itemRenamed() will be emitted (unless the user canceled,
417       e.g. by pressing the Escape key).
418
419       See also setRenameEnabled().
420
421       Example: fileiconview/qfileiconview.cpp.
422

bool QIconViewItem::renameEnabled () const

424       Returns TRUE if the item can be renamed by the user with in-place
425       renaming; otherwise returns FALSE.
426
427       See also setRenameEnabled().
428
429       Example: fileiconview/qfileiconview.cpp.
430

void QIconViewItem::repaint () [virtual]

432       Repaints the item.
433

int QIconViewItem::rtti () const [virtual]

435       Returns 0.
436
437       Make your derived classes return their own values for rtti(), so that
438       you can distinguish between icon view item types. You should use values
439       greater than 1000, preferably a large random number, to allow for
440       extensions to this class.
441

void QIconViewItem::setDragEnabled ( bool allow ) [virtual]

443       If allow is TRUE, the icon view permits the user to drag the icon view
444       item either to another position within the icon view or to somewhere
445       outside of it. If allow is FALSE, the item cannot be dragged.
446

void QIconViewItem::setDropEnabled ( bool allow ) [virtual]

448       If allow is TRUE, the icon view lets the user drop something on this
449       icon view item.
450

void QIconViewItem::setItemRect ( const QRect & r ) [protected]

452       Sets the bounding rectangle of the whole item to r. This function is
453       provided for subclasses which reimplement calcRect(), so that they can
454       set the calculated rectangle. Any other use is discouraged.
455
456       See also calcRect(), textRect(), setTextRect(), pixmapRect(), and
457       setPixmapRect().
458

void QIconViewItem::setKey ( const QString & k ) [virtual]

460       Sets k as the sort key of the icon view item. By default text() is used
461       for sorting.
462
463       See also compare().
464
465       Example: fileiconview/qfileiconview.cpp.
466

void QIconViewItem::setPicture ( const QPicture & icon ) [virtual]

468       Sets icon as the item's icon in the icon view. This function might be a
469       no-op if you reimplement picture().
470
471       See also picture().
472

void QIconViewItem::setPixmap ( const QPixmap & icon ) [virtual]

474       Sets icon as the item's icon in the icon view. This function might be a
475       no-op if you reimplement pixmap().
476
477       Note: Pixmaps with individual dimensions larger than 300 pixels may not
478       be displayed properly, depending on the arrangement in use. See the
479       main class documentation for details.
480
481       See also pixmap().
482

void QIconViewItem::setPixmap ( const QPixmap & icon, bool recalc, bool redraw

484       = TRUE ) [virtual]
485       This is an overloaded member function, provided for convenience. It
486       behaves essentially like the above function.
487
488       Sets icon as the item's icon in the icon view. If recalc is TRUE, the
489       icon view's layout is recalculated. If redraw is TRUE (the default),
490       the icon view is repainted.
491
492       Note: Pixmaps with individual dimensions larger than 300 pixels may not
493       be displayed properly, depending on the arrangement in use. See the
494       main class documentation for details.
495
496       See also pixmap().
497

void QIconViewItem::setPixmapRect ( const QRect & r ) [protected]

499       Sets the bounding rectangle of the item's icon to r. This function is
500       provided for subclasses which reimplement calcRect(), so that they can
501       set the calculated rectangle. Any other use is discouraged.
502
503       See also calcRect(), pixmapRect(), setItemRect(), and setTextRect().
504

void QIconViewItem::setRenameEnabled ( bool allow ) [virtual]

506       If allow is TRUE, the user can rename the icon view item by clicking on
507       the text (or pressing F2) while the item is selected (in-place
508       renaming). If allow is FALSE, in-place renaming is not possible.
509
510       Examples:
511

void QIconViewItem::setSelectable ( bool enable ) [virtual]

513       Sets this item to be selectable if enable is TRUE (the default) or
514       unselectable if enable is FALSE.
515
516       The user is unable to select a non-selectable item using either the
517       keyboard or the mouse. (The application programmer can select an item
518       in code regardless of this setting.)
519
520       See also isSelectable().
521

void QIconViewItem::setSelected ( bool s, bool cb ) [virtual]

523       Selects or unselects the item, depending on s; it may also unselect
524       other items, depending on QIconView::selectionMode() and cb.
525
526       If s is FALSE, the item is unselected.
527
528       If s is TRUE and QIconView::selectionMode() is Single, the item is
529       selected and the item previously selected is unselected.
530
531       If s is TRUE and QIconView::selectionMode() is Extended, the item is
532       selected. If cb is TRUE, the selection state of the other items is left
533       unchanged. If cb is FALSE (the default) all other items are unselected.
534
535       If s is TRUE and QIconView::selectionMode() is Multi, the item is
536       selected.
537
538       Note that cb is used only if QIconView::selectionMode() is Extended; cb
539       defaults to FALSE.
540
541       All items whose selection status changes repaint themselves.
542
543       Example: fileiconview/qfileiconview.cpp.
544

void QIconViewItem::setSelected ( bool s ) [virtual]

546       This is an overloaded member function, provided for convenience. It
547       behaves essentially like the above function.
548
549       This variant is equivalent to calling the other variant with cb set to
550       FALSE.
551

void QIconViewItem::setText ( const QString & text ) [virtual]

553       Sets text as the text of the icon view item. This function might be a
554       no-op if you reimplement text().
555
556       See also text().
557
558       Example: fileiconview/qfileiconview.cpp.
559

void QIconViewItem::setText ( const QString & text, bool recalc, bool redraw =

561       TRUE ) [virtual]
562       This is an overloaded member function, provided for convenience. It
563       behaves essentially like the above function.
564
565       Sets text as the text of the icon view item. If recalc is TRUE, the
566       icon view's layout is recalculated. If redraw is TRUE (the default),
567       the icon view is repainted.
568
569       See also text().
570

void QIconViewItem::setTextRect ( const QRect & r ) [protected]

572       Sets the bounding rectangle of the item's text to r. This function is
573       provided for subclasses which reimplement calcRect(), so that they can
574       set the calculated rectangle. Any other use is discouraged.
575
576       See also calcRect(), textRect(), setItemRect(), and setPixmapRect().
577

QSize QIconViewItem::size () const

579       Returns the size of the item.
580

QString QIconViewItem::text () const [virtual]

582       Returns the text of the icon view item. Normally you set the text of
583       the item with setText(), but sometimes it's inconvenient to call
584       setText() for every item; so you can subclass QIconViewItem,
585       reimplement this function, and return the text of the item. If you do
586       this, you must call calcRect() manually each time the text (and
587       therefore its size) changes.
588
589       See also setText().
590
591       Example: fileiconview/qfileiconview.cpp.
592

QRect QIconViewItem::textRect ( bool relative = TRUE ) const

594       Returns the bounding rectangle of the item's text.
595
596       If relative is TRUE, (the default), the returned rectangle is relative
597       to the origin of the item's rectangle. If relative is FALSE, the
598       returned rectangle is relative to the origin of the icon view's
599       contents coordinate system.
600
601       Example: fileiconview/qfileiconview.cpp.
602

int QIconViewItem::width () const

604       Returns the width of the item.
605

int QIconViewItem::x () const

607       Returns the x-coordinate of the item (in contents coordinates).
608

int QIconViewItem::y () const

610       Returns the y-coordinate of the item (in contents coordinates).
611
612

SEE ALSO

614       http://doc.trolltech.com/qiconviewitem.html
615       http://www.trolltech.com/faq/tech.html
616
618       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
619       license file included in the distribution for a complete license
620       statement.
621

AUTHOR

623       Generated automatically from the source code.
624

BUGS

626       If you find a bug in Qt, please report it as described in
627       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
628       help you. Thank you.
629
630       The definitive Qt documentation is provided in HTML format; it is
631       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
632       web browser. This man page is provided as a convenience for those users
633       who prefer man pages, although this format is not officially supported
634       by Trolltech.
635
636       If you find errors in this manual page, please report them to qt-
637       bugs@trolltech.com.  Please include the name of the manual page
638       (qiconviewitem.3qt) and the Qt version (3.3.8).
639
640
641
642Trolltech AS                    2 February 2007             QIconViewItem(3qt)
Impressum