KDE 4.1 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

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

__init__ (  self,
DNSSD.ServiceBrowser  browser,
QObject  parent=0
)

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()
)
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()
)

Enumeration Documentation

AdditionalRoles
Enumerator:
ServicePtrRole = 0xA06519DE

ModelColumns

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

  • Full Index

Modules

  • akonadi
  • dnssd
  • kdecore
  • kdeui
  • khtml
  • kio
  • knewstuff
  • kparts
  • kutils
  • nepomuk
  • phonon
  • solid
  • soprano
This documentation is maintained by Simon Edwards.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal