QTreeWidgetItem Class Reference

#include <qtreewidget.h>

Collaboration diagram for QTreeWidgetItem:

Collaboration graph
[legend]
List of all members.

Detailed Description

The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class.

The QTreeWidgetItem class is a convenience class that replaces the QListViewItem class in Qt 3. It provides an item for use with the QTreeWidget class.

Items are usually constructed with a parent that is either a QTreeWidget (for top-level items) or a QTreeWidgetItem (for items on lower levels of the tree). For example, the following code constructs a top-level item to represent cities of the world, and adds a entry for Oslo as a child item:

snippets/qtreewidget-using/mainwindow.cpp QTreeWidgetItem *cities osloItem->setText(1, tr("Yes"));

Items can be added in a particular order by specifying the item they follow when they are constructed:

QTreeWidgetItem *planets planets->setText(0

Each column in an item can have its own background brush which is set with the setBackground() function. The current background brush can be found with background(). The text label for each column can be rendered with its own font and brush. These are specified with the setFont() and setForeground() functions, and read with font() and foreground().

The main difference between top-level items and those in lower levels of the tree is that a top-level item has no parent(). This information can be used to tell the difference between items, and is useful to know when inserting and removing items from the tree. Children of an item can be removed with takeChild() and inserted at a given index in the list of children with the insertChild() function.

By default, items are enabled, selectable, checkable, and can be the source of a drag and drop operation. Each item's flags can be changed by calling setFlags() with the appropriate value (see {Qt::ItemFlags}). Checkable items can be checked and unchecked with the setCheckState() function. The corresponding checkState() function indicates whether the item is currently checked.

When subclassing QTreeWidgetItem to provide custom items, it is possible to define new types for them so that they can be distinguished from standard items. The constructors for subclasses that require this feature need to call the base class constructor with a new type value equal to or greater than \l UserType. \sa QTreeWidget, {Model/View Programming}, QListWidgetItem, QTableWidgetItem Definition at line 42 of file qtreewidget.h.

Public Types

enum  ItemType

Public Member Functions

 QTreeWidgetItem (int type=Type)
 QTreeWidgetItem (const QStringList &strings, int type=Type)
 QTreeWidgetItem (QTreeWidget *view, int type=Type)
 QTreeWidgetItem (QTreeWidget *view, const QStringList &strings, int type=Type)
 QTreeWidgetItem (QTreeWidget *view, QTreeWidgetItem *after, int type=Type)
 QTreeWidgetItem (QTreeWidgetItem *parent, int type=Type)
 QTreeWidgetItem (QTreeWidgetItem *parent, const QStringList &strings, int type=Type)
 QTreeWidgetItem (QTreeWidgetItem *parent, QTreeWidgetItem *after, int type=Type)
 QTreeWidgetItem (const QTreeWidgetItem &other)
virtual ~QTreeWidgetItem ()
virtual QTreeWidgetItemclone () const
QTreeWidgettreeWidget () const
void setSelected (bool select)
bool isSelected () const
void setHidden (bool hide)
bool isHidden () const
void setExpanded (bool expand)
bool isExpanded () const
Qt::ItemFlags flags () const
void setFlags (Qt::ItemFlags flags)
QString text (int column) const
void setText (int column, const QString &text)
QIcon icon (int column) const
void setIcon (int column, const QIcon &icon)
QString statusTip (int column) const
void setStatusTip (int column, const QString &statusTip)
QString toolTip (int column) const
void setToolTip (int column, const QString &toolTip)
QString whatsThis (int column) const
void setWhatsThis (int column, const QString &whatsThis)
QFont font (int column) const
void setFont (int column, const QFont &font)
int textAlignment (int column) const
void setTextAlignment (int column, int alignment)
QColor backgroundColor (int column) const
void setBackgroundColor (int column, const QColor &color)
QBrush background (int column) const
void setBackground (int column, const QBrush &brush)
QColor textColor (int column) const
void setTextColor (int column, const QColor &color)
QBrush foreground (int column) const
void setForeground (int column, const QBrush &brush)
Qt::CheckState checkState (int column) const
void setCheckState (int column, Qt::CheckState state)
QSize sizeHint (int column) const
void setSizeHint (int column, const QSize &size)
virtual QVariant data (int column, int role) const
virtual void setData (int column, int role, const QVariant &value)
virtual bool operator< (const QTreeWidgetItem &other) const
virtual void read (QDataStream &in)
virtual void write (QDataStream &out) const
QTreeWidgetItemoperator= (const QTreeWidgetItem &other)
QTreeWidgetItemparent () const
QTreeWidgetItemchild (int index) const
int childCount () const
int columnCount () const
int indexOfChild (QTreeWidgetItem *child) const
void addChild (QTreeWidgetItem *child)
void insertChild (int index, QTreeWidgetItem *child)
QTreeWidgetItemtakeChild (int index)
void addChildren (const QList< QTreeWidgetItem * > &children)
void insertChildren (int index, const QList< QTreeWidgetItem * > &children)
QList< QTreeWidgetItem * > takeChildren ()
int type () const
void sortChildren (int column, Qt::SortOrder order)

Private Member Functions

void sortChildren (int column, Qt::SortOrder order, bool climb)
QVariant childrenCheckState (int column) const
void itemChanged ()
void executePendingSort () const

Private Attributes

int rtti
QVector< QVector< QWidgetItemData > > values
QTreeWidgetview
QVariantList display
QTreeWidgetItempar
QList< QTreeWidgetItem * > children
Qt::ItemFlags itemFlags

Friends

class QTreeModel
class QTreeWidget
class QTreeWidgetItemIterator

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &out, const QTreeWidgetItem &item)
QDataStreamoperator>> (QDataStream &in, QTreeWidgetItem &item)


Member Enumeration Documentation

enum QTreeWidgetItem::ItemType

This enum describes the types that are used to describe tree widget items.

Type The default type for tree widget items. UserType The minimum value for custom types. Values below UserType are reserved by Qt.

You can define new user types in QTreeWidgetItem subclasses to ensure that custom items are treated specially; for example, when items are sorted.

See also:
type()

Definition at line 48 of file qtreewidget.h.

00048 { Type = 0, UserType = 1000 };


Constructor & Destructor Documentation

QTreeWidgetItem::QTreeWidgetItem ( int  type = Type  ) 

Constructs a tree widget item of the specified type. The item must be inserted into a tree widget.

See also:
type()

Definition at line 1188 of file qtreewidget.cpp.

Referenced by clone().

QTreeWidgetItem::QTreeWidgetItem ( const QStringList strings,
int  type = Type 
)

Constructs a tree widget item of the specified type. The item must be inserted into a tree widget. The given list of strings will be set as the item text for each column in the item.

See also:
type()

Definition at line 1207 of file qtreewidget.cpp.

References QList< T >::at(), QList< T >::count(), i, and setText().

01208     : rtti(type), view(0), par(0),
01209       itemFlags(Qt::ItemIsSelectable
01210                 |Qt::ItemIsUserCheckable
01211                 |Qt::ItemIsEnabled
01212                 |Qt::ItemIsDragEnabled
01213                 |Qt::ItemIsDropEnabled)
01214 {
01215     for (int i = 0; i < strings.count(); ++i)
01216         setText(i, strings.at(i));
01217 }

Here is the call graph for this function:

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidget parent,
int  type = Type 
) [explicit]

Constructs a tree widget item of the specified type and appends it to the items in the given parent.

See also:
type()

Definition at line 1228 of file qtreewidget.cpp.

References QAbstractItemView::model(), QVector< T >::reserve(), values, and view.

