File: DeviceModel.h

package info (click to toggle)
kde-runtime 4%3A17.08.3-2.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 25,204 kB
  • sloc: cpp: 111,675; ansic: 5,030; perl: 1,579; xml: 793; sh: 407; makefile: 42; python: 28
file content (47 lines) | stat: -rw-r--r-- 1,520 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef DEVICEMODEL_H
#define DEVICEMODEL_H

#include <QtCore/QAbstractItemModel>
#include <QtCore/QModelIndex>
#include <QtCore/QVariant>
#include <QtCore/QList>
#include <QtCore/QHash>

class DeviceModel : public QAbstractItemModel {
    Q_OBJECT

    public:
		enum DeviceType {
			Attached,
			Detatched
		};

		enum {
			UdiRole = Qt::UserRole,
			TypeRole
		};
        DeviceModel(QObject* parent = 0);
        ~DeviceModel();
        Qt::ItemFlags flags(const QModelIndex &index) const;
        QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
        QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
        int rowCount(const QModelIndex &parent = QModelIndex()) const;
        int columnCount(const QModelIndex &parent = QModelIndex()) const;
        QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
        QModelIndex parent(const QModelIndex &index) const;
        bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    public slots:
        void forgetDevice(const QString &udi);
        void reload();
    private slots:
        void deviceAttached(const QString &udi);
        void deviceRemoved(const QString &udi);
    private:
        void addNewDevice(const QString &udi);
        QList<QString> m_attached;
        QList<QString> m_disconnected;
        QHash<QString, bool> m_loginForced;
        QHash<QString, bool> m_attachedForced;
};

#endif