framework turns start
This commit is contained in:
parent
60b9820a54
commit
ed89fb49bd
|
@ -0,0 +1,63 @@
|
||||||
|
#include "ExtractRuleView.h"
|
||||||
|
#include "TranslateBasic.h"
|
||||||
|
#include "extract_basic.h"
|
||||||
|
#include "WrapConfigs.h"
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
using namespace unit_configurations;
|
||||||
|
using namespace size_provider;
|
||||||
|
|
||||||
|
ExtractRuleView::ExtractRuleView(std::shared_ptr<TranslateBasic> base,
|
||||||
|
std::shared_ptr<extract::AsRuleSet> inst_r, QWidget* p /*= nullptr*/)
|
||||||
|
: QWidget(p), _rule_base(inst_r),
|
||||||
|
_member_units(new QTableView(this)),
|
||||||
|
_member_model(new QStandardItemModel(this)),
|
||||||
|
_configs_stack(new QStackedWidget(this))
|
||||||
|
{
|
||||||
|
this->_current_fields_cache = std::make_shared<FieldManagerLayer>("", nullptr);
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout(this);
|
||||||
|
auto split = new QSplitter(Qt::Horizontal, this);
|
||||||
|
layout->addWidget(split);
|
||||||
|
|
||||||
|
split->addWidget(_member_units);
|
||||||
|
split->addWidget(_configs_stack);
|
||||||
|
|
||||||
|
_configs_stack->addWidget(new configurations::EmptyConfiguration(this));
|
||||||
|
auto single_configs = new SingleBasedConfiguration(base, this);
|
||||||
|
auto list_configs = new ListBasedConfiguration(base, this);
|
||||||
|
auto union_configs = new UnionBasedConfiguration(base, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
ListBasedConfiguration::ListBasedConfiguration(
|
||||||
|
std::shared_ptr<TranslateBasic> core, QWidget* p /*= nullptr*/)
|
||||||
|
:QWidget(p), _bind_core(core), _bind_u(nullptr),
|
||||||
|
|
||||||
|
_rule_select(new QComboBox(this)),
|
||||||
|
_size_layout_select(new QComboBox(this)),
|
||||||
|
|
||||||
|
_configs_stack(new QStackedWidget(this)),
|
||||||
|
_const_number_input(new QSpinBox(this)),
|
||||||
|
_prev_field_refer(new QComboBox(this))
|
||||||
|
{
|
||||||
|
auto layout = new QGridLayout(this);
|
||||||
|
layout->addWidget(new QLabel(tr("RuleAppoint:")), 0, 0);
|
||||||
|
layout->addWidget(_rule_select, 0, 1, 1, 2);
|
||||||
|
layout->addWidget(new QLabel(tr("SizeAppoint:")), 1, 0);
|
||||||
|
layout->addWidget(_size_layout_select, 1, 1, 1, 2);
|
||||||
|
|
||||||
|
layout->addWidget(_configs_stack, 2, 0, 2, 3);
|
||||||
|
_configs_stack->addWidget(_const_number_input);
|
||||||
|
_configs_stack->addWidget(_prev_field_refer);
|
||||||
|
|
||||||
|
layout->setRowStretch(4, 1);
|
||||||
|
layout->setColumnStretch(1, 1);
|
||||||
|
}
|
|
@ -7,19 +7,23 @@
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include "SequenceView.h"
|
|
||||||
#include "extract_basic.h"
|
#include "extract_basic.h"
|
||||||
|
#include "TranslateBasic.h"
|
||||||
|
|
||||||
namespace configuration_panel {
|
namespace unit_configurations {
|
||||||
|
class SingleBasedConfiguration : public QWidget {
|
||||||
|
public:
|
||||||
|
SingleBasedConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Áбí×Ö¶ÎÅäÖÃÃæ°å
|
/// Áбí×Ö¶ÎÅäÖÃÃæ°å
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class ListUnitConfiguration : public QWidget {
|
class ListBasedConfiguration : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<TranslateBasic> _bind_core;
|
std::shared_ptr<TranslateBasic> _bind_core;
|
||||||
std::shared_ptr<extract::AsList> _bind_u;
|
std::shared_ptr<extract::ListBasedUnit> _bind_u;
|
||||||
QModelIndex _bind_index;
|
QModelIndex _bind_index;
|
||||||
|
|
||||||
QComboBox* const _rule_select;
|
QComboBox* const _rule_select;
|
||||||
|
@ -35,24 +39,20 @@ namespace configuration_panel {
|
||||||
void fieldProviderBind(const QString &typeAlias);
|
void fieldProviderBind(const QString &typeAlias);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ListUnitConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
ListBasedConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
void currentRuleAccept(
|
class UnionBasedConfiguration : public QWidget {
|
||||||
std::shared_ptr<ExtractImpl> u,
|
public:
|
||||||
const QModelIndex& i,
|
UnionBasedConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
||||||
std::shared_ptr<ScopeFieldsGetter> getter);
|
|
||||||
void reloadContent(std::shared_ptr<extract::AsList> u,
|
|
||||||
std::shared_ptr<ScopeFieldsGetter> getter);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void currentRuleChanged(const QModelIndex& idx);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExtractRuleView : public QWidget
|
class ExtractRuleView : public QWidget
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
RuleSetCustom* const _sequence_view;
|
QTableView *const _member_units;
|
||||||
|
QStandardItemModel *const _member_model;
|
||||||
QStackedWidget* const _configs_stack;
|
QStackedWidget* const _configs_stack;
|
||||||
|
|
||||||
std::shared_ptr<extract::AsRuleSet> _rule_base;
|
std::shared_ptr<extract::AsRuleSet> _rule_base;
|
||||||
|
@ -61,7 +61,5 @@ private:
|
||||||
public:
|
public:
|
||||||
ExtractRuleView(std::shared_ptr<TranslateBasic> base,
|
ExtractRuleView(std::shared_ptr<TranslateBasic> base,
|
||||||
std::shared_ptr<extract::AsRuleSet> inst_r, QWidget* p = nullptr);
|
std::shared_ptr<extract::AsRuleSet> inst_r, QWidget* p = nullptr);
|
||||||
|
|
||||||
void cacheRefresh(const QModelIndex& curr, configuration_panel::ListUnitConfiguration* t);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,238 +0,0 @@
|
||||||
#include "StructuralRuleView.h"
|
|
||||||
#include "TranslateBasic.h"
|
|
||||||
#include "extract_basic.h"
|
|
||||||
#include <QGridLayout>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QSplitter>
|
|
||||||
#include <QGroupBox>
|
|
||||||
#include <QTabWidget>
|
|
||||||
#include <QTextCodec>
|
|
||||||
#include <QHeaderView>
|
|
||||||
|
|
||||||
using namespace configuration_panel;
|
|
||||||
using namespace size_provider;
|
|
||||||
|
|
||||||
ExtractRuleView::ExtractRuleView(std::shared_ptr<TranslateBasic> base,
|
|
||||||
std::shared_ptr<extract::AsRuleSet> inst_r, QWidget* p /*= nullptr*/)
|
|
||||||
: QWidget(p), _rule_base(inst_r),
|
|
||||||
_sequence_view(new RuleSetCustom(base, inst_r, this)),
|
|
||||||
_configs_stack(new QStackedWidget(this))
|
|
||||||
{
|
|
||||||
this->_current_fields_cache = std::make_shared<FieldManagerLayer>("", nullptr);
|
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this);
|
|
||||||
auto split = new QSplitter(Qt::Horizontal, this);
|
|
||||||
layout->addWidget(split);
|
|
||||||
|
|
||||||
split->addWidget(_sequence_view);
|
|
||||||
split->addWidget(_configs_stack);
|
|
||||||
|
|
||||||
_configs_stack->addWidget(new EmptyConfiguration(this));
|
|
||||||
auto count_span = new CountWithinConfiguration(this);
|
|
||||||
_configs_stack->addWidget(count_span);
|
|
||||||
auto encode_config = new EncodingConfiguration(this);
|
|
||||||
_configs_stack->addWidget(encode_config);
|
|
||||||
auto combine_config = new BitCombineConfiguration(this);
|
|
||||||
_configs_stack->addWidget(combine_config);
|
|
||||||
auto list_config = new ListUnitConfiguration(base, this);
|
|
||||||
_configs_stack->addWidget(list_config);
|
|
||||||
|
|
||||||
connect(count_span, &CountWithinConfiguration::currentRuleChanged,
|
|
||||||
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
|
||||||
connect(encode_config, &EncodingConfiguration::currentRuleChanged,
|
|
||||||
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
|
||||||
connect(combine_config, &BitCombineConfiguration::currentRuleChanged,
|
|
||||||
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
|
||||||
connect(list_config, &ListUnitConfiguration::currentRuleChanged,
|
|
||||||
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
|
||||||
|
|
||||||
connect(_sequence_view, &RuleSetCustom::currentRuleChanged,
|
|
||||||
[=](std::shared_ptr<ExtractImpl> u, const QModelIndex& i) {
|
|
||||||
switch (u->outType()) {
|
|
||||||
case DataType::TextString:
|
|
||||||
if (typeid(*u.get()) == typeid(extract::AsString)) {
|
|
||||||
_configs_stack->setCurrentIndex(2);
|
|
||||||
encode_config->currentRuleAccept(u, i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (typeid(*u.get()) == typeid(extract::AsBitCombine)) {
|
|
||||||
_configs_stack->setCurrentIndex(3);
|
|
||||||
combine_config->currentRuleAccept(u, i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DataType::Integer:
|
|
||||||
case DataType::Unsigned:
|
|
||||||
_configs_stack->setCurrentIndex(1);
|
|
||||||
count_span->currentRuleAccept(u, i);
|
|
||||||
break;
|
|
||||||
case DataType::LIST_COLLECTION:
|
|
||||||
_configs_stack->setCurrentIndex(4);
|
|
||||||
cacheRefresh(i, list_config);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_configs_stack->setCurrentIndex(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtractRuleView::cacheRefresh(const QModelIndex& curr, ListUnitConfiguration* t)
|
|
||||||
{
|
|
||||||
if (!curr.isValid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
this->_current_fields_cache->clear();
|
|
||||||
this->_rule_base->registSubField(this->_current_fields_cache);
|
|
||||||
|
|
||||||
auto field_idx = curr.sibling(curr.row(), 0);
|
|
||||||
this->_current_fields_cache->bindCurrent(field_idx.data(Qt::DisplayRole).toString());
|
|
||||||
|
|
||||||
auto ins = this->_rule_base->operator[](curr.row());
|
|
||||||
auto conv = std::dynamic_pointer_cast<extract::AsList>(ins.second);
|
|
||||||
if (conv) {
|
|
||||||
t->currentRuleAccept(conv, curr, this->_current_fields_cache);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CUSTOM_RULE 0
|
|
||||||
#define BASIC_RULE 1
|
|
||||||
ListUnitConfiguration::ListUnitConfiguration(
|
|
||||||
std::shared_ptr<TranslateBasic> core, QWidget* p /*= nullptr*/)
|
|
||||||
:QWidget(p), _bind_core(core), _bind_u(nullptr),
|
|
||||||
|
|
||||||
_rule_select(new QComboBox(this)),
|
|
||||||
_size_layout_select(new QComboBox(this)),
|
|
||||||
|
|
||||||
_configs_stack(new QStackedWidget(this)),
|
|
||||||
_const_number_input(new QSpinBox(this)),
|
|
||||||
_prev_field_refer(new QComboBox(this))
|
|
||||||
{
|
|
||||||
auto layout = new QGridLayout(this);
|
|
||||||
layout->addWidget(new QLabel(tr("RuleAppoint:")), 0, 0);
|
|
||||||
layout->addWidget(_rule_select, 0, 1, 1, 2);
|
|
||||||
layout->addWidget(new QLabel(tr("SizeAppoint:")), 1, 0);
|
|
||||||
layout->addWidget(_size_layout_select, 1, 1, 1, 2);
|
|
||||||
|
|
||||||
layout->addWidget(_configs_stack, 2, 0, 2, 3);
|
|
||||||
_configs_stack->addWidget(_const_number_input);
|
|
||||||
_configs_stack->addWidget(_prev_field_refer);
|
|
||||||
|
|
||||||
layout->setRowStretch(4, 1);
|
|
||||||
layout->setColumnStretch(1, 1);
|
|
||||||
|
|
||||||
for (auto key : this->_bind_core->customDelegates().keys())
|
|
||||||
_rule_select->addItem(key, CUSTOM_RULE);
|
|
||||||
for (auto key : this->_bind_core->extractUnitList().keys())
|
|
||||||
if (!QList<QString>{"AsList", "AsUnion", "AsRuleSet"}.contains(key))
|
|
||||||
_rule_select->addItem(key, BASIC_RULE);
|
|
||||||
|
|
||||||
auto keys = this->_bind_core->sizeProviderList().keys();
|
|
||||||
std::sort(keys.begin(), keys.end());
|
|
||||||
_size_layout_select->addItems(keys);
|
|
||||||
|
|
||||||
connect(_size_layout_select, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
||||||
[=](int idx) {
|
|
||||||
this->_configs_stack->setCurrentIndex(
|
|
||||||
this->_size_layout_select->currentIndex()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
connect(this->_size_layout_select, &QComboBox::currentTextChanged,
|
|
||||||
this, &ListUnitConfiguration::sizeProviderSet);
|
|
||||||
connect(this->_rule_select, &QComboBox::currentTextChanged,
|
|
||||||
this, &ListUnitConfiguration::elmRuleSet);
|
|
||||||
connect(this->_const_number_input, QOverload<int>::of(&QSpinBox::valueChanged),
|
|
||||||
this, &ListUnitConfiguration::constProviderBind);
|
|
||||||
connect(this->_prev_field_refer, &QComboBox::currentTextChanged,
|
|
||||||
this, &ListUnitConfiguration::fieldProviderBind);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListUnitConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u,
|
|
||||||
const QModelIndex& i, std::shared_ptr<ScopeFieldsGetter> getter)
|
|
||||||
{
|
|
||||||
this->_bind_u = std::dynamic_pointer_cast<extract::AsList>(u);
|
|
||||||
this->_bind_index = i;
|
|
||||||
|
|
||||||
reloadContent(this->_bind_u, getter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListUnitConfiguration::reloadContent(std::shared_ptr<extract::AsList> u,
|
|
||||||
std::shared_ptr<ScopeFieldsGetter> getter)
|
|
||||||
{
|
|
||||||
QSignalBlocker v(_rule_select);
|
|
||||||
_rule_select->setCurrentText(u->elementRule()->typeAlias());
|
|
||||||
QSignalBlocker m(_size_layout_select);
|
|
||||||
_size_layout_select->setCurrentText(u->sizeProvider()->typeAlias());
|
|
||||||
QSignalBlocker vll(_prev_field_refer);
|
|
||||||
auto item_list = getter->prevFields();
|
|
||||||
this->_prev_field_refer->clear();
|
|
||||||
this->_prev_field_refer->addItems(item_list.keys());
|
|
||||||
|
|
||||||
auto const_conv = std::dynamic_pointer_cast<ConstNumberProvider>(u->sizeProvider());
|
|
||||||
if (const_conv) {
|
|
||||||
_configs_stack->setCurrentIndex(0);
|
|
||||||
|
|
||||||
QSignalBlocker v(_const_number_input);
|
|
||||||
_const_number_input->setValue(const_conv->value(const_conv->expression()));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto runtime_conv = std::dynamic_pointer_cast<InterpretedNumberPrivider>(u->sizeProvider());
|
|
||||||
if (runtime_conv) {
|
|
||||||
_configs_stack->setCurrentIndex(1);
|
|
||||||
this->_prev_field_refer->setCurrentText(runtime_conv->typeAlias());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListUnitConfiguration::elmRuleSet(const QString& typeAlias)
|
|
||||||
{
|
|
||||||
auto type_mark = this->_rule_select->currentData().toInt();
|
|
||||||
switch (type_mark) {
|
|
||||||
case CUSTOM_RULE: {
|
|
||||||
auto target_rule = this->_bind_core->customDelegates()[typeAlias];
|
|
||||||
_bind_u->setElementRule(target_rule);
|
|
||||||
}break;
|
|
||||||
default: {
|
|
||||||
auto target_unit = this->_bind_core->extractUnitList()[typeAlias];
|
|
||||||
_bind_u->setElementRule(target_unit);
|
|
||||||
}break;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit this->currentRuleChanged(this->_bind_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListUnitConfiguration::sizeProviderSet(const QString& typeAlias)
|
|
||||||
{
|
|
||||||
if (typeAlias == this->_bind_u->sizeProvider()->typeAlias())
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto ninst = this->_bind_core->sizeProviderList()[typeAlias]->newDefault();
|
|
||||||
this->_bind_u->setSizeProvider(std::dynamic_pointer_cast<SizeProvider>(ninst));
|
|
||||||
|
|
||||||
auto u = this->_bind_u;
|
|
||||||
auto const_conv = std::dynamic_pointer_cast<ConstNumberProvider>(u->sizeProvider());
|
|
||||||
if (const_conv) {
|
|
||||||
_configs_stack->setCurrentIndex(0);
|
|
||||||
_const_number_input->setValue(const_conv->value(const_conv->expression()));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto runtime_conv = std::dynamic_pointer_cast<InterpretedNumberPrivider>(u->sizeProvider());
|
|
||||||
if (runtime_conv) {
|
|
||||||
_configs_stack->setCurrentIndex(1);
|
|
||||||
this->_prev_field_refer->setCurrentText(runtime_conv->typeAlias());
|
|
||||||
}
|
|
||||||
|
|
||||||
emit this->currentRuleChanged(this->_bind_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListUnitConfiguration::fieldProviderBind(const QString& typeAlias)
|
|
||||||
{
|
|
||||||
this->_bind_u->sizeProvider()->setExpression(typeAlias);
|
|
||||||
emit this->currentRuleChanged(this->_bind_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListUnitConfiguration::constProviderBind(int value)
|
|
||||||
{
|
|
||||||
this->_bind_u->sizeProvider()->setExpression(QString("%1").arg(value));
|
|
||||||
emit this->currentRuleChanged(this->_bind_index);
|
|
||||||
}
|
|
|
@ -95,19 +95,19 @@
|
||||||
<ClCompile Include="common.cpp" />
|
<ClCompile Include="common.cpp" />
|
||||||
<ClCompile Include="convert_basic.cpp" />
|
<ClCompile Include="convert_basic.cpp" />
|
||||||
<ClCompile Include="extract_basic.cpp" />
|
<ClCompile Include="extract_basic.cpp" />
|
||||||
|
<ClCompile Include="ExtractRuleView.cpp" />
|
||||||
<ClCompile Include="TranslateBasic.cpp" />
|
<ClCompile Include="TranslateBasic.cpp" />
|
||||||
<ClCompile Include="WrapConfigs.cpp" />
|
<ClCompile Include="WrapConfigs.cpp" />
|
||||||
<QtRcc Include="TranslateUI.qrc" />
|
<QtRcc Include="TranslateUI.qrc" />
|
||||||
<QtUic Include="TranslateUI.ui" />
|
<QtUic Include="TranslateUI.ui" />
|
||||||
<ClCompile Include="ParseUntility.cpp" />
|
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="common.h" />
|
<ClInclude Include="common.h" />
|
||||||
<ClInclude Include="convert_basic.h" />
|
<ClInclude Include="convert_basic.h" />
|
||||||
<ClInclude Include="extract_basic.h" />
|
<ClInclude Include="extract_basic.h" />
|
||||||
<ClInclude Include="ParseUntility.h" />
|
|
||||||
<QtMoc Include="WrapConfigs.h" />
|
<QtMoc Include="WrapConfigs.h" />
|
||||||
|
<QtMoc Include="ExtractRuleView.h" />
|
||||||
<ClInclude Include="TranslateBasic.h" />
|
<ClInclude Include="TranslateBasic.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue