Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

TQIconView Class Reference
[iconview module]

The TQIconView class provides an area with movable labelled icons. More...

#include <tqiconview.h>

Inherits TQScrollView.

List of all member functions.

Public Members

Public Slots

Signals

Properties

Protected Members

Protected Slots


Detailed Description

The TQIconView class provides an area with movable labelled icons.

A TQIconView can display and manage a grid or other 2D layout of labelled icons. Each labelled icon is a TQIconViewItem. Items (TQIconViewItems) can be added or deleted at any time; items can be moved within the TQIconView. Single or multiple items can be selected. Items can be renamed in-place. TQIconView also supports drag and drop.

Each item contains a label string, a pixmap or picture (the icon itself) and optionally a sort key. The sort key is used for sorting the items and defaults to the label string. The label string can be displayed below or to the right of the icon (see ItemTextPos).

The simplest way to create a TQIconView is to create a TQIconView object and create some TQIconViewItems with the TQIconView as their parent, set the icon view's geometry and show it. For example:

    TQIconView *iv = new TQIconView( this );
    TQDir dir( path, "*.xpm" );
    for ( uint i = 0; i < dir.count(); i++ ) {
        (void) new TQIconViewItem( iv, dir[i], TQPixmap( path + dir[i] ) );
    }
    iv->resize( 600, 400 );
    iv->show();
    

The TQIconViewItem call passes a pointer to the TQIconView we wish to populate, along with the label text and a TQPixmap.

When an item is inserted the TQIconView allocates a position for it. Existing items are rearranged if autoArrange() is TRUE. The default arrangement is LeftToRight -- the TQIconView fills up the left-most column from top to bottom, then moves one column right and fills that from top to bottom and so on. The arrangement can be modified with any of the following approaches:

The spacing between items is set with setSpacing(). Items can be laid out using a fixed grid using setGridX() and setGridY(); by default the TQIconView calculates a grid dynamically. The position of items' label text is set with setItemTextPos(). The text's background can be set with setItemTextBackground(). The maximum width of an item and of its text are set with setMaxItemWidth() and setMaxItemTextLength(). The label text will be word-wrapped if it is too long; this is controlled by setWordWrapIconText(). If the label text is truncated, the user can still see the entire text in a tool tip if they hover the mouse over the item. This is controlled with setShowToolTips().

Items which are selectable may be selected depending on the SelectionMode; the default is Single. Because TQIconView offers multiple selection it must display keyboard focus and selection state separately. Therefore there are functions to set the selection state of an item (setSelected()) and to select which item displays keyboard focus (setCurrentItem()). When multiple items may be selected the icon view provides a rubberband, too.

When in-place renaming is enabled (it is disabled by default), the user may change the item's label. They do this by selecting the item (single clicking it or navigating to it with the arrow keys), then single clicking it (or pressing F2), and entering their text. If no key has been set with TQIconViewItem::setKey() the new text will also serve as the key. (See TQIconViewItem::setRenameEnabled().)

You can control whether users can move items themselves with setItemsMovable().

Because the internal structure used to store the icon view items is linear, no iterator class is needed to iterate over all the items. Instead we iterate by getting the first item from the icon view and then each subsequent (TQIconViewItem::nextItem()) from each item in turn:

        for ( TQIconViewItem *item = iv->firstItem(); item; item = item->nextItem() )
            do_something( item );
    
TQIconView also provides currentItem(). You can search for an item using findItem() (searching by position or for label text) and with findFirstVisibleItem() and findLastVisibleItem(). The number of items is returned by count(). An item can be removed from an icon view using takeItem(); to delete an item use delete. All the items can be deleted with clear().

The TQIconView emits a wide range of useful signals, including selectionChanged(), currentChanged(), clicked(), moved() and itemRenamed().

Drag and Drop

TQIconView supports the drag and drop of items within the TQIconView itself. It also supports the drag and drop of items out of or into the TQIconView and drag and drop onto items themselves. The drag and drop of items outside the TQIconView can be achieved in a simple way with basic functionality, or in a more sophisticated way which provides more power and control.

The simple approach to dragging items out of the icon view is to subclass TQIconView and reimplement TQIconView::dragObject().

    TQDragObject *MyIconView::dragObject()
    {
        return new TQTextDrag( currentItem()->text(), this );
    }
    

