Qt 4.8
Classes | Public Functions | Static Public Functions | Protected Functions | Private Functions | Properties | Friends | List of all members
QTreeModel Class Reference

#include <qtreewidget_p.h>

Inheritance diagram for QTreeModel:
QAbstractItemModel QObject

Classes

struct  SkipSorting
 

Public Functions

void clear ()
 Removes all items in the model. More...
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 Returns the number of columns in the item referred to by the given index. More...
 
QModelIndex createIndexFromItem (int row, int col, QTreeWidgetItem *item) const
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 Returns the data corresponding to the given model index and role. More...
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 Handles the data supplied by a drag and drop operation that ended with the given action. More...
 
void ensureSorted (int column, Qt::SortOrder order, int start, int end, const QModelIndex &parent)
 
Qt::ItemFlags flags (const QModelIndex &index) const
 Returns the flags for the item referred to the given index. More...
 
bool hasChildren (const QModelIndex &parent) const
 Returns true if parent has any children; otherwise returns false. More...
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const
 Returns the header data corresponding to the given header section, orientation and data role. More...
 
QModelIndex index (const QTreeWidgetItem *item, int column) const
 Returns the model index that refers to the tree view item and column. More...
 
QModelIndex index (int row, int column, const QModelIndex &parent) const
 Returns the model index with the given row, column and parent. More...
 
bool insertColumns (int column, int count, const QModelIndex &)
 
bool insertRows (int row, int count, const QModelIndex &)
 
QMimeDatainternalMimeData () const
 
QTreeWidgetItemitem (const QModelIndex &index) const
 Returns the tree view item corresponding to the index given. More...
 
void itemChanged (QTreeWidgetItem *item)
 
QMap< int, QVariantitemData (const QModelIndex &index) const
 Returns a map with values for all predefined roles in the model for the item at the given index. More...
 
QMimeDatamimeData (const QModelIndexList &indexes) const
 Returns an object that contains serialized items of data corresponding to the list of indexes specified. More...
 
QStringList mimeTypes () const
 Returns a list of MIME types that can be used to describe a list of model indexes. More...
 
QModelIndex parent (const QModelIndex &child) const
 Returns the parent model index of the index given as the child. More...
 
 QTreeModel (int columns=0, QTreeWidget *parent=0)
 Constructs a tree model with a parent object and the given number of columns. More...
 
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 
int rowCount (const QModelIndex &parent) const
 Returns the number of rows in the parent model index. More...
 
void setColumnCount (int columns)
 Sets the number of columns in the tree model. More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role)
 Sets the data for the item specified by the index and role to that referred to by the value. More...
 
bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role)
 Sets the header data for the item specified by the header section, orientation and data role to the given value. More...
 
void sort (int column, Qt::SortOrder order)
 Sorts the entire tree in the model in the given order, by the values in the given column. More...
 
Qt::DropActions supportedDropActions () const
 Returns the drop actions supported by this model. More...
 
QTreeWidgetview () const
 
 ~QTreeModel ()
 Destroys this tree model. More...
 
- Public Functions inherited from QAbstractItemModel
virtual QModelIndex buddy (const QModelIndex &index) const
 Returns a model index for the buddy of the item represented by index. More...
 
virtual bool canFetchMore (const QModelIndex &parent) const
 Returns true if there is more data available for parent; otherwise returns false. More...
 
virtual void fetchMore (const QModelIndex &parent)
 Fetches any available data for the items with the parent specified by the parent index. More...
 
bool hasIndex (int row, int column, const QModelIndex &parent=QModelIndex()) const
 Returns true if the model returns a valid QModelIndex for row and column with parent, otherwise returns false. More...
 
bool insertColumn (int column, const QModelIndex &parent=QModelIndex())
 Inserts a single column before the given column in the child items of the parent specified. More...
 
bool insertRow (int row, const QModelIndex &parent=QModelIndex())
 Inserts a single row before the given row in the child items of the parent specified. More...
 
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
 Returns a list of indexes for the items in the column of the start index where data stored under the given role matches the specified value. More...
 
 QAbstractItemModel (QObject *parent=0)
 Constructs an abstract item model with the given parent. More...
 
bool removeColumn (int column, const QModelIndex &parent=QModelIndex())
 Removes the given column from the child items of the parent specified. More...
 
virtual bool removeColumns (int column, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, removes count columns starting with the given column under parent parent from the model. More...
 
bool removeRow (int row, const QModelIndex &parent=QModelIndex())
 Removes the given row from the child items of the parent specified. More...
 
const QHash< int, QByteArray > & roleNames () const
 Returns the model's role names. More...
 
virtual bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles)
 Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole. More...
 
void setSupportedDragActions (Qt::DropActions)
 Sets the supported drag actions for the items in the model. More...
 
QModelIndex sibling (int row, int column, const QModelIndex &idx) const
 Returns the sibling at row and column for the item at index, or an invalid QModelIndex if there is no sibling at that location. More...
 
virtual QSize span (const QModelIndex &index) const
 Returns the row and column span of the item represented by index. More...
 
Qt::DropActions supportedDragActions () const
 Returns the actions supported by the data in this model. More...
 
virtual ~QAbstractItemModel ()
 Destroys the abstract item model. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static bool itemGreaterThan (const QPair< QTreeWidgetItem *, int > &left, const QPair< QTreeWidgetItem *, int > &right)
 Returns true if the value of the left item is greater than the value of the right item. More...
 
static bool itemLessThan (const QPair< QTreeWidgetItem *, int > &left, const QPair< QTreeWidgetItem *, int > &right)
 Returns true if the value of the left item is less than the value of the right item. More...
 
static QList< QTreeWidgetItem * >::iterator sortedInsertionIterator (const QList< QTreeWidgetItem *>::iterator &begin, const QList< QTreeWidgetItem *>::iterator &end, Qt::SortOrder order, QTreeWidgetItem *item)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Protected Functions

void beginInsertItems (QTreeWidgetItem *parent, int row, int count)
 
void beginRemoveItems (QTreeWidgetItem *parent, int row, int count)
 
void emitDataChanged (QTreeWidgetItem *item, int column)
 Emits the dataChanged() signal for the given item. More...
 
void endInsertItems ()
 
void endRemoveItems ()
 
 QTreeModel (QTreeModelPrivate &, QTreeWidget *parent=0)
 
void sortItems (QList< QTreeWidgetItem *> *items, int column, Qt::SortOrder order)
 
void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Functions inherited from QAbstractItemModel
void beginInsertColumns (const QModelIndex &parent, int first, int last)
 Begins a column insertion operation. More...
 
void beginInsertRows (const QModelIndex &parent, int first, int last)
 Begins a row insertion operation. More...
 
bool beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn)
 Begins a column move operation. More...
 
bool beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow)
 Begins a row move operation. More...
 
void beginRemoveColumns (const QModelIndex &parent, int first, int last)
 Begins a column removal operation. More...
 
void beginRemoveRows (const QModelIndex &parent, int first, int last)
 Begins a row removal operation. More...
 
void beginResetModel ()
 Begins a model reset operation. More...
 
void changePersistentIndex (const QModelIndex &from, const QModelIndex &to)
 Changes the QPersistentModelIndex that is equal to the given from model index to the given to model index. More...
 
void changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to)
 Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list to the given to model index list. More...
 
