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

#include <qdeclarativexmllistmodel_p.h>

Inheritance diagram for QDeclarativeXmlListModel:
QListModelInterface QDeclarativeParserStatus QObject

Public Types

enum  Status { Null, Ready, Loading, Error }
 

Public Slots

void reload ()
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void countChanged ()
 
void namespaceDeclarationsChanged ()
 
void progressChanged (qreal progress)
 
void queryChanged ()
 
void sourceChanged ()
 
void statusChanged (QDeclarativeXmlListModel::Status)
 
void xmlChanged ()
 
- Signals inherited from QListModelInterface
void itemsChanged (int index, int count, const QList< int > &roles)
 Emit this signal when count items at index have had their roles changed. More...
 
void itemsInserted (int index, int count)
 Emit this signal when count items are inserted at index. More...
 
void itemsMoved (int from, int to, int count)
 Emit this signal when count items are moved from index from to index to. More...
 
void itemsRemoved (int index, int count)
 Emit this signal when count items are removed at index. 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...
 

Public Functions

virtual void classBegin ()
 Invoked after class creation, but before any properties have been set. More...
 
virtual void componentComplete ()
 Invoked after the root component that caused this instantiation has completed construction. More...
 
virtual int count () const
 Returns the number of data entries in the model. More...
 
virtual QHash< int, QVariantdata (int index, const QList< int > &roles=(QList< int >())) const
 
virtual QVariant data (int index, int role) const
 Returns the data at the given index for the specified roles. More...
 
Q_INVOKABLE QString errorString () const
 
Q_INVOKABLE QScriptValue get (int index) const
 
QString namespaceDeclarations () const
 
qreal progress () const
 
 QDeclarativeXmlListModel (QObject *parent=0)
 
QString query () const
 
QDeclarativeListProperty< QDeclarativeXmlListModelRoleroleObjects ()
 
virtual QList< int > roles () const
 Returns the list of roles for which the list model interface provides data. More...
 
void setNamespaceDeclarations (const QString &)
 
void setQuery (const QString &)
 
void setSource (const QUrl &)
 
void setXml (const QString &)
 
QUrl source () const
 
Status status () const
 
virtual QString toString (int role) const
 Returns a string description of the specified role. More...
 
QString xml () const
 
 ~QDeclarativeXmlListModel ()
 
- Public Functions inherited from QListModelInterface
 QListModelInterface (QObject *parent=0)
 Constructs a QListModelInterface with the specified parent. More...
 
virtual ~QListModelInterface ()
 The destructor is virtual. 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...
 
- Public Functions inherited from QDeclarativeParserStatus
 QDeclarativeParserStatus ()
 
virtual ~QDeclarativeParserStatus ()
 

Private Slots

void dataCleared ()
 
void queryCompleted (const QDeclarativeXmlQueryResult &)
 
void queryError (void *object, const QString &error)
 
void requestFinished ()
 
void requestProgress (qint64, qint64)
 

Properties

int count
 
QString namespaceDeclarations
 
qreal progress
 
QString query
 
QDeclarativeListProperty< QDeclarativeXmlListModelRoleroles
 
QUrl source
 
Status status
 
QString xml
 

Additional Inherited Members

- 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 QListModelInterface
 QListModelInterface (QObjectPrivate &dd, QObject *parent)
 
- 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 73 of file qdeclarativexmllistmodel_p.h.

Enumerations

◆ Status

Constructors and Destructors

◆ QDeclarativeXmlListModel()

QDeclarativeXmlListModel::QDeclarativeXmlListModel ( QObject parent = 0)

Definition at line 712 of file qdeclarativexmllistmodel.cpp.

714 {
715 }
QListModelInterface(QObject *parent=0)
Constructs a QListModelInterface with the specified parent.

◆ ~QDeclarativeXmlListModel()

QDeclarativeXmlListModel::~QDeclarativeXmlListModel ( )

Definition at line 717 of file qdeclarativexmllistmodel.cpp.

