Qt 4.8
Signals | Public Functions | Private Slots | Properties | List of all members
QDeclarativeVisualDataModel Class Reference

#include <qdeclarativevisualitemmodel_p.h>

Inheritance diagram for QDeclarativeVisualDataModel:
QDeclarativeVisualModel QObject

Signals

void createdPackage (int index, QDeclarativePackage *package)
 
void destroyingPackage (QDeclarativePackage *package)
 
void rootIndexChanged ()
 
- Signals inherited from QDeclarativeVisualModel
void countChanged ()
 
void createdItem (int index, QDeclarativeItem *item)
 
void destroyingItem (QDeclarativeItem *item)
 
void itemsChanged (int index, int count)
 
void itemsInserted (int index, int count)
 
void itemsMoved (int from, int to, int count)
 
void itemsRemoved (int index, int count)
 
void modelReset ()
 
- 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...
 

Public Functions

void completeItem ()
 
bool completePending () const
 
int count () const
 
QDeclarativeComponentdelegate () const
 
int indexOf (QDeclarativeItem *item, QObject *objectContext) const
 
bool isValid () const
 
QDeclarativeItemitem (int index, bool complete=true)
 
QDeclarativeItemitem (int index, const QByteArray &, bool complete=true)
 
QVariant model () const
 
Q_INVOKABLE QVariant modelIndex (int idx) const
 
Q_INVOKABLE QVariant parentModelIndex () const
 
QString part () const
 
QObjectparts ()
 
 QDeclarativeVisualDataModel ()
 
 QDeclarativeVisualDataModel (QDeclarativeContext *, QObject *parent=0)
 
ReleaseFlags release (QDeclarativeItem *item)
 
QVariant rootIndex () const
 
void setDelegate (QDeclarativeComponent *)
 
void setModel (const QVariant &)
 
void setPart (const QString &)
 
void setRootIndex (const QVariant &root)
 
virtual void setWatchedRoles (QList< QByteArray > roles)
 
virtual QString stringValue (int index, const QString &role)
 
virtual ~QDeclarativeVisualDataModel ()
 
- Public Functions inherited from QDeclarativeVisualModel
virtual ~QDeclarativeVisualModel ()
 
- 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...
 

Private Slots

void _q_createdPackage (int index, QDeclarativePackage *package)
 
void _q_dataChanged (const QModelIndex &, const QModelIndex &)
 
void _q_destroyingPackage (QDeclarativePackage *package)
 
void _q_itemsChanged (int, int, const QList< int > &)
 
void _q_itemsInserted (int index, int count)
 
void _q_itemsMoved (int from, int to, int count)
 
void _q_itemsRemoved (int index, int count)
 
void _q_layoutChanged ()
 
void _q_modelReset ()
 
void _q_rowsInserted (const QModelIndex &, int, int)
 
void _q_rowsMoved (const QModelIndex &, int, int, const QModelIndex &, int)
 
void _q_rowsRemoved (const QModelIndex &, int, int)
 

Properties

QDeclarativeComponentdelegate
 
QVariant model
 
QString part
 
QObjectparts
 
QVariant rootIndex
 

Additional Inherited Members

- Public Types inherited from QDeclarativeVisualModel
enum  ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 }
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- 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)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QDeclarativeVisualModel
 QDeclarativeVisualModel (QObjectPrivate &dd, QObject *parent=0)
 
- 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
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 141 of file qdeclarativevisualitemmodel_p.h.

Constructors and Destructors

◆ QDeclarativeVisualDataModel() [1/2]

QDeclarativeVisualDataModel::QDeclarativeVisualDataModel ( )

◆ QDeclarativeVisualDataModel() [2/2]

QDeclarativeVisualDataModel::QDeclarativeVisualDataModel ( QDeclarativeContext ctxt,
QObject parent = 0 
)

Definition at line 678 of file qdeclarativevisualitemmodel.cpp.

◆ ~QDeclarativeVisualDataModel()

QDeclarativeVisualDataModel::~QDeclarativeVisualDataModel ( )
virtual

Definition at line 683 of file qdeclarativevisualitemmodel.cpp.