QModelIndex createIndex (int row, int column, void *data=0) const
 Creates a model index for the given row and column with the internal pointer ptr. More...
 
QModelIndex createIndex (int row, int column, int id) const
 Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead. More...
 
QModelIndex createIndex (int row, int column, quint32 id) const
 Creates a model index for the given row and column with the internal identifier, id. More...
 
bool decodeData (int row, int column, const QModelIndex &parent, QDataStream &stream)
 
void encodeData (const QModelIndexList &indexes, QDataStream &stream) const
 
void endInsertColumns ()
 Ends a column insertion operation. More...
 
void endInsertRows ()
 Ends a row insertion operation. More...
 
void endMoveColumns ()
 Ends a column move operation. More...
 
void endMoveRows ()
 Ends a row move operation. More...
 
void endRemoveColumns ()
 Ends a column removal operation. More...
 
void endRemoveRows ()
 Ends a row removal operation. More...
 
void endResetModel ()
 Completes a model reset operation. More...
 
QModelIndexList persistentIndexList () const
 Returns the list of indexes stored as persistent indexes in the model. More...
 
 QAbstractItemModel (QAbstractItemModelPrivate &dd, QObject *parent=0)
 
void reset ()
 Resets the model to its original state in any attached views. More...
 
void setRoleNames (const QHash< int, QByteArray > &roleNames)
 Sets the model's role names to roleNames. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 

Private Functions

bool executePendingSort () const
 
bool isChanging () const
 

Properties

QModelIndexList cachedIndexes
 
QTreeWidgetItemheaderItem
 
QList< QTreeWidgetItemIterator * > iterators
 
QTreeWidgetItemrootItem
 
bool skipPendingSort
 
QBasicTimer sortPendingTimer
 

Friends

class QTreeWidget
 
class QTreeWidgetItem
 
class QTreeWidgetItemIterator
 
class QTreeWidgetItemIteratorPrivate
 
class QTreeWidgetItemPrivate
 
class QTreeWidgetPrivate
 
struct SkipSorting
 

Additional Inherited Members

- Public Slots inherited from QAbstractItemModel
virtual void revert ()
 Lets the model know that it should discard cached information. More...
 
virtual bool submit ()
 Lets the model know that it should submit cached information to permanent storage. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QAbstractItemModel
void columnsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted just before columns are inserted into the model. More...
 
void columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 This signal is emitted just before columns are moved within the model. More...
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted just before columns are removed from the model. More...
 
void columnsInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted after columns have been inserted into the model. More...
 
void columnsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
 This signal is emitted after columns have been moved within the model. More...
 
void columnsRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted after columns have been removed from the model. More...
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 This signal is emitted whenever the data in an existing item changes. More...
 
void headerDataChanged (Qt::Orientation orientation, int first, int last)
 This signal is emitted whenever a header is changed. More...
 
void layoutAboutToBeChanged ()
 This signal is emitted just before the layout of a model is changed. More...
 
void layoutChanged ()
 This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted. More...
 
void modelAboutToBeReset ()
 This signal is emitted when reset() is called, before the model's internal state (e. More...
 
void modelReset ()
 This signal is emitted when reset() is called, after the model's internal state (e. More...
 
void rowsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted just before rows are inserted into the model. More...
 
void rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 This signal is emitted just before rows are moved within the model. More...
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted just before rows are removed from the model. More...
 
void rowsInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted after rows have been inserted into the model. More...
 
void rowsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
 This signal is emitted after rows have been moved within the model. More...
 
void rowsRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted after rows have been removed from the model. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QAbstractItemModel
void resetInternalData ()
 This slot is called just after the internal data of a model is cleared while it is being reset. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 71 of file qtreewidget_p.h.

Constructors and Destructors

◆ QTreeModel() [1/2]

QTreeModel::QTreeModel ( int  columns = 0,
QTreeWidget parent = 0 
)
explicit

Constructs a tree model with a parent object and the given number of columns.

Warning
This function is not part of the public interface.

Definition at line 124 of file qtreewidget.cpp.

Referenced by createIndexFromItem().

127 {
128  rootItem->view = parent;
131  setColumnCount(columns);
132 }
QTreeWidget * view
Definition: qtreewidget.h:219
QTreeWidgetItem * headerItem
QTreeWidgetItem * rootItem
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
Qt::ItemFlags itemFlags
Definition: qtreewidget.h:223
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QAbstractItemModel(QObject *parent=0)
Constructs an abstract item model with the given parent.
void setColumnCount(int columns)
Sets the number of columns in the tree model.
bool skipPendingSort

◆ ~QTreeModel()

QTreeModel::~QTreeModel ( )

Destroys this tree model.

Warning
This function is not part of the public interface.

Definition at line 157 of file qtreewidget.cpp.

158 {
159  clear();
160  delete headerItem;
161  rootItem->view = 0;
162  delete rootItem;
163 }
void clear()
Removes all items in the model.
QTreeWidget * view
Definition: qtreewidget.h:219
QTreeWidgetItem * headerItem
QTreeWidgetItem * rootItem

◆ QTreeModel() [2/2]

QTreeModel::QTreeModel ( QTreeModelPrivate dd,
QTreeWidget parent = 0 
)
protected
Warning
This function is not part of the public interface.

Definition at line 139 of file qtreewidget.cpp.

140  : QAbstractItemModel(dd, parent), rootItem(new QTreeWidgetItem),
142 {
143  rootItem->view = parent;
146 }
QTreeWidget * view
Definition: qtreewidget.h:219
QTreeWidgetItem * headerItem
QTreeWidgetItem * rootItem
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
Qt::ItemFlags itemFlags
Definition: qtreewidget.h:223
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QAbstractItemModel(QObject *parent=0)
Constructs an abstract item model with the given parent.
bool skipPendingSort

Functions

◆ beginInsertItems()

void QTreeModel::beginInsertItems ( QTreeWidgetItem parent,
int  row,
int  count 
)
protected

Definition at line 862 of file qtreewidget.cpp.

Referenced by createIndexFromItem(), and QTreeWidgetItem::insertChildren().

863 {
864  QModelIndex par = index(parent, 0);
865  beginInsertRows(par, row, row + count - 1);
866 }
QModelIndex index(const QTreeWidgetItem *item, int column) const
Returns the model index that refers to the tree view item and column.
The QModelIndex class is used to locate data in a data model.
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.

◆ beginRemoveItems()

void QTreeModel::beginRemoveItems ( QTreeWidgetItem parent,
int  row,
int  count 
)
protected

Definition at line 873 of file qtreewidget.cpp.

Referenced by createIndexFromItem(), QTreeWidgetItem::takeChild(), QTreeWidgetItem::takeChildren(), and QTreeWidgetItem::~QTreeWidgetItem().

874 {
875  Q_ASSERT(row >= 0);
876  Q_ASSERT(count > 0);
877  beginRemoveRows(index(parent, 0), row, row + count - 1);
878  if (!parent)
879  parent = rootItem;
880  // now update the iterators
881  for (int i = 0; i < iterators.count(); ++i) {
882  for (int j = 0; j < count; j++) {
883  QTreeWidgetItem *c = parent->child(row + j);
884  iterators[i]->d_func()->ensureValidIterator(c);
885  }
886  }
887 }
QModelIndex index(const QTreeWidgetItem *item, int column) const
Returns the model index that refers to the tree view item and column.
unsigned char c[8]
Definition: qnumeric_p.h:62
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QList< QTreeWidgetItemIterator * > iterators
QTreeWidgetItem * rootItem
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
QTreeWidgetItem * child(int index) const
Returns the item at the given index in the list of the item&#39;s children.
Definition: qtreewidget.h:184
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.