01229     : rtti(type), view(0), par(0),
01230       itemFlags(Qt::ItemIsSelectable
01231                 |Qt::ItemIsUserCheckable
01232                 |Qt::ItemIsEnabled
01233                 |Qt::ItemIsDragEnabled
01234                 |Qt::ItemIsDropEnabled)
01235 {
01236     if (view && view->model()) {
01237         QTreeModel *model = ::qobject_cast<QTreeModel*>(view->model());
01238         model->rootItem->addChild(this);
01239         values.reserve(model->headerItem->columnCount());
01240     }
01241 }

Here is the call graph for this function:

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidget parent,
const QStringList strings,
int  type = Type 
)

Constructs a tree widget item of the specified type and appends it to the items in the given parent. The given list of strings will be set as the item text for each column in the item.

See also:
type()

Definition at line 1253 of file qtreewidget.cpp.

References QList< T >::at(), QList< T >::count(), i, QAbstractItemView::model(), QVector< T >::reserve(), setText(), values, and view.

01254     : rtti(type), view(0), par(0),
01255       itemFlags(Qt::ItemIsSelectable
01256                 |Qt::ItemIsUserCheckable
01257                 |Qt::ItemIsEnabled
01258                 |Qt::ItemIsDragEnabled
01259                 |Qt::ItemIsDropEnabled)
01260 {
01261     for (int i = 0; i < strings.count(); ++i)
01262         setText(i, strings.at(i));
01263     if (view && view->model()) {
01264         QTreeModel *model = ::qobject_cast<QTreeModel*>(view->model());
01265         model->rootItem->addChild(this);
01266         values.reserve(model->headerItem->columnCount());
01267     }
01268 }

Here is the call graph for this function:

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidget parent,
QTreeWidgetItem preceding,
int  type = Type 
)

Constructs a tree widget item of the specified type and inserts it into the given parent after the preceding item.

See also:
type()

Definition at line 1278 of file qtreewidget.cpp.

References columnCount(), QTreeModel::headerItem, i, indexOfChild(), insertChild(), QAbstractItemView::model(), QVector< T >::reserve(), QTreeModel::rootItem, values, and view.

01279     : rtti(type), view(0), par(0),
01280       itemFlags(Qt::ItemIsSelectable
01281                 |Qt::ItemIsUserCheckable
01282                 |Qt::ItemIsEnabled
01283                 |Qt::ItemIsDragEnabled
01284                 |Qt::ItemIsDropEnabled)
01285 {
01286     if (view) {
01287         QTreeModel *model = ::qobject_cast<QTreeModel*>(view->model());
01288         if (model) {
01289             int i = model->rootItem->indexOfChild(after) + 1;
01290             model->rootItem->insertChild(i, this);
01291             values.reserve(model->headerItem->columnCount());
01292         }
01293     }
01294 }

Here is the call graph for this function:

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidgetItem parent,
int  type = Type 
) [explicit]

Constructs a tree widget item and append it to the given parent.

See also:
type()

Definition at line 1301 of file qtreewidget.cpp.

References addChild(), and parent().

01302     : rtti(type), view(0), par(0),
01303       itemFlags(Qt::ItemIsSelectable
01304                 |Qt::ItemIsUserCheckable
01305                 |Qt::ItemIsEnabled
01306                 |Qt::ItemIsDragEnabled
01307                 |Qt::ItemIsDropEnabled)
01308 {
01309     if (parent)
01310         parent->addChild(this);
01311 }

Here is the call graph for this function:

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidgetItem parent,
const QStringList strings,
int  type = Type 
)

Constructs a tree widget item and append it to the given parent. The given list of strings will be set as the item text for each column in the item.

See also:
type()

Definition at line 1319 of file qtreewidget.cpp.

References QList< T >::at(), QList< T >::count(), i, parent(), and setText().

01320     : rtti(type), view(0), par(0),
01321       itemFlags(Qt::ItemIsSelectable
01322                 |Qt::ItemIsUserCheckable
01323                 |Qt::ItemIsEnabled
01324                 |Qt::ItemIsDragEnabled
01325                 |Qt::ItemIsDropEnabled)
01326 {
01327     for (int i = 0; i < strings.count(); ++i)
01328         setText(i, strings.at(i));
01329     if (parent)
01330         parent->addChild(this);
01331 
01332 }

Here is the call graph for this function:

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidgetItem parent,
QTreeWidgetItem preceding,
int  type = Type 
)

Constructs a tree widget item of the specified type that is inserted into the parent after the preceding child item.

See also:
type()

Definition at line 1342 of file qtreewidget.cpp.

References i, indexOfChild(), insertChild(), and parent().

01343     : rtti(type), view(0), par(0),
01344       itemFlags(Qt::ItemIsSelectable
01345                 |Qt::ItemIsUserCheckable
01346                 |Qt::ItemIsEnabled
01347                 |Qt::ItemIsDragEnabled
01348                 |Qt::ItemIsDropEnabled)
01349 {
01350     if (parent) {
01351         int i = parent->indexOfChild(after) + 1;
01352         parent->insertChild(i, this);
01353     }
01354 }

Here is the call graph for this function:

QTreeWidgetItem::QTreeWidgetItem ( const QTreeWidgetItem other  ) 

Since:
4.1
Constructs a copy of other. Note that type() and treeWidget() are not copied.

This function is useful when reimplementing clone().

See also:
data(), flags()

Definition at line 1595 of file qtreewidget.cpp.

01596     : rtti(Type), values(other.values), view(0), display(other.display),
01597       par(0), itemFlags(other.itemFlags)
01598 {
01599 }

QTreeWidgetItem::~QTreeWidgetItem (  )  [virtual]

Destroys this tree widget item.

Definition at line 1360 of file qtreewidget.cpp.

References QList< T >::at(), QTreeModel::beginRemoveItems(), child(), children, QList< T >::clear(), QList< T >::count(), QTreeModel::endRemoveItems(), QTreeModel::headerItem, i, QList< T >::indexOf(), QAbstractItemView::model(), par, QTreeModel::rootItem, QList< T >::takeAt(), and view.

01361 {
01362     QTreeModel *model = (view ? ::qobject_cast<QTreeModel*>(view->model()) : 0);
01363     if (par) {
01364         int i = par->children.indexOf(this);
01365         if (model) model->beginRemoveItems(par, i, 1);
01366         par->children.takeAt(i);
01367         if (model) model->endRemoveItems();
01368     } else if (model) {
01369         if (this == model->headerItem) {
01370             model->headerItem = 0;
01371         } else {
01372             int i = model->rootItem->children.indexOf(this);
01373             model->beginRemoveItems(0, i, 1);
01374             model->rootItem->children.takeAt(i);
01375             model->endRemoveItems();
01376         }
01377     }
01378     // at this point the persistent indexes for the children should also be invalidated
01379     // since we invalidated the parent
01380     for (int i = 0; i < children.count(); ++i) {
01381         QTreeWidgetItem *child = children.at(i);
01382         // make sure the child does not try to remove itself from our children list
01383         child->par = 0;
01384         // make sure the child does not try to remove itself from the top level list
01385         child->view = 0;
01386         delete child;
01387     }
01388 
01389     children.clear();
01390 }

Here is the call graph for this function:


Member Function Documentation

QTreeWidgetItem * QTreeWidgetItem::clone (  )  const [virtual]

Creates a deep copy of the item and of its children.

Definition at line 1395 of file qtreewidget.cpp.

References QList< T >::append(), child(), childCount(), children, TokenEngine::copy(), i, QVector< T >::isEmpty(), parent(), QStack< T >::pop(), QStack< T >::push(), and QTreeWidgetItem().

Referenced by qdesigner_internal::ChangeTreeContentsCommand::changeContents(), and qdesigner_internal::ChangeTreeContentsCommand::initState().

