blob: 6ced36f53460e82eac9b9ba7ddbdf0b9fb49e724 (
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
58
59
60
61
62
63
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "cpptoolsreuse.h"
#include <QAbstractListModel>
#include <QComboBox>
namespace CppEditor {
namespace Internal {
class ParseContextModel : public QAbstractListModel
{
Q_OBJECT
public:
void update(const ProjectPartInfo &projectPartInfo);
void setPreferred(int index);
void clearPreferred();
int currentIndex() const;
bool isCurrentPreferred() const;
QString currentId() const;
QString currentToolTip() const;
bool areMultipleAvailable() const;
signals:
void updated(bool areMultipleAvailable);
void preferredParseContextChanged(const QString &id);
private:
void reset(const ProjectPartInfo &projectPartInfo);
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
private:
ProjectPartInfo::Hints m_hints;
QList<ProjectPart::ConstPtr> m_projectParts;
int m_currentIndex = -1;
};
class ParseContextWidget : public QComboBox
{
Q_OBJECT
public:
ParseContextWidget(ParseContextModel &parseContextModel, QWidget *parent);
void syncToModel();
QSize minimumSizeHint() const final;
private:
ParseContextModel &m_parseContextModel;
QAction *m_clearPreferredAction = nullptr;
};
} // namespace Internal
} // namespace CppEditor
|