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
remotes/origin/work/carl/mobile-drawer-improvement
Albert Astals Cid 5 years ago
parent e0f45add55
commit f9841b0f8a
  1. 58
      kdocumentviewer.h
  2. 14
      part.cpp
  3. 11
      part.h
  4. 8
      shell/shell.cpp

@ -1,58 +0,0 @@
/***************************************************************************
* 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 "xmlgui_helper.h"
#include <memory> #include <memory>
KDocumentViewer::~KDocumentViewer() = default;
#ifdef OKULAR_KEEP_FILE_OPEN #ifdef OKULAR_KEEP_FILE_OPEN
class FileKeeper class FileKeeper
{ {
@ -979,18 +977,6 @@ Part::~Part()
#endif #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() void Part::startPresentation()
{ {
m_cliPresentation = true; m_cliPresentation = true;

@ -35,7 +35,6 @@
#include "core/document.h" #include "core/document.h"
#include "core/observer.h" #include "core/observer.h"
#include "interfaces/viewerinterface.h" #include "interfaces/viewerinterface.h"
#include "kdocumentviewer.h"
#include "okularpart_export.h" #include "okularpart_export.h"
@ -109,11 +108,10 @@ enum EmbedMode {
* @author Wilco Greven <greven@kde.org> * @author Wilco Greven <greven@kde.org>
* @version 0.2 * @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_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.okular") Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
Q_INTERFACES(KDocumentViewer)
Q_INTERFACES(Okular::ViewerInterface) Q_INTERFACES(Okular::ViewerInterface)
friend class PartTest; friend class PartTest;
@ -136,9 +134,8 @@ public:
void notifyViewportChanged(bool smoothMove) override; void notifyViewportChanged(bool smoothMove) override;
void notifyPageChanged(int page, int flags) override; void notifyPageChanged(int page, int flags) override;
bool openDocument(const QUrl &url, uint page) override; Q_INVOKABLE void startPresentation();
void startPresentation() override; Q_INVOKABLE QStringList supportedMimeTypes() const;
QStringList supportedMimeTypes() const override;
QUrl realUrl() const; QUrl realUrl() const;
@ -152,7 +149,7 @@ public:
Q_INVOKABLE bool activateTabIfAlreadyOpenFile() const; Q_INVOKABLE bool activateTabIfAlreadyOpenFile() const;
public Q_SLOTS: // dbus 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 Q_NOREPLY void openDocument(const QString &doc);
Q_SCRIPTABLE uint pages(); Q_SCRIPTABLE uint pages();
Q_SCRIPTABLE uint currentPage(); Q_SCRIPTABLE uint currentPage();

@ -56,7 +56,6 @@
// local includes // local includes
#include "../interfaces/viewerinterface.h" #include "../interfaces/viewerinterface.h"
#include "kdocumentviewer.h"
#include "shellutils.h" #include "shellutils.h"
static const char *shouldShowMenuBarComingFromFullScreen = "shouldShowMenuBarComingFromFullScreen"; static const char *shouldShowMenuBarComingFromFullScreen = "shouldShowMenuBarComingFromFullScreen";
@ -424,9 +423,7 @@ void Shell::fileOpen()
// button is clicked // button is clicked
const int activeTab = m_tabWidget->currentIndex(); const int activeTab = m_tabWidget->currentIndex();
if (!m_fileformatsscanned) { if (!m_fileformatsscanned) {
const KDocumentViewer *const doc = qobject_cast<KDocumentViewer *>(m_tabs[activeTab].part); QMetaObject::invokeMethod(m_tabs[activeTab].part, "supportedMimeTypes", Q_RETURN_ARG(QStringList, m_fileformats));
if (doc)
m_fileformats = doc->supportedMimeTypes();
if (m_fileformats.isEmpty()) if (m_fileformats.isEmpty())
m_fileformats = fileFormats(); m_fileformats = fileFormats();
@ -700,10 +697,9 @@ void Shell::openNewTab(const QUrl &url, const QString &serializedOptions)
void Shell::applyOptionsToPart(QObject *part, const QString &serializedOptions) void Shell::applyOptionsToPart(QObject *part, const QString &serializedOptions)
{ {
KDocumentViewer *const doc = qobject_cast<KDocumentViewer *>(part);
const QString find = ShellUtils::find(serializedOptions); const QString find = ShellUtils::find(serializedOptions);
if (ShellUtils::startInPresentation(serializedOptions)) if (ShellUtils::startInPresentation(serializedOptions))
doc->startPresentation(); QMetaObject::invokeMethod(part, "startPresentation");
if (ShellUtils::showPrintDialog(serializedOptions)) if (ShellUtils::showPrintDialog(serializedOptions))
QMetaObject::invokeMethod(part, "enableStartWithPrint"); QMetaObject::invokeMethod(part, "enableStartWithPrint");
if (ShellUtils::showPrintDialogAndExit(serializedOptions)) if (ShellUtils::showPrintDialogAndExit(serializedOptions))

Loading…
Cancel
Save