01396 {
01397     QTreeWidgetItem *copy = 0;
01398 
01399     QStack<const QTreeWidgetItem*> stack;
01400     QStack<QTreeWidgetItem*> parentStack;
01401     stack.push(this);
01402     parentStack.push(0);
01403 
01404     QTreeWidgetItem *root = 0;
01405     const QTreeWidgetItem *item = 0;
01406     QTreeWidgetItem *parent = 0;
01407     while (!stack.isEmpty()) {
01408         // get current item, and copied parent
01409         item = stack.pop();
01410         parent = parentStack.pop();
01411 
01412         // copy item
01413         copy = new QTreeWidgetItem(*item);
01414         if (!root)
01415             root = copy;
01416 
01417         // set parent and add to parents children list
01418         if (parent) {
01419             copy->par = parent;
01420             parent->children.append(copy);
01421         }
01422 
01423         for (int i=0; i<item->childCount(); ++i) {
01424             stack.push(item->child(i));
01425             parentStack.push(copy);
01426         }
01427     }
01428     return root;
01429 }

Here is the call graph for this function:

QTreeWidget * QTreeWidgetItem::treeWidget (  )  const [inline]

Returns the tree widget that contains the item.

Definition at line 62 of file qtreewidget.h.

Referenced by qdesigner_internal::TreeWidgetEditor::copyContents(), QTreeWidgetItemIteratorPrivate::ensureValidIterator(), and QTreeWidgetItemIteratorPrivate::nextSibling().

00062 { return view; }

void QTreeWidgetItem::setSelected ( bool  select  )  [inline]

Since:
4.2
Sets the selected state of the item to select.

See also:
isSelected()

Definition at line 346 of file qtreewidget.h.

References QTreeWidget::setItemSelected(), and view.

00347 { if (view) view->setItemSelected(this, aselect); }

Here is the call graph for this function:

bool QTreeWidgetItem::isSelected (  )  const [inline]

Since:
4.2
Returns true if the item is selected, otherwise returns false.

See also:
setSelected()

Definition at line 349 of file qtreewidget.h.

References QTreeWidget::isItemSelected(), and view.

00350 { return (view ? view->isItemSelected(this) : false); }

Here is the call graph for this function:

void QTreeWidgetItem::setHidden ( bool  hide  )  [inline]

Since:
4.2
Hides the item if hide is true, otherwise shows the item.

See also:
isHidden()

Definition at line 352 of file qtreewidget.h.

References QTreeWidget::setItemHidden(), and view.

00353 { if (view) view->setItemHidden(this, ahide); }

Here is the call graph for this function:

bool QTreeWidgetItem::isHidden (  )  const [inline]

Since:
4.2
Returns true if the item is hidden, otherwise returns false.

See also:
setHidden()

Definition at line 355 of file qtreewidget.h.

References QTreeWidget::isItemHidden(), and view.

00356 { return (view ? view->isItemHidden(this) : false); }

Here is the call graph for this function:

void QTreeWidgetItem::setExpanded ( bool  expand  )  [inline]

Since:
4.2
Expands the item if expand is true, otherwise collapses the item.

See also:
isExpanded()

Definition at line 358 of file qtreewidget.h.

References QTreeWidget::setItemExpanded(), and view.

00359 { if (view) view->setItemExpanded(this, aexpand); }

Here is the call graph for this function:

bool QTreeWidgetItem::isExpanded (  )  const [inline]

Since:
4.2
Returns true if the item is expanded, otherwise returns false.

See also:
setExpanded()

Definition at line 361 of file qtreewidget.h.

References QTreeWidget::isItemExpanded(), and view.

00362 { return (view ? view->isItemExpanded(this) : false); }

Here is the call graph for this function:

Qt::ItemFlags QTreeWidgetItem::flags (  )  const [inline]

Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.

The default value for flags is Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled. If the item was constructed with a parent, flags will in addition contain Qt::ItemIsDropEnabled.

See also:
setFlags()

Definition at line 73 of file qtreewidget.h.

Referenced by MainWindow::addTorrent(), qdesigner_internal::TreeWidgetEditor::copyContents(), SettingsTree::createItem(), QTreeWidgetItemIteratorPrivate::ensureValidIterator(), QTreeModel::flags(), QTreeWidgetItemIterator::matchesFlags(), qdesigner_internal::TreeWidgetEditor::on_newItemButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_newSubItemButton_clicked(), XbelTree::parseFolderElement(), XbelHandler::startElement(), and qdesigner_internal::WidgetBoxTreeView::widgetToItem().

00073 { return itemFlags; }

void QTreeWidgetItem::setFlags ( Qt::ItemFlags  flags  )  [inline]

Sets the flags for the item to the given flags. These determine whether the item can be selected or modified. This is often used to disable an item.

See also:
flags()

Definition at line 188 of file qtreewidget.h.

References itemChanged(), and itemFlags.

Referenced by MainWindow::addTorrent(), qdesigner_internal::TreeWidgetEditor::copyContents(), SettingsTree::createItem(), qdesigner_internal::TreeWidgetEditor::on_newItemButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_newSubItemButton_clicked(), XbelTree::parseFolderElement(), XbelHandler::startElement(), and qdesigner_internal::WidgetBoxTreeView::widgetToItem().

00189 { itemFlags = aflags; itemChanged(); }

Here is the call graph for this function:

QString QTreeWidgetItem::text ( int  column  )  const [inline]

Returns the text in the specified column.

See also:
setText()

Definition at line 76 of file qtreewidget.h.

References data, and Qt::DisplayRole.

Referenced by qdesigner_internal::WidgetBoxTreeView::category(), qdesigner_internal::TreeWidgetEditor::copyContents(), qdesigner_internal::TreeWidgetEditor::fillContentsFromTreeWidget(), findItem(), XbelGenerator::generateItem(), qdesigner_internal::TreeWidgetEditor::moveColumnsLeft(), qdesigner_internal::TreeWidgetEditor::moveColumnsRight(), ConnectionWidget::on_tree_itemActivated(), FindFileDialog::openFile(), operator<(), MainWindow::printPage(), recursiveTranslate(), QAbstractFormBuilder::saveTreeWidgetExtraInfo(), QDBusViewer::serviceChanged(), MainWindow::showFont(), ConnectionWidget::showMetaData(), XbelTree::updateDomElement(), qdesigner_internal::TreeWidgetEditor::updateEditor(), qdesigner_internal::WidgetBoxTreeView::updateItemData(), and SettingsTree::updateSetting().

00077         { return data(column, Qt::DisplayRole).toString(); }

void QTreeWidgetItem::setText ( int  column,
const QString text 
) [inline]

Sets the text to be displayed in the given column to the given text.

See also:
text() setFont() setForeground()

Definition at line 191 of file qtreewidget.h.

References Qt::DisplayRole, and setData().

Referenced by PluginDialog::addItems(), MainWindow::addTorrent(), qdesigner_internal::TreeWidgetEditor::copyContents(), SettingsTree::createItem(), XbelHandler::endElement(), qdesigner_internal::WidgetBoxTreeView::indexOfScratchpad(), HelpDialog::insertContents(), NewForm::loadFrom(), QAbstractFormBuilder::loadTreeWidgetExtraInfo(), qdesigner_internal::TreeWidgetEditor::moveColumnsLeft(), qdesigner_internal::TreeWidgetEditor::moveColumnsRight(), qdesigner_internal::ObjectInspector::ObjectInspector(), qdesigner_internal::TreeWidgetEditor::on_itemTextLineEdit_textEdited(), qdesigner_internal::TreeWidgetEditor::on_newItemButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_newSubItemButton_clicked(), XbelTree::parseFolderElement(), PluginDialog::populateTreeWidget(), QTreeWidgetItem(), recursiveTranslate(), QTreeWidget::setHeaderLabels(), MainWindow::setupFontTree(), XbelHandler::startElement(), MainWindow::updateDownloadRate(), qdesigner_internal::WidgetBoxTreeView::updateItemData(), MainWindow::updatePeerInfo(), MainWindow::updateProgress(), MainWindow::updateState(), MainWindow::updateUploadRate(), and qdesigner_internal::WidgetBoxTreeView::widgetToItem().

