update
This commit is contained in:
parent
7a9ae2812c
commit
b194d486fa
|
@ -51,13 +51,21 @@ ExtractRuleView::ExtractRuleView(std::shared_ptr<TranslateBasic> base,
|
||||||
_configs_stack->setCurrentIndex(1);
|
_configs_stack->setCurrentIndex(1);
|
||||||
single_configs->currentAccept(unit, target);
|
single_configs->currentAccept(unit, target);
|
||||||
}
|
}
|
||||||
|
else if (unit->baseType() == ListBasedUnit::topic()) {
|
||||||
|
_configs_stack->setCurrentIndex(2);
|
||||||
|
list_configs->currentAccept(unit, target);
|
||||||
|
}
|
||||||
|
else if (unit->baseType() == UnionBasedUnit::topic()){
|
||||||
|
_configs_stack->setCurrentIndex(3);
|
||||||
|
union_configs->currentAccept(unit, target);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
_configs_stack->setCurrentIndex(0);
|
_configs_stack->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_member_units->setModel(_member_model);
|
_member_units->setModel(_member_model);
|
||||||
_member_model->setHorizontalHeaderLabels(QStringList() << "FieldName" << "OffsetSpan"<< "UnitType" );
|
_member_model->setHorizontalHeaderLabels(QStringList() << "FieldName" << "OffsetSpan" << "UnitType");
|
||||||
_member_units->setContextMenuPolicy(Qt::CustomContextMenu);
|
_member_units->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(_member_units, &QTableView::customContextMenuRequested, [=](const QPoint& pt) {
|
connect(_member_units, &QTableView::customContextMenuRequested, [=](const QPoint& pt) {
|
||||||
QMenu m;
|
QMenu m;
|
||||||
|
@ -115,29 +123,42 @@ void ExtractRuleView::showEvent(QShowEvent* e)
|
||||||
|
|
||||||
ListBasedConfiguration::ListBasedConfiguration(
|
ListBasedConfiguration::ListBasedConfiguration(
|
||||||
std::shared_ptr<TranslateBasic> core, QWidget* p /*= nullptr*/)
|
std::shared_ptr<TranslateBasic> core, QWidget* p /*= nullptr*/)
|
||||||
:QWidget(p), _bind_core(core), _bind_u(nullptr),
|
:QWidget(p), _bind_core(core),
|
||||||
|
_offset_enter(new QSpinBox(this)),
|
||||||
|
_delegate_sync(new QPushButton("Sync", this)),
|
||||||
_rule_select(new QComboBox(this)),
|
_rule_select(new QComboBox(this)),
|
||||||
_size_layout_select(new QComboBox(this)),
|
_size_layout_select(new QComboBox(this)),
|
||||||
|
|
||||||
_configs_stack(new QStackedWidget(this)),
|
_configs_stack(new QStackedWidget(this)),
|
||||||
|
_content_display(new QTextBrowser(this)),
|
||||||
_const_number_input(new QSpinBox(this)),
|
_const_number_input(new QSpinBox(this)),
|
||||||
_prev_field_refer(new QComboBox(this))
|
_prev_field_refer(new QComboBox(this))
|
||||||
{
|
{
|
||||||
auto layout = new QGridLayout(this);
|
auto layout = new QGridLayout(this);
|
||||||
layout->addWidget(new QLabel(tr("RuleAppoint:")), 0, 0);
|
layout->addWidget(new QLabel("OffsetSpan:", this), 0, 0);
|
||||||
layout->addWidget(_rule_select, 0, 1, 1, 2);
|
layout->addWidget(this->_offset_enter, 0, 1);
|
||||||
layout->addWidget(new QLabel(tr("SizeAppoint:")), 1, 0);
|
layout->addWidget(this->_delegate_sync, 0, 2);
|
||||||
layout->addWidget(_size_layout_select, 1, 1, 1, 2);
|
layout->addWidget(new QLabel(tr("Delegate:")), 1, 0);
|
||||||
|
layout->addWidget(_rule_select, 1, 1, 1, 2);
|
||||||
|
layout->addWidget(new QLabel(tr("Size:")), 2, 0);
|
||||||
|
layout->addWidget(_size_layout_select, 2, 1, 1, 2);
|
||||||
|
|
||||||
layout->addWidget(_configs_stack, 2, 0, 2, 3);
|
layout->addWidget(_configs_stack, 3, 0, 2, 3);
|
||||||
_configs_stack->addWidget(_const_number_input);
|
_configs_stack->addWidget(_const_number_input);
|
||||||
_configs_stack->addWidget(_prev_field_refer);
|
_configs_stack->addWidget(_prev_field_refer);
|
||||||
|
|
||||||
layout->setRowStretch(4, 1);
|
layout->addWidget(this->_content_display, 5, 0, 3, 3);
|
||||||
|
|
||||||
|
layout->setRowStretch(7, 1);
|
||||||
layout->setColumnStretch(1, 1);
|
layout->setColumnStretch(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListBasedConfiguration::currentAccept(std::shared_ptr<ExtractUnit> inst_u, const QModelIndex& idx)
|
||||||
|
{
|
||||||
|
_bind_u = std::dynamic_pointer_cast<ListBasedUnit>(inst_u);
|
||||||
|
_bind_index = idx;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SingleBasedConfiguration::SingleBasedConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p /*= nullptr*/)
|
SingleBasedConfiguration::SingleBasedConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p /*= nullptr*/)
|
||||||
: QWidget(p), _bind_core(core),
|
: QWidget(p), _bind_core(core),
|
||||||
|
@ -162,8 +183,12 @@ SingleBasedConfiguration::SingleBasedConfiguration(std::shared_ptr<TranslateBasi
|
||||||
});
|
});
|
||||||
connect(this->_delegate_changed, QOverload<const QString&>::of(&QComboBox::currentTextChanged),
|
connect(this->_delegate_changed, QOverload<const QString&>::of(&QComboBox::currentTextChanged),
|
||||||
[=](const QString& current_alias) {
|
[=](const QString& current_alias) {
|
||||||
auto vinst = _bind_core->operator[](current_alias)->newDefault();
|
auto o_inst = _bind_core->operator[](current_alias);
|
||||||
inst_current->setDelegate(std::dynamic_pointer_cast<ExtractDelegate>(vinst));
|
auto v_inst = o_inst->newDefault();
|
||||||
|
QJsonObject content;
|
||||||
|
o_inst->saveTo(content);
|
||||||
|
v_inst->loadFrom(_bind_core, content);
|
||||||
|
inst_current->setDelegate(std::dynamic_pointer_cast<ExtractDelegate>(v_inst));
|
||||||
emit this->reloadRequest();
|
emit this->reloadRequest();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -194,3 +219,8 @@ UnionBasedConfiguration::UnionBasedConfiguration(std::shared_ptr<TranslateBasic>
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnionBasedConfiguration::currentAccept(std::shared_ptr<ExtractUnit> inst_u, const QModelIndex& idx)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -12,10 +12,6 @@
|
||||||
#include "extract_basic.h"
|
#include "extract_basic.h"
|
||||||
#include "TranslateBasic.h"
|
#include "TranslateBasic.h"
|
||||||
|
|
||||||
namespace extract {
|
|
||||||
class SingleBasedUnit;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace unit_configurations {
|
namespace unit_configurations {
|
||||||
class SingleBasedConfiguration : public QWidget {
|
class SingleBasedConfiguration : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -44,23 +40,35 @@ namespace unit_configurations {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<TranslateBasic> _bind_core;
|
std::shared_ptr<TranslateBasic> _bind_core;
|
||||||
std::shared_ptr<extract::ListBasedUnit> _bind_u;
|
QSpinBox* const _offset_enter;
|
||||||
QModelIndex _bind_index;
|
QPushButton* const _delegate_sync;
|
||||||
|
|
||||||
QComboBox* const _rule_select;
|
QComboBox* const _rule_select;
|
||||||
QComboBox* const _size_layout_select;
|
QComboBox* const _size_layout_select;
|
||||||
|
|
||||||
QStackedWidget* const _configs_stack;
|
QStackedWidget* const _configs_stack;
|
||||||
|
QTextBrowser* const _content_display;
|
||||||
|
|
||||||
QSpinBox* const _const_number_input;
|
QSpinBox* const _const_number_input;
|
||||||
QComboBox* const _prev_field_refer;
|
QComboBox* const _prev_field_refer;
|
||||||
|
|
||||||
|
std::shared_ptr<extract::ListBasedUnit> _bind_u = nullptr;
|
||||||
|
QModelIndex _bind_index;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ListBasedConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
ListBasedConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
||||||
|
void currentAccept(std::shared_ptr<ExtractUnit> inst_u, const QModelIndex& idx);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void reloadRequest();
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnionBasedConfiguration : public QWidget {
|
class UnionBasedConfiguration : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
UnionBasedConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
UnionBasedConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
||||||
|
void currentAccept(std::shared_ptr<ExtractUnit> inst_u, const QModelIndex& idx);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void reloadRequest();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +93,6 @@ public:
|
||||||
void appendUnit();
|
void appendUnit();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *e) override;
|
void showEvent(QShowEvent* e) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ void WrapConfigs::dataChanged(QStandardItem* cell)
|
||||||
auto origin_key = total_alias_set.at(cell->row());
|
auto origin_key = total_alias_set.at(cell->row());
|
||||||
|
|
||||||
auto new_type = cell->text();
|
auto new_type = cell->text();
|
||||||
auto new_ins = _bind_base->extractUnitTypeMap()[new_type]->newDefault();
|
auto new_ins = _bind_base->extractDelegateTypeMap()[new_type]->newDefault();
|
||||||
auto new_delegate = std::dynamic_pointer_cast<ExtractDelegate>(new_ins);
|
auto new_delegate = std::dynamic_pointer_cast<ExtractDelegate>(new_ins);
|
||||||
new_delegate->setAlias(origin_key);
|
new_delegate->setAlias(origin_key);
|
||||||
_bind_base->replaceDelegate(origin_key, new_delegate);
|
_bind_base->replaceDelegate(origin_key, new_delegate);
|
||||||
|
@ -197,7 +197,7 @@ QWidget* RuleSelectDelegate::createEditor(QWidget* parent, const QStyleOptionVie
|
||||||
|
|
||||||
void RuleSelectDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
void RuleSelectDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
auto rule_names = this->_kernel->extractUnitTypeMap().keys();
|
auto rule_names = this->_kernel->extractDelegateTypeMap().keys();
|
||||||
std::sort(rule_names.begin(), rule_names.end());
|
std::sort(rule_names.begin(), rule_names.end());
|
||||||
|
|
||||||
auto combo = dynamic_cast<QComboBox*>(editor);
|
auto combo = dynamic_cast<QComboBox*>(editor);
|
||||||
|
|
|
@ -675,7 +675,7 @@ std::shared_ptr<Serializable> ListBasedUnit::newDefault() const
|
||||||
|
|
||||||
QString ListBasedUnit::baseType() const
|
QString ListBasedUnit::baseType() const
|
||||||
{
|
{
|
||||||
return NAME(ListBasedUnit);
|
return topic();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SizeProvider> ListBasedUnit::sizeProvider() const
|
std::shared_ptr<SizeProvider> ListBasedUnit::sizeProvider() const
|
||||||
|
@ -688,6 +688,11 @@ void ListBasedUnit::setSizeProvider(std::shared_ptr<SizeProvider> inst)
|
||||||
_list.size_provider_inst = inst;
|
_list.size_provider_inst = inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ListBasedUnit::topic()
|
||||||
|
{
|
||||||
|
return NAME(ListBasedUnit);
|
||||||
|
}
|
||||||
|
|
||||||
void UnionBasedUnit::updateMatch(int index, std::shared_ptr<RuleMatch> rule)
|
void UnionBasedUnit::updateMatch(int index, std::shared_ptr<RuleMatch> rule)
|
||||||
{
|
{
|
||||||
auto nidx = std::min(std::max(0, index), _union.rulematch_list.size() - 1);
|
auto nidx = std::min(std::max(0, index), _union.rulematch_list.size() - 1);
|
||||||
|
@ -706,7 +711,7 @@ void UnionBasedUnit::clearRules()
|
||||||
|
|
||||||
QString UnionBasedUnit::baseType() const
|
QString UnionBasedUnit::baseType() const
|
||||||
{
|
{
|
||||||
return NAME(UnionBasedUnit);
|
return topic();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UnionBasedUnit::name() const
|
QString UnionBasedUnit::name() const
|
||||||
|
@ -765,7 +770,7 @@ void UnionBasedUnit::loadFrom(std::shared_ptr<TranslateBasic> core, const QJsonO
|
||||||
auto rule_obj = array.at(index);
|
auto rule_obj = array.at(index);
|
||||||
QString match_type;
|
QString match_type;
|
||||||
STRING_PEAK(match_type, rule_obj);
|
STRING_PEAK(match_type, rule_obj);
|
||||||
|
|
||||||
auto ninst = core->ruleMatchMap()[match_type]->newDefault();
|
auto ninst = core->ruleMatchMap()[match_type]->newDefault();
|
||||||
QJsonObject content_obj;
|
QJsonObject content_obj;
|
||||||
OBJECT_PEAK(content_obj, rule_obj);
|
OBJECT_PEAK(content_obj, rule_obj);
|
||||||
|
@ -803,3 +808,8 @@ void UnionBasedUnit::setCountWithin(int count)
|
||||||
{
|
{
|
||||||
_union.bytes_count = count;
|
_union.bytes_count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString UnionBasedUnit::topic()
|
||||||
|
{
|
||||||
|
return NAME(UnionBasedUnit);
|
||||||
|
}
|
||||||
|
|
|
@ -324,6 +324,7 @@ namespace extract {
|
||||||
std::shared_ptr<ExtractDelegate> delegateInst() const;
|
std::shared_ptr<ExtractDelegate> delegateInst() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static QString topic();
|
||||||
QString baseType() const;
|
QString baseType() const;
|
||||||
QString name() const override;
|
QString name() const override;
|
||||||
void setName(const QString& name) override;
|
void setName(const QString& name) override;
|
||||||
|
@ -356,6 +357,7 @@ namespace extract {
|
||||||
void setCountWithin(int count);
|
void setCountWithin(int count);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static QString topic();
|
||||||
QString baseType() const override;
|
QString baseType() const override;
|
||||||
void registSubField(std::shared_ptr<ScopeFieldsSetter> inst) override;
|
void registSubField(std::shared_ptr<ScopeFieldsSetter> inst) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue