DNSSD
DNSSD::ServiceModel Class Reference
#include <DNSSD/ServiceModel>

Detailed Description
ServiceModel implements Qt Model interface around ServiceBrowser to allow easy integration of service discovery into GUI.Example of combo box showing list of HTTP servers on local network:
DNSSD::ServiceModel* m=new ServiceModel(new DNSSD::ServiceBrowser("_http._tcp")); QComboBox *c=new QComboBox(); c->setModel(m);
After user makes the selection, application typically needs pointer to selected service in order to get host name and port. RemoteService::Ptr can be obtained from QModelIndex using:
void onSelected(const QModelIndex& selection) { DNSSD::RemoteService::Ptr service=selection.data(DNSSD::ServiceModel::ServicePtrRole). value<DNSSD::RemoteService::Ptr>();
- Since:
- 4.1 Model for list of Zeroconf services
Definition at line 61 of file servicemodel.h.
Public Types | |
enum | AdditionalRoles { ServicePtrRole = 0xA06519DE } |
enum | ModelColumns { ServiceName = 0, Host = 1, Port = 2 } |
Public Member Functions | |
virtual int | columnCount (const QModelIndex &parent=QModelIndex()) const |
virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
virtual bool | hasIndex (int row, int column, const QModelIndex &parent) const |
virtual QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
virtual QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
virtual QModelIndex | parent (const QModelIndex &index) const |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const |
ServiceModel (ServiceBrowser *browser, QObject *parent=0) | |
virtual | ~ServiceModel () |
Member Enumeration Documentation
- Enumerator:
-
ServicePtrRole returns pointer to service (RemoteService::Ptr type)
Definition at line 67 of file servicemodel.h.
Default columns for this model.
If service browser is not set to resolve automatically, then the model has only one column (service name).
Definition at line 75 of file servicemodel.h.
Constructor & Destructor Documentation
DNSSD::ServiceModel::ServiceModel | ( | ServiceBrowser * | browser, | |
QObject * | parent = 0 | |||
) | [explicit] |
Creates model for given service browses and starts browsing for services.
The model becomes parent of the browser so there is no need to delete it afterwards.
Definition at line 34 of file servicemodel.cpp.
DNSSD::ServiceModel::~ServiceModel | ( | ) | [virtual] |
Definition at line 46 of file servicemodel.cpp.
Member Function Documentation
int DNSSD::ServiceModel::columnCount | ( | const QModelIndex & | parent = QModelIndex() |
) | const [virtual] |
Definition at line 51 of file servicemodel.cpp.
QVariant DNSSD::ServiceModel::data | ( | const QModelIndex & | index, | |
int | role = Qt::DisplayRole | |||
) | const [virtual] |
Definition at line 78 of file servicemodel.cpp.
bool DNSSD::ServiceModel::hasIndex | ( | int | row, | |
int | column, | |||
const QModelIndex & | parent | |||
) | const [virtual] |
Definition at line 70 of file servicemodel.cpp.
QVariant DNSSD::ServiceModel::headerData | ( | int | section, | |
Qt::Orientation | orientation, | |||
int | role = Qt::DisplayRole | |||
) | const [virtual] |
Definition at line 97 of file servicemodel.cpp.
QModelIndex DNSSD::ServiceModel::index | ( | int | row, | |
int | column, | |||
const QModelIndex & | parent = QModelIndex() | |||
) | const [virtual] |
Definition at line 65 of file servicemodel.cpp.
QModelIndex DNSSD::ServiceModel::parent | ( | const QModelIndex & | index | ) | const [virtual] |
Definition at line 60 of file servicemodel.cpp.
int DNSSD::ServiceModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() |
) | const [virtual] |
Definition at line 55 of file servicemodel.cpp.
The documentation for this class was generated from the following files: