Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QPersistentModelIndexData Class Reference

#include <qabstractitemmodel_p.h>

Public Functions

 QPersistentModelIndexData ()
 
 QPersistentModelIndexData (const QModelIndex &idx)
 

Static Public Functions

static QPersistentModelIndexDatacreate (const QModelIndex &index)
 
static void destroy (QPersistentModelIndexData *data)
 

Public Variables

QModelIndex index
 
const QAbstractItemModelmodel
 
QAtomicInt ref
 

Detailed Description

Definition at line 64 of file qabstractitemmodel_p.h.

Constructors and Destructors

◆ QPersistentModelIndexData() [1/2]

QPersistentModelIndexData::QPersistentModelIndexData ( )
inline

Definition at line 67 of file qabstractitemmodel_p.h.

Referenced by create().

67 : model(0) {}
const QAbstractItemModel * model

◆ QPersistentModelIndexData() [2/2]

QPersistentModelIndexData::QPersistentModelIndexData ( const QModelIndex idx)
inline

Definition at line 68 of file qabstractitemmodel_p.h.

68 : index(idx), model(idx.model()) {}
const QAbstractItemModel * model
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.

Functions

◆ create()

QPersistentModelIndexData * QPersistentModelIndexData::create ( const QModelIndex index)
static

Definition at line 57 of file qabstractitemmodel.cpp.

Referenced by QPersistentModelIndex::operator=(), and QPersistentModelIndex::QPersistentModelIndex().

58 {
59  Q_ASSERT(index.isValid()); // we will _never_ insert an invalid index in the list
61  QAbstractItemModel *model = const_cast<QAbstractItemModel *>(index.model());
62  QHash<QModelIndex, QPersistentModelIndexData *> &indexes = model->d_func()->persistent.indexes;
64  if (it != indexes.end()) {
65  d = (*it);
66  } else {
67  d = new QPersistentModelIndexData(index);
68  indexes.insert(index, d);
69  }
70  Q_ASSERT(d);
71  return d;
72 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
const QAbstractItemModel * model
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemModel class provides the abstract interface for item model classes.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865

◆ destroy()

void QPersistentModelIndexData::destroy ( QPersistentModelIndexData data)
static

Definition at line 74 of file qabstractitemmodel.cpp.

Referenced by QPersistentModelIndex::operator=(), and QPersistentModelIndex::~QPersistentModelIndex().

75 {
76  Q_ASSERT(data);
77  Q_ASSERT(data->ref == 0);
78  QAbstractItemModel *model = const_cast<QAbstractItemModel *>(data->model);
79  // a valid persistent model index with a null model pointer can only happen if the model was destroyed
80  if (model) {
81  QAbstractItemModelPrivate *p = model->d_func();
82  Q_ASSERT(p);
84  }
85  delete data;
86 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const QAbstractItemModel * model
static const char * data(const QByteArray &arr)
void removePersistentIndexData(QPersistentModelIndexData *data)
The QAbstractItemModel class provides the abstract interface for item model classes.

Properties

◆ index

QModelIndex QPersistentModelIndexData::index

Definition at line 69 of file qabstractitemmodel_p.h.

Referenced by QAbstractItemModel::changePersistentIndex(), QAbstractItemModel::changePersistentIndexList(), QPersistentModelIndex::child(), QPersistentModelIndex::column(), QAbstractItemModelPrivate::columnsAboutToBeInserted(), QAbstractItemModelPrivate::columnsAboutToBeRemoved(), QAbstractItemModelPrivate::columnsInserted(), QAbstractItemModelPrivate::columnsRemoved(), QPersistentModelIndex::data(), QPersistentModelIndex::flags(), QPersistentModelIndex::internalId(), QPersistentModelIndex::internalPointer(), QAbstractItemModelPrivate::invalidatePersistentIndex(), QAbstractItemModelPrivate::invalidatePersistentIndexes(), QPersistentModelIndex::isValid(), QAbstractItemModelPrivate::itemsAboutToBeMoved(), QPersistentModelIndex::model(), QAbstractItemModelPrivate::movePersistentIndexes(), QPersistentModelIndex::operator const QModelIndex &(), QPersistentModelIndex::operator!=(), QPersistentModelIndex::operator<(), operator<<(), QPersistentModelIndex::operator==(), QPersistentModelIndex::parent(), QAbstractItemModel::persistentIndexList(), QAbstractItemModelPrivate::removePersistentIndexData(), QDirModelPrivate::restorePersistentIndexes(), QPersistentModelIndex::row(), QAbstractItemModelPrivate::rowsAboutToBeInserted(), QAbstractItemModelPrivate::rowsAboutToBeRemoved(), QAbstractItemModelPrivate::rowsInserted(), QAbstractItemModelPrivate::rowsRemoved(), QDirModelPrivate::savePersistentIndexes(), QPersistentModelIndex::sibling(), and QSortFilterProxyModelPrivate::store_persistent_indexes().

◆ model

const QAbstractItemModel* QPersistentModelIndexData::model

◆ ref

QAtomicInt QPersistentModelIndexData::ref

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