KDE 4.7 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

ServiceModel servicemodel.h DNSSD/ServiceModel Model for list of Zeroconf services

This class provides a Qt Model for ServiceBrowser to allow easy integration of service discovery into a GUI. For example, to show the HTTP servers published on the local network, you can do:

 DNSSD.ServiceModel *serviceModel = new ServiceModel(
     new DNSSD.ServiceBrowser("_http._tcp")
     );
 QComboBox *serviceCombo = new QComboBox();
 serviceCombo->setModel(serviceModel);

After the user makes a selection, the application typically needs to get a pointer to the selected service in order to get the host name and port. A RemoteService.Ptr can be obtained from a QModelIndex using:

 void onSelected(const QModelIndex &selection) {
     DNSSD.RemoteService.Ptr service =
         selection.data(DNSSD.ServiceModel.ServicePtrRole)
                  .value<DNSSD.RemoteService.Ptr>();
 }

Since:
4.1
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 a model for the given service browser and starts browsing for services.

The model takes ownership of the browser, so there is no need to delete it afterwards.

You should not call ServiceBrowser.startBrowse() on browser before passing it to ServiceModel.

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

The additional data roles provided by this model

Enumerator:
ServicePtrRole = 0xA06519DE

ModelColumns

The default columns for this model.

If service browser is not set to resolve automatically, then the model will only ever have one column (the service name).

Enumerator:
ServiceName = 0
Host = 1
Port = 2

  • Full Index

Modules

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