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,87 @@
|
||||
#ifndef DESIGNATORMAPPINGMODEL_H
|
||||
#define DESIGNATORMAPPINGMODEL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
||||
// Forward declaration
|
||||
class DataBaseController;
|
||||
|
||||
class DesignatorMappingItem
|
||||
{
|
||||
public:
|
||||
QString designator;
|
||||
QString singularName;
|
||||
QString pluralName;
|
||||
bool isCustom;
|
||||
|
||||
DesignatorMappingItem() : isCustom(false) {}
|
||||
DesignatorMappingItem(const QString &des, const QString &sing, const QString &plur, bool custom = false)
|
||||
: designator(des), singularName(sing), pluralName(plur), isCustom(custom) {}
|
||||
|
||||
// Операторы сравнения для использования в QList
|
||||
bool operator==(const DesignatorMappingItem &other) const {
|
||||
return designator == other.designator &&
|
||||
singularName == other.singularName &&
|
||||
pluralName == other.pluralName &&
|
||||
isCustom == other.isCustom;
|
||||
}
|
||||
|
||||
bool operator!=(const DesignatorMappingItem &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
class DesignatorMappingModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QList<DesignatorMappingItem> mappings READ mappings WRITE setMappings NOTIFY mappingsChanged FINAL)
|
||||
|
||||
public:
|
||||
explicit DesignatorMappingModel(QObject *parent = nullptr);
|
||||
|
||||
// Установка контроллера БД
|
||||
void setDatabaseController(DataBaseController *dbController);
|
||||
void loadDataFromDatabase(); // Новый метод для загрузки данных после инициализации БД
|
||||
void saveToDatabase();
|
||||
void loadFromDatabase();
|
||||
|
||||
// Основные методы
|
||||
QList<DesignatorMappingItem> mappings() const;
|
||||
void setMappings(const QList<DesignatorMappingItem> &newMappings);
|
||||
|
||||
// Методы для работы с маппингом
|
||||
QString getComponentType(const QString &designator, bool isPlural = false) const;
|
||||
void addMapping(const DesignatorMappingItem &item);
|
||||
void updateMapping(const QString &designator, const DesignatorMappingItem &item);
|
||||
void removeMapping(const QString &designator);
|
||||
void clearCustomMappings();
|
||||
|
||||
// Методы для работы с настройками
|
||||
void resetToDefaults();
|
||||
bool isModified() const;
|
||||
void setModified(bool modified);
|
||||
|
||||
signals:
|
||||
void mappingsChanged();
|
||||
void mappingAdded(const QString &designator);
|
||||
void mappingUpdated(const QString &designator);
|
||||
void mappingRemoved(const QString &designator);
|
||||
void settingsModified();
|
||||
|
||||
private:
|
||||
QList<DesignatorMappingItem> m_mappings;
|
||||
QMap<QString, DesignatorMappingItem> m_mappingMap;
|
||||
bool m_isModified;
|
||||
DataBaseController *m_dbController;
|
||||
|
||||
void updateMappingMap();
|
||||
void initializeDefaultMappings();
|
||||
|
||||
// Статические константы для значений по умолчанию
|
||||
static const QList<DesignatorMappingItem> DEFAULT_MAPPINGS;
|
||||
};
|
||||
|
||||
#endif // DESIGNATORMAPPINGMODEL_H
|
||||
Reference in New Issue
Block a user