aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/squish/propertyitemdelegate.h
blob: 6967fcb7f853c343163c9ee0b5b866f8ed322c9d (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
// Copyright (C) 2022 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/fancylineedit.h>

#include <QStyledItemDelegate>

namespace Squish {
namespace Internal {

class PropertyItemDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    PropertyItemDelegate(QObject *parent = nullptr);
    void paint(QPainter *painter,
               const QStyleOptionViewItem &option,
               const QModelIndex &index) const override;

    QWidget *createEditor(QWidget *parent,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const override;
    void setEditorData(QWidget *editor, const QModelIndex &index) const override;
    void setModelData(QWidget *editor,
                      QAbstractItemModel *model,
                      const QModelIndex &index) const override;
};

class ValidatingPropertyNameLineEdit : public Utils::FancyLineEdit
{
    Q_OBJECT
public:
    ValidatingPropertyNameLineEdit(const QStringList &forbidden, QWidget *parent = nullptr);

private:
    QStringList m_forbidden;
};

class ValidatingPropertyContainerLineEdit : public Utils::FancyLineEdit
{
    Q_OBJECT
public:
    ValidatingPropertyContainerLineEdit(const QStringList &allowed, QWidget *parent = nullptr);

private:
    QStringList m_allowed;
};

} // namespace Internal
} // namespace Squish