ServiceModel Class Reference
from PyKDE4.dnssd import *
Inherits: QAbstractItemModel → QObject
Namespace: DNSSD
Detailed Description
\class ServiceModel servicemodel.h DNSSD/ServiceModel
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
- Author:
-  Jakub Stachowski 
| 
 Enumerations | 
| AdditionalRoles | { ServicePtrRole } | 
| ModelColumns | { ServiceName, Host, Port } | 
| 
 Methods | 
|  | __init__ (self, DNSSD.ServiceBrowser browser, QObject parent=0) | 
| int | columnCount (self, QModelIndex parent=QModelIndex()) | 
| QVariant | data (self, QModelIndex index, int role=Qt.DisplayRole) | 
| bool | hasIndex (self, int row, int column, QModelIndex parent) | 
| QVariant | headerData (self, int section, Qt.Orientation orientation, int role=Qt.DisplayRole) | 
| QModelIndex | index (self, int row, int column, QModelIndex parent=QModelIndex()) | 
| QModelIndex | parent (self, QModelIndex index) | 
| int | rowCount (self, QModelIndex parent=QModelIndex()) | 
Method Documentation
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.
 
| int columnCount | ( | self, |  | 
|  |  | QModelIndex | parent=QModelIndex() | 
|  | ) |  |  |  | 
 
 
| bool hasIndex | ( | self, |  | 
|  |  | int | row, | 
|  |  | int | column, | 
|  |  | QModelIndex | parent | 
|  | ) |  |  |  | 
 
 
| int rowCount | ( | self, |  | 
|  |  | QModelIndex | parent=QModelIndex() | 
|  | ) |  |  |  | 
 
 
Enumeration Documentation
- Enumerator: 
- 
| ServicePtrRole = 0xA06519DE |  |  
 
 
Default columns for this model. If service browser is not set to resolve automatically, then the model
has only one column (service name).
- Enumerator: 
- 
| ServiceName = 0 |  |  | Host = 1 |  |  | Port = 2 |  |