Qt 4.8
Public Functions | Properties | List of all members
QDeclarativeSqlQueryScriptClass Class Reference
Inheritance diagram for QDeclarativeSqlQueryScriptClass:
QScriptClass

Public Functions

QScriptValue property (const QScriptValue &object, const QScriptString &name, uint)
 Returns the value of the property with the given name of the given object. More...
 
QScriptValue::PropertyFlags propertyFlags (const QScriptValue &, const QScriptString &name, uint)
 Returns the flags of the property with the given name of the given object. More...
 
 QDeclarativeSqlQueryScriptClass (QScriptEngine *engine)
 
QueryFlags queryProperty (const QScriptValue &, const QScriptString &name, QueryFlags flags, uint *)
 Queries this script class for how access to the property with the given name of the given object should be handled. More...
 
void setProperty (QScriptValue &object, const QScriptString &name, uint, const QScriptValue &value)
 Sets the property with the given name of the given object to the given value. More...
 
- Public Functions inherited from QScriptClass
QScriptEngineengine () const
 Returns the engine that this QScriptClass is associated with. More...
 
virtual QVariant extension (Extension extension, const QVariant &argument=QVariant())
 This virtual function can be reimplemented in a QScriptClass subclass to provide support for extensions. More...
 
virtual QString name () const
 Returns the name of the script class. More...
 
virtual QScriptClassPropertyIteratornewIterator (const QScriptValue &object)
 Returns an iterator for traversing custom properties of the given object. More...
 
virtual QScriptValue prototype () const
 Returns the object to be used as the prototype of new instances of this class (created with QScriptEngine::newObject()). More...
 
 QScriptClass (QScriptEngine *engine)
 Constructs a QScriptClass object to be used in the given engine. More...
 
virtual bool supportsExtension (Extension extension) const
 Returns true if the QScriptClass supports the given extension; otherwise, false is returned. More...
 
virtual ~QScriptClass ()
 Destroys the QScriptClass object. More...
 

Properties

QScriptString str_forwardOnly
 
QScriptString str_length
 

Additional Inherited Members

- Public Types inherited from QScriptClass
enum  Extension { Callable, HasInstance }
 This enum specifies the possible extensions to a QScriptClass. More...
 
enum  QueryFlag { HandlesReadAccess = 0x01, HandlesWriteAccess = 0x02 }
 This enum describes flags that are used to query a QScriptClass regarding how access to a property should be handled. More...
 
- Protected Functions inherited from QScriptClass
 QScriptClass (QScriptEngine *engine, QScriptClassPrivate &dd)
 
- Protected Variables inherited from QScriptClass
QScopedPointer< QScriptClassPrivated_ptr
 

Detailed Description

Definition at line 70 of file qdeclarativesqldatabase.cpp.

Constructors and Destructors

◆ QDeclarativeSqlQueryScriptClass()

QDeclarativeSqlQueryScriptClass::QDeclarativeSqlQueryScriptClass ( QScriptEngine engine)
inline

Definition at line 72 of file qdeclarativesqldatabase.cpp.

Referenced by qmlsqldatabase_executeSql().

72  : QScriptClass(engine)
73  {
74  str_length = engine->toStringHandle(QLatin1String("length"));
75  str_forwardOnly = engine->toStringHandle(QLatin1String("forwardOnly")); // not in HTML5 (an optimization)
76  }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QScriptString toStringHandle(const QString &str)
Returns a handle that represents the given string, str.
QScriptClass(QScriptEngine *engine)
Constructs a QScriptClass object to be used in the given engine.

Functions

◆ property()

QScriptValue QDeclarativeSqlQueryScriptClass::property ( const QScriptValue object,
const QScriptString name,
uint  id 
)
inlinevirtual

Returns the value of the property with the given name of the given object.

The id argument is only useful if you assigned a value to it in queryProperty().

The default implementation does nothing and returns an invalid QScriptValue.

See also
setProperty(), propertyFlags()

Reimplemented from QScriptClass.

Definition at line 95 of file qdeclarativesqldatabase.cpp.