00192 { setData(column, Qt::DisplayRole, atext); }

Here is the call graph for this function:

QIcon QTreeWidgetItem::icon ( int  column  )  const [inline]

Returns the icon that is displayed in the specified column.

See also:
setIcon(), {QAbstractItemView::iconSize}{iconSize}

Definition at line 80 of file qtreewidget.h.

References data, and Qt::DecorationRole.

Referenced by qdesigner_internal::TreeWidgetEditor::copyContents(), qdesigner_internal::TreeWidgetEditor::fillContentsFromTreeWidget(), qdesigner_internal::TreeWidgetEditor::moveColumnsLeft(), qdesigner_internal::TreeWidgetEditor::moveColumnsRight(), qdesigner_internal::TreeWidgetEditor::on_previewPixmapItemButton_clicked(), QAbstractFormBuilder::saveTreeWidgetExtraInfo(), and qdesigner_internal::TreeWidgetEditor::updateEditor().

00081         { return qvariant_cast<QIcon>(data(column, Qt::DecorationRole)); }

void QTreeWidgetItem::setIcon ( int  column,
const QIcon icon 
) [inline]

Sets the icon to be displayed in the given column to icon.

See also:
icon(), setText(), {QAbstractItemView::iconSize}{iconSize}

Definition at line 194 of file qtreewidget.h.

References Qt::DecorationRole, and setData().

Referenced by PluginDialog::addItems(), qdesigner_internal::TreeWidgetEditor::copyContents(), QAbstractFormBuilder::loadTreeWidgetExtraInfo(), qdesigner_internal::TreeWidgetEditor::moveColumnsLeft(), qdesigner_internal::TreeWidgetEditor::moveColumnsRight(), qdesigner_internal::TreeWidgetEditor::on_deletePixmapItemButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_previewPixmapItemButton_clicked(), PreviewDialog::paintItem(), XbelTree::parseFolderElement(), PluginDialog::populateTreeWidget(), XbelHandler::startElement(), and qdesigner_internal::WidgetBoxTreeView::widgetToItem().

00195 { setData(column, Qt::DecorationRole, aicon); }

Here is the call graph for this function:

QString QTreeWidgetItem::statusTip ( int  column  )  const [inline]

Returns the status tip for the contents of the given column.

See also:
setStatusTip()

Definition at line 84 of file qtreewidget.h.

References data, and Qt::StatusTipRole.

00085         { return data(column, Qt::StatusTipRole).toString(); }

void QTreeWidgetItem::setStatusTip ( int  column,
const QString statusTip 
) [inline]

Sets the status tip for the given column to the given statusTip. QTreeWidget mouse tracking needs to be enabled for this feature to work.

See also:
statusTip() setToolTip() setWhatsThis()

Definition at line 198 of file qtreewidget.h.

References setData(), and Qt::StatusTipRole.

00199 { setData(column, Qt::StatusTipRole, astatusTip); }

Here is the call graph for this function:

QString QTreeWidgetItem::toolTip ( int  column  )  const [inline]

Returns the tool tip for the given column.

See also:
setToolTip()

Definition at line 89 of file qtreewidget.h.

References data, and Qt::ToolTipRole.

00090         { return data(column, Qt::ToolTipRole).toString(); }

void QTreeWidgetItem::setToolTip ( int  column,
const QString toolTip 
) [inline]

Sets the tooltip for the given column to toolTip.

See also:
toolTip() setStatusTip() setWhatsThis()

Definition at line 203 of file qtreewidget.h.

References setData(), and Qt::ToolTipRole.

Referenced by MainWindow::addTorrent(), NewForm::loadFrom(), PluginDialog::populateTreeWidget(), and MainWindow::updateState().

00204 { setData(column, Qt::ToolTipRole, atoolTip); }

Here is the call graph for this function:

QString QTreeWidgetItem::whatsThis ( int  column  )  const [inline]

Returns the "What's This?" help for the contents of the given column.

See also:
setWhatsThis()

Definition at line 95 of file qtreewidget.h.

References data, and Qt::WhatsThisRole.

00096         { return data(column, Qt::WhatsThisRole).toString(); }

void QTreeWidgetItem::setWhatsThis ( int  column,
const QString whatsThis 
) [inline]

Sets the "What's This?" help for the given column to whatsThis.

See also:
whatsThis() setStatusTip() setToolTip()

Definition at line 208 of file qtreewidget.h.

References setData(), and Qt::WhatsThisRole.

Referenced by PluginDialog::populateTreeWidget().

00209 { setData(column, Qt::WhatsThisRole, awhatsThis); }

Here is the call graph for this function:

QFont QTreeWidgetItem::font ( int  column  )  const [inline]

Returns the font used to render the text in the specified column.

See also:
setFont()

Definition at line 100 of file qtreewidget.h.

References data, and Qt::FontRole.

Referenced by PluginDialog::populateTreeWidget(), qSetBold(), and ConnectionWidget::setActive().

00101         { return qvariant_cast<QFont>(data(column, Qt::FontRole)); }

void QTreeWidgetItem::setFont ( int  column,
const QFont font 
) [inline]

Sets the font used to display the text in the given column to the given font.

See also:
font() setText() setForeground()

Definition at line 212 of file qtreewidget.h.

References Qt::FontRole, and setData().

Referenced by PluginDialog::populateTreeWidget(), and qSetBold().

00213 { setData(column, Qt::FontRole, afont); }

Here is the call graph for this function:

int QTreeWidgetItem::textAlignment ( int  column  )  const [inline]

Returns the text alignment for the label in the given column (see {Qt::AlignmentFlag}).

Definition at line 104 of file qtreewidget.h.

References data, and Qt::TextAlignmentRole.

00105         { return data(column, Qt::TextAlignmentRole).toInt(); }

void QTreeWidgetItem::setTextAlignment ( int  column,
int  alignment 
) [inline]

Sets the text alignment for the label in the given column to the alignment specified (see {Qt::AlignmentFlag}).

Definition at line 106 of file qtreewidget.h.

References Qt::TextAlignmentRole.

Referenced by MainWindow::addTorrent().

00107         { setData(column, Qt::TextAlignmentRole, alignment); }

QColor QTreeWidgetItem::backgroundColor ( int  column  )  const [inline]

This function is deprecated. Use background() instead.

Definition at line 109 of file qtreewidget.h.

References Qt::BackgroundColorRole, and data.

00110         { return qvariant_cast<QColor>(data(column, Qt::BackgroundColorRole)); }

void QTreeWidgetItem::setBackgroundColor ( int  column,
const QColor color 
) [inline]

This function is deprecated. Use setBackground() instead.

Definition at line 111 of file qtreewidget.h.

References Qt::BackgroundColorRole.

00112         { setData(column, Qt::BackgroundColorRole, color); }

QBrush QTreeWidgetItem::background ( int  column  )  const [inline]

Since:
4.2
Returns the brush used to render the background of the specified column.

See also:
foreground()

Definition at line 114 of file qtreewidget.h.

References Qt::BackgroundRole, and data.

00115         { return qvariant_cast<QBrush>(data(column, Qt::BackgroundRole)); }

void QTreeWidgetItem::setBackground ( int  column,
const QBrush brush 
) [inline]

Since:
4.2
Sets the background brush of the label in the given column to the specified brush.

See also:
setForeground()

Definition at line 116 of file qtreewidget.h.

References Qt::BackgroundRole.

00117         { setData(column, Qt::BackgroundRole, brush); }

QColor QTreeWidgetItem::textColor ( int  column  )  const [inline]

This function is deprecated. Use foreground() instead.

Definition at line 119 of file qtreewidget.h.

References data, and Qt::TextColorRole.

00120         { return qvariant_cast<QColor>(data(column, Qt::TextColorRole)); }

void QTreeWidgetItem::setTextColor ( int  column,
const QColor color 
) [inline]

