MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QSparqlQueryModel Class Reference

The QSparqlQueryModel class provides a read-only data model for SPARQL result sets. More...

Inheritance diagram for QSparqlQueryModel:
QAbstractTableModel QAbstractItemModel QObject

List of all members.

Signals

void  finished ()
void  started ()

Public Member Functions

  QSparqlQueryModel (QObject *parent=0)
virtual  ~QSparqlQueryModel ()
int  rowCount (const QModelIndex &parent=QModelIndex()) const
int  columnCount (const QModelIndex &parent=QModelIndex()) const
QSparqlResultRow  resultRow (int row) const
QSparqlResultRow  resultRow () const
QVariant  data (const QModelIndex &item, int role=Qt::DisplayRole) const
QVariant  headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
bool  setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
bool  insertColumns (int column, int count, const QModelIndex &parent=QModelIndex())
bool  removeColumns (int column, int count, const QModelIndex &parent=QModelIndex())
void  setQuery (const QSparqlQuery &query, QSparqlConnection &conn)
QSparqlQuery  query () const
virtual void  clear ()
QSparqlError  lastError () const

Protected Member Functions

virtual void  queryChange ()
QModelIndex  indexInQuery (const QModelIndex &item) const
void  setLastError (const QSparqlError &error)

Detailed Description

The QSparqlQueryModel class provides a read-only data model for SPARQL result sets.

QSparqlQueryModel is a high-level interface for executing SPARQL statements and traversing the result set. It is built on top of the lower-level QSparqlQuery and can be used to provide data to view classes such as QTableView.

QSparqlQueryModel can also be used to access a connection programmatically, without binding it to a view.

See also:
QSparqlQuery

Constructor & Destructor Documentation

QSparqlQueryModel::QSparqlQueryModel ( QObject parent = 0  )  [explicit]

Creates an empty QSparqlQueryModel with the given parent.

QSparqlQueryModel::~QSparqlQueryModel (  )  [virtual]

Destroys the object and frees any allocated resources.

See also:
clear()

Member Function Documentation

void QSparqlQueryModel::clear (  )  [virtual]

Clears the model and releases any acquired resources. After this function, the model is not usable until setQuery() has been called.

See also:
setQuery()
int QSparqlQueryModel::columnCount ( const QModelIndex parent = QModelIndex()  )  const

Returns the number of columns, which is the number of variables in the select part of the query

Reimplemented from QAbstractItemModel.

QVariant QSparqlQueryModel::data ( const QModelIndex item,
int  role = Qt::DisplayRole  
) const

Returns the value for the specified item and role.

If item is out of bounds or if an error occurred, an invalid QVariant is returned.

See also:
lastError()

Reimplemented from QAbstractItemModel.

void QSparqlQueryModel::finished (  )  [signal]

This signal is emitted when the QSparqlResult, used by the model, has finished retrieving its data or when there was an error.

QVariant QSparqlQueryModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole  
) const [virtual]

Returns the header data for the given role in the section of the header with the specified orientation.

Reimplemented from QAbstractItemModel.

QModelIndex QSparqlQueryModel::indexInQuery ( const QModelIndex item  )  const [protected]

Returns the index of the value in the connection result set for the given item in the model.

The return value is identical to item if no columns or rows have been inserted, removed, or moved around.

Returns an invalid model index if item is out of bounds or if item does not point to a value in the result set.

See also:
QSparqlTableModel::indexInQuery(), insertColumns(), removeColumns()
bool QSparqlQueryModel::insertColumns ( int  column,
int  count,
const QModelIndex parent = QModelIndex()  
) [virtual]

Inserts count columns into the model at position column. The parent parameter must always be an invalid QModelIndex, since the model does not support parent-child relationships.

Returns true if column is within bounds; otherwise returns false.

By default, inserted columns are empty. To fill them with data, reimplement data() and handle any inserted column separately.

See also:
removeColumns()

Reimplemented from QAbstractItemModel.

QSparqlError QSparqlQueryModel::lastError (  )  const

Returns information about the last error that occurred on the connection.

See also:
query()
QSparqlQuery QSparqlQueryModel::query (  )  const

Returns the QSparqlQuery associated with this model.

See also:
setQuery()
void QSparqlQueryModel::queryChange (  )  [protected, virtual]

This virtual function is called whenever the query changes. The default implementation does nothing.

query() returns the new query.

See also:
query(), setQuery()
bool QSparqlQueryModel::removeColumns ( int  column,
int  count,
const QModelIndex parent = QModelIndex()  
) [virtual]

Removes count columns from the model starting from position column. The parent parameter must always be an invalid QModelIndex, since the model does not support parent-child relationships.

Removing columns effectively hides them. It does not affect the underlying QSparqlQuery.

Returns true if the columns were removed; otherwise returns false.

Reimplemented from QAbstractItemModel.

QSparqlResultRow QSparqlQueryModel::resultRow (  )  const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns an empty record containing information about the fields of the current query.

If the model is not initialized, an empty record will be returned.

See also:
QSparqlResultRow::isEmpty()
QSparqlResultRow QSparqlQueryModel::resultRow ( int  row  )  const

Returns the record containing information about the fields of the current query. If row is the index of a valid row, the record will be populated with values from that row.

If the model is not initialized, an empty record will be returned.

See also:
QSparqlResultRow::isEmpty()
int QSparqlQueryModel::rowCount ( const QModelIndex parent = QModelIndex()  )  const

If the connection supports returning the size of a query (see QSparqlConnection::hasFeature()), the number of rows of the current query is returned. Otherwise, returns the number of rows currently cached on the client.

parent should always be an invalid QModelIndex.

See also:
canFetchMore(), QSparqlConnection::hasFeature()

Reimplemented from QAbstractItemModel.

bool QSparqlQueryModel::setHeaderData ( int  section,
Qt::Orientation  orientation,
const QVariant value,
int  role = Qt::EditRole  
) [virtual]

Sets the caption for a horizontal header for the specified role to value. This is useful if the model is used to display data in a view (e.g., QTableView).

Returns true if orientation is Qt::Horizontal and the section refers to a valid section; otherwise returns false.

Note that this function cannot be used to modify values in the connection since the model is read-only.

See also:
data()

Reimplemented from QAbstractItemModel.

void QSparqlQueryModel::setLastError ( const QSparqlError error  )  [protected]

Protected function which allows derived classes to set the value of the last error that occurred on the connection to error.

See also:
lastError()
void QSparqlQueryModel::setQuery ( const QSparqlQuery query,
QSparqlConnection connection  
)

Executes the query query for the given connection connection connection. If no connection is specified, the default connection is used.

lastError() can be used to retrieve verbose information if there was an error setting the query.

See also:
query(), queryChange(), lastError()
void QSparqlQueryModel::started (  )  [signal]

This signal is emitted when the QSparqlResult, used by the model, has started to execute.


Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
Commercial Qt/LGPL 2.1 with Nokia exception/GPL 3.0
MeeGo 1.2 Harmattan API