KDNSSD 5.109.0
servicemodel.h
1/*
2 This file is part of the KDE project
3
4 SPDX-FileCopyrightText: 2008 Jakub Stachowski <qbast@go2.pl>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KDNSSDSERVICEMODEL_H
10#define KDNSSDSERVICEMODEL_H
11
12#include "kdnssd_export.h"
13#include "remoteservice.h"
14#include <QAbstractItemModel>
15#include <memory>
16
17namespace KDNSSD
18{
19struct ServiceModelPrivate;
20class ServiceBrowser;
21
53class KDNSSD_EXPORT ServiceModel : public QAbstractItemModel
54{
55 Q_OBJECT
56
57public:
60 ServicePtrRole = 0xA06519DE,
61 };
62
70 ServiceName = 0,
71 Host = 1,
72 Port = 2,
73 };
74
85 explicit ServiceModel(ServiceBrowser *browser, QObject *parent = nullptr);
86
87 ~ServiceModel() override;
88
90 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
92 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
94 QModelIndex parent(const QModelIndex &index) const override;
96 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
98 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
100 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
102 virtual bool hasIndex(int row, int column, const QModelIndex &parent) const;
103
104private:
105 std::unique_ptr<ServiceModelPrivate> const d;
106 friend struct ServiceModelPrivate;
107};
108
109}
110
111#endif
Browses for network services advertised over DNS-SD.
Definition servicebrowser.h:55
Model for list of Zeroconf services.
Definition servicemodel.h:54
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
virtual bool hasIndex(int row, int column, const QModelIndex &parent) const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
AdditionalRoles
The additional data roles provided by this model.
Definition servicemodel.h:59
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
ServiceModel(ServiceBrowser *browser, QObject *parent=nullptr)
Creates a model for the given service browser and starts browsing for services.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
ModelColumns
The default columns for this model.
Definition servicemodel.h:69
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QModelIndex parent(const QModelIndex &index) const override