This function is deprecated. Use setForeground() instead.

Definition at line 121 of file qtreewidget.h.

References Qt::TextColorRole.

00122         { setData(column, Qt::TextColorRole, color); }

QBrush QTreeWidgetItem::foreground ( int  column  )  const [inline]

Since:
4.2
Returns the brush used to render the foreground (e.g. text) of the specified column.

See also:
background()

Definition at line 124 of file qtreewidget.h.

References data, and Qt::ForegroundRole.

00125         { return qvariant_cast<QBrush>(data(column, Qt::ForegroundRole)); }

void QTreeWidgetItem::setForeground ( int  column,
const QBrush brush 
) [inline]

Since:
4.2
Sets the foreground brush of the label in the given column to the specified brush.

See also:
setBackground()

Definition at line 126 of file qtreewidget.h.

References Qt::ForegroundRole.

00127         { setData(column, Qt::ForegroundRole, brush); }

Qt::CheckState QTreeWidgetItem::checkState ( int  column  )  const [inline]

Returns the check state of the label in the given column.

See also:
Qt::CheckState

Definition at line 129 of file qtreewidget.h.

References Qt::CheckStateRole, and data.

Referenced by childrenCheckState(), MainWindow::markUnmarkFonts(), QTreeWidgetItemIterator::matchesFlags(), and MainWindow::updateStyles().

00130         { return static_cast<Qt::CheckState>(data(column, Qt::CheckStateRole).toInt()); }

void QTreeWidgetItem::setCheckState ( int  column,
Qt::CheckState  state 
) [inline]

Sets the item in the given column check state to be state.

See also:
checkState()

Definition at line 131 of file qtreewidget.h.

References Qt::CheckStateRole.

Referenced by PreviewDialog::addPage(), MainWindow::markUnmarkFonts(), MainWindow::setupFontTree(), and MainWindow::updateStyles().

00132         { setData(column, Qt::CheckStateRole, state); }

QSize QTreeWidgetItem::sizeHint ( int  column  )  const [inline]

Since:
4.1
Returns the size hint set for the tree item in the given column (see {QSize}).

Definition at line 134 of file qtreewidget.h.

References data, and Qt::SizeHintRole.

00135         { return qvariant_cast<QSize>(data(column, Qt::SizeHintRole)); }

void QTreeWidgetItem::setSizeHint ( int  column,
const QSize size 
) [inline]

Since:
4.1
Sets the size hint for the tree item in the given column to be size. If no size hint is set, the item delegate will compute the size hint based on the item data.

Definition at line 136 of file qtreewidget.h.

References size, and Qt::SizeHintRole.

00137         { setData(column, Qt::SizeHintRole, size); }

QVariant QTreeWidgetItem::data ( int  column,
int  role 
) const [virtual]

Returns the value for the item's column and role.

Definition at line 1513 of file qtreewidget.cpp.

References QVector< T >::at(), QList< T >::at(), Qt::CheckStateRole, children, childrenCheckState(), QList< T >::count(), display, Qt::DisplayRole, Qt::EditRole, i, itemFlags, Qt::ItemIsTristate, QVector< T >::size(), QWidgetItemData::value, and values.

Referenced by qdesigner_internal::WidgetBoxTreeView::addWidget(), qdesigner_internal::WidgetBoxTreeView::category(), childrenCheckState(), qdesigner_internal::WidgetBoxTreeView::contextMenuEvent(), QTreeModel::data(), XbelGenerator::generateItem(), qdesigner_internal::WidgetBoxTreeView::handleMousePress(), QTreeModel::headerData(), qdesigner_internal::WidgetBoxTreeView::itemToWidget(), HelpDialog::locateContents(), HelpDialog::locateLink(), NewForm::on_treeWidget_currentItemChanged(), NewForm::on_treeWidget_itemActivated(), MainWindow::printPage(), setData(), MainWindow::showFont(), qdesigner_internal::ObjectInspector::slotPopupContextMenu(), qdesigner_internal::ObjectInspector::slotSelectionChanged(), qdesigner_internal::WidgetBoxTreeView::updateItemData(), and SettingsTree::updateSetting().

01514 {
01515     switch (role) {
01516     case Qt::EditRole:
01517     case Qt::DisplayRole:
01518         if (column >= 0 && column < display.count())
01519             return display.at(column);
01520         break;
01521     case Qt::CheckStateRole:
01522         // special case for check state in tristate
01523         if (children.count() && (itemFlags & Qt::ItemIsTristate))
01524             return childrenCheckState(column);
01525    default:
01526         if (column >= 0 && column < values.size()) {
01527             const QVector<QWidgetItemData> &column_values = values.at(column);
01528             for (int i = 0; i < column_values.count(); ++i)
01529                 if (column_values.at(i).role == role)
01530                     return column_values.at(i).value;
01531         }
01532     }
01533     return QVariant();
01534 }

Here is the call graph for this function:

void QTreeWidgetItem::setData ( int  column,
int  role,
const QVariant value 
) [virtual]

Sets the value for the item's column and role to the given value.

The role describes the type of data specified by value, and is defined by the Qt::ItemDataRole enum.

Definition at line 1438 of file qtreewidget.cpp.

References QVector< T >::append(), QList< T >::append(), QVector< T >::at(), QList< T >::at(), Qt::CheckStateRole, child(), children, QList< T >::count(), QVector< T >::count(), data(), display, Qt::DisplayRole, Qt::EditRole, QTreeModel::emitDataChanged(), QTreeModel::headerItem, i, QVariant::isValid(), itemFlags, Qt::ItemIsTristate, QAbstractItemView::model(), p, par, QVector< T >::resize(), QWidgetItemData::role, QTreeModel::setColumnCount(), setData(), value, QVector< T >::value(), QWidgetItemData::value, values, and view.

Referenced by XbelHandler::createChildItem(), qdesigner_internal::WidgetBoxTreeView::indexOfScratchpad(), HelpDialog::insertContents(), NewForm::loadFrom(), setData(), QTreeModel::setData(), setFont(), QTreeModel::setHeaderData(), setIcon(), setStatusTip(), setText(), setToolTip(), MainWindow::setupFontTree(), setWhatsThis(), qdesigner_internal::WidgetBoxTreeView::updateItemData(), and qdesigner_internal::WidgetBoxTreeView::widgetToItem().

01439 {
01440     if (column < 0)
01441         return;
01442 
01443     QTreeModel *model = (view ? ::qobject_cast<QTreeModel*>(view->model()) : 0);
01444     switch (role) {
01445     case Qt::EditRole:
01446     case Qt::DisplayRole: {
01447         if (values.count() <= column) {
01448             if (model && this == model->headerItem)
01449                 model->setColumnCount(column + 1);
01450             else
01451                 values.resize(column + 1);
01452         }
01453         if (display.count() <= column) {
01454             for (int i = display.count() - 1; i < column - 1; ++i)
01455                 display.append(QVariant());
01456             display.append(value);
01457         } else if (display[column] != value) {
01458             display[column] = value;
01459         } else {
01460             return; // value is unchanged
01461         }
01462     } break;
01463     case Qt::CheckStateRole:
01464         if (itemFlags & Qt::ItemIsTristate) {
01465             for (int i = 0; i < children.count(); ++i) {
01466                 QTreeWidgetItem *child = children.at(i);
01467                 if (child->data(column, role).isValid()) {// has a CheckState
01468                     Qt::ItemFlags f = itemFlags; // a little hack to avoid multiple dataChanged signals
01469                     itemFlags &= ~Qt::ItemIsTristate;
01470                     child->setData(column, role, value);
01471                     itemFlags = f;
01472                 }
01473             }
01474         }
01475         // Don't break, but fall through
01476     default:
01477         if (column < values.count()) {
01478             bool found = false;
01479             QVector<QWidgetItemData> column_values = values.at(column);
01480             for (int i = 0; i < column_values.count(); ++i) {
01481                 if (column_values.at(i).role == role) {
01482                     if (column_values.at(i).value == value)
01483                         return; // value is unchanged
01484                     values[column][i].value = value;
01485                     found = true;
01486                     break;
01487                 }
01488             }
01489             if (!found)
01490                 values[column].append(QWidgetItemData(role, value));
01491         } else {
01492             if (model && this == model->headerItem)
01493                 model->setColumnCount(column + 1);
01494             else
01495                 values.resize(column + 1);
01496             values[column].append(QWidgetItemData(role, value));
01497         }
01498     }
01499 
01500     if (model) {
01501         model->emitDataChanged(this, column);
01502         if (role == Qt::CheckStateRole) {
01503             QTreeWidgetItem *p;
01504             for (p = par; p && (p->itemFlags & Qt::ItemIsTristate); p = p->par)
01505                 model->emitDataChanged(p, column);
01506         }
01507     }
01508 }

