File indexing completed on 2024-06-16 07:42:25

0001 /*
0002     SPDX-FileCopyrightText: 2007-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef _K3B_DEVICE_MODEL_H_
0009 #define _K3B_DEVICE_MODEL_H_
0010 
0011 #include "k3b_export.h"
0012 
0013 #include <QAbstractItemModel>
0014 
0015 namespace K3b {
0016     namespace Device {
0017         class Device;
0018     }
0019 
0020     class LIBK3B_EXPORT DeviceModel : public QAbstractItemModel
0021     {
0022         Q_OBJECT
0023 
0024     public:
0025         explicit DeviceModel( QObject* parent = 0 );
0026         ~DeviceModel() override;
0027 
0028         QList<Device::Device*> devices() const;
0029 
0030         Device::Device* deviceForIndex( const QModelIndex& index ) const;
0031         QModelIndex indexForDevice( Device::Device* dev ) const;
0032 
0033         int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
0034         QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
0035         QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override;
0036         QModelIndex parent( const QModelIndex& index ) const override;
0037         int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
0038 
0039         enum DeviceRoles {
0040             IsDevice = 1000, //**< boolean value only used to check if we have a device item */
0041             Vendor,
0042             Description,
0043             BlockDevice,
0044             Valid
0045         };
0046 
0047     public Q_SLOTS:
0048         void addDevice( K3b::Device::Device* );
0049         void addDevices( const QList<K3b::Device::Device*>& );
0050         void setDevices( const QList<K3b::Device::Device*>& devices );
0051         void removeDevice( K3b::Device::Device* dev );
0052         void clear();
0053 
0054     private Q_SLOTS:
0055         void slotMediumChanged( K3b::Device::Device* dev );
0056         void slotCheckingMedium( K3b::Device::Device* dev, const QString& );
0057 
0058     private:
0059         class Private;
0060         Private* const d;
0061     };
0062 }
0063 
0064 #endif