Servus
1.5.1
C++ network oriented utilities including a zeroconf implementation
|
An item model on top of a Servus service, to be used in a Qt item view. More...
#include <itemModel.h>
Public Member Functions | |
SERVUSQT_API | ItemModel (Servus &service, QObject *parent=nullptr) |
Construct a new model by filling it with the current discovered instances and put the service into browsing state. More... | |
virtual SERVUSQT_API | ~ItemModel () |
Destruct the model and reset the service back to non-browsing state. More... | |
SERVUSQT_API QModelIndex | index (int row, int colum, const QModelIndex &parent=QModelIndex()) const override |
Mandatory override of QAbstractItemModel::index. More... | |
SERVUSQT_API QModelIndex | parent (const QModelIndex &index) const override |
Mandatory override of QAbstractItemModel::parent. More... | |
SERVUSQT_API int | rowCount (const QModelIndex &index=QModelIndex()) const override |
Mandatory override of QAbstractItemModel::rowCount. More... | |
SERVUSQT_API int | columnCount (const QModelIndex &index=QModelIndex()) const override |
Mandatory override of QAbstractItemModel::columnCount. More... | |
SERVUSQT_API QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
Mandatory override of QAbstractItemModel::data. More... | |
SERVUSQT_API QVariant | headerData (int section, Qt::Orientation orientation, int role) const override |
Optional override of QAbstractItemModel::headerData. More... | |
An item model on top of a Servus service, to be used in a Qt item view.
The model is represented as a hierarchy with two levels where the first level containts one row per discovered instance of the service, and the second level contains one row per announced key-value pair.
The model itself sets the given Servus instance into the browsing state and asynchronously browses for new and/or deleted instances every 100ms.
Definition at line 45 of file itemModel.h.
SERVUSQT_API servus::qt::ItemModel::ItemModel | ( | Servus & | service, |
QObject * | parent = nullptr |
||
) |
Construct a new model by filling it with the current discovered instances and put the service into browsing state.
service | the mutable service instance that the model represents |
parent | optional parent for memory ownership |
|
virtual |
Destruct the model and reset the service back to non-browsing state.
|
override |
Mandatory override of QAbstractItemModel::columnCount.
Independent of index, the column count will always be 1.
|
override |
Mandatory override of QAbstractItemModel::data.
If index points to an instance item, the returned data for Qt::DisplayRole will be the instance name, and for Qt::ToolTipRole and Qt::UserRole the data will be the hostname. If index points to a key-value item, the returned data for Qt::DisplayRole will be a string in the format "key = value". For any other index and/or role, the returned data will be QVariant().
|
override |
Optional override of QAbstractItemModel::headerData.
If orientation is Qt::Horizontal and role is Qt::DisplayRole, the returned data will be a string in the format "Instances for <service-name>". For any other input, the returned data will be QVariant().
|
override |
Mandatory override of QAbstractItemModel::index.
|
override |
Mandatory override of QAbstractItemModel::parent.
If index points to a key-value item, the parent will be the corresponding instance. If index points to an instance, the parent will be QModelIndex().
|
override |
Mandatory override of QAbstractItemModel::rowCount.
If index points is QModelIndex(), the row count will be the number of discovered instances. If index points to an instance item, the row count will be the number of announced key-value items. If index points to a key-value item, the row count will always be 0.