A TQIconViewItem contains an icon, a string and optionally a sort key, and can display itself in a TQIconView. The class is designed to be very similar to QListView and QListBox in use, both via instantiation and subclassing.
The simplest way to create a TQIconViewItem and insert it into a TQIconView is to construct the item passing the constructor a pointer to the icon view, a string and an icon:
By default the text of an icon view item may not be edited by the user but calling setRenameEnabled(TRUE) will allow the user to perform in-place editing of the item's text.
.PP
When the icon view is deleted all items in it are deleted automatically.
for ( item = iconView->firstItem(); item; item = item->nextItem() )
.br
do_something_with( item );
.br
.fi
.PP
The item's icon view is available from iconView(), and its position in the icon view from index().
.PP
The item's selection status is available from isSelected() and is set and controlled by setSelected() and isSelectable().
.PP
The text and icon can be set with setText() and setPixmap() and retrieved with text() and pixmap(). The item's sort key defaults to text() but may be set with setKey() and retrieved with key(). The comparison function, compare() uses key().
.PP
Items may be repositioned with move() and moveBy(). An item's geometry is available from rect(), x(), y(), width(), height(), size(), pos(), textRect() and pixmapRect(). You can also test against the position of a point with contains() and intersects().
\fBNote:\fR Pixmaps with individual dimensions larger than 300 pixels may not be displayed properly, depending on the arrangement in use. For example, pixmaps wider than 300 pixels will not be arranged correctly if the icon view uses a TQIconView::TopToBottom arrangement, and pixmaps taller than 300 pixels will not be arranged correctly if the icon view uses a TQIconView::LeftToRight arrangement.
Constructs an icon view item and inserts it into the icon view \fIparent\fR using \fItext\fR as the text and a default icon, after the icon view item \fIafter\fR.
Constructs an icon view item and inserts it into the icon view \fIparent\fR using \fItext\fR as the text and \fIicon\fR as the icon, after the icon view item \fIafter\fR.
Constructs an icon view item and inserts it into the icon view \fIparent\fR using \fItext\fR as the text and \fIpicture\fR as the icon, after the icon view item \fIafter\fR.
This virtual function is responsible for calculating the rectangles returned by rect(), textRect() and pixmapRect(). setRect(), setTextRect() and setPixmapRect() are provided mainly for reimplementations of this function.
Compares this icon view item to \fIi\fR. Returns -1 if this item is less than \fIi\fR, 0 if they are equal, and 1 if this icon view item is greater than \fIi\fR.
The default implementation compares the item keys (key()) using TQString::localeAwareCompare(). A reimplementation may use different values and a different comparison function. Here is a reimplementation that uses plain Unicode comparison:
This function is called when something is dropped on the item. \fIe\fR provides all the information about the drop. If the drag object of the drop was a TQIconDrag, \fIlst\fR contains the list of the dropped items. You can get the data by calling TQIconDragItem::data() on each item. If the \fIlst\fR is empty, i.e. the drag was not a TQIconDrag, you must decode the data in \fIe\fR and work with that.
Paints the item using the painter \fIp\fR and the color group \fIcg\fR. If you want the item to be drawn with a different font or color, reimplement this function, change the values of the color group or the painter's font, and then call the TQIconViewItem::paintItem() with the changed values.
Returns the icon of the icon view item if it is a picture, or 0 if it is a pixmap. In the latter case use pixmap() instead. Normally you set the picture of the item with setPicture(), but sometimes it's inconvenient to call setPicture() for every item. So you can subclass TQIconViewItem, reimplement this function and return a pointer to the item's picture. If you do this, you \fImust\fR call calcRect() manually each time the size of this picture changes.
Returns the icon of the icon view item if it is a pixmap, or 0 if it is a picture. In the latter case use picture() instead. Normally you set the pixmap of the item with setPixmap(), but sometimes it's inconvenient to call setPixmap() for every item. So you can subclass TQIconViewItem, reimplement this function and return a pointer to the item's pixmap. If you do this, you \fImust\fR call calcRect() manually each time the size of this pixmap changes.
Returns the bounding rectangle of the item's icon.
.PP
If \fIrelative\fR is TRUE, (the default), the rectangle is relative to the origin of the item's rectangle. If \fIrelative\fR is FALSE, the returned rectangle is relative to the origin of the icon view's contents coordinate system.
This function sets up the icon view so that the user can edit the item text, and then returns. When the user is done, setText() will be called and TQIconView::itemRenamed() will be emitted (unless the user canceled, e.g. by pressing the Escape key).
Make your derived classes return their own values for rtti(), so that you can distinguish between icon view item types. You should use values greater than 1000, preferably a large random number, to allow for extensions to this class.
If \fIallow\fR is TRUE, the icon view permits the user to drag the icon view item either to another position within the icon view or to somewhere outside of it. If \fIallow\fR is FALSE, the item cannot be dragged.
Sets the bounding rectangle of the whole item to \fIr\fR. This function is provided for subclasses which reimplement calcRect(), so that they can set the calculated rectangle. \fIAny other use is discouraged.\fR
.PP
See also calcRect(), textRect(), setTextRect(), pixmapRect(), and setPixmapRect().
Sets \fIicon\fR as the item's icon in the icon view. This function might be a no-op if you reimplement pixmap().
.PP
\fBNote:\fR Pixmaps with individual dimensions larger than 300 pixels may not be displayed properly, depending on the arrangement in use. See the main class documentation for details.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets \fIicon\fR as the item's icon in the icon view. If \fIrecalc\fR is TRUE, the icon view's layout is recalculated. If \fIredraw\fR is TRUE (the default), the icon view is repainted.
.PP
\fBNote:\fR Pixmaps with individual dimensions larger than 300 pixels may not be displayed properly, depending on the arrangement in use. See the main class documentation for details.
Sets the bounding rectangle of the item's icon to \fIr\fR. This function is provided for subclasses which reimplement calcRect(), so that they can set the calculated rectangle. \fIAny other use is discouraged.\fR
.PP
See also calcRect(), pixmapRect(), setItemRect(), and setTextRect().
If \fIallow\fR is TRUE, the user can rename the icon view item by clicking on the text (or pressing F2) while the item is selected (in-place renaming). If \fIallow\fR is FALSE, in-place renaming is not possible.
.PP
Examples:
.)l fileiconview/qfileiconview.cpp, iconview/main.cpp, and iconview/simple_dd/main.cpp.
Sets this item to be selectable if \fIenable\fR is TRUE (the default) or unselectable if \fIenable\fR is FALSE.
.PP
The user is unable to select a non-selectable item using either the keyboard or the mouse. (The application programmer can select an item in code regardless of this setting.)
If \fIs\fR is TRUE and TQIconView::selectionMode() is \fCExtended\fR, the item is selected. If \fIcb\fR is TRUE, the selection state of the other items is left unchanged. If \fIcb\fR is FALSE (the default) all other items are unselected.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets \fItext\fR as the text of the icon view item. If \fIrecalc\fR is TRUE, the icon view's layout is recalculated. If \fIredraw\fR is TRUE (the default), the icon view is repainted.
Sets the bounding rectangle of the item's text to \fIr\fR. This function is provided for subclasses which reimplement calcRect(), so that they can set the calculated rectangle. \fIAny other use is discouraged.\fR
.PP
See also calcRect(), textRect(), setItemRect(), and setPixmapRect().
Returns the text of the icon view item. Normally you set the text of the item with setText(), but sometimes it's inconvenient to call setText() for every item; so you can subclass TQIconViewItem, reimplement this function, and return the text of the item. If you do this, you must call calcRect() manually each time the text (and therefore its size) changes.
Returns the bounding rectangle of the item's text.
.PP
If \fIrelative\fR is TRUE, (the default), the returned rectangle is relative to the origin of the item's rectangle. If \fIrelative\fR is FALSE, the returned rectangle is relative to the origin of the icon view's contents coordinate system.