QIconViewItem Class Reference
[ iconview module ]
The QIconViewItem class implements an iconview item.
More...
#include <qiconview.h>
Inherits Qt.
List of all member functions.
Public Members
-
QIconViewItem ( QIconView * parent, QIconViewItem * after )Â
QIconViewItem ( QIconView * parent, const QString & text )Â
QIconViewItem ( QIconView * parent, QIconViewItem * after, const QString & text )Â
QIconViewItem ( QIconView * parent, const QString & text, const QPixmap & icon )Â
QIconViewItem ( QIconView * parent, QIconViewItem * after, const QString & text, const QPixmap & icon )Â
-
-
-
-
virtual QStringÂ
text () const
virtual QPixmap*Â
pixmap () const
virtual QStringÂ
key () const
-
-
-
-
-
-
-
-
-
-
-
-
-
virtual voidÂ
move ( int x, int y )Â
virtual voidÂ
moveBy ( int dx, int dy )Â
virtual voidÂ
move ( const QPoint & pnt )Â
virtual voidÂ
moveBy ( const QPoint & pnt )Â
-
-
-
-
-
-
-
QRectÂ
textRect ( bool relative = TRUE ) const
QRectÂ
pixmapRect ( bool relative = TRUE ) const
boolÂ
contains ( QPoint pnt ) const
-
virtual boolÂ
acceptDrop ( const QMimeSource * mime ) const
-
virtual intÂ
compare ( QIconViewItem * i ) const
virtual voidÂ
setText ( const QString & text )Â
virtual voidÂ
setPixmap ( const QPixmap & icon )Â
virtual voidÂ
setText ( const QString & text, bool recalc, bool redraw = TRUE )Â
virtual voidÂ
setPixmap ( const QPixmap & icon, bool recalc, bool redraw = TRUE )Â
virtual voidÂ
setKey ( const QString & k )Â
Protected Members
Detailed Description
The QIconViewItem class implements an iconview item.
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
Member Function Documentation
QIconViewItem::QIconViewItem ( QIconView * parent )
Constructs an iconview item with no text and a default icon, and
inserts it into the iconview parent.
QIconViewItem::QIconViewItem ( QIconView * parent, QIconViewItem * after )
Constructs an iconview item with no text and a default icon, and inserts
it into the iconview parent after the iconview item after.
QIconViewItem::QIconViewItem ( QIconView * parent, QIconViewItem * after, const QString & text )
Constructs an iconview item using text as text and a default icon, and
inserts it into the iconview parent after the iconview item after.
QIconViewItem::QIconViewItem ( QIconView * parent, QIconViewItem * after, const QString & text, const QPixmap & icon )
Constructs an iconview item using text as text and icon as icon,
and inserts it into the iconview parent after the iconview item after.
QIconViewItem::QIconViewItem ( QIconView * parent, const QString & text )
Constructs an iconview item using text as text and a default icon,
and inserts it into the iconview parent.
QIconViewItem::QIconViewItem ( QIconView * parent, const QString & text, const QPixmap & icon )
Constructs an iconview item using text as text and icon as icon,
and inserts it into the iconview parent.
QIconViewItem::~QIconViewItem () [virtual]
Destructs the iconview item and tells the iconview about it.
bool QIconViewItem::acceptDrop ( const QMimeSource * mime ) const [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.
void QIconViewItem::calcRect ( const QString & text_ = QString::null ) [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.
int QIconViewItem::compare ( QIconViewItem * i ) const [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().
bool QIconViewItem::contains ( QPoint pnt ) const
Returns TRUE if the item contains the point pnt (in contents
coordinates), and FALSE if it does not.
bool QIconViewItem::dragEnabled () const
Returns TRUE if the user is allowed to drag the iconview item, or else
FALSE.
See also setDragEnabled().
void QIconViewItem::dragEntered () [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.
void QIconViewItem::dragLeft () [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.
bool QIconViewItem::dropEnabled () const
Returns TRUE if the user is allowed to drop something onto the item,
otherwise FALSE.
See also setDropEnabled().
void QIconViewItem::dropped ( QDropEvent * e, const QValueList<QIconDragItem> & lst ) [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.
int QIconViewItem::height () const
Returns the height of the item.
QIconView * QIconViewItem::iconView () const
Returns a pointer to this items' iconview parent.
int QIconViewItem::index () const
Returns the index of this item in the iconview, or -1 if an error occurred.
bool QIconViewItem::intersects ( QRect r ) const
Returns TRUE, if the item intersects the rectangle r (in contents
coordinates), and FALSE if it does not.
bool QIconViewItem::isSelectable () const
Returns TRUE if the item is selectable, or else FALSE.
See also setSelectable().
bool QIconViewItem::isSelected () const
Returns TRUE if the item is selected, or else FALSE.
See also setSelected().
QString QIconViewItem::key () const [virtual]
Returns the key of the iconview item.
See also setKey() and compareItems().
void QIconViewItem::move ( int x, int y ) [virtual]
Moves the item to x and y in the iconview (these are contents
coordinates).
void QIconViewItem::move ( const QPoint & pnt ) [virtual]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void QIconViewItem::moveBy ( int dx, int dy ) [virtual]
Moves the item by the distance dx and dy.
void QIconViewItem::moveBy ( const QPoint & pnt ) [virtual]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
QIconViewItem * QIconViewItem::nextItem () const
Returns a pointer to the next item, or 0 if this is the last item
of the iconview.
void QIconViewItem::paintFocus ( QPainter * p, const QColorGroup & cg ) [virtual protected]
Paints the focus rect of the item using the painter p and the color group cg.
void QIconViewItem::paintItem ( QPainter * p, const QColorGroup & 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.
QPixmap * QIconViewItem::pixmap () const [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().
QRect QIconViewItem::pixmapRect ( bool relative = TRUE ) const
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.
QPoint QIconViewItem::pos () const
Returns the position of the item (in contents coordinates).
QIconViewItem * QIconViewItem::prevItem () const
Returns a pointer to the previous item, or 0 if this is the first item
of the iconview.
QRect QIconViewItem::rect () const
Returns the bounding rect of the item (in contents coordinates).
void QIconViewItem::removeRenameBox () [virtual protected]
Removes the editbox which is used for in-place renaming.
void QIconViewItem::rename ()
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.
bool QIconViewItem::renameEnabled () const
Returns TRUE if the item can be renamed by the user with in-place
renaming, or else FALSE.
See also setRenameEnabled().
void QIconViewItem::repaint () [virtual]
Repaints the item.
void QIconViewItem::setDragEnabled ( bool allow ) [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.
void QIconViewItem::setDropEnabled ( bool allow ) [virtual]
If allow is TRUE, the iconview lets the user drop something on
this iconview item.
void QIconViewItem::setItemRect ( const QRect & r ) [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.
void QIconViewItem::setKey ( const QString & k ) [virtual]
Sets k as key of the iconview item. This is used for sorting.
See also compareItems().
void QIconViewItem::setPixmap ( const QPixmap & icon ) [virtual]
Sets icon as item icon of the iconview item. This method might be
a no-op if you reimplement pixmap().
See also pixmap().
void QIconViewItem::setPixmap ( const QPixmap & icon, bool recalc, bool redraw = TRUE ) [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().
void QIconViewItem::setPixmapRect ( const QRect & r ) [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.
void QIconViewItem::setRenameEnabled ( bool allow ) [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
void QIconViewItem::setSelectable ( bool enable ) [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().
void QIconViewItem::setSelected ( bool s, bool cb ) [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.
void QIconViewItem::setSelected ( bool s ) [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.
void QIconViewItem::setText ( const QString & text ) [virtual]
Sets text as text of the iconview item. This method might be a no-op
if you reimplement text().
See also text().
void QIconViewItem::setText ( const QString & text, bool recalc, bool redraw = TRUE ) [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().
void QIconViewItem::setTextRect ( const QRect & r ) [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.
QSize QIconViewItem::size () const
Returns the size of the item.
QString QIconViewItem::text () const [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().
QRect QIconViewItem::textRect ( bool relative = TRUE ) const
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.
int QIconViewItem::width () const
Returns the width of the item.
int QIconViewItem::x () const
Returns the X-Coordinate of the item (in contents coordinates).
int QIconViewItem::y () const
Returns the Y-Coordinate of the item (in contents coordinates).
void QIconViewItem::calcTmpText () [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-2005
Trolltech, all rights reserved.