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

DNSSD

  • dnssd
domainmodel.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 *
3 * Copyright (C) 2008 Jakub Stachowski <qbast@go2.pl>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include "domainmodel.h"
22#include "domainbrowser.h"
23#include <qstringlist.h>
24
25namespace DNSSD
26{
27
28struct DomainModelPrivate
29{
30 DomainBrowser* m_browser;
31};
32
33
34DomainModel::DomainModel(DomainBrowser* browser, QObject* parent)
35 : QAbstractItemModel(parent), d(new DomainModelPrivate)
36{
37 d->m_browser=browser;
38 browser->setParent(this);
39 connect(browser, SIGNAL(domainAdded(QString)), this,
40 SIGNAL(layoutChanged()));
41 connect(browser, SIGNAL(domainRemoved(QString)), this,
42 SIGNAL(layoutChanged()));
43 browser->startBrowse();
44}
45
46DomainModel::~DomainModel()
47{
48 delete d;
49}
50
51int DomainModel::columnCount(const QModelIndex& parent) const
52{
53 Q_UNUSED(parent);
54 return 1;
55}
56int DomainModel::rowCount(const QModelIndex& parent ) const
57{
58 return (parent.isValid()) ? 0 : d->m_browser->domains().size();
59}
60
61QModelIndex DomainModel::parent(const QModelIndex& index ) const
62{
63 Q_UNUSED(index);
64 return QModelIndex();
65}
66
67QModelIndex DomainModel::index(int row, int column, const QModelIndex& parent ) const
68{
69 return hasIndex(row, column, parent) ? createIndex(row, column) : QModelIndex();
70}
71
72bool DomainModel::hasIndex(int row, int column, const QModelIndex &parent) const
73{
74 if (parent.isValid()) return false;
75 if (column!=0) return false;
76 if (row<0 || row>=rowCount(parent)) return false;
77 return true;
78}
79
80QVariant DomainModel::data(const QModelIndex& index, int role ) const
81{
82 if (!index.isValid()) return QVariant();
83 if (!hasIndex(index.row(), index.column(), index.parent())) return QVariant();
84 const QStringList domains=d->m_browser->domains();
85 if (role==Qt::DisplayRole) return domains[index.row()];
86 return QVariant();
87}
88
89}
DNSSD::DomainBrowser
Browses recommended domains for browsing or publishing to.
Definition: domainbrowser.h:55
DNSSD::DomainBrowser::startBrowse
void startBrowse()
Starts browsing.
Definition: dummy-domainbrowser.cpp:34
DNSSD::DomainModel::data
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: domainmodel.cpp:80
DNSSD::DomainModel::columnCount
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: domainmodel.cpp:51
DNSSD::DomainModel::parent
virtual QModelIndex parent(const QModelIndex &index) const
Definition: domainmodel.cpp:61
DNSSD::DomainModel::rowCount
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: domainmodel.cpp:56
DNSSD::DomainModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: domainmodel.cpp:67
DNSSD::DomainModel::DomainModel
DomainModel(DomainBrowser *browser, QObject *parent=0)
Creates a model for given domain browser and starts browsing for domains.
Definition: domainmodel.cpp:34
DNSSD::DomainModel::hasIndex
virtual bool hasIndex(int row, int column, const QModelIndex &parent) const
Definition: domainmodel.cpp:72
DNSSD::DomainModel::~DomainModel
virtual ~DomainModel()
Definition: domainmodel.cpp:46
QAbstractItemModel
QObject
domainbrowser.h
domainmodel.h
DNSSD
Definition: domainbrowser.h:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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