2020-03-08 17:49:15 +07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
#include <QTableWidget>
|
|
|
|
|
|
|
|
class QStringListModel;
|
|
|
|
|
|
|
|
class SubstitutionsTable : public QTableWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum class Column { Language = 0, Source, Target, Count };
|
|
|
|
|
|
|
|
explicit SubstitutionsTable(QWidget* parent = nullptr);
|
|
|
|
|
2020-03-28 18:26:05 +07:00
|
|
|
void setSourceLanguageModel(QStringListModel* model);
|
|
|
|
|
2020-03-08 17:49:15 +07:00
|
|
|
void setSubstitutions(const Substitutions& substitutions);
|
|
|
|
Substitutions substitutions() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void handleItemChange(QTableWidgetItem* item);
|
|
|
|
void addRow(const LanguageId& language = {},
|
|
|
|
const Substitution& substutution = {});
|
|
|
|
std::pair<LanguageId, Substitution> at(int row) const;
|
2020-03-19 01:21:17 +07:00
|
|
|
void updateModel(const Substitutions& substitutions);
|
2020-03-08 17:49:15 +07:00
|
|
|
|
2020-03-28 18:26:05 +07:00
|
|
|
QStringListModel* sourceLanguages_{nullptr};
|
|
|
|
QStringListModel* substitutionLanguages_;
|
2020-03-08 17:49:15 +07:00
|
|
|
};
|