added web service
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
#ifndef SIMPLELISTTABLEMODEL_H
|
||||
#define SIMPLELISTTABLEMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
#include <QPair>
|
||||
|
||||
// Forward declaration
|
||||
class ComponentModel;
|
||||
|
||||
// Структура для хранения данных ячейки
|
||||
struct SimpleListCellData
|
||||
{
|
||||
QString value; // Значение ячейки
|
||||
bool isAutoGenerated; // Автоматически сгенерированное значение
|
||||
bool isEmpty; // Пустая ячейка
|
||||
|
||||
SimpleListCellData() : isAutoGenerated(false), isEmpty(true) {}
|
||||
|
||||
SimpleListCellData(const QString &val, bool autoGen = false, bool empty = false)
|
||||
: value(val), isAutoGenerated(autoGen), isEmpty(empty) {}
|
||||
};
|
||||
|
||||
// Структура для хранения строки таблицы
|
||||
struct SimpleListRowData
|
||||
{
|
||||
SimpleListCellData designator; // Десигнатор (поз. обозначение)
|
||||
SimpleListCellData name; // Наименование
|
||||
SimpleListCellData quantity; // Количество
|
||||
bool isEmpty; // Пустая строка
|
||||
|
||||
SimpleListRowData() : isEmpty(false) {}
|
||||
};
|
||||
|
||||
class SimpleListTableModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimpleListTableModel(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;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
// Методы для работы со строками
|
||||
void addRow(const SimpleListRowData &rowData);
|
||||
void insertRow(int position, const SimpleListRowData &rowData);
|
||||
void removeRow(int row);
|
||||
void clear();
|
||||
|
||||
// Новые методы для управления строками
|
||||
void addEmptyRow();
|
||||
void addEmptyRowAt(int position);
|
||||
SimpleListRowData createEmptyRow() const;
|
||||
bool canEditRow(int row) const;
|
||||
|
||||
// Методы для работы с компонентами
|
||||
void setComponents(const QList<ComponentModel*> &components);
|
||||
|
||||
// Методы для сохранения/загрузки
|
||||
QByteArray saveToDatabase() const;
|
||||
void loadFromDatabase(const QByteArray &data);
|
||||
|
||||
// Методы для экспорта
|
||||
QString getDocumentTitle() const;
|
||||
QString getDocumentType() const;
|
||||
|
||||
// Методы для работы с тех. запасом
|
||||
void setTechReservePercent(int percent);
|
||||
int getTechReservePercent() const;
|
||||
|
||||
signals:
|
||||
void modelDataChanged();
|
||||
void headerDataChanged(Qt::Orientation orientation, int first, int last);
|
||||
|
||||
private:
|
||||
void updateRowEmptyStatus(int row);
|
||||
SimpleListCellData createCellData(const QString &value, bool isAuto = false, bool isEmpty = false);
|
||||
|
||||
QList<SimpleListRowData> m_rows;
|
||||
QList<ComponentModel*> m_components; // Компоненты для генерации
|
||||
int m_techReservePercent; // Процент тех запаса
|
||||
|
||||
static const int COLUMN_COUNT = 3;
|
||||
static const QStringList DEFAULT_HEADERS;
|
||||
};
|
||||
|
||||
#endif // SIMPLELISTTABLEMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user