File indexing completed on 2024-04-21 15:02:06

0001 /* This file is part of the KDE libraries
0002     Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
0003     Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
0004     Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
0005     Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 #ifndef KJS_OBJECT_MODEL
0023 #define KJS_OBJECT_MODEL
0024 
0025 #include <QModelIndex>
0026 #include <QVariant>
0027 
0028 namespace KJS
0029 {
0030 class Interpreter;
0031 class JSObject;
0032 }
0033 
0034 struct Node;
0035 class KJSObjectModel : public QAbstractItemModel
0036 {
0037     Q_OBJECT
0038 public:
0039     explicit KJSObjectModel(KJS::Interpreter *js, QObject *parent = nullptr);
0040     ~KJSObjectModel() override;
0041 
0042     QVariant data(const QModelIndex &index, int role) const override;
0043     Qt::ItemFlags flags(const QModelIndex &index) const override;
0044     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
0045     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
0046     QModelIndex parent(const QModelIndex &index) const override;
0047     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0048     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0049 
0050     void updateModel(KJS::JSObject *m_root);
0051 
0052 private:
0053     KJS::Interpreter *m_js;
0054     KJS::JSObject *m_root;
0055 };
0056 
0057 #endif