◆ clear()

void QTreeModel::clear ( )

Removes all items in the model.

Warning
This function is not part of the public interface.

Definition at line 174 of file qtreewidget.cpp.

Referenced by view(), and ~QTreeModel().

175 {
176  SkipSorting skipSorting(this);
177  for (int i = 0; i < rootItem->childCount(); ++i) {
179  item->par = 0;
180  item->view = 0;
181  delete item;
182  }
185  reset();
186 }
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
int childCount() const
Returns the number of child items.
Definition: qtreewidget.h:190
QTreeWidget * view
Definition: qtreewidget.h:219
friend struct SkipSorting
QTreeWidgetItem * par
Definition: qtreewidget.h:221
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QTreeWidgetItem * rootItem
void clear()
Removes all items from the list.
Definition: qlist.h:764
void stop()
Stops the timer.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
QBasicTimer sortPendingTimer
QList< QTreeWidgetItem * > children
Definition: qtreewidget.h:222
void reset()
Resets the model to its original state in any attached views.

◆ columnCount()

int QTreeModel::columnCount ( const QModelIndex index = QModelIndex()) const
virtual

Returns the number of columns in the item referred to by the given index.

Warning
This function is not part of the public interface. Reimplemented Function

Implements QAbstractItemModel.

Definition at line 363 of file qtreewidget.cpp.

Referenced by emitDataChanged(), ensureSorted(), index(), insertColumns(), setColumnCount(), setHeaderData(), sort(), sortItems(), and view().

364 {
365  Q_UNUSED(index);
366  if (!headerItem)
367  return 0;
368  return headerItem->columnCount();
369 }
QTreeWidgetItem * headerItem
int columnCount() const
Returns the number of columns in the item.
Definition: qtreewidget.h:191
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ createIndexFromItem()

QModelIndex QTreeModel::createIndexFromItem ( int  row,
int  col,
QTreeWidgetItem item 
) const
inline

Definition at line 138 of file qtreewidget_p.h.

139  { return createIndex(row, col, item); }
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...

◆ data()

QVariant QTreeModel::data ( const QModelIndex index,
int  role = Qt::DisplayRole 
) const
virtual

Returns the data corresponding to the given model index and role.

Warning
This function is not part of the public interface. Reimplemented Function

Implements QAbstractItemModel.

Definition at line 401 of file qtreewidget.cpp.

Referenced by view().

402 {
403  if (!index.isValid())
404  return QVariant();
405  QTreeWidgetItem *itm = item(index);
406  if (itm)
407  return itm->data(index.column(), role);
408  return QVariant();
409 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
int column() const
Returns the column this model index refers to.
virtual QVariant data(int column, int role) const
Returns the value for the item&#39;s column and role.

◆ dropMimeData()

bool QTreeModel::dropMimeData ( const QMimeData data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex parent 
)
virtual

Handles the data supplied by a drag and drop operation that ended with the given action.

Returns true if the data and action can be handled by the model; otherwise returns false.

The specified row, column and parent indicate the location of an item in the model where the operation ended. It is the responsibility of the model to complete the action at the correct location.

For instance, a drop action on an item in a QTreeView can result in new items either being inserted as children of the item specified by row, column, and parent, or as siblings of the item.

When row and column are -1 it means that the dropped data should be considered as dropped directly on parent. Usually this will mean appending the data as child items of parent. If row and column are greater than or equal zero, it means that the drop occurred just before the specified row and column in the specified parent.

See also
supportedDropActions(), {Using drag and drop with item views}

Reimplemented from QAbstractItemModel.

Definition at line 800 of file qtreewidget.cpp.

Referenced by view().

802 {
803  if (row == -1 && column == -1)
804  row = rowCount(parent); // append
805  return view()->dropMimeData(item(parent), row, data, action);
806 }
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
int rowCount(const QModelIndex &parent) const
Returns the number of rows in the parent model index.
QTreeWidget * view() const
Definition: qtreewidget_p.h:85
virtual bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action)
Handles the data supplied by a drag and drop operation that ended with the given action in the index ...

◆ emitDataChanged()

void QTreeModel::emitDataChanged ( QTreeWidgetItem item,
int  column 
)
protected

Emits the dataChanged() signal for the given item.

Warning
This function is not part of the public interface.

if column is -1 then all columns have changed

Definition at line 836 of file qtreewidget.cpp.

Referenced by createIndexFromItem(), and QTreeWidgetItem::setData().

837 {
838  if (signalsBlocked())
839  return;
840 
841  if (headerItem == item && column < item->columnCount()) {
842  if (column == -1)
844  else
845  emit headerDataChanged(Qt::Horizontal, column, column);
846  return;
847  }
848 
849  SkipSorting skipSorting(this); //This is a little bit wrong, but not doing it would kill performence
850 
851  QModelIndex bottomRight, topLeft;
852  if (column == -1) {
853  topLeft = index(item, 0);
854  bottomRight = createIndex(topLeft.row(), columnCount() - 1, item);
855  } else {
856  topLeft = index(item, column);
857  bottomRight = topLeft;
858  }
859  emit dataChanged(topLeft, bottomRight);
860 }
QModelIndex index(const QTreeWidgetItem *item, int column) const
Returns the model index that refers to the tree view item and column.
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
QTreeWidgetItem * headerItem
friend struct SkipSorting
int row() const
Returns the row this model index refers to.
#define emit
Definition: qobjectdefs.h:76
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns in the item referred to by the given index.
void headerDataChanged(Qt::Orientation orientation, int first, int last)
This signal is emitted whenever a header is changed.
The QModelIndex class is used to locate data in a data model.
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This signal is emitted whenever the data in an existing item changes.
bool signalsBlocked() const
Returns true if signals are blocked; otherwise returns false.
Definition: qobject.h:148

◆ endInsertItems()

void QTreeModel::endInsertItems ( )
protected

Definition at line 868 of file qtreewidget.cpp.

Referenced by createIndexFromItem(), and QTreeWidgetItem::insertChildren().

869 {
870  endInsertRows();
871 }
void endInsertRows()
Ends a row insertion operation.

◆ endRemoveItems()

void QTreeModel::endRemoveItems ( )
protected

Definition at line 889 of file qtreewidget.cpp.

Referenced by createIndexFromItem(), QTreeWidgetItem::takeChildren(), and QTreeWidgetItem::~QTreeWidgetItem().

890 {
891  endRemoveRows();
892 }
void endRemoveRows()
Ends a row removal operation.

◆ ensureSorted()

void QTreeModel::ensureSorted ( int  column,
Qt::SortOrder  order,
int  start,
int  end,
const QModelIndex parent 
)
Warning
This function is not part of the public interface.

Definition at line 641 of file qtreewidget.cpp.

Referenced by view().

