cmake/Source/QtDialog/QCMakeWidgets.h

87 lines
1.9 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
2009-10-04 10:30:41 +03:00
#include <QComboBox>
#include <QCompleter>
2016-07-09 11:21:54 +02:00
#include <QLineEdit>
class QToolButton;
2023-05-23 16:38:00 +02:00
class QSortFilterProxyModel;
// common widgets for Qt based CMake
/// Editor widget for editing paths or file paths
class QCMakeFileEditor : public QLineEdit
{
Q_OBJECT
public:
2019-11-11 23:01:05 +01:00
QCMakeFileEditor(QWidget* p, QString var);
protected slots:
virtual void chooseFile() = 0;
signals:
void fileDialogExists(bool);
2016-07-09 11:21:54 +02:00
protected:
void resizeEvent(QResizeEvent* e);
QToolButton* ToolButton;
QString Variable;
};
/// editor widget for editing files
class QCMakePathEditor : public QCMakeFileEditor
{
Q_OBJECT
public:
2018-01-26 17:06:56 +01:00
QCMakePathEditor(QWidget* p = nullptr, const QString& var = QString());
void chooseFile();
};
/// editor widget for editing paths
class QCMakeFilePathEditor : public QCMakeFileEditor
{
Q_OBJECT
public:
2018-01-26 17:06:56 +01:00
QCMakeFilePathEditor(QWidget* p = nullptr, const QString& var = QString());
void chooseFile();
};
/// completer class that returns native cmake paths
class QCMakeFileCompleter : public QCompleter
{
Q_OBJECT
public:
QCMakeFileCompleter(QObject* o, bool dirs);
virtual QString pathFromIndex(const QModelIndex& idx) const;
};
2009-10-04 10:30:41 +03:00
// editor for strings
class QCMakeComboBox : public QComboBox
{
Q_OBJECT
Q_PROPERTY(QString value READ currentText WRITE setValue USER true);
2016-07-09 11:21:54 +02:00
2009-10-04 10:30:41 +03:00
public:
2016-07-09 11:21:54 +02:00
QCMakeComboBox(QWidget* p, QStringList strings)
: QComboBox(p)
2009-10-04 10:30:41 +03:00
{
this->addItems(strings);
}
void setValue(const QString& v)
{
int i = this->findText(v);
2016-07-09 11:21:54 +02:00
if (i != -1) {
2009-10-04 10:30:41 +03:00
this->setCurrentIndex(i);
}
}
};
2023-05-23 16:38:00 +02:00
namespace QtCMake {
bool setSearchFilter(QSortFilterProxyModel* model,
const QString& searchString);
void setSearchFilterColor(QLineEdit* edit, bool valid);
}