Here is the call graph for this function:

bool QTreeWidgetItem::operator< ( const QTreeWidgetItem other  )  const [virtual]

Returns true if the text in the item is less than the text in the other item, otherwise returns false.

Definition at line 1541 of file qtreewidget.cpp.

References QTreeWidget::sortColumn(), text(), and view.

01542 {
01543     int column = view ? view->sortColumn() : 0;
01544     return text(column) < other.text(column);
01545 }

Here is the call graph for this function:

void QTreeWidgetItem::read ( QDataStream in  )  [virtual]

Reads the item from stream in. This only reads data into a single item.

See also:
write()

Definition at line 1554 of file qtreewidget.cpp.

References QList< T >::at(), QList< T >::clear(), display, Qt::DisplayRole, i, QDataStream::Qt_4_2, QVariant::value(), values, and QDataStream::version().

Referenced by operator>>().

01555 {
01556     // convert from streams written before we introduced display (4.2.0)
01557     if (in.version() < QDataStream::Qt_4_2) {
01558         display.clear();
01559         in >> values;
01560         // move the display value over to the display string list
01561         for (int column = 0; column < values.count(); ++column) {
01562             display << QVariant();
01563             for (int i = 0; i < values.at(column).count(); ++i) {
01564                 if (values.at(column).at(i).role == Qt::DisplayRole) {
01565                     display[column] = values.at(column).at(i).value;
01566                     values[column].remove(i--);
01567                 }
01568             }
01569         }
01570     } else {
01571         in >> values >> display;
01572     }
01573 }

Here is the call graph for this function:

void QTreeWidgetItem::write ( QDataStream out  )  const [virtual]

Writes the item to stream out. This only writes data from one single item.

See also:
read()

Definition at line 1580 of file qtreewidget.cpp.

References display, and values.

Referenced by operator<<().

01581 {
01582     out << values << display;
01583 }

QTreeWidgetItem & QTreeWidgetItem::operator= ( const QTreeWidgetItem other  ) 

Assigns other's data and flags to this item. Note that type() and treeWidget() are not copied.

This function is useful when reimplementing clone().

See also:
data(), flags()

Definition at line 1609 of file qtreewidget.cpp.

References display, itemFlags, and values.

01610 {
01611     values = other.values;
01612     display = other.display;
01613     itemFlags = other.itemFlags;
01614     return *this;
01615 }

QTreeWidgetItem * QTreeWidgetItem::parent (  )  const [inline]

Returns the item's parent.

See also:
child()

Definition at line 150 of file qtreewidget.h.

Referenced by clone(), qdesigner_internal::WidgetBoxTreeView::contextMenuEvent(), XbelHandler::endElement(), QTreeWidgetItemIteratorPrivate::ensureValidIterator(), qdesigner_internal::WidgetBoxTreeView::handleMousePress(), QTreeModel::index(), QTreeWidgetItemIteratorPrivate::next(), QTreeWidgetItemIteratorPrivate::nextSibling(), qdesigner_internal::TreeWidgetEditor::on_deleteItemButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemDownButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemLeftButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemRightButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemUpButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_newItemButton_clicked(), ConnectionWidget::on_tree_currentItemChanged(), ConnectionWidget::on_tree_itemActivated(), NewForm::on_treeWidget_currentItemChanged(), NewForm::on_treeWidget_itemPressed(), QTreeModel::parent(), QTreeWidgetItemIteratorPrivate::previous(), QTreeWidgetItem(), QTreeWidgetItemIterator::QTreeWidgetItemIterator(), qdesigner_internal::WidgetBoxTreeView::removeCurrentItem(), MainWindow::showFont(), ConnectionWidget::showMetaData(), qdesigner_internal::TreeWidgetEditor::updateEditor(), qdesigner_internal::WidgetBoxTreeView::updateItemData(), SettingsTree::updateSetting(), and MainWindow::updateStyles().

00150 { return par; }

QTreeWidgetItem * QTreeWidgetItem::child ( int  index  )  const [inline]

Returns the item at the given index in the list of the item's children.

See also:
parent()

Definition at line 151 of file qtreewidget.h.

Referenced by addChild(), qdesigner_internal::WidgetBoxTreeView::category(), clone(), qdesigner_internal::TreeWidgetEditor::copyContents(), XbelGenerator::generateItem(), QTreeModel::index(), insertChild(), insertChildren(), HelpDialog::locateLink(), QTreeWidgetItemIteratorPrivate::next(), QTreeWidgetItemIteratorPrivate::nextSibling(), qdesigner_internal::TreeWidgetEditor::on_deleteItemButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemRightButton_clicked(), QTreeWidgetItemIteratorPrivate::previous(), recursiveTranslate(), QAbstractFormBuilder::saveTreeWidgetExtraInfo(), setData(), MainWindow::showFont(), MainWindow::updateStyles(), qdesigner_internal::WidgetBoxTreeView::widget(), and ~QTreeWidgetItem().

00151                                                    {
00152         if (index < 0 || index >= children.size())
00153             return 0;
00154         return children.at(index);
00155     }

int QTreeWidgetItem::childCount (  )  const [inline]

Returns the number of child items.

Definition at line 156 of file qtreewidget.h.

Referenced by qdesigner_internal::WidgetBoxTreeView::category(), QTreeModel::clear(), clone(), qdesigner_internal::TreeWidgetEditor::copyContents(), XbelGenerator::generateItem(), QTreeModel::hasChildren(), insertChildren(), HelpDialog::locateLink(), QTreeWidgetItemIterator::matchesFlags(), QTreeWidgetItemIteratorPrivate::next(), qdesigner_internal::TreeWidgetEditor::on_deleteItemButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemDownButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemRightButton_clicked(), QTreeWidgetItemIteratorPrivate::previous(), recursiveTranslate(), qdesigner_internal::WidgetBoxTreeView::removeWidget(), QTreeModel::rowCount(), QAbstractFormBuilder::saveTreeWidgetExtraInfo(), qdesigner_internal::TreeWidgetEditor::updateEditor(), MainWindow::updateStyles(), qdesigner_internal::WidgetBoxTreeView::widget(), and qdesigner_internal::WidgetBoxTreeView::widgetCount().

00156 { return children.count(); }

int QTreeWidgetItem::columnCount (  )  const [inline]

Returns the number of columns in the item.

Definition at line 157 of file qtreewidget.h.

References values.

Referenced by QTreeModel::columnCount(), QTreeModel::itemChanged(), QTreeWidgetItem(), recursiveTranslate(), and QTreeWidget::setHeaderItem().

00157 { return values.count(); }

int QTreeWidgetItem::indexOfChild ( QTreeWidgetItem child  )  const [inline]

Returns the index of the given child in the item's list of children.

Definition at line 215 of file qtreewidget.h.

References children, and QList< T >::indexOf().

