1 | /* |
---|
2 | |
---|
3 | Copyright 2014 Adam Reichold |
---|
4 | |
---|
5 | This file is part of qpdfview. |
---|
6 | |
---|
7 | qpdfview is free software: you can redistribute it and/or modify |
---|
8 | it under the terms of the GNU General Public License as published by |
---|
9 | the Free Software Foundation, either version 2 of the License, or |
---|
10 | (at your option) any later version. |
---|
11 | |
---|
12 | qpdfview is distributed in the hope that it will be useful, |
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | GNU General Public License for more details. |
---|
16 | |
---|
17 | You should have received a copy of the GNU General Public License |
---|
18 | along with qpdfview. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef THUMBNAILITEM_H |
---|
23 | #define THUMBNAILITEM_H |
---|
24 | |
---|
25 | #include <QString> |
---|
26 | |
---|
27 | #if QT_VERSION >= QT_VERSION_CHECK(4,7,0) |
---|
28 | |
---|
29 | #include <QStaticText> |
---|
30 | |
---|
31 | #endif // QT_VERSION |
---|
32 | |
---|
33 | #include "pageitem.h" |
---|
34 | |
---|
35 | namespace qpdfview |
---|
36 | { |
---|
37 | |
---|
38 | namespace Model |
---|
39 | { |
---|
40 | class Page; |
---|
41 | } |
---|
42 | |
---|
43 | class ThumbnailItem : public PageItem |
---|
44 | { |
---|
45 | Q_OBJECT |
---|
46 | |
---|
47 | public: |
---|
48 | ThumbnailItem(Model::Page* page, const QString& text, int index, QGraphicsItem* parent = 0); |
---|
49 | |
---|
50 | QRectF boundingRect() const; |
---|
51 | void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); |
---|
52 | |
---|
53 | #if QT_VERSION >= QT_VERSION_CHECK(4,7,0) |
---|
54 | |
---|
55 | QString text() const { return m_text.text(); } |
---|
56 | void setText(const QString& text) { m_text.setText(text); } |
---|
57 | |
---|
58 | #else |
---|
59 | |
---|
60 | const QString& text() const { return m_text; } |
---|
61 | void setText(const QString& text) { m_text = text; } |
---|
62 | |
---|
63 | #endif // QT_VERSION |
---|
64 | |
---|
65 | qreal textHeight() const; |
---|
66 | |
---|
67 | bool isHighlighted() const { return m_isHighlighted; } |
---|
68 | void setHighlighted(bool highlighted); |
---|
69 | |
---|
70 | protected: |
---|
71 | void mousePressEvent(QGraphicsSceneMouseEvent* event); |
---|
72 | void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); |
---|
73 | void mouseMoveEvent(QGraphicsSceneMouseEvent*); |
---|
74 | void mouseReleaseEvent(QGraphicsSceneMouseEvent*); |
---|
75 | |
---|
76 | void contextMenuEvent(QGraphicsSceneContextMenuEvent*); |
---|
77 | |
---|
78 | private slots: |
---|
79 | void loadInteractiveElements(); |
---|
80 | |
---|
81 | private: |
---|
82 | Q_DISABLE_COPY(ThumbnailItem) |
---|
83 | |
---|
84 | #if QT_VERSION >= QT_VERSION_CHECK(4,7,0) |
---|
85 | |
---|
86 | QStaticText m_text; |
---|
87 | |
---|
88 | #else |
---|
89 | |
---|
90 | QString m_text; |
---|
91 | |
---|
92 | #endif // QT_VERSION |
---|
93 | |
---|
94 | bool m_isHighlighted; |
---|
95 | |
---|
96 | }; |
---|
97 | |
---|
98 | } // qpdfview |
---|
99 | |
---|
100 | #endif // THUMBNAILITEM_H |
---|