In this example we create a TQTextDrag object, (derived from TQDragObject), containing the item's label and return it as the drag object. We could just as easily have created a TQImageDrag from the item's pixmap and returned that instead.

TQIconViews and their TQIconViewItems can also be the targets of drag and drops. To make the TQIconView itself able to accept drops connect to the dropped() signal. When a drop occurs this signal will be emitted with a TQDragEvent and a TQValueList of TQIconDragItems. To make a TQIconViewItem into a drop target subclass TQIconViewItem and reimplement TQIconViewItem::acceptDrop() and TQIconViewItem::dropped().

    bool MyIconViewItem::acceptDrop( const TQMimeSource *mime ) const
    {
        if ( mime->provides( "text/plain" ) )
            return TRUE;
        return FALSE;
    }

    void MyIconViewItem::dropped( TQDropEvent *evt, const TQValueList<TQIconDragItem>& )
    {
        TQString label;
        if ( TQTextDrag::decode( evt, label ) )
            setText( label );
    }
    

See iconview/simple_dd/main.h and iconview/simple_dd/main.cpp for a simple drag and drop example which demonstrates drag and drop between a TQIconView and a TQListBox.

If you want to use extended drag-and-drop or have drag shapes drawn you must take a more sophisticated approach.

The first part is starting drags -- you should use a TQIconDrag (or a class derived from it) for the drag object. In dragObject() create the drag object, populate it with TQIconDragItems and return it. Normally such a drag should offer each selected item's data. So in dragObject() you should iterate over all the items, and create a TQIconDragItem for each selected item, and append these items with TQIconDrag::append() to the TQIconDrag object. You can use TQIconDragItem::setData() to set the data of each item that should be dragged. If you want to offer the data in additional mime-types, it's best to use a class derived from TQIconDrag, which implements additional encoding and decoding functions.

When a drag enters the icon view, there is little to do. Simply connect to the dropped() signal and reimplement TQIconViewItem::acceptDrop() and TQIconViewItem::dropped(). If you've used a TQIconDrag (or a subclass of it) the second argument to the dropped signal contains a TQValueList of TQIconDragItems -- you can access their data by calling TQIconDragItem::data() on each one.

For an example implementation of complex drag-and-drop look at the fileiconview example (qt/examples/fileiconview).

See also TQIconViewItem::setDragEnabled(), TQIconViewItem::setDropEnabled(), TQIconViewItem::acceptDrop(), TQIconViewItem::dropped(), and Advanced Widgets.


Member Type Documentation

TQIconView::Arrangement

This enum type determines in which direction the items flow when the view runs out of space.

TQIconView::ItemTextPos

This enum type specifies the position of the item text in relation to the icon.

TQIconView::ResizeMode

This enum type is used to tell TQIconView how it should treat the positions of its icons when the widget is resized. The modes are:

TQIconView::SelectionMode

This enumerated type is used by TQIconView to indicate how it reacts to selection by the user. It has four values:

To summarise: Single is a real single-selection icon view; Multi a real multi-selection icon view; Extended is an icon view in which users can select multiple items but usually want to select either just one or a range of contiguous items; and NoSelection mode is for an icon view where the user can look but not touch.


Member Function Documentation

TQIconView::TQIconView ( TQWidget * parent = 0, const char * name = 0, WFlags f = 0 )

Constructs an empty icon view called name, with parent parent and using the widget flags f.

TQIconView::~TQIconView () [virtual]

Destroys the icon view and deletes all items.

void TQIconView::adjustItems () [virtual protected slot]

Adjusts the positions of the items to the geometry of the icon view.

void TQIconView::arrangeItemsInGrid ( const TQSize & grid, bool update = TRUE ) [virtual slot]

This variant uses grid instead of (gridX(), gridY()). If grid is invalid (see TQSize::isValid()), arrangeItemsInGrid() calculates a valid grid itself and uses that.

If update is TRUE (the default) the viewport is repainted.

Example: fileiconview/qfileiconview.h.

void TQIconView::arrangeItemsInGrid ( bool update = TRUE ) [virtual slot]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Arranges all the items in the grid given by gridX() and gridY().

Even if sorting() is enabled, the items are not sorted by this function. If you want to sort or rearrange the items, use iconview->sort(iconview->sortDirection()).