Referenced by qdesigner_internal::TreeWidgetEditor::on_deleteItemButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemDownButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemLeftButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemRightButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemUpButton_clicked(), QTreeWidgetItem(), and qdesigner_internal::TreeWidgetEditor::updateEditor().

00216 { (void)const_cast<QTreeWidgetItem*>(this)->takeChild(-1); return children.indexOf(achild); }

Here is the call graph for this function:

void QTreeWidgetItem::addChild ( QTreeWidgetItem child  ) 

Appends the child item to the list of children.

See also:
insertChild() takeChild()

Definition at line 1624 of file qtreewidget.cpp.

References child(), children, QList< T >::count(), and insertChild().

Referenced by QTreeWidgetItem().

01625 {
01626     insertChild(children.count(), child);
01627 }

Here is the call graph for this function:

void QTreeWidgetItem::insertChild ( int  index,
QTreeWidgetItem child 
)

Inserts the child item at index in the list of children.

If the child has already been inserted somewhere else it wont be inserted again.

Definition at line 1634 of file qtreewidget.cpp.

References QList< T >::begin(), c, child(), children, QList< T >::count(), QList< T >::end(), QTreeView::header(), i, QList< T >::insert(), QVector< T >::isEmpty(), QTreeWidget::isSortingEnabled(), QAbstractItemView::model(), par, QStack< T >::pop(), QStack< T >::push(), qMax(), QHeaderView::sortIndicatorOrder(), and view.

Referenced by addChild(), insertChildren(), qdesigner_internal::TreeWidgetEditor::on_moveItemDownButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemLeftButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemRightButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemUpButton_clicked(), and QTreeWidgetItem().

01635 {
01636     if (index < 0 || index > children.count() || child == 0 || child->view != 0 || child->par != 0)
01637         return;
01638 
01639     if (QTreeModel *model = (view ? ::qobject_cast<QTreeModel*>(view->model()) : 0)) {
01640         if (model->rootItem == this)
01641             child->par = 0;
01642         else
01643             child->par = this;
01644         if (view->isSortingEnabled()) {
01645 #if 0
01646             Qt::SortOrder order = view->header()->sortIndicatorOrder();
01647             QList<QTreeWidgetItem*>::iterator it;
01648             it = model->sortedInsertionIterator(children.begin(), children.end(),
01649                                                 order, child);
01650             index = qMax(it - children.begin(), 0);
01651 #else
01652             // do a delayed sort instead
01653             index = children.count(); // append
01654             model->sortPending = true;
01655 #endif
01656         }
01657         model->beginInsertItems(this, index, 1);
01658         int cols = model->columnCount();
01659         QStack<QTreeWidgetItem*> stack;
01660         stack.push(child);
01661         while (!stack.isEmpty()) {
01662             QTreeWidgetItem *i = stack.pop();
01663             i->view = view;
01664             i->values.reserve(cols);
01665             for (int c = 0; c < i->children.count(); ++c)
01666                 stack.push(i->children.at(c));
01667         }
01668         children.insert(index, child);
01669         model->endInsertItems();
01670     } else {
01671         child->par = this;
01672         children.insert(index, child);
01673     }
01674 }

Here is the call graph for this function:

QTreeWidgetItem * QTreeWidgetItem::takeChild ( int  index  ) 

Removes the item at index and returns it, otherwise return 0.

Definition at line 1679 of file qtreewidget.cpp.

References c, children, QList< T >::count(), i, QVector< T >::isEmpty(), QAbstractItemView::model(), par, QStack< T >::pop(), QStack< T >::push(), QList< T >::takeAt(), and view.

Referenced by qdesigner_internal::TreeWidgetEditor::on_moveItemDownButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemLeftButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemRightButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_moveItemUpButton_clicked(), QTreeModel::removeRows(), and qdesigner_internal::WidgetBoxTreeView::removeWidget().

01680 {
01681     if (index >= 0 && index < children.count()) {
01682         QTreeModel *model = (view ? ::qobject_cast<QTreeModel*>(view->model()) : 0);
01683         if (model && model->executePendingSort())
01684             model = 0; // no need to emit signals
01685         if (model) model->beginRemoveItems(this, index, 1);
01686         QTreeWidgetItem *item = children.takeAt(index);
01687         item->par = 0;
01688         QStack<QTreeWidgetItem*> stack;
01689         stack.push(item);
01690         while (!stack.isEmpty()) {
01691             QTreeWidgetItem *i = stack.pop();
01692             i->view = 0;
01693             for (int c = 0; c < i->children.count(); ++c)
01694                 stack.push(i->children.at(c));
01695         }
01696         if (model) model->endRemoveRows();
01697         return item;
01698     }
01699     return 0;
01700 }

Here is the call graph for this function:

void QTreeWidgetItem::addChildren ( const QList< QTreeWidgetItem * > &  children  ) 

Since:
4.1
Appends the given list of children to the item.

See also:
insertChildren() takeChildren()

Definition at line 1709 of file qtreewidget.cpp.

References children, and insertChildren().

01710 {
01711     insertChildren(this->children.count(), children);
01712 }

Here is the call graph for this function:

void QTreeWidgetItem::insertChildren ( int  index,
const QList< QTreeWidgetItem * > &  children 
)

Since:
4.1
Inserts the given list of children into the list of the item children at index .

Children that have already been inserted somewhere else wont be inserted.

Definition at line 1721 of file qtreewidget.cpp.

References QList< T >::append(), QList< T >::at(), c, child(), childCount(), children, QList< T >::count(), i, insertChild(), QList< T >::isEmpty(), QVector< T >::isEmpty(), QTreeWidget::isSortingEnabled(), QAbstractItemView::model(), n, par, QStack< T >::pop(), QStack< T >::push(), QTreeModel::rootItem, and view.

Referenced by addChildren().

01722 {
01723     if (view && view->isSortingEnabled()) {
01724         for (int n = 0; n < children.count(); ++n)
01725             insertChild(index, children.at(n));
01726         return;
01727     }
01728     QTreeModel *model = (view ? ::qobject_cast<QTreeModel*>(view->model()) : 0);
01729     QStack<QTreeWidgetItem*> stack;
01730     QList<QTreeWidgetItem*> itemsToInsert;
01731     for (int n = 0; n < children.count(); ++n) {
01732         QTreeWidgetItem *child = children.at(n);
01733         if (child->view || child->par)
01734             continue;
01735         itemsToInsert.append(child);
01736         if (view && model) {
01737             if (child->childCount() == 0)
01738                 child->view = view;
01739             else
01740                 stack.push(child);
01741         }
01742         if (model && (model->rootItem == this))
01743             child->par = 0;
01744         else
01745             child->par = this;
01746     }
01747     if (!itemsToInsert.isEmpty()) {
01748         while (!stack.isEmpty()) {
01749             QTreeWidgetItem *i = stack.pop();
01750             i->view = view;
01751             for (int c = 0; c < i->children.count(); ++c)
01752                 stack.push(i->children.at(c));
01753         }
01754         if (model) model->beginInsertItems(this, index, itemsToInsert.count());
01755         for (int n = 0; n < itemsToInsert.count(); ++n)
01756             this->children.insert(index + n, itemsToInsert.at(n));
01757         if (model) model->endInsertItems();
01758     }
01759 }

Here is the call graph for this function:

QList< QTreeWidgetItem * > QTreeWidgetItem::takeChildren (  ) 

Since:
4.1
Removes the list of children and returns it, otherwise return an empty list.

Definition at line 1766 of file qtreewidget.cpp.

References QList< T >::at(), c, children, QList< T >::clear(), QList< T >::count(), i, QVector< T >::isEmpty(), QAbstractItemView::model(), n, par, QStack< T >::pop(), QStack< T >::push(), and view.