684 {
686  if (d->m_listAccessor)
687  delete d->m_listAccessor;
688  if (d->m_delegateDataType)
689  d->m_delegateDataType->release();
690 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

Functions

◆ _q_createdPackage

void QDeclarativeVisualDataModel::_q_createdPackage ( int  index,
QDeclarativePackage package 
)
privateslot

Definition at line 1440 of file qdeclarativevisualitemmodel.cpp.

Referenced by setModel().

1441 {
1443  emit createdItem(index, qobject_cast<QDeclarativeItem*>(package->part(d->m_part)));
1444 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
QObject * part(const QString &=QString())
quint16 index
void createdItem(int index, QDeclarativeItem *item)

◆ _q_dataChanged

void QDeclarativeVisualDataModel::_q_dataChanged ( const QModelIndex begin,
const QModelIndex end 
)
privateslot

Definition at line 1417 of file qdeclarativevisualitemmodel.cpp.

Referenced by setModel().

1418 {
1420  if (begin.parent() == d->m_root)
1421  _q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles);
1422 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
int row() const
Returns the row this model index refers to.
void _q_itemsChanged(int, int, const QList< int > &)

◆ _q_destroyingPackage

void QDeclarativeVisualDataModel::_q_destroyingPackage ( QDeclarativePackage package)
privateslot

Definition at line 1446 of file qdeclarativevisualitemmodel.cpp.

Referenced by setModel().

1447 {
1449  emit destroyingItem(qobject_cast<QDeclarativeItem*>(package->part(d->m_part)));
1450 }
double d
Definition: qnumeric_p.h:62
void destroyingItem(QDeclarativeItem *item)
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
QObject * part(const QString &=QString())

◆ _q_itemsChanged

void QDeclarativeVisualDataModel::_q_itemsChanged ( int  index,
int  count,
const QList< int > &  roles 
)
privateslot

Definition at line 1225 of file qdeclarativevisualitemmodel.cpp.

Referenced by _q_dataChanged(), _q_layoutChanged(), and setModel().

1227 {
1229  bool changed = false;
1230  if (!d->watchedRoles.isEmpty() && d->watchedRoleIds.isEmpty()) {
1231  foreach (QByteArray r, d->watchedRoles) {
1232  if (d->m_roleNames.contains(r))
1233  d->watchedRoleIds << d->m_roleNames.value(r);
1234  }
1235  }
1236 
1238  iter != d->m_cache.end(); ++iter) {
1239  const int idx = iter.key();
1240 
1241  if (idx >= index && idx < index+count) {
1243  QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
1244  for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) {
1245  int role = roles.at(roleIdx);
1246  if (!changed && !d->watchedRoleIds.isEmpty() && d->watchedRoleIds.contains(role))
1247  changed = true;
1248  int propId = data->propForRole(role);
1249  if (propId != -1) {
1250  if (data->hasValue(propId)) {
1251  if (d->m_listModelInterface) {
1252  data->setValue(propId, d->m_listModelInterface->data(idx, role));
1253  } else if (d->m_abstractItemModel) {
1254  QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root);
1255  data->setValue(propId, d->m_abstractItemModel->data(index, role));
1256  }
1257  }
1258  } else {
1259  QString roleName;
1260  if (d->m_listModelInterface)
1261  roleName = d->m_listModelInterface->toString(role);
1262  else if (d->m_abstractItemModel)
1263  roleName = QString::fromUtf8(d->m_abstractItemModel->roleNames().value(role));
1264  qmlInfo(this) << "Changing role not present in item: " << roleName;
1265  }
1266  }
1267  if (d->m_roles.count() == 1) {
1268  // Handle the modelData role we add if there is just one role.
1269  int propId = data->modelDataPropertyId();
1270  if (data->hasValue(propId)) {
1271  int role = d->m_roles.at(0);
1272  if (d->m_listModelInterface) {
1273  data->setValue(propId, d->m_listModelInterface->data(idx, role));
1274  } else if (d->m_abstractItemModel) {
1275  QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root);
1276  data->setValue(propId, d->m_abstractItemModel->data(index, role));
1277  }
1278  }
1279  }
1280  }
1281  }
1282  if (changed)
1284 }
double d
Definition: qnumeric_p.h:62
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
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
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
static const char * data(const QByteArray &arr)
The QModelIndex class is used to locate data in a data model.
quint16 index
void itemsChanged(int index, int count)
QDeclarativeInfo qmlInfo(const QObject *me)

◆ _q_itemsInserted

void QDeclarativeVisualDataModel::_q_itemsInserted ( int  index,
int  count 
)
privateslot

Definition at line 1286 of file qdeclarativevisualitemmodel.cpp.

Referenced by _q_rowsInserted(), _q_rowsMoved(), and setModel().

1287 {
1289  if (!count)
1290  return;
1291  // XXX - highly inefficient
1294  iter != d->m_cache.end(); ) {
1295 
1296  if (iter.key() >= index) {
1298  int index = iter.key() + count;
1299  iter = d->m_cache.erase(iter);
1300 
1301  items.insert(index, objRef);
1302 
1303  QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
1304  data->setIndex(index);
1305  } else {
1306  ++iter;
1307  }
1308  }
1309  d->m_cache.unite(items);
1310 
1311  emit itemsInserted(index, count);
1312  emit countChanged();
1313 }
double d
Definition: qnumeric_p.h:62
void itemsInserted(int index, int count)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
#define Q_D(Class)
Definition: qglobal.h:2482
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define emit
Definition: qobjectdefs.h:76
static const char * data(const QByteArray &arr)
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
quint16 index

