aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/namevaluevalidator.h
blob: 1a9302095f80af40cc93dc5576052159bf4403a6 (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
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "utils_global.h"

#include "environmentfwd.h"

#include <QPersistentModelIndex>
#include <QTimer>
#include <QValidator>

QT_BEGIN_NAMESPACE
class QModelIndex;
QT_END_NAMESPACE

namespace Utils {

class NameValueModel;

class QTCREATOR_UTILS_EXPORT NameValueValidator : public QValidator
{
    Q_OBJECT
public:
    NameValueValidator(QWidget *parent,
                       NameValueModel *model,
                       QTreeView *view,
                       const QModelIndex &index,
                       const QString &toolTipText);

    QValidator::State validate(QString &in, int &pos) const override;

    void fixup(QString &input) const override;

private:
    const QString m_toolTipText;
    NameValueModel *m_model;
    QTreeView *m_view;
    QPersistentModelIndex m_index;
    mutable QTimer m_hideTipTimer;
};
} // namespace Utils