File indexing completed on 2023-05-30 09:09:56
0001 /* 0002 * This file is part of the KDE libraries 0003 * Copyright (C) 2007 Harri Porten (porten@kde.org) 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public 0016 * License along with this library; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0018 */ 0019 0020 #ifndef KHTMLADAPTORPART_H 0021 #define KHTMLADAPTORPART_H 0022 0023 #include <khtml_export.h> 0024 #include <kparts/part.h> 0025 #include <kparts/browserextension.h> 0026 #include <kpluginfactory.h> 0027 0028 namespace KJS 0029 { 0030 class ExecState; 0031 class JSObject; 0032 } 0033 0034 class ScriptingInterface 0035 { 0036 public: 0037 virtual ~ScriptingInterface() { } 0038 0039 virtual void initScripting(KJS::ExecState *exec) = 0; 0040 virtual void stopScripting() = 0; 0041 0042 virtual KJS::JSObject *scriptObject() = 0; 0043 }; 0044 0045 Q_DECLARE_INTERFACE(ScriptingInterface, "org.kde.khtml.ScriptingInterface") 0046 0047 class KHTMLAdaptorPartFactory : public KPluginFactory 0048 { 0049 Q_OBJECT 0050 public: 0051 KHTMLAdaptorPartFactory(); 0052 virtual QObject *create(const char *iface, 0053 QWidget *wparent, 0054 QObject *parent, 0055 const QVariantList &args, 0056 const QString &keyword) override; 0057 }; 0058 0059 class AdaptorView : public KParts::ReadOnlyPart, 0060 public ScriptingInterface 0061 { 0062 Q_OBJECT 0063 Q_INTERFACES(ScriptingInterface) 0064 public: 0065 AdaptorView(QWidget *wparent, QObject *parent, const QStringList &args); 0066 0067 void initScripting(KJS::ExecState *exec) override; 0068 void stopScripting() override { } 0069 KJS::JSObject *scriptObject() override; 0070 0071 protected: 0072 bool openFile() override; 0073 }; 0074 0075 #endif