aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/debugger/sourcefileshandler.h
blob: d714eda2e3695efad64aae9b82232b43a51ece0b (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <utils/filepath.h>

#include <QAbstractItemModel>
#include <QStringList>

namespace Debugger::Internal {

class DebuggerEngine;

class SourceFilesHandler : public QAbstractItemModel
{
public:
    explicit SourceFilesHandler(DebuggerEngine *engine);

    int columnCount(const QModelIndex &parent) const override
        { return parent.isValid() ? 0 : 2; }
    int rowCount(const QModelIndex &parent) const override
        { return parent.isValid() ? 0 : m_shortNames.size(); }
    QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); }
    QModelIndex index(int row, int column, const QModelIndex &) const override
        { return createIndex(row, column); }
    QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
    QVariant data(const QModelIndex &index, int role) const override;
    bool setData(const QModelIndex &idx, const QVariant &data, int role) override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;

    void clearModel();

    void setSourceFiles(const QMap<QString, Utils::FilePath> &sourceFiles);
    void removeAll();

    QAbstractItemModel *model() { return m_proxyModel; }

private:
    DebuggerEngine *m_engine;
    QStringList m_shortNames;
    Utils::FilePaths m_fullNames;
    QAbstractItemModel *m_proxyModel;
};

} // Debugger::Internal