Qt 4.8
Public Functions | List of all members
QDeclarativeVisualDataModelPrivate::Cache Class Reference
Inheritance diagram for QDeclarativeVisualDataModelPrivate::Cache:
QHash< int, ObjectRef >

Public Functions

QObjectgetItem (int index)
 
void insertItem (int index, QObject *obj)
 
QObjectitem (int index)
 
bool releaseItem (QObject *obj)
 
- Public Functions inherited from QHash< int, ObjectRef >
iterator begin ()
 Returns an STL-style iterator pointing to the first item in the hash. More...
 
const_iterator begin () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int capacity () const
 Returns the number of buckets in the QHash's internal hash table. More...
 
void clear ()
 Removes all items from the hash. More...
 
const_iterator constBegin () const
 Returns a const STL-style iterator pointing to the first item in the hash. More...
 
const_iterator constEnd () const
 Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash. More...
 
const_iterator constFind (const int &key) const
 Returns an iterator pointing to the item with the key in the hash. More...
 
bool contains (const int &key) const
 Returns true if the hash contains an item with the key; otherwise returns false. More...
 
int count (const int &key) const
 Returns the number of items associated with the key. More...
 
int count () const
 Same as size(). More...
 
void detach ()
 Detaches this hash from any other hashes with which it may share data. More...
 
bool empty () const
 This function is provided for STL compatibility. More...
 
iterator end ()
 Returns an STL-style iterator pointing to the imaginary item after the last item in the hash. More...
 
const_iterator end () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
iterator erase (iterator it)
 Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator to the next item in the hash. More...
 
iterator find (const int &key)
 Returns an iterator pointing to the item with the key in the hash. More...
 
const_iterator find (const int &key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
iterator insert (const int &key, const ObjectRef &value)
 Inserts a new item with the key and a value of value. More...
 
iterator insertMulti (const int &key, const ObjectRef &value)
 Inserts a new item with the key and a value of value. More...
 
bool isDetached () const
 Returns true if the hash's internal data isn't shared with any other hash object; otherwise returns false. More...
 
bool isEmpty () const
 Returns true if the hash contains no items; otherwise returns false. More...
 
bool isSharedWith (const QHash< int, ObjectRef > &other) const
 
const int key (const ObjectRef &value) const
 Returns the first key mapped to value. More...
 
const int key (const ObjectRef &value, const int &defaultKey) const
 Returns the first key mapped to value, or defaultKey if the hash contains no item mapped to value. More...
 
QList< int > keys () const
 Returns a list containing all the keys in the hash, in an arbitrary order. More...
 
QList< int > keys (const ObjectRef &value) const
 Returns a list containing all the keys associated with value value, in an arbitrary order. More...
 
bool operator!= (const QHash< int, ObjectRef > &other) const
 Returns true if other is not equal to this hash; otherwise returns false. More...
 
QHash< int, ObjectRef > & operator= (const QHash< int, ObjectRef > &other)
 Assigns other to this hash and returns a reference to this hash. More...
 
bool operator== (const QHash< int, ObjectRef > &other) const
 Returns true if other is equal to this hash; otherwise returns false. More...
 
ObjectRef & operator[] (const int &key)
 Returns the value associated with the key as a modifiable reference. More...
 
const ObjectRef operator[] (const int &key) const
 Same as value(). More...
 
 QHash ()
 Constructs an empty hash. More...
 
 QHash (const QHash< int, ObjectRef > &other)
 Constructs a copy of other. More...
 
int remove (const int &key)
 Removes all the items that have the key from the hash. More...
 
void reserve (int size)
 Ensures that the QHash's internal hash table consists of at least size buckets. More...
 
void setSharable (bool sharable)
 
int size () const
 Returns the number of items in the hash. More...
 
void squeeze ()
 Reduces the size of the QHash's internal hash table to save memory. More...
 
void swap (QHash< int, ObjectRef > &other)
 Swaps hash other with this hash. More...
 
ObjectRef take (const int &key)
 Removes the item with the key from the hash and returns the value associated with it. More...
 
QList< int > uniqueKeys () const
 Returns a list containing all the keys in the map. More...
 
QHash< int, ObjectRef > & unite (const QHash< int, ObjectRef > &other)
 Inserts all the items in the other hash into this hash. More...
 
const ObjectRef value (const int &key) const
 Returns the value associated with the key. More...
 
const ObjectRef value (const int &key, const ObjectRef &defaultValue) const
 If the hash contains no item with the given key, the function returns defaultValue. More...
 
QList< ObjectRef > values () const
 Returns a list containing all the values in the hash, in an arbitrary order. More...
 
QList< ObjectRef > values (const int &key) const
 Returns a list of all the values associated with the key, from the most recently inserted to the least recently inserted. More...
 
 ~QHash ()
 Destroys the hash. More...
 

Additional Inherited Members

- Public Types inherited from QHash< int, ObjectRef >
typedef const_iterator ConstIterator
 Qt-style synonym for QHash::const_iterator. More...
 
typedef qptrdiff difference_type
 Typedef for ptrdiff_t. More...
 
typedef iterator Iterator
 Qt-style synonym for QHash::iterator. More...
 
typedef int key_type
 Typedef for Key. More...
 
typedef ObjectRef mapped_type
 Typedef for T. More...
 
typedef int size_type
 Typedef for int. More...
 
- Public Variables inherited from QHash< int, ObjectRef >
QHashDatad
 
QHashNode< int, ObjectRef > * e
 

Detailed Description

Definition at line 347 of file qdeclarativevisualitemmodel.cpp.

Functions

◆ getItem()

QObject* QDeclarativeVisualDataModelPrivate::Cache::getItem ( int  index)
inline

Definition at line 349 of file qdeclarativevisualitemmodel.cpp.

349  {
350  QObject *item = 0;
352  if (it != end()) {
353  (*it).ref++;
354  item = (*it).obj;
355  }
356  return item;
357  }
#define it(className, varName)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
quint16 index
iterator find(const int &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865

◆ insertItem()

void QDeclarativeVisualDataModelPrivate::Cache::insertItem ( int  index,
QObject obj 
)
inline

Definition at line 365 of file qdeclarativevisualitemmodel.cpp.

365  {
366  insert(index, ObjectRef(obj));
367  }
iterator insert(const int &key, const ObjectRef &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
quint16 index

◆ item()

QObject* QDeclarativeVisualDataModelPrivate::Cache::item ( int  index)
inline

Definition at line 358 of file qdeclarativevisualitemmodel.cpp.

358  {
359  QObject *item = 0;
361  if (it != end())
362  item = (*it).obj;
363  return item;
364  }
#define it(className, varName)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
quint16 index
iterator find(const int &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865

◆ releaseItem()

bool QDeclarativeVisualDataModelPrivate::Cache::releaseItem ( QObject obj)
inline

Definition at line 368 of file qdeclarativevisualitemmodel.cpp.

368  {
370  for (; it != end(); ++it) {
371  ObjectRef &objRef = *it;
372  if (objRef.obj == obj) {
373  if (--objRef.ref == 0) {
374  erase(it);
375  return true;
376  }
377  break;
378  }
379  }
380  return false;
381  }
#define it(className, varName)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827

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