File indexing completed on 2024-05-05 05:37:10

0001 /*
0002  *   SPDX-FileCopyrightText: 2008 Aaron Seigo <aseigo@kde.org>
0003  *   SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
0004  *
0005  *   SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #ifndef MODELVIEWER
0009 #define MODELVIEWER
0010 
0011 #include <QAbstractItemDelegate>
0012 #include <QDialog>
0013 #include <QStyleOptionViewItem>
0014 
0015 class QAbstractItemModel;
0016 class QTreeView;
0017 
0018 namespace Plasma5Support
0019 {
0020 class DataEngine;
0021 } // namespace Plasma5Support
0022 
0023 class Delegate : public QAbstractItemDelegate
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     explicit Delegate(QObject *parent = nullptr);
0029     ~Delegate() override;
0030 
0031     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0032 
0033 protected:
0034     QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0035 };
0036 
0037 class ModelViewer : public QDialog
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042     ModelViewer(Plasma5Support::DataEngine *engine, const QString &m_source, QWidget *parent = nullptr);
0043     ~ModelViewer() override;
0044 
0045 private Q_SLOTS:
0046     void engineDestroyed();
0047 
0048 private:
0049     Plasma5Support::DataEngine *m_engine;
0050     QString m_source;
0051     QAbstractItemModel *m_model;
0052     QTreeView *m_view;
0053 };
0054 
0055 #endif