#ifndef ADDPRODUCTTYPEDIALOG_H
#define ADDPRODUCTTYPEDIALOG_H

#include <QTreeWidgetItem>

#include <QDialog>

namespace Ui {
class AddProductTypeDialog;
}

template <typename DataType> struct SqlTreeNode;

class ColouredLineEdit;

class AddProductTypeDialog : public QDialog {
private:
  static constexpr int m_textColumn = 0;
  QTreeWidgetItem *m_currentTreeWidgetItem;
  QTreeWidgetItem *m_futureTreeWidgetItem;
  QTreeWidgetItem *m_commonTreeWidgetItem;
  Ui::AddProductTypeDialog *m_ui;

private:
  bool m_lastCase;
  ColouredLineEdit *m_currentTypeNameLineEdit;
  ColouredLineEdit *m_futureTypeNameLineEdit;

public:
  explicit AddProductTypeDialog(const SqlTreeNode<QString> *sqlTreeNode,
                                QWidget *parent = nullptr,
                                Qt::WindowFlags f = Qt::WindowFlags());
  ~AddProductTypeDialog();

private:
  void createLineEditWidgets();
  void initializeWidgetItems();
  void configureConnections();
  void configureTreeWidget();
  void configureStandardText();
  void showCase(const SqlTreeNode<QString> *sqlTreeNode);

private:
  void done(int resultCode) override;
  void setHiddenBadCaseGroup(bool hidden);
  void showGoodCase(QString &&generalNodeName);
  void showBadCase(QString &&generalNodeName);

public:
  // m_lastCase is true when case was good
  bool lastCase();
  QString futureTypeName();
  QString currentTypeName();
  void setTopText(const QString &value);
  void notifyInputError();
};

#endif // ADDPRODUCTTYPEDIALOG_H
