File: modelviewer.h

package info (click to toggle)
plasma-sdk 6.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,264 kB
  • sloc: cpp: 4,446; xml: 452; sh: 27; makefile: 12
file content (55 lines) | stat: -rw-r--r-- 1,181 bytes parent folder | download | duplicates (2)
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
53
54
55
/*
 *   SPDX-FileCopyrightText: 2008 Aaron Seigo <aseigo@kde.org>
 *   SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
 *
 *   SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef MODELVIEWER
#define MODELVIEWER

#include <QAbstractItemDelegate>
#include <QDialog>
#include <QStyleOptionViewItem>

class QAbstractItemModel;
class QTreeView;

namespace Plasma5Support
{
class DataEngine;
} // namespace Plasma5Support

class Delegate : public QAbstractItemDelegate
{
    Q_OBJECT

public:
    explicit Delegate(QObject *parent = nullptr);
    ~Delegate() override;

    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;

protected:
    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};

class ModelViewer : public QDialog
{
    Q_OBJECT

public:
    ModelViewer(Plasma5Support::DataEngine *engine, const QString &m_source, QWidget *parent = nullptr);
    ~ModelViewer() override;

private Q_SLOTS:
    void engineDestroyed();

private:
    Plasma5Support::DataEngine *m_engine;
    QString m_source;
    QAbstractItemModel *m_model;
    QTreeView *m_view;
};

#endif