[go: up one dir, main page]

Menu

[58c4ad]: / src / thumbnailscene.h  Maximize  Restore  History

Download this file

94 lines (79 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/****************************************************************************
** This file is part of the taborca project hosted at
** sf.net/projects/taborca
** Copyright (C) 2013 Shawn Rutledge
** Contact: s@ecloud.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.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called LICENSE; if not, write to the
** Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
****************************************************************************/
#ifndef THUMBNAILSCENE_H
#define THUMBNAILSCENE_H
#include <QGraphicsScene>
#include <QGraphicsGridLayout>
#include "thumbnailitem.h"
/**
\brief QGraphicsScene specialized for holding thumbnails for all of the
pages in the open PDF.
Used in the thumbnails dock widget.
Implements drag-and-drop page reordering.
*/
class ThumbnailScene : public QGraphicsScene
{
Q_OBJECT
public:
ThumbnailScene();
/**
If pages have been reordered, returns the command line options
for the pdftk cat command. Otherwise, empty string.
*/
QString pdftkCatPageRanges();
int currentPage() { return selectedIdx; }
public slots:
void resize(int numItems);
void add(int idx, QImage pm, QString label);
void layout(int width = -1, int height = -1);
void currentPage(int idx);
/**
Override QGraphicsScene::clear() to also delete local stuff.
*/
void clear();
signals:
void statusMessage(QString msg, int timeout = 0);
void statusClear();
void currentPageThumbnail(QGraphicsItem* it);
protected:
void dragEnterEvent ( QGraphicsSceneDragDropEvent * ev );
void dragMoveEvent ( QGraphicsSceneDragDropEvent * ev );
void dropEvent ( QGraphicsSceneDragDropEvent * ev );
/**
At what index would the insertion occur *after*
if dropped at the given position?
E.g. if it's between items 5 and 6, will return 5.
*/
QPoint insertionIdx(QPointF pos);
protected:
int cols;
int spacing;
QVector<ThumbnailItem*> items;
int selectedIdx;
QPixmap defaultItemIcon;
QGraphicsLineItem insertionPoint;
int row;
int col;
int maxWidth;
int maxHeight;
};
#endif // THUMBNAILSCENE_H