The QIconViewItem class implements an iconview item. More...
#include <qiconview.h>
Inherits Qt.
An iconview item is a object containing an icon and a text, which can display itself in an iconview.
The simplest way to create an iconview item and insert it into an iconview is to construct it with a pointer to the iconview, a string and an icon:
// parent is a pointer to our iconview, pixmap a QPixmap, // which we want to use as icon (void) new QIconViewItem( parent, "This is the text of the item", pixmap );
When the iconview is deleted, all items of it are deleted automatically, so the programmer need not delete the iconview items itself.
To iterate over all items of an iconview do something like
QIconViewItem *item; for ( item = iconview->firstItem(); item; item = item->nextItem() ) do_something_with( item );
To remove an item from an iconview, just delete the item. The destructor of the QIconViewItem does all the work for removing it from the iconview.
As the iconview is designed to use DnD, the iconview item has methods for DnD too which may be reimplemented.
The class is designed to be very similar to QListView and QListBox in use, both via instantiation and subclassing.
Examples: iconview/main.cpp
Constructs an iconview item with no text and a default icon, and inserts it into the iconview parent.
Constructs an iconview item with no text and a default icon, and inserts it into the iconview parent after the iconview item after.
Constructs an iconview item using text as text and a default icon, and inserts it into the iconview parent after the iconview item after.
Constructs an iconview item using text as text and icon as icon, and inserts it into the iconview parent after the iconview item after.
Constructs an iconview item using text as text and a default icon, and inserts it into the iconview parent.
Constructs an iconview item using text as text and icon as icon, and inserts it into the iconview parent.
[virtual]
Destructs the iconview item and tells the iconview about it.
[virtual]
Returns TRUE if the item accepts the QMimeSource mime (so it could be dropped on the item), and FALSE if it does not.
The default implementation does nothing and returns always TRUE. A subclass must reimplement this to accept drops.
[virtual protected]
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.
[virtual]
Compares this iconview item to i. Returns -1 if this item is less than i, 0 if they are equal and 1 if this iconview item is greater than i.
The default implementation uses QIconViewItem::key() to compare the items. A reimplementation may use different values.
See also key().
Returns TRUE if the item contains the point pnt (in contents coordinates), and FALSE if it does not.
Returns TRUE if the user is allowed to drag the iconview item, or else FALSE.
See also setDragEnabled().
[virtual protected]
This method is called, when a drag entered the item's bounding rect.
The default implementation does nothing, subclasses should reimplement this method.
[virtual protected]
This method is called, when a drag left the item's bounding rect.
The default implementation does nothing, subclasses should reimplement this method.
Returns TRUE if the user is allowed to drop something onto the item, otherwise FALSE.
See also setDropEnabled().
[virtual protected]
This method is called when something was dropped on the item. e contains all the information about the drop. If the drag object of the drop was a QIconDrag, lst contains the list of the dropped items. You can get the data using QIconDragItem::data() of each item then.
So if lst is not empty, use this data for further operations, else the drag was not a QIconDrag, so you have to decode e yourself and work with that.
The default implementation does nothing, subclasses should reimplement this method.
Returns the height of the item.
Returns a pointer to this items' iconview parent.
Returns the index of this item in the iconview, or -1 if an error occurred.
Returns TRUE, if the item intersects the rectangle r (in contents coordinates), and FALSE if it does not.
Returns TRUE if the item is selectable, or else FALSE.
See also setSelectable().
Returns TRUE if the item is selected, or else FALSE.
See also setSelected().
[virtual]
Returns the key of the iconview item.
See also setKey() and compareItems().
[virtual]
Moves the item to x and y in the iconview (these are contents coordinates).
[virtual]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[virtual]
Moves the item by the distance dx and dy.
[virtual]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a pointer to the next item, or 0 if this is the last item of the iconview.
[virtual protected]
Paints the focus rect of the item using the painter p and the color group cg.
[virtual protected]
Paints the item using the painter p and the color group cg. If you want the item to be drawn with a different font or color, reimplement this method and change the values of the color group or the painter's font, and call then the QIconViewItem::paintItem() with the changed values.
[virtual]
Returns the icon of the iconview item. Normally you will set the pixmap if the item with setPixmap(), but sometimes it's inconvenient to call setText() for each item, so you can subclass QIconViewItem, reimplement this method and return a pointer to the item's pixmap. If you do this you have to call calcRect() manually each time the size of this pixmap changes!
See also setPixmap().
Returns the bounding rectangle of the item's icon.
If relative is FALSE the returned rectangle is relative to the origin of the iconview's contents coordinate system. If relative is TRUE the rectangle is relative to the origin of the item's rectangle.
Returns the position of the item (in contents coordinates).
Returns a pointer to the previous item, or 0 if this is the first item of the iconview.
Returns the bounding rect of the item (in contents coordinates).
[virtual protected]
Removes the editbox which is used for in-place renaming.
Starts in-place renaming an icon, if allowed.
This function sets the icon view up so that the user can edit the item text, and then returns. When the user is done, setText() will be called and QIconView::itemRenamed() be emitted.
Returns TRUE if the item can be renamed by the user with in-place renaming, or else FALSE.
See also setRenameEnabled().
[virtual]
Repaints the item.
[virtual]
If allow is TRUE, the iconview lets the user to drag the iconview item (inside the iconview and outside of it). if allow is FALSE, the item cannot be dragged.
[virtual]
If allow is TRUE, the iconview lets the user drop something on this iconview item.
[protected]
Sets the bounding rectangle of the whole item. This should be only used in subclasses, which reimplement calcRect() to be able to set the calculated rectangle.
[virtual]
Sets k as key of the iconview item. This is used for sorting.
See also compareItems().
[virtual]
Sets icon as item icon of the iconview item. This method might be a no-op if you reimplement pixmap().
See also pixmap().
[virtual]
Sets icon as item icon of the iconview item. If recalc is TRUE, the iconview's layout is recalculated. If redraw is TRUE (the default), the icon view is repainted.
See also pixmap().
[protected]
Sets the bounding rectangle of the item icon. This should be only used in subclasses, which reimplement calcRect() to be able to set the calculated rectangle.
[virtual]
If allow is TRUE, the user can rename the iconview item by clicking on the text while the item is selected (in-place renaming). If allow is FALSE, in-place renaming is not possible.
Examples: iconview/main.cpp
[virtual]
Sets this items to be selectable if enable is TRUE (the default) or not to be selectable if enable is FALSE.
The user is not able to select a non-selectable item using either the keyboard or mouse. The application programmer still can, of course.
See also isSelectable().
[virtual]
Selects or unselects the item depending on s, and may also unselect other items, depending on QIconView::selectionMode() and cb.
If s is FALSE, the item is unselected.
If s is TRUE and QIconView::selectionMode() is Single,
the item
is selected, and the item which was selected is unselected.
If s is TRUE and QIconView::selectionMode() is Extended,
the item
is selected. If cb is TRUE, the other items of the iconview are
not touched. If cb is FALSE all other items are unselected.
If s is TRUE and QIconView::selectionMode() is Multi
the item
is selected.
Note that cb is used only if QIconView::selectionMode() is Extended.
All items whose selection status change repaint themselves.
[virtual]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This variant is equivalent to calling the other variant with cb set to FALSE.
[virtual]
Sets text as text of the iconview item. This method might be a no-op if you reimplement text().
See also text().
[virtual]
Sets text as text of the iconview item. If recalc is TRUE, the iconview's layout is recalculated. If redraw is TRUE (the default), the icon view is repainted.
See also text().
[protected]
Sets the bounding rectangle of the item text. This should be only used in subclasses, which reimplement calcRect() to be able to set the calculated rectangle.
Returns the size of the item.
[virtual]
Returns the text of the iconview item. Normally you will set the text if the item with setText(), but sometimes it's inconvenient to call setText() for each item, so you can subclass QIconViewItem, reimplement this method and return the text of the item. If you do this you have to call calcRect() manually each time the text (and so the size of it) changes.
See also setText().
Returns the bounding rectangle of the item's text.
If relative is FALSE the returned rectangle is relative to the origin of the iconview's contents coordinate system. If relative is TRUE the rectangle is relative to the origin of the item's rectangle.
Returns the width of the item.
Returns the X-Coordinate of the item (in contents coordinates).
Returns the Y-Coordinate of the item (in contents coordinates).
[protected]
For internal use only.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright İ 2000 Trolltech | Trademarks | Qt version 2.2.1
|