File indexing completed on 2024-05-05 16:08:23

0001 /*  This file is part of the KDE project
0002     Copyright (C) 2006 Michael Larouche <michael.larouche@kdemail.net>
0003                   2007 Kevin Ottens <ervin@kde.org>
0004 
0005     This library is free software; you can redistribute it and/or
0006     modify it under the terms of the GNU Library General Public
0007     License version 2 as published by the Free Software Foundation.
0008 
0009     This library is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012     Library General Public License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to
0016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017     Boston, MA 02110-1301, USA.
0018 
0019 */
0020 #ifndef KDEVICELISTITEM_P_H
0021 #define KDEVICELISTITEM_P_H
0022 
0023 #include <QVariant>
0024 #include <QList>
0025 
0026 namespace Solid
0027 {
0028 class Device;
0029 }
0030 
0031 /**
0032  * @brief Item for the Device List model
0033  * Represent a Solid::Device in the tree device list model.
0034  * It helps to map the device in the tree.
0035  *
0036  * Keep a reference of the device that it maps.
0037  *
0038  * @author Michaƫl Larouche <michael.larouche@kdemail.net>
0039  */
0040 class KDeviceListItem
0041 {
0042 public:
0043     /**
0044      * @brief Create a new DeviceListItem
0045      */
0046     KDeviceListItem();
0047 
0048     /**
0049      * The d-tor duh.
0050      */
0051     ~KDeviceListItem();
0052 
0053     /**
0054      * @brief Return a child of this item according to the given row.
0055      * @param row row of the child to retrieve.
0056      * @return the child DeviceListItem
0057      */
0058     KDeviceListItem *child(int row);
0059 
0060     /**
0061      * @brief Get all the children of this item.
0062      * @return list of children.
0063      */
0064     QList<KDeviceListItem *> children();
0065 
0066     /**
0067      * @brief Returns the index position of a child in the list.
0068      * @param child the child to insert.
0069      * @return the index position of a child in the list.
0070      */
0071     int indexOf(KDeviceListItem *child) const;
0072 
0073     /**
0074      * @brief Helper method to get the numbers of childrens of this item.
0075      * @return the child count of this item.
0076      */
0077     int childCount() const;
0078 
0079     /**
0080      * Get the relative(to parent) row position of this item in the tree.
0081      * @return the row position.
0082      */
0083     int row() const;
0084 
0085     /**
0086      * @brief Set the parent of this item
0087      * @param parent the parent DeviceListItem.
0088      */
0089     void setParent(KDeviceListItem *parent);
0090 
0091     /**
0092      * @brief Get the parent of this item
0093      * @return the parent DeviceListItem.
0094      */
0095     KDeviceListItem *parent();
0096 
0097     /**
0098      * Get the Solid::Device reference for this item.
0099      * @param device the Solid::Device reference.
0100      */
0101     void setDevice(const Solid::Device &device);
0102 
0103     /**
0104      * Get the Solid::Device reference for this item.
0105      * @return the Solid::Device reference.
0106      */
0107     Solid::Device &device();
0108 
0109 private:
0110     /**
0111      * @brief Helper method to append a child DeviceListItem.
0112      * @param child child item to append.
0113      */
0114     void appendChild(KDeviceListItem *child);
0115 
0116     /**
0117      * @brief Helper method to remove a child DeviceListItem.
0118      * @param child child item to remove.
0119      */
0120     void removeChild(KDeviceListItem *child);
0121 
0122     class Private;
0123     Private *const d;
0124 };
0125 
0126 #endif