Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Source/QtDialog/QCMakeWidgets.h
5000 views
1
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2
file LICENSE.rst or https://cmake.org/licensing for details. */
3
#pragma once
4
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <QComboBox>
8
#include <QCompleter>
9
#include <QLineEdit>
10
11
class QToolButton;
12
class QSortFilterProxyModel;
13
14
// common widgets for Qt based CMake
15
16
/// Editor widget for editing paths or file paths
17
class QCMakeFileEditor : public QLineEdit
18
{
19
Q_OBJECT
20
public:
21
QCMakeFileEditor(QWidget* p, QString var);
22
protected slots:
23
virtual void chooseFile() = 0;
24
signals:
25
void fileDialogExists(bool);
26
27
protected:
28
void resizeEvent(QResizeEvent* e);
29
QToolButton* ToolButton;
30
QString Variable;
31
};
32
33
/// editor widget for editing files
34
class QCMakePathEditor : public QCMakeFileEditor
35
{
36
Q_OBJECT
37
public:
38
QCMakePathEditor(QWidget* p = nullptr, QString const& var = QString());
39
void chooseFile();
40
};
41
42
/// editor widget for editing paths
43
class QCMakeFilePathEditor : public QCMakeFileEditor
44
{
45
Q_OBJECT
46
public:
47
QCMakeFilePathEditor(QWidget* p = nullptr, QString const& var = QString());
48
void chooseFile();
49
};
50
51
/// completer class that returns native cmake paths
52
class QCMakeFileCompleter : public QCompleter
53
{
54
Q_OBJECT
55
public:
56
QCMakeFileCompleter(QObject* o, bool dirs);
57
virtual QString pathFromIndex(QModelIndex const& idx) const;
58
};
59
60
// editor for strings
61
class QCMakeComboBox : public QComboBox
62
{
63
Q_OBJECT
64
Q_PROPERTY(QString value READ currentText WRITE setValue USER true);
65
66
public:
67
QCMakeComboBox(QWidget* p, QStringList strings)
68
: QComboBox(p)
69
{
70
this->addItems(strings);
71
}
72
void setValue(QString const& v)
73
{
74
int i = this->findText(v);
75
if (i != -1) {
76
this->setCurrentIndex(i);
77
}
78
}
79
};
80
81
namespace QtCMake {
82
bool setSearchFilter(QSortFilterProxyModel* model,
83
QString const& searchString);
84
85
void setSearchFilterColor(QLineEdit* edit, bool valid);
86
}
87
88