97  {
98  QSqlQuery query = qscriptvalue_cast<QSqlQuery>(object.data());
99  if (name == str_length) {
100  int s = query.size();
101  if (s<0) {
102  // Inefficient.
103  if (query.last()) {
104  return query.at()+1;
105  } else {
106  return 0;
107  }
108  } else {
109  return s;
110  }
111  } else if (name == str_forwardOnly) {
112  return query.isForwardOnly();
113  }
114  return engine()->undefinedValue();
115  }
T qscriptvalue_cast(const QScriptValue &)
The QSqlQuery class provides a means of executing and manipulating SQL statements.
Definition: qsqlquery.h:63
QScriptEngine * engine() const
Returns the engine that this QScriptClass is associated with.
bool last()
Retrieves the last record in the result, if available, and positions the query on the retrieved recor...
Definition: qsqlquery.cpp:703
bool isForwardOnly() const
Returns true if you can only scroll forward through a result set; otherwise returns false...
Definition: qsqlquery.cpp:806
int size() const
Returns the size of the result (number of rows returned), or -1 if the size cannot be determined or i...
Definition: qsqlquery.cpp:724
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
int at() const
Returns the current internal position of the query.
Definition: qsqlquery.cpp:420

◆ propertyFlags()

QScriptValue::PropertyFlags QDeclarativeSqlQueryScriptClass::propertyFlags ( const QScriptValue object,
const QScriptString name,
uint  id 
)
inlinevirtual

Returns the flags of the property with the given name of the given object.

The id argument is only useful if you assigned a value to it in queryProperty().

The default implementation returns 0.

See also
property()

Reimplemented from QScriptClass.

Definition at line 126 of file qdeclarativesqldatabase.cpp.

◆ queryProperty()

QueryFlags QDeclarativeSqlQueryScriptClass::queryProperty ( const QScriptValue object,
const QScriptString name,
QueryFlags  flags,
uint id 
)
inlinevirtual

Queries this script class for how access to the property with the given name of the given object should be handled.

The given flags specify the aspects of interest. This function should return a subset of flags to indicate which aspects of property access should be further handled by the script class.

For example, if the flags contain HandlesReadAccess, and you would like your class to handle the reading of the property (through the property() function), the returned flags should include HandlesReadAccess. If the returned flags do not contain HandlesReadAccess, the property will be handled as a normal script object property.

You can optionally use the id argument to store a value that will subsequently be passed on to functions such as property() and setProperty().

The default implementation of this function returns 0.

Note: This function is only called if the given property isn't already a normal property of the object. For example, say you advertise that you want to handle read access to property foo, but not write access; if foo is then assigned a value, it will become a normal script object property, and subsequently you will no longer be queried regarding read access to foo.

See also
property()

Reimplemented from QScriptClass.

Definition at line 78 of file qdeclarativesqldatabase.cpp.

81  {
82  if (flags & HandlesReadAccess) {
83  if (name == str_length) {
84  return HandlesReadAccess;
85  } else if (name == str_forwardOnly) {
86  return flags;
87  }
88  }
89  if (flags & HandlesWriteAccess)
90  if (name == str_forwardOnly)
91  return flags;
92  return 0;
93  }

◆ setProperty()

void QDeclarativeSqlQueryScriptClass::setProperty ( QScriptValue object,
const QScriptString name,
uint  id,
const QScriptValue value 
)
inlinevirtual

Sets the property with the given name of the given object to the given value.

The id argument is only useful if you assigned a value to it in queryProperty().

The default implementation does nothing.

An invalid value represents a request to remove the property.

See also
property()

Reimplemented from QScriptClass.

Definition at line 117 of file qdeclarativesqldatabase.cpp.

119  {
120  if (name == str_forwardOnly) {
121  QSqlQuery query = qscriptvalue_cast<QSqlQuery>(object.data());
122  query.setForwardOnly(value.toBool());
123  }
124  }
T qscriptvalue_cast(const QScriptValue &)
The QSqlQuery class provides a means of executing and manipulating SQL statements.
Definition: qsqlquery.h:63
bool toBool() const
Returns the boolean value of this QScriptValue, using the conversion rules described in ECMA-262 sect...
void setForwardOnly(bool forward)
Sets forward only mode to forward.
Definition: qsqlquery.cpp:835

Properties

◆ str_forwardOnly

QScriptString QDeclarativeSqlQueryScriptClass::str_forwardOnly
private

◆ str_length

QScriptString QDeclarativeSqlQueryScriptClass::str_length
private

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