718 {
719 }

Functions

◆ classBegin()

void QDeclarativeXmlListModel::classBegin ( )
virtual

Invoked after class creation, but before any properties have been set.

Implements QDeclarativeParserStatus.

Definition at line 1006 of file qdeclarativexmllistmodel.cpp.

1007 {
1009  d->isComponentComplete = false;
1010 
1014  connect(queryEngine, SIGNAL(error(void*,QString)),
1015  SLOT(queryError(void*,QString)));
1016 }
static QDeclarativeXmlQueryEngine * instance(QDeclarativeEngine *engine)
QDeclarativeParserStatus ** d
#define error(msg)
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
void queryError(void *object, const QString &error)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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
void queryCompleted(const QDeclarativeXmlQueryResult &)
Q_DECLARATIVE_EXPORT QDeclarativeEngine * qmlEngine(const QObject *)

◆ componentComplete()

void QDeclarativeXmlListModel::componentComplete ( )
virtual

Invoked after the root component that caused this instantiation has completed construction.

At this point all static values and binding values have been assigned to the class.

Implements QDeclarativeParserStatus.

Definition at line 1018 of file qdeclarativexmllistmodel.cpp.

1019 {
1021  d->isComponentComplete = true;
1022  reload();
1023 }
QDeclarativeParserStatus ** d
#define Q_D(Class)
Definition: qglobal.h:2482

◆ count()

virtual int QDeclarativeXmlListModel::count ( ) const
virtual

Returns the number of data entries in the model.

Implements QListModelInterface.

Referenced by data(), dataCleared(), get(), and requestFinished().

◆ countChanged

void QDeclarativeXmlListModel::countChanged ( )
signal

Referenced by queryCompleted(), and requestFinished().

◆ data() [1/2]

QHash< int, QVariant > QDeclarativeXmlListModel::data ( int  index,
const QList< int > &  roles = (QList<int>()) 
) const
virtual

Definition at line 738 of file qdeclarativexmllistmodel.cpp.

Referenced by requestFinished().

