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:
@@ -0,0 +1,96 @@
|
||||
#include "componentmodel.h"
|
||||
|
||||
ComponentModel::ComponentModel(QObject *parent)
|
||||
: QObject{parent}
|
||||
{}
|
||||
|
||||
int ComponentModel::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void ComponentModel::setId(int newId)
|
||||
{
|
||||
if (m_id == newId)
|
||||
return;
|
||||
m_id = newId;
|
||||
emit idChanged();
|
||||
}
|
||||
|
||||
QString ComponentModel::designator() const
|
||||
{
|
||||
return m_designator;
|
||||
}
|
||||
|
||||
void ComponentModel::setDesignator(const QString &newDesignator)
|
||||
{
|
||||
if (m_designator == newDesignator)
|
||||
return;
|
||||
m_designator = newDesignator;
|
||||
emit designatorChanged();
|
||||
}
|
||||
|
||||
QString ComponentModel::currentVariant() const
|
||||
{
|
||||
return m_currentVariant;
|
||||
}
|
||||
|
||||
void ComponentModel::setCurrentVariant(const QString &newCurrentVariant)
|
||||
{
|
||||
qDebug() << "ComponentModel: Устанавливаем текущий вариант:" << newCurrentVariant << "для компонента" << m_designator << "текущий:" << m_currentVariant;
|
||||
|
||||
if (m_currentVariant == newCurrentVariant) {
|
||||
qDebug() << "ComponentModel: Вариант не изменился, но обновляем свойства";
|
||||
updateCurrentProperties();
|
||||
return;
|
||||
}
|
||||
|
||||
m_currentVariant = newCurrentVariant;
|
||||
updateCurrentProperties();
|
||||
emit currentVariantChanged();
|
||||
}
|
||||
|
||||
QMap<QString, QString> ComponentModel::properties() const
|
||||
{
|
||||
return m_currentProperties;
|
||||
}
|
||||
|
||||
void ComponentModel::setProperties(const QMap<QString, QString> &newProperties)
|
||||
{
|
||||
if (m_currentProperties == newProperties)
|
||||
return;
|
||||
m_currentProperties = newProperties;
|
||||
emit propertiesChanged();
|
||||
}
|
||||
|
||||
void ComponentModel::setBaseProperties(const QMap<QString, QString> &newBaseProperties)
|
||||
{
|
||||
if (m_baseProperties == newBaseProperties)
|
||||
return;
|
||||
m_baseProperties = newBaseProperties;
|
||||
qDebug() << "ComponentModel: Устанавливаем базовые свойства для" << m_designator << "свойств:" << newBaseProperties.size();
|
||||
// НЕ вызываем updateCurrentProperties() здесь, так как вариант еще не установлен
|
||||
emit propertiesChanged();
|
||||
}
|
||||
|
||||
void ComponentModel::setVariantProperties(const QString &variantName, const QMap<QString, QString> &variantProps)
|
||||
{
|
||||
m_variantProperties[variantName] = variantProps;
|
||||
qDebug() << "ComponentModel: Устанавливаем свойства варианта" << variantName << "для" << m_designator << "свойств:" << variantProps.size();
|
||||
updateCurrentProperties();
|
||||
emit propertiesChanged();
|
||||
}
|
||||
|
||||
void ComponentModel::updateCurrentProperties() {
|
||||
qDebug() << "ComponentModel: Обновляем свойства для" << m_designator << "текущий вариант:" << m_currentVariant;
|
||||
qDebug() << "ComponentModel: Базовых свойств:" << m_baseProperties.size();
|
||||
qDebug() << "ComponentModel: Доступных вариантов:" << m_variantProperties.keys();
|
||||
|
||||
m_currentProperties = m_baseProperties;
|
||||
if (!m_currentVariant.isEmpty() && m_variantProperties.contains(m_currentVariant)) {
|
||||
qDebug() << "ComponentModel: Объединяем с вариативными свойствами для варианта" << m_currentVariant;
|
||||
m_currentProperties.unite(m_variantProperties[m_currentVariant]);
|
||||
}
|
||||
|
||||
qDebug() << "ComponentModel: Итоговых свойств:" << m_currentProperties.size();
|
||||
}
|
||||
Reference in New Issue
Block a user