You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
725 lines
36 KiB
725 lines
36 KiB
'\" t
|
|
.TH QListViewItem 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
|
|
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
|
|
.\" license file included in the distribution for a complete license
|
|
.\" statement.
|
|
.\"
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
QListViewItem \- Implements a list view item
|
|
.SH SYNOPSIS
|
|
\fC#include <ntqlistview.h>\fR
|
|
.PP
|
|
Inherits Qt.
|
|
.PP
|
|
Inherited by QCheckListItem.
|
|
.PP
|
|
.SS "Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "\fBQListViewItem\fR ( QListView * parent )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBQListViewItem\fR ( QListViewItem * parent )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBQListViewItem\fR ( QListView * parent, QListViewItem * after )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBQListViewItem\fR ( QListViewItem * parent, QListViewItem * after )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBQListViewItem\fR ( QListView * parent, TQString label1, TQString label2 = TQString::null, TQString label3 = TQString::null, TQString label4 = TQString::null, TQString label5 = TQString::null, TQString label6 = TQString::null, TQString label7 = TQString::null, TQString label8 = TQString::null )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBQListViewItem\fR ( QListViewItem * parent, TQString label1, TQString label2 = TQString::null, TQString label3 = TQString::null, TQString label4 = TQString::null, TQString label5 = TQString::null, TQString label6 = TQString::null, TQString label7 = TQString::null, TQString label8 = TQString::null )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBQListViewItem\fR ( QListView * parent, QListViewItem * after, TQString label1, TQString label2 = TQString::null, TQString label3 = TQString::null, TQString label4 = TQString::null, TQString label5 = TQString::null, TQString label6 = TQString::null, TQString label7 = TQString::null, TQString label8 = TQString::null )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBQListViewItem\fR ( QListViewItem * parent, QListViewItem * after, TQString label1, TQString label2 = TQString::null, TQString label3 = TQString::null, TQString label4 = TQString::null, TQString label5 = TQString::null, TQString label6 = TQString::null, TQString label7 = TQString::null, TQString label8 = TQString::null )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual \fB~QListViewItem\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBinsertItem\fR ( QListViewItem * newChild )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBtakeItem\fR ( QListViewItem * item )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void removeItem ( QListViewItem * item ) \fI(obsolete)\fR"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBheight\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBinvalidateHeight\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBtotalHeight\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual int \fBwidth\fR ( const TQFontMetrics & fm, const QListView * lv, int c ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBwidthChanged\fR ( int c = -1 ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBdepth\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetText\fR ( int column, const TQString & text )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual TQString \fBtext\fR ( int column ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetPixmap\fR ( int column, const TQPixmap & pm )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual const TQPixmap * \fBpixmap\fR ( int column ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual TQString \fBkey\fR ( int column, bool ascending ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual int \fBcompare\fR ( QListViewItem * i, int col, bool ascending ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsortChildItems\fR ( int column, bool ascending )"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBchildCount\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisOpen\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetOpen\fR ( bool o )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetup\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetSelected\fR ( bool s )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisSelected\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBpaintCell\fR ( TQPainter * p, const TQColorGroup & cg, int column, int width, int align )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBpaintBranches\fR ( TQPainter * p, const TQColorGroup & cg, int w, int y, int h )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBpaintFocus\fR ( TQPainter * p, const TQColorGroup & cg, const TQRect & r )"
|
|
.br
|
|
.ti -1c
|
|
.BI "QListViewItem * \fBfirstChild\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "QListViewItem * \fBnextSibling\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "QListViewItem * \fBparent\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "QListViewItem * \fBitemAbove\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "QListViewItem * \fBitemBelow\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBitemPos\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "QListView * \fBlistView\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetSelectable\fR ( bool enable )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisSelectable\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetExpandable\fR ( bool enable )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisExpandable\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBrepaint\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsort\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBmoveItem\fR ( QListViewItem * after )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetDragEnabled\fR ( bool allow )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetDropEnabled\fR ( bool allow )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBdragEnabled\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBdropEnabled\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual bool \fBacceptDrop\fR ( const TQMimeSource * mime ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetVisible\fR ( bool b )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisVisible\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetRenameEnabled\fR ( int col, bool b )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBrenameEnabled\fR ( int col ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBstartRename\fR ( int col )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetEnabled\fR ( bool b )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisEnabled\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual int \fBrtti\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetMultiLinesEnabled\fR ( bool b )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBmultiLinesEnabled\fR () const"
|
|
.br
|
|
.in -1c
|
|
.SS "Protected Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "virtual void \fBenforceSortOrder\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetHeight\fR ( int height )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBactivate\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBactivatedPos\fR ( TQPoint & pos )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBdropped\fR ( TQDropEvent * e )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBdragEntered\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBdragLeft\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBokRename\fR ( int col )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBcancelRename\fR ( int col )"
|
|
.br
|
|
.in -1c
|
|
.SH DESCRIPTION
|
|
The QListViewItem class implements a list view item.
|
|
.PP
|
|
A list view item is a multi-column object capable of displaying itself in a QListView.
|
|
.PP
|
|
The easiest way to use QListViewItem is to construct one with a few constant strings, and either a QListView or another QListViewItem as parent.
|
|
.PP
|
|
.nf
|
|
.br
|
|
(void) new QListViewItem( listView, "Column 1", "Column 2" );
|
|
.br
|
|
(void) new QListViewItem( listView->firstChild(), "A", "B", "C" );
|
|
.br
|
|
.fi
|
|
We've discarded the pointers to the items since we can still access them via their parent \fIlistView\fR. By default, QListView sorts its items; this can be switched off with QListView::setSorting(-1).
|
|
.PP
|
|
The parent must be another QListViewItem or a QListView. If the parent is a QListView, the item becomes a top-level item within that QListView. If the parent is another QListViewItem, the item becomes a child of that list view item.
|
|
.PP
|
|
If you keep the pointer, you can set or change the texts using setText(), add pixmaps using setPixmap(), change its mode using setSelectable(), setSelected(), setOpen() and setExpandable(). You'll also be able to change its height using setHeight(), and traverse its sub-items. You don't have to keep the pointer since you can get a pointer to any QListViewItem in a QListView using QListView::selectedItem(), QListView::currentItem(), QListView::firstChild(), QListView::lastItem() and QListView::findItem().
|
|
.PP
|
|
If you call \fCdelete\fR on a list view item, it will be deleted as expected, and as usual for TQObjects, if it has any child items (to any depth), all these will be deleted too.
|
|
.PP
|
|
QCheckListItems are list view items that have a checkbox or radio button and can be used in place of plain QListViewItems.
|
|
.PP
|
|
You can traverse the tree as if it were a doubly-linked list using itemAbove() and itemBelow(); they return pointers to the items directly above and below this item on the screen (even if none of them are actually visible at the moment).
|
|
.PP
|
|
Here's how to traverse all of an item's children (but not its children's children, etc.): Example:
|
|
.PP
|
|
.nf
|
|
.br
|
|
QListViewItem * myChild = myItem->firstChild();
|
|
.br
|
|
while( myChild ) {
|
|
.br
|
|
doSomething( myChild );
|
|
.br
|
|
myChild = myChild->nextSibling();
|
|
.br
|
|
}
|
|
.br
|
|
.fi
|
|
.PP
|
|
If you want to iterate over every item, to any level of depth use an iterator. To iterate over the entire tree, initialize the iterator with the list view itself; to iterate starting from a particular item, initialize the iterator with the item:
|
|
.PP
|
|
.nf
|
|
.br
|
|
QListViewItemIterator it( listview );
|
|
.br
|
|
while ( it.current() ) {
|
|
.br
|
|
QListViewItem *item = it.current();
|
|
.br
|
|
doSomething( item );
|
|
.br
|
|
++it;
|
|
.br
|
|
}
|
|
.br
|
|
.fi
|
|
.PP
|
|
Note that the order of the children will change when the sorting order changes and is undefined if the items are not visible. You can, however, call enforceSortOrder() at any time; QListView will always call it before it needs to show an item.
|
|
.PP
|
|
Many programs will need to reimplement QListViewItem. The most commonly reimplemented functions are: <center>.nf
|
|
.TS
|
|
l - l. Function Description text() Returns the text in a column. Many subclasses will compute this on the fly. key() Used for sorting. The default key() simply calls text(), but judicious use of key() can give you fine control over sorting; for example, TQFileDialog reimplements key() to sort by date. setup() Called before showing the item and whenever the list view's font changes, for example. activate()
|
|
.TE
|
|
.fi
|
|
</center>
|
|
.PP
|
|
Some subclasses call setExpandable(TRUE) even when they have no children, and populate themselves when setup() or setOpen(TRUE) is called. The dirview/dirview.cpp example program uses this technique to start up quickly: The files and subdirectories in a directory aren't inserted into the tree until they're actually needed.
|
|
.PP
|
|
<center>
|
|
.ce 1
|
|
.B "[Image Omitted]"
|
|
.PP
|
|
</center>
|
|
.PP
|
|
See also QCheckListItem, QListView, and Advanced Widgets.
|
|
.SH MEMBER FUNCTION DOCUMENTATION
|
|
.SH "QListViewItem::QListViewItem ( QListView * parent )"
|
|
Constructs a new top-level list view item in the QListView \fIparent\fR.
|
|
.SH "QListViewItem::QListViewItem ( QListViewItem * parent )"
|
|
Constructs a new list view item that is a child of \fIparent\fR and first in the parent's list of children.
|
|
.SH "QListViewItem::QListViewItem ( QListView * parent, QListViewItem * after )"
|
|
Constructs an empty list view item that is a child of \fIparent\fR and is after item \fIafter\fR in the parent's list of children. Since \fIparent\fR is a QListView the item will be a top-level item.
|
|
.SH "QListViewItem::QListViewItem ( QListViewItem * parent, QListViewItem * after )"
|
|
Constructs an empty list view item that is a child of \fIparent\fR and is after item \fIafter\fR in the parent's list of children.
|
|
.SH "QListViewItem::QListViewItem ( QListView * parent, TQString label1, TQString label2 = TQString::null, TQString label3 = TQString::null, TQString label4 = TQString::null, TQString label5 = TQString::null, TQString label6 = TQString::null, TQString label7 = TQString::null, TQString label8 = TQString::null )"
|
|
Constructs a new top-level list view item in the QListView \fIparent\fR, with up to eight constant strings, \fIlabel1\fR, \fIlabel2\fR, \fIlabel3\fR, \fIlabel4\fR, \fIlabel5\fR, \fIlabel6\fR, \fIlabel7\fR and \fIlabel8\fR defining its columns' contents.
|
|
.PP
|
|
See also setText().
|
|
.SH "QListViewItem::QListViewItem ( QListViewItem * parent, TQString label1, TQString label2 = TQString::null, TQString label3 = TQString::null, TQString label4 = TQString::null, TQString label5 = TQString::null, TQString label6 = TQString::null, TQString label7 = TQString::null, TQString label8 = TQString::null )"
|
|
Constructs a new list view item as a child of the QListViewItem \fIparent\fR with up to eight constant strings, \fIlabel1\fR, \fIlabel2\fR, \fIlabel3\fR, \fIlabel4\fR, \fIlabel5\fR, \fIlabel6\fR, \fIlabel7\fR and \fIlabel8\fR as columns' contents.
|
|
.PP
|
|
See also setText().
|
|
.SH "QListViewItem::QListViewItem ( QListView * parent, QListViewItem * after, TQString label1, TQString label2 = TQString::null, TQString label3 = TQString::null, TQString label4 = TQString::null, TQString label5 = TQString::null, TQString label6 = TQString::null, TQString label7 = TQString::null, TQString label8 = TQString::null )"
|
|
Constructs a new list view item in the QListView \fIparent\fR that is included after item \fIafter\fR and that has up to eight column texts, \fIlabel1\fR, \fIlabel2\fR, \fIlabel3\fR, \fIlabel4\fR, \fIlabel5\fR, \fIlabel6\fR, \fIlabel7\fR and\fIlabel8\fR.
|
|
.PP
|
|
Note that the order is changed according to QListViewItem::key() unless the list view's sorting is disabled using QListView::setSorting(-1).
|
|
.PP
|
|
See also setText().
|
|
.SH "QListViewItem::QListViewItem ( QListViewItem * parent, QListViewItem * after, TQString label1, TQString label2 = TQString::null, TQString label3 = TQString::null, TQString label4 = TQString::null, TQString label5 = TQString::null, TQString label6 = TQString::null, TQString label7 = TQString::null, TQString label8 = TQString::null )"
|
|
Constructs a new list view item as a child of the QListViewItem \fIparent\fR. It is inserted after item \fIafter\fR and may contain up to eight strings, \fIlabel1\fR, \fIlabel2\fR, \fIlabel3\fR, \fIlabel4\fR, \fIlabel5\fR, \fIlabel6\fR, \fIlabel7\fR and \fIlabel8\fR as column entries.
|
|
.PP
|
|
Note that the order is changed according to QListViewItem::key() unless the list view's sorting is disabled using QListView::setSorting(-1).
|
|
.PP
|
|
See also setText().
|
|
.SH "QListViewItem::~QListViewItem ()\fC [virtual]\fR"
|
|
Destroys the item, deleting all its children and freeing up all allocated resources.
|
|
.SH "bool QListViewItem::acceptDrop ( const TQMimeSource * mime ) const\fC [virtual]\fR"
|
|
Returns TRUE if the item can accept drops of type TQMimeSource \fImime\fR; otherwise returns FALSE.
|
|
.PP
|
|
The default implementation does nothing and returns FALSE. A subclass must reimplement this to accept drops.
|
|
.SH "void QListViewItem::activate ()\fC [virtual protected]\fR"
|
|
This virtual function is called whenever the user presses the mouse on this item or presses Space on it.
|
|
.PP
|
|
See also activatedPos().
|
|
.PP
|
|
Reimplemented in QCheckListItem.
|
|
.SH "bool QListViewItem::activatedPos ( TQPoint & pos )\fC [protected]\fR"
|
|
When called from a reimplementation of activate(), this function gives information on how the item was activated. Otherwise the behavior is undefined.
|
|
.PP
|
|
If activate() was caused by a mouse press, the function sets \fIpos\fR to where the user clicked and returns TRUE; otherwise it returns FALSE and does not change \fIpos\fR.
|
|
.PP
|
|
\fIpos\fR is relative to the top-left corner of this item.
|
|
.PP
|
|
\fBWarning:\fR We recommend that you ignore this function; it is scheduled to become obsolete.
|
|
.PP
|
|
See also activate().
|
|
.SH "void QListViewItem::cancelRename ( int col )\fC [virtual protected]\fR"
|
|
This function is called if the user cancels in-place renaming of this item in column \fIcol\fR (e.g. by pressing Esc).
|
|
.PP
|
|
See also okRename().
|
|
.SH "int QListViewItem::childCount () const"
|
|
Returns how many children this item has. The count only includes the item's immediate children.
|
|
.SH "int QListViewItem::compare ( QListViewItem * i, int col, bool ascending ) const\fC [virtual]\fR"
|
|
Compares this list view item to \fIi\fR using the column \fIcol\fR in \fIascending\fR order. Returns < 0 if this item is less than \fIi\fR, 0 if they are equal and > 0 if this item is greater than \fIi\fR.
|
|
.PP
|
|
This function is used for sorting.
|
|
.PP
|
|
The default implementation compares the item keys (key()) using TQString::localeAwareCompare(). A reimplementation can use different values and a different comparison function. Here is a reimplementation that uses plain Unicode comparison:
|
|
.PP
|
|
.nf
|
|
.br
|
|
int MyListViewItem::compare( QListViewItem *i, int col,
|
|
.br
|
|
bool ascending ) const
|
|
.br
|
|
{
|
|
.br
|
|
return key( col, ascending ).compare( i->key( col, ascending) );
|
|
.br
|
|
}
|
|
.br
|
|
.fi
|
|
We don't recommend using \fIascending\fR so your code can safely ignore it.
|
|
.PP
|
|
See also key(), TQString::localeAwareCompare(), and TQString::compare().
|
|
.SH "int QListViewItem::depth () const"
|
|
Returns the depth of this item.
|
|
.PP
|
|
Example: dirview/dirview.cpp.
|
|
.SH "bool QListViewItem::dragEnabled () const"
|
|
Returns TRUE if this item can be dragged; otherwise returns FALSE.
|
|
.PP
|
|
See also setDragEnabled().
|
|
.SH "void QListViewItem::dragEntered ()\fC [virtual protected]\fR"
|
|
This function is called when a drag enters the item's bounding rectangle.
|
|
.PP
|
|
The default implementation does nothing, subclasses may need to reimplement this function.
|
|
.SH "void QListViewItem::dragLeft ()\fC [virtual protected]\fR"
|
|
This function is called when a drag leaves the item's bounding rectangle.
|
|
.PP
|
|
The default implementation does nothing, subclasses may need to reimplement this function.
|
|
.SH "bool QListViewItem::dropEnabled () const"
|
|
Returns TRUE if this item accepts drops; otherwise returns FALSE.
|
|
.PP
|
|
See also setDropEnabled() and acceptDrop().
|
|
.SH "void QListViewItem::dropped ( TQDropEvent * e )\fC [virtual protected]\fR"
|
|
This function is called when something was dropped on the item. \fIe\fR contains all the information about the drop.
|
|
.PP
|
|
The default implementation does nothing, subclasses may need to reimplement this function.
|
|
.SH "void QListViewItem::enforceSortOrder () const\fC [virtual protected]\fR"
|
|
Makes sure that this object's children are sorted appropriately.
|
|
.PP
|
|
This only works if every item from the root item down to this item is already sorted.
|
|
.PP
|
|
See also sortChildItems().
|
|
.SH "QListViewItem * QListViewItem::firstChild () const"
|
|
Returns the first (top) child of this item, or 0 if this item has no children.
|
|
.PP
|
|
Note that the children are not guaranteed to be sorted properly. QListView and QListViewItem try to postpone or avoid sorting to the greatest degree possible, in order to keep the user interface snappy.
|
|
.PP
|
|
See also nextSibling() and sortChildItems().
|
|
.PP
|
|
Example: checklists/checklists.cpp.
|
|
.SH "int QListViewItem::height () const"
|
|
Returns the height of this item in pixels. This does not include the height of any children; totalHeight() returns that.
|
|
.SH "void QListViewItem::insertItem ( QListViewItem * newChild )\fC [virtual]\fR"
|
|
Inserts \fInewChild\fR into this list view item's list of children. You should not need to call this function; it is called automatically by the constructor of \fInewChild\fR.
|
|
.PP
|
|
\fBWarning:\fR If you are using \fCSingle\fR selection mode, then you should only insert unselected items.
|
|
.SH "void QListViewItem::invalidateHeight ()\fC [virtual]\fR"
|
|
Invalidates the cached total height of this item, including all open children.
|
|
.PP
|
|
See also setHeight(), height(), and totalHeight().
|
|
.SH "bool QListViewItem::isEnabled () const"
|
|
Returns TRUE if this item is enabled; otherwise returns FALSE.
|
|
.PP
|
|
See also setEnabled().
|
|
.SH "bool QListViewItem::isExpandable () const"
|
|
Returns TRUE if this item is expandable even when it has no children; otherwise returns FALSE.
|
|
.SH "bool QListViewItem::isOpen () const"
|
|
Returns TRUE if this list view item has children \fIand\fR they are not explicitly hidden; otherwise returns FALSE.
|
|
.PP
|
|
See also setOpen().
|
|
.SH "bool QListViewItem::isSelectable () const"
|
|
Returns TRUE if the item is selectable (as it is by default); otherwise returns FALSE
|
|
.PP
|
|
See also setSelectable().
|
|
.SH "bool QListViewItem::isSelected () const"
|
|
Returns TRUE if this item is selected; otherwise returns FALSE.
|
|
.PP
|
|
See also setSelected(), QListView::setSelected(), and QListView::selectionChanged().
|
|
.PP
|
|
Example: listviews/listviews.cpp.
|
|
.SH "bool QListViewItem::isVisible () const"
|
|
Returns TRUE if the item is visible; otherwise returns FALSE.
|
|
.PP
|
|
See also setVisible().
|
|
.SH "QListViewItem * QListViewItem::itemAbove ()"
|
|
Returns a pointer to the item immediately above this item on the screen. This is usually the item's closest older sibling, but it may also be its parent or its next older sibling's youngest child, or something else if anyoftheabove->height() returns 0. Returns 0 if there is no item immediately above this item.
|
|
.PP
|
|
This function assumes that all parents of this item are open (i.e. that this item is visible, or can be made visible by scrolling).
|
|
.PP
|
|
This function might be relatively slow because of the tree traversions needed to find the correct item.
|
|
.PP
|
|
See also itemBelow() and QListView::itemRect().
|
|
.SH "QListViewItem * QListViewItem::itemBelow ()"
|
|
Returns a pointer to the item immediately below this item on the screen. This is usually the item's eldest child, but it may also be its next younger sibling, its parent's next younger sibling, grandparent's, etc., or something else if anyoftheabove->height() returns 0. Returns 0 if there is no item immediately below this item.
|
|
.PP
|
|
This function assumes that all parents of this item are open (i.e. that this item is visible or can be made visible by scrolling).
|
|
.PP
|
|
See also itemAbove() and QListView::itemRect().
|
|
.PP
|
|
Example: dirview/dirview.cpp.
|
|
.SH "int QListViewItem::itemPos () const"
|
|
Returns the y coordinate of this item in the list view's coordinate system. This function is normally much slower than QListView::itemAt(), but it works for all items whereas QListView::itemAt() normally only works for items on the screen.
|
|
.PP
|
|
See also QListView::itemAt(), QListView::itemRect(), and QListView::itemPos().
|
|
.SH "TQString QListViewItem::key ( int column, bool ascending ) const\fC [virtual]\fR"
|
|
Returns a key that can be used for sorting by column \fIcolumn\fR. The default implementation returns text(). Derived classes may also incorporate the order indicated by \fIascending\fR into this key, although this is not recommended.
|
|
.PP
|
|
If you want to sort on non-alphabetical data, e.g. dates, numbers, etc., it is more efficient to reimplement compare().
|
|
.PP
|
|
See also compare() and sortChildItems().
|
|
.SH "QListView * QListViewItem::listView () const"
|
|
Returns a pointer to the list view containing this item.
|
|
.PP
|
|
Note that this function traverses the items to the root to find the listview. This function will return 0 for taken items - see QListViewItem::takeItem()
|
|
.SH "void QListViewItem::moveItem ( QListViewItem * after )"
|
|
Move the item to be after item \fIafter\fR, which must be one of the item's siblings. To move an item in the hierarchy, use takeItem() and insertItem().
|
|
.PP
|
|
Note that this function will have no effect if sorting is enabled in the list view.
|
|
.SH "bool QListViewItem::multiLinesEnabled () const"
|
|
Returns TRUE if the item can display multiple lines of text in its columns; otherwise returns FALSE.
|
|
.SH "QListViewItem * QListViewItem::nextSibling () const"
|
|
Returns the sibling item below this item, or 0 if there is no sibling item after this item.
|
|
.PP
|
|
Note that the siblings are not guaranteed to be sorted properly. QListView and QListViewItem try to postpone or avoid sorting to the greatest degree possible, in order to keep the user interface snappy.
|
|
.PP
|
|
See also firstChild() and sortChildItems().
|
|
.PP
|
|
Example: xml/tagreader-with-features/structureparser.cpp.
|
|
.SH "void QListViewItem::okRename ( int col )\fC [virtual protected]\fR"
|
|
This function is called if the user presses Enter during in-place renaming of the item in column \fIcol\fR.
|
|
.PP
|
|
See also cancelRename().
|
|
.SH "void QListViewItem::paintBranches ( TQPainter * p, const TQColorGroup & cg, int w, int y, int h )\fC [virtual]\fR"
|
|
Paints a set of branches from this item to (some of) its children.
|
|
.PP
|
|
Painter \fIp\fR is set up with clipping and translation so that you can only draw in the rectangle that needs redrawing; \fIcg\fR is the color group to use; the update rectangle is at (0, 0) and has size width \fIw\fR by height \fIh\fR. The top of the rectangle you own is at \fIy\fR (which is never greater than 0 but can be outside the window system's allowed coordinate range).
|
|
.PP
|
|
The update rectangle is in an undefined state when this function is called; this function must draw on \fIall\fR of the pixels.
|
|
.PP
|
|
See also paintCell() and QListView::drawContentsOffset().
|
|
.SH "void QListViewItem::paintCell ( TQPainter * p, const TQColorGroup & cg, int column, int width, int align )\fC [virtual]\fR"
|
|
This virtual function paints the contents of one column of an item and aligns it as described by \fIalign\fR.
|
|
.PP
|
|
\fIp\fR is a TQPainter open on the relevant paint device. \fIp\fR is translated so (0, 0) is the top-left pixel in the cell and \fIwidth-1\fR, height()-1 is the bottom-right pixel \fIin\fR the cell. The other properties of \fIp\fR (pen, brush, etc) are undefined. \fIcg\fR is the color group to use. \fIcolumn\fR is the logical column number within the item that is to be painted; 0 is the column which may contain a tree.
|
|
.PP
|
|
This function may use QListView::itemMargin() for readability spacing on the left and right sides of data such as text, and should honor isSelected() and QListView::allColumnsShowFocus().
|
|
.PP
|
|
If you reimplement this function, you should also reimplement width().
|
|
.PP
|
|
The rectangle to be painted is in an undefined state when this function is called, so you \fImust\fR draw on all the pixels. The painter \fIp\fR has the right font on entry.
|
|
.PP
|
|
See also paintBranches() and QListView::drawContentsOffset().
|
|
.PP
|
|
Example: listviews/listviews.cpp.
|
|
.PP
|
|
Reimplemented in QCheckListItem.
|
|
.SH "void QListViewItem::paintFocus ( TQPainter * p, const TQColorGroup & cg, const TQRect & r )\fC [virtual]\fR"
|
|
Paints a focus indicator on the rectangle \fIr\fR using painter \fIp\fR and colors \fIcg\fR.
|
|
.PP
|
|
\fIp\fR is already clipped.
|
|
.PP
|
|
See also paintCell(), paintBranches(), and QListView::allColumnsShowFocus.
|
|
.PP
|
|
Reimplemented in QCheckListItem.
|
|
.SH "QListViewItem * QListViewItem::parent () const"
|
|
Returns the parent of this item, or 0 if this item has no parent.
|
|
.PP
|
|
See also firstChild() and nextSibling().
|
|
.PP
|
|
Examples:
|
|
.)l dirview/dirview.cpp and qutlook/centralwidget.cpp.
|
|
.SH "const TQPixmap * QListViewItem::pixmap ( int column ) const\fC [virtual]\fR"
|
|
Returns the pixmap for \fIcolumn\fR, or 0 if there is no pixmap for \fIcolumn\fR.
|
|
.PP
|
|
See also setText() and setPixmap().
|
|
.PP
|
|
Example: dirview/dirview.cpp.
|
|
.SH "void QListViewItem::removeItem ( QListViewItem * item )\fC [virtual]\fR"
|
|
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
|
|
.PP
|
|
This function has been renamed takeItem().
|
|
.SH "bool QListViewItem::renameEnabled ( int col ) const"
|
|
Returns TRUE if this item can be in-place renamed in column \fIcol\fR; otherwise returns FALSE.
|
|
.SH "void QListViewItem::repaint () const"
|
|
Repaints this item on the screen if it is currently visible.
|
|
.PP
|
|
Example: addressbook/centralwidget.cpp.
|
|
.SH "int QListViewItem::rtti () const\fC [virtual]\fR"
|
|
Returns 0.
|
|
.PP
|
|
Make your derived classes return their own values for rtti(), so that you can distinguish between different kinds of list view items. You should use values greater than 1000 to allow for extensions to this class.
|
|
.PP
|
|
Reimplemented in QCheckListItem.
|
|
.SH "void QListViewItem::setDragEnabled ( bool allow )\fC [virtual]\fR"
|
|
If \fIallow\fR is TRUE, the list view starts a drag (see QListView::dragObject()) when the user presses and moves the mouse on this item.
|
|
.SH "void QListViewItem::setDropEnabled ( bool allow )\fC [virtual]\fR"
|
|
If \fIallow\fR is TRUE, the list view accepts drops onto the item; otherwise drops are not allowed.
|
|
.SH "void QListViewItem::setEnabled ( bool b )\fC [virtual]\fR"
|
|
If \fIb\fR is TRUE the item is enabled; otherwise it is disabled. Disabled items are drawn differently (e.g. grayed-out) and are not accessible by the user.
|
|
.SH "void QListViewItem::setExpandable ( bool enable )\fC [virtual]\fR"
|
|
Sets this item to be expandable even if it has no children if \fIenable\fR is TRUE, and to be expandable only if it has children if \fIenable\fR is FALSE (the default).
|
|
.PP
|
|
The dirview example uses this in the canonical fashion. It checks whether the directory is empty in setup() and calls setExpandable(TRUE) if not; in setOpen() it reads the contents of the directory and inserts items accordingly. This strategy means that dirview can display the entire file system without reading very much at startup.
|
|
.PP
|
|
Note that root items are not expandable by the user unless QListView::setRootIsDecorated() is set to TRUE.
|
|
.PP
|
|
See also setSelectable().
|
|
.SH "void QListViewItem::setHeight ( int height )\fC [virtual protected]\fR"
|
|
Sets this item's height to \fIheight\fR pixels. This implicitly changes totalHeight(), too.
|
|
.PP
|
|
Note that a font change causes this height to be overwritten unless you reimplement setup().
|
|
.PP
|
|
For best results in Windows style we suggest using an even number of pixels.
|
|
.PP
|
|
See also height(), totalHeight(), and isOpen().
|
|
.SH "void QListViewItem::setMultiLinesEnabled ( bool b )\fC [virtual]\fR"
|
|
If \fIb\fR is TRUE each of the item's columns may contain multiple lines of text; otherwise each of them may only contain a single line.
|
|
.SH "void QListViewItem::setOpen ( bool o )\fC [virtual]\fR"
|
|
Opens or closes an item, i.e. shows or hides an item's children.
|
|
.PP
|
|
If \fIo\fR is TRUE all child items are shown initially. The user can hide them by clicking the \fB-\fR icon to the left of the item. If \fIo\fR is FALSE, the children of this item are initially hidden. The user can show them by clicking the \fB+\fR icon to the left of the item.
|
|
.PP
|
|
See also height(), totalHeight(), and isOpen().
|
|
.PP
|
|
Examples:
|
|
.)l checklists/checklists.cpp, dirview/dirview.cpp, dirview/main.cpp, fileiconview/mainwindow.cpp, and xml/tagreader-with-features/structureparser.cpp.
|
|
.SH "void QListViewItem::setPixmap ( int column, const TQPixmap & pm )\fC [virtual]\fR"
|
|
Sets the pixmap in column \fIcolumn\fR to \fIpm\fR, if \fIpm\fR is non-null and different from the current pixmap, and if \fIcolumn\fR is non-negative.
|
|
.PP
|
|
See also pixmap() and setText().
|
|
.PP
|
|
Example: dirview/dirview.cpp.
|
|
.SH "void QListViewItem::setRenameEnabled ( int col, bool b )\fC [virtual]\fR"
|
|
If \fIb\fR is TRUE, this item can be in-place renamed in the column \fIcol\fR by the user; otherwise it cannot be renamed in-place.
|
|
.SH "void QListViewItem::setSelectable ( bool enable )\fC [virtual]\fR"
|
|
Sets this item to be selectable if \fIenable\fR is TRUE (the default) or not to be selectable if \fIenable\fR is FALSE.
|
|
.PP
|
|
The user is not able to select a non-selectable item using either the keyboard or the mouse. This also applies for the application programmer (e.g. setSelected() respects this value).
|
|
.PP
|
|
See also isSelectable().
|
|
.SH "void QListViewItem::setSelected ( bool s )\fC [virtual]\fR"
|
|
If \fIs\fR is TRUE this item is selected; otherwise it is deselected.
|
|
.PP
|
|
This function does not maintain any invariants or repaint anything -- QListView::setSelected() does that.
|
|
.PP
|
|
See also height() and totalHeight().
|
|
.PP
|
|
Example: addressbook/centralwidget.cpp.
|
|
.SH "void QListViewItem::setText ( int column, const TQString & text )\fC [virtual]\fR"
|
|
Sets the text in column \fIcolumn\fR to \fItext\fR, if \fIcolumn\fR is a valid column number and \fItext\fR is different from the existing text.
|
|
.PP
|
|
If \fItext()\fR has been reimplemented, this function may be a no-op.
|
|
.PP
|
|
See also text() and key().
|
|
.PP
|
|
Examples:
|
|
.)l addressbook/centralwidget.cpp, qutlook/centralwidget.cpp, and xml/outliner/outlinetree.cpp.
|
|
.SH "void QListViewItem::setVisible ( bool b )"
|
|
If \fIb\fR is TRUE, the item is made visible; otherwise it is hidden.
|
|
.PP
|
|
If the item is not visible, itemAbove() and itemBelow() will never return this item, although you still can reach it by using e.g. QListViewItemIterator.
|
|
.SH "void QListViewItem::setup ()\fC [virtual]\fR"
|
|
This virtual function is called before the first time QListView needs to know the height or any other graphical attribute of this object, and whenever the font, GUI style, or colors of the list view change.
|
|
.PP
|
|
The default calls widthChanged() and sets the item's height to the height of a single line of text in the list view's font. (If you use icons, multi-line text, etc., you will probably need to call setHeight() yourself or reimplement it.)
|
|
.PP
|
|
Example: dirview/dirview.cpp.
|
|
.SH "void QListViewItem::sort ()\fC [virtual]\fR"
|
|
Sorts all this item's child items using the current sorting configuration (sort column and direction).
|
|
.PP
|
|
See also enforceSortOrder().
|
|
.SH "void QListViewItem::sortChildItems ( int column, bool ascending )\fC [virtual]\fR"
|
|
Sorts this item's children using column \fIcolumn\fR. This is done in ascending order if \fIascending\fR is TRUE and in descending order if \fIascending\fR is FALSE.
|
|
.PP
|
|
Asks some of the children to sort their children. (QListView and QListViewItem ensure that all on-screen objects are properly sorted but may avoid or defer sorting other objects in order to be more responsive.)
|
|
.PP
|
|
See also key() and compare().
|
|
.SH "void QListViewItem::startRename ( int col )\fC [virtual]\fR"
|
|
If in-place renaming of this item is enabled (see renameEnabled()), this function starts renaming the item in column \fIcol\fR, by creating and initializing an edit box.
|
|
.SH "void QListViewItem::takeItem ( QListViewItem * item )\fC [virtual]\fR"
|
|
Removes \fIitem\fR from this object's list of children and causes an update of the screen display. The item is not deleted. You should not normally need to call this function because QListViewItem::~QListViewItem() calls it.
|
|
.PP
|
|
The normal way to delete an item is to use \fCdelete\fR.
|
|
.PP
|
|
If you need to move an item from one place in the hierarchy to another you can use takeItem() to remove the item from the list view and then insertItem() to put the item back in its new position.
|
|
.PP
|
|
If a taken item is part of a selection in \fCSingle\fR selection mode, it is unselected and selectionChanged() is emitted. If a taken item is part of a selection in \fCMulti\fR or \fCExtended\fR selection mode, it remains selected.
|
|
.PP
|
|
\fBWarning:\fR This function leaves \fIitem\fR and its children in a state where most member functions are unsafe. Only a few functions work correctly on an item in this state, most notably insertItem(). The functions that work on taken items are explicitly documented as such.
|
|
.PP
|
|
See also QListViewItem::insertItem().
|
|
.SH "TQString QListViewItem::text ( int column ) const\fC [virtual]\fR"
|
|
Returns the text in column \fIcolumn\fR, or TQString::null if there is no text in that column.
|
|
.PP
|
|
See also key() and paintCell().
|
|
.PP
|
|
Examples:
|
|
.)l addressbook/centralwidget.cpp, dirview/dirview.cpp, network/archivesearch/archivedialog.ui.h, and network/ftpclient/ftpmainwindow.ui.h.
|
|
.SH "int QListViewItem::totalHeight () const"
|
|
Returns the total height of this object, including any visible children. This height is recomputed lazily and cached for as long as possible.
|
|
.PP
|
|
Functions which can affect the total height are, setHeight() which is used to set an item's height, setOpen() to show or hide an item's children, and invalidateHeight() to invalidate the cached height.
|
|
.PP
|
|
See also height().
|
|
.SH "int QListViewItem::width ( const TQFontMetrics & fm, const QListView * lv, int c ) const\fC [virtual]\fR"
|
|
Returns the number of pixels of width required to draw column \fIc\fR of list view \fIlv\fR, using the metrics \fIfm\fR without cropping. The list view containing this item may use this information depending on the QListView::WidthMode settings for the column.
|
|
.PP
|
|
The default implementation returns the width of the bounding rectangle of the text of column \fIc\fR.
|
|
.PP
|
|
See also listView(), widthChanged(), QListView::setColumnWidthMode(), and QListView::itemMargin.
|
|
.SH "void QListViewItem::widthChanged ( int c = -1 ) const"
|
|
Call this function when the value of width() may have changed for column \fIc\fR. Normally, you should call this if text(c) changes. Passing -1 for \fIc\fR indicates that all columns may have changed. It is more efficient to pass -1 if two or more columns have changed than to call widthChanged() separately for each one.
|
|
.PP
|
|
See also width().
|
|
|
|
.SH "SEE ALSO"
|
|
.BR http://doc.trolltech.com/qlistviewitem.html
|
|
.BR http://www.trolltech.com/faq/tech.html
|
|
.SH COPYRIGHT
|
|
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
|
|
license file included in the distribution for a complete license
|
|
statement.
|
|
.SH AUTHOR
|
|
Generated automatically from the source code.
|
|
.SH BUGS
|
|
If you find a bug in Qt, please report it as described in
|
|
.BR http://doc.trolltech.com/bughowto.html .
|
|
Good bug reports help us to help you. Thank you.
|
|
.P
|
|
The definitive TQt documentation is provided in HTML format; it is
|
|
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
|
|
a web browser. This man page is provided as a convenience for those
|
|
users who prefer man pages, although this format is not officially
|
|
supported by Trolltech.
|
|
.P
|
|
If you find errors in this manual page, please report them to
|
|
.BR qt-bugs@trolltech.com .
|
|
Please include the name of the manual page (tqlistviewitem.3qt) and the Qt
|
|
version (3.3.8).
|