◆ _q_itemsMoved

void QDeclarativeVisualDataModel::_q_itemsMoved ( int  from,
int  to,
int  count 
)
privateslot

Definition at line 1347 of file qdeclarativevisualitemmodel.cpp.

Referenced by _q_rowsMoved(), and setModel().

1348 {
1350  // XXX - highly inefficient
1353  iter != d->m_cache.end(); ) {
1354 
1355  if (iter.key() >= from && iter.key() < from + count) {
1357  int index = iter.key() - from + to;
1358  iter = d->m_cache.erase(iter);
1359 
1360  items.insert(index, objRef);
1361 
1362  QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
1363  data->setIndex(index);
1364  } else {
1365  ++iter;
1366  }
1367  }
1369  iter != d->m_cache.end(); ) {
1370 
1371  int diff = from > to ? count : -count;
1372  if (iter.key() >= qMin(from,to) && iter.key() < qMax(from+count,to+count)) {
1374  int index = iter.key() + diff;
1375  iter = d->m_cache.erase(iter);
1376 
1377  items.insert(index, objRef);
1378 
1379  QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
1380  data->setIndex(index);
1381  } else {
1382  ++iter;
1383  }
1384  }
1385  d->m_cache.unite(items);
1386 
1387  emit itemsMoved(from, to, count);
1388 }
double d
Definition: qnumeric_p.h:62
void itemsMoved(int from, int to, int count)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
#define Q_D(Class)
Definition: qglobal.h:2482
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define emit
Definition: qobjectdefs.h:76
static const char * data(const QByteArray &arr)
static Bigint * diff(Bigint *a, Bigint *b)
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
quint16 index

◆ _q_itemsRemoved

void QDeclarativeVisualDataModel::_q_itemsRemoved ( int  index,
int  count 
)
privateslot

Definition at line 1315 of file qdeclarativevisualitemmodel.cpp.

Referenced by _q_rowsMoved(), _q_rowsRemoved(), and setModel().

1316 {
1318  if (!count)
1319  return;
1320  // XXX - highly inefficient
1323  iter != d->m_cache.end(); ) {
1324  if (iter.key() >= index && iter.key() < index + count) {
1326  iter = d->m_cache.erase(iter);
1327  items.insertMulti(-1, objRef); //XXX perhaps better to maintain separately
1328  QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
1329  data->setIndex(-1);
1330  } else if (iter.key() >= index + count) {
1332  int index = iter.key() - count;
1333  iter = d->m_cache.erase(iter);
1334  items.insert(index, objRef);
1335  QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
1336  data->setIndex(index);
1337  } else {
1338  ++iter;
1339  }
1340  }
1341 
1342  d->m_cache.unite(items);
1343  emit itemsRemoved(index, count);
1344  emit countChanged();
1345 }
double d
Definition: qnumeric_p.h:62
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
#define Q_D(Class)
Definition: qglobal.h:2482
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define emit
Definition: qobjectdefs.h:76
static const char * data(const QByteArray &arr)
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
quint16 index
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:772
void itemsRemoved(int index, int count)

◆ _q_layoutChanged

void QDeclarativeVisualDataModel::_q_layoutChanged ( )
privateslot

Definition at line 1424 of file qdeclarativevisualitemmodel.cpp.

Referenced by setModel().

