Update PDF export constants and header dimensions in PDFController and PerechenTableModel. Adjusted row counts for first and subsequent pages to improve layout consistency.
This commit is contained in:
@@ -105,8 +105,8 @@ bool PDFController::exportPerechenToPdf(const QString &filePath, MainController
|
||||
qreal mmToPixels = painter.device()->logicalDpiX() / 25.4;
|
||||
|
||||
// Константы для количества строк на страницах
|
||||
const int rowsOnFirstPage = 27; // На первой странице 23 строки
|
||||
const int rowsOnOtherPages = 33; // На последующих страницах 29 строк
|
||||
const int rowsOnFirstPage = 25; // На первой странице 23 строки
|
||||
const int rowsOnOtherPages = 32; // На последующих страницах 29 строк
|
||||
|
||||
int totalRows = perechenModel->rowCount();
|
||||
int currentRow = 0;
|
||||
@@ -1550,7 +1550,7 @@ bool PDFController::addPerechenTableRange(QPainter &painter, PerechenTableModel
|
||||
painter.setFont(tableFont);
|
||||
|
||||
// Заголовки колонок
|
||||
QStringList headers = {"Поз.", "Наименование", "Кол.", "Примечание"};
|
||||
QStringList headers = {"Поз.\nобозначение", "Наименование", "Кол.", "Примечание"};
|
||||
|
||||
qreal posWidth = 20 * mmToPixels; // Поз.: 20мм
|
||||
qreal nameWidth = 110 * mmToPixels; // Наименование: 110мм
|
||||
@@ -1558,6 +1558,7 @@ bool PDFController::addPerechenTableRange(QPainter &painter, PerechenTableModel
|
||||
qreal noteWidth = 45 * mmToPixels; // Примечание: 45мм
|
||||
|
||||
qreal rowHeight = 8 * mmToPixels;
|
||||
qreal headerHeight = 15 * mmToPixels;
|
||||
|
||||
// Позиция начала таблицы
|
||||
qreal tableStartX = tableRect.x();
|
||||
@@ -1566,25 +1567,25 @@ bool PDFController::addPerechenTableRange(QPainter &painter, PerechenTableModel
|
||||
qreal currentX = tableStartX;
|
||||
|
||||
// Колонка "Поз." (20мм)
|
||||
QRectF posHeaderRect(currentX, tableRect.y(), posWidth, rowHeight);
|
||||
QRectF posHeaderRect(currentX, tableRect.y(), posWidth, headerHeight);
|
||||
painter.drawRect(posHeaderRect);
|
||||
painter.drawText(posHeaderRect, headers[0], QTextOption(Qt::AlignCenter));
|
||||
currentX += posWidth;
|
||||
|
||||
// Колонка "Наименование" (110мм)
|
||||
QRectF nameHeaderRect(currentX, tableRect.y(), nameWidth, rowHeight);
|
||||
QRectF nameHeaderRect(currentX, tableRect.y(), nameWidth, headerHeight);
|
||||
painter.drawRect(nameHeaderRect);
|
||||
painter.drawText(nameHeaderRect, headers[1], QTextOption(Qt::AlignCenter));
|
||||
currentX += nameWidth;
|
||||
|
||||
// Колонка "Кол." (10мм)
|
||||
QRectF qtyHeaderRect(currentX, tableRect.y(), qtyWidth, rowHeight);
|
||||
QRectF qtyHeaderRect(currentX, tableRect.y(), qtyWidth, headerHeight);
|
||||
painter.drawRect(qtyHeaderRect);
|
||||
painter.drawText(qtyHeaderRect, headers[2], QTextOption(Qt::AlignCenter));
|
||||
currentX += qtyWidth;
|
||||
|
||||
// Колонка "Примечание" (45мм)
|
||||
QRectF noteHeaderRect(currentX, tableRect.y(), noteWidth, rowHeight);
|
||||
QRectF noteHeaderRect(currentX, tableRect.y(), noteWidth, headerHeight);
|
||||
painter.drawRect(noteHeaderRect);
|
||||
painter.drawText(noteHeaderRect, headers[3], QTextOption(Qt::AlignCenter));
|
||||
|
||||
@@ -1597,7 +1598,7 @@ bool PDFController::addPerechenTableRange(QPainter &painter, PerechenTableModel
|
||||
currentX = tableStartX;
|
||||
|
||||
// Колонка "Поз." (20мм)
|
||||
QRectF posCellRect(currentX, tableRect.y() + (displayRow + 1) * rowHeight, posWidth, rowHeight);
|
||||
QRectF posCellRect(currentX, tableRect.y() + (displayRow) * rowHeight+headerHeight, posWidth, rowHeight);
|
||||
painter.drawRect(posCellRect);
|
||||
|
||||
// Если это реальная строка данных (не пустая)
|
||||
@@ -1617,7 +1618,7 @@ bool PDFController::addPerechenTableRange(QPainter &painter, PerechenTableModel
|
||||
currentX += posWidth;
|
||||
|
||||
// Колонка "Наименование" (110мм)
|
||||
QRectF nameCellRect(currentX, tableRect.y() + (displayRow + 1) * rowHeight, nameWidth, rowHeight);
|
||||
QRectF nameCellRect(currentX, tableRect.y() + (displayRow) * rowHeight+headerHeight, nameWidth, rowHeight);
|
||||
painter.drawRect(nameCellRect);
|
||||
|
||||
// Если это реальная строка данных (не пустая)
|
||||
@@ -1690,7 +1691,7 @@ bool PDFController::addPerechenTableRange(QPainter &painter, PerechenTableModel
|
||||
currentX += nameWidth;
|
||||
|
||||
// Колонка "Кол." (10мм)
|
||||
QRectF qtyCellRect(currentX, tableRect.y() + (displayRow + 1) * rowHeight, qtyWidth, rowHeight);
|
||||
QRectF qtyCellRect(currentX, tableRect.y() + (displayRow) * rowHeight+headerHeight, qtyWidth, rowHeight);
|
||||
painter.drawRect(qtyCellRect);
|
||||
|
||||
// Если это реальная строка данных (не пустая)
|
||||
@@ -1710,7 +1711,7 @@ bool PDFController::addPerechenTableRange(QPainter &painter, PerechenTableModel
|
||||
currentX += qtyWidth;
|
||||
|
||||
// Колонка "Примечание" (45мм)
|
||||
QRectF noteCellRect(currentX, tableRect.y() + (displayRow + 1) * rowHeight, noteWidth, rowHeight);
|
||||
QRectF noteCellRect(currentX, tableRect.y() + (displayRow) * rowHeight+headerHeight, noteWidth, rowHeight);
|
||||
painter.drawRect(noteCellRect);
|
||||
|
||||
// Если это реальная строка данных (не пустая)
|
||||
@@ -2895,8 +2896,8 @@ QList<PageInfo> PDFController::getPerechenPagesInfo(MainController *mainControll
|
||||
qDebug() << "PDFController::getPerechenPagesInfo: Количество строк в модели:" << perechenModel->rowCount();
|
||||
|
||||
// Константы для количества строк на страницах
|
||||
const int rowsOnFirstPage = 27; // На первой странице 27 строк
|
||||
const int rowsOnOtherPages = 33; // На последующих страницах 33 строк
|
||||
const int rowsOnFirstPage = 25; // На первой странице 27 строк
|
||||
const int rowsOnOtherPages = 32; // На последующих страницах 33 строк
|
||||
|
||||
int totalRows = perechenModel->rowCount();
|
||||
int currentRow = 0;
|
||||
@@ -3061,8 +3062,8 @@ bool PDFController::drawPerechenPage(QPainter &painter, const PageInfo &pageInfo
|
||||
qreal mmToPixels = painter.device()->logicalDpiX() / 25.4;
|
||||
|
||||
// Константы для количества строк на страницах
|
||||
const int rowsOnFirstPage = 27;
|
||||
const int rowsOnOtherPages = 33;
|
||||
const int rowsOnFirstPage = 25;
|
||||
const int rowsOnOtherPages = 32;
|
||||
|
||||
int totalRows = perechenModel->rowCount();
|
||||
int currentRow = 0;
|
||||
|
||||
@@ -60,8 +60,8 @@ public:
|
||||
explicit PerechenTableModel(QObject *parent = nullptr);
|
||||
|
||||
// Константы для разбивки на страницы
|
||||
static const int ROWS_PER_FIRST_PAGE = 27;
|
||||
static const int ROWS_PER_OTHER_PAGE = 33;
|
||||
static const int ROWS_PER_FIRST_PAGE = 25;
|
||||
static const int ROWS_PER_OTHER_PAGE = 32;
|
||||
|
||||
// Методы QAbstractTableModel
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
Reference in New Issue
Block a user