From f9841b0f8aa9648096aefb90f2a3b675e43ec1fb Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 9 Nov 2020 23:30:07 +0100 Subject: [PATCH] Remove kdocumentviewer It was causing problems (Windows build fails) now that we enabled -Wweak-vtables (and probably before didn't work that much before, guessing that's why we had that if (doc) in openFile) This is the simplest solution, invokeMethod is not great but we already use it, so it's not too terrible The openDocument function was unused so remove it. The other two solutions are: * Make KDocumentViewer be part of okularcore and then link the okularcore to the okular binary, not nice * Make another dynamic library that just contains the KDocumentViewer class, but i'd rather not add yet another library we have to install and take care of --- kdocumentviewer.h | 58 ----------------------------------------------- part.cpp | 14 ------------ part.h | 11 ++++----- shell/shell.cpp | 8 ++----- 4 files changed, 6 insertions(+), 85 deletions(-) delete mode 100644 kdocumentviewer.h diff --git a/kdocumentviewer.h b/kdocumentviewer.h deleted file mode 100644 index 4aee11f59..000000000 --- a/kdocumentviewer.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Pino Toscano * - * * - * 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) any later version. * - ***************************************************************************/ - -#ifndef _KDOCUMENTVIEWER_H_ -#define _KDOCUMENTVIEWER_H_ - -#include "okularpart_export.h" - -#include - -class QUrl; - -/** - * @short Abstract interface for a document viewer - * - * This interface describes the basic functions of a document viewer. - */ -class OKULARPART_EXPORT KDocumentViewer -{ -public: - KDocumentViewer() - { - } - virtual ~KDocumentViewer(); - - KDocumentViewer(const KDocumentViewer &) = delete; - KDocumentViewer &operator=(const KDocumentViewer &) = delete; - - /** - * Open the document at the specified @p url at page @p page. - */ - virtual bool openDocument(const QUrl &url, uint page) = 0; - - /** - * Change to @p page the currently shown page. - */ - virtual void goToPage(uint page) = 0; - - /** - * Start the presentation mode. - */ - virtual void startPresentation() = 0; - - /** - * Return a list with the supported mimetypes. - */ - virtual QStringList supportedMimeTypes() const = 0; -}; - -Q_DECLARE_INTERFACE(KDocumentViewer, "org.kde.kdocumentviewer/0.1") - -#endif diff --git a/part.cpp b/part.cpp index 2117d27f7..90abefb71 100644 --- a/part.cpp +++ b/part.cpp @@ -119,8 +119,6 @@ #include "xmlgui_helper.h" #include -KDocumentViewer::~KDocumentViewer() = default; - #ifdef OKULAR_KEEP_FILE_OPEN class FileKeeper { @@ -979,18 +977,6 @@ Part::~Part() #endif } -bool Part::openDocument(const QUrl &url, uint page) -{ - Okular::DocumentViewport vp(page - 1); - vp.rePos.enabled = true; - vp.rePos.normalizedX = 0; - vp.rePos.normalizedY = 0; - vp.rePos.pos = Okular::DocumentViewport::TopLeft; - if (vp.isValid()) - m_document->setNextDocumentViewport(vp); - return openUrl(url); -} - void Part::startPresentation() { m_cliPresentation = true; diff --git a/part.h b/part.h index 54ab40020..2adb3c724 100644 --- a/part.h +++ b/part.h @@ -35,7 +35,6 @@ #include "core/document.h" #include "core/observer.h" #include "interfaces/viewerinterface.h" -#include "kdocumentviewer.h" #include "okularpart_export.h" @@ -109,11 +108,10 @@ enum EmbedMode { * @author Wilco Greven * @version 0.2 */ -class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::DocumentObserver, public KDocumentViewer, public Okular::ViewerInterface +class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::DocumentObserver, public Okular::ViewerInterface { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.okular") - Q_INTERFACES(KDocumentViewer) Q_INTERFACES(Okular::ViewerInterface) friend class PartTest; @@ -136,9 +134,8 @@ public: void notifyViewportChanged(bool smoothMove) override; void notifyPageChanged(int page, int flags) override; - bool openDocument(const QUrl &url, uint page) override; - void startPresentation() override; - QStringList supportedMimeTypes() const override; + Q_INVOKABLE void startPresentation(); + Q_INVOKABLE QStringList supportedMimeTypes() const; QUrl realUrl() const; @@ -152,7 +149,7 @@ public: Q_INVOKABLE bool activateTabIfAlreadyOpenFile() const; public Q_SLOTS: // dbus - Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page) override; + Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page); Q_SCRIPTABLE Q_NOREPLY void openDocument(const QString &doc); Q_SCRIPTABLE uint pages(); Q_SCRIPTABLE uint currentPage(); diff --git a/shell/shell.cpp b/shell/shell.cpp index 84f4a775d..8203a16e9 100644 --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -56,7 +56,6 @@ // local includes #include "../interfaces/viewerinterface.h" -#include "kdocumentviewer.h" #include "shellutils.h" static const char *shouldShowMenuBarComingFromFullScreen = "shouldShowMenuBarComingFromFullScreen"; @@ -424,9 +423,7 @@ void Shell::fileOpen() // button is clicked const int activeTab = m_tabWidget->currentIndex(); if (!m_fileformatsscanned) { - const KDocumentViewer *const doc = qobject_cast(m_tabs[activeTab].part); - if (doc) - m_fileformats = doc->supportedMimeTypes(); + QMetaObject::invokeMethod(m_tabs[activeTab].part, "supportedMimeTypes", Q_RETURN_ARG(QStringList, m_fileformats)); if (m_fileformats.isEmpty()) m_fileformats = fileFormats(); @@ -700,10 +697,9 @@ void Shell::openNewTab(const QUrl &url, const QString &serializedOptions) void Shell::applyOptionsToPart(QObject *part, const QString &serializedOptions) { - KDocumentViewer *const doc = qobject_cast(part); const QString find = ShellUtils::find(serializedOptions); if (ShellUtils::startInPresentation(serializedOptions)) - doc->startPresentation(); + QMetaObject::invokeMethod(part, "startPresentation"); if (ShellUtils::showPrintDialog(serializedOptions)) QMetaObject::invokeMethod(part, "enableStartWithPrint"); if (ShellUtils::showPrintDialogAndExit(serializedOptions))