The QIconViewItem class implements an iconview item. More...
#include <qiconview.h>
An iconview item is a object containing an icon and a text, which can display itself in an iconview.
The most simple 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 must 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.
Subclassing QIconViewItem will provide a big flexibility.
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 a \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 a \icon as icon, and inserts it into the iconview parent.
[virtual]
Destructs the iconview item and tells the iconview about it.
[virtual]
Returns TRUE, of the item accepts the QMimeSource mime (so it could be dropped on the item), else FALSE is returned.
The default implementation does nothing and returns always TRUE. A subclass should reimplement this to allow dropping something on an item.
[virtual protected]
Recalculates the bounding rect, text- and pixmap-rect of the item.
[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).
Returns TRUE, if the user is allowed to drag the iconview item, 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, subcasses should reimplement this method.
[virtual protected]
This method is called, when a drag left the item's bounding rect.
The default implementation does nothing, subcasses 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 gives you all 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 the iconview of this item.
Returns the index of this item in the iconview, of -1 if something went wrong.
[virtual protected]
Initializes the iconview item and inserts it into the iconview.
Returns TRUE, if the item intersects the rectangle r (in contents coordinates).
Returns TRUE, of the item is selectable, else FALSE.
See also: setSelectable().
Returns TRUE, if the item is selected, 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, the color group cg. If you want, that your iconview item is 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 paintItem() method of the super class with the changed values.
[virtual]
Returns the icon of the iconview item. Normally you will set the pixmap if the item with setPixmap(), but somethimes you don't want that every item stores a copy of a pixmap or that you need to call setPixmap() for each item, so you can reimplement this method and return the pointer to the item pixmap directly here. If you do this you have to call calcRect() manually each time the size of this pixmap changes!
See also: setPixmap().
Returns the rectangle of the icon of the item. If relative is FALSE, the returned rectangle is relative to the origin of the contents' coordinate system, else 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]
Removed the editbox which was used for in-place renaming.
Starts renaming an icon.
Returns TRUE, if the item can be renamed ny the user with in-place renaming, 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, no dragging is possible with this item.
[virtual]
If allow is TRUE, the iconview lets the use 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 calcualted 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. Using recalc you can specify, if the iconview should be recalculated and using redraw if it should be repainted or not.
This method might be a no-op if you reimplement pixmap().
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 calcualted rectangle.
[virtual]
If \allow is TRUE, the user can rename the iconview item, when clicking on the text after the item has been selected (in-place renaming). If allow is FALSE, no inplace-renaming is done.
Examples: iconview/main.cpp
[virtual]
If s is TRUE, this item can be selected, else it can't be selected.
[virtual]
Selects / Unselects the item depending on the QIconView::selectionMode() of the iconview.
The item redraws itself if the selection changed.
[virtual]
Selects / Unselects the item depending on the QIconView::selectionMode() of the iconview.
If s is FALSE, the item gets unselected. If s is TRUE
The item redraws itself if the selection changed.
[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. Using recalc you can specify, if the iconview should be recalculated and using redraw if it should be repainted or not.
This method might be a no-op if you reimplement text().
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 calcualted rectangle.
[protected]
Sets the iconview of the item ot v. Normally you should not make use of this methode, only if you really know what you are doing!.
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 somethimes you don't want to call setText/) for each item, so you can reimplement this method and return the text of the item directly here. 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 rectangle of the text of the item. If relative is FALSE, the returned rectangle is relative to the origin of the contents' coordinate system, else 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.troll.no):
This file is part of the Qt toolkit, copyright © 1995-2000 Troll Tech, all rights reserved.
Copyright İ 2000 Troll Tech | Trademarks | Qt version 2.1.0-beta1
|