retro-imager/src/drivelistmodel.h

40 lines
1,017 B
C
Raw Normal View History

2020-03-04 16:55:40 +01:00
#ifndef DRIVELISTMODEL_H
#define DRIVELISTMODEL_H
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2020 Raspberry Pi Ltd
2020-03-04 16:55:40 +01:00
*/
#include <QAbstractItemModel>
#include <QMap>
#include <QHash>
#include "drivelistitem.h"
#include "drivelistmodelpollthread.h"
2020-03-04 16:55:40 +01:00
class DriveListModel : public QAbstractListModel
{
Q_OBJECT
2020-03-04 16:55:40 +01:00
public:
DriveListModel(QObject *parent = nullptr);
virtual int rowCount(const QModelIndex &) const;
virtual QHash<int, QByteArray> roleNames() const;
virtual QVariant data(const QModelIndex &index, int role) const;
void startPolling();
void stopPolling();
2020-03-04 16:55:40 +01:00
enum driveListRoles {
deviceRole = Qt::UserRole + 1, descriptionRole, sizeRole, isUsbRole, isScsiRole, isReadOnlyRole, mountpointsRole
2020-03-04 16:55:40 +01:00
};
public slots:
void processDriveList(std::vector<Drivelist::DeviceDescriptor> l);
2020-03-04 16:55:40 +01:00
protected:
QMap<QString,DriveListItem *> _drivelist;
QHash<int, QByteArray> _rolenames;
DriveListModelPollThread _thread;
2020-03-04 16:55:40 +01:00
};
#endif // DRIVELISTMODEL_H