added web service
This commit is contained in:
+165
-3
@@ -618,6 +618,109 @@ void VedomostProcessor::setModel(VedomostTableModel *model)
|
||||
}
|
||||
}
|
||||
|
||||
// SimpleListProcessor
|
||||
SimpleListProcessor::SimpleListProcessor(QObject *parent)
|
||||
: DocumentProcessor(parent)
|
||||
, m_controller(new SimpleListTableController(this))
|
||||
{
|
||||
}
|
||||
|
||||
SimpleListProcessor::~SimpleListProcessor()
|
||||
{
|
||||
// m_controller удалится автоматически, так как он является дочерним объектом
|
||||
}
|
||||
|
||||
void SimpleListProcessor::processComponents(const QList<ComponentModel*> &components)
|
||||
{
|
||||
qDebug() << "SimpleListProcessor::processComponents: Получено" << components.size() << "компонентов";
|
||||
// Передаем компоненты в контроллер
|
||||
if (m_controller) {
|
||||
m_controller->setComponents(components);
|
||||
qDebug() << "SimpleListProcessor::processComponents: Компоненты переданы в контроллер";
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleListProcessor::processProjectParams(const QMap<QString, QString> ¶ms)
|
||||
{
|
||||
qDebug() << "SimpleListProcessor::processProjectParams: Получено" << params.size() << "параметров";
|
||||
// Пока не используем параметры проекта
|
||||
}
|
||||
|
||||
QTableView* SimpleListProcessor::createTableView()
|
||||
{
|
||||
QTableView *tableView = new QTableView();
|
||||
if (m_controller) {
|
||||
tableView->setModel(m_controller->getTableModel());
|
||||
|
||||
// Настройка растягивания столбцов
|
||||
QHeaderView *horizontalHeader = tableView->horizontalHeader();
|
||||
horizontalHeader->setStretchLastSection(false);
|
||||
|
||||
// Устанавливаем режимы для каждого столбца
|
||||
horizontalHeader->setSectionResizeMode(0, QHeaderView::Interactive); // Поз.обозначение
|
||||
horizontalHeader->setSectionResizeMode(1, QHeaderView::Interactive); // Наименование
|
||||
horizontalHeader->setSectionResizeMode(2, QHeaderView::Interactive); // Количество
|
||||
|
||||
// Устанавливаем начальные размеры для столбцов
|
||||
horizontalHeader->resizeSection(0, 150); // Поз.обозначение
|
||||
horizontalHeader->resizeSection(1, 300); // Наименование
|
||||
horizontalHeader->resizeSection(2, 80); // Количество
|
||||
|
||||
// Настройка вертикального заголовка
|
||||
QHeaderView *verticalHeader = tableView->verticalHeader();
|
||||
verticalHeader->setDefaultSectionSize(25);
|
||||
verticalHeader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
qDebug() << "SimpleListProcessor::createTableView: Настроено растягивание столбцов";
|
||||
} else {
|
||||
// Если контроллер не установлен, создаем временную модель
|
||||
QStandardItemModel *tempModel = new QStandardItemModel(tableView);
|
||||
QStringList headers;
|
||||
headers << "Поз.обозначение" << "Наименование" << "Кол.";
|
||||
tempModel->setHorizontalHeaderLabels(headers);
|
||||
tableView->setModel(tempModel);
|
||||
|
||||
// Настройка столбцов
|
||||
QHeaderView *horizontalHeader = tableView->horizontalHeader();
|
||||
horizontalHeader->setStretchLastSection(false);
|
||||
horizontalHeader->setSectionResizeMode(0, QHeaderView::Interactive);
|
||||
horizontalHeader->setSectionResizeMode(1, QHeaderView::Interactive);
|
||||
horizontalHeader->setSectionResizeMode(2, QHeaderView::Interactive);
|
||||
horizontalHeader->resizeSection(0, 150);
|
||||
horizontalHeader->resizeSection(1, 300);
|
||||
horizontalHeader->resizeSection(2, 80);
|
||||
|
||||
QHeaderView *verticalHeader = tableView->verticalHeader();
|
||||
verticalHeader->setDefaultSectionSize(25);
|
||||
verticalHeader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
qDebug() << "SimpleListProcessor::createTableView: Создана временная модель";
|
||||
}
|
||||
return tableView;
|
||||
}
|
||||
|
||||
void SimpleListProcessor::updateTable()
|
||||
{
|
||||
qDebug() << "SimpleListProcessor::updateTable: Обновляем таблицу";
|
||||
if (m_controller) {
|
||||
m_controller->updateTableFromComponents();
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleListProcessor::setController(SimpleListTableController *controller)
|
||||
{
|
||||
qDebug() << "SimpleListProcessor::setController: Устанавливаем контроллер";
|
||||
m_controller = controller;
|
||||
}
|
||||
|
||||
void SimpleListProcessor::setModel(SimpleListTableModel *model)
|
||||
{
|
||||
qDebug() << "SimpleListProcessor::setModel: Модель установлена в контроллер";
|
||||
if (m_controller) {
|
||||
m_controller->setModel(model);
|
||||
}
|
||||
}
|
||||
|
||||
// DocumentEditWidget
|
||||
DocumentEditWidget::DocumentEditWidget(DocumentProcessor *processor, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@@ -759,6 +862,8 @@ void DocumentEditWidget::onOpenColumnSettings()
|
||||
docType = DocumentType::Specification;
|
||||
} else if (qobject_cast<VedomostProcessor*>(m_processor)) {
|
||||
docType = DocumentType::Vedomost;
|
||||
} else if (qobject_cast<SimpleListProcessor*>(m_processor)) {
|
||||
docType = DocumentType::SimpleList;
|
||||
} else {
|
||||
qDebug() << "DocumentEditWidget::onOpenColumnSettings: Процессор не поддерживает настройки";
|
||||
return;
|
||||
@@ -774,7 +879,13 @@ void DocumentEditWidget::onOpenColumnSettings()
|
||||
qDebug() << "DocumentEditWidget::onOpenColumnSettings: Получены настройки таблицы:" << newTableMappings;
|
||||
qDebug() << "DocumentEditWidget::onOpenColumnSettings: Получены настройки надписей:" << newInscriptionValues;
|
||||
|
||||
// Настройки таблицы и надписей уже сохранены в диалоге
|
||||
// Настройки таблицы и надписей уже сохранены в диалоге в контроллер
|
||||
// Сохраняем настройки в БД
|
||||
if (m_controller) {
|
||||
m_controller->saveProjectSettingsToDatabase();
|
||||
qDebug() << "DocumentEditWidget::onOpenColumnSettings: Настройки сохранены в БД";
|
||||
}
|
||||
|
||||
qDebug() << "DocumentEditWidget::onOpenColumnSettings: Настройки обновлены, но таблица не генерируется автоматически";
|
||||
} else {
|
||||
qDebug() << "DocumentEditWidget::onOpenColumnSettings: Диалог настроек отменен";
|
||||
@@ -887,7 +998,45 @@ void DocumentEditWidget::onGenerateTable()
|
||||
qDebug() << "DocumentEditWidget::onGenerateTable: VedomostController недоступен";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "DocumentEditWidget::onGenerateTable: Процессор не является PerechenProcessor, SpecificationPCBProcessor, SpecificationProcessor или VedomostProcessor";
|
||||
// Проверяем, является ли процессор SimpleListProcessor
|
||||
SimpleListProcessor *simpleListProcessor = qobject_cast<SimpleListProcessor*>(m_processor);
|
||||
if (simpleListProcessor) {
|
||||
if (m_controller && m_controller->simpleListTableController()) {
|
||||
qDebug() << "DocumentEditWidget::onGenerateTable: Генерируем таблицу через SimpleListTableController из SpecificationPCB";
|
||||
|
||||
// Генерируем таблицу бланка заказа на основе SpecificationPCB
|
||||
SpecificationPCBTableModel *specPCBModel = m_controller->specificationPCBTableModel();
|
||||
if (specPCBModel && specPCBModel->rowCount() > 0) {
|
||||
// Если SpecificationPCB уже сгенерирована, используем её
|
||||
m_controller->simpleListTableController()->generateTableFromSpecificationPCB(specPCBModel);
|
||||
} else {
|
||||
// Если SpecificationPCB не сгенерирована, сначала генерируем её
|
||||
qDebug() << "DocumentEditWidget::onGenerateTable: SpecificationPCB не сгенерирована, генерируем её";
|
||||
if (m_controller->specificationPCBController() && m_componentModel) {
|
||||
m_controller->specificationPCBController()->setComponents(m_componentModel->getComponents());
|
||||
m_controller->specificationPCBController()->generateTableFromComponents();
|
||||
|
||||
// Теперь используем сгенерированную SpecificationPCB
|
||||
specPCBModel = m_controller->specificationPCBTableModel();
|
||||
if (specPCBModel) {
|
||||
m_controller->simpleListTableController()->generateTableFromSpecificationPCB(specPCBModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Устанавливаем модель из контроллера
|
||||
if (m_controller->simpleListTableModel()) {
|
||||
m_tableView->setModel(m_controller->simpleListTableModel());
|
||||
applyColumnStretching();
|
||||
setupSelectionConnection();
|
||||
qDebug() << "DocumentEditWidget::onGenerateTable: Модель SimpleListTableModel установлена";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "DocumentEditWidget::onGenerateTable: SimpleListTableController недоступен";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "DocumentEditWidget::onGenerateTable: Процессор не является PerechenProcessor, SpecificationPCBProcessor, SpecificationProcessor, VedomostProcessor или SimpleListProcessor";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -970,7 +1119,20 @@ void DocumentEditWidget::onRecalculateTable()
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "DocumentEditWidget::onRecalculateTable: Процессор не является PerechenProcessor, SpecificationPCBProcessor, SpecificationProcessor или VedomostProcessor";
|
||||
// Проверяем, является ли процессор SimpleListProcessor
|
||||
SimpleListProcessor *simpleListProcessor = qobject_cast<SimpleListProcessor*>(m_processor);
|
||||
if (simpleListProcessor) {
|
||||
if (m_controller && m_controller->simpleListTableController()) {
|
||||
qDebug() << "DocumentEditWidget::onRecalculateTable: Пересчитываем таблицу SimpleListTableModel";
|
||||
m_controller->simpleListTableController()->updateTableFromComponents();
|
||||
qDebug() << "DocumentEditWidget::onRecalculateTable: Пересчет SimpleListTableModel завершен";
|
||||
} else {
|
||||
qDebug() << "DocumentEditWidget::onRecalculateTable: SimpleListTableController недоступен";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "DocumentEditWidget::onRecalculateTable: Процессор не является PerechenProcessor, SpecificationPCBProcessor, SpecificationProcessor, VedomostProcessor или SimpleListProcessor";
|
||||
}
|
||||
|
||||
void DocumentEditWidget::setData(ComponentTableModel *componentModel, ProjectParamTableModel *projectParamModel)
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "../controller/specificationpcbcontroller.h"
|
||||
#include "../controller/specificationcontroller.h"
|
||||
#include "../controller/vedomostcontroller.h"
|
||||
#include "../model/simplelisttablemodel.h"
|
||||
#include "../controller/simplelisttablecontroller.h"
|
||||
#include "documentsettingsdialog.h"
|
||||
#include "../model/titleinscriptionsmodel.h"
|
||||
|
||||
@@ -176,6 +178,33 @@ private:
|
||||
VedomostController *m_controller;
|
||||
};
|
||||
|
||||
class SimpleListProcessor : public DocumentProcessor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SimpleListProcessor(QObject *parent = nullptr);
|
||||
~SimpleListProcessor();
|
||||
|
||||
void processComponents(const QList<ComponentModel*> &components) override;
|
||||
void processProjectParams(const QMap<QString, QString> ¶ms) override;
|
||||
QTableView* createTableView() override;
|
||||
|
||||
// Метод для обновления таблицы по кнопке
|
||||
void updateTable();
|
||||
|
||||
// Метод для получения контроллера
|
||||
SimpleListTableController* getController() const { return m_controller; }
|
||||
|
||||
// Метод для установки контроллера (для интеграции с MainController)
|
||||
void setController(SimpleListTableController *controller);
|
||||
|
||||
// Метод для установки модели (для интеграции с MainController)
|
||||
void setModel(SimpleListTableModel *model);
|
||||
|
||||
private:
|
||||
SimpleListTableController *m_controller;
|
||||
};
|
||||
|
||||
// Универсальный виджет для работы с документами
|
||||
class DocumentEditWidget : public QWidget
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../controller/specificationpcbcontroller.h"
|
||||
#include "../controller/specificationcontroller.h"
|
||||
#include "../controller/vedomostcontroller.h"
|
||||
#include "../controller/simplelisttablecontroller.h"
|
||||
#include "../model/componenttablemodel.h"
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
@@ -83,6 +84,9 @@ DocumentSettingsDialog::DocumentSettingsDialog(DocumentType docType, MainControl
|
||||
, m_titleInscriptionsModel(nullptr)
|
||||
, m_primaryApplicationComboBox(nullptr)
|
||||
, m_primaryApplicationFieldNumber(0)
|
||||
, m_simpleListNameFieldComboBox(nullptr)
|
||||
, m_simpleListTechReserveSpinBox(nullptr)
|
||||
, m_simpleListBoardsCountSpinBox(nullptr)
|
||||
{
|
||||
qDebug() << "DocumentSettingsDialog: Конструктор для типа документа:" << static_cast<int>(docType);
|
||||
|
||||
@@ -127,6 +131,11 @@ void DocumentSettingsDialog::setUp()
|
||||
// Загружаем настройки "Первичное применение" для всех типов документов
|
||||
loadPrimaryApplicationSettings();
|
||||
|
||||
// Загружаем настройки SimpleList
|
||||
if (m_documentType == DocumentType::SimpleList) {
|
||||
loadSimpleListSettings();
|
||||
}
|
||||
|
||||
qDebug() << "DocumentSettingsDialog::setUp: Настройка диалога завершена";
|
||||
}
|
||||
|
||||
@@ -183,6 +192,11 @@ void DocumentSettingsDialog::createTableSettingsTab()
|
||||
createWhereUsedField();
|
||||
}
|
||||
|
||||
// Создаем поля настроек для SimpleList
|
||||
if (m_documentType == DocumentType::SimpleList) {
|
||||
createSimpleListSettingsFields();
|
||||
}
|
||||
|
||||
// Создаем поля для размера шрифта и поджима
|
||||
createFontSettingsFields();
|
||||
|
||||
@@ -991,6 +1005,10 @@ void DocumentSettingsDialog::loadTableSettings()
|
||||
qDebug() << "DocumentSettingsDialog::loadTableSettings: VedomostController недоступен";
|
||||
}
|
||||
break;
|
||||
case DocumentType::SimpleList:
|
||||
// Для SimpleList настройки колонок не используются
|
||||
qDebug() << "DocumentSettingsDialog::loadTableSettings: SimpleList - настройки колонок не требуются";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "DocumentSettingsDialog::loadTableSettings: Контроллер недоступен";
|
||||
@@ -1100,6 +1118,9 @@ void DocumentSettingsDialog::loadFontSettings()
|
||||
fontStretch = m_controller->vedomostController()->getFontStretch();
|
||||
}
|
||||
break;
|
||||
case DocumentType::SimpleList:
|
||||
// Для SimpleList настройки шрифта не используются
|
||||
break;
|
||||
}
|
||||
|
||||
m_fontSizeSpinBox->setValue(fontSize);
|
||||
@@ -1146,6 +1167,9 @@ void DocumentSettingsDialog::saveFontSettings()
|
||||
m_controller->vedomostController()->setFontStretch(fontStretch);
|
||||
}
|
||||
break;
|
||||
case DocumentType::SimpleList:
|
||||
// Для SimpleList настройки шрифта не используются
|
||||
break;
|
||||
}
|
||||
|
||||
// Сохраняем в БД
|
||||
@@ -1235,6 +1259,10 @@ void DocumentSettingsDialog::saveTableSettings()
|
||||
qDebug() << "DocumentSettingsDialog::saveTableSettings: VedomostController недоступен";
|
||||
}
|
||||
break;
|
||||
case DocumentType::SimpleList:
|
||||
// Для SimpleList настройки колонок не используются
|
||||
qDebug() << "DocumentSettingsDialog::saveTableSettings: SimpleList - настройки колонок не требуются";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "DocumentSettingsDialog::saveTableSettings: Контроллер недоступен";
|
||||
@@ -1371,6 +1399,11 @@ void DocumentSettingsDialog::onAccept()
|
||||
// Сохраняем настройки "Первичное применение" для всех типов документов
|
||||
savePrimaryApplicationSettings();
|
||||
|
||||
// Сохраняем настройки SimpleList
|
||||
if (m_documentType == DocumentType::SimpleList) {
|
||||
saveSimpleListSettings();
|
||||
}
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
@@ -1896,3 +1929,141 @@ void DocumentSettingsDialog::setDecimalNumberValues(const QMap<QString, QString>
|
||||
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 сохранены";
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ enum class DocumentType {
|
||||
Perechen, // Перечень элементов
|
||||
SpecificationPCB, // Спецификация ПП
|
||||
Specification, // Спецификация материалов
|
||||
Vedomost // Ведомость покупных изделий
|
||||
Vedomost, // Ведомость покупных изделий
|
||||
SimpleList // Список элементов для экспорта
|
||||
};
|
||||
|
||||
class DocumentSettingsDialog : public QDialog
|
||||
@@ -160,6 +161,16 @@ private:
|
||||
void createFontSettingsFields();
|
||||
void loadFontSettings();
|
||||
void saveFontSettings();
|
||||
|
||||
// Методы для работы с настройками SimpleList
|
||||
void createSimpleListSettingsFields();
|
||||
void loadSimpleListSettings();
|
||||
void saveSimpleListSettings();
|
||||
|
||||
// Виджеты для настроек SimpleList
|
||||
QComboBox *m_simpleListNameFieldComboBox;
|
||||
QSpinBox *m_simpleListTechReserveSpinBox;
|
||||
QSpinBox *m_simpleListBoardsCountSpinBox;
|
||||
};
|
||||
|
||||
#endif // DOCUMENTSETTINGSDIALOG_H
|
||||
|
||||
@@ -36,6 +36,7 @@ void EditPDFWidget::setWidgets(){
|
||||
m_specificationProcessor = new SpecificationProcessor(this);
|
||||
m_specificationPCBProcessor = new SpecificationPCBProcessor(this);
|
||||
m_vedomostProcessor = new VedomostProcessor(this);
|
||||
m_simpleListProcessor = new SimpleListProcessor(this);
|
||||
|
||||
// Устанавливаем PerechenTableController из MainController в PerechenProcessor
|
||||
if (m_controller && m_perechenProcessor) {
|
||||
@@ -106,6 +107,21 @@ void EditPDFWidget::setWidgets(){
|
||||
}
|
||||
}
|
||||
|
||||
// Устанавливаем SimpleListTableController из MainController в SimpleListProcessor
|
||||
if (m_controller && m_simpleListProcessor) {
|
||||
SimpleListTableController *simpleListController = m_controller->simpleListTableController();
|
||||
if (simpleListController) {
|
||||
qDebug() << "EditPDFWidget::setWidgets: Используем SimpleListTableController из MainController";
|
||||
m_simpleListProcessor->setController(simpleListController);
|
||||
|
||||
SimpleListTableModel *simpleListModel = m_controller->simpleListTableModel();
|
||||
if (simpleListModel) {
|
||||
qDebug() << "EditPDFWidget::setWidgets: Устанавливаем SimpleListTableModel из MainController в SimpleListProcessor";
|
||||
m_simpleListProcessor->setModel(simpleListModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Создаем виджеты документов с соответствующими процессорами
|
||||
if (m_controller) {
|
||||
// Используем новый конструктор с контроллером для сохранения настроек
|
||||
@@ -113,18 +129,21 @@ void EditPDFWidget::setWidgets(){
|
||||
m_specificationEditWidget = new DocumentEditWidget(m_specificationProcessor, m_controller, this);
|
||||
m_specificationPCBEditWidget = new DocumentEditWidget(m_specificationPCBProcessor, m_controller, this);
|
||||
m_vedomostEditWidget = new DocumentEditWidget(m_vedomostProcessor, m_controller, this);
|
||||
m_simpleListEditWidget = new DocumentEditWidget(m_simpleListProcessor, m_controller, this);
|
||||
} else {
|
||||
// Используем старый конструктор для обратной совместимости
|
||||
m_perechenEditWidget = new DocumentEditWidget(m_perechenProcessor, this);
|
||||
m_specificationEditWidget = new DocumentEditWidget(m_specificationProcessor, this);
|
||||
m_specificationPCBEditWidget = new DocumentEditWidget(m_specificationPCBProcessor, this);
|
||||
m_vedomostEditWidget = new DocumentEditWidget(m_vedomostProcessor, this);
|
||||
m_simpleListEditWidget = new DocumentEditWidget(m_simpleListProcessor, this);
|
||||
}
|
||||
|
||||
m_tabWidget->addTab(m_specificationEditWidget, "Спецификация");
|
||||
m_tabWidget->addTab(m_specificationPCBEditWidget, "Спецификация ПП");
|
||||
m_tabWidget->addTab(m_vedomostEditWidget, "Ведомость");
|
||||
m_tabWidget->addTab(m_perechenEditWidget, "Перечень");
|
||||
m_tabWidget->addTab(m_simpleListEditWidget, "Бланк заказа");
|
||||
}
|
||||
|
||||
void EditPDFWidget::setUpLayout(){
|
||||
@@ -172,6 +191,7 @@ void EditPDFWidget::setData(ComponentTableModel *componentModel, ProjectParamTab
|
||||
m_specificationEditWidget->setData(componentModel, projectParamModel);
|
||||
m_specificationPCBEditWidget->setData(componentModel, projectParamModel);
|
||||
m_vedomostEditWidget->setData(componentModel, projectParamModel);
|
||||
m_simpleListEditWidget->setData(componentModel, projectParamModel);
|
||||
}
|
||||
|
||||
void EditPDFWidget::updateAllViews()
|
||||
|
||||
@@ -45,12 +45,14 @@ private:
|
||||
SpecificationProcessor* m_specificationProcessor;
|
||||
SpecificationPCBProcessor* m_specificationPCBProcessor;
|
||||
VedomostProcessor* m_vedomostProcessor;
|
||||
SimpleListProcessor* m_simpleListProcessor;
|
||||
|
||||
// Виджеты документов
|
||||
DocumentEditWidget* m_perechenEditWidget;
|
||||
DocumentEditWidget* m_specificationEditWidget;
|
||||
DocumentEditWidget* m_specificationPCBEditWidget;
|
||||
DocumentEditWidget* m_vedomostEditWidget;
|
||||
DocumentEditWidget* m_simpleListEditWidget;
|
||||
|
||||
// Модели данных
|
||||
ComponentTableModel* m_componentModel;
|
||||
|
||||
+102
-13
@@ -4,6 +4,7 @@
|
||||
#include "../model/specificationpcbtablemodel.h"
|
||||
#include "../model/specificationtablemodel.h"
|
||||
#include "../model/vedomosttablemodel.h"
|
||||
#include "../model/simplelisttablemodel.h"
|
||||
#include "../model/titleinscriptionsmodel.h"
|
||||
#include "../model/projectparamtablemodel.h"
|
||||
#include "../controller/altiumparser.h"
|
||||
@@ -129,6 +130,7 @@ void MainWindow::setUpLayout(){
|
||||
csvMenu->addAction("&Перечень элементов (CSV)", this, &MainWindow::onExportPerechenToCsv);
|
||||
csvMenu->addAction("&Ведомость покупных изделий (CSV)", this, &MainWindow::onExportPurchaseListToCsv);
|
||||
csvMenu->addAction("Спецификация &PCB (CSV)", this, &MainWindow::onExportSpecificationPcbToCsv);
|
||||
csvMenu->addAction("&Бланк заказа (CSV)", this, &MainWindow::onExportSimpleListToCsv);
|
||||
m_viewMenu = m_menuBar->addMenu(tr("&Вид"));
|
||||
QAction* dataPanelAction = m_viewMenu->addAction(tr("&Панель данных"), this, &MainWindow::onViewDataPanel);
|
||||
dataPanelAction->setCheckable(true);
|
||||
@@ -173,6 +175,7 @@ void MainWindow::setUpLayout(){
|
||||
m_toolBar2->addAction(tr("Перечень (CSV)"), this, &MainWindow::onExportPerechenToCsv);
|
||||
m_toolBar2->addAction(tr("Ведомость (CSV)"), this, &MainWindow::onExportPurchaseListToCsv);
|
||||
m_toolBar2->addAction(tr("Спецификация PCB (CSV)"), this, &MainWindow::onExportSpecificationPcbToCsv);
|
||||
m_toolBar2->addAction(tr("Бланк заказа (CSV)"), this, &MainWindow::onExportSimpleListToCsv);
|
||||
m_toolBar2->addSeparator();
|
||||
QAction* undoToolAction = m_toolBar2->addAction(tr("&Отменить"), this, &MainWindow::onUndo);
|
||||
QAction* redoToolAction = m_toolBar2->addAction(tr("&Повторить"), this, &MainWindow::onRedo);
|
||||
@@ -421,6 +424,20 @@ void MainWindow::openProjectFile(const QString &fileName) {
|
||||
qDebug() << "MainWindow::onFileOpen: Данные таблицы ведомости покупных изделий не найдены в БД";
|
||||
}
|
||||
|
||||
// Загружаем бланк заказа напрямую в модель MainController
|
||||
QByteArray simpleListTableData = m_controller->loadSimpleListTableFromDatabase();
|
||||
if (!simpleListTableData.isEmpty()) {
|
||||
SimpleListTableModel *simpleListModel = m_controller->simpleListTableModel();
|
||||
if (simpleListModel) {
|
||||
simpleListModel->loadFromDatabase(simpleListTableData);
|
||||
qDebug() << "MainWindow::onFileOpen: Таблица бланка заказа загружена из БД в MainController";
|
||||
} else {
|
||||
qDebug() << "MainWindow::onFileOpen: SimpleListTableModel недоступен в MainController";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "MainWindow::onFileOpen: Данные таблицы бланка заказа не найдены в БД";
|
||||
}
|
||||
|
||||
// Загружаем надписи титульного листа в MainController
|
||||
QMap<int, QString> inscriptions;
|
||||
if (m_controller->loadTitleInscriptionsFromDatabase(inscriptions)) {
|
||||
@@ -548,6 +565,20 @@ bool MainWindow::onFileSave(){
|
||||
qDebug() << "MainWindow::onFileSave: VedomostTableModel недоступен в MainController";
|
||||
}
|
||||
|
||||
// Сохраняем бланк заказа из модели MainController
|
||||
SimpleListTableModel *simpleListModel = m_controller->simpleListTableModel();
|
||||
if (simpleListModel) {
|
||||
QByteArray tableData = simpleListModel->saveToDatabase();
|
||||
if (!tableData.isEmpty()) {
|
||||
success &= m_controller->saveSimpleListTableToDatabase(tableData);
|
||||
qDebug() << "MainWindow::onFileSave: Таблица бланка заказа сохранена из MainController";
|
||||
} else {
|
||||
qDebug() << "MainWindow::onFileSave: Данные таблицы бланка заказа пусты";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "MainWindow::onFileSave: SimpleListTableModel недоступен в MainController";
|
||||
}
|
||||
|
||||
if (success) {
|
||||
m_statusBar->showMessage(tr("Проект сохранен: %1").arg(m_currentProjectPath));
|
||||
return true;
|
||||
@@ -632,21 +663,35 @@ void MainWindow::onFileSaveAs(){
|
||||
qDebug() << "MainWindow::onFileSaveAs: SpecificationTableModel недоступен в MainController";
|
||||
}
|
||||
|
||||
// Сохраняем ведомость покупных изделий из модели MainController
|
||||
VedomostTableModel *vedomostModel = m_controller->vedomostTableModel();
|
||||
if (vedomostModel) {
|
||||
QByteArray tableData = vedomostModel->saveToDatabase();
|
||||
if (!tableData.isEmpty()) {
|
||||
success &= m_controller->saveVedomostTableToDatabase(tableData);
|
||||
qDebug() << "MainWindow::onFileSaveAs: Таблица ведомости покупных изделий сохранена из MainController";
|
||||
// Сохраняем ведомость покупных изделий из модели MainController
|
||||
VedomostTableModel *vedomostModel = m_controller->vedomostTableModel();
|
||||
if (vedomostModel) {
|
||||
QByteArray tableData = vedomostModel->saveToDatabase();
|
||||
if (!tableData.isEmpty()) {
|
||||
success &= m_controller->saveVedomostTableToDatabase(tableData);
|
||||
qDebug() << "MainWindow::onFileSaveAs: Таблица ведомости покупных изделий сохранена из MainController";
|
||||
} else {
|
||||
qDebug() << "MainWindow::onFileSaveAs: Данные таблицы ведомости покупных изделий пусты";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "MainWindow::onFileSaveAs: Данные таблицы ведомости покупных изделий пусты";
|
||||
qDebug() << "MainWindow::onFileSaveAs: VedomostTableModel недоступен в MainController";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "MainWindow::onFileSaveAs: VedomostTableModel недоступен в MainController";
|
||||
}
|
||||
|
||||
if (success) {
|
||||
|
||||
// Сохраняем бланк заказа из модели MainController
|
||||
SimpleListTableModel *simpleListModel = m_controller->simpleListTableModel();
|
||||
if (simpleListModel) {
|
||||
QByteArray tableData = simpleListModel->saveToDatabase();
|
||||
if (!tableData.isEmpty()) {
|
||||
success &= m_controller->saveSimpleListTableToDatabase(tableData);
|
||||
qDebug() << "MainWindow::onFileSaveAs: Таблица бланка заказа сохранена из MainController";
|
||||
} else {
|
||||
qDebug() << "MainWindow::onFileSaveAs: Данные таблицы бланка заказа пусты";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "MainWindow::onFileSaveAs: SimpleListTableModel недоступен в MainController";
|
||||
}
|
||||
|
||||
if (success) {
|
||||
m_currentProjectPath = fileName;
|
||||
updateWindowTitle();
|
||||
updateStatusBar();
|
||||
@@ -1150,6 +1195,50 @@ void MainWindow::onExportPurchaseListToCsv()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onExportSimpleListToCsv()
|
||||
{
|
||||
qDebug() << "MainWindow::onExportSimpleListToCsv: Экспорт бланка заказа в CSV";
|
||||
|
||||
// Проверяем, открыт ли проект
|
||||
if (m_currentProjectPath.isEmpty()) {
|
||||
QMessageBox::warning(this, tr("Предупреждение"),
|
||||
tr("Сначала создайте или откройте проект"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверяем, есть ли данные в модели бланка заказа
|
||||
SimpleListTableModel *simpleListModel = m_controller->simpleListTableModel();
|
||||
if (!simpleListModel || simpleListModel->rowCount() == 0) {
|
||||
QMessageBox::warning(this, tr("Предупреждение"),
|
||||
tr("Бланк заказа пуст. Сначала сгенерируйте таблицу."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Открываем диалог сохранения файла
|
||||
QString defaultPath = QCoreApplication::applicationDirPath() + "/БланкЗаказа.csv";
|
||||
QString fileName = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Экспорт бланка заказа в CSV"),
|
||||
defaultPath,
|
||||
tr("CSV файлы (*.csv);;Все файлы (*)")
|
||||
);
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
m_statusBar->showMessage(tr("Экспорт бланка заказа в CSV: %1").arg(fileName));
|
||||
|
||||
// Экспортируем в CSV через MainController
|
||||
if (m_controller->exportSimpleListToCsv(fileName)) {
|
||||
QMessageBox::information(this, tr("Успех"),
|
||||
tr("Бланк заказа успешно экспортирован в CSV:\n%1").arg(fileName));
|
||||
m_statusBar->showMessage(tr("Экспорт бланка заказа в CSV завершен"));
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Ошибка"),
|
||||
tr("Не удалось экспортировать бланк заказа в CSV:\n%1").arg(m_controller->lastError()));
|
||||
m_statusBar->showMessage(tr("Ошибка экспорта бланка заказа в CSV"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onUndo(){}
|
||||
|
||||
void MainWindow::onRedo(){}
|
||||
|
||||
@@ -93,6 +93,7 @@ private slots:
|
||||
void onExportPerechenToCsv();
|
||||
void onExportPurchaseListToCsv();
|
||||
void onExportSpecificationPcbToCsv();
|
||||
void onExportSimpleListToCsv();
|
||||
void onUndo();
|
||||
void onRedo();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user