KDE 4.4 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.ServiceModel

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

ModelColumns
Enumerator:

  • 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