108 lines
6.8 KiB
C++
108 lines
6.8 KiB
C++
#ifndef PDFCONTROLLER_H
|
|
#define PDFCONTROLLER_H
|
|
|
|
#include <QObject>
|
|
#include <QPainter>
|
|
#include <QString>
|
|
#include <QFont>
|
|
#include <QList>
|
|
#include <QModelIndex>
|
|
#include "../model/pageinfo.h"
|
|
#include "../model/perechentablemodel.h"
|
|
|
|
class MainController;
|
|
class PerechenTableModel;
|
|
class TitleInscriptionsModel;
|
|
class ProjectParamTableModel;
|
|
class SpecificationPCBTableModel;
|
|
class SpecificationTableModel;
|
|
class VedomostTableModel;
|
|
|
|
class PDFController : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit PDFController(QObject *parent = nullptr);
|
|
|
|
// Метод для экспорта перечня элементов в PDF
|
|
bool exportPerechenToPdf(const QString &filePath, MainController *mainController);
|
|
|
|
// Метод для экспорта спецификации PCB в PDF
|
|
bool exportSpecificationPcbToPdf(const QString &filePath, MainController *mainController);
|
|
|
|
// Метод для экспорта спецификации материалов в PDF
|
|
bool exportSpecificationToPdf(const QString &filePath, MainController *mainController);
|
|
|
|
// Метод для экспорта ведомости покупных изделий в PDF
|
|
bool exportVedomostToPdf(const QString &filePath, MainController *mainController);
|
|
|
|
// Новые методы для предварительного просмотра
|
|
QList<PageInfo> getPerechenPagesInfo(MainController *mainController);
|
|
QList<PageInfo> getSpecificationPcbPagesInfo(MainController *mainController);
|
|
QList<PageInfo> getSpecificationPagesInfo(MainController *mainController);
|
|
QList<PageInfo> getVedomostPagesInfo(MainController *mainController);
|
|
|
|
// Методы для рисования страниц на painter
|
|
bool drawPerechenPage(QPainter &painter, const PageInfo &pageInfo, MainController *mainController);
|
|
bool drawSpecificationPcbPage(QPainter &painter, const PageInfo &pageInfo, MainController *mainController);
|
|
bool drawSpecificationPage(QPainter &painter, const PageInfo &pageInfo, MainController *mainController);
|
|
bool drawVedomostPage(QPainter &painter, const PageInfo &pageInfo, MainController *mainController);
|
|
|
|
// Методы для генерации таблиц
|
|
bool generateTableA4(const QString &filePath, MainController *mainController);
|
|
bool generateTableA5(const QString &filePath, MainController *mainController);
|
|
|
|
// Методы для генерации штампов ГОСТ
|
|
bool generateGostStampA4(const QString &filePath, MainController *mainController);
|
|
|
|
bool generateGostStampA5(const QString &filePath, MainController *mainController);
|
|
|
|
// Утилитарные функции для работы с шрифтом ГОСТ
|
|
static QFont createGostFont(int pointSize, bool bold = false, bool italic = false, int stretch = 100);
|
|
static void drawTextWithGostFont(QPainter &painter, const QRectF &rect,
|
|
const QString &text, int pointSize,
|
|
Qt::Alignment alignment = Qt::AlignLeft);
|
|
static void drawTextWithAutoSize(QPainter &painter, const QRectF &rect,
|
|
const QString &text, int maxPointSize = 20);
|
|
static void drawTextMultiline(QPainter &painter, const QRectF &rect,
|
|
const QString &text, const QFont &font,
|
|
int maxLines = 3);
|
|
|
|
// Метод для получения значения надписи с учетом параметров проекта
|
|
static QString getInscriptionValueWithProjectParams(const TitleInscriptionsModel* titleModel,
|
|
const ProjectParamTableModel* projectParamModel,
|
|
int inscriptionIndex);
|
|
|
|
private:
|
|
// Вспомогательные методы для создания PDF
|
|
bool createPdfDocument(const QString &filePath, const QString &title);
|
|
bool addGostFrameA4FirstPage(QPainter &painter, const QRectF &pageRect, const TitleInscriptionsModel* model, const ProjectParamTableModel* projectParamModel, int currentPage, int totalPages , int docType);
|
|
bool addGostFrameA4(QPainter &painter, const QRectF &pageRect, const TitleInscriptionsModel* model, const ProjectParamTableModel* projectParamModel, int currentPage, int totalPages, int docType);
|
|
bool addGostFrameA3(QPainter &painter, const QRectF &pageRect, const TitleInscriptionsModel* model, const ProjectParamTableModel* projectParamModel, int currentPage, int totalPages);
|
|
bool addTitleInscriptions(QPainter &painter, TitleInscriptionsModel *titleModel, const QRectF &stampRect);
|
|
bool addPerechenTable(QPainter &painter, PerechenTableModel *perechenModel, const QRectF &tableRect, MainController *mainController = nullptr);
|
|
bool addPerechenTableRange(QPainter &painter, PerechenTableModel *perechenModel, const QRectF &tableRect, int startRow, int rowCount, MainController *mainController = nullptr);
|
|
bool addSpecificationPcbTableRange(QPainter &painter, SpecificationPCBTableModel *specificationModel, const QRectF &tableRect, int startRow, int rowCount, MainController *mainController = nullptr);
|
|
bool addSpecificationTableRange(QPainter &painter, SpecificationTableModel *specificationModel, const QRectF &tableRect, int startRow, int rowCount, MainController *mainController = nullptr);
|
|
bool addVedomostTableRange(QPainter &painter, VedomostTableModel *vedomostModel, const QRectF &tableRect, int startRow, int rowCount, MainController *mainController = nullptr);
|
|
|
|
bool addGostFrameA3FirstPage(QPainter &painter, const QRectF &pageRect, const TitleInscriptionsModel *model, const ProjectParamTableModel *projectParamModel, int currentPage, int totalPages);
|
|
bool addListRegistrationTable(QPainter &painter,const QRectF &pageRect);
|
|
|
|
// Вспомогательная функция для получения поджима ячейки
|
|
static int getCellStretch(const QModelIndex &index, int defaultStretch);
|
|
|
|
// Вспомогательная функция для получения флага подчеркивания ячейки
|
|
static bool getCellUnderline(const QModelIndex &index, bool defaultUnderline = true);
|
|
|
|
// Вспомогательная функция для рисования ячейки с учетом поджима
|
|
void drawCellWithStretch(QPainter &painter, const QModelIndex &index, const QRectF &rect,
|
|
const QString &text, int fontSize, int defaultStretch,
|
|
const QFont &baseFont, Qt::Alignment alignment, MainController *mainController = nullptr);
|
|
signals:
|
|
// Сигнал о переполнении ячейки при отрисовке в PDF
|
|
void cellOverflowDetected(const QModelIndex &index, bool isOverflow);
|
|
};
|
|
|
|
#endif // PDFCONTROLLER_H
|