File indexing completed on 2024-05-12 16:37:15

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2001 David Faure <faure@kde.org>
0003  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef KWVIEWMODEPREVIEW_H
0022 #define KWVIEWMODEPREVIEW_H
0023 
0024 #include "KWViewMode.h"
0025 #include "words_export.h"
0026 
0027 #include <QString>
0028 
0029 /**
0030  * A mode for previewing the overall document
0031  * Pages are organized in a grid (mostly useful with low zoom levels)
0032  */
0033 class WORDS_EXPORT KWViewModePreview : public KWViewMode
0034 {
0035     Q_OBJECT
0036 public:
0037     /// constructor
0038     explicit KWViewModePreview();
0039     ~KWViewModePreview() override {}
0040 
0041     QPointF documentToView(const QPointF &point, KoViewConverter *viewConverter) const override;
0042     QPointF viewToDocument(const QPointF &point, KoViewConverter *viewConverter) const override;
0043     QSizeF contentsSize() const override;
0044 
0045     /**
0046      * The preview can show several pages in a row for easy overview.
0047      * You can set the preferred pages per row here.
0048      * @param num the new number of pages per row
0049      */
0050     void setPagesPerRow(int num) {
0051         m_pagesPerRow = num;
0052     }
0053     /**
0054      * @return the number of pages we are showing per row
0055      */
0056     int pagesPerRow() const {
0057         return m_pagesPerRow;
0058     }
0059 
0060     /// return a string identification of this viewMode
0061     static const QString viewMode() {
0062         return "ModePreview";
0063     }
0064     /// return a string identification of this viewMode
0065     const QString type() const override {
0066         return KWViewModePreview::viewMode();
0067     }
0068     QVector<ViewMap> mapExposedRects(const QRectF &viewRect, KoViewConverter *viewConverter) const override;
0069 
0070     /// set the gap between the pages
0071     void setGap(int gap);
0072 
0073 protected:
0074     void updatePageCache() override;
0075 
0076 private:
0077     int m_pagesPerRow;
0078 };
0079 
0080 #endif