/****************************************************************************
** 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