100 lines
3.1 KiB
C
100 lines
3.1 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <QDialog>
|
||
|
|
#include <QList>
|
||
|
|
#include <QStringList>
|
||
|
|
#include "DocxBuilder.h"
|
||
|
|
|
||
|
|
QT_BEGIN_NAMESPACE
|
||
|
|
class QLabel;
|
||
|
|
class QListWidget;
|
||
|
|
class QPushButton;
|
||
|
|
class QLineEdit;
|
||
|
|
class QComboBox;
|
||
|
|
class QSpinBox;
|
||
|
|
class QStackedWidget;
|
||
|
|
class QGroupBox;
|
||
|
|
QT_END_NAMESPACE
|
||
|
|
|
||
|
|
// ============================================================
|
||
|
|
// Шаг мастера
|
||
|
|
// ============================================================
|
||
|
|
struct WizardStep {
|
||
|
|
QString prompt; // Вопрос / подсказка пользователю
|
||
|
|
QStringList choices; // Варианты выбора (если пусто — свободный ввод)
|
||
|
|
DocElementType elementType; // Тип элемента, который создаём на этом шаге
|
||
|
|
};
|
||
|
|
|
||
|
|
// ============================================================
|
||
|
|
// Диалог-мастер пошагового создания документа
|
||
|
|
// ============================================================
|
||
|
|
class DocumentWizard : public QDialog {
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
public:
|
||
|
|
// templateLines — набор строк-шаблонов, «скармливаемых» в начале работы.
|
||
|
|
// Формат каждой строки: "type|prompt|choice1;choice2;choice3"
|
||
|
|
// type: heading1 / heading2 / heading3 / text / table / image
|
||
|
|
explicit DocumentWizard(const QStringList& templateLines,
|
||
|
|
QWidget* parent = nullptr);
|
||
|
|
|
||
|
|
// Путь к созданному файлу
|
||
|
|
QString outputFilePath() const { return m_outputPath; }
|
||
|
|
|
||
|
|
private slots:
|
||
|
|
void onNextClicked();
|
||
|
|
void onBackClicked();
|
||
|
|
void onFinishClicked();
|
||
|
|
void onChoiceSelected(int row);
|
||
|
|
void onAddTableRow();
|
||
|
|
void onRemoveTableRow();
|
||
|
|
void onBrowseImage();
|
||
|
|
|
||
|
|
private:
|
||
|
|
void parseTemplates(const QStringList& lines);
|
||
|
|
void showStep(int index);
|
||
|
|
void buildStepWidget(int index);
|
||
|
|
void applyCurrentStep();
|
||
|
|
|
||
|
|
// --- Данные ---
|
||
|
|
QList<WizardStep> m_steps;
|
||
|
|
int m_currentStep = 0;
|
||
|
|
QString m_outputPath;
|
||
|
|
DocxBuilder m_builder;
|
||
|
|
|
||
|
|
// Промежуточные данные текущего шага
|
||
|
|
QString m_chosenText;
|
||
|
|
TableData m_tableData;
|
||
|
|
QString m_imagePath;
|
||
|
|
|
||
|
|
// --- UI ---
|
||
|
|
QLabel* m_stepLabel;
|
||
|
|
QLabel* m_promptLabel;
|
||
|
|
QStackedWidget* m_contentStack;
|
||
|
|
|
||
|
|
// Страница 0 — выбор из списка или ввод
|
||
|
|
QListWidget* m_choiceList;
|
||
|
|
QLineEdit* m_freeInput;
|
||
|
|
|
||
|
|
// Страница 1 — ввод таблицы
|
||
|
|
QGroupBox* m_tableGroup;
|
||
|
|
QLineEdit* m_tableHeadersEdit;
|
||
|
|
QListWidget* m_tableRowsList;
|
||
|
|
QLineEdit* m_tableRowInput;
|
||
|
|
QPushButton* m_addRowBtn;
|
||
|
|
QPushButton* m_removeRowBtn;
|
||
|
|
|
||
|
|
// Страница 2 — выбор изображения
|
||
|
|
QLineEdit* m_imagePathEdit;
|
||
|
|
QPushButton* m_browseBtn;
|
||
|
|
QSpinBox* m_imgWidthCm;
|
||
|
|
QSpinBox* m_imgHeightCm;
|
||
|
|
|
||
|
|
QPushButton* m_backBtn;
|
||
|
|
QPushButton* m_nextBtn;
|
||
|
|
QPushButton* m_finishBtn;
|
||
|
|
QLabel* m_progressLabel;
|
||
|
|
|
||
|
|
void setupUi();
|
||
|
|
};
|