739 {
742  for (int i = 0; i < roles.size(); ++i) {
743  int role = roles.at(i);
744  int roleIndex = d->roles.indexOf(role);
745  rv.insert(role, roleIndex == -1 ? QVariant() : d->data.value(roleIndex).value(index));
746  }
747  return rv;
748 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDeclarativeParserStatus ** d
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
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ data() [2/2]

QVariant QDeclarativeXmlListModel::data ( int  index,
int  role 
) const
virtual

Returns the data at the given index for the specified roles.

Implements QListModelInterface.

Definition at line 750 of file qdeclarativexmllistmodel.cpp.

751 {
753  int roleIndex = d->roles.indexOf(role);
754  return (roleIndex == -1) ? QVariant() : d->data.value(roleIndex).value(index);
755 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDeclarativeParserStatus ** d
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
virtual QHash< int, QVariant > data(int index, const QList< int > &roles=(QList< int >())) const

◆ dataCleared

void QDeclarativeXmlListModel::dataCleared ( )
privateslot

Definition at line 1136 of file qdeclarativexmllistmodel.cpp.

Referenced by reload(), and requestFinished().

1137 {
1141  r.size = 0;
1142  r.removed << qMakePair(0, count());
1143  r.keyRoleResultsCache = d->keyRoleResultsCache;
1144  queryCompleted(r);
1145 }
QDeclarativeParserStatus ** d
#define Q_D(Class)
Definition: qglobal.h:2482
#define XMLLISTMODEL_CLEAR_ID
void queryCompleted(const QDeclarativeXmlQueryResult &)
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
virtual int count() const
Returns the number of data entries in the model.
QList< QPair< int, int > > removed

◆ errorString()

QString QDeclarativeXmlListModel::errorString ( ) const

Definition at line 1000 of file qdeclarativexmllistmodel.cpp.

1001 {
1003  return d->errorString;
1004 }
QDeclarativeParserStatus ** d
#define Q_D(Class)
Definition: qglobal.h:2482

◆ get()

QScriptValue QDeclarativeXmlListModel::get ( int  index) const

Definition at line 929 of file qdeclarativexmllistmodel.cpp.

930 {
932 
934  if (index < 0 || index >= count())
935  return sengine->undefinedValue();
936 
937  QScriptValue sv = sengine->newObject();
938  for (int i=0; i<d->roleObjects.count(); i++)
939  sv.setProperty(d->roleObjects[i]->name(), sengine->toScriptValue(d->data.value(i).value(index)));
940  return sv;
941 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
QDeclarativeParserStatus ** d
QScriptValue toScriptValue(const T &value)
Creates a QScriptValue with the given value.
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptEngine class provides an environment for evaluating Qt Script code.
QScriptValue newObject()
Creates a QtScript object of class Object.
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
quint16 index
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
virtual int count() const
Returns the number of data entries in the model.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ namespaceDeclarations()

QString QDeclarativeXmlListModel::namespaceDeclarations ( ) const

Referenced by setQuery().

◆ namespaceDeclarationsChanged

void QDeclarativeXmlListModel::namespaceDeclarationsChanged ( )
signal

◆ progress()

qreal QDeclarativeXmlListModel::progress ( ) const

Referenced by get().

◆ progressChanged

void QDeclarativeXmlListModel::progressChanged ( qreal  progress)
signal

Referenced by requestFinished(), and requestProgress().

◆ query()

QString QDeclarativeXmlListModel::query ( ) const

Referenced by setQuery(), and setXml().

◆ queryChanged

void QDeclarativeXmlListModel::queryChanged ( )
signal

Referenced by setQuery().

◆ queryCompleted

void QDeclarativeXmlListModel::queryCompleted ( const QDeclarativeXmlQueryResult result)
privateslot

Definition at line 1160 of file qdeclarativexmllistmodel.cpp.

Referenced by classBegin(), and dataCleared().

1161 {
1163  if (result.queryId != d->queryId)
1164  return;
1165 
1166  int origCount = d->size;
1167  bool sizeChanged = result.size != d->size;
1168 
1169  d->size = result.size;
1170  d->data = result.data;
1171  d->keyRoleResultsCache = result.keyRoleResultsCache;
1172  d->status = Ready;
1173  d->errorString.clear();
1174  d->queryId = -1;
1175 
1176  bool hasKeys = false;
1177  for (int i=0; i<d->roleObjects.count(); i++) {
1178  if (d->roleObjects[i]->isKey()) {
1179  hasKeys = true;
1180  break;
1181  }
1182  }
1183  if (!hasKeys) {
1184  if (!(origCount == 0 && d->size == 0)) {
1185  emit itemsRemoved(0, origCount);
1186  emit itemsInserted(0, d->size);
1187  emit countChanged();
1188  }
1189 
1190  } else {
1191  for (int i=0; i<result.removed.count(); i++)
1192  emit itemsRemoved(result.removed[i].first, result.removed[i].second);
1193  for (int i=0; i<result.inserted.count(); i++)
1194  emit itemsInserted(result.inserted[i].first, result.inserted[i].second);
1195 
1196  if (sizeChanged)
1197  emit countChanged();
1198  }
1199 
1200  emit statusChanged(d->status);
1201 }
QDeclarativeParserStatus ** d
QList< QPair< int, int > > inserted
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void itemsRemoved(int index, int count)
Emit this signal when count items are removed at index.
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
void itemsInserted(int index, int count)
Emit this signal when count items are inserted at index.
void statusChanged(QDeclarativeXmlListModel::Status)
QList< QPair< int, int > > removed
QList< QList< QVariant > > data

◆ queryError

void QDeclarativeXmlListModel::queryError ( void *  object,
const QString error 
)
privateslot

Definition at line 1147 of file qdeclarativexmllistmodel.cpp.

Referenced by classBegin().

1148 {
1149  // Be extra careful, object may no longer exist, it's just an ID.
1151  for (int i=0; i<d->roleObjects.count(); i++) {
1152  if (d->roleObjects.at(i) == static_cast<QDeclarativeXmlListModelRole*>(object)) {
1153  qmlInfo(d->roleObjects.at(i)) << QObject::tr("invalid query: \"%1\"").arg(error);
1154  return;
1155  }
1156  }
1157  qmlInfo(this) << QObject::tr("invalid query: \"%1\"").arg(error);
1158 }
QDeclarativeParserStatus ** d
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
#define Q_D(Class)
Definition: qglobal.h:2482
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QDeclarativeInfo qmlInfo(const QObject *me)

◆ reload

void QDeclarativeXmlListModel::reload ( )
slot

Definition at line 1041 of file qdeclarativexmllistmodel.cpp.

Referenced by componentComplete(), setNamespaceDeclarations(), setQuery(), setSource(), and setXml().

1042 {
1044 
1045  if (!d->isComponentComplete)
1046  return;
1047 
1049  d->queryId = -1;
1050 
1051  if (d->size < 0)
1052  d->size = 0;
1053 
1054  if (d->reply) {
1055  d->reply->abort();
1056  d->deleteReply();
1057  }
1058 
1059  if (!d->xml.isEmpty()) {
1060  d->queryId = QDeclarativeXmlQueryEngine::instance(qmlEngine(this))->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache);
1061  d->notifyQueryStarted(false);
1062 
1063  } else if (d->src.isEmpty()) {
1064  d->queryId = XMLLISTMODEL_CLEAR_ID;
1065  d->notifyQueryStarted(false);
1066  QTimer::singleShot(0, this, SLOT(dataCleared()));
1067 
1068  } else {
1069  d->notifyQueryStarted(true);
1070  QNetworkRequest req(d->src);
1071  req.setRawHeader("Accept", "application/xml,*/*");
1072  d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
1073  QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
1074  QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
1075  this, SLOT(requestProgress(qint64,qint64)));
1076  }
1077 }
static QDeclarativeXmlQueryEngine * instance(QDeclarativeEngine *engine)
QDeclarativeParserStatus ** d
#define SLOT(a)
Definition: qobjectdefs.h:226
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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 XMLLISTMODEL_CLEAR_ID
__int64 qint64
Definition: qglobal.h:942
QNetworkReply * get(const QNetworkRequest &request)
Posts a request to obtain the contents of the target request and returns a new QNetworkReply object o...
int doQuery(QString query, QString namespaces, QByteArray data, QList< QDeclarativeXmlListModelRole *> *roleObjects, QStringList keyRoleResultsCache)
Q_DECLARATIVE_EXPORT QDeclarativeEngine * qmlEngine(const QObject *)
bool singleShot
This static function calls a slot after a given time interval.
Definition: qtimer.h:59
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
QDeclarativeEngine * engine() const
Return the context&#39;s QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the QDeclar...
QNetworkAccessManager * networkAccessManager() const
Returns a common QNetworkAccessManager which can be used by any QML element instantiated by this engi...

◆ requestFinished

void QDeclarativeXmlListModel::requestFinished ( )
privateslot

Definition at line 1081 of file qdeclarativexmllistmodel.cpp.

Referenced by reload().

1082 {
1084 
1085  d->redirectCount++;
1086  if (d->redirectCount < XMLLISTMODEL_MAX_REDIRECT) {
1087  QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
1088  if (redirect.isValid()) {
1089  QUrl url = d->reply->url().resolved(redirect.toUrl());
1090  d->deleteReply();
1091  setSource(url);
1092  return;
1093  }
1094  }
1095  d->redirectCount = 0;
1096 
1097  if (d->reply->error() != QNetworkReply::NoError) {
1098  d->errorString = d->reply->errorString();
1099  d->deleteReply();
1100 
1101  int count = this->count();
1102  d->data.clear();
1103  d->size = 0;
1104  if (count > 0) {
1105  emit itemsRemoved(0, count);
1106  emit countChanged();
1107  }
1108 
1109  d->status = Error;
1110  d->queryId = -1;
1111  emit statusChanged(d->status);
1112  } else {
1113  QByteArray data = d->reply->readAll();
1114  if (data.isEmpty()) {
1115  d->queryId = XMLLISTMODEL_CLEAR_ID;
1116  QTimer::singleShot(0, this, SLOT(dataCleared()));
1117  } else {
1118  d->queryId = QDeclarativeXmlQueryEngine::instance(qmlEngine(this))->doQuery(d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache);
1119  }
1120  d->deleteReply();
1121 
1122  d->progress = 1.0;
1123  emit progressChanged(d->progress);
1124  }
1125 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
#define XMLLISTMODEL_MAX_REDIRECT
static QDeclarativeXmlQueryEngine * instance(QDeclarativeEngine *engine)
QDeclarativeParserStatus ** d
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define SLOT(a)
Definition: qobjectdefs.h:226
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
void itemsRemoved(int index, int count)
Emit this signal when count items are removed at index.
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
#define XMLLISTMODEL_CLEAR_ID
void progressChanged(qreal progress)
QUrl toUrl() const
Returns the variant as a QUrl if the variant has type() Url ; otherwise returns an invalid QUrl...
Definition: qvariant.cpp:2528
int doQuery(QString query, QString namespaces, QByteArray data, QList< QDeclarativeXmlListModelRole *> *roleObjects, QStringList keyRoleResultsCache)
Q_DECLARATIVE_EXPORT QDeclarativeEngine * qmlEngine(const QObject *)
bool singleShot
This static function calls a slot after a given time interval.
Definition: qtimer.h:59
void statusChanged(QDeclarativeXmlListModel::Status)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
virtual int count() const
Returns the number of data entries in the model.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
virtual QHash< int, QVariant > data(int index, const QList< int > &roles=(QList< int >())) const

◆ requestProgress

void QDeclarativeXmlListModel::requestProgress ( qint64  received,
qint64  total 
)
privateslot

Definition at line 1127 of file qdeclarativexmllistmodel.cpp.

Referenced by reload().

1128 {
1130  if (d->status == Loading && total > 0) {
1131  d->progress = qreal(received)/total;
1132  emit progressChanged(d->progress);
1133  }
1134 }
double qreal
Definition: qglobal.h:1193
QDeclarativeParserStatus ** d
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
void progressChanged(qreal progress)

◆ roleObjects()

QDeclarativeListProperty< QDeclarativeXmlListModelRole > QDeclarativeXmlListModel::roleObjects ( )

Definition at line 729 of file qdeclarativexmllistmodel.cpp.

Referenced by QDeclarativeXmlListModelPrivate::append_role(), and QDeclarativeXmlListModelPrivate::clear_role().

730 {
735  return list;
736 }
static void append_role(QDeclarativeListProperty< QDeclarativeXmlListModelRole > *list, QDeclarativeXmlListModelRole *role)
QDeclarativeParserStatus ** d
#define Q_D(Class)
Definition: qglobal.h:2482
static void clear_role(QDeclarativeListProperty< QDeclarativeXmlListModelRole > *list)

◆ roles()

virtual QList<int> QDeclarativeXmlListModel::roles ( ) const
virtual

Returns the list of roles for which the list model interface provides data.

Implements QListModelInterface.

Referenced by data().

◆ setNamespaceDeclarations()

void QDeclarativeXmlListModel::setNamespaceDeclarations ( const QString declarations)

Definition at line 894 of file qdeclarativexmllistmodel.cpp.

895 {
897  if (d->namespaces != declarations) {
898  d->namespaces = declarations;
899  reload();
901  }
902 }
QDeclarativeParserStatus ** d
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
static QVector< Declaration > declarations(const QVector< StyleRule > &styleRules, const QString &part, quint64 pseudoClass=PseudoClass_Unspecified)

◆ setQuery()

void QDeclarativeXmlListModel::setQuery ( const QString query)

Definition at line 852 of file qdeclarativexmllistmodel.cpp.

853 {
855  if (!query.startsWith(QLatin1Char('/'))) {
856  qmlInfo(this) << QCoreApplication::translate("QDeclarativeXmlRoleList", "An XmlListModel query must start with '/' or \"//\"");
857  return;
858  }
859 
860  if (d->query != query) {
861  d->query = query;
862  reload();
863  emit queryChanged();
864  }
865 }
QDeclarativeParserStatus ** d
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
#define Q_D(Class)
Definition: qglobal.h:2482
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
#define emit
Definition: qobjectdefs.h:76
QString query() const
QDeclarativeInfo qmlInfo(const QObject *me)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ setSource()

void QDeclarativeXmlListModel::setSource ( const QUrl src)

Definition at line 800 of file qdeclarativexmllistmodel.cpp.

Referenced by requestFinished().

801 {
803  if (d->src != src) {
804  d->src = src;
805  if (d->xml.isEmpty()) // src is only used if d->xml is not set
806  reload();
808  }
809 }
QDeclarativeParserStatus ** d
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76

◆ setXml()

void QDeclarativeXmlListModel::setXml ( const QString xml)

Definition at line 828 of file qdeclarativexmllistmodel.cpp.

829 {
831  if (d->xml != xml) {
832  d->xml = xml;
833  reload();
834  emit xmlChanged();
835  }
836 }
QDeclarativeParserStatus ** d
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76

◆ source()

QUrl QDeclarativeXmlListModel::source ( ) const

Referenced by toString().

◆ sourceChanged

void QDeclarativeXmlListModel::sourceChanged ( )
signal

Referenced by setSource().

◆ status()

Status QDeclarativeXmlListModel::status ( ) const

Referenced by get().

◆ statusChanged

void QDeclarativeXmlListModel::statusChanged ( QDeclarativeXmlListModel::Status  )
signal

Referenced by queryCompleted(), and requestFinished().

◆ toString()

QString QDeclarativeXmlListModel::toString ( int  role) const
virtual

Returns a string description of the specified role.

Implements QListModelInterface.

Definition at line 776 of file qdeclarativexmllistmodel.cpp.

777 {
779  int index = d->roles.indexOf(role);
780  if (index == -1)
781  return QString();
782  return d->roleNames.at(index);
783 }
QDeclarativeParserStatus ** d
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index

◆ xml()

QString QDeclarativeXmlListModel::xml ( ) const

Referenced by setSource(), and setXml().

◆ xmlChanged

void QDeclarativeXmlListModel::xmlChanged ( )
signal

Referenced by setXml().

Properties

◆ count

int QDeclarativeXmlListModel::count
private

Definition at line 86 of file qdeclarativexmllistmodel_p.h.

◆ namespaceDeclarations

QString QDeclarativeXmlListModel::namespaceDeclarations
private

Definition at line 84 of file qdeclarativexmllistmodel_p.h.

◆ progress

qreal QDeclarativeXmlListModel::progress
private

Definition at line 80 of file qdeclarativexmllistmodel_p.h.

◆ query

QString QDeclarativeXmlListModel::query
private

Definition at line 83 of file qdeclarativexmllistmodel_p.h.

◆ roles

QList< int > QDeclarativeXmlListModel::roles
private

◆ source

QUrl QDeclarativeXmlListModel::source
private

Definition at line 81 of file qdeclarativexmllistmodel_p.h.

◆ status

QDeclarativeXmlListModel::Status QDeclarativeXmlListModel::status
private

Definition at line 79 of file qdeclarativexmllistmodel_p.h.

◆ xml

QString QDeclarativeXmlListModel::xml
private

Definition at line 82 of file qdeclarativexmllistmodel_p.h.


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