#ifndef TITLEINSCRIPTIONSDIALOG_H
#define TITLEINSCRIPTIONSDIALOG_H

#include <QDialog>
#include <QComboBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QLabel>
#include <QScrollArea>
#include <QLineEdit>
#include <QGroupBox>
#include <QMap>
#include <QString>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QSlider>
#include "../model/projectparamtablemodel.h"
#include "../model/titleinscriptionsmodel.h"
#include "titleinscriptiontypes.h"

class TitleInscriptionsDialog : public QDialog
{
    Q_OBJECT
public:
    explicit TitleInscriptionsDialog(ProjectParamTableModel *projectParamModel, QWidget *parent = nullptr);
    
    // Методы для получения настроек
    QMap<int, QString> getInscriptionValues() const;
    void setInscriptionValues(const QMap<int, QString> &values);
    
    // Методы для работы с моделью
    void setTitleInscriptionsModel(TitleInscriptionsModel *model);
    TitleInscriptionsModel* getTitleInscriptionsModel() const;

private slots:
    void onComboBoxChanged(int fieldNumber, const QString &value);
    void onCustomValueChanged(int fieldNumber, const QString &value);
    void onZoomChanged(int value);
    void onAccept();
    void onCancel();

private:
    void setUp();
    void setWidgets();
    void setUpLayout();
    void setUpConnections();
    void createInscriptionFields();
    void createImagePreview();
    void updateFieldValue(int fieldNumber, const QString &value);
    
    ProjectParamTableModel *m_projectParamModel;
    TitleInscriptionsModel *m_titleInscriptionsModel;
    
    // Виджеты
    QScrollArea *m_scrollArea;
    QWidget *m_scrollContent;
    QGraphicsView *m_imageView;
    QGraphicsScene *m_imageScene;
    QGraphicsPixmapItem *m_imageItem;
    QSlider *m_zoomSlider;
    
    // Кнопки
    QPushButton *m_okButton;
    QPushButton *m_cancelButton;
    
    // Данные полей
    QMap<int, TitleInscriptionField> m_fields;
    QMap<int, QComboBox*> m_comboBoxes;
    QMap<int, QLineEdit*> m_customEdits;
    QMap<int, QLabel*> m_fieldLabels;
    
    // Статические данные о графах ГОСТ
    static QMap<int, QString> s_fieldNames;
    static QMap<int, QString> s_fieldDescriptions;
    
    static void initializeFieldData();
};

#endif // TITLEINSCRIPTIONSDIALOG_H 