aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/baremetal/debugservers/uvsc/uvtargetdevicemodel.h
blob: d84ea64e2238991d3ebe0cb89e92801403c427b6 (plain)
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
48
49
50
51
52
53
54
55
56
57
// Copyright (C) 2020 Denis Shienkov <denis.shienkov@gmail.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "uvtargetdeviceselection.h"

#include <utils/basetreeview.h>
#include <utils/filepath.h>
#include <utils/treemodel.h>

QT_BEGIN_NAMESPACE
class QXmlStreamReader;
QT_END_NAMESPACE

namespace BareMetal::Internal::Uv {

// DeviceSelectionModel

class DeviceSelectionItem;
class DeviceSelectionModel final : public Utils::TreeModel<DeviceSelectionItem>
{
    Q_OBJECT

public:
    explicit DeviceSelectionModel(QObject *parent = nullptr);
    void fillAllPacks(const Utils::FilePath &toolsIniFile);

private:
    void parsePackage(const QString &packageFile);
    void parsePackage(QXmlStreamReader &in, const QString &packageFile);
    void parseFamily(QXmlStreamReader &in, DeviceSelectionItem *parent);
    void parseSubFamily(QXmlStreamReader &in, DeviceSelectionItem *parent);
    void parseDevice(QXmlStreamReader &in, DeviceSelectionItem *parent);
    void parseDeviceVariant(QXmlStreamReader &in, DeviceSelectionItem *parent);

    Utils::FilePath m_toolsIniFile;
};

// DeviceSelectionView

class DeviceSelectionView final : public Utils::TreeView
{
    Q_OBJECT
public:
    explicit DeviceSelectionView(QWidget *parent = nullptr);

signals:
    void deviceSelected(const DeviceSelection &selection);

private:
    void currentChanged(const QModelIndex &current, const QModelIndex &previous) final;

    DeviceSelection buildSelection(const DeviceSelectionItem *item) const;
};

} // BareMetal::Internal::Uv