• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

DNSSD

  • DNSSD
  • ServiceModel
Public Types | Public Member Functions | List of all members
DNSSD::ServiceModel Class Reference

#include <DNSSD/ServiceModel>

Inheritance diagram for DNSSD::ServiceModel:
Inheritance graph
[legend]

Public Types

enum  AdditionalRoles { ServicePtrRole = 0xA06519DE }
 
enum  ModelColumns { ServiceName = 0, Host = 1, Port = 2 }
 

Public Member Functions

 ServiceModel (ServiceBrowser *browser, QObject *parent=0)
 
virtual ~ServiceModel ()
 
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
 

Detailed Description

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

Definition at line 66 of file servicemodel.h.

Member Enumeration Documentation

enum DNSSD::ServiceModel::AdditionalRoles

The additional data roles provided by this model.

Enumerator
ServicePtrRole 

gets a RemoteService::Ptr for the service

Definition at line 73 of file servicemodel.h.

enum DNSSD::ServiceModel::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 
Host 
Port 

Definition at line 83 of file servicemodel.h.

Constructor & Destructor Documentation

DNSSD::ServiceModel::ServiceModel ( ServiceBrowser *  browser,
QObject *  parent = 0 
)
explicit

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.

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
Reimplemented from superclass.

Definition at line 51 of file servicemodel.cpp.

QVariant DNSSD::ServiceModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
virtual
Reimplemented from superclass.

Definition at line 78 of file servicemodel.cpp.

bool DNSSD::ServiceModel::hasIndex ( int  row,
int  column,
const QModelIndex &  parent 
) const
virtual
Reimplemented from superclass.

Definition at line 70 of file servicemodel.cpp.

QVariant DNSSD::ServiceModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
virtual
Reimplemented from superclass.

Definition at line 97 of file servicemodel.cpp.

QModelIndex DNSSD::ServiceModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
virtual
Reimplemented from superclass.

Definition at line 65 of file servicemodel.cpp.

QModelIndex DNSSD::ServiceModel::parent ( const QModelIndex &  index) const
virtual
Reimplemented from superclass.

Definition at line 60 of file servicemodel.cpp.

int DNSSD::ServiceModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual
Reimplemented from superclass.

Definition at line 55 of file servicemodel.cpp.


The documentation for this class was generated from the following files:
  • servicemodel.h
  • servicemodel.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:30 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

DNSSD

Skip menu "DNSSD"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal