File indexing completed on 2024-04-28 16:01:19
0001 /* 0002 SPDX-FileCopyrightText: 2008 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #include "kwebkitpartfactory.h" 0008 #include "kwebkitpart_debug.h" 0009 #include "kwebkitpart_ext.h" 0010 #include "kwebkitpart.h" 0011 0012 #include <KPluginMetaData> 0013 0014 KWebKitFactory::~KWebKitFactory() 0015 { 0016 // qCDebug(KWEBKITPART_LOG) << this; 0017 } 0018 0019 QObject *KWebKitFactory::create(const char* iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString& keyword) 0020 { 0021 Q_UNUSED(iface); 0022 Q_UNUSED(keyword); 0023 Q_UNUSED(args); 0024 0025 qCDebug(KWEBKITPART_LOG) << parentWidget << parent; 0026 connect(parentWidget, SIGNAL(destroyed(QObject*)), this, SLOT(slotDestroyed(QObject*))); 0027 0028 // NOTE: The code below is what makes it possible to properly integrate QtWebKit's 0029 // history management with any KParts based application. 0030 QByteArray histData (m_historyBufContainer.value(parentWidget)); 0031 if (!histData.isEmpty()) histData = qUncompress(histData); 0032 KWebKitPart* part = new KWebKitPart(parentWidget, parent, metaData(), histData); 0033 WebKitBrowserExtension* ext = qobject_cast<WebKitBrowserExtension*>(part->browserExtension()); 0034 if (ext) { 0035 connect(ext, SIGNAL(saveHistory(QObject*,QByteArray)), this, SLOT(slotSaveHistory(QObject*,QByteArray))); 0036 } 0037 return part; 0038 } 0039 0040 void KWebKitFactory::slotSaveHistory(QObject* widget, const QByteArray& buffer) 0041 { 0042 // qCDebug(KWEBKITPART_LOG) << "Caching history data from" << widget; 0043 m_historyBufContainer.insert(widget, buffer); 0044 } 0045 0046 void KWebKitFactory::slotDestroyed(QObject* object) 0047 { 0048 // qCDebug(KWEBKITPART_LOG) << "Removing cached history data of" << object; 0049 m_historyBufContainer.remove(object); 0050 }