01767 {
01768     QList<QTreeWidgetItem*> removed;
01769     if (children.count() > 0) {
01770         QTreeModel *model = (view ? ::qobject_cast<QTreeModel*>(view->model()) : 0);
01771         if (model && model->executePendingSort())
01772             model = 0; // no need to emit signals
01773         if (model) model->beginRemoveItems(this, 0, children.count());
01774         for (int n = 0; n < children.count(); ++n) {
01775             QTreeWidgetItem *item = children.at(n);
01776             item->par = 0;
01777             QStack<QTreeWidgetItem*> stack;
01778             stack.push(item);
01779             while (!stack.isEmpty()) {
01780                 QTreeWidgetItem *i = stack.pop();
01781                 i->view = 0;
01782                 for (int c = 0; c < i->children.count(); ++c)
01783                     stack.push(i->children.at(c));
01784             }
01785         }
01786         removed = children;
01787         children.clear(); // detach
01788         if (model) model->endRemoveItems();
01789     }
01790     return removed;
01791 }

Here is the call graph for this function:

int QTreeWidgetItem::type (  )  const [inline]

Returns the type passed to the QTreeWidgetItem constructor.

Definition at line 168 of file qtreewidget.h.

00168 { return rtti; }

void QTreeWidgetItem::sortChildren ( int  column,
Qt::SortOrder  order 
) [inline]

Since:
4.2
Sorts the children of the item using the given order, by the values in the given column.

Definition at line 169 of file qtreewidget.h.

Referenced by QTreeModel::sort().

00170         { sortChildren(column, order, false); }

void QTreeWidgetItem::sortChildren ( int  column,
Qt::SortOrder  order,
bool  climb 
) [private]

Definition at line 1800 of file qtreewidget.cpp.

References QList< T >::begin(), children, QList< T >::end(), QAbstractItemView::model(), QTreeModel::sortItems(), and view.

01801 {
01802     QTreeModel *model = (view ? ::qobject_cast<QTreeModel*>(view->model()) : 0);
01803     if (!model)
01804         return;
01805     model->sortItems(&children, column, order);
01806     if (climb) {
01807         QList<QTreeWidgetItem*>::iterator it = children.begin();
01808         for (; it != children.end(); ++it)
01809             (*it)->sortChildren(column, order, climb);
01810     }
01811 }

Here is the call graph for this function:

QVariant QTreeWidgetItem::childrenCheckState ( int  column  )  const [private]

Definition at line 1821 of file qtreewidget.cpp.

References QList< T >::at(), Qt::Checked, checkState(), Qt::CheckStateRole, children, QList< T >::count(), data(), i, Qt::PartiallyChecked, Qt::Unchecked, and value.

Referenced by data().

01822 {
01823     if (column < 0)
01824         return QVariant();
01825     int checkedChildrenCount = 0;
01826     int uncheckedChildrenCount = 0;
01827     int validChildrenCount = 0;
01828     for (int i = 0; i < children.count(); ++i) {
01829         QVariant value = children.at(i)->data(column, Qt::CheckStateRole);
01830         if (!value.isValid())
01831             continue;
01832         Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt());
01833         if (checkState == Qt::Unchecked)
01834             ++uncheckedChildrenCount;
01835         else
01836             ++checkedChildrenCount; // includes partially checked items
01837         ++validChildrenCount;
01838     }
01839     if (checkedChildrenCount + uncheckedChildrenCount == 0)
01840         return QVariant(); // value was not defined
01841     if (checkedChildrenCount == validChildrenCount)
01842         return Qt::Checked;
01843     if (uncheckedChildrenCount == validChildrenCount)
01844         return Qt::Unchecked;
01845     return Qt::PartiallyChecked;
01846 }

Here is the call graph for this function:

void QTreeWidgetItem::itemChanged (  )  [private]

Definition at line 1851 of file qtreewidget.cpp.

References QAbstractItemView::model(), and view.

Referenced by setFlags().

01852 {
01853     if (QTreeModel *model = (view ? ::qobject_cast<QTreeModel*>(view->model()) : 0))
01854         model->itemChanged(this);
01855 }

Here is the call graph for this function:

void QTreeWidgetItem::executePendingSort (  )  const [private]

Definition at line 1860 of file qtreewidget.cpp.

References QAbstractItemView::model(), and view.

01861 {
01862     if (QTreeModel *model = (view ? ::qobject_cast<QTreeModel*>(view->model()) : 0))
01863         model->executePendingSort();
01864 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class QTreeModel [friend]

Definition at line 44 of file qtreewidget.h.

friend class QTreeWidget [friend]

Definition at line 45 of file qtreewidget.h.

friend class QTreeWidgetItemIterator [friend]

Definition at line 46 of file qtreewidget.h.

QDataStream & operator<< ( QDataStream out,
const QTreeWidgetItem item 
) [related]

Writes the tree widget item item to stream out.

This operator uses QTreeWidgetItem::write().

See also:
{Format of the QDataStream Operators}

Definition at line 1877 of file qtreewidget.cpp.

References write().

01878 {
01879     item.write(out);
01880     return out;
01881 }

Here is the call graph for this function:

QDataStream & operator>> ( QDataStream in,
QTreeWidgetItem item 
) [related]

Reads a tree widget item from stream in into item.

This operator uses QTreeWidgetItem::read().

See also:
{Format of the QDataStream Operators}

Definition at line 1892 of file qtreewidget.cpp.

References read().

01893 {
01894     item.read(in);
01895     return in;
01896 }

Here is the call graph for this function:


Member Data Documentation

int QTreeWidgetItem::rtti [private]

Definition at line 178 of file qtreewidget.h.

QVector< QVector<QWidgetItemData> > QTreeWidgetItem::values [private]

Definition at line 180 of file qtreewidget.h.

Referenced by data(), QTreeModel::insertColumns(), operator=(), QTreeWidgetItem(), read(), QTreeModel::setColumnCount(), setData(), and write().

QTreeWidget* QTreeWidgetItem::view [private]

Definition at line 181 of file qtreewidget.h.

Referenced by QTreeModel::clear(), executePendingSort(), insertChild(), insertChildren(), QTreeModel::insertRows(), isExpanded(), isHidden(), isSelected(), itemChanged(), QTreeWidgetItemIterator::matchesFlags(), operator<(), QTreeModel::QTreeModel(), QTreeWidgetItem(), QTreeWidgetItemIterator::QTreeWidgetItemIterator(), QTreeModel::setColumnCount(), setData(), setExpanded(), QTreeWidget::setHeaderItem(), setHidden(), setSelected(), sortChildren(), takeChild(), takeChildren(), QTreeModel::~QTreeModel(), and ~QTreeWidgetItem().

QVariantList QTreeWidgetItem::display [private]

Definition at line 182 of file qtreewidget.h.

Referenced by data(), QTreeModel::insertColumns(), operator=(), read(), QTreeModel::setColumnCount(), setData(), and write().

QTreeWidgetItem* QTreeWidgetItem::par [private]

Definition at line 183 of file qtreewidget.h.

Referenced by QTreeModel::clear(), insertChild(), insertChildren(), QTreeModel::insertRows(), setData(), takeChild(), takeChildren(), and ~QTreeWidgetItem().

QList<QTreeWidgetItem*> QTreeWidgetItem::children [private]

Definition at line 184 of file qtreewidget.h.

Referenced by addChild(), addChildren(), childrenCheckState(), QTreeModel::clear(), clone(), data(), QTreeModel::ensureSorted(), QTreeModel::index(), indexOfChild(), insertChild(), insertChildren(), QTreeModel::insertColumns(), QTreeModel::insertRows(), QTreeWidgetItemIterator::QTreeWidgetItemIterator(), QTreeModel::removeRows(), setData(), sortChildren(), takeChild(), takeChildren(), and ~QTreeWidgetItem().

Qt::ItemFlags QTreeWidgetItem::itemFlags [private]

Definition at line 185 of file qtreewidget.h.

Referenced by data(), operator=(), setData(), and setFlags().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 19:38:55 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1