2070 lines
102 KiB
C++
2070 lines
102 KiB
C++
#include "documentsettingsdialog.h"
|
||
#include "../controller/maincontroller.h"
|
||
#include "../controller/perechentablecontroller.h"
|
||
#include "../controller/specificationpcbcontroller.h"
|
||
#include "../controller/specificationcontroller.h"
|
||
#include "../controller/vedomostcontroller.h"
|
||
#include "../controller/simplelisttablecontroller.h"
|
||
#include "../model/componenttablemodel.h"
|
||
#include <QDebug>
|
||
#include <QMessageBox>
|
||
#include <QApplication>
|
||
#include <QDir>
|
||
#include <QFile>
|
||
#include <QPixmap>
|
||
#include <QTransform>
|
||
#include <QPainter>
|
||
#include <QFont>
|
||
|
||
// Инициализация статических данных о графах ГОСТ
|
||
QMap<int, QString> DocumentSettingsDialog::s_fieldNames;
|
||
QMap<int, QString> DocumentSettingsDialog::s_fieldDescriptions;
|
||
|
||
void DocumentSettingsDialog::initializeFieldData()
|
||
{
|
||
if (s_fieldNames.isEmpty()) {
|
||
// Основные поля (обязательные)
|
||
s_fieldNames[1] = "Наименование изделия";
|
||
s_fieldNames[2] = "Обозначение документа";
|
||
s_fieldNames[4] = "Литера";
|
||
s_fieldNames[9] = "Наименование организации";
|
||
s_fieldNames[10] = "Характер работы (Разраб.)";
|
||
s_fieldNames[11] = "Фамилии лиц";
|
||
s_fieldNames[111] = "Фамилия разработчика";
|
||
s_fieldNames[112] = "Фамилия проверяющего";
|
||
s_fieldNames[113] = "Фамилия Норм контроллера";
|
||
s_fieldNames[114] = "Фамилия утверждающего";
|
||
|
||
// Поля изменений (обязательные)
|
||
s_fieldNames[14] = "Сведения об изменениях";
|
||
s_fieldNames[15] = "Сведения об изменениях (Лист)";
|
||
s_fieldNames[16] = "Сведения об изменениях (№ докум.)";
|
||
s_fieldNames[19] = "Инвентарный номер подлинника";
|
||
|
||
// Поля изменений (специфичные для каждого документа)
|
||
s_fieldNames[21] = "Взамен инв. номер";
|
||
s_fieldNames[22] = "Инв. номер дубликата";
|
||
s_fieldNames[24] = "Обозначение документа (взамен) / Справ. №";
|
||
s_fieldNames[25] = "Обозначение соответствующего документа / Перв. примен.";
|
||
s_fieldNames[251] = "Первичное применение (Перечень)";
|
||
s_fieldNames[252] = "Первичное применение (Спецификация ПП)";
|
||
s_fieldNames[253] = "Первичное применение (Спецификация)";
|
||
s_fieldNames[254] = "Первичное применение (Ведомость)";
|
||
s_fieldNames[301]= "Наименование документа";
|
||
s_fieldNames[1002] = "Название документа";
|
||
|
||
// Описания полей
|
||
s_fieldDescriptions[1] = "(1) Центральная область титульного листа";
|
||
s_fieldDescriptions[2] = "(2) Центральная область + последующие страницы";
|
||
s_fieldDescriptions[4] = "(4) Правый верхний угол";
|
||
s_fieldDescriptions[9] = "(9) Правый нижний угол";
|
||
s_fieldDescriptions[10] = "(10) Указывается характер работы";
|
||
s_fieldDescriptions[11] = "(11) Общая группа для фамилий";
|
||
s_fieldDescriptions[111] = "Фамилия разработчика документа";
|
||
s_fieldDescriptions[112] = "Фамилия проверяющего документа";
|
||
s_fieldDescriptions[113] = "Фамилия нормоконтролера";
|
||
s_fieldDescriptions[114] = "Фамилия утверждающего лица";
|
||
s_fieldDescriptions[14] = "(14) Информация об изменениях в документе";
|
||
s_fieldDescriptions[15] = "(15) Номер листа с изменениями";
|
||
s_fieldDescriptions[16] = "(16) Номер документа с изменениями";
|
||
s_fieldDescriptions[19] = "(19) Инвентарный номер подлинника документа";
|
||
s_fieldDescriptions[21] = "(21) Инвентарный номер заменяемого документа";
|
||
s_fieldDescriptions[22] = "(22) Инвентарный номер дубликата";
|
||
s_fieldDescriptions[24] = "(24) Обозначение заменяемого документа или справочный номер";
|
||
s_fieldDescriptions[25] = "(25) Обозначение соответствующего документа или первое применение";
|
||
s_fieldDescriptions[301] = "(1 низ)Наименование документа под обозначением документа";
|
||
}
|
||
}
|
||
|
||
DocumentSettingsDialog::DocumentSettingsDialog(DocumentType docType, MainController *controller, QWidget *parent)
|
||
: QDialog(parent)
|
||
, m_documentType(docType)
|
||
, m_controller(controller)
|
||
, m_projectParamModel(nullptr)
|
||
, m_titleInscriptionsModel(nullptr)
|
||
, m_primaryApplicationComboBox(nullptr)
|
||
, m_primaryApplicationFieldNumber(0)
|
||
, m_simpleListNameFieldComboBox(nullptr)
|
||
, m_simpleListTechReserveSpinBox(nullptr)
|
||
, m_simpleListBoardsCountSpinBox(nullptr)
|
||
{
|
||
qDebug() << "DocumentSettingsDialog: Конструктор для типа документа:" << static_cast<int>(docType);
|
||
|
||
// Инициализируем статические данные
|
||
initializeFieldData();
|
||
|
||
// Получаем модели из контроллера
|
||
if (m_controller) {
|
||
m_projectParamModel = m_controller->projectParamTableModel();
|
||
m_titleInscriptionsModel = m_controller->titleInscriptionsModel();
|
||
|
||
// Получаем доступные свойства компонентов
|
||
if (m_controller->componentTableModel()) {
|
||
m_availableProperties = m_controller->componentTableModel()->propertyNames();
|
||
}
|
||
}
|
||
|
||
setUp();
|
||
}
|
||
|
||
void DocumentSettingsDialog::setUp()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::setUp: Начинаем настройку диалога";
|
||
setWidgets();
|
||
createTabWidget();
|
||
setUpLayout();
|
||
setUpConnections();
|
||
loadTableSettings();
|
||
loadInscriptionSettings();
|
||
loadFontSettings();
|
||
|
||
// Загружаем настройки децимальных номеров (только для SpecificationPCB и Specification)
|
||
if (m_documentType == DocumentType::SpecificationPCB || m_documentType == DocumentType::Specification) {
|
||
loadDecimalNumberSettings();
|
||
}
|
||
|
||
// Загружаем настройки "Куда входит" для ведомости
|
||
if (m_documentType == DocumentType::Vedomost) {
|
||
loadDecimalNumberSettings();
|
||
}
|
||
|
||
// Загружаем настройки "Первичное применение" для всех типов документов
|
||
loadPrimaryApplicationSettings();
|
||
|
||
// Загружаем настройки SimpleList
|
||
if (m_documentType == DocumentType::SimpleList) {
|
||
loadSimpleListSettings();
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::setUp: Настройка диалога завершена";
|
||
}
|
||
|
||
void DocumentSettingsDialog::setWidgets()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::setWidgets: Создаем виджеты";
|
||
|
||
// Создаем кнопки диалога
|
||
m_okButton = new QPushButton("ОК", this);
|
||
m_cancelButton = new QPushButton("Отмена", this);
|
||
|
||
qDebug() << "DocumentSettingsDialog::setWidgets: Виджеты созданы";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createTabWidget()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createTabWidget: Создаем табы";
|
||
|
||
m_tabWidget = new QTabWidget(this);
|
||
|
||
// Создаем табы
|
||
createTableSettingsTab();
|
||
createTitleInscriptionsTab();
|
||
|
||
// Добавляем табы в виджет
|
||
m_tabWidget->addTab(m_tableSettingsTab, "Настройки таблицы");
|
||
m_tabWidget->addTab(m_titleInscriptionsTab, "Основные надписи");
|
||
|
||
qDebug() << "DocumentSettingsDialog::createTabWidget: Табы созданы";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createTableSettingsTab()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createTableSettingsTab: Создаем таб настроек таблицы";
|
||
|
||
m_tableSettingsTab = new QWidget();
|
||
m_tableScrollArea = new QScrollArea(m_tableSettingsTab);
|
||
m_tableScrollContent = new QWidget();
|
||
m_resetTableButton = new QPushButton("Сбросить настройки", m_tableSettingsTab);
|
||
|
||
// Создаем поля для настроек колонок
|
||
createTableColumnFields();
|
||
|
||
// Создаем поля для децимальных номеров (только для SpecificationPCB и Specification)
|
||
if (m_documentType == DocumentType::SpecificationPCB || m_documentType == DocumentType::Specification) {
|
||
createDecimalNumberFields();
|
||
}
|
||
|
||
// Создаем поле "Первичное применение" для всех типов документов
|
||
createPrimaryApplicationField();
|
||
|
||
// Создаем поле "Куда входит" для ведомости
|
||
if (m_documentType == DocumentType::Vedomost) {
|
||
createWhereUsedField();
|
||
}
|
||
|
||
// Создаем поля настроек для SimpleList
|
||
if (m_documentType == DocumentType::SimpleList) {
|
||
createSimpleListSettingsFields();
|
||
}
|
||
|
||
// Создаем поля для размера шрифта и поджима
|
||
createFontSettingsFields();
|
||
|
||
// Настраиваем компоновку
|
||
QVBoxLayout *tabLayout = new QVBoxLayout(m_tableSettingsTab);
|
||
|
||
// Добавляем описание
|
||
QLabel *descriptionLabel = new QLabel("Настройте соответствие колонок таблицы свойствам компонентов:", m_tableSettingsTab);
|
||
tabLayout->addWidget(descriptionLabel);
|
||
|
||
// Добавляем область прокрутки
|
||
m_tableScrollArea->setWidget(m_tableScrollContent);
|
||
m_tableScrollArea->setWidgetResizable(true);
|
||
tabLayout->addWidget(m_tableScrollArea);
|
||
|
||
// Добавляем кнопку сброса
|
||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||
buttonLayout->addStretch();
|
||
buttonLayout->addWidget(m_resetTableButton);
|
||
tabLayout->addLayout(buttonLayout);
|
||
|
||
qDebug() << "DocumentSettingsDialog::createTableSettingsTab: Таб настроек таблицы создан";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createTitleInscriptionsTab()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createTitleInscriptionsTab: Создаем таб основных надписей";
|
||
|
||
m_titleInscriptionsTab = new QWidget();
|
||
m_inscriptionScrollArea = new QScrollArea(m_titleInscriptionsTab);
|
||
m_inscriptionScrollContent = new QWidget();
|
||
m_resetInscriptionButton = new QPushButton("Сбросить настройки", m_titleInscriptionsTab);
|
||
|
||
// Создаем поля для надписей
|
||
createInscriptionFields();
|
||
|
||
// Создаем предварительный просмотр
|
||
createImagePreview();
|
||
|
||
// Настраиваем компоновку
|
||
QHBoxLayout *tabLayout = new QHBoxLayout(m_titleInscriptionsTab);
|
||
|
||
// Левая панель с настройками
|
||
QVBoxLayout *leftPanel = new QVBoxLayout();
|
||
|
||
// Добавляем описание
|
||
QLabel *descriptionLabel = new QLabel("Настройте основные надписи документа:", m_titleInscriptionsTab);
|
||
leftPanel->addWidget(descriptionLabel);
|
||
|
||
// Добавляем область прокрутки
|
||
m_inscriptionScrollArea->setWidget(m_inscriptionScrollContent);
|
||
m_inscriptionScrollArea->setWidgetResizable(true);
|
||
leftPanel->addWidget(m_inscriptionScrollArea);
|
||
|
||
// Добавляем кнопку сброса
|
||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||
buttonLayout->addStretch();
|
||
buttonLayout->addWidget(m_resetInscriptionButton);
|
||
leftPanel->addLayout(buttonLayout);
|
||
|
||
// Правая панель с предварительным просмотром
|
||
QVBoxLayout *rightPanel = new QVBoxLayout();
|
||
|
||
QLabel *previewLabel = new QLabel("Предварительный просмотр:", m_titleInscriptionsTab);
|
||
rightPanel->addWidget(previewLabel);
|
||
|
||
rightPanel->addWidget(m_imageView);
|
||
|
||
// Добавляем слайдер масштабирования
|
||
QHBoxLayout *zoomLayout = new QHBoxLayout();
|
||
zoomLayout->addWidget(new QLabel("Масштаб:", m_titleInscriptionsTab));
|
||
zoomLayout->addWidget(m_zoomSlider);
|
||
rightPanel->addLayout(zoomLayout);
|
||
|
||
// Добавляем панели в основную компоновку
|
||
tabLayout->addLayout(leftPanel, 2);
|
||
tabLayout->addLayout(rightPanel, 1);
|
||
|
||
qDebug() << "DocumentSettingsDialog::createTitleInscriptionsTab: Таб основных надписей создан";
|
||
}
|
||
|
||
void DocumentSettingsDialog::setUpLayout()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::setUpLayout: Настраиваем компоновку";
|
||
|
||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||
|
||
// Добавляем табы
|
||
mainLayout->addWidget(m_tabWidget);
|
||
|
||
// Добавляем кнопки диалога
|
||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||
buttonLayout->addStretch();
|
||
buttonLayout->addWidget(m_okButton);
|
||
buttonLayout->addWidget(m_cancelButton);
|
||
mainLayout->addLayout(buttonLayout);
|
||
|
||
// Устанавливаем размер диалога
|
||
resize(800, 600);
|
||
|
||
qDebug() << "DocumentSettingsDialog::setUpLayout: Компоновка настроена";
|
||
}
|
||
|
||
void DocumentSettingsDialog::setUpConnections()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::setUpConnections: Настраиваем соединения";
|
||
|
||
connect(m_okButton, &QPushButton::clicked, this, &DocumentSettingsDialog::onAccept);
|
||
connect(m_cancelButton, &QPushButton::clicked, this, &DocumentSettingsDialog::onCancel);
|
||
connect(m_resetTableButton, &QPushButton::clicked, this, &DocumentSettingsDialog::onResetTableSettings);
|
||
connect(m_resetInscriptionButton, &QPushButton::clicked, this, &DocumentSettingsDialog::onResetInscriptionSettings);
|
||
connect(m_zoomSlider, &QSlider::valueChanged, this, &DocumentSettingsDialog::onZoomChanged);
|
||
|
||
qDebug() << "DocumentSettingsDialog::setUpConnections: Соединения настроены";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createTableColumnFields()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createTableColumnFields: Создаем поля настроек таблицы";
|
||
|
||
QStringList columnNames = getTableColumnNames();
|
||
QStringList defaultMappings = getDefaultTableMappings();
|
||
|
||
QGridLayout *gridLayout = new QGridLayout(m_tableScrollContent);
|
||
gridLayout->setAlignment(Qt::AlignTop);
|
||
|
||
// Заголовки
|
||
if(columnNames.size()>0){
|
||
gridLayout->addWidget(new QLabel("Колонка", m_tableScrollContent), 0, 0);
|
||
gridLayout->addWidget(new QLabel("Свойство компонента", m_tableScrollContent), 0, 1);
|
||
}
|
||
// Создаем комбобоксы для каждой колонки
|
||
for (int i = 0; i < columnNames.size(); ++i) {
|
||
QLabel *columnLabel = new QLabel(columnNames[i], m_tableScrollContent);
|
||
gridLayout->addWidget(columnLabel, i + 1, 0);
|
||
|
||
QComboBox *comboBox = new QComboBox(m_tableScrollContent);
|
||
comboBox->addItem("-- Не выбрано --", "");
|
||
|
||
// Добавляем доступные свойства
|
||
for (const QString &property : m_availableProperties) {
|
||
// Для свойств компонентов показываем только название, так как значения могут быть разными для каждого компонента
|
||
comboBox->addItem(property, property);
|
||
}
|
||
|
||
// По умолчанию устанавливаем "Не выбрано"
|
||
comboBox->setCurrentIndex(0);
|
||
|
||
// Соединяем сигнал изменения
|
||
connect(comboBox, QOverload<const QString &>::of(&QComboBox::currentTextChanged),
|
||
[this, i](const QString &value) {
|
||
onTableComboBoxChanged(i, value);
|
||
});
|
||
|
||
m_tableColumnComboBoxes.append(comboBox);
|
||
gridLayout->addWidget(comboBox, i + 1, 1);
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::createTableColumnFields: Поля настроек таблицы созданы";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createDecimalNumberFields()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createDecimalNumberFields: Создаем поля децимальных номеров и названия платы";
|
||
|
||
// Создаем группу для децимальных номеров и названия платы
|
||
QGroupBox *decimalGroup = new QGroupBox("Децимальные номера и название платы", m_tableScrollContent);
|
||
QGridLayout *decimalLayout = new QGridLayout(decimalGroup);
|
||
|
||
int currentRow = 0;
|
||
|
||
// Поле "Название платы" (только для SpecificationPCB)
|
||
if (m_documentType == DocumentType::SpecificationPCB) {
|
||
QLabel *boardNameLabel = new QLabel("Название платы:", decimalGroup);
|
||
decimalLayout->addWidget(boardNameLabel, currentRow, 0);
|
||
|
||
QComboBox *boardNameComboBox = new QComboBox(decimalGroup);
|
||
boardNameComboBox->setEditable(true);
|
||
boardNameComboBox->addItem("-- Не выбрано --", "");
|
||
|
||
// Добавляем параметры проекта
|
||
if (m_projectParamModel) {
|
||
QMap<QString, QString> projectParams = m_projectParamModel->getDataAsMap();
|
||
for (auto it = projectParams.begin(); it != projectParams.end(); ++it) {
|
||
QString paramName = it.key();
|
||
QString paramValue = it.value();
|
||
|
||
// Формируем отображаемый текст: "Название (значение)" если значение не пустое
|
||
QString displayText = paramName;
|
||
if (!paramValue.isEmpty()) {
|
||
displayText += QString(" (%1)").arg(paramValue);
|
||
}
|
||
|
||
boardNameComboBox->addItem(displayText, paramName);
|
||
}
|
||
}
|
||
|
||
// Соединяем сигнал изменения
|
||
connect(boardNameComboBox, QOverload<const QString &>::of(&QComboBox::currentTextChanged),
|
||
[this](const QString &value) {
|
||
onDecimalNumberComboBoxChanged("boardName", value);
|
||
});
|
||
|
||
// Добавляем комбобокс в компоновку
|
||
decimalLayout->addWidget(boardNameComboBox, currentRow, 1);
|
||
|
||
// Сохраняем ссылку на комбобокс
|
||
m_decimalNumberComboBoxes["boardName"] = boardNameComboBox;
|
||
currentRow++;
|
||
}
|
||
|
||
// Поле "Название документа" (только для Specification)
|
||
if (m_documentType == DocumentType::Specification) {
|
||
QLabel *documentNameLabel = new QLabel("Название документа:", decimalGroup);
|
||
decimalLayout->addWidget(documentNameLabel, currentRow, 0);
|
||
|
||
QComboBox *documentNameComboBox = new QComboBox(decimalGroup);
|
||
documentNameComboBox->setEditable(true);
|
||
documentNameComboBox->addItem("-- Не выбрано --", "");
|
||
|
||
// Добавляем параметры проекта
|
||
if (m_projectParamModel) {
|
||
QMap<QString, QString> projectParams = m_projectParamModel->getDataAsMap();
|
||
for (auto it = projectParams.begin(); it != projectParams.end(); ++it) {
|
||
QString paramName = it.key();
|
||
QString paramValue = it.value();
|
||
|
||
// Формируем отображаемый текст: "Название (значение)" если значение не пустое
|
||
QString displayText = paramName;
|
||
if (!paramValue.isEmpty()) {
|
||
displayText += QString(" (%1)").arg(paramValue);
|
||
}
|
||
|
||
documentNameComboBox->addItem(displayText, paramName);
|
||
}
|
||
}
|
||
|
||
// Соединяем сигнал изменения
|
||
connect(documentNameComboBox, QOverload<const QString &>::of(&QComboBox::currentTextChanged),
|
||
[this](const QString &value) {
|
||
onDecimalNumberComboBoxChanged("documentName", value);
|
||
});
|
||
|
||
// Добавляем комбобокс в компоновку
|
||
decimalLayout->addWidget(documentNameComboBox, currentRow, 1);
|
||
|
||
// Сохраняем ссылку на комбобокс
|
||
m_decimalNumberComboBoxes["documentName"] = documentNameComboBox;
|
||
currentRow++;
|
||
}
|
||
|
||
// Поле "Децимальный номер платы"
|
||
QLabel *boardLabel = new QLabel("Децимальный номер платы:", decimalGroup);
|
||
decimalLayout->addWidget(boardLabel, currentRow, 0);
|
||
|
||
QComboBox *boardComboBox = new QComboBox(decimalGroup);
|
||
boardComboBox->setEditable(true);
|
||
boardComboBox->addItem("-- Не выбрано --", "");
|
||
|
||
// Поле "Децимальный номер документа"
|
||
currentRow++;
|
||
QLabel *docLabel = new QLabel("Децимальный номер документа:", decimalGroup);
|
||
decimalLayout->addWidget(docLabel, currentRow, 0);
|
||
|
||
QComboBox *docComboBox = new QComboBox(decimalGroup);
|
||
docComboBox->setEditable(true);
|
||
docComboBox->addItem("-- Не выбрано --", "");
|
||
|
||
// Добавляем параметры проекта в оба комбобокса
|
||
if (m_projectParamModel) {
|
||
QMap<QString, QString> projectParams = m_projectParamModel->getDataAsMap();
|
||
for (auto it = projectParams.begin(); it != projectParams.end(); ++it) {
|
||
QString paramName = it.key();
|
||
QString paramValue = it.value();
|
||
|
||
// Формируем отображаемый текст: "Название (значение)" если значение не пустое
|
||
QString displayText = paramName;
|
||
if (!paramValue.isEmpty()) {
|
||
displayText += QString(" (%1)").arg(paramValue);
|
||
}
|
||
|
||
boardComboBox->addItem(displayText, paramName);
|
||
docComboBox->addItem(displayText, paramName);
|
||
}
|
||
}
|
||
|
||
// Соединяем сигналы изменения
|
||
connect(boardComboBox, QOverload<const QString &>::of(&QComboBox::currentTextChanged),
|
||
[this](const QString &value) {
|
||
onDecimalNumberComboBoxChanged("board", value);
|
||
});
|
||
|
||
connect(docComboBox, QOverload<const QString &>::of(&QComboBox::currentTextChanged),
|
||
[this](const QString &value) {
|
||
onDecimalNumberComboBoxChanged("document", value);
|
||
});
|
||
|
||
// Добавляем комбобоксы в компоновку
|
||
// boardComboBox должен быть на той же строке, что и boardLabel (currentRow - 1)
|
||
decimalLayout->addWidget(boardComboBox, currentRow - 1, 1);
|
||
// docComboBox на текущей строке
|
||
decimalLayout->addWidget(docComboBox, currentRow, 1);
|
||
|
||
// Сохраняем ссылки на комбобоксы
|
||
m_decimalNumberComboBoxes["board"] = boardComboBox;
|
||
m_decimalNumberComboBoxes["document"] = docComboBox;
|
||
|
||
// Добавляем группу в основную компоновку таблицы
|
||
QGridLayout *mainGridLayout = qobject_cast<QGridLayout*>(m_tableScrollContent->layout());
|
||
if (mainGridLayout) {
|
||
int row = mainGridLayout->rowCount();
|
||
mainGridLayout->addWidget(decimalGroup, row, 0, 1, 2);
|
||
} else {
|
||
// Если основная компоновка не является QGridLayout, создаем новую
|
||
QVBoxLayout *mainLayout = new QVBoxLayout(m_tableScrollContent);
|
||
mainLayout->addWidget(decimalGroup);
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::createDecimalNumberFields: Поля децимальных номеров и названия платы созданы";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createWhereUsedField()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createWhereUsedField: Создаем поле 'Куда входит'";
|
||
|
||
// Создаем группу для поля "Куда входит"
|
||
QGroupBox *whereUsedGroup = new QGroupBox("Куда входит (обозначение)", m_tableScrollContent);
|
||
QGridLayout *whereUsedLayout = new QGridLayout(whereUsedGroup);
|
||
|
||
// Поле "Куда входит"
|
||
QLabel *whereUsedLabel = new QLabel("Куда входит (обозначение):", whereUsedGroup);
|
||
whereUsedLayout->addWidget(whereUsedLabel, 0, 0);
|
||
|
||
QComboBox *whereUsedComboBox = new QComboBox(whereUsedGroup);
|
||
whereUsedComboBox->setEditable(true);
|
||
whereUsedComboBox->addItem("-- Не выбрано --", "");
|
||
|
||
// Добавляем параметры проекта в комбобокс
|
||
if (m_projectParamModel) {
|
||
QMap<QString, QString> projectParams = m_projectParamModel->getDataAsMap();
|
||
for (auto it = projectParams.begin(); it != projectParams.end(); ++it) {
|
||
QString paramName = it.key();
|
||
QString paramValue = it.value();
|
||
|
||
// Формируем отображаемый текст: "Название (значение)" если значение не пустое
|
||
QString displayText = paramName;
|
||
if (!paramValue.isEmpty()) {
|
||
displayText += QString(" (%1)").arg(paramValue);
|
||
}
|
||
|
||
whereUsedComboBox->addItem(displayText, paramName);
|
||
}
|
||
}
|
||
|
||
// Соединяем сигнал изменения
|
||
connect(whereUsedComboBox, QOverload<const QString &>::of(&QComboBox::currentTextChanged),
|
||
[this](const QString &value) {
|
||
onDecimalNumberComboBoxChanged("whereUsed", value);
|
||
});
|
||
|
||
// Добавляем комбобокс в компоновку
|
||
whereUsedLayout->addWidget(whereUsedComboBox, 0, 1);
|
||
|
||
// Сохраняем ссылку на комбобокс
|
||
m_decimalNumberComboBoxes["whereUsed"] = whereUsedComboBox;
|
||
|
||
// Добавляем группу в основную компоновку таблицы
|
||
QGridLayout *mainGridLayout = qobject_cast<QGridLayout*>(m_tableScrollContent->layout());
|
||
if (mainGridLayout) {
|
||
int row = mainGridLayout->rowCount();
|
||
mainGridLayout->addWidget(whereUsedGroup, row, 0, 1, 2);
|
||
} else {
|
||
// Если основная компоновка не является QGridLayout, создаем новую
|
||
QVBoxLayout *mainLayout = new QVBoxLayout(m_tableScrollContent);
|
||
mainLayout->addWidget(whereUsedGroup);
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::createWhereUsedField: Поле 'Куда входит' создано";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createPrimaryApplicationField()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createPrimaryApplicationField: Создаем поле 'Первичное применение'";
|
||
|
||
// Определяем номер поля в зависимости от типа документа
|
||
int fieldNumber = 0;
|
||
QString fieldLabelText;
|
||
switch (m_documentType) {
|
||
case DocumentType::Perechen:
|
||
fieldNumber = 251;
|
||
fieldLabelText = "Первичное применение (Перечень):";
|
||
break;
|
||
case DocumentType::SpecificationPCB:
|
||
fieldNumber = 252;
|
||
fieldLabelText = "Первичное применение (Спецификация ПП):";
|
||
break;
|
||
case DocumentType::Specification:
|
||
fieldNumber = 253;
|
||
fieldLabelText = "Первичное применение (Спецификация):";
|
||
break;
|
||
case DocumentType::Vedomost:
|
||
fieldNumber = 254;
|
||
fieldLabelText = "Первичное применение (Ведомость):";
|
||
break;
|
||
default:
|
||
return;
|
||
}
|
||
|
||
// Создаем группу для поля "Первичное применение"
|
||
QGroupBox *primaryAppGroup = new QGroupBox("Первичное применение", m_tableScrollContent);
|
||
QGridLayout *primaryAppLayout = new QGridLayout(primaryAppGroup);
|
||
|
||
// Поле "Первичное применение"
|
||
QLabel *primaryAppLabel = new QLabel(fieldLabelText, primaryAppGroup);
|
||
primaryAppLayout->addWidget(primaryAppLabel, 0, 0);
|
||
|
||
QComboBox *primaryAppComboBox = new QComboBox(primaryAppGroup);
|
||
primaryAppComboBox->setEditable(true);
|
||
primaryAppComboBox->addItem("-- Не выбрано --", "");
|
||
|
||
// Добавляем параметры проекта в комбобокс
|
||
if (m_projectParamModel) {
|
||
QMap<QString, QString> projectParams = m_projectParamModel->getDataAsMap();
|
||
for (auto it = projectParams.begin(); it != projectParams.end(); ++it) {
|
||
QString paramName = it.key();
|
||
QString paramValue = it.value();
|
||
|
||
// Формируем отображаемый текст: "Название (значение)" если значение не пустое
|
||
QString displayText = paramName;
|
||
if (!paramValue.isEmpty()) {
|
||
displayText += QString(" (%1)").arg(paramValue);
|
||
}
|
||
|
||
primaryAppComboBox->addItem(displayText, paramName);
|
||
}
|
||
}
|
||
|
||
// Соединяем сигнал изменения
|
||
connect(primaryAppComboBox, QOverload<const QString &>::of(&QComboBox::currentTextChanged),
|
||
[this, fieldNumber](const QString &value) {
|
||
onPrimaryApplicationComboBoxChanged(fieldNumber, value);
|
||
});
|
||
|
||
// Добавляем комбобокс в компоновку
|
||
primaryAppLayout->addWidget(primaryAppComboBox, 0, 1);
|
||
|
||
// Сохраняем ссылку на комбобокс
|
||
m_primaryApplicationComboBox = primaryAppComboBox;
|
||
m_primaryApplicationFieldNumber = fieldNumber;
|
||
|
||
// Добавляем группу в основную компоновку таблицы
|
||
QGridLayout *mainGridLayout = qobject_cast<QGridLayout*>(m_tableScrollContent->layout());
|
||
if (mainGridLayout) {
|
||
int row = mainGridLayout->rowCount();
|
||
mainGridLayout->addWidget(primaryAppGroup, row, 0, 1, 2);
|
||
} else {
|
||
// Если основная компоновка не является QGridLayout, создаем новую
|
||
QVBoxLayout *mainLayout = qobject_cast<QVBoxLayout*>(m_tableScrollContent->layout());
|
||
if (mainLayout) {
|
||
mainLayout->addWidget(primaryAppGroup);
|
||
} else {
|
||
QVBoxLayout *newLayout = new QVBoxLayout(m_tableScrollContent);
|
||
newLayout->addWidget(primaryAppGroup);
|
||
}
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::createPrimaryApplicationField: Поле 'Первичное применение' создано для поля" << fieldNumber;
|
||
}
|
||
|
||
void DocumentSettingsDialog::createFontSettingsFields()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createFontSettingsFields: Создаем поля настроек шрифта";
|
||
|
||
// Создаем группу для настроек шрифта
|
||
QGroupBox *fontGroup = new QGroupBox("Настройки шрифта таблицы", m_tableScrollContent);
|
||
QGridLayout *fontLayout = new QGridLayout(fontGroup);
|
||
|
||
// Поле "Размер шрифта"
|
||
QLabel *fontSizeLabel = new QLabel("Размер шрифта:", fontGroup);
|
||
fontLayout->addWidget(fontSizeLabel, 0, 0);
|
||
|
||
m_fontSizeSpinBox = new QSpinBox(fontGroup);
|
||
m_fontSizeSpinBox->setMinimum(6);
|
||
m_fontSizeSpinBox->setMaximum(72);
|
||
m_fontSizeSpinBox->setValue(12);
|
||
m_fontSizeSpinBox->setSuffix(" пт");
|
||
fontLayout->addWidget(m_fontSizeSpinBox, 0, 1);
|
||
|
||
// Поле "Поджим по ширине"
|
||
QLabel *fontStretchLabel = new QLabel("Поджим по ширине:", fontGroup);
|
||
fontLayout->addWidget(fontStretchLabel, 1, 0);
|
||
|
||
m_fontStretchSpinBox = new QSpinBox(fontGroup);
|
||
m_fontStretchSpinBox->setMinimum(50);
|
||
m_fontStretchSpinBox->setMaximum(200);
|
||
m_fontStretchSpinBox->setValue(100);
|
||
m_fontStretchSpinBox->setSuffix("%");
|
||
fontLayout->addWidget(m_fontStretchSpinBox, 1, 1);
|
||
|
||
// Добавляем группу в основную компоновку таблицы
|
||
QGridLayout *mainGridLayout = qobject_cast<QGridLayout*>(m_tableScrollContent->layout());
|
||
if (mainGridLayout) {
|
||
int row = mainGridLayout->rowCount();
|
||
mainGridLayout->addWidget(fontGroup, row, 0, 1, 2);
|
||
} else {
|
||
// Если основная компоновка не является QGridLayout, создаем новую
|
||
QVBoxLayout *mainLayout = qobject_cast<QVBoxLayout*>(m_tableScrollContent->layout());
|
||
if (mainLayout) {
|
||
mainLayout->addWidget(fontGroup);
|
||
}
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::createFontSettingsFields: Поля настроек шрифта созданы";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createInscriptionFields()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createInscriptionFields: Создаем поля надписей";
|
||
|
||
QList<int> requiredFields = getRequiredInscriptionFields();
|
||
QList<int> optionalFields = getOptionalInscriptionFields();
|
||
|
||
QVBoxLayout *mainLayout = new QVBoxLayout(m_inscriptionScrollContent);
|
||
|
||
// Создаем группу для обязательных полей
|
||
if (!requiredFields.isEmpty()) {
|
||
QGroupBox *requiredGroup = new QGroupBox("Обязательные поля", m_inscriptionScrollContent);
|
||
QGridLayout *requiredLayout = new QGridLayout(requiredGroup);
|
||
|
||
int row = 0;
|
||
for (int fieldNumber : requiredFields) {
|
||
createInscriptionField(fieldNumber, requiredLayout, row, true);
|
||
row++;
|
||
}
|
||
|
||
mainLayout->addWidget(requiredGroup);
|
||
}
|
||
|
||
// Создаем группу для опциональных полей
|
||
if (!optionalFields.isEmpty()) {
|
||
QGroupBox *optionalGroup = new QGroupBox("Опциональные поля", m_inscriptionScrollContent);
|
||
QGridLayout *optionalLayout = new QGridLayout(optionalGroup);
|
||
|
||
int row = 0;
|
||
for (int fieldNumber : optionalFields) {
|
||
createInscriptionField(fieldNumber, optionalLayout, row, false);
|
||
row++;
|
||
}
|
||
|
||
mainLayout->addWidget(optionalGroup);
|
||
}
|
||
|
||
mainLayout->addStretch();
|
||
|
||
qDebug() << "DocumentSettingsDialog::createInscriptionFields: Поля надписей созданы";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createInscriptionField(int fieldNumber, QGridLayout *layout, int row, bool isRequired)
|
||
{
|
||
QString fieldName = s_fieldNames.value(fieldNumber, QString("Поле %1").arg(fieldNumber));
|
||
QString fieldDescription = s_fieldDescriptions.value(fieldNumber, "");
|
||
|
||
// Создаем метку с названием поля
|
||
QString labelText = fieldName;
|
||
if (isRequired) {
|
||
labelText += " *";
|
||
}
|
||
QLabel *nameLabel = new QLabel(labelText);
|
||
nameLabel->setWordWrap(true);
|
||
layout->addWidget(nameLabel, row, 0);
|
||
|
||
// Создаем редактируемый комбобокс для выбора значения
|
||
QComboBox *comboBox = new QComboBox();
|
||
comboBox->setEditable(true);
|
||
comboBox->addItem("-- Не выбрано --", "");
|
||
|
||
// Добавляем параметры проекта
|
||
if (m_projectParamModel) {
|
||
QMap<QString, QString> projectParams = m_projectParamModel->getDataAsMap();
|
||
for (auto it = projectParams.begin(); it != projectParams.end(); ++it) {
|
||
QString paramName = it.key();
|
||
QString paramValue = it.value();
|
||
|
||
// Формируем отображаемый текст: "Название (значение)" если значение не пустое
|
||
QString displayText = paramName;
|
||
if (!paramValue.isEmpty()) {
|
||
displayText += QString(" (%1)").arg(paramValue);
|
||
}
|
||
|
||
comboBox->addItem(displayText, paramName);
|
||
}
|
||
}
|
||
|
||
// Соединяем сигнал изменения
|
||
connect(comboBox, QOverload<const QString &>::of(&QComboBox::currentTextChanged),
|
||
[this, fieldNumber](const QString &value) {
|
||
onInscriptionComboBoxChanged(fieldNumber, value);
|
||
});
|
||
|
||
m_inscriptionComboBoxes[fieldNumber] = comboBox;
|
||
layout->addWidget(comboBox, row, 1);
|
||
|
||
// Создаем метку для описания
|
||
if (!fieldDescription.isEmpty()) {
|
||
QLabel *descLabel = new QLabel(fieldDescription);
|
||
descLabel->setWordWrap(true);
|
||
descLabel->setStyleSheet("color: gray; font-size: 10px;");
|
||
layout->addWidget(descLabel, row, 3);
|
||
}
|
||
|
||
// Сохраняем информацию о поле
|
||
TitleInscriptionFieldExtended field;
|
||
field.number = fieldNumber;
|
||
field.name = fieldName;
|
||
field.description = fieldDescription;
|
||
field.isRequired = isRequired;
|
||
field.isCustom = false;
|
||
field.currentValue = "";
|
||
field.projectParamName = "";
|
||
|
||
m_inscriptionFields[fieldNumber] = field;
|
||
}
|
||
|
||
void DocumentSettingsDialog::createImagePreview()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createImagePreview: Создаем предварительный просмотр";
|
||
|
||
m_imageView = new QGraphicsView();
|
||
m_imageScene = new QGraphicsScene();
|
||
m_imageView->setScene(m_imageScene);
|
||
|
||
// Загружаем изображение титульного листа
|
||
QStringList possiblePaths;
|
||
possiblePaths << QApplication::applicationDirPath() + "/assets/Титул.PNG";
|
||
possiblePaths << QApplication::applicationDirPath() + "/assets/Title.PNG";
|
||
possiblePaths << "assets/Титул.PNG";
|
||
possiblePaths << "assets/Title.PNG";
|
||
possiblePaths << ":/assets/Титул.PNG";
|
||
possiblePaths << ":/assets/Title.PNG";
|
||
|
||
QString imagePath;
|
||
bool imageFound = false;
|
||
|
||
for (const QString &path : possiblePaths) {
|
||
qDebug() << "DocumentSettingsDialog::createImagePreview: Проверяем путь:" << path;
|
||
if (QFile::exists(path)) {
|
||
imagePath = path;
|
||
imageFound = true;
|
||
qDebug() << "DocumentSettingsDialog::createImagePreview: Найдено изображение по пути:" << path;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (imageFound) {
|
||
QPixmap pixmap(imagePath);
|
||
if (!pixmap.isNull()) {
|
||
m_imageItem = m_imageScene->addPixmap(pixmap);
|
||
m_imageScene->setSceneRect(pixmap.rect());
|
||
m_imageView->fitInView(m_imageScene->sceneRect(), Qt::KeepAspectRatio);
|
||
qDebug() << "DocumentSettingsDialog::createImagePreview: Изображение загружено успешно, размер:" << pixmap.size();
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::createImagePreview: Не удалось загрузить изображение из" << imagePath;
|
||
createPlaceholderImage();
|
||
}
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::createImagePreview: Не удалось найти изображение титульного листа";
|
||
createPlaceholderImage();
|
||
}
|
||
|
||
// Создаем слайдер масштабирования
|
||
m_zoomSlider = new QSlider(Qt::Horizontal);
|
||
m_zoomSlider->setRange(25, 200);
|
||
m_zoomSlider->setValue(100);
|
||
m_zoomSlider->setTickPosition(QSlider::TicksBelow);
|
||
m_zoomSlider->setTickInterval(25);
|
||
|
||
qDebug() << "DocumentSettingsDialog::createImagePreview: Предварительный просмотр создан";
|
||
}
|
||
|
||
void DocumentSettingsDialog::createPlaceholderImage()
|
||
{
|
||
// Создаем заглушку с текстом
|
||
QPixmap placeholder(400, 600);
|
||
placeholder.fill(Qt::white);
|
||
|
||
QPainter painter(&placeholder);
|
||
painter.setPen(Qt::black);
|
||
painter.setFont(QFont("Arial", 14));
|
||
painter.drawText(placeholder.rect(), Qt::AlignCenter, "Титульный лист\n(изображение не найдено)");
|
||
|
||
m_imageItem = m_imageScene->addPixmap(placeholder);
|
||
m_imageScene->setSceneRect(placeholder.rect());
|
||
}
|
||
|
||
QStringList DocumentSettingsDialog::getTableColumnNames() const
|
||
{
|
||
switch (m_documentType) {
|
||
case DocumentType::Perechen:
|
||
return {"Наименование"};
|
||
case DocumentType::SpecificationPCB:
|
||
return {"Обозначение", "Наименование"};
|
||
case DocumentType::Specification:
|
||
return {}; // Пока ничего не нужно
|
||
case DocumentType::Vedomost:
|
||
return {"Наименование", "Код продукции", "Обозначение документа на поставку",
|
||
"Поставщик", "Примечание"};
|
||
default:
|
||
return {};
|
||
}
|
||
}
|
||
|
||
QStringList DocumentSettingsDialog::getDefaultTableMappings() const
|
||
{
|
||
switch (m_documentType) {
|
||
case DocumentType::Perechen:
|
||
// Перечень: только наименование
|
||
return {"Name"};
|
||
case DocumentType::SpecificationPCB:
|
||
// Спецификация ПП: обозначение и наименование
|
||
return {"Designator", "Name"};
|
||
case DocumentType::Specification:
|
||
// Спецификация: пока ничего не нужно
|
||
return {};
|
||
case DocumentType::Vedomost:
|
||
// Ведомость: только поля, которые можно маппить на свойства компонентов
|
||
return {"Name", "ProductCode", "DocumentCode", "Supplier", "WhereUsed", "Note"};
|
||
default:
|
||
return {};
|
||
}
|
||
}
|
||
|
||
QList<int> DocumentSettingsDialog::getRequiredInscriptionFields() const
|
||
{
|
||
// Общие обязательные поля для всех документов
|
||
// Поле 25 (Первичное применение) теперь находится в настройках таблицы как 251-254
|
||
return {1, 2, 4, 9, 10, 11, 111, 112, 113, 114};
|
||
}
|
||
|
||
QList<int> DocumentSettingsDialog::getOptionalInscriptionFields() const
|
||
{
|
||
// Специфичные поля для каждого типа документа
|
||
switch (m_documentType) {
|
||
case DocumentType::Perechen:
|
||
// Перечень: поля изменений для перечня элементов
|
||
return {};
|
||
case DocumentType::SpecificationPCB:
|
||
// Спецификация ПП: поля изменений для спецификации печатной платы
|
||
return {};
|
||
case DocumentType::Specification:
|
||
// Спецификация материалов: поля изменений для спецификации материалов
|
||
// Поле 1002 "Название документа" теперь находится в разделе децимальных номеров
|
||
return {};
|
||
case DocumentType::Vedomost:
|
||
// Ведомость покупных изделий: поля изменений для ведомости
|
||
return {301};
|
||
default:
|
||
return {};
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::loadTableSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Загружаем настройки таблицы";
|
||
|
||
// Загружаем текущие настройки из контроллера
|
||
if (m_controller) {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Контроллер доступен";
|
||
switch (m_documentType) {
|
||
case DocumentType::Perechen:
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Загружаем для Perechen";
|
||
if (m_controller->perechenTableController()) {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: PerechenTableController доступен";
|
||
m_currentTableMappings = m_controller->perechenTableController()->getColumnMappings();
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Загружены настройки Perechen:" << m_currentTableMappings;
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: PerechenTableController недоступен";
|
||
}
|
||
break;
|
||
case DocumentType::SpecificationPCB:
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Загружаем для SpecificationPCB";
|
||
if (m_controller->specificationPCBController()) {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: SpecificationPCBController доступен";
|
||
m_currentTableMappings = m_controller->specificationPCBController()->getColumnMappings();
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Загружены настройки SpecificationPCB:" << m_currentTableMappings;
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: SpecificationPCBController недоступен";
|
||
}
|
||
break;
|
||
case DocumentType::Specification:
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Загружаем для Specification";
|
||
if (m_controller->specificationController()) {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: SpecificationController доступен";
|
||
m_currentTableMappings = m_controller->specificationController()->getColumnMappings();
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Загружены настройки Specification:" << m_currentTableMappings;
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: SpecificationController недоступен";
|
||
}
|
||
break;
|
||
case DocumentType::Vedomost:
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Загружаем для Vedomost";
|
||
if (m_controller->vedomostController()) {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: VedomostController доступен";
|
||
m_currentTableMappings = m_controller->vedomostController()->getColumnMappings();
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Загружены настройки Vedomost:" << m_currentTableMappings;
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: VedomostController недоступен";
|
||
}
|
||
break;
|
||
case DocumentType::SimpleList:
|
||
// Для SimpleList настройки колонок не используются
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: SimpleList - настройки колонок не требуются";
|
||
break;
|
||
}
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Контроллер недоступен";
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Применяем настройки к комбобоксам, количество:" << m_tableColumnComboBoxes.size();
|
||
|
||
// Применяем настройки к комбобоксам
|
||
for (int i = 0; i < m_tableColumnComboBoxes.size() && i < m_currentTableMappings.size(); ++i) {
|
||
QString value = m_currentTableMappings[i];
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Применяем значение" << value << "к комбобоксу" << i;
|
||
if (value.isEmpty()) {
|
||
// Если значение пустое, устанавливаем "-- Не выбрано --"
|
||
m_tableColumnComboBoxes[i]->setCurrentIndex(0);
|
||
} else {
|
||
// Сначала ищем по данным (itemData)
|
||
int index = m_tableColumnComboBoxes[i]->findData(value);
|
||
if (index >= 0) {
|
||
m_tableColumnComboBoxes[i]->setCurrentIndex(index);
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Установлен индекс" << index << "для значения" << value << "(найдено по данным)";
|
||
} else {
|
||
// Если не найдено по данным, ищем по тексту
|
||
index = m_tableColumnComboBoxes[i]->findText(value);
|
||
if (index >= 0) {
|
||
m_tableColumnComboBoxes[i]->setCurrentIndex(index);
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Установлен индекс" << index << "для значения" << value << "(найдено по тексту)";
|
||
} else {
|
||
// Если не найдено, добавляем значение в комбобокс и устанавливаем его
|
||
m_tableColumnComboBoxes[i]->addItem(value, value);
|
||
index = m_tableColumnComboBoxes[i]->findData(value);
|
||
m_tableColumnComboBoxes[i]->setCurrentIndex(index);
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Добавлено значение" << value << "в комбобокс и установлен индекс" << index;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Настройки таблицы загружены";
|
||
}
|
||
|
||
void DocumentSettingsDialog::loadInscriptionSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::loadInscriptionSettings: Загружаем настройки надписей";
|
||
|
||
if (m_titleInscriptionsModel) {
|
||
QMap<int, QString> savedValues = m_titleInscriptionsModel->getAllInscriptions();
|
||
|
||
for (auto it = savedValues.begin(); it != savedValues.end(); ++it) {
|
||
int fieldNumber = it.key();
|
||
QString value = it.value();
|
||
|
||
if (m_inscriptionComboBoxes.contains(fieldNumber)) {
|
||
// Ищем значение в комбобоксе по данным (название поля)
|
||
int index = m_inscriptionComboBoxes[fieldNumber]->findData(value);
|
||
if (index >= 0) {
|
||
// Нашли предустановленное значение, устанавливаем его
|
||
m_inscriptionComboBoxes[fieldNumber]->setCurrentIndex(index);
|
||
} else {
|
||
// Если значение не найдено в предустановленных, устанавливаем как кастомный текст
|
||
m_inscriptionComboBoxes[fieldNumber]->setCurrentText(value);
|
||
}
|
||
|
||
// Обновляем поле (сохраняем оригинальное значение из модели)
|
||
m_inscriptionFields[fieldNumber].currentValue = value;
|
||
}
|
||
}
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::loadInscriptionSettings: Настройки надписей загружены";
|
||
}
|
||
|
||
void DocumentSettingsDialog::loadFontSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::loadFontSettings: Загружаем настройки шрифта";
|
||
|
||
if (!m_controller || !m_fontSizeSpinBox || !m_fontStretchSpinBox) {
|
||
qDebug() << "DocumentSettingsDialog::loadFontSettings: Контроллер или виджеты недоступны";
|
||
return;
|
||
}
|
||
|
||
int fontSize = 12;
|
||
int fontStretch = 100;
|
||
|
||
// Получаем настройки из соответствующего контроллера
|
||
switch (m_documentType) {
|
||
case DocumentType::Perechen:
|
||
if (m_controller->perechenTableController()) {
|
||
fontSize = m_controller->perechenTableController()->getFontSize();
|
||
fontStretch = m_controller->perechenTableController()->getFontStretch();
|
||
}
|
||
break;
|
||
case DocumentType::SpecificationPCB:
|
||
if (m_controller->specificationPCBController()) {
|
||
fontSize = m_controller->specificationPCBController()->getFontSize();
|
||
fontStretch = m_controller->specificationPCBController()->getFontStretch();
|
||
}
|
||
break;
|
||
case DocumentType::Specification:
|
||
if (m_controller->specificationController()) {
|
||
fontSize = m_controller->specificationController()->getFontSize();
|
||
fontStretch = m_controller->specificationController()->getFontStretch();
|
||
}
|
||
break;
|
||
case DocumentType::Vedomost:
|
||
if (m_controller->vedomostController()) {
|
||
fontSize = m_controller->vedomostController()->getFontSize();
|
||
fontStretch = m_controller->vedomostController()->getFontStretch();
|
||
}
|
||
break;
|
||
case DocumentType::SimpleList:
|
||
// Для SimpleList настройки шрифта не используются
|
||
break;
|
||
}
|
||
|
||
m_fontSizeSpinBox->setValue(fontSize);
|
||
m_fontStretchSpinBox->setValue(fontStretch);
|
||
|
||
qDebug() << "DocumentSettingsDialog::loadFontSettings: Настройки шрифта загружены - размер:" << fontSize << "поджим:" << fontStretch;
|
||
}
|
||
|
||
void DocumentSettingsDialog::saveFontSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::saveFontSettings: Сохраняем настройки шрифта";
|
||
|
||
if (!m_controller || !m_fontSizeSpinBox || !m_fontStretchSpinBox) {
|
||
qDebug() << "DocumentSettingsDialog::saveFontSettings: Контроллер или виджеты недоступны";
|
||
return;
|
||
}
|
||
|
||
int fontSize = m_fontSizeSpinBox->value();
|
||
int fontStretch = m_fontStretchSpinBox->value();
|
||
|
||
// Сохраняем настройки в соответствующий контроллер
|
||
switch (m_documentType) {
|
||
case DocumentType::Perechen:
|
||
if (m_controller->perechenTableController()) {
|
||
m_controller->perechenTableController()->setFontSize(fontSize);
|
||
m_controller->perechenTableController()->setFontStretch(fontStretch);
|
||
}
|
||
break;
|
||
case DocumentType::SpecificationPCB:
|
||
if (m_controller->specificationPCBController()) {
|
||
m_controller->specificationPCBController()->setFontSize(fontSize);
|
||
m_controller->specificationPCBController()->setFontStretch(fontStretch);
|
||
}
|
||
break;
|
||
case DocumentType::Specification:
|
||
if (m_controller->specificationController()) {
|
||
m_controller->specificationController()->setFontSize(fontSize);
|
||
m_controller->specificationController()->setFontStretch(fontStretch);
|
||
}
|
||
break;
|
||
case DocumentType::Vedomost:
|
||
if (m_controller->vedomostController()) {
|
||
m_controller->vedomostController()->setFontSize(fontSize);
|
||
m_controller->vedomostController()->setFontStretch(fontStretch);
|
||
}
|
||
break;
|
||
case DocumentType::SimpleList:
|
||
// Для SimpleList настройки шрифта не используются
|
||
break;
|
||
}
|
||
|
||
// Сохраняем в БД
|
||
if (m_controller) {
|
||
m_controller->saveProjectSettingsToDatabase();
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::saveFontSettings: Настройки шрифта сохранены - размер:" << fontSize << "поджим:" << fontStretch;
|
||
}
|
||
|
||
void DocumentSettingsDialog::saveTableSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Сохраняем настройки таблицы";
|
||
|
||
// Собираем текущие настройки из комбобоксов
|
||
m_currentTableMappings.clear();
|
||
for (QComboBox *comboBox : m_tableColumnComboBoxes) {
|
||
QString value = comboBox->currentText();
|
||
// Если выбрано "-- Не выбрано --", сохраняем пустую строку
|
||
if (value == "-- Не выбрано --") {
|
||
value = "";
|
||
}
|
||
m_currentTableMappings.append(value);
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Собранные настройки из комбобоксов:" << m_currentTableMappings;
|
||
|
||
// Для Perechen нужно сохранить полный список настроек (4 элемента)
|
||
if (m_documentType == DocumentType::Perechen) {
|
||
// Получаем текущие настройки из контроллера
|
||
QStringList fullMappings;
|
||
if (m_controller && m_controller->perechenTableController()) {
|
||
fullMappings = m_controller->perechenTableController()->getColumnMappings();
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Полные настройки из контроллера:" << fullMappings;
|
||
}
|
||
|
||
// Обновляем только те настройки, которые есть в комбобоксах
|
||
for (int i = 0; i < m_tableColumnComboBoxes.size() && i < fullMappings.size(); ++i) {
|
||
fullMappings[i] = m_currentTableMappings[i];
|
||
}
|
||
|
||
m_currentTableMappings = fullMappings;
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Обновленные полные настройки:" << m_currentTableMappings;
|
||
}
|
||
|
||
// Сохраняем в контроллер
|
||
if (m_controller) {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Контроллер доступен";
|
||
switch (m_documentType) {
|
||
case DocumentType::Perechen:
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Сохраняем для Perechen";
|
||
if (m_controller->perechenTableController()) {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: PerechenTableController доступен";
|
||
m_controller->perechenTableController()->setColumnMappings(m_currentTableMappings);
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Настройки Perechen сохранены";
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: PerechenTableController недоступен";
|
||
}
|
||
break;
|
||
case DocumentType::SpecificationPCB:
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Сохраняем для SpecificationPCB";
|
||
if (m_controller->specificationPCBController()) {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: SpecificationPCBController доступен";
|
||
m_controller->specificationPCBController()->setColumnMappings(m_currentTableMappings);
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Настройки SpecificationPCB сохранены";
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: SpecificationPCBController недоступен";
|
||
}
|
||
break;
|
||
case DocumentType::Specification:
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Сохраняем для Specification";
|
||
if (m_controller->specificationController()) {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: SpecificationController доступен";
|
||
m_controller->specificationController()->setColumnMappings(m_currentTableMappings);
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Настройки Specification сохранены";
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: SpecificationController недоступен";
|
||
}
|
||
break;
|
||
case DocumentType::Vedomost:
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Сохраняем для Vedomost";
|
||
if (m_controller->vedomostController()) {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: VedomostController доступен";
|
||
m_controller->vedomostController()->setColumnMappings(m_currentTableMappings);
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Настройки Vedomost сохранены";
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: VedomostController недоступен";
|
||
}
|
||
break;
|
||
case DocumentType::SimpleList:
|
||
// Для SimpleList настройки колонок не используются
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: SimpleList - настройки колонок не требуются";
|
||
break;
|
||
}
|
||
} else {
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Контроллер недоступен";
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Настройки таблицы сохранены:" << m_currentTableMappings;
|
||
}
|
||
|
||
void DocumentSettingsDialog::saveInscriptionSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::saveInscriptionSettings: Сохраняем настройки надписей";
|
||
|
||
if (m_titleInscriptionsModel) {
|
||
// Обновляем только поля из таба основных надписей, не заменяя все поля
|
||
// Это важно, чтобы не потерять поля 251-254 (Первичное применение)
|
||
for (auto it = m_inscriptionFields.begin(); it != m_inscriptionFields.end(); ++it) {
|
||
int fieldNumber = it.key();
|
||
const TitleInscriptionFieldExtended &field = it.value();
|
||
|
||
if (!field.currentValue.isEmpty()) {
|
||
m_titleInscriptionsModel->setInscriptionValue(fieldNumber, field.currentValue);
|
||
} else {
|
||
m_titleInscriptionsModel->setInscriptionValue(fieldNumber, "");
|
||
}
|
||
}
|
||
|
||
// Сохраняем в базу данных через контроллер
|
||
// Сохраняем все надписи из модели, как это делают остальные поля
|
||
if (m_controller) {
|
||
QMap<int, QString> allInscriptions = m_titleInscriptionsModel->getAllInscriptions();
|
||
m_controller->saveTitleInscriptionsToDatabase(allInscriptions);
|
||
}
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::saveInscriptionSettings: Настройки надписей сохранены";
|
||
}
|
||
|
||
// Слоты
|
||
void DocumentSettingsDialog::onTableComboBoxChanged(int columnIndex, const QString &value)
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::onTableComboBoxChanged: Колонка" << columnIndex << "изменена на" << value;
|
||
|
||
// Если выбрано "-- Не выбрано --", сохраняем пустую строку
|
||
QString saveValue = (value == "-- Не выбрано --") ? "" : value;
|
||
updateTableFieldValue(columnIndex, saveValue);
|
||
|
||
// Для Perechen обновляем полный список настроек
|
||
if (m_documentType == DocumentType::Perechen && m_controller && m_controller->perechenTableController()) {
|
||
QStringList fullMappings = m_controller->perechenTableController()->getColumnMappings();
|
||
if (columnIndex < fullMappings.size()) {
|
||
fullMappings[columnIndex] = saveValue;
|
||
m_currentTableMappings = fullMappings;
|
||
qDebug() << "DocumentSettingsDialog::onTableComboBoxChanged: Обновлены полные настройки:" << m_currentTableMappings;
|
||
}
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::onInscriptionComboBoxChanged(int fieldNumber, const QString &value)
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::onInscriptionComboBoxChanged: Поле" << fieldNumber << "изменено на" << value;
|
||
|
||
// Получаем комбобокс для этого поля
|
||
if (m_inscriptionComboBoxes.contains(fieldNumber)) {
|
||
QComboBox *comboBox = m_inscriptionComboBoxes[fieldNumber];
|
||
|
||
// Проверяем, является ли значение одним из предустановленных параметров проекта
|
||
int index = comboBox->findText(value);
|
||
if (index >= 0) {
|
||
// Это предустановленное значение, берем данные (название поля)
|
||
QString fieldName = comboBox->itemData(index).toString();
|
||
if (!fieldName.isEmpty()) {
|
||
updateInscriptionFieldValue(fieldNumber, fieldName);
|
||
return;
|
||
}
|
||
}
|
||
|
||
// Если это не предустановленное значение, используем как есть (кастомный ввод)
|
||
updateInscriptionFieldValue(fieldNumber, value);
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::onDecimalNumberComboBoxChanged(const QString &type, const QString &value)
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::onDecimalNumberComboBoxChanged: Децимальный номер" << type << "изменен на" << value;
|
||
|
||
if (m_decimalNumberComboBoxes.contains(type)) {
|
||
QComboBox *comboBox = m_decimalNumberComboBoxes[type];
|
||
|
||
// Проверяем, является ли значение одним из предустановленных параметров проекта
|
||
int index = comboBox->findText(value);
|
||
if (index >= 0) {
|
||
// Это предустановленное значение, берем данные (название поля)
|
||
QString fieldName = comboBox->itemData(index).toString();
|
||
if (!fieldName.isEmpty()) {
|
||
m_decimalNumberValues[type] = fieldName;
|
||
return;
|
||
}
|
||
}
|
||
|
||
// Если это не предустановленное значение, используем как есть (кастомный ввод)
|
||
m_decimalNumberValues[type] = value;
|
||
}
|
||
}
|
||
|
||
|
||
void DocumentSettingsDialog::onZoomChanged(int value)
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::onZoomChanged: Масштаб изменен на" << value;
|
||
|
||
if (m_imageView && m_imageScene) {
|
||
qreal scale = value / 100.0;
|
||
m_imageView->setTransform(QTransform::fromScale(scale, scale));
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::onAccept()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::onAccept: Принимаем настройки";
|
||
|
||
saveTableSettings();
|
||
saveInscriptionSettings();
|
||
saveFontSettings();
|
||
|
||
// Сохраняем настройки децимальных номеров (только для SpecificationPCB и Specification)
|
||
if (m_documentType == DocumentType::SpecificationPCB || m_documentType == DocumentType::Specification) {
|
||
saveDecimalNumberSettings();
|
||
}
|
||
|
||
// Сохраняем настройки "Куда входит" для ведомости
|
||
if (m_documentType == DocumentType::Vedomost) {
|
||
saveDecimalNumberSettings();
|
||
}
|
||
|
||
// Сохраняем настройки "Первичное применение" для всех типов документов
|
||
savePrimaryApplicationSettings();
|
||
|
||
// Сохраняем настройки SimpleList
|
||
if (m_documentType == DocumentType::SimpleList) {
|
||
saveSimpleListSettings();
|
||
}
|
||
|
||
accept();
|
||
}
|
||
|
||
void DocumentSettingsDialog::onCancel()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::onCancel: Отменяем настройки";
|
||
reject();
|
||
}
|
||
|
||
void DocumentSettingsDialog::onResetTableSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::onResetTableSettings: Сбрасываем настройки таблицы";
|
||
|
||
// Для всех типов документов сбрасываем на "Не выбрано"
|
||
for (QComboBox *comboBox : m_tableColumnComboBoxes) {
|
||
comboBox->setCurrentIndex(0); // "-- Не выбрано --"
|
||
}
|
||
|
||
// Сбрасываем настройки децимальных номеров (только для SpecificationPCB и Specification)
|
||
if (m_documentType == DocumentType::SpecificationPCB || m_documentType == DocumentType::Specification) {
|
||
for (auto it = m_decimalNumberComboBoxes.begin(); it != m_decimalNumberComboBoxes.end(); ++it) {
|
||
it.value()->setCurrentIndex(0); // "-- Не выбрано --"
|
||
}
|
||
m_decimalNumberValues.clear();
|
||
}
|
||
|
||
// Сбрасываем настройки "Куда входит" для ведомости
|
||
if (m_documentType == DocumentType::Vedomost) {
|
||
if (m_decimalNumberComboBoxes.contains("whereUsed")) {
|
||
m_decimalNumberComboBoxes["whereUsed"]->setCurrentIndex(0); // "-- Не выбрано --"
|
||
}
|
||
m_decimalNumberValues.remove("whereUsed");
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::onResetInscriptionSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::onResetInscriptionSettings: Сбрасываем настройки надписей";
|
||
|
||
for (auto it = m_inscriptionComboBoxes.begin(); it != m_inscriptionComboBoxes.end(); ++it) {
|
||
it.value()->setCurrentIndex(0); // "-- Не выбрано --"
|
||
}
|
||
|
||
for (auto it = m_inscriptionFields.begin(); it != m_inscriptionFields.end(); ++it) {
|
||
it.value().currentValue = "";
|
||
it.value().isCustom = false;
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::updateTableFieldValue(int columnIndex, const QString &value)
|
||
{
|
||
if (columnIndex < m_currentTableMappings.size()) {
|
||
m_currentTableMappings[columnIndex] = value;
|
||
qDebug() << "DocumentSettingsDialog::updateTableFieldValue: Обновлено значение колонки" << columnIndex << "на" << value;
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::updateInscriptionFieldValue(int fieldNumber, const QString &value)
|
||
{
|
||
if (m_inscriptionFields.contains(fieldNumber)) {
|
||
m_inscriptionFields[fieldNumber].currentValue = value;
|
||
// Проверяем, является ли значение кастомным (не из списка параметров проекта)
|
||
bool isCustom = true;
|
||
if (m_projectParamModel) {
|
||
QMap<QString, QString> projectParams = m_projectParamModel->getDataAsMap();
|
||
isCustom = !projectParams.contains(value);
|
||
}
|
||
m_inscriptionFields[fieldNumber].isCustom = isCustom;
|
||
qDebug() << "DocumentSettingsDialog::updateInscriptionFieldValue: Обновлено значение поля" << fieldNumber << "на" << value << "isCustom:" << isCustom;
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::updateDecimalNumberFieldValue(const QString &type, const QString &value)
|
||
{
|
||
if (m_decimalNumberComboBoxes.contains(type)) {
|
||
QComboBox *comboBox = m_decimalNumberComboBoxes[type];
|
||
m_decimalNumberComboBoxes[type]->setCurrentText(value);
|
||
qDebug() << "DocumentSettingsDialog::updateDecimalNumberFieldValue: Обновлено значение децимального номера" << type << "на" << value;
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::loadDecimalNumberSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::loadDecimalNumberSettings: Загружаем настройки децимальных номеров";
|
||
|
||
if (m_controller) {
|
||
QStringList mappings;
|
||
switch (m_documentType) {
|
||
case DocumentType::SpecificationPCB:
|
||
if (m_controller->specificationPCBController()) {
|
||
mappings = m_controller->specificationPCBController()->getColumnMappings();
|
||
}
|
||
break;
|
||
case DocumentType::Specification:
|
||
if (m_controller->specificationController()) {
|
||
mappings = m_controller->specificationController()->getColumnMappings();
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
// Загружаем значения децимальных номеров и названия платы из маппингов
|
||
if (mappings.size() >= 9) { // Предполагаем, что поля находятся в позициях 6, 7 и 8
|
||
// Название платы (только для SpecificationPCB)
|
||
if (m_documentType == DocumentType::SpecificationPCB && mappings.size() > 6 && !mappings[6].isEmpty()) {
|
||
m_decimalNumberValues["boardName"] = mappings[6];
|
||
if (m_decimalNumberComboBoxes.contains("boardName")) {
|
||
int index = m_decimalNumberComboBoxes["boardName"]->findData(mappings[6]);
|
||
if (index >= 0) {
|
||
m_decimalNumberComboBoxes["boardName"]->setCurrentIndex(index);
|
||
} else {
|
||
m_decimalNumberComboBoxes["boardName"]->setCurrentText(mappings[6]);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Децимальный номер платы
|
||
if (mappings.size() > 7 && !mappings[7].isEmpty()) {
|
||
m_decimalNumberValues["board"] = mappings[7];
|
||
if (m_decimalNumberComboBoxes.contains("board")) {
|
||
int index = m_decimalNumberComboBoxes["board"]->findData(mappings[7]);
|
||
if (index >= 0) {
|
||
m_decimalNumberComboBoxes["board"]->setCurrentIndex(index);
|
||
} else {
|
||
m_decimalNumberComboBoxes["board"]->setCurrentText(mappings[7]);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Децимальный номер документа
|
||
if (mappings.size() > 8 && !mappings[8].isEmpty()) {
|
||
m_decimalNumberValues["document"] = mappings[8];
|
||
if (m_decimalNumberComboBoxes.contains("document")) {
|
||
int index = m_decimalNumberComboBoxes["document"]->findData(mappings[8]);
|
||
if (index >= 0) {
|
||
m_decimalNumberComboBoxes["document"]->setCurrentIndex(index);
|
||
} else {
|
||
m_decimalNumberComboBoxes["document"]->setCurrentText(mappings[8]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Для спецификации также загружаем значение из поля 1001 titleInscriptionsModel (децимальный номер документа)
|
||
if (m_documentType == DocumentType::Specification && m_titleInscriptionsModel && m_decimalNumberComboBoxes.contains("document")) {
|
||
QString field1001Value = m_titleInscriptionsModel->getInscriptionValue(1001);
|
||
if (!field1001Value.isEmpty()) {
|
||
QComboBox *docComboBox = m_decimalNumberComboBoxes["document"];
|
||
// Пытаемся найти значение в списке по itemData (название поля)
|
||
int index = docComboBox->findData(field1001Value);
|
||
if (index >= 0) {
|
||
docComboBox->setCurrentIndex(index);
|
||
m_decimalNumberValues["document"] = field1001Value;
|
||
} else {
|
||
// Если не найдено в списке, устанавливаем как кастомный текст
|
||
docComboBox->setCurrentText(field1001Value);
|
||
m_decimalNumberValues["document"] = field1001Value;
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::loadDecimalNumberSettings: Загружено значение документа из поля 1001:" << field1001Value;
|
||
}
|
||
}
|
||
|
||
// Для спецификации также загружаем значение "Название документа" из поля 1002 titleInscriptionsModel
|
||
if (m_documentType == DocumentType::Specification && m_titleInscriptionsModel && m_decimalNumberComboBoxes.contains("documentName")) {
|
||
QString field1002Value = m_titleInscriptionsModel->getInscriptionValue(1002);
|
||
if (!field1002Value.isEmpty()) {
|
||
QComboBox *documentNameComboBox = m_decimalNumberComboBoxes["documentName"];
|
||
// Пытаемся найти значение в списке по itemData (название поля)
|
||
int index = documentNameComboBox->findData(field1002Value);
|
||
if (index >= 0) {
|
||
documentNameComboBox->setCurrentIndex(index);
|
||
m_decimalNumberValues["documentName"] = field1002Value;
|
||
} else {
|
||
// Если не найдено в списке, устанавливаем как кастомный текст
|
||
documentNameComboBox->setCurrentText(field1002Value);
|
||
m_decimalNumberValues["documentName"] = field1002Value;
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::loadDecimalNumberSettings: Загружено значение названия документа из поля 1002:" << field1002Value;
|
||
}
|
||
}
|
||
|
||
// Для ведомости загружаем значение "Куда входит" из columnMappings[4]
|
||
if (m_documentType == DocumentType::Vedomost) {
|
||
if (m_controller->vedomostController()) {
|
||
mappings = m_controller->vedomostController()->getColumnMappings();
|
||
// Поле "WhereUsed" находится в позиции 4
|
||
if (mappings.size() > 4 && !mappings[4].isEmpty()) {
|
||
m_decimalNumberValues["whereUsed"] = mappings[4];
|
||
if (m_decimalNumberComboBoxes.contains("whereUsed")) {
|
||
QComboBox *whereUsedComboBox = m_decimalNumberComboBoxes["whereUsed"];
|
||
int index = whereUsedComboBox->findData(mappings[4]);
|
||
if (index >= 0) {
|
||
whereUsedComboBox->setCurrentIndex(index);
|
||
} else {
|
||
whereUsedComboBox->setCurrentText(mappings[4]);
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::loadDecimalNumberSettings: Загружено значение 'Куда входит':" << mappings[4];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::loadDecimalNumberSettings: Настройки децимальных номеров загружены:" << m_decimalNumberValues;
|
||
}
|
||
|
||
void DocumentSettingsDialog::saveDecimalNumberSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::saveDecimalNumberSettings: Сохраняем настройки децимальных номеров";
|
||
|
||
if (m_controller) {
|
||
QStringList mappings;
|
||
switch (m_documentType) {
|
||
case DocumentType::SpecificationPCB:
|
||
if (m_controller->specificationPCBController()) {
|
||
mappings = m_controller->specificationPCBController()->getColumnMappings();
|
||
}
|
||
break;
|
||
case DocumentType::Specification:
|
||
if (m_controller->specificationController()) {
|
||
mappings = m_controller->specificationController()->getColumnMappings();
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
// Расширяем маппинги до нужного размера
|
||
while (mappings.size() < 9) {
|
||
mappings.append("");
|
||
}
|
||
|
||
// Устанавливаем значения полей
|
||
if (m_documentType == DocumentType::SpecificationPCB) {
|
||
mappings[6] = m_decimalNumberValues.value("boardName", ""); // Название платы
|
||
}
|
||
mappings[7] = m_decimalNumberValues.value("board", ""); // Децимальный номер платы
|
||
mappings[8] = m_decimalNumberValues.value("document", ""); // Децимальный номер документа
|
||
|
||
// Сохраняем обновленные маппинги
|
||
switch (m_documentType) {
|
||
case DocumentType::SpecificationPCB:
|
||
if (m_controller->specificationPCBController()) {
|
||
m_controller->specificationPCBController()->setColumnMappings(mappings);
|
||
}
|
||
break;
|
||
case DocumentType::Specification:
|
||
if (m_controller->specificationController()) {
|
||
m_controller->specificationController()->setColumnMappings(mappings);
|
||
}
|
||
// Для спецификации сохраняем значение из docComboBox в titleInscriptionsModel с полем 1001 (децимальный номер документа)
|
||
if (m_titleInscriptionsModel && m_decimalNumberComboBoxes.contains("document")) {
|
||
QComboBox *docComboBox = m_decimalNumberComboBoxes["document"];
|
||
QString docValue = docComboBox->currentText();
|
||
|
||
// Если выбрано "-- Не выбрано --", очищаем поле
|
||
if (docValue == "-- Не выбрано --" || docValue.isEmpty()) {
|
||
m_titleInscriptionsModel->setInscriptionValue(1001, "");
|
||
} else {
|
||
// Получаем значение: если это предустановленное значение, берем itemData, иначе текст
|
||
int index = docComboBox->findText(docValue);
|
||
if (index >= 0) {
|
||
QString fieldName = docComboBox->itemData(index).toString();
|
||
if (!fieldName.isEmpty()) {
|
||
// Это предустановленное значение - сохраняем название поля
|
||
m_titleInscriptionsModel->setInscriptionValue(1001, fieldName);
|
||
} else {
|
||
// Это кастомный ввод - сохраняем текст
|
||
m_titleInscriptionsModel->setInscriptionValue(1001, docValue);
|
||
}
|
||
} else {
|
||
// Кастомный ввод - сохраняем текст
|
||
m_titleInscriptionsModel->setInscriptionValue(1001, docValue);
|
||
}
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::saveDecimalNumberSettings: Сохранено значение документа в поле 1001:" << m_titleInscriptionsModel->getInscriptionValue(1001);
|
||
}
|
||
|
||
// Для спецификации сохраняем значение "Название документа" из documentNameComboBox в titleInscriptionsModel с полем 1002
|
||
if (m_titleInscriptionsModel && m_decimalNumberComboBoxes.contains("documentName")) {
|
||
QComboBox *documentNameComboBox = m_decimalNumberComboBoxes["documentName"];
|
||
QString documentNameValue = documentNameComboBox->currentText();
|
||
|
||
// Если выбрано "-- Не выбрано --", очищаем поле
|
||
if (documentNameValue == "-- Не выбрано --" || documentNameValue.isEmpty()) {
|
||
m_titleInscriptionsModel->setInscriptionValue(1002, "");
|
||
} else {
|
||
// Получаем значение: если это предустановленное значение, берем itemData, иначе текст
|
||
int index = documentNameComboBox->findText(documentNameValue);
|
||
if (index >= 0) {
|
||
QString fieldName = documentNameComboBox->itemData(index).toString();
|
||
if (!fieldName.isEmpty()) {
|
||
// Это предустановленное значение - сохраняем название поля
|
||
m_titleInscriptionsModel->setInscriptionValue(1002, fieldName);
|
||
} else {
|
||
// Это кастомный ввод - сохраняем текст
|
||
m_titleInscriptionsModel->setInscriptionValue(1002, documentNameValue);
|
||
}
|
||
} else {
|
||
// Кастомный ввод - сохраняем текст
|
||
m_titleInscriptionsModel->setInscriptionValue(1002, documentNameValue);
|
||
}
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::saveDecimalNumberSettings: Сохранено значение названия документа в поле 1002:" << m_titleInscriptionsModel->getInscriptionValue(1002);
|
||
}
|
||
break;
|
||
case DocumentType::Vedomost:
|
||
// Для ведомости сохраняем значение "Куда входит" в columnMappings[4]
|
||
if (m_controller->vedomostController()) {
|
||
mappings = m_controller->vedomostController()->getColumnMappings();
|
||
// Расширяем маппинги до нужного размера
|
||
while (mappings.size() < 5) {
|
||
mappings.append("");
|
||
}
|
||
// Устанавливаем значение "Куда входит" в позицию 4
|
||
if (m_decimalNumberComboBoxes.contains("whereUsed")) {
|
||
QComboBox *whereUsedComboBox = m_decimalNumberComboBoxes["whereUsed"];
|
||
QString whereUsedValue = whereUsedComboBox->currentText();
|
||
|
||
// Если выбрано "-- Не выбрано --", очищаем поле
|
||
if (whereUsedValue == "-- Не выбрано --" || whereUsedValue.isEmpty()) {
|
||
mappings[4] = "";
|
||
} else {
|
||
// Получаем значение: если это предустановленное значение, берем itemData, иначе текст
|
||
int index = whereUsedComboBox->findText(whereUsedValue);
|
||
if (index >= 0) {
|
||
QString fieldName = whereUsedComboBox->itemData(index).toString();
|
||
if (!fieldName.isEmpty()) {
|
||
// Это предустановленное значение - сохраняем название поля
|
||
mappings[4] = fieldName;
|
||
} else {
|
||
// Это кастомный ввод - сохраняем текст
|
||
mappings[4] = whereUsedValue;
|
||
}
|
||
} else {
|
||
// Кастомный ввод - сохраняем текст
|
||
mappings[4] = whereUsedValue;
|
||
}
|
||
}
|
||
}
|
||
m_controller->vedomostController()->setColumnMappings(mappings);
|
||
qDebug() << "DocumentSettingsDialog::saveDecimalNumberSettings: Сохранено значение 'Куда входит':" << mappings[4];
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::saveDecimalNumberSettings: Настройки децимальных номеров сохранены:" << m_decimalNumberValues;
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::loadPrimaryApplicationSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::loadPrimaryApplicationSettings: Загружаем настройки 'Первичное применение'";
|
||
|
||
if (!m_primaryApplicationComboBox || m_primaryApplicationFieldNumber == 0) {
|
||
qDebug() << "DocumentSettingsDialog::loadPrimaryApplicationSettings: Поле 'Первичное применение' не создано";
|
||
return;
|
||
}
|
||
|
||
// Загружаем значение из titleInscriptionsModel
|
||
if (m_titleInscriptionsModel) {
|
||
QString value = m_titleInscriptionsModel->getInscriptionValue(m_primaryApplicationFieldNumber);
|
||
if (!value.isEmpty()) {
|
||
// Пытаемся найти значение в списке по itemData (название поля)
|
||
int index = m_primaryApplicationComboBox->findData(value);
|
||
if (index >= 0) {
|
||
m_primaryApplicationComboBox->setCurrentIndex(index);
|
||
} else {
|
||
// Если не найдено в списке, устанавливаем как кастомный текст
|
||
m_primaryApplicationComboBox->setCurrentText(value);
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::loadPrimaryApplicationSettings: Загружено значение из поля" << m_primaryApplicationFieldNumber << ":" << value;
|
||
} else {
|
||
// Если значение пустое, устанавливаем "-- Не выбрано --"
|
||
m_primaryApplicationComboBox->setCurrentIndex(0);
|
||
}
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::savePrimaryApplicationSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::savePrimaryApplicationSettings: Сохраняем настройки 'Первичное применение'";
|
||
|
||
if (!m_primaryApplicationComboBox || m_primaryApplicationFieldNumber == 0) {
|
||
qDebug() << "DocumentSettingsDialog::savePrimaryApplicationSettings: Поле 'Первичное применение' не создано";
|
||
return;
|
||
}
|
||
|
||
QString value = m_primaryApplicationComboBox->currentText();
|
||
|
||
// Если выбрано "-- Не выбрано --", очищаем поле
|
||
if (value == "-- Не выбрано --" || value.isEmpty()) {
|
||
if (m_titleInscriptionsModel) {
|
||
m_titleInscriptionsModel->setInscriptionValue(m_primaryApplicationFieldNumber, "");
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::savePrimaryApplicationSettings: Очищено поле" << m_primaryApplicationFieldNumber;
|
||
} else {
|
||
// Получаем значение: если это предустановленное значение, берем itemData, иначе текст
|
||
int index = m_primaryApplicationComboBox->findText(value);
|
||
if (index >= 0) {
|
||
QString fieldName = m_primaryApplicationComboBox->itemData(index).toString();
|
||
if (!fieldName.isEmpty()) {
|
||
// Это предустановленное значение - сохраняем название поля
|
||
if (m_titleInscriptionsModel) {
|
||
m_titleInscriptionsModel->setInscriptionValue(m_primaryApplicationFieldNumber, fieldName);
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::savePrimaryApplicationSettings: Сохранено предустановленное значение в поле" << m_primaryApplicationFieldNumber << ":" << fieldName;
|
||
} else {
|
||
// Это кастомный ввод - сохраняем текст
|
||
if (m_titleInscriptionsModel) {
|
||
m_titleInscriptionsModel->setInscriptionValue(m_primaryApplicationFieldNumber, value);
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::savePrimaryApplicationSettings: Сохранено кастомное значение в поле" << m_primaryApplicationFieldNumber << ":" << value;
|
||
}
|
||
} else {
|
||
// Кастомный ввод - сохраняем текст
|
||
if (m_titleInscriptionsModel) {
|
||
m_titleInscriptionsModel->setInscriptionValue(m_primaryApplicationFieldNumber, value);
|
||
}
|
||
qDebug() << "DocumentSettingsDialog::savePrimaryApplicationSettings: Сохранено кастомное значение в поле" << m_primaryApplicationFieldNumber << ":" << value;
|
||
}
|
||
|
||
// Сохраняем в базу данных через контроллер
|
||
// Сохраняем все надписи из модели, как это делают остальные поля
|
||
if (m_controller && m_titleInscriptionsModel) {
|
||
QMap<int, QString> allInscriptions = m_titleInscriptionsModel->getAllInscriptions();
|
||
m_controller->saveTitleInscriptionsToDatabase(allInscriptions);
|
||
qDebug() << "DocumentSettingsDialog::savePrimaryApplicationSettings: Сохранены все надписи из модели, включая поле" << m_primaryApplicationFieldNumber;
|
||
}
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::onPrimaryApplicationComboBoxChanged(int fieldNumber, const QString &value)
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::onPrimaryApplicationComboBoxChanged: Изменено значение поля" << fieldNumber << "на" << value;
|
||
|
||
// Обновляем значение в модели (но не сохраняем в базу данных до нажатия ОК)
|
||
if (m_titleInscriptionsModel) {
|
||
if (value == "-- Не выбрано --" || value.isEmpty()) {
|
||
m_titleInscriptionsModel->setInscriptionValue(fieldNumber, "");
|
||
} else {
|
||
// Получаем значение: если это предустановленное значение, берем itemData, иначе текст
|
||
if (m_primaryApplicationComboBox) {
|
||
int index = m_primaryApplicationComboBox->findText(value);
|
||
if (index >= 0) {
|
||
QString fieldName = m_primaryApplicationComboBox->itemData(index).toString();
|
||
if (!fieldName.isEmpty()) {
|
||
// Это предустановленное значение - сохраняем название поля
|
||
m_titleInscriptionsModel->setInscriptionValue(fieldNumber, fieldName);
|
||
} else {
|
||
// Это кастомный ввод - сохраняем текст
|
||
m_titleInscriptionsModel->setInscriptionValue(fieldNumber, value);
|
||
}
|
||
} else {
|
||
// Кастомный ввод - сохраняем текст
|
||
m_titleInscriptionsModel->setInscriptionValue(fieldNumber, value);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Публичные методы
|
||
QStringList DocumentSettingsDialog::getTableColumnMappings() const
|
||
{
|
||
return m_currentTableMappings;
|
||
}
|
||
|
||
void DocumentSettingsDialog::setTableColumnMappings(const QStringList &mappings)
|
||
{
|
||
m_currentTableMappings = mappings;
|
||
loadTableSettings();
|
||
}
|
||
|
||
QMap<int, QString> DocumentSettingsDialog::getTitleInscriptionValues() const
|
||
{
|
||
QMap<int, QString> values;
|
||
for (auto it = m_inscriptionFields.begin(); it != m_inscriptionFields.end(); ++it) {
|
||
if (!it.value().currentValue.isEmpty()) {
|
||
values[it.key()] = it.value().currentValue;
|
||
}
|
||
}
|
||
return values;
|
||
}
|
||
|
||
void DocumentSettingsDialog::setTitleInscriptionValues(const QMap<int, QString> &values)
|
||
{
|
||
for (auto it = values.begin(); it != values.end(); ++it) {
|
||
if (m_inscriptionFields.contains(it.key())) {
|
||
m_inscriptionFields[it.key()].currentValue = it.value();
|
||
}
|
||
}
|
||
loadInscriptionSettings();
|
||
}
|
||
|
||
void DocumentSettingsDialog::setTitleInscriptionsModel(TitleInscriptionsModel *model)
|
||
{
|
||
m_titleInscriptionsModel = model;
|
||
loadInscriptionSettings();
|
||
}
|
||
|
||
TitleInscriptionsModel* DocumentSettingsDialog::getTitleInscriptionsModel() const
|
||
{
|
||
return m_titleInscriptionsModel;
|
||
}
|
||
|
||
// Методы для работы с децимальными номерами
|
||
QMap<QString, QString> DocumentSettingsDialog::getDecimalNumberValues() const
|
||
{
|
||
return m_decimalNumberValues;
|
||
}
|
||
|
||
void DocumentSettingsDialog::setDecimalNumberValues(const QMap<QString, QString> &values)
|
||
{
|
||
m_decimalNumberValues = values;
|
||
if (m_documentType == DocumentType::SpecificationPCB || m_documentType == DocumentType::Specification) {
|
||
loadDecimalNumberSettings();
|
||
}
|
||
if (m_documentType == DocumentType::Vedomost) {
|
||
loadDecimalNumberSettings();
|
||
}
|
||
}
|
||
|
||
void DocumentSettingsDialog::createSimpleListSettingsFields()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::createSimpleListSettingsFields: Создаем поля настроек SimpleList";
|
||
|
||
// Создаем группу для настроек SimpleList
|
||
QGroupBox *simpleListGroup = new QGroupBox("Настройки списка", m_tableScrollContent);
|
||
QGridLayout *simpleListLayout = new QGridLayout(simpleListGroup);
|
||
|
||
// Поле "Наименование"
|
||
QLabel *nameFieldLabel = new QLabel("Поле для наименования:", simpleListGroup);
|
||
simpleListLayout->addWidget(nameFieldLabel, 0, 0);
|
||
|
||
m_simpleListNameFieldComboBox = new QComboBox(simpleListGroup);
|
||
m_simpleListNameFieldComboBox->addItem("-- Не выбрано --", "");
|
||
|
||
// Добавляем доступные свойства из контроллера
|
||
if (m_controller && m_controller->simpleListTableController()) {
|
||
QStringList availableProperties = m_controller->simpleListTableController()->getAvailableProperties();
|
||
for (const QString &property : availableProperties) {
|
||
m_simpleListNameFieldComboBox->addItem(property, property);
|
||
}
|
||
}
|
||
|
||
simpleListLayout->addWidget(m_simpleListNameFieldComboBox, 0, 1);
|
||
|
||
// Поле "Технический запас"
|
||
QLabel *techReserveLabel = new QLabel("Технический запас (%):", simpleListGroup);
|
||
simpleListLayout->addWidget(techReserveLabel, 1, 0);
|
||
|
||
m_simpleListTechReserveSpinBox = new QSpinBox(simpleListGroup);
|
||
m_simpleListTechReserveSpinBox->setRange(0, 100);
|
||
m_simpleListTechReserveSpinBox->setValue(10);
|
||
m_simpleListTechReserveSpinBox->setSuffix("%");
|
||
simpleListLayout->addWidget(m_simpleListTechReserveSpinBox, 1, 1);
|
||
|
||
// Поле "Кол-во плат"
|
||
QLabel *boardsCountLabel = new QLabel("Кол-во плат:", simpleListGroup);
|
||
simpleListLayout->addWidget(boardsCountLabel, 2, 0);
|
||
m_simpleListBoardsCountSpinBox = new QSpinBox(simpleListGroup);
|
||
m_simpleListBoardsCountSpinBox->setRange(1, 9999);
|
||
m_simpleListBoardsCountSpinBox->setValue(1);
|
||
simpleListLayout->addWidget(m_simpleListBoardsCountSpinBox, 2, 1);
|
||
|
||
// Добавляем группу в основную компоновку таблицы
|
||
QGridLayout *mainGridLayout = qobject_cast<QGridLayout*>(m_tableScrollContent->layout());
|
||
if (mainGridLayout) {
|
||
int row = mainGridLayout->rowCount();
|
||
mainGridLayout->addWidget(simpleListGroup, row, 0, 1, 2);
|
||
} else {
|
||
// Если основная компоновка не является QGridLayout, создаем новую
|
||
QVBoxLayout *mainLayout = new QVBoxLayout(m_tableScrollContent);
|
||
mainLayout->addWidget(simpleListGroup);
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::createSimpleListSettingsFields: Поля настроек SimpleList созданы";
|
||
}
|
||
|
||
void DocumentSettingsDialog::loadSimpleListSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::loadSimpleListSettings: Загружаем настройки SimpleList";
|
||
|
||
if (!m_controller || !m_controller->simpleListTableController()) {
|
||
qDebug() << "DocumentSettingsDialog::loadSimpleListSettings: Контроллер недоступен";
|
||
return;
|
||
}
|
||
|
||
SimpleListTableController *controller = m_controller->simpleListTableController();
|
||
|
||
// Загружаем поле наименования
|
||
QString nameField = controller->getNameField();
|
||
if (m_simpleListNameFieldComboBox) {
|
||
int index = m_simpleListNameFieldComboBox->findData(nameField);
|
||
if (index >= 0) {
|
||
m_simpleListNameFieldComboBox->setCurrentIndex(index);
|
||
} else {
|
||
// Если значение не найдено, устанавливаем по умолчанию "Name"
|
||
index = m_simpleListNameFieldComboBox->findData("Name");
|
||
if (index >= 0) {
|
||
m_simpleListNameFieldComboBox->setCurrentIndex(index);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Загружаем процент тех запаса
|
||
int techReservePercent = controller->getTechReservePercent();
|
||
if (m_simpleListTechReserveSpinBox) {
|
||
m_simpleListTechReserveSpinBox->setValue(techReservePercent);
|
||
}
|
||
|
||
// Загружаем кол-во плат
|
||
if (m_simpleListBoardsCountSpinBox) {
|
||
m_simpleListBoardsCountSpinBox->setValue(controller->getBoardsCount());
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::loadSimpleListSettings: Настройки загружены - поле:" << nameField << "тех.запас:" << techReservePercent << "кол-во плат:" << controller->getBoardsCount();
|
||
}
|
||
|
||
void DocumentSettingsDialog::saveSimpleListSettings()
|
||
{
|
||
qDebug() << "DocumentSettingsDialog::saveSimpleListSettings: Сохраняем настройки SimpleList";
|
||
|
||
if (!m_controller || !m_controller->simpleListTableController()) {
|
||
qDebug() << "DocumentSettingsDialog::saveSimpleListSettings: Контроллер недоступен";
|
||
return;
|
||
}
|
||
|
||
SimpleListTableController *controller = m_controller->simpleListTableController();
|
||
|
||
// Сохраняем поле наименования
|
||
if (m_simpleListNameFieldComboBox) {
|
||
QString nameField = m_simpleListNameFieldComboBox->currentData().toString();
|
||
if (nameField.isEmpty()) {
|
||
nameField = m_simpleListNameFieldComboBox->currentText();
|
||
if (nameField == "-- Не выбрано --") {
|
||
nameField = "Name"; // Значение по умолчанию
|
||
}
|
||
}
|
||
controller->setNameField(nameField);
|
||
qDebug() << "DocumentSettingsDialog::saveSimpleListSettings: Сохранено поле наименования:" << nameField;
|
||
}
|
||
|
||
// Сохраняем процент тех запаса
|
||
if (m_simpleListTechReserveSpinBox) {
|
||
int techReservePercent = m_simpleListTechReserveSpinBox->value();
|
||
controller->setTechReservePercent(techReservePercent);
|
||
qDebug() << "DocumentSettingsDialog::saveSimpleListSettings: Сохранен процент тех запаса:" << techReservePercent;
|
||
}
|
||
|
||
// Сохраняем кол-во плат
|
||
if (m_simpleListBoardsCountSpinBox) {
|
||
int boardsCount = m_simpleListBoardsCountSpinBox->value();
|
||
controller->setBoardsCount(boardsCount);
|
||
qDebug() << "DocumentSettingsDialog::saveSimpleListSettings: Сохранено кол-во плат:" << boardsCount;
|
||
}
|
||
|
||
qDebug() << "DocumentSettingsDialog::saveSimpleListSettings: Настройки SimpleList сохранены";
|
||
}
|