PDF4QT/Pdf4QtDocPageOrganizer/pageitemdelegate.h

63 lines
2.0 KiB
C
Raw Normal View History

2021-07-07 18:30:03 +02:00
// Copyright (C) 2021 Jakub Melka
//
2021-08-10 19:22:56 +02:00
// This file is part of PDF4QT.
2021-07-07 18:30:03 +02:00
//
2021-08-10 19:22:56 +02:00
// PDF4QT is free software: you can redistribute it and/or modify
2021-07-07 18:30:03 +02:00
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// with the written consent of the copyright owner, any later version.
//
2021-08-10 19:22:56 +02:00
// PDF4QT is distributed in the hope that it will be useful,
2021-07-07 18:30:03 +02:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
2021-08-10 19:22:56 +02:00
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
2021-07-07 18:30:03 +02:00
#ifndef PDFDOCPAGEORGANIZER_PAGEITEMDELEGATE_H
#define PDFDOCPAGEORGANIZER_PAGEITEMDELEGATE_H
2021-07-29 20:20:28 +02:00
#include "pdfrenderer.h"
#include "pdfcms.h"
2021-07-07 18:30:03 +02:00
#include <QAbstractItemDelegate>
namespace pdfdocpage
{
class PageItemModel;
struct PageGroupItem;
2021-07-07 18:30:03 +02:00
class PageItemDelegate : public QAbstractItemDelegate
{
Q_OBJECT
private:
using BaseClass = QAbstractItemDelegate;
public:
explicit PageItemDelegate(PageItemModel* model, QObject* parent);
virtual ~PageItemDelegate() override;
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
QSize getPageImageSize() const;
void setPageImageSize(QSize pageImageSize);
2021-07-07 18:30:03 +02:00
private:
static constexpr int getVerticalSpacing() { return 5; }
static constexpr int getHorizontalSpacing() { return 5; }
QPixmap getPageImagePixmap(const PageGroupItem* item, QRect rect) const;
2021-07-07 18:30:03 +02:00
PageItemModel* m_model;
QSize m_pageImageSize;
2021-07-29 20:20:28 +02:00
pdf::PDFRasterizer* m_rasterizer;
2021-07-07 18:30:03 +02:00
};
} // namespace pdfdocpage
#endif // PDFDOCPAGEORGANIZER_PAGEITEMDELEGATE_H