diff --git a/core/document.h b/core/document.h --- a/core/document.h +++ b/core/document.h @@ -326,6 +326,7 @@ /** * Returns the url of the currently opened document. + * May be a temporary file, e. g. if the document needed to be decompressed. */ QUrl currentDocument() const; @@ -905,6 +906,8 @@ * is used in the KPart to initialize the print dialog and in the * generators to check whether the document needs to be rotated or not. * + * The orientation is determined using the page sizes, as they were before the user rotated the view. + * * @since 0.14 (KDE 4.8) */ QPrinter::Orientation orientation() const; diff --git a/part.h b/part.h --- a/part.h +++ b/part.h @@ -120,9 +120,11 @@ public: // Default constructor /** - * If one element of 'args' contains one of the strings "Print/Preview" or "ViewerWidget", + * @param parentWidget TODO + * @param parent The parent object. + * @param args If one element contains one of the strings "Print/Preview" or "ViewerWidget", * the part will be set up in the corresponding mode. Additionally, it is possible to specify - * which config file should be used by adding a string containing "ConfigFileName=" + * which config file should be used by adding a string containing "ConfigFileName=\" * to 'args'. **/ Part(QWidget* parentWidget, QObject* parent, const QVariantList& args); @@ -135,12 +137,20 @@ void notifyViewportChanged( bool smoothMove ) override; void notifyPageChanged( int page, int flags ) override; + // Reimplemented from KDocumentViewer bool openDocument(const QUrl &url, uint page) override; void startPresentation() override; QStringList supportedMimeTypes() const override; + /** + * Returns the URL of the real document file, even if actually a temporary file was created and opened. + * A temporary file will be created e. g. if the document needs to be decompressed before opening. + */ QUrl realUrl() const; + /** + * TODO + */ void showSourceLocation(const QString& fileName, int line, int column, bool showGraphically = true) override; void clearLastShownSourceLocation() override; bool isWatchFileModeEnabled() const override; @@ -154,30 +164,110 @@ Q_SCRIPTABLE Q_NOREPLY void openDocument( const QString &doc ); Q_SCRIPTABLE uint pages(); Q_SCRIPTABLE uint currentPage(); + + /** + * Returns the path to the actually opened file. + * May be a temporary file, e. g. if the document needed to be decompressed. + */ Q_SCRIPTABLE QString currentDocument(); + + /** + * Returns the metadata entry for the key @p metaData. + * + * @see DocumentInfo + */ Q_SCRIPTABLE QString documentMetaData( const QString &metaData ) const; + + /** + * Opens the viewer configuration dialog (i. e. not the backend configuration dialog). + */ Q_SCRIPTABLE void slotPreferences(); + + /** + * Shows and focuses the incremental find bar. Also works in presentation mode. + */ Q_SCRIPTABLE void slotFind(); + + /** + * Opens the print preview dialog. + */ Q_SCRIPTABLE void slotPrintPreview(); Q_SCRIPTABLE void slotPreviousPage(); Q_SCRIPTABLE void slotNextPage(); Q_SCRIPTABLE void slotGotoFirst(); Q_SCRIPTABLE void slotGotoLast(); + + /** + * Turns presentation mode on or off. + */ Q_SCRIPTABLE void slotTogglePresentation(); + + /** + * Turns the Change Colors feature on or off. + */ Q_SCRIPTABLE void slotToggleChangeColors(); + + /** + * Turns the Change Colors feature on or off. + */ Q_SCRIPTABLE void slotSetChangeColors(bool active); + + /** + * Reloads the current document, if a document is opened. + * Continuously tries to reload, if the first try fails. + */ Q_SCRIPTABLE Q_NOREPLY void reload(); + + /** + * Will show the print dialog when the document is loaded the next time. + */ Q_SCRIPTABLE Q_NOREPLY void enableStartWithPrint(); + + /** + * Will exit when the print dialog is closed in any way. + */ Q_SCRIPTABLE Q_NOREPLY void enableExitAfterPrint(); + + /** + * Will open the find bar and search for the next occurence of @text, + * when the document is loaded the next time. + * Does not necessarily search from the beginning of the document. + * Does not necessarily search case sensitive. + * + * @param text The text to search for. Must not be empty. + */ Q_SCRIPTABLE Q_NOREPLY void enableStartWithFind(const QString &text); Q_SIGNALS: + /** + * This signal is emitted when the document changes, so it becomes printable or not. + * Used to enable/disable the Print action in the File menu. + */ void enablePrintAction(bool enable); void openSourceReference(const QString& absFileName, int line, int column); void viewerMenuStateChange(bool enabled); + + /** + * This signal is emitted when a document is loaded, so it can be closed. + * Used to enable/disable the Close action in the File menu. + */ void enableCloseAction(bool enable); + + /** + * This signal is emitted when a document is loaded. + * Used to set the tab icon according to the mime type. + */ void mimeTypeChanged(QMimeType mimeType); + + /** + * This signal is emitted when URLs were dropped on the viewer widget, + * and they are not handled by this Part itself. + */ void urlsDropped( const QList& urls ); + + /** + * This signal is emitted when the Fit Window to Page action is triggered. + */ void fitWindowToPage( const QSize& pageViewPortSize, const QSize& pageSize ); protected: @@ -266,8 +356,25 @@ void setViewerShortcuts(); void setupActions(); + /* + * Sets orientation and document title of @p printer to match the current document as good as possible. + */ void setupPrint( QPrinter &printer ); + + /** + * Prints the document to the given @p printer. + */ bool doPrint( QPrinter &printer ); + + /** + * Opens a temporary file and tries to decompress the file @p path points to. + * + * @param[out] destpath Path to the created temporary file (only at success) + * @param path Path to the compressed file to read from + * @param compressionType Compression type of the compressed file. + * + * @return Whether the file was decompressed successfully. + */ bool handleCompressed(QString &destpath, const QString &path, KCompressionDevice::CompressionType compressionType ); void rebuildBookmarkMenu( bool unplugActions = true ); void updateAboutBackendAction(); @@ -427,3 +534,4 @@ #endif /* kate: replace-tabs on; indent-width 4; */ +