Commit f9841b0f authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

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
parent e0f45add
Pipeline #40412 canceled with stage
/***************************************************************************
* Copyright (C) 2007 by Pino Toscano <pino@kde.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) any later version. *
***************************************************************************/
#ifndef _KDOCUMENTVIEWER_H_
#define _KDOCUMENTVIEWER_H_
#include "okularpart_export.h"
#include <QStringList>
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
......@@ -119,8 +119,6 @@
#include "xmlgui_helper.h"
#include <memory>
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;
......
......@@ -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 <greven@kde.org>
* @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();
......
......@@ -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<KDocumentViewer *>(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<KDocumentViewer *>(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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment