diff --git a/app_icon.rc b/app_icon.rc index 0443bfe..f2cdf59 100644 --- a/app_icon.rc +++ b/app_icon.rc @@ -3,3 +3,5 @@ IDI_ICON1 ICON DISCARDABLE "assets/icon2.ico" + + diff --git a/controller/pdfcontroller.cpp b/controller/pdfcontroller.cpp index b4a8820..556981b 100644 --- a/controller/pdfcontroller.cpp +++ b/controller/pdfcontroller.cpp @@ -446,7 +446,7 @@ bool PDFController::exportVedomostToPdf(const QString &filePath, MainController // Константы для количества строк на страницах (для А5 формата) const int rowsOnFirstPage = 24; // На первой странице 20 строк - const int rowsOnOtherPages = 30; // На последующих страницах 25 строк + const int rowsOnOtherPages = 29; // На последующих страницах 25 строк int totalRows = vedomostModel->rowCount(); int currentRow = 0; @@ -721,6 +721,7 @@ bool PDFController::addListRegistrationTable(QPainter &painter, const QRectF &pa bool PDFController::addGostFrameA4FirstPage(QPainter &painter, const QRectF &pageRect, const TitleInscriptionsModel* model, const ProjectParamTableModel* projectParamModel, int currentPage, int totalPages, int docType) { // Загружаем TTF шрифт из QRC ресурсов + totalPages++; QString fontPath = ":/assets/GOST_A.TTF"; int fontId = QFontDatabase::addApplicationFont(fontPath); @@ -1003,7 +1004,7 @@ painter.drawText(mainTableRect.left()+165*mmToPixels, mainTableRect.top()+20*mmT bool PDFController::addGostFrameA4(QPainter &painter, const QRectF &pageRect, const TitleInscriptionsModel* model, const ProjectParamTableModel* projectParamModel, int currentPage, int totalPages, int docType) { - + totalPages++; // Рисуем только внутреннюю рамку ГОСТ с отступами: // Слева: 20мм, Сверху: 5мм, Справа: 5мм, Снизу: 5мм @@ -2799,7 +2800,7 @@ bool PDFController::addVedomostTableRange(QPainter &painter, VedomostTableModel // Обрабатываем каждую колонку отдельно if (col == 0) { // Первая колонка - номер строки (начиная с 1) - painter.drawText(cellRect, QString::number(row + 1), QTextOption(Qt::AlignCenter)); + painter.drawText(cellRect, QString::number(displayRow + 1), QTextOption(Qt::AlignCenter)); } else if (row < totalRows) { // Остальные колонки - данные из модели (смещение на -1, так как первая колонка не входит в модель) QModelIndex cellIndex = vedomostModel->index(row, col - 1); @@ -3266,7 +3267,7 @@ QList PDFController::getVedomostPagesInfo(MainController *mainControll // Константы для количества строк на страницах (должны совпадать с экспортом) const int rowsOnFirstPage = 24; // На первой странице 24 строки (как в экспорте) - const int rowsOnOtherPages = 30; // На последующих страницах 30 строк (как в экспорте) + const int rowsOnOtherPages = 29; // На последующих страницах 30 строк (как в экспорте) int totalRows = vedomostModel->rowCount(); int currentRow = 0; @@ -3334,7 +3335,7 @@ bool PDFController::drawVedomostPage(QPainter &painter, const PageInfo &pageInfo // Константы для количества строк на страницах (должны совпадать с экспортом) const int rowsOnFirstPage = 24; // На первой странице 24 строки (как в экспорте) - const int rowsOnOtherPages = 30; // На последующих страницах 30 строк (как в экспорте) + const int rowsOnOtherPages = 29; // На последующих страницах 30 строк (как в экспорте) int totalRows = vedomostModel->rowCount(); int currentRow = 0; diff --git a/model/vedomosttablemodel.cpp b/model/vedomosttablemodel.cpp index d6dc0f5..d65f910 100644 --- a/model/vedomosttablemodel.cpp +++ b/model/vedomosttablemodel.cpp @@ -68,16 +68,28 @@ QVariant VedomostTableModel::data(const QModelIndex &index, int role) const } if (role == Qt::BackgroundRole) { - // Проверяем переполнение ячейки (используем приблизительную ширину колонки) - // Приблизительные ширины колонок для Vedomost (в пикселях) - static const qreal columnWidths[] = {200, 150, 200, 150, 150, 80, 80, 80, 80, 150}; // 10 колонок - qreal columnWidth = (index.column() < 10) ? columnWidths[index.column()] : 150; - - // Проверяем переполнение ячейки (используем информацию из PDF) - QPair cellKey(index.row(), index.column()); - if (m_overflowCells.contains(cellKey)) { - // Подсвечиваем красным, если ячейка переполнена (помечена из PDF) - return QBrush(QColor(255, 200, 200)); // Светло-красный + if (row.isHeader) { + return QBrush(QColor(200, 200, 200)); + } else { + // Проверяем переполнение ячейки (используем приблизительную ширину колонки) + // Приблизительные ширины колонок для Vedomost (в пикселях) + static const qreal columnWidths[] = {200, 150, 200, 150, 150, 80, 80, 80, 80, 150}; // 10 колонок + qreal columnWidth = (index.column() < 10) ? columnWidths[index.column()] : 150; + + // Проверяем переполнение ячейки (используем информацию из PDF) + QPair cellKey(index.row(), index.column()); + if (m_overflowCells.contains(cellKey)) { + // Подсвечиваем красным, если ячейка переполнена (помечена из PDF) + return QBrush(QColor(255, 200, 200)); // Светло-красный + } + + // Чередуем оттенки фона для разных страниц + // Нечетные страницы - светло-голубой, четные - светло-желтый + if (row.pageNumber % 2 == 1) { + return QBrush(QColor(240, 248, 255)); // AliceBlue - для нечетных страниц + } else { + return QBrush(QColor(255, 255, 240)); // Ivory - для четных страниц + } } } @@ -174,8 +186,13 @@ QVariant VedomostTableModel::headerData(int section, Qt::Orientation orientation return DEFAULT_HEADERS.at(section); } } else { - // Вертикальные заголовки - номера строк - return section + 1; + // Вертикальные заголовки - номера строк с указанием страницы + if (section < m_rows.size()) { + const VedomostRowData &row = m_rows[section]; + return QString("%1 (стр. %2)").arg(section + 1).arg(row.pageNumber); + } else { + return section + 1; + } } return QVariant(); @@ -1122,31 +1139,48 @@ bool VedomostTableModel::isRowHeader(int row) const void VedomostTableModel::updatePageNumbers() { + qDebug() << "VedomostTableModel::updatePageNumbers: Обновляем номера страниц"; + + int currentRow = 0; int currentPage = 1; int rowsOnCurrentPage = 0; for (int i = 0; i < m_rows.size(); ++i) { VedomostRowData &row = m_rows[i]; - if (i == 0) { - // Первая страница - if (rowsOnCurrentPage >= ROWS_PER_FIRST_PAGE) { - currentPage++; - rowsOnCurrentPage = 0; - } - } else { - // Остальные страницы - if (rowsOnCurrentPage >= ROWS_PER_OTHER_PAGE) { - currentPage++; - rowsOnCurrentPage = 0; - } + // Определяем, сколько строк помещается на текущей странице + int maxRowsOnPage = (currentPage == 1) ? ROWS_PER_FIRST_PAGE : ROWS_PER_OTHER_PAGE; + + // Если текущая страница заполнена, переходим на следующую + if (rowsOnCurrentPage >= maxRowsOnPage) { + currentPage++; + rowsOnCurrentPage = 0; + maxRowsOnPage = ROWS_PER_OTHER_PAGE; // Начиная со второй страницы } + // Устанавливаем номер страницы для строки row.pageNumber = currentPage; - row.rowNumber = i + 1; + row.name.pageNumber = currentPage; + row.productCode.pageNumber = currentPage; + row.documentCode.pageNumber = currentPage; + row.supplier.pageNumber = currentPage; + row.whereUsed.pageNumber = currentPage; + row.quantityPerItem.pageNumber = currentPage; + row.quantityInSet.pageNumber = currentPage; + row.quantityForReg.pageNumber = currentPage; + row.totalQuantity.pageNumber = currentPage; + row.note.pageNumber = currentPage; + + // Увеличиваем счетчик строк на текущей странице rowsOnCurrentPage++; + currentRow++; + + qDebug() << "VedomostTableModel::updatePageNumbers: Строка" << i << "на странице" << currentPage + << "(строк на странице:" << rowsOnCurrentPage << "/" << maxRowsOnPage << ")"; } + qDebug() << "VedomostTableModel::updatePageNumbers: Обновление завершено, всего страниц:" << currentPage; + // Уведомляем UI об изменении данных для обновления отображения страниц if (!m_rows.isEmpty()) { emit dataChanged(index(0, 0), index(m_rows.size() - 1, COLUMN_COUNT - 1), diff --git a/model/vedomosttablemodel.h b/model/vedomosttablemodel.h index 92bf6d8..13a7c9c 100644 --- a/model/vedomosttablemodel.h +++ b/model/vedomosttablemodel.h @@ -63,8 +63,8 @@ public: explicit VedomostTableModel(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 = 24; + static const int ROWS_PER_OTHER_PAGE = 29; // Методы QAbstractTableModel int rowCount(const QModelIndex &parent = QModelIndex()) const override;