KIO
kdevicelistitem.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kdevicelistitem_p.h"
00021
00022 #include <solid/device.h>
00023
00024 class KDeviceListItem::Private
00025 {
00026 public:
00027 Private() : parent(0) {}
00028
00029 ~Private()
00030 {
00031 qDeleteAll(children);
00032 }
00033
00034 Solid::Device device;
00035 KDeviceListItem *parent;
00036
00037 QList<KDeviceListItem*> children;
00038 };
00039
00040 KDeviceListItem::KDeviceListItem()
00041 : d(new Private)
00042 {
00043 }
00044
00045 KDeviceListItem::~KDeviceListItem()
00046 {
00047 delete d;
00048 }
00049
00050 KDeviceListItem *KDeviceListItem::child(int row)
00051 {
00052 return d->children.value(row);
00053 }
00054
00055 QList<KDeviceListItem*> KDeviceListItem::children()
00056 {
00057 return d->children;
00058 }
00059
00060 int KDeviceListItem::indexOf(KDeviceListItem *child) const
00061 {
00062 return d->children.indexOf(child);
00063 }
00064
00065 int KDeviceListItem::childCount() const
00066 {
00067 return d->children.count();
00068 }
00069
00070 int KDeviceListItem::row() const
00071 {
00072 if (d->parent) {
00073 return d->parent->indexOf(const_cast<KDeviceListItem*>(this));
00074 } else {
00075 return 0;
00076 }
00077 }
00078
00079 void KDeviceListItem::setParent(KDeviceListItem *parent)
00080 {
00081 if (d->parent) {
00082 d->parent->removeChild(this);
00083 }
00084
00085 d->parent = parent;
00086
00087 if (d->parent) {
00088 d->parent->appendChild(this);
00089 }
00090 }
00091
00092 KDeviceListItem *KDeviceListItem::parent()
00093 {
00094 return d->parent;
00095 }
00096
00097 void KDeviceListItem::setDevice(const Solid::Device &device)
00098 {
00099 d->device = device;
00100 }
00101
00102 Solid::Device &KDeviceListItem::device()
00103 {
00104 return d->device;
00105 }
00106
00107 void KDeviceListItem::appendChild(KDeviceListItem *child)
00108 {
00109 d->children.append(child);
00110 }
00111
00112 void KDeviceListItem::removeChild(KDeviceListItem *child)
00113 {
00114 d->children.removeAll(child);
00115 }