File indexing completed on 2025-01-05 03:58:35

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-12-01
0007  * Description : Widget for displaying HTML in the backends - QtWebKit version
0008  *
0009  * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2009-2011 by Michael G. Hansen <mike at mghansen dot de>
0011  * SPDX-FileCopyrightText: 2015      by Mohamed_Anwer <m_dot_anwer at gmx dot com>
0012  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 #ifndef DIGIKAM_HTML_WIDGET_QWEBKIT_H
0018 #define DIGIKAM_HTML_WIDGET_QWEBKIT_H
0019 
0020 // Qt includes
0021 
0022 #include <qwebview.h>
0023 
0024 // Local includes
0025 
0026 #include "geoifacecommon.h"
0027 #include "geoifacetypes.h"
0028 #include "geocoordinates.h"
0029 
0030 namespace Digikam
0031 {
0032 
0033 class HTMLWidget : public QWebView
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038 
0039     explicit HTMLWidget(QWidget* const parent = nullptr);
0040     ~HTMLWidget();
0041 
0042     void loadInitialHTML(const QString& initialHTML);
0043     QVariant runScript(const QString& scriptCode, bool async = true);
0044     bool runScript2Coordinates(const QString& scriptCode, GeoCoordinates* const coordinates);
0045     void mouseModeChanged(const GeoMouseModes mouseMode);
0046     void setSelectionRectangle(const GeoCoordinates::Pair& searchCoordinates);
0047     void removeSelectionRectangle();
0048     void centerOn(const qreal west, const qreal north, const qreal east, const qreal south,
0049                   const bool useSaneZoomLevel = true);
0050     void setSharedGeoIfaceObject(GeoIfaceSharedData* const sharedData);
0051 
0052 protected:
0053 
0054     bool eventFilter(QObject* object, QEvent* event)    override;
0055     void mousePressEvent(QMouseEvent* e)                override;
0056     void mouseReleaseEvent(QMouseEvent* e)              override;
0057     void mouseMoveEvent(QMouseEvent* e)                 override;
0058 
0059 protected Q_SLOTS:
0060 
0061     void slotHTMLCompleted(bool ok);
0062     void slotScanForJSMessages(const QString& message);
0063     void progress(int progress);
0064 
0065 Q_SIGNALS:
0066 
0067     void signalHTMLEvents(const QStringList& events);
0068     void signalMessageEvent(const QString& message);
0069     void signalJavaScriptReady();
0070     void selectionHasBeenMade(const Digikam::GeoCoordinates::Pair& coordinatesRect);
0071 
0072 private:
0073 
0074     class Private;
0075     Private* const      d;
0076 
0077     GeoIfaceSharedData* s;
0078 };
0079 
0080 } // namespace Digikam
0081 
0082 #endif // DIGIKAM_HTML_WIDGET_QWEBKIT_H