1425 {
1427  _q_itemsChanged(0, count(), d->m_roles);
1428 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void _q_itemsChanged(int, int, const QList< int > &)

◆ _q_modelReset

void QDeclarativeVisualDataModel::_q_modelReset ( )
privateslot

Definition at line 1430 of file qdeclarativevisualitemmodel.cpp.

Referenced by setModel().

1431 {
1433  d->m_root = QModelIndex();
1434  emit modelReset();
1436  if (d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(d->m_root))
1437  d->m_abstractItemModel->fetchMore(d->m_root);
1438 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
The QModelIndex class is used to locate data in a data model.

◆ _q_rowsInserted

void QDeclarativeVisualDataModel::_q_rowsInserted ( const QModelIndex parent,
int  begin,
int  end 
)
privateslot

Definition at line 1390 of file qdeclarativevisualitemmodel.cpp.

Referenced by setModel().

1391 {
1393  if (parent == d->m_root)
1394  _q_itemsInserted(begin, end - begin + 1);
1395 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static const KeyPair *const end
void _q_itemsInserted(int index, int count)

◆ _q_rowsMoved

void QDeclarativeVisualDataModel::_q_rowsMoved ( const QModelIndex sourceParent,
int  sourceStart,
int  sourceEnd,
const QModelIndex destinationParent,
int  destinationRow 
)
privateslot

Definition at line 1404 of file qdeclarativevisualitemmodel.cpp.

Referenced by setModel().

1405 {
1407  const int count = sourceEnd - sourceStart + 1;
1408  if (destinationParent == d->m_root && sourceParent == d->m_root) {
1409  _q_itemsMoved(sourceStart, sourceStart > destinationRow ? destinationRow : destinationRow-count, count);
1410  } else if (sourceParent == d->m_root) {
1411  _q_itemsRemoved(sourceStart, count);
1412  } else if (destinationParent == d->m_root) {
1413  _q_itemsInserted(destinationRow, count);
1414  }
1415 }
double d
Definition: qnumeric_p.h:62
void _q_itemsRemoved(int index, int count)
void _q_itemsMoved(int from, int to, int count)
#define Q_D(Class)
Definition: qglobal.h:2482
void _q_itemsInserted(int index, int count)

◆ _q_rowsRemoved

void QDeclarativeVisualDataModel::_q_rowsRemoved ( const QModelIndex parent,
int  begin,
int  end 
)
privateslot

Definition at line 1397 of file qdeclarativevisualitemmodel.cpp.

Referenced by setModel().

1398 {
1400  if (parent == d->m_root)
1401  _q_itemsRemoved(begin, end - begin + 1);
1402 }
double d
Definition: qnumeric_p.h:62
void _q_itemsRemoved(int index, int count)
#define Q_D(Class)
Definition: qglobal.h:2482
static const KeyPair *const end

◆ completeItem()

void QDeclarativeVisualDataModel::completeItem ( )
virtual

Implements QDeclarativeVisualModel.

Definition at line 1148 of file qdeclarativevisualitemmodel.cpp.

1149 {
1151  if (d->m_visualItemModel) {
1152  d->m_visualItemModel->completeItem();
1153  return;
1154  }
1155 
1156  d->m_delegate->completeCreate();
1157  d->m_completePending = false;
1158 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ completePending()

bool QDeclarativeVisualDataModel::completePending ( ) const
virtual

Implements QDeclarativeVisualModel.

Definition at line 1140 of file qdeclarativevisualitemmodel.cpp.

1141 {
1143  if (d->m_visualItemModel)
1144  return d->m_visualItemModel->completePending();
1145  return d->m_completePending;
1146 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ count()

int QDeclarativeVisualDataModel::count ( ) const
virtual

Implements QDeclarativeVisualModel.

Definition at line 969 of file qdeclarativevisualitemmodel.cpp.

Referenced by _q_itemsInserted(), _q_itemsMoved(), _q_itemsRemoved(), _q_layoutChanged(), _q_rowsMoved(), and QDeclarativeVisualDataModelPrivate::modelCount().

970 {
972  if (d->m_visualItemModel)
973  return d->m_visualItemModel->count();
974  if (!d->m_delegate)
975  return 0;
976  return d->modelCount();
977 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ createdPackage

void QDeclarativeVisualDataModel::createdPackage ( int  index,
QDeclarativePackage package 
)
signal

Referenced by item(), and setModel().

◆ delegate()

QDeclarativeComponent* QDeclarativeVisualDataModel::delegate ( ) const

Referenced by setDelegate(), and setModel().

◆ destroyingPackage

void QDeclarativeVisualDataModel::destroyingPackage ( QDeclarativePackage package)
signal

Referenced by release(), and setModel().

◆ indexOf()

int QDeclarativeVisualDataModel::indexOf ( QDeclarativeItem item,
QObject objectContext 
) const
virtual

Implements QDeclarativeVisualModel.

Definition at line 1211 of file qdeclarativevisualitemmodel.cpp.

1212 {
1214  return val.toInt();
1215  return -1;
1216 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
QVariant contextProperty(const QString &) const
Returns the value of the name property for this context as a QVariant.
static QDeclarativeContext * contextForObject(const QObject *)
Returns the QDeclarativeContext for the object, or 0 if no context has been set.

◆ isValid()

bool QDeclarativeVisualDataModel::isValid ( ) const
inlinevirtual

Implements QDeclarativeVisualModel.

Definition at line 173 of file qdeclarativevisualitemmodel_p.h.

173 { return delegate() != 0; }
QDeclarativeComponent * delegate() const

◆ item() [1/2]

QDeclarativeItem * QDeclarativeVisualDataModel::item ( int  index,
bool  complete = true 
)
virtual

Implements QDeclarativeVisualModel.

Definition at line 979 of file qdeclarativevisualitemmodel.cpp.

Referenced by item(), and release().

980 {
982  if (d->m_visualItemModel)
983  return d->m_visualItemModel->item(index, d->m_part.toUtf8(), complete);
984  return item(index, QByteArray(), complete);
985 }
double d
Definition: qnumeric_p.h:62
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define Q_D(Class)
Definition: qglobal.h:2482
QDeclarativeItem * item(int index, bool complete=true)
quint16 index

◆ item() [2/2]

QDeclarativeItem * QDeclarativeVisualDataModel::item ( int  index,
const QByteArray viewId,
bool  complete = true 
)

Definition at line 1071 of file qdeclarativevisualitemmodel.cpp.

1072 {
1074  if (d->m_visualItemModel)
1075  return d->m_visualItemModel->item(index, viewId, complete);
1076 
1077  if (d->modelCount() <= 0 || !d->m_delegate)
1078  return 0;
1079  QObject *nobj = d->m_cache.getItem(index);
1080  bool needComplete = false;
1081  if (!nobj) {
1082  QDeclarativeContext *ccontext = d->m_context;
1083  if (!ccontext) ccontext = qmlContext(this);
1084  QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext);
1086  if ((!d->m_listModelInterface || !d->m_abstractItemModel) && d->m_listAccessor
1087  && d->m_listAccessor->type() == QDeclarativeListAccessor::ListProperty) {
1088  QDeclarativeContext *objCtxt = ctxt;
1089  objCtxt->setContextObject(d->m_listAccessor->at(index).value<QObject*>());
1090  ctxt = new QDeclarativeContext(ctxt);
1091  QDeclarative_setParent_noEvent(objCtxt, ctxt);
1092  }
1093  ctxt->setContextProperty(QLatin1String("model"), data);
1094  ctxt->setContextObject(data);
1095  d->m_completePending = false;
1096  nobj = d->m_delegate->beginCreate(ctxt);
1097  if (complete) {
1098  d->m_delegate->completeCreate();
1099  } else {
1100  d->m_completePending = true;
1101  needComplete = true;
1102  }
1103  if (nobj) {
1104  QDeclarative_setParent_noEvent(ctxt, nobj);
1105  QDeclarative_setParent_noEvent(data, nobj);
1106  d->m_cache.insertItem(index, nobj);
1107  if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(nobj))
1108  emit createdPackage(index, package);
1109  } else {
1110  delete data;
1111  delete ctxt;
1112  qmlInfo(this, d->m_delegate->errors()) << "Error creating delegate";
1113  }
1114  }
1116  if (!item) {
1117  QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(nobj);
1118  if (package) {
1119  QObject *o = package->part(QString::fromUtf8(viewId));
1120  item = qobject_cast<QDeclarativeItem *>(o);
1121  if (item)
1122  d->m_packaged.insertMulti(item, package);
1123  }
1124  }
1125  if (!item) {
1126  if (needComplete)
1127  d->m_delegate->completeCreate();
1128  d->m_cache.releaseItem(nobj);
1129  if (!d->m_delegateValidated) {
1130  qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type.");
1131  d->m_delegateValidated = true;
1132  }
1133  }
1134  if (d->modelCount()-1 == index && d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(d->m_root))
1135  d->m_abstractItemModel->fetchMore(d->m_root);
1136 
1137  return item;
1138 }
double d
Definition: qnumeric_p.h:62
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
#define Q_D(Class)
Definition: qglobal.h:2482
void setContextObject(QObject *)
Set the context object.
QDeclarativeItem * item(int index, bool complete=true)
The QDeclarativeItem class provides the most basic of all visual items in QML.
void createdPackage(int index, QDeclarativePackage *package)
#define emit
Definition: qobjectdefs.h:76
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
static const char * data(const QByteArray &arr)
void setContextProperty(const QString &, QObject *)
Set the value of the name property on this context.
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
The QDeclarativeContext class defines a context within a QML engine.
quint16 index
QDeclarativeInfo qmlInfo(const QObject *me)

◆ model()

QVariant QDeclarativeVisualDataModel::model ( ) const

◆ modelIndex()

QVariant QDeclarativeVisualDataModel::modelIndex ( int  idx) const

Definition at line 926 of file qdeclarativevisualitemmodel.cpp.

Referenced by setRootIndex().

927 {
929  if (d->m_abstractItemModel)
930  return QVariant::fromValue(d->m_abstractItemModel->index(idx, 0, d->m_root));
932 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
The QModelIndex class is used to locate data in a data model.

◆ parentModelIndex()

QVariant QDeclarativeVisualDataModel::parentModelIndex ( ) const

Definition at line 949 of file qdeclarativevisualitemmodel.cpp.

950 {
952  if (d->m_abstractItemModel)
953  return QVariant::fromValue(d->m_abstractItemModel->parent(d->m_root));
955 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
The QModelIndex class is used to locate data in a data model.

◆ part()

QString QDeclarativeVisualDataModel::part ( ) const

Referenced by parentModelIndex(), and setPart().

◆ parts()

QObject* QDeclarativeVisualDataModel::parts ( )

Referenced by release().

◆ release()

QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release ( QDeclarativeItem item)
virtual

Implements QDeclarativeVisualModel.

Definition at line 990 of file qdeclarativevisualitemmodel.cpp.

991 {
993  if (d->m_visualItemModel)
994  return d->m_visualItemModel->release(item);
995 
996  ReleaseFlags stat = 0;
997  QObject *obj = item;
998  bool inPackage = false;
999 
1000  QHash<QObject*,QDeclarativePackage*>::iterator it = d->m_packaged.find(item);
1001  if (it != d->m_packaged.end()) {
1002  QDeclarativePackage *package = *it;
1003  d->m_packaged.erase(it);
1004  if (d->m_packaged.contains(item))
1005  stat |= Referenced;
1006  inPackage = true;
1007  obj = package; // fall through and delete
1008  }
1009 
1010  if (d->m_cache.releaseItem(obj)) {
1011  // Remove any bindings to avoid warnings due to parent change.
1014  QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
1015  if (d->ownContext && d->context)
1016  d->context->clearContext();
1017 
1018  if (inPackage) {
1019  emit destroyingPackage(qobject_cast<QDeclarativePackage*>(obj));
1020  } else {
1021  if (item->scene())
1022  item->scene()->removeItem(item);
1023  }
1024  stat |= Destroyed;
1025  obj->deleteLater();
1026  } else if (!inPackage) {
1027  stat |= Referenced;
1028  }
1029 
1030  return stat;
1031 }
double d
Definition: qnumeric_p.h:62
QDeclarativeContextData * context
#define it(className, varName)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
QDeclarativeItem * item(int index, bool complete=true)
void removeItem(QGraphicsItem *item)
Removes the item item and all its children from the scene.
#define emit
Definition: qobjectdefs.h:76
QAbstractDeclarativeData * declarativeData
Definition: qobject_p.h:214
void destroyingPackage(QDeclarativePackage *package)
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145

◆ rootIndex()

QVariant QDeclarativeVisualDataModel::rootIndex ( ) const

Referenced by setDelegate().

◆ rootIndexChanged

void QDeclarativeVisualDataModel::rootIndexChanged ( )
signal

Referenced by _q_modelReset(), and setRootIndex().

◆ setDelegate()

void QDeclarativeVisualDataModel::setDelegate ( QDeclarativeComponent delegate)

Definition at line 836 of file qdeclarativevisualitemmodel.cpp.

837 {
839  bool wasValid = d->m_delegate != 0;
840  d->m_delegate = delegate;
841  d->m_delegateValidated = false;
842  if (!wasValid && d->modelCount() && d->m_delegate) {
843  emit itemsInserted(0, d->modelCount());
844  emit countChanged();
845  }
846  if (wasValid && !d->m_delegate && d->modelCount()) {
847  emit itemsRemoved(0, d->modelCount());
848  emit countChanged();
849  }
850 }
double d
Definition: qnumeric_p.h:62
QDeclarativeComponent * delegate() const
void itemsInserted(int index, int count)
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
void itemsRemoved(int index, int count)

◆ setModel()

void QDeclarativeVisualDataModel::setModel ( const QVariant model)

Definition at line 714 of file qdeclarativevisualitemmodel.cpp.

Referenced by QDeclarativeVisualDataModelPartsMetaObject::initialValue().

715 {
717  delete d->m_listAccessor;
718  d->m_listAccessor = 0;
719  d->m_modelVariant = model;
720  if (d->m_listModelInterface) {
721  // Assume caller has released all items.
722  QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList<int>)),
723  this, SLOT(_q_itemsChanged(int,int,QList<int>)));
724  QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsInserted(int,int)),
725  this, SLOT(_q_itemsInserted(int,int)));
726  QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsRemoved(int,int)),
727  this, SLOT(_q_itemsRemoved(int,int)));
728  QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)),
729  this, SLOT(_q_itemsMoved(int,int,int)));
730  d->m_listModelInterface = 0;
731  } else if (d->m_abstractItemModel) {
732  QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
733  this, SLOT(_q_rowsInserted(QModelIndex,int,int)));
734  QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
735  this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
736  QObject::disconnect(d->m_abstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
738  QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
739  this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)));
740  QObject::disconnect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset()));
741  QObject::disconnect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));
742  d->m_abstractItemModel = 0;
743  } else if (d->m_visualItemModel) {
744  QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)),
745  this, SIGNAL(itemsInserted(int,int)));
746  QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)),
747  this, SIGNAL(itemsRemoved(int,int)));
748  QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)),
749  this, SIGNAL(itemsMoved(int,int,int)));
754  d->m_visualItemModel = 0;
755  }
756 
757  d->m_roles.clear();
758  d->m_roleNames.clear();
759  if (d->m_delegateDataType)
760  d->m_delegateDataType->release();
761  d->m_metaDataCreated = 0;
762  d->m_metaDataCacheable = false;
763  d->m_delegateDataType = new VDMDelegateDataType(&QDeclarativeVisualDataModelData::staticMetaObject, d->m_context?d->m_context->engine():qmlEngine(this));
764 
765  QObject *object = qvariant_cast<QObject *>(model);
766  if (object && (d->m_listModelInterface = qobject_cast<QListModelInterface *>(object))) {
767  QObject::connect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList<int>)),
768  this, SLOT(_q_itemsChanged(int,int,QList<int>)));
769  QObject::connect(d->m_listModelInterface, SIGNAL(itemsInserted(int,int)),
770  this, SLOT(_q_itemsInserted(int,int)));
771  QObject::connect(d->m_listModelInterface, SIGNAL(itemsRemoved(int,int)),
772  this, SLOT(_q_itemsRemoved(int,int)));
773  QObject::connect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)),
774  this, SLOT(_q_itemsMoved(int,int,int)));
775  d->m_metaDataCacheable = true;
776  if (d->m_delegate && d->m_listModelInterface->count())
777  emit itemsInserted(0, d->m_listModelInterface->count());
778  return;
779  } else if (object && (d->m_abstractItemModel = qobject_cast<QAbstractItemModel *>(object))) {
780  QObject::connect(d->m_abstractItemModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
781  this, SLOT(_q_rowsInserted(QModelIndex,int,int)));
782  QObject::connect(d->m_abstractItemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
783  this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
784  QObject::connect(d->m_abstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
786  QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
787  this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)));
788  QObject::connect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset()));
789  QObject::connect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));
790  d->m_metaDataCacheable = true;
791  if (d->m_abstractItemModel->canFetchMore(d->m_root))
792  d->m_abstractItemModel->fetchMore(d->m_root);
793  return;
794  }
795  if ((d->m_visualItemModel = qvariant_cast<QDeclarativeVisualDataModel *>(model))) {
796  QObject::connect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)),
797  this, SIGNAL(itemsInserted(int,int)));
798  QObject::connect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)),
799  this, SIGNAL(itemsRemoved(int,int)));
800  QObject::connect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)),
801  this, SIGNAL(itemsMoved(int,int,int)));
802  QObject::connect(d->m_visualItemModel, SIGNAL(createdPackage(int,QDeclarativePackage*)),
806  return;
807  }
808  d->m_listAccessor = new QDeclarativeListAccessor;
809  d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this));
810  if (d->m_listAccessor->type() != QDeclarativeListAccessor::ListProperty)
811  d->m_metaDataCacheable = true;
812  if (d->m_delegate && d->modelCount()) {
813  emit itemsInserted(0, d->modelCount());
814  emit countChanged();
815  }
816 }
double d
Definition: qnumeric_p.h:62
void itemsMoved(int from, int to, int count)
void itemsInserted(int index, int count)
void _q_itemsRemoved(int index, int count)
void _q_rowsInserted(const QModelIndex &, int, int)
void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)
#define SLOT(a)
Definition: qobjectdefs.h:226
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
void _q_itemsMoved(int from, int to, int count)
void _q_createdPackage(int index, QDeclarativePackage *package)
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void createdPackage(int index, QDeclarativePackage *package)
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 rece...
Definition: qobject.cpp:2580
#define emit
Definition: qobjectdefs.h:76
void _q_dataChanged(const QModelIndex &, const QModelIndex &)
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.
Definition: qobject.cpp:2895
Q_DECLARATIVE_EXPORT QDeclarativeEngine * qmlEngine(const QObject *)
void destroyingPackage(QDeclarativePackage *package)
void _q_itemsChanged(int, int, const QList< int > &)
The QModelIndex class is used to locate data in a data model.
if(void) toggleToolbarShown
void _q_rowsRemoved(const QModelIndex &, int, int)
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
void _q_destroyingPackage(QDeclarativePackage *package)
void itemsChanged(int index, int count)
void _q_itemsInserted(int index, int count)
void itemsRemoved(int index, int count)

