summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/components/itemlibrary/assetimportupdatetreeitemdelegate.h
blob: da6d13861f1ac1ff8348fc594380683e1d9495b2 (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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <QItemDelegate>
#include <QStyleOptionViewItem>

namespace QmlDesigner {
namespace Internal {

class AssetImportUpdateTreeItemDelegate : public QItemDelegate
{
public:
    AssetImportUpdateTreeItemDelegate(QObject *parent = nullptr);
    void paint(QPainter *painter, const QStyleOptionViewItem &option,
               const QModelIndex &index) const override;
    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
    struct LayoutInfo
    {
        QRect checkRect;
        QRect textRect;
        QRect iconRect;
        Qt::CheckState checkState;
        QStyleOptionViewItem option;
    };

    LayoutInfo getLayoutInfo(const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void drawText(QPainter *painter, const QStyleOptionViewItem &option,
                  const QRect &rect, const QModelIndex &index) const;
};

} // namespace Internal
} // namespace QmlDesigner