643 {
644  if (isChanging())
645  return;
646 
648 
649  if (column < 0 || column >= columnCount())
650  return;
651 
652  SkipSorting skipSorting(this);
653 
654  QTreeWidgetItem *itm = item(parent);
655  if (!itm)
656  itm = rootItem;
658 
659  int count = end - start + 1;
660  QVector < QPair<QTreeWidgetItem*,int> > sorting(count);
661  for (int i = 0; i < count; ++i) {
662  sorting[i].first = lst.at(start + i);
663  sorting[i].second = start + i;
664  }
665 
667  qStableSort(sorting.begin(), sorting.end(), compare);
668 
669  QModelIndexList oldPersistentIndexes;
670  QModelIndexList newPersistentIndexes;
672  bool changed = false;
673 
674  for (int i = 0; i < count; ++i) {
675  int oldRow = sorting.at(i).second;
676  QTreeWidgetItem *item = lst.takeAt(oldRow);
677  lit = sortedInsertionIterator(lit, lst.end(), order, item);
678  int newRow = qMax(lit - lst.begin(), 0);
679 
680  if ((newRow < oldRow) && !(*item < *lst.at(oldRow - 1)) && !(*lst.at(oldRow - 1) < *item ))
681  newRow = oldRow;
682 
683  lit = lst.insert(lit, item);
684  if (newRow != oldRow) {
685  // we are going to change the persistent indexes, so we need to prepare
686  if (!changed) { // this will only happen once
687  changed = true;
688  emit layoutAboutToBeChanged(); // the selection model needs to know
689  oldPersistentIndexes = persistentIndexList();
690  newPersistentIndexes = oldPersistentIndexes;
691  }
692  for (int j = i + 1; j < count; ++j) {
693  int otherRow = sorting.at(j).second;
694  if (oldRow < otherRow && newRow >= otherRow)
695  --sorting[j].second;
696  else if (oldRow > otherRow && newRow <= otherRow)
697  ++sorting[j].second;
698  }
699  for (int k = 0; k < newPersistentIndexes.count(); ++k) {
700  QModelIndex pi = newPersistentIndexes.at(k);
701  if (pi.parent() != parent)
702  continue;
703  int oldPersistentRow = pi.row();
704  int newPersistentRow = oldPersistentRow;
705  if (oldPersistentRow == oldRow)
706  newPersistentRow = newRow;
707  else if (oldRow < oldPersistentRow && newRow >= oldPersistentRow)
708  newPersistentRow = oldPersistentRow - 1;
709  else if (oldRow > oldPersistentRow && newRow <= oldPersistentRow)
710  newPersistentRow = oldPersistentRow + 1;
711  if (newPersistentRow != oldPersistentRow)
712  newPersistentIndexes[k] = createIndex(newPersistentRow,
713  pi.column(), pi.internalPointer());
714  }
715  }
716  }
717 
718  if (changed) {
719  itm->children = lst;
720  changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes);
722  }
723 }
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
QModelIndexList persistentIndexList() const
Returns the list of indexes stored as persistent indexes in the model.
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to)
Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list t...
friend struct SkipSorting
static bool compare(const QVariant::Private *a, const QVariant::Private *b)
Compares a to b.
Definition: qvariant.cpp:383
void layoutAboutToBeChanged()
This signal is emitted just before the layout of a model is changed.
static bool itemGreaterThan(const QPair< QTreeWidgetItem *, int > &left, const QPair< QTreeWidgetItem *, int > &right)
Returns true if the value of the left item is greater than the value of the right item...
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
int row() const
Returns the row this model index refers to.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
QTreeWidgetItem * rootItem
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns in the item referred to by the given index.
void layoutChanged()
This signal is emitted whenever the layout of items exposed by the model has changed; for example...
void stop()
Stops the timer.
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
void qStableSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:202
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
bool(* LessThan)(const QPair< QTreeWidgetItem *, int > &, const QPair< QTreeWidgetItem *, int > &)
Definition: qtreewidget.cpp:57
bool isChanging() const
static QList< QTreeWidgetItem * >::iterator sortedInsertionIterator(const QList< QTreeWidgetItem *>::iterator &begin, const QList< QTreeWidgetItem *>::iterator &end, Qt::SortOrder order, QTreeWidgetItem *item)
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QModelIndex class is used to locate data in a data model.
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
QBasicTimer sortPendingTimer
QList< QTreeWidgetItem * > children
Definition: qtreewidget.h:222
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Appends a new row to the current test data.
Definition: qtestcase.cpp:2183
static const KeyPair *const end
static bool itemLessThan(const QPair< QTreeWidgetItem *, int > &left, const QPair< QTreeWidgetItem *, int > &right)
Returns true if the value of the left item is less than the value of the right item.
int column() const
Returns the column this model index refers to.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ executePendingSort()

bool QTreeModel::executePendingSort ( ) const
inlineprivate

Definition at line 203 of file qtreewidget_p.h.

Referenced by index(), QTreeWidgetItem::takeChild(), QTreeWidgetItem::takeChildren(), and timerEvent().

204 {
207  int column = view()->header()->sortIndicatorSection();
209  QTreeModel *that = const_cast<QTreeModel*>(this);
210  that->sort(column, order);
211  return true;
212  }
213  return false;
214 }
int sortIndicatorSection() const
Returns the logical index of the section that has a sort indicator.
bool isActive() const
Returns true if the timer is running and has not been stopped; otherwise returns false.
Definition: qbasictimer.h:62
void sort(int column, Qt::SortOrder order)
Sorts the entire tree in the model in the given order, by the values in the given column...
SortOrder
Definition: qnamespace.h:189
QTreeWidget * view() const
Definition: qtreewidget_p.h:85
void stop()
Stops the timer.
bool isChanging() const
QHeaderView * header() const
Returns the header for the tree view.
Definition: qtreeview.cpp:302
QBasicTimer sortPendingTimer
Qt::SortOrder sortIndicatorOrder() const
Returns the order for the sort indicator.
bool skipPendingSort

◆ flags()

Qt::ItemFlags QTreeModel::flags ( const QModelIndex index) const
virtual

Returns the flags for the item referred to the given index.

Reimplemented Function

Reimplemented from QAbstractItemModel.

Definition at line 607 of file qtreewidget.cpp.

Referenced by view().

608 {
609  if (!index.isValid())
610  return rootItem->flags();
611  QTreeWidgetItem *itm = item(index);
612  Q_ASSERT(itm);
613  return itm->flags();
614 }
Qt::ItemFlags flags() const
Returns the flags used to describe the item.
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QTreeWidgetItem * rootItem
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63

◆ hasChildren()

bool QTreeModel::hasChildren ( const QModelIndex parent) const
virtual

Returns true if parent has any children; otherwise returns false.

Use rowCount() on the parent to find out the number of children.

See also
parent() index()

Reimplemented from QAbstractItemModel.

Definition at line 371 of file qtreewidget.cpp.

Referenced by view().

372 {
373  if (!parent.isValid())
374  return (rootItem->childCount() > 0);
375 
376  QTreeWidgetItem *itm = item(parent);
377  if (!itm)
378  return false;
379  switch (itm->d->policy) {
381  return true;
383  return false;
385  return (itm->childCount() > 0);
386  }
387  return false;
388 }
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
int childCount() const
Returns the number of child items.
Definition: qtreewidget.h:190
QTreeWidgetItem * rootItem
QTreeWidgetItem::ChildIndicatorPolicy policy
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
QTreeWidgetItemPrivate * d
Definition: qtreewidget.h:220

