1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
/***************************************************************************
Copyright (C) 2003-2020 Robby Stephenson <robby@periapsis.org>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License or (at your option) version 3 or any later version *
* accepted by the membership of KDE e.V. (or its successor approved *
* by the membership of KDE e.V.), which shall act as a proxy *
* defined in Section 14 of version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
***************************************************************************/
#ifndef TELLICO_ENTRYVIEW_H
#define TELLICO_ENTRYVIEW_H
#include "datavectors.h"
#ifdef USE_KHTML
#include <KHTMLPart>
#include <KHTMLView>
#else
#include <QWebEngineView>
#include <QWebEnginePage>
#include <QPrinter>
#endif
class QTemporaryFile;
namespace Tellico {
class XSLTHandler;
class ImageFactory;
class StyleOptions;
/**
* @author Robby Stephenson
*/
class EntryView : public
#ifdef USE_KHTML
KHTMLPart {
#else
QWebEngineView {
#endif
Q_OBJECT
public:
/**
* The EntryView shows a HTML representation of the data in the entry.
*
* @param parent QWidget parent
*/
EntryView(QWidget* parent);
/**
*/
virtual ~EntryView();
/**
* Uses the xslt handler to convert an entry to html, and then writes that html to the view
*
* @param entry The entry to show
*/
void showEntry(Data::EntryPtr entry);
void showText(const QString& text);
/**
* Clear the widget and set Entry pointer to NULL
*/
void clear();
/**
* Sets the XSLT file. If the file name does not start with a back-slash, then the
* standard directories are searched.
*
* @param file The XSLT file name
*/
void setXSLTFile(const QString& file);
void addXSLTStringParam(const QByteArray& name, const QByteArray& value);
void setXSLTOptions(const StyleOptions& options);
void setUseGradientImages(bool b) { m_useGradientImages = b; }
void resetView();
Q_SIGNALS:
void signalTellicoAction(const QUrl& url);
public Q_SLOTS:
void copy();
/**
* Helper function to refresh view.
*/
void slotRefresh();
void showEntries(Tellico::Data::EntryList entries);
private Q_SLOTS:
/**
* Open a URL.
*
* @param url The URL to open
*/
void slotOpenURL(const QUrl& url);
void slotReloadEntry();
protected:
#ifdef USE_KHTML
void changeEvent(QEvent* event);
#else
void changeEvent(QEvent* event) override;
#endif
private Q_SLOTS:
void slotPrint();
private:
void resetColors();
#ifdef USE_KHTML
void contextMenuEvent(QContextMenuEvent* event);
#else
void contextMenuEvent(QContextMenuEvent* event) override;
#endif
Data::EntryPtr m_entry;
XSLTHandler* m_handler;
QString m_xsltFile;
QString m_textToShow;
QTemporaryFile* m_tempFile;
bool m_useGradientImages;
bool m_checkCommonFile;
#ifndef USE_KHTML
QPrinter m_printer;
#endif
};
#ifdef USE_KHTML
class EntryViewWidget : public KHTMLView {
Q_OBJECT
public:
EntryViewWidget(EntryView* part, QWidget* parent);
public Q_SLOTS:
void copy();
protected:
void changeEvent(QEvent* event) override;
};
#else
class EntryViewPage : public QWebEnginePage {
Q_OBJECT
public:
EntryViewPage(QWidget* parent);
Q_SIGNALS:
void signalTellicoAction(const QUrl& url);
protected:
virtual bool acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool isMainFrame) override;
virtual QWebEnginePage* createWindow(QWebEnginePage::WebWindowType type) override;
private:
void openExternalLink(const QUrl& url);
};
#endif
} //end namespace
#endif
|