◆ setPart()

void QDeclarativeVisualDataModel::setPart ( const QString part)

Definition at line 963 of file qdeclarativevisualitemmodel.cpp.

Referenced by QDeclarativeVisualDataModelPartsMetaObject::initialValue().

964 {
966  d->m_part = part;
967 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setRootIndex()

void QDeclarativeVisualDataModel::setRootIndex ( const QVariant root)

Definition at line 890 of file qdeclarativevisualitemmodel.cpp.

891 {
894  if (d->m_root != modelIndex) {
895  int oldCount = d->modelCount();
896  d->m_root = modelIndex;
897  if (d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(modelIndex))
898  d->m_abstractItemModel->fetchMore(modelIndex);
899  int newCount = d->modelCount();
900  if (d->m_delegate && oldCount)
901  emit itemsRemoved(0, oldCount);
902  if (d->m_delegate && newCount)
903  emit itemsInserted(0, newCount);
904  if (newCount != oldCount)
905  emit countChanged();
907  }
908 }
double d
Definition: qnumeric_p.h:62
void itemsInserted(int index, int count)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_INVOKABLE QVariant modelIndex(int idx) const
#define emit
Definition: qobjectdefs.h:76
The QModelIndex class is used to locate data in a data model.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
void itemsRemoved(int index, int count)

◆ setWatchedRoles()

void QDeclarativeVisualDataModel::setWatchedRoles ( QList< QByteArray roles)
virtual

Implements QDeclarativeVisualModel.

Definition at line 1218 of file qdeclarativevisualitemmodel.cpp.

1219 {
1221  d->watchedRoles = roles;
1222  d->watchedRoleIds.clear();
1223 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ stringValue()

QString QDeclarativeVisualDataModel::stringValue ( int  index,
const QString role 
)
virtual

Implements QDeclarativeVisualModel.

Definition at line 1160 of file qdeclarativevisualitemmodel.cpp.

1161 {
1163  if (d->m_visualItemModel)
1164  return d->m_visualItemModel->stringValue(index, name);
1165 
1166  if ((!d->m_listModelInterface || !d->m_abstractItemModel) && d->m_listAccessor) {
1167  if (QObject *object = d->m_listAccessor->at(index).value<QObject*>())
1168  return object->property(name.toUtf8()).toString();
1169  }
1170 
1171  if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate)
1172  return QString();
1173 
1174  QString val;
1175  QObject *data = 0;
1176  bool tempData = false;
1177 
1178  if (QObject *nobj = d->m_cache.item(index))
1179  data = d->data(nobj);
1180  if (!data) {
1181  data = new QDeclarativeVisualDataModelData(index, this);
1182  tempData = true;
1183  }
1184 
1185  QDeclarativeData *ddata = QDeclarativeData::get(data);
1186  if (ddata && ddata->propertyCache) {
1188  if (prop) {
1189  if (prop->propType == QVariant::String) {
1190  void *args[] = { &val, 0 };
1192  } else if (prop->propType == qMetaTypeId<QVariant>()) {
1193  QVariant v;
1194  void *args[] = { &v, 0 };
1196  val = v.toString();
1197  }
1198  } else {
1199  val = data->property(name.toUtf8()).toString();
1200  }
1201  } else {
1202  val = data->property(name.toUtf8()).toString();
1203  }
1204 
1205  if (tempData)
1206  delete data;
1207 
1208  return val;
1209 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
QDeclarativePropertyCache * propertyCache
static QDeclarativeData * get(const QObject *object, bool create=false)
static int metacall(QObject *, Call, int, void **)
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
static QString toString(Register *reg, int type, bool *ok=0)
const char * name
Data * property(const QScriptDeclarativeClass::Identifier &id) const
static const char * data(const QByteArray &arr)
quint16 index
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807

Properties

◆ delegate

QDeclarativeComponent * QDeclarativeVisualDataModel::delegate
private

Definition at line 147 of file qdeclarativevisualitemmodel_p.h.

◆ model

QVariant QDeclarativeVisualDataModel::model
private

Definition at line 146 of file qdeclarativevisualitemmodel_p.h.

◆ part

QString QDeclarativeVisualDataModel::part
private

Definition at line 148 of file qdeclarativevisualitemmodel_p.h.

◆ parts

QObject * QDeclarativeVisualDataModel::parts
private

Definition at line 149 of file qdeclarativevisualitemmodel_p.h.

◆ rootIndex

QVariant QDeclarativeVisualDataModel::rootIndex
private

Definition at line 150 of file qdeclarativevisualitemmodel_p.h.


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