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

KIO

  • kio
  • kfile
kdevicelistitem.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 2006 Michael Larouche <michael.larouche@kdemail.net>
3 2007 Kevin Ottens <ervin@kde.org>
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 version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18
19*/
20#include "kdevicelistitem_p.h"
21
22#include <solid/device.h>
23
24class KDeviceListItem::Private
25{
26public:
27 Private() : parent(0) {}
28
29 ~Private()
30 {
31 qDeleteAll(children);
32 }
33
34 Solid::Device device;
35 KDeviceListItem *parent;
36
37 QList<KDeviceListItem*> children;
38};
39
40KDeviceListItem::KDeviceListItem()
41 : d(new Private)
42{
43}
44
45KDeviceListItem::~KDeviceListItem()
46{
47 delete d;
48}
49
50KDeviceListItem *KDeviceListItem::child(int row)
51{
52 return d->children.value(row);
53}
54
55QList<KDeviceListItem*> KDeviceListItem::children()
56{
57 return d->children;
58}
59
60int KDeviceListItem::indexOf(KDeviceListItem *child) const
61{
62 return d->children.indexOf(child);
63}
64
65int KDeviceListItem::childCount() const
66{
67 return d->children.count();
68}
69
70int KDeviceListItem::row() const
71{
72 if (d->parent) {
73 return d->parent->indexOf(const_cast<KDeviceListItem*>(this));
74 } else {
75 return 0;
76 }
77}
78
79void KDeviceListItem::setParent(KDeviceListItem *parent)
80{
81 if (d->parent) {
82 d->parent->removeChild(this);
83 }
84
85 d->parent = parent;
86
87 if (d->parent) {
88 d->parent->appendChild(this);
89 }
90}
91
92KDeviceListItem *KDeviceListItem::parent()
93{
94 return d->parent;
95}
96
97void KDeviceListItem::setDevice(const Solid::Device &device)
98{
99 d->device = device;
100}
101
102Solid::Device &KDeviceListItem::device()
103{
104 return d->device;
105}
106
107void KDeviceListItem::appendChild(KDeviceListItem *child)
108{
109 d->children.append(child);
110}
111
112void KDeviceListItem::removeChild(KDeviceListItem *child)
113{
114 d->children.removeAll(child);
115}
KDeviceListItem
Item for the Device List model Represent a Solid::Device in the tree device list model.
Definition: kdevicelistitem_p.h:41
KDeviceListItem::device
Solid::Device & device()
Get the Solid::Device reference for this item.
Definition: kdevicelistitem.cpp:102
KDeviceListItem::parent
KDeviceListItem * parent()
Get the parent of this item.
Definition: kdevicelistitem.cpp:92
KDeviceListItem::children
QList< KDeviceListItem * > children()
Get all the children of this item.
Definition: kdevicelistitem.cpp:55
KDeviceListItem::child
KDeviceListItem * child(int row)
Return a child of this item according to the given row.
Definition: kdevicelistitem.cpp:50
KDeviceListItem::~KDeviceListItem
~KDeviceListItem()
The d-tor duh.
Definition: kdevicelistitem.cpp:45
KDeviceListItem::setDevice
void setDevice(const Solid::Device &device)
Get the Solid::Device reference for this item.
Definition: kdevicelistitem.cpp:97
KDeviceListItem::childCount
int childCount() const
Helper method to get the numbers of childrens of this item.
Definition: kdevicelistitem.cpp:65
KDeviceListItem::row
int row() const
Get the relative(to parent) row position of this item in the tree.
Definition: kdevicelistitem.cpp:70
KDeviceListItem::KDeviceListItem
KDeviceListItem()
Create a new DeviceListItem.
Definition: kdevicelistitem.cpp:40
KDeviceListItem::indexOf
int indexOf(KDeviceListItem *child) const
Returns the index position of a child in the list.
Definition: kdevicelistitem.cpp:60
KDeviceListItem::setParent
void setParent(KDeviceListItem *parent)
Set the parent of this item.
Definition: kdevicelistitem.cpp:79
QList
kdevicelistitem_p.h
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.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • 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