1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #ifndef FB2VIEW_H
- #define FB2VIEW_H
- #include <QHash>
- #include <QResizeEvent>
- #include <QTimer>
- #include <QThread>
- #include <QWebElement>
- #include <QWebView>
- class Fb2BaseWebView : public QWebView
- {
- Q_OBJECT
- public:
- Fb2BaseWebView(QWidget* parent = 0)
- : QWebView(parent)
- {
- m_timer.setInterval(100);
- m_timer.setSingleShot(true);
- connect(&m_timer, SIGNAL(timeout()), SLOT(doResize()));
- }
- protected slots:
- void doResize() {
- QResizeEvent event(size(), m_size);
- QWebView::resizeEvent(&event);
- QWebView::update();
- }
- protected:
- void resizeEvent(QResizeEvent* event) {
- if (!m_timer.isActive()) m_size = event->oldSize();
- m_timer.start();
- }
- private:
- QTimer m_timer;
- QSize m_size;
- };
- class Fb2WebPage : public QWebPage
- {
- Q_OBJECT
- public:
- explicit Fb2WebPage(QObject *parent = 0);
- protected:
- virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
- };
- class Fb2WebView : public Fb2BaseWebView
- {
- Q_OBJECT
- public:
- explicit Fb2WebView(QWidget *parent = 0);
- virtual ~Fb2WebView();
- void load(const QString &filename);
- QString toBodyXml();
- QString toXml();
- bool UndoEnabled();
- bool RedoEnabled();
- bool CutEnabled();
- bool CopyEnabled();
- bool BoldChecked();
- bool ItalicChecked();
- bool StrikeChecked();
- bool SubChecked();
- bool SupChecked();
- signals:
-
- public slots:
- void linkHovered(const QString &link, const QString &title, const QString &textContent);
- void file(QString name, QString path);
- void html(QString name, QString html);
- void zoomIn();
- void zoomOut();
- void zoomOrig();
- private slots:
- void fixContents();
- private:
- QWebElement doc();
- private:
- typedef QHash<QString, QString> StringHash;
- StringHash m_files;
- QThread *m_thread;
- };
- #endif // FB2VIEW_H
|