Add initial project structure with essential files including .gitignore, application resources, and various model and view components for the application. Implemented asynchronous parsing support and database structure checks.

This commit is contained in:
2025-12-08 15:21:18 +03:00
parent 4f8c90c15b
commit 3467003721
110 changed files with 35406 additions and 0 deletions
+176
View File
@@ -0,0 +1,176 @@
#include "columnsettingsdialog.h"
#include "../controller/maincontroller.h"
#include "../model/componenttablemodel.h"
#include "../model/projectsettingsmodel.h"
#include <QDebug>
// Статические константы
const QStringList ColumnSettingsDialog::COLUMN_NAMES = QStringList() << "Поз.обозначение" << "Наименование" << "Кол." << "Примечание";
const QStringList ColumnSettingsDialog::DEFAULT_MAPPINGS = QStringList() << "Designator" << "<Пусто>" << "<Пусто>" << "<Пусто>";
ColumnSettingsDialog::ColumnSettingsDialog(const QStringList &availableProperties,
const QStringList &currentMappings,
QWidget *parent)
: QDialog(parent)
, m_availableProperties(availableProperties)
, m_currentMappings(currentMappings)
, m_controller(nullptr)
{
setUp();
}
ColumnSettingsDialog::ColumnSettingsDialog(MainController *controller, QWidget *parent)
: QDialog(parent)
, m_controller(controller)
{
// Загружаем настройки из контроллера
if (m_controller) {
m_controller->loadProjectSettingsFromDatabase();
m_availableProperties = m_controller->componentTableModel()->propertyNames();
m_currentMappings = m_controller->projectSettingsModel()->columnMappings();
}
setUp();
}
void ColumnSettingsDialog::setUp()
{
setWidgets();
setUpLayout();
setUpConnections();
}
void ColumnSettingsDialog::setWidgets()
{
// Создаем комбобоксы для каждой колонки
for (int i = 0; i < COLUMN_NAMES.size(); ++i) {
QComboBox *comboBox = new QComboBox(this);
// Делаем комбобокс редактируемым для ввода выражений
comboBox->setEditable(true);
// Добавляем доступные свойства
for (const QString &property : m_availableProperties) {
comboBox->addItem(property);
}
// Устанавливаем текущее значение
if (i < m_currentMappings.size()) {
QString currentMapping = m_currentMappings[i];
int index = comboBox->findText(currentMapping);
if (index >= 0) {
comboBox->setCurrentIndex(index);
} else {
// Если значение не найдено в списке, устанавливаем его как текст
comboBox->setCurrentText(currentMapping);
}
}
m_columnComboBoxes.append(comboBox);
}
// Создаем кнопки
m_okButton = new QPushButton("OK", this);
m_cancelButton = new QPushButton("Отмена", this);
m_resetButton = new QPushButton("Сброс", this);
// Настраиваем диалог
setWindowTitle("Настройки колонок");
setModal(true);
resize(400, 300);
}
void ColumnSettingsDialog::setUpLayout()
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
// Создаем сетку для колонок
QGridLayout *gridLayout = new QGridLayout();
// Заголовки
gridLayout->addWidget(new QLabel("Колонка", this), 0, 0);
gridLayout->addWidget(new QLabel("Источник данных", this), 0, 1);
// Строки для каждой колонки
for (int i = 0; i < COLUMN_NAMES.size(); ++i) {
QLabel *columnLabel = new QLabel(COLUMN_NAMES[i], this);
gridLayout->addWidget(columnLabel, i + 1, 0);
gridLayout->addWidget(m_columnComboBoxes[i], i + 1, 1);
}
mainLayout->addLayout(gridLayout);
// Кнопки
QHBoxLayout *buttonLayout = new QHBoxLayout();
buttonLayout->addWidget(m_resetButton);
buttonLayout->addStretch();
buttonLayout->addWidget(m_cancelButton);
buttonLayout->addWidget(m_okButton);
mainLayout->addLayout(buttonLayout);
}
void ColumnSettingsDialog::setUpConnections()
{
connect(m_okButton, &QPushButton::clicked, this, [this]() {
// Сохраняем настройки перед закрытием
saveSettings();
accept();
});
connect(m_cancelButton, &QPushButton::clicked, this, &QDialog::reject);
connect(m_resetButton, &QPushButton::clicked, this, [this]() {
// Сбрасываем к значениям по умолчанию
for (int i = 0; i < m_columnComboBoxes.size() && i < DEFAULT_MAPPINGS.size(); ++i) {
int index = m_columnComboBoxes[i]->findText(DEFAULT_MAPPINGS[i]);
if (index >= 0) {
m_columnComboBoxes[i]->setCurrentIndex(index);
}
}
});
}
QStringList ColumnSettingsDialog::getColumnMappings() const
{
QStringList mappings;
for (QComboBox *comboBox : m_columnComboBoxes) {
mappings.append(comboBox->currentText());
}
return mappings;
}
void ColumnSettingsDialog::saveSettings()
{
qDebug() << "ColumnSettingsDialog: Сохранение настроек столбцов";
if (m_controller) {
// Сохраняем настройки столбцов в модель настроек
QStringList mappings = getColumnMappings();
m_controller->projectSettingsModel()->setColumnMappings(mappings);
// Сохраняем в базу данных
m_controller->saveProjectSettingsToDatabase();
// Синхронизируем настройки колонок с PerechenTableController
m_controller->syncColumnMappingsWithPerechenController();
qDebug() << "ColumnSettingsDialog: Настройки столбцов синхронизированы с PerechenTableController";
}
}
void ColumnSettingsDialog::loadSettings()
{
qDebug() << "ColumnSettingsDialog: Загрузка настроек столбцов";
if (m_controller) {
m_controller->loadProjectSettingsFromDatabase();
m_currentMappings = m_controller->projectSettingsModel()->columnMappings();
// Обновляем UI
for (int i = 0; i < m_columnComboBoxes.size() && i < m_currentMappings.size(); ++i) {
QString mapping = m_currentMappings[i];
int index = m_columnComboBoxes[i]->findText(mapping);
if (index >= 0) {
m_columnComboBoxes[i]->setCurrentIndex(index);
} else {
m_columnComboBoxes[i]->setCurrentText(mapping);
}
}
}
}