File indexing completed on 2024-04-28 15:52:00

0001 /*
0002     SPDX-FileCopyrightText: 2004 Albert Astals Cid <aacid@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef _OKULAR_THUMBNAILLIST_H_
0008 #define _OKULAR_THUMBNAILLIST_H_
0009 
0010 #include <QScrollArea>
0011 #include <QToolBar>
0012 
0013 #include "core/observer.h"
0014 
0015 class ThumbnailListPrivate;
0016 
0017 namespace Okular
0018 {
0019 class Document;
0020 }
0021 
0022 /**
0023  * @short A scrollview that displays page pixmap previews (aka thumbnails).
0024  *
0025  * ...
0026  */
0027 class ThumbnailList : public QScrollArea, public Okular::DocumentObserver
0028 {
0029     Q_OBJECT
0030 public:
0031     ThumbnailList(QWidget *parent, Okular::Document *document);
0032     ~ThumbnailList() override;
0033 
0034     // inherited: create thumbnails ( inherited as a DocumentObserver )
0035     void notifySetup(const QVector<Okular::Page *> &pages, int setupFlags) override;
0036     // inherited: hilihght current thumbnail ( inherited as DocumentObserver )
0037     void notifyCurrentPageChanged(int previous, int current) override;
0038     // inherited: redraw thumbnail ( inherited as DocumentObserver )
0039     void notifyPageChanged(int pageNumber, int changedFlags) override;
0040     // inherited: request all visible pixmap (due to a global change or so..)
0041     void notifyContentsCleared(int changedFlags) override;
0042     // inherited: the visible areas of the page have changed
0043     void notifyVisibleRectsChanged() override;
0044     // inherited: tell if pixmap is hidden and can be unloaded
0045     bool canUnloadPixmap(int pageNumber) const override;
0046 
0047     // redraw visible widgets (useful for refreshing contents...)
0048     void updateWidgets();
0049 
0050     // show current page in Thumbnails view
0051     void syncThumbnail();
0052 
0053 public Q_SLOTS:
0054     // these are connected to ThumbnailController buttons
0055     void slotFilterBookmarks(bool filterOn);
0056 
0057 protected:
0058     // scroll up/down the view
0059     void keyPressEvent(QKeyEvent *keyEvent) override;
0060 
0061     // catch the viewport event and filter them if necessary
0062     bool viewportEvent(QEvent *) override;
0063 
0064 Q_SIGNALS:
0065     void rightClick(const Okular::Page *, const QPoint);
0066 
0067 private:
0068     friend class ThumbnailListPrivate;
0069     ThumbnailListPrivate *d;
0070 };
0071 
0072 /**
0073  * @short A vertical boxed container with zero size hint (for insertion on left toolbox)
0074  */
0075 class ThumbnailsBox : public QWidget
0076 {
0077     Q_OBJECT
0078 
0079 public:
0080     explicit ThumbnailsBox(QWidget *parent);
0081     QSize sizeHint() const override;
0082 };
0083 
0084 /**
0085  * @short A toolbar that sets ThumbnailList properties when clicking on items
0086  *
0087  * This class is the small toolbar that resides in the bottom of the
0088  * ThumbnailsBox container (below ThumbnailList and the SearchLine) and
0089  * emits signals whenever a button is pressed. A click action results
0090  * in invoking some method (or slot) in ThumbnailList.
0091  */
0092 class ThumbnailController : public QToolBar
0093 {
0094     Q_OBJECT
0095 
0096 public:
0097     ThumbnailController(QWidget *parent, ThumbnailList *thumbnailList);
0098 };
0099 
0100 #endif