◆ headerData()

QVariant QTreeModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const
virtual

Returns the header data corresponding to the given header section, orientation and data role.

Warning
This function is not part of the public interface. Reimplemented Function

Reimplemented from QAbstractItemModel.

Definition at line 562 of file qtreewidget.cpp.

Referenced by view().

563 {
564  if (orientation != Qt::Horizontal)
565  return QVariant();
566 
567  if (headerItem)
568  return headerItem->data(section, role);
569  if (role == Qt::DisplayRole)
570  return QString::number(section + 1);
571  return QVariant();
572 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QTreeWidgetItem * headerItem
virtual QVariant data(int column, int role) const
Returns the value for the item&#39;s column and role.

◆ index() [1/2]

QModelIndex QTreeModel::index ( const QTreeWidgetItem item,
int  column 
) const

Returns the model index that refers to the tree view item and column.

Warning
This function is not part of the public interface.

Definition at line 253 of file qtreewidget.cpp.

Referenced by beginInsertItems(), beginRemoveItems(), emitDataChanged(), QTreeWidgetPrivate::item(), itemChanged(), parent(), and view().

254 {
256 
257  if (!item || (item == rootItem))
258  return QModelIndex();
259  const QTreeWidgetItem *par = item->parent();
260  QTreeWidgetItem *itm = const_cast<QTreeWidgetItem*>(item);
261  if (!par)
262  par = rootItem;
263  int row;
264  int guess = item->d->rowGuess;
265  if (guess >= 0
266  && par->children.count() > guess
267  && par->children.at(guess) == itm) {
268  row = guess;
269  } else {
270  row = par->children.lastIndexOf(itm);
271  itm->d->rowGuess = row;
272  }
273  return createIndex(row, column, itm);
274 }
bool executePendingSort() const
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
int lastIndexOf(const T &t, int from=-1) const
Returns the index position of the last occurrence of value in the list, searching backward from index...
Definition: qlist.h:862
QTreeWidgetItem * parent() const
Returns the item&#39;s parent.
Definition: qtreewidget.h:183
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QTreeWidgetItem * rootItem
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
QTreeWidgetItemPrivate * d
Definition: qtreewidget.h:220
The QModelIndex class is used to locate data in a data model.
QList< QTreeWidgetItem * > children
Definition: qtreewidget.h:222

◆ index() [2/2]

QModelIndex QTreeModel::index ( int  row,
int  column,
const QModelIndex parent 
) const
virtual

Returns the model index with the given row, column and parent.

Warning
This function is not part of the public interface. Reimplemented Function

Implements QAbstractItemModel.

Definition at line 287 of file qtreewidget.cpp.

288 {
290 
291  int c = columnCount(parent);
292  if (row < 0 || column < 0 || column >= c)
293  return QModelIndex();
294 
295  QTreeWidgetItem *parentItem = parent.isValid() ? item(parent) : rootItem;
296  if (parentItem && row < parentItem->childCount()) {
297  QTreeWidgetItem *itm = parentItem->child(row);
298  if (itm)
299  return createIndex(row, column, itm);
300  return QModelIndex();
301  }
302 
303  return QModelIndex();
304 }
bool executePendingSort() const
unsigned char c[8]
Definition: qnumeric_p.h:62
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
QTreeWidgetItem * rootItem
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns in the item referred to by the given index.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
QTreeWidgetItem * child(int index) const
Returns the item at the given index in the list of the item&#39;s children.
Definition: qtreewidget.h:184
The QModelIndex class is used to locate data in a data model.

◆ insertColumns()

bool QTreeModel::insertColumns ( int  column,
int  count,
const QModelIndex parent 
)
virtual
Warning
This function is not part of the public interface. Reimplemented Function

Reimplemented from QAbstractItemModel.

Definition at line 491 of file qtreewidget.cpp.

Referenced by view().

492 {
493  SkipSorting skipSorting(this);
494  if (count < 1 || column < 0 || column > columnCount(parent) || parent.column() > 0 || !headerItem)
495  return false;
496 
497  beginInsertColumns(parent, column, column + count - 1);
498 
499  int oldCount = columnCount(parent);
500  column = qBound(0, column, oldCount);
501  headerItem->values.resize(oldCount + count);
502  for (int i = oldCount; i < oldCount + count; ++i) {
505  }
506 
507  QStack<QTreeWidgetItem*> itemstack;
508  itemstack.push(0);
509  while (!itemstack.isEmpty()) {
510  QTreeWidgetItem *par = itemstack.pop();
512  for (int row = 0; row < children.count(); ++row) {
513  QTreeWidgetItem *child = children.at(row);
514  if (child->children.count())
515  itemstack.push(child);
516  child->values.insert(column, count, QVector<QWidgetItemData>());
517  }
518  }
519 
521  return true;
522 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
void beginInsertColumns(const QModelIndex &parent, int first, int last)
Begins a column insertion operation.
The QStack class is a template class that provides a stack.
Definition: qcontainerfwd.h:63
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QTreeWidgetItem * headerItem
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
T pop()
Removes the top item from the stack and returns it.
Definition: qstack.h:67
friend struct SkipSorting
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QTreeWidgetItem * rootItem
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns in the item referred to by the given index.
void push(const T &t)
Adds element t to the top of the stack.
Definition: qstack.h:60
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
void insert(int i, const T &t)
Inserts value at index position i in the vector.
Definition: qvector.h:362
QTreeWidgetItemPrivate * d
Definition: qtreewidget.h:220
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
QVector< QVector< QWidgetItemData > > values
Definition: qtreewidget.h:218
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
void endInsertColumns()
Ends a column insertion operation.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
QList< QTreeWidgetItem * > children
Definition: qtreewidget.h:222
int column() const
Returns the column this model index refers to.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ insertRows()

bool QTreeModel::insertRows ( int  row,
int  count,
const QModelIndex parent 
)
virtual
Warning
This function is not part of the public interface. Reimplemented Function

Reimplemented from QAbstractItemModel.

Definition at line 465 of file qtreewidget.cpp.

Referenced by view().

466 {
467  SkipSorting skipSorting(this);
468  if (count < 1 || row < 0 || row > rowCount(parent) || parent.column() > 0)
469  return false;
470 
471  beginInsertRows(parent, row, row + count - 1);
472  QTreeWidgetItem *par = item(parent);
473  while (count > 0) {
475  item->view = view();
476  item->par = par;
477  if (par)
478  par->children.insert(row++, item);
479  else
480  rootItem->children.insert(row++, item);
481  --count;
482  }
483  endInsertRows();
484  return true;
485 }
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
void endInsertRows()
Ends a row insertion operation.
QTreeWidget * view
Definition: qtreewidget.h:219
friend struct SkipSorting
QTreeWidgetItem * par
Definition: qtreewidget.h:221
friend class QTreeWidgetItem
Definition: qtreewidget_p.h:76
int rowCount(const QModelIndex &parent) const
Returns the number of rows in the parent model index.
QTreeWidget * view() const
Definition: qtreewidget_p.h:85
QTreeWidgetItem * rootItem
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
QList< QTreeWidgetItem * > children
Definition: qtreewidget.h:222
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.
int column() const
Returns the column this model index refers to.

◆ internalMimeData()

QMimeData * QTreeModel::internalMimeData ( ) const

Definition at line 779 of file qtreewidget.cpp.

Referenced by view().

780 {
782 }
QModelIndexList cachedIndexes
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...

◆ isChanging()

bool QTreeModel::isChanging ( ) const
private

Definition at line 821 of file qtreewidget.cpp.

Referenced by ensureSorted(), executePendingSort(), QTreeWidgetItem::sortChildren(), and sortItems().

822 {
823  Q_D(const QTreeModel);
824  return !d->changes.isEmpty();
825 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ item()

QTreeWidgetItem * QTreeModel::item ( const QModelIndex index) const

Returns the tree view item corresponding to the index given.

Warning
This function is not part of the public interface.
See also
QModelIndex

Definition at line 236 of file qtreewidget.cpp.

Referenced by QTreeWidgetPrivate::_q_selectionChanged(), clear(), data(), dropMimeData(), emitDataChanged(), ensureSorted(), flags(), hasChildren(), index(), insertRows(), itemData(), mimeData(), QTreeWidgetItemIterator::QTreeWidgetItemIterator(), QTreeWidgetItemPrivate::QTreeWidgetItemPrivate(), removeRows(), rowCount(), setData(), sortItems(), and view().

237 {
238  if (!index.isValid())
239  return 0;
240  return static_cast<QTreeWidgetItem*>(index.internalPointer());
241 }
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63

◆ itemChanged()

void QTreeModel::itemChanged ( QTreeWidgetItem item)

Definition at line 813 of file qtreewidget.cpp.

Referenced by view().

814 {
815  SkipSorting skipSorting(this); //this is kind of wrong, but not doing this would kill performence
816  QModelIndex left = index(item, 0);
817  QModelIndex right = index(item, item->columnCount() - 1);
818  emit dataChanged(left, right);
819 }
QModelIndex index(const QTreeWidgetItem *item, int column) const
Returns the model index that refers to the tree view item and column.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
friend struct SkipSorting
#define emit
Definition: qobjectdefs.h:76
The QModelIndex class is used to locate data in a data model.
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This signal is emitted whenever the data in an existing item changes.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
int columnCount() const
Returns the number of columns in the item.
Definition: qtreewidget.h:191

◆ itemData()

QMap< int, QVariant > QTreeModel::itemData ( const QModelIndex index) const
virtual

Returns a map with values for all predefined roles in the model for the item at the given index.

Reimplement this function if you want to extend the default behavior of this function to include custom roles in the map.

See also
Qt::ItemDataRole, data()

Reimplemented from QAbstractItemModel.

Definition at line 436 of file qtreewidget.cpp.

Referenced by view().

437 {
438  QMap<int, QVariant> roles;
439  QTreeWidgetItem *itm = item(index);
440  if (itm) {
441  int column = index.column();
442  if (column < itm->values.count()) {
443  for (int i = 0; i < itm->values.at(column).count(); ++i) {
444  roles.insert(itm->values.at(column).at(i).role,
445  itm->values.at(column).at(i).value);
446  }
447  }
448 
449  // the two special cases
450  QVariant displayValue = itm->data(column, Qt::DisplayRole);
451  if (displayValue.isValid())
452  roles.insert(Qt::DisplayRole, displayValue);
453 
454  QVariant checkValue = itm->data(column, Qt::CheckStateRole);
455  if (checkValue.isValid())
456  roles.insert(Qt::CheckStateRole, checkValue);
457  }
458  return roles;
459 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
quint16 values[128]
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
QVector< QVector< QWidgetItemData > > values
Definition: qtreewidget.h:218
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
int column() const
Returns the column this model index refers to.
virtual QVariant data(int column, int role) const
Returns the value for the item&#39;s column and role.

◆ itemGreaterThan()

bool QTreeModel::itemGreaterThan ( const QPair< QTreeWidgetItem *, int > &  left,
const QPair< QTreeWidgetItem *, int > &  right 
)
static

Returns true if the value of the left item is greater than the value of the right item.

Warning
This function is not part of the public interface.

Used by the sorting functions.

Definition at line 755 of file qtreewidget.cpp.

Referenced by ensureSorted(), sortItems(), and view().

757 {
758  return *(right.first) < *(left.first);
759 }
T1 first
Definition: qpair.h:65

◆ itemLessThan()

bool QTreeModel::itemLessThan ( const QPair< QTreeWidgetItem *, int > &  left,
const QPair< QTreeWidgetItem *, int > &  right 
)
static

Returns true if the value of the left item is less than the value of the right item.

Warning
This function is not part of the public interface.

Used by the sorting functions.

Definition at line 737 of file qtreewidget.cpp.

Referenced by ensureSorted(), sortItems(), and view().

739 {
740  return *(left.first) < *(right.first);
741 }
T1 first
Definition: qpair.h:65

◆ mimeData()

QMimeData * QTreeModel::mimeData ( const QModelIndexList indexes) const
virtual

Returns an object that contains serialized items of data corresponding to the list of indexes specified.

The formats used to describe the encoded data is obtained from the mimeTypes() function.

If the list of indexes is empty, or there are no supported MIME types, 0 is returned rather than a serialized empty list.

See also
mimeTypes(), dropMimeData()

Reimplemented from QAbstractItemModel.

Definition at line 784 of file qtreewidget.cpp.

Referenced by view().

785 {
787  for (int i = 0; i < indexes.count(); ++i) {
788  if (indexes.at(i).column() == 0) // only one item per row
789  items << item(indexes.at(i));
790  }
791 
792  // cachedIndexes is a little hack to avoid copying from QModelIndexList to
793  // QList<QTreeWidgetItem*> and back again in the view
794  cachedIndexes = indexes;
795  QMimeData *mimeData = view()->mimeData(items);
797  return mimeData;
798 }
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
QMimeData * mimeData(const QModelIndexList &indexes) const
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QTreeWidget * view() const
Definition: qtreewidget_p.h:85
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
virtual QMimeData * mimeData(const QList< QTreeWidgetItem *> items) const
Returns an object that contains a serialized description of the specified items.
void clear()
Removes all items from the list.
Definition: qlist.h:764
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
QModelIndexList cachedIndexes
int column() const
Returns the column this model index refers to.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ mimeTypes()

QStringList QTreeModel::mimeTypes ( ) const
virtual

Returns a list of MIME types that can be used to describe a list of model indexes.

See also
mimeData()

Reimplemented from QAbstractItemModel.

Definition at line 774 of file qtreewidget.cpp.

Referenced by view().

775 {
776  return view()->mimeTypes();
777 }
virtual QStringList mimeTypes() const
Returns a list of MIME types that can be used to describe a list of treewidget items.
QTreeWidget * view() const
Definition: qtreewidget_p.h:85

◆ parent()

QModelIndex QTreeModel::parent ( const QModelIndex child) const
virtual

Returns the parent model index of the index given as the child.

Warning
This function is not part of the public interface. Reimplemented Function

Implements QAbstractItemModel.

Definition at line 317 of file qtreewidget.cpp.

318 {
319  SkipSorting skipSorting(this); //The reason we don't sort here is that this might be called from a valid QPersistentModelIndex
320  //We don't want it to become suddenly invalid
321 
322  if (!child.isValid())
323  return QModelIndex();
324  QTreeWidgetItem *itm = static_cast<QTreeWidgetItem *>(child.internalPointer());
325  if (!itm || itm == rootItem)
326  return QModelIndex();
327  QTreeWidgetItem *parent = itm->parent();
328  return index(parent, 0);
329 }
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
QModelIndex index(const QTreeWidgetItem *item, int column) const
Returns the model index that refers to the tree view item and column.
friend struct SkipSorting
QTreeWidgetItem * parent() const
Returns the item&#39;s parent.
Definition: qtreewidget.h:183
QTreeWidgetItem * rootItem
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QModelIndex class is used to locate data in a data model.

◆ removeRows()

bool QTreeModel::removeRows ( int  row,
int  count,
const QModelIndex parent = QModelIndex() 
)
virtual
Warning
This function is not part of the public interface. Reimplemented Function

Reimplemented from QAbstractItemModel.

Definition at line 528 of file qtreewidget.cpp.

Referenced by view().

528  {
529  if (count < 1 || row < 0 || (row + count) > rowCount(parent))
530  return false;
531 
532  beginRemoveRows(parent, row, row + count - 1);
533 
534  bool blockSignal = signalsBlocked();
535  blockSignals(true);
536 
537  QTreeWidgetItem *itm = item(parent);
538  for (int i = row + count - 1; i >= row; --i) {
539  QTreeWidgetItem *child = itm ? itm->takeChild(i) : rootItem->children.takeAt(i);
540  Q_ASSERT(child);
541  child->view = 0;
542  delete child;
543  child = 0;
544  }
545  blockSignals(blockSignal);
546 
547  endRemoveRows();
548  return true;
549 }
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
Definition: qobject.cpp:1406
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
QTreeWidget * view
Definition: qtreewidget.h:219
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int rowCount(const QModelIndex &parent) const
Returns the number of rows in the parent model index.
QTreeWidgetItem * takeChild(int index)
Removes the item at index and returns it, otherwise return 0.
QTreeWidgetItem * rootItem
void endRemoveRows()
Ends a row removal operation.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
bool signalsBlocked() const
Returns true if signals are blocked; otherwise returns false.
Definition: qobject.h:148
QList< QTreeWidgetItem * > children
Definition: qtreewidget.h:222

◆ rowCount()

int QTreeModel::rowCount ( const QModelIndex parent) const
virtual

Returns the number of rows in the parent model index.

Warning
This function is not part of the public interface. Reimplemented Function

Implements QAbstractItemModel.

Definition at line 341 of file qtreewidget.cpp.

Referenced by dropMimeData(), insertRows(), removeRows(), and view().

342 {
343  if (!parent.isValid())
344  return rootItem->childCount();
345 
346  QTreeWidgetItem *parentItem = item(parent);
347  if (parentItem)
348  return parentItem->childCount();
349  return 0;
350 }
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
int childCount() const
Returns the number of child items.
Definition: qtreewidget.h:190
QTreeWidgetItem * rootItem
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63

◆ setColumnCount()

void QTreeModel::setColumnCount ( int  columns)

Sets the number of columns in the tree model.

Warning
This function is not part of the public interface.

Definition at line 197 of file qtreewidget.cpp.

Referenced by QTreeModel(), QTreeWidgetItem::setData(), and view().

198 {
199  SkipSorting skipSorting(this);
200  if (columns < 0)
201  return;
202  if (!headerItem) {
203  headerItem = new QTreeWidgetItem();
204  headerItem->view = view();
205  }
206  int count = columnCount();
207  if (count == columns)
208  return;
209 
210  if (columns < count) {
211  beginRemoveColumns(QModelIndex(), columns, count - 1);
212  headerItem->values.resize(columns);
214  } else {
215  beginInsertColumns(QModelIndex(), count, columns - 1);
216  headerItem->values.resize(columns);
217  for (int i = count; i < columns; ++i) {// insert data without emitting the dataChanged signal
220  }
222  }
223 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
void beginInsertColumns(const QModelIndex &parent, int first, int last)
Begins a column insertion operation.
void beginRemoveColumns(const QModelIndex &parent, int first, int last)
Begins a column removal operation.
QTreeWidget * view
Definition: qtreewidget.h:219
QTreeWidgetItem * headerItem
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
friend struct SkipSorting
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
friend class QTreeWidgetItem
Definition: qtreewidget_p.h:76
QTreeWidget * view() const
Definition: qtreewidget_p.h:85
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns in the item referred to by the given index.
QTreeWidgetItemPrivate * d
Definition: qtreewidget.h:220
The QModelIndex class is used to locate data in a data model.
QVector< QVector< QWidgetItemData > > values
Definition: qtreewidget.h:218
void endInsertColumns()
Ends a column insertion operation.
void endRemoveColumns()
Ends a column removal operation.

◆ setData()

bool QTreeModel::setData ( const QModelIndex index,
const QVariant value,
int  role 
)
virtual

Sets the data for the item specified by the index and role to that referred to by the value.

Warning
This function is not part of the public interface. Reimplemented Function

Returns true if successful; otherwise returns false.

Reimplemented from QAbstractItemModel.

Definition at line 424 of file qtreewidget.cpp.

Referenced by view().

425 {
426  if (!index.isValid())
427  return false;
428  QTreeWidgetItem *itm = item(index);
429  if (itm) {
430  itm->setData(index.column(), role, value);
431  return true;
432  }
433  return false;
434 }
virtual void setData(int column, int role, const QVariant &value)
Sets the value for the item&#39;s column and role to the given value.
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
int column() const
Returns the column this model index refers to.

◆ setHeaderData()

bool QTreeModel::setHeaderData ( int  section,
Qt::Orientation  orientation,
const QVariant value,
int  role 
)
virtual

Sets the header data for the item specified by the header section, orientation and data role to the given value.

Warning
This function is not part of the public interface. Reimplemented Function

Returns true if successful; otherwise returns false.

Reimplemented from QAbstractItemModel.

Definition at line 587 of file qtreewidget.cpp.

Referenced by view().

589 {
590  if (section < 0 || orientation != Qt::Horizontal || !headerItem || section >= columnCount())
591  return false;
592 
593  headerItem->setData(section, role, value);
594  return true;
595 }
virtual void setData(int column, int role, const QVariant &value)
Sets the value for the item&#39;s column and role to the given value.
QTreeWidgetItem * headerItem
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns in the item referred to by the given index.

◆ sort()

void QTreeModel::sort ( int  column,
Qt::SortOrder  order 
)
virtual

Sorts the entire tree in the model in the given order, by the values in the given column.

Warning
This function is not part of the public interface.

Reimplemented from QAbstractItemModel.

Definition at line 626 of file qtreewidget.cpp.

Referenced by executePendingSort(), and view().

627 {
628  SkipSorting skipSorting(this);
630 
631  if (column < 0 || column >= columnCount())
632  return;
633 
634  //layoutAboutToBeChanged and layoutChanged will be called by sortChildren
635  rootItem->sortChildren(column, order, true);
636 }
friend struct SkipSorting
QTreeWidgetItem * rootItem
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns in the item referred to by the given index.
void stop()
Stops the timer.
void sortChildren(int column, Qt::SortOrder order)
Sorts the children of the item using the given order, by the values in the given column.
Definition: qtreewidget.h:204
QBasicTimer sortPendingTimer

◆ sortedInsertionIterator()

QList< QTreeWidgetItem * >::iterator QTreeModel::sortedInsertionIterator ( const QList< QTreeWidgetItem *>::iterator &  begin,
const QList< QTreeWidgetItem *>::iterator &  end,
Qt::SortOrder  order,
QTreeWidgetItem item 
)
static
Warning
This function is not part of the public interface.

Definition at line 764 of file qtreewidget.cpp.

Referenced by ensureSorted(), and view().

768 {
769  if (order == Qt::AscendingOrder)
770  return qLowerBound(begin, end, item, QTreeModelLessThan());
771  return qLowerBound(begin, end, item, QTreeModelGreaterThan());
772 }
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:227

◆ sortItems()

void QTreeModel::sortItems ( QList< QTreeWidgetItem *> *  items,
int  column,
Qt::SortOrder  order 
)
protected

Definition at line 894 of file qtreewidget.cpp.

Referenced by createIndexFromItem(), and QTreeWidgetItemPrivate::sortChildren().

895 {
896  // see QTreeViewItem::operator<
897  Q_UNUSED(column);
898  if (isChanging())
899  return;
900 
901  // store the original order of indexes
902  QVector< QPair<QTreeWidgetItem*,int> > sorting(items->count());
903  for (int i = 0; i < sorting.count(); ++i) {
904  sorting[i].first = items->at(i);
905  sorting[i].second = i;
906  }
907 
908  // do the sorting
910  qStableSort(sorting.begin(), sorting.end(), compare);
911 
912  QModelIndexList fromList;
914  int colCount = columnCount();
915  for (int r = 0; r < sorting.count(); ++r) {
916  int oldRow = sorting.at(r).second;
917  if (oldRow == r)
918  continue;
919  QTreeWidgetItem *item = sorting.at(r).first;
920  items->replace(r, item);
921  for (int c = 0; c < colCount; ++c) {
922  QModelIndex from = createIndex(oldRow, c, item);
923  if (static_cast<QAbstractItemModelPrivate *>(d_ptr.data())->persistent.indexes.contains(from)) {
924  QModelIndex to = createIndex(r, c, item);
925  fromList << from;
926  toList << to;
927  }
928  }
929  }
930  changePersistentIndexList(fromList, toList);
931 }
unsigned char c[8]
Definition: qnumeric_p.h:62
T * data() const
Returns the value of the pointer referenced by this object.
T & first()
Returns a reference to the first item in the vector.
Definition: qvector.h:260
QTreeWidgetItem * item(const QModelIndex &index) const
Returns the tree view item corresponding to the index given.
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QList< QVariant > toList(char **buf, int count, T *=0)
Definition: qsql_ibase.cpp:472
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to)
Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list t...
static bool compare(const QVariant::Private *a, const QVariant::Private *b)
Compares a to b.
Definition: qvariant.cpp:383
static bool itemGreaterThan(const QPair< QTreeWidgetItem *, int > &left, const QPair< QTreeWidgetItem *, int > &right)
Returns true if the value of the left item is greater than the value of the right item...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns in the item referred to by the given index.
void replace(int i, const T &t)
Replaces the item at index position i with value.
Definition: qlist.h:609
void qStableSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:202
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class...
Definition: qtreewidget.h:63
bool(* LessThan)(const QPair< QTreeWidgetItem *, int > &, const QPair< QTreeWidgetItem *, int > &)
Definition: qtreewidget.cpp:57
bool isChanging() const
The QModelIndex class is used to locate data in a data model.
QScopedPointer< QObjectData > d_ptr
Definition: qobject.h:320
static bool itemLessThan(const QPair< QTreeWidgetItem *, int > &left, const QPair< QTreeWidgetItem *, int > &right)
Returns true if the value of the left item is less than the value of the right item.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ supportedDropActions()

Qt::DropActions QTreeModel::supportedDropActions ( ) const
virtual

Returns the drop actions supported by this model.

Since
4.2

The default implementation returns Qt::CopyAction. Reimplement this function if you wish to support additional actions. You must also reimplement the dropMimeData() function to handle the additional operations.

See also
dropMimeData(), Qt::DropActions, {Using drag and drop with item views}

Reimplemented from QAbstractItemModel.

Definition at line 808 of file qtreewidget.cpp.

Referenced by view().

809 {
810  return view()->supportedDropActions();
811 }
virtual Qt::DropActions supportedDropActions() const
Returns the drop actions supported by this view.
QTreeWidget * view() const
Definition: qtreewidget_p.h:85

◆ timerEvent()

void QTreeModel::timerEvent ( QTimerEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive timer events for the object.

QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter.

See also
startTimer(), killTimer(), event()

Reimplemented from QObject.

Definition at line 933 of file qtreewidget.cpp.

Referenced by createIndexFromItem().

934 {
935  if (ev->timerId() == sortPendingTimer.timerId()) {
937  } else {
939  }
940 }
bool executePendingSort() const
virtual void timerEvent(QTimerEvent *)
This event handler can be reimplemented in a subclass to receive timer events for the object...
Definition: qobject.cpp:1294
int timerId() const
Returns the timer&#39;s ID.
Definition: qbasictimer.h:63
QBasicTimer sortPendingTimer

◆ view()

QTreeWidget* QTreeModel::view ( ) const
inline

Definition at line 85 of file qtreewidget_p.h.

Referenced by dropMimeData(), executePendingSort(), insertRows(), mimeData(), mimeTypes(), setColumnCount(), and supportedDropActions().

The QTreeWidget class provides a tree view that uses a predefined tree model.
Definition: qtreewidget.h:260
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273

Friends and Related Functions

◆ QTreeWidget

friend class QTreeWidget
friend

Definition at line 74 of file qtreewidget_p.h.

◆ QTreeWidgetItem

friend class QTreeWidgetItem
friend

Definition at line 76 of file qtreewidget_p.h.

Referenced by insertRows(), and setColumnCount().

◆ QTreeWidgetItemIterator

Definition at line 78 of file qtreewidget_p.h.

◆ QTreeWidgetItemIteratorPrivate

Definition at line 79 of file qtreewidget_p.h.

Referenced by QTreeWidgetItemIterator::QTreeWidgetItemIterator().

◆ QTreeWidgetItemPrivate

Definition at line 77 of file qtreewidget_p.h.

◆ QTreeWidgetPrivate

friend class QTreeWidgetPrivate
friend

Definition at line 75 of file qtreewidget_p.h.

◆ SkipSorting

friend struct SkipSorting
friend

Definition at line 175 of file qtreewidget_p.h.

Properties

◆ cachedIndexes

QModelIndexList QTreeModel::cachedIndexes
mutableprivate

Definition at line 155 of file qtreewidget_p.h.

Referenced by internalMimeData(), and mimeData().

◆ headerItem

QTreeWidgetItem* QTreeModel::headerItem
private

◆ iterators

QList<QTreeWidgetItemIterator*> QTreeModel::iterators
private

◆ rootItem

QTreeWidgetItem* QTreeModel::rootItem
private

◆ skipPendingSort

bool QTreeModel::skipPendingSort
mutableprivate

◆ sortPendingTimer

QBasicTimer QTreeModel::sortPendingTimer
mutableprivate

Definition at line 158 of file qtreewidget_p.h.

Referenced by clear(), ensureSorted(), executePendingSort(), sort(), and timerEvent().


The documentation for this class was generated from the following files: