QIconViewItem - Implements an iconview item
#include <qiconview.h>
Inherits Qt.
Public Members
QIconViewItem ( QIconView * parent )
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 ~QIconViewItem ()
virtual void setRenameEnabled ( bool allow )
virtual void setDragEnabled ( bool allow )
virtual void setDropEnabled ( bool allow )
virtual QString text () const
virtual QPixmap* pixmap () const
virtual QString key () const
bool renameEnabled () const
bool dragEnabled () const
bool dropEnabled () const
QIconView* iconView () const
QIconViewItem* prevItem () const
QIconViewItem* nextItem () const
int index () const
virtual void setSelected ( bool s, bool cb )
virtual void setSelected ( bool s )
virtual void setSelectable ( bool s )
bool isSelected () const
bool isSelectable () const
virtual void repaint ()
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 rect () const
int x () const
int y () const
int width () const
int height () const
QSize size () const
QPoint pos () const
QRect textRect ( bool relative = TRUE ) const
QRect pixmapRect ( bool relative = TRUE ) const
bool contains ( QPoint pnt ) const
bool intersects ( QRect r ) const
void rename ()
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
virtual void removeRenameBox ()
virtual void calcRect ( const QString & text_ =
QString::null )
virtual void paintItem ( QPainter * p, const QColorGroup &
cg )
virtual void paintFocus ( QPainter * p, const QColorGroup
& cg )
virtual void dropped ( QDropEvent * e, const
QValueList<QIconDragItem> & lst )
virtual void dragEntered ()
virtual void dragLeft ()
void setItemRect ( const QRect & r )
void setTextRect ( const QRect & r )
void setPixmapRect ( const QRect & r )
void calcTmpText () (internal)
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 );
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.
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]
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.
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).
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().
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
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).
For internal use only.
SEE ALSO
http://doc.trolltech.com/qiconviewitem.html
http://www.trolltech.com/faq/tech.html
COPYRIGHT
Copyright 1992-2001 Trolltech AS,
http://www.trolltech.com. See the license file included
in the distribution for a complete license statement.
AUTHOR
Generated automatically from the source code.
BUGS
If you find a bug in Qt, please report it as described in
http://doc.trolltech.com/bughowto.html. Good bug reports
make our job much simpler. Thank you.
In case of content or formattting problems with this
manual page, please report them to qt-bugs@trolltech.com.
Please include the name of the manual page
(qiconviewitem.3qt) and the Qt version (2.3.1).
Man(1) output converted with
man2html