If update is TRUE (the default), the viewport is repainted as well.

See also TQIconView::gridX, TQIconView::gridY, and TQIconView::sort().

Arrangement TQIconView::arrangement () const

Returns the arrangement mode of the icon view. See the "arrangement" property for details.

bool TQIconView::autoArrange () const

Returns TRUE if the icon view rearranges its items when a new item is inserted; otherwise returns FALSE. See the "autoArrange" property for details.

void TQIconView::clear () [virtual]

Clears the icon view. All items are deleted.

void TQIconView::clearSelection () [virtual]

Unselects all the items.

void TQIconView::clicked ( TQIconViewItem * item ) [signal]

This signal is emitted when the user clicks any mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

See also mouseButtonClicked(), rightButtonClicked(), and pressed().

void TQIconView::clicked ( TQIconViewItem * item, const TQPoint & pos ) [signal]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

This signal is emitted when the user clicks any mouse button on an icon view item. item is a pointer to the item that has been clicked.

pos is the position of the mouse cursor in the global coordinate system (TQMouseEvent::globalPos()). (If the click's press and release differ by a pixel or two, pos is the position at release time.)

See also mouseButtonClicked(), rightButtonClicked(), and pressed().

void TQIconView::contextMenuRequested ( TQIconViewItem * item, const TQPoint & pos ) [signal]

This signal is emitted when the user invokes a context menu with the right mouse button or with special system keys, with item being the item under the mouse cursor or the current item, respectively.

pos is the position for the context menu in the global coordinate system.

uint TQIconView::count () const

Returns the number of items in the icon view. See the "count" property for details.

void TQIconView::currentChanged ( TQIconViewItem * item ) [signal]

This signal is emitted when a new item becomes current. item is the new current item (or 0 if no item is now current).

See also currentItem().

TQIconViewItem * TQIconView::currentItem () const

Returns a pointer to the current item of the icon view, or 0 if no item is current.

See also setCurrentItem(), firstItem(), and lastItem().

void TQIconView::doAutoScroll () [virtual protected slot]

Performs autoscrolling when selecting multiple icons with the rubber band.

void TQIconView::doubleClicked ( TQIconViewItem * item ) [signal]

This signal is emitted when the user double-clicks on item.

TQDragObject * TQIconView::dragObject () [virtual protected]

Returns the TQDragObject that should be used for drag-and-drop. This function is called by the icon view when starting a drag to get the dragobject that should be used for the drag. Subclasses may reimplement this.

See also TQIconDrag.

Examples: fileiconview/qfileiconview.cpp and iconview/simple_dd/main.cpp.

void TQIconView::drawBackground ( TQPainter * p, const TQRect & r ) [virtual protected]

This function is called to draw the rectangle r of the background using the painter p.

The default implementation fills r with the viewport's backgroundBrush(). Subclasses may reimplement this to draw custom backgrounds.

See also contentsX, contentsY, and drawContents().

void TQIconView::drawRubber ( TQPainter * p ) [virtual protected]

Draws the rubber band using the painter p.

void TQIconView::dropped ( TQDropEvent * e, const TQValueList<TQIconDragItem> & lst ) [signal]

This signal is emitted when a drop event occurs in the viewport (but not on any icon) which the icon view itself can't handle.

e provides all the information about the drop. If the drag object of the drop was a TQIconDrag, lst contains the list of the dropped items. You can get the data using TQIconDragItem::data() on each item. If the lst is empty, i.e. the drag was not a TQIconDrag, you have to decode the data in e and work with that.

Note TQIconViewItems may be drop targets; if a drop event occurs on an item the item handles the drop.

Examples: iconview/main.cpp and iconview/simple_dd/main.cpp.

void TQIconView::emitSelectionChanged ( TQIconViewItem * i = 0 ) [protected]

Emits a signal to indicate selection changes. i is the TQIconViewItem that was selected or de-selected.

You should never need to call this function.

void TQIconView::ensureItemVisible ( TQIconViewItem * item )

Makes sure that item is entirely visible. If necessary, ensureItemVisible() scrolls the icon view.

See also ensureVisible().

TQIconViewItem * TQIconView::findFirstVisibleItem ( const TQRect & r ) const

Finds the first item whose bounding rectangle overlaps r and returns a pointer to that item. r is given in content coordinates. Returns 0 if no item overlaps r.

If you want to find all items that touch r, you will need to use this function and nextItem() in a loop ending at findLastVisibleItem() and test TQIconViewItem::rect() for each of these items.

See also findLastVisibleItem() and TQIconViewItem::rect().

TQIconViewItem * TQIconView::findItem ( const TQPoint & pos ) const

Returns a pointer to the item that contains point pos, which is given in contents coordinates, or 0 if no item contains point pos.

TQIconViewItem * TQIconView::findItem ( const TQString & text, ComparisonFlags compare = BeginsWith ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns a pointer to the first item whose text begins with text, or 0 if no such item could be found. Use the compare flag to control the comparison behaviour. (See TQt::StringComparisonMode.)

TQIconViewItem * TQIconView::findLastVisibleItem ( const TQRect & r ) const

Finds the last item whose bounding rectangle overlaps r and returns a pointer to that item. r is given in content coordinates. Returns 0 if no item overlaps r.

See also findFirstVisibleItem().

TQIconViewItem * TQIconView::firstItem () const

Returns a pointer to the first item of the icon view, or 0 if there are no items in the icon view.

See also lastItem() and currentItem().

int TQIconView::gridX () const

Returns the horizontal grid of the icon view. See the "gridX" property for details.

int TQIconView::gridY () const

Returns the vertical grid of the icon view. See the "gridY" property for details.

int TQIconView::index ( const TQIconViewItem * item ) const

Returns the index of item, or -1 if item doesn't exist in this icon view.

void TQIconView::insertInGrid ( TQIconViewItem * item ) [virtual protected]

Inserts the TQIconViewItem item in the icon view's grid. You should never need to call this function. Instead, insert TQIconViewItems by creating them with a pointer to the TQIconView that they are to be inserted into.

void TQIconView::insertItem ( TQIconViewItem * item, TQIconViewItem * after = 0L ) [virtual]

Inserts the icon view item item after after. If after is 0, item is appended after the last item.

You should never need to call this function. Instead create TQIconViewItem's and associate them with your icon view like this:

        (void) new TQIconViewItem( myIconview, "The text of the item", aPixmap );
    

void TQIconView::invertSelection () [virtual]

Inverts the selection. Works only in Multi and Extended selection mode.

bool TQIconView::isRenaming () const

Returns TRUE if an iconview item is being renamed; otherwise returns FALSE.

void TQIconView::itemRenamed ( TQIconViewItem * item, const TQString & name ) [signal]

This signal is emitted when item has been renamed to name, usually by in-place renaming.

See also TQIconViewItem::setRenameEnabled() and TQIconViewItem::rename().

void TQIconView::itemRenamed ( TQIconViewItem * item ) [signal]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

This signal is emitted when item has been renamed, usually by in-place renaming.

See also TQIconViewItem::setRenameEnabled() and TQIconViewItem::rename().

TQBrush TQIconView::itemTextBackground () const

Returns the brush to use when drawing the background of an item's text. See the "itemTextBackground" property for details.

ItemTextPos TQIconView::itemTextPos () const

Returns the position where the text of each item is drawn. See the "itemTextPos" property for details.

bool TQIconView::itemsMovable () const

Returns TRUE if the user is allowed to move items around in the icon view; otherwise returns FALSE. See the "itemsMovable" property for details.

TQIconViewItem * TQIconView::lastItem () const

Returns a pointer to the last item of the icon view, or 0 if there are no items in the icon view.

See also firstItem() and currentItem().

TQIconViewItem * TQIconView::makeRowLayout ( TQIconViewItem * begin, int & y, bool & changed ) [protected]

Lays out a row of icons (if Arrangement == TopToBottom this is a column). Starts laying out with the item begin. y is the starting coordinate. Returns the last item of the row (column) and sets the new starting coordinate to y. The changed parameter is used internally.

Warning: This function may be made private in a future version of TQt. We do not recommend calling it.

int TQIconView::maxItemTextLength () const

Returns the maximum length (in characters) that an item's text may have. See the "maxItemTextLength" property for details.

int TQIconView::maxItemWidth () const

Returns the maximum width that an item may have. See the "maxItemWidth" property for details.

void TQIconView::mouseButtonClicked ( int button, TQIconViewItem * item, const TQPoint & pos ) [signal]

This signal is emitted when the user clicks mouse button button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (TQMouseEvent::globalPos()). (If the click's press and release differ by a pixel or two, pos is the position at release time.)

See also mouseButtonPressed(), rightButtonClicked(), and clicked().

void TQIconView::mouseButtonPressed ( int button, TQIconViewItem * item, const TQPoint & pos ) [signal]

This signal is emitted when the user presses mouse button button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (TQMouseEvent::globalPos()).

See also rightButtonClicked() and pressed().

void TQIconView::moved () [signal]

This signal is emitted after successfully dropping one (or more) items of the icon view. If the items should be removed, it's best to do so in a slot connected to this signal.

Example: iconview/main.cpp.

void TQIconView::onItem ( TQIconViewItem * item ) [signal]

This signal is emitted when the user moves the mouse cursor onto an item, similar to the TQWidget::enterEvent() function.

void TQIconView::onViewport () [signal]

This signal is emitted when the user moves the mouse cursor from an item to an empty part of the icon view.

See also onItem().

void TQIconView::pressed ( TQIconViewItem * item ) [signal]

This signal is emitted when the user presses any mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

See also mouseButtonPressed(), rightButtonPressed(), and clicked().

void TQIconView::pressed ( TQIconViewItem * item, const TQPoint & pos ) [signal]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

This signal is emitted when the user presses any mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (TQMouseEvent::globalPos()). (If the click's press and release differ by a pixel or two, pos is the position at release time.)

See also mouseButtonPressed(), rightButtonPressed(), and clicked().

void TQIconView::repaintItem ( TQIconViewItem * item ) [virtual]

Repaints the item.

void TQIconView::repaintSelectedItems ()

Repaints the selected items.

ResizeMode TQIconView::resizeMode () const

Returns the resize mode of the icon view. See the "resizeMode" property for details.

void TQIconView::returnPressed ( TQIconViewItem * item ) [signal]

This signal is emitted if the user presses the Return or Enter key. item is the currentItem() at the time of the keypress.

void TQIconView::rightButtonClicked ( TQIconViewItem * item, const TQPoint & pos ) [signal]

This signal is emitted when the user clicks the right mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (TQMouseEvent::globalPos()). (If the click's press and release differ by a pixel or two, pos is the position at release time.)

See also rightButtonPressed(), mouseButtonClicked(), and clicked().

void TQIconView::rightButtonPressed ( TQIconViewItem * item, const TQPoint & pos ) [signal]

This signal is emitted when the user presses the right mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (TQMouseEvent::globalPos()).

void TQIconView::selectAll ( bool select ) [virtual]

In Multi and Extended modes, this function sets all items to be selected if select is TRUE, and to be unselected if select is FALSE.

In Single and NoSelection modes, this function only changes the selection status of currentItem().

void TQIconView::selectionChanged () [signal]

This signal is emitted when the selection has been changed. It's emitted in each selection mode.

void TQIconView::selectionChanged ( TQIconViewItem * item ) [signal]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

This signal is emitted when the selection changes. item is the newly selected item. This signal is emitted only in single selection mode.

SelectionMode TQIconView::selectionMode () const

Returns the selection mode of the icon view. See the "selectionMode" property for details.

void TQIconView::setArrangement ( Arrangement am ) [virtual]

Sets the arrangement mode of the icon view to am. See the "arrangement" property for details.

void TQIconView::setAutoArrange ( bool b ) [virtual]

Sets whether the icon view rearranges its items when a new item is inserted to b. See the "autoArrange" property for details.

void TQIconView::setCurrentItem ( TQIconViewItem * item ) [virtual]

Makes item the new current item of the icon view.

void TQIconView::setGridX ( int rx ) [virtual]

Sets the horizontal grid of the icon view to rx. See the "gridX" property for details.

void TQIconView::setGridY ( int ry ) [virtual]

Sets the vertical grid of the icon view to ry. See the "gridY" property for details.

void TQIconView::setItemTextBackground ( const TQBrush & b ) [virtual]

Sets the brush to use when drawing the background of an item's text to b. See the "itemTextBackground" property for details.

void TQIconView::setItemTextPos ( ItemTextPos pos ) [virtual]

Sets the position where the text of each item is drawn to pos. See the "itemTextPos" property for details.

void TQIconView::setItemsMovable ( bool b ) [virtual]

Sets whether the user is allowed to move items around in the icon view to b. See the "itemsMovable" property for details.

void TQIconView::setMaxItemTextLength ( int w ) [virtual]

Sets the maximum length (in characters) that an item's text may have to w. See the "maxItemTextLength" property for details.

void TQIconView::setMaxItemWidth ( int w ) [virtual]

Sets the maximum width that an item may have to w. See the "maxItemWidth" property for details.

void TQIconView::setResizeMode ( ResizeMode am ) [virtual]

Sets the resize mode of the icon view to am. See the "resizeMode" property for details.

void TQIconView::setSelected ( TQIconViewItem * item, bool s, bool cb = FALSE ) [virtual]

Selects or unselects item depending on s, and may also unselect other items, depending on TQIconView::selectionMode() and cb.

If s is FALSE, item is unselected.

If s is TRUE and TQIconView::selectionMode() is Single, item is selected, and the item which was selected is unselected.

If s is TRUE and TQIconView::selectionMode() is Extended, item is selected. If cb is TRUE, the selection state of the icon view's other items is left unchanged. If cb is FALSE (the default) all other items are unselected.

If s is TRUE and TQIconView::selectionMode() is Multi item is selected.

Note that cb is used only if TQIconView::selectionMode() is Extended. cb defaults to FALSE.

All items whose selection status is changed repaint themselves.

void TQIconView::setSelectionMode ( SelectionMode m ) [virtual]

Sets the selection mode of the icon view to m. See the "selectionMode" property for details.

void TQIconView::setShowToolTips ( bool b ) [virtual]

Sets whether the icon view will display a tool tip with the complete text for any truncated item text to b. See the "showToolTips" property for details.

void TQIconView::setSorting ( bool sort, bool ascending = TRUE )

If sort is TRUE, this function sets the icon view to sort items when a new item is inserted. If sort is FALSE, the icon view will not be sorted.

Note that autoArrange() must be TRUE for sorting to take place.

If ascending is TRUE (the default), items are sorted in ascending order. If ascending is FALSE, items are sorted in descending order.

TQIconViewItem::compare() is used to compare pairs of items. The sorting is based on the items' keys; these default to the items' text unless specifically set to something else.

See also TQIconView::autoArrange, TQIconView::autoArrange, sortDirection, sort(), and TQIconViewItem::setKey().

void TQIconView::setSpacing ( int sp ) [virtual]

Sets the space in pixels between icon view items to sp. See the "spacing" property for details.

void TQIconView::setWordWrapIconText ( bool b ) [virtual]

Sets whether the item text will be word-wrapped if it is too long to b. See the "wordWrapIconText" property for details.

bool TQIconView::showToolTips () const

Returns TRUE if the icon view will display a tool tip with the complete text for any truncated item text; otherwise returns FALSE. See the "showToolTips" property for details.

void TQIconView::slotUpdate () [virtual protected slot]

This slot is used for a slightly-delayed update.

The icon view is not redrawn immediately after inserting a new item but after a very small delay using a TQTimer. This means that when many items are inserted in a loop the icon view is probably redrawn only once at the end of the loop. This makes the insertions both flicker-free and faster.

void TQIconView::sort ( bool ascending = TRUE ) [virtual]

Sorts and rearranges all the items in the icon view. If ascending is TRUE, the items are sorted in increasing order, otherwise they are sorted in decreasing order.

TQIconViewItem::compare() is used to compare pairs of items. The sorting is based on the items' keys; these default to the items' text unless specifically set to something else.

Note that this function sets the sort order to ascending.

See also TQIconViewItem::key(), TQIconViewItem::setKey(), TQIconViewItem::compare(), TQIconView::setSorting(), and TQIconView::sortDirection.

bool TQIconView::sortDirection () const

Returns TRUE if the sort direction for inserting new items is ascending;; otherwise returns FALSE. See the "sortDirection" property for details.

bool TQIconView::sorting () const

Returns TRUE if the icon view sorts on insertion; otherwise returns FALSE. See the "sorting" property for details.

int TQIconView::spacing () const

Returns the space in pixels between icon view items. See the "spacing" property for details.

void TQIconView::startDrag () [virtual protected]

Starts a drag.

void TQIconView::takeItem ( TQIconViewItem * item ) [virtual]

Takes the icon view item item out of the icon view and causes an update of the screen display. The item is not deleted. You should normally not need to call this function because TQIconViewItem::~TQIconViewItem() calls it. The normal way to delete an item is to delete it.

bool TQIconView::wordWrapIconText () const

Returns TRUE if the item text will be word-wrapped if it is too long; otherwise returns FALSE. See the "wordWrapIconText" property for details.


Property Documentation

Arrangement arrangement

This property holds the arrangement mode of the icon view.

This can be LeftToRight or TopToBottom. The default is LeftToRight.

Set this property's value with setArrangement() and get this property's value with arrangement().

bool autoArrange

This property holds whether the icon view rearranges its items when a new item is inserted.

The default is TRUE.

Note that if the icon view is not visible at the time of insertion, TQIconView defers all position-related work until it is shown and then calls arrangeItemsInGrid().

Set this property's value with setAutoArrange() and get this property's value with autoArrange().

uint count

This property holds the number of items in the icon view.

Get this property's value with count().

int gridX

This property holds the horizontal grid of the icon view.

If the value is -1, (the default), TQIconView computes suitable column widths based on the icon view's contents.

Note that setting a grid width overrides setMaxItemWidth().

Set this property's value with setGridX() and get this property's value with gridX().

int gridY

This property holds the vertical grid of the icon view.

If the value is -1, (the default), TQIconView computes suitable column heights based on the icon view's contents.

Set this property's value with setGridY() and get this property's value with gridY().

TQBrush itemTextBackground

This property holds the brush to use when drawing the background of an item's text.

By default this brush is set to NoBrush, meaning that only the normal icon view background is used.

Set this property's value with setItemTextBackground() and get this property's value with itemTextBackground().

ItemTextPos itemTextPos

This property holds the position where the text of each item is drawn.

Valid values are Bottom or Right. The default is Bottom.

Set this property's value with setItemTextPos() and get this property's value with itemTextPos().

bool itemsMovable

This property holds whether the user is allowed to move items around in the icon view.

The default is TRUE.

Set this property's value with setItemsMovable() and get this property's value with itemsMovable().

int maxItemTextLength

This property holds the maximum length (in characters) that an item's text may have.

The default is 255 characters.

Set this property's value with setMaxItemTextLength() and get this property's value with maxItemTextLength().

int maxItemWidth

This property holds the maximum width that an item may have.

The default is 100 pixels.

Note that if the gridX() value is set TQIconView will ignore this property.

Set this property's value with setMaxItemWidth() and get this property's value with maxItemWidth().

ResizeMode resizeMode

This property holds the resize mode of the icon view.

This can be Fixed or Adjust. The default is Fixed. See ResizeMode.

Set this property's value with setResizeMode() and get this property's value with resizeMode().

SelectionMode selectionMode

This property holds the selection mode of the icon view.

This can be Single (the default), Extended, Multi or NoSelection.

Set this property's value with setSelectionMode() and get this property's value with selectionMode().

bool showToolTips

This property holds whether the icon view will display a tool tip with the complete text for any truncated item text.

The default is TRUE. Note that this has no effect if setWordWrapIconText() is TRUE, as it is by default.

Set this property's value with setShowToolTips() and get this property's value with showToolTips().

bool sortDirection

This property holds whether the sort direction for inserting new items is ascending;.

The default is TRUE (i.e. ascending). This sort direction is only meaningful if both sorting() and autoArrange() are TRUE.

To set the sort direction, use setSorting()

Get this property's value with sortDirection().

bool sorting

This property holds whether the icon view sorts on insertion.

The default is FALSE, i.e. no sorting on insertion.

To set the sorting, use setSorting().

Get this property's value with sorting().

int spacing

This property holds the space in pixels between icon view items.

The default is 5 pixels.

Negative values for spacing are illegal.

Set this property's value with setSpacing() and get this property's value with spacing().

bool wordWrapIconText

This property holds whether the item text will be word-wrapped if it is too long.

The default is TRUE.

If this property is FALSE, icon text that is too long is truncated, and an ellipsis (...) appended to indicate that truncation has occurred. The full text can still be seen by the user if they hover the mouse because the full text is shown in a tooltip; see setShowToolTips().

Set this property's value with setWordWrapIconText() and get this property's value with wordWrapIconText().


This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8