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,79 @@
|
||||
#ifndef PCBMATERIALMODEL_H
|
||||
#define PCBMATERIALMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QDebug>
|
||||
#include "../controller/databasecontroller.h"
|
||||
|
||||
// Структура для хранения данных о материалах платы
|
||||
struct PCBMaterialData {
|
||||
int id;
|
||||
QString name;
|
||||
QString value;
|
||||
double height;
|
||||
int dielType;
|
||||
int layerNumber;
|
||||
|
||||
PCBMaterialData() : id(-1), height(0.0), dielType(0), layerNumber(0) {}
|
||||
|
||||
PCBMaterialData(int _id, const QString &_name, const QString &_value,
|
||||
double _height, int _dielType, int _layerNumber)
|
||||
: id(_id), name(_name), value(_value), height(_height),
|
||||
dielType(_dielType), layerNumber(_layerNumber) {}
|
||||
};
|
||||
|
||||
class PCBMaterialModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PCBMaterialModel(QObject *parent = nullptr);
|
||||
|
||||
// Методы QAbstractTableModel
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
// Методы для работы с данными
|
||||
void setDatabase(DataBaseController *database);
|
||||
void loadMaterials();
|
||||
void clearMaterials();
|
||||
|
||||
// Геттеры
|
||||
int getLayerCount() const { return m_layerCount; }
|
||||
int getMaterialCount() const { return m_materials.size(); }
|
||||
const QList<PCBMaterialData>& getMaterials() const { return m_materials; }
|
||||
|
||||
// Методы для получения данных по индексу
|
||||
PCBMaterialData getMaterial(int row) const;
|
||||
QString getMaterialName(int row) const;
|
||||
QString getMaterialValue(int row) const;
|
||||
double getMaterialHeight(int row) const;
|
||||
int getMaterialDielType(int row) const;
|
||||
int getMaterialLayerNumber(int row) const;
|
||||
|
||||
// Методы для форматирования данных
|
||||
QString formatHeight(double height) const;
|
||||
QString formatDielType(int dielType) const;
|
||||
|
||||
private:
|
||||
QList<PCBMaterialData> m_materials;
|
||||
DataBaseController *m_database;
|
||||
int m_layerCount;
|
||||
|
||||
// Константы для колонок
|
||||
enum Columns {
|
||||
ColumnLayerNumber = 0,
|
||||
ColumnName,
|
||||
ColumnValue,
|
||||
ColumnHeight,
|
||||
ColumnDielType,
|
||||
ColumnCount
|
||||
};
|
||||
};
|
||||
|
||||
#endif // PCBMATERIALMODEL_H
|
||||
Reference in New Issue
Block a user