完善基础提取单元配置
This commit is contained in:
parent
9171ae8786
commit
f0109e0ba2
|
|
@ -10,412 +10,229 @@
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
//
|
|
||||||
//using namespace configuration_panel;
|
using namespace configuration_panel;
|
||||||
//using namespace size_provider;
|
using namespace size_provider;
|
||||||
//
|
|
||||||
//
|
ExtractRuleView::ExtractRuleView(std::shared_ptr<TranslateBasic> base,
|
||||||
//ExtractRuleView::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*/)
|
: QWidget(p), _rule_base(inst_r),
|
||||||
// : QWidget(p), _rule_base(inst_r),
|
_sequence_view(new RuleSetCustom(base, inst_r, this)),
|
||||||
// _sequence_view(new RuleSetCustom(base, inst_r, this)),
|
_configs_stack(new QStackedWidget(this))
|
||||||
// _configs_stack(new QStackedWidget(this))
|
{
|
||||||
//{
|
this->_current_fields_cache = std::make_shared<FieldManagerLayer>("", nullptr);
|
||||||
// this->_current_fields_cache = std::make_shared<FieldManagerLayer>("", nullptr);
|
|
||||||
//
|
auto layout = new QVBoxLayout(this);
|
||||||
// auto layout = new QVBoxLayout(this);
|
auto split = new QSplitter(Qt::Horizontal, this);
|
||||||
// auto split = new QSplitter(Qt::Horizontal, this);
|
layout->addWidget(split);
|
||||||
// layout->addWidget(split);
|
|
||||||
//
|
split->addWidget(_sequence_view);
|
||||||
// split->addWidget(_sequence_view);
|
split->addWidget(_configs_stack);
|
||||||
// split->addWidget(_configs_stack);
|
|
||||||
//
|
_configs_stack->addWidget(new EmptyConfiguration(this));
|
||||||
// _configs_stack->addWidget(new EmptyConfiguration(this));
|
auto count_span = new CountWithinConfiguration(this);
|
||||||
// auto count_span = new CountWithinConfiguration(this);
|
_configs_stack->addWidget(count_span);
|
||||||
// _configs_stack->addWidget(count_span);
|
auto encode_config = new EncodingConfiguration(this);
|
||||||
// auto encode_config = new EncodingConfiguration(this);
|
_configs_stack->addWidget(encode_config);
|
||||||
// _configs_stack->addWidget(encode_config);
|
auto combine_config = new BitCombineConfiguration(this);
|
||||||
// auto combine_config = new BitCombineConfiguration(this);
|
_configs_stack->addWidget(combine_config);
|
||||||
// _configs_stack->addWidget(combine_config);
|
auto list_config = new ListUnitConfiguration(base, this);
|
||||||
// auto list_config = new ListUnitConfiguration(base, this);
|
_configs_stack->addWidget(list_config);
|
||||||
// _configs_stack->addWidget(list_config);
|
|
||||||
//
|
connect(count_span, &CountWithinConfiguration::currentRuleChanged,
|
||||||
// connect(count_span, &CountWithinConfiguration::currentRuleChanged,
|
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
||||||
// _sequence_view, &RuleSetCustom::targetRuleRefresh);
|
connect(encode_config, &EncodingConfiguration::currentRuleChanged,
|
||||||
// connect(encode_config, &EncodingConfiguration::currentRuleChanged,
|
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
||||||
// _sequence_view, &RuleSetCustom::targetRuleRefresh);
|
connect(combine_config, &BitCombineConfiguration::currentRuleChanged,
|
||||||
// connect(combine_config, &BitCombineConfiguration::currentRuleChanged,
|
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
||||||
// _sequence_view, &RuleSetCustom::targetRuleRefresh);
|
connect(list_config, &ListUnitConfiguration::currentRuleChanged,
|
||||||
// connect(list_config, &ListUnitConfiguration::currentRuleChanged,
|
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
||||||
// _sequence_view, &RuleSetCustom::targetRuleRefresh);
|
|
||||||
//
|
connect(_sequence_view, &RuleSetCustom::currentRuleChanged,
|
||||||
// connect(_sequence_view, &RuleSetCustom::currentRuleChanged,
|
[=](std::shared_ptr<ExtractImpl> u, const QModelIndex& i) {
|
||||||
// [=](std::shared_ptr<ExtractImpl> u, const QModelIndex& i) {
|
switch (u->outType()) {
|
||||||
// switch (u->outType()) {
|
case DataType::TextString:
|
||||||
// case DataType::TextString:
|
if (typeid(*u.get()) == typeid(extract::AsString)) {
|
||||||
// if (typeid(*u.get()) == typeid(extract::AsString)) {
|
_configs_stack->setCurrentIndex(2);
|
||||||
// _configs_stack->setCurrentIndex(2);
|
encode_config->currentRuleAccept(u, i);
|
||||||
// encode_config->currentRuleAccept(u, i);
|
break;
|
||||||
// break;
|
}
|
||||||
// }
|
else if (typeid(*u.get()) == typeid(extract::AsBitCombine)) {
|
||||||
// else if (typeid(*u.get()) == typeid(extract::AsBitCombine)) {
|
_configs_stack->setCurrentIndex(3);
|
||||||
// _configs_stack->setCurrentIndex(3);
|
combine_config->currentRuleAccept(u, i);
|
||||||
// combine_config->currentRuleAccept(u, i);
|
break;
|
||||||
// break;
|
}
|
||||||
// }
|
case DataType::Integer:
|
||||||
// case DataType::Integer:
|
case DataType::Unsigned:
|
||||||
// case DataType::Unsigned:
|
_configs_stack->setCurrentIndex(1);
|
||||||
// _configs_stack->setCurrentIndex(1);
|
count_span->currentRuleAccept(u, i);
|
||||||
// count_span->currentRuleAccept(u, i);
|
break;
|
||||||
// break;
|
case DataType::LIST_COLLECTION:
|
||||||
// case DataType::LIST_COLLECTION:
|
_configs_stack->setCurrentIndex(4);
|
||||||
// _configs_stack->setCurrentIndex(4);
|
cacheRefresh(i, list_config);
|
||||||
// cacheRefresh(i, list_config);
|
break;
|
||||||
// break;
|
default:
|
||||||
// default:
|
_configs_stack->setCurrentIndex(0);
|
||||||
// _configs_stack->setCurrentIndex(0);
|
break;
|
||||||
// break;
|
}
|
||||||
// }
|
});
|
||||||
// });
|
}
|
||||||
//}
|
|
||||||
//
|
void ExtractRuleView::cacheRefresh(const QModelIndex& curr, ListUnitConfiguration* t)
|
||||||
//void ExtractRuleView::cacheRefresh(const QModelIndex& curr, ListUnitConfiguration* t)
|
{
|
||||||
//{
|
if (!curr.isValid())
|
||||||
// if (!curr.isValid())
|
return;
|
||||||
// return;
|
|
||||||
//
|
this->_current_fields_cache->clear();
|
||||||
// this->_current_fields_cache->clear();
|
this->_rule_base->registSubField(this->_current_fields_cache);
|
||||||
// this->_rule_base->registSubField(this->_current_fields_cache);
|
|
||||||
//
|
auto field_idx = curr.sibling(curr.row(), 0);
|
||||||
// auto field_idx = curr.sibling(curr.row(), 0);
|
this->_current_fields_cache->bindCurrent(field_idx.data(Qt::DisplayRole).toString());
|
||||||
// this->_current_fields_cache->bindCurrent(field_idx.data(Qt::DisplayRole).toString());
|
|
||||||
//
|
auto ins = this->_rule_base->operator[](curr.row());
|
||||||
// auto ins = this->_rule_base->operator[](curr.row());
|
auto conv = std::dynamic_pointer_cast<extract::AsList>(ins.second);
|
||||||
// auto conv = std::dynamic_pointer_cast<extract::AsList>(ins.second);
|
if (conv) {
|
||||||
// if (conv) {
|
t->currentRuleAccept(conv, curr, this->_current_fields_cache);
|
||||||
// t->currentRuleAccept(conv, curr, this->_current_fields_cache);
|
}
|
||||||
// }
|
}
|
||||||
//}
|
|
||||||
//
|
#define CUSTOM_RULE 0
|
||||||
//EmptyConfiguration::EmptyConfiguration(QWidget* p/*=nullptr*/)
|
#define BASIC_RULE 1
|
||||||
//{
|
ListUnitConfiguration::ListUnitConfiguration(
|
||||||
// auto layout = new QVBoxLayout(this);
|
std::shared_ptr<TranslateBasic> core, QWidget* p /*= nullptr*/)
|
||||||
// auto label = new QLabel(u8"Can't Configurate.", this);
|
:QWidget(p), _bind_core(core), _bind_u(nullptr),
|
||||||
// label->setAlignment(Qt::AlignCenter);
|
|
||||||
// layout->addWidget(label);
|
_rule_select(new QComboBox(this)),
|
||||||
//}
|
_size_layout_select(new QComboBox(this)),
|
||||||
//
|
|
||||||
//CountWithinConfiguration::CountWithinConfiguration(QWidget* p /*= nullptr*/)
|
_configs_stack(new QStackedWidget(this)),
|
||||||
// : QWidget(p), _bind_u(nullptr), _count_input(new QSpinBox(this))
|
_const_number_input(new QSpinBox(this)),
|
||||||
//{
|
_prev_field_refer(new QComboBox(this))
|
||||||
// auto layout = new QGridLayout(this);
|
{
|
||||||
// layout->addWidget(new QLabel(tr("BytesCount:")));
|
auto layout = new QGridLayout(this);
|
||||||
// layout->addWidget(_count_input, 0, 1);
|
layout->addWidget(new QLabel(tr("RuleAppoint:")), 0, 0);
|
||||||
// _count_input->setRange(1, 100);
|
layout->addWidget(_rule_select, 0, 1, 1, 2);
|
||||||
// layout->setRowStretch(1, 1);
|
layout->addWidget(new QLabel(tr("SizeAppoint:")), 1, 0);
|
||||||
// layout->setColumnStretch(1, 1);
|
layout->addWidget(_size_layout_select, 1, 1, 1, 2);
|
||||||
//
|
|
||||||
// connect(_count_input, QOverload<int>::of(&QSpinBox::valueChanged), [=](int value) {
|
layout->addWidget(_configs_stack, 2, 0, 2, 3);
|
||||||
// if (this->_bind_u) {
|
_configs_stack->addWidget(_const_number_input);
|
||||||
// auto ptr = std::dynamic_pointer_cast<extract::AbstractExtractor>(this->_bind_u);
|
_configs_stack->addWidget(_prev_field_refer);
|
||||||
// if (ptr) {
|
|
||||||
// ptr->setCountWithin(value);
|
layout->setRowStretch(4, 1);
|
||||||
// emit this->currentRuleChanged(_bind_index);
|
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))
|
||||||
//void CountWithinConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i)
|
_rule_select->addItem(key, BASIC_RULE);
|
||||||
//{
|
|
||||||
// this->_bind_u = u;
|
auto keys = this->_bind_core->sizeProviderList().keys();
|
||||||
// this->_bind_index = i;
|
std::sort(keys.begin(), keys.end());
|
||||||
//
|
_size_layout_select->addItems(keys);
|
||||||
// _count_input->setValue(u->countWithin());
|
|
||||||
//}
|
connect(_size_layout_select, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
//
|
[=](int idx) {
|
||||||
//EncodingConfiguration::EncodingConfiguration(QWidget* p /*= nullptr*/)
|
this->_configs_stack->setCurrentIndex(
|
||||||
// : QWidget(p), _bind_u(nullptr), _count_input(new QSpinBox(this)),
|
this->_size_layout_select->currentIndex()
|
||||||
// _encoding_set(new QComboBox(this))
|
);
|
||||||
//{
|
});
|
||||||
// auto layout = new QGridLayout(this);
|
connect(this->_size_layout_select, &QComboBox::currentTextChanged,
|
||||||
// layout->addWidget(new QLabel(tr("BytesCount:")));
|
this, &ListUnitConfiguration::sizeProviderSet);
|
||||||
// layout->addWidget(_count_input, 0, 1);
|
connect(this->_rule_select, &QComboBox::currentTextChanged,
|
||||||
// layout->addWidget(new QLabel(tr("Encoding:")), 1, 0);
|
this, &ListUnitConfiguration::elmRuleSet);
|
||||||
// layout->addWidget(_encoding_set, 1, 1);
|
connect(this->_const_number_input, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||||
// layout->setRowStretch(2, 1);
|
this, &ListUnitConfiguration::constProviderBind);
|
||||||
// layout->setColumnStretch(1, 1);
|
connect(this->_prev_field_refer, &QComboBox::currentTextChanged,
|
||||||
//
|
this, &ListUnitConfiguration::fieldProviderBind);
|
||||||
//
|
}
|
||||||
// connect(_count_input, QOverload<int>::of(&QSpinBox::valueChanged), [=](int value) {
|
|
||||||
// if (this->_bind_u) {
|
void ListUnitConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u,
|
||||||
// auto ptr = std::dynamic_pointer_cast<extract::AbstractExtractor>(this->_bind_u);
|
const QModelIndex& i, std::shared_ptr<ScopeFieldsGetter> getter)
|
||||||
// if (ptr) {
|
{
|
||||||
// ptr->setCountWithin(value);
|
this->_bind_u = std::dynamic_pointer_cast<extract::AsList>(u);
|
||||||
// emit this->currentRuleChanged(_bind_index);
|
this->_bind_index = i;
|
||||||
// }
|
|
||||||
// }
|
reloadContent(this->_bind_u, getter);
|
||||||
// });
|
}
|
||||||
//
|
|
||||||
// auto codec_list = QTextCodec::availableCodecs();
|
void ListUnitConfiguration::reloadContent(std::shared_ptr<extract::AsList> u,
|
||||||
// for (auto codec : codec_list)
|
std::shared_ptr<ScopeFieldsGetter> getter)
|
||||||
// _encoding_set->addItem(QString::fromLatin1(codec));
|
{
|
||||||
// connect(_encoding_set, QOverload<const QString&>::of(&QComboBox::currentIndexChanged),
|
QSignalBlocker v(_rule_select);
|
||||||
// [=](const QString& value) {
|
_rule_select->setCurrentText(u->elementRule()->typeAlias());
|
||||||
// if (this->_bind_u) {
|
QSignalBlocker m(_size_layout_select);
|
||||||
// auto ptr = std::dynamic_pointer_cast<extract::AsString>(this->_bind_u);
|
_size_layout_select->setCurrentText(u->sizeProvider()->typeAlias());
|
||||||
// if (ptr) {
|
QSignalBlocker vll(_prev_field_refer);
|
||||||
// auto insx = QTextCodec::codecForName(value.toUtf8());
|
auto item_list = getter->prevFields();
|
||||||
// ptr->setStrCodec(insx);
|
this->_prev_field_refer->clear();
|
||||||
// emit this->currentRuleChanged(_bind_index);
|
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);
|
||||||
//
|
|
||||||
//void EncodingConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i)
|
QSignalBlocker v(_const_number_input);
|
||||||
//{
|
_const_number_input->setValue(const_conv->value(const_conv->expression()));
|
||||||
// this->_bind_u = u;
|
}
|
||||||
// this->_bind_index = i;
|
|
||||||
//
|
auto runtime_conv = std::dynamic_pointer_cast<InterpretedNumberPrivider>(u->sizeProvider());
|
||||||
// _count_input->setValue(u->countWithin());
|
if (runtime_conv) {
|
||||||
// auto codec_name = std::dynamic_pointer_cast<extract::AsString>(u)->codecName();
|
_configs_stack->setCurrentIndex(1);
|
||||||
//
|
this->_prev_field_refer->setCurrentText(runtime_conv->typeAlias());
|
||||||
// QSignalBlocker x(this->_encoding_set);
|
}
|
||||||
// this->_encoding_set->setCurrentText(codec_name);
|
}
|
||||||
//}
|
|
||||||
//
|
void ListUnitConfiguration::elmRuleSet(const QString& typeAlias)
|
||||||
//BitCombineConfiguration::BitCombineConfiguration(QWidget* p /*= nullptr*/)
|
{
|
||||||
// : QWidget(p), _bind_u(nullptr),
|
auto type_mark = this->_rule_select->currentData().toInt();
|
||||||
// _count_input(new QSpinBox(this)),
|
switch (type_mark) {
|
||||||
// _bit_items(new QTableView(this)),
|
case CUSTOM_RULE: {
|
||||||
// _bit_model(new QStandardItemModel(this)),
|
auto target_rule = this->_bind_core->customDelegates()[typeAlias];
|
||||||
// _index_appoint(new QSpinBox(this)),
|
_bind_u->setElementRule(target_rule);
|
||||||
// _bit_means(new QLineEdit(this))
|
}break;
|
||||||
//{
|
default: {
|
||||||
// auto layout = new QGridLayout(this);
|
auto target_unit = this->_bind_core->extractUnitList()[typeAlias];
|
||||||
// layout->addWidget(new QLabel(tr("BytesCount:")));
|
_bind_u->setElementRule(target_unit);
|
||||||
// layout->addWidget(_count_input, 0, 1, 1, 2);
|
}break;
|
||||||
// auto group_box = new QGroupBox(tr("BitsContent"));
|
}
|
||||||
// layout->addWidget(group_box, 1, 0, 3, 3);
|
|
||||||
// layout->setColumnStretch(1, 1);
|
emit this->currentRuleChanged(this->_bind_index);
|
||||||
//
|
}
|
||||||
// layout = new QGridLayout(group_box);
|
|
||||||
// layout->addWidget(_bit_items, 0, 0, 3, 3);
|
void ListUnitConfiguration::sizeProviderSet(const QString& typeAlias)
|
||||||
//
|
{
|
||||||
// layout->addWidget(new QLabel(tr("Bit Index:")), 3, 0);
|
if (typeAlias == this->_bind_u->sizeProvider()->typeAlias())
|
||||||
// layout->addWidget(_index_appoint, 3, 1, 1, 2);
|
return;
|
||||||
// layout->addWidget(new QLabel(tr("Bit Means:")), 4, 0);
|
|
||||||
// layout->addWidget(_bit_means, 4, 1, 1, 2);
|
auto ninst = this->_bind_core->sizeProviderList()[typeAlias]->newDefault();
|
||||||
//
|
this->_bind_u->setSizeProvider(std::dynamic_pointer_cast<SizeProvider>(ninst));
|
||||||
// auto remove = new QPushButton(tr("RemoveItem"));
|
|
||||||
// layout->addWidget(remove, 5, 1);
|
auto u = this->_bind_u;
|
||||||
// auto append = new QPushButton(tr("AppendNew"));
|
auto const_conv = std::dynamic_pointer_cast<ConstNumberProvider>(u->sizeProvider());
|
||||||
// layout->addWidget(append, 5, 2);
|
if (const_conv) {
|
||||||
//
|
_configs_stack->setCurrentIndex(0);
|
||||||
// layout->setColumnStretch(1, 1);
|
_const_number_input->setValue(const_conv->value(const_conv->expression()));
|
||||||
// layout->setColumnStretch(2, 1);
|
}
|
||||||
//
|
|
||||||
// _bit_items->setModel(this->_bit_model);
|
auto runtime_conv = std::dynamic_pointer_cast<InterpretedNumberPrivider>(u->sizeProvider());
|
||||||
// this->_bit_model->setHorizontalHeaderLabels(QStringList() << tr("No.") << tr("Means"));
|
if (runtime_conv) {
|
||||||
// this->_count_input->setRange(1, 100);
|
_configs_stack->setCurrentIndex(1);
|
||||||
//
|
this->_prev_field_refer->setCurrentText(runtime_conv->typeAlias());
|
||||||
// connect(this->_count_input, QOverload<int>::of(&QSpinBox::valueChanged), [=](int value) {
|
}
|
||||||
// this->_bind_u->setCountWithin(value);
|
|
||||||
// this->_index_appoint->setRange(0, value * 8);
|
emit this->currentRuleChanged(this->_bind_index);
|
||||||
//
|
}
|
||||||
// auto options = this->_bind_u->switchOptions();
|
|
||||||
// this->_bind_u->clearOptions();
|
void ListUnitConfiguration::fieldProviderBind(const QString& typeAlias)
|
||||||
// for (auto key : options.keys()) {
|
{
|
||||||
// if (key > value * 8)
|
this->_bind_u->sizeProvider()->setExpression(typeAlias);
|
||||||
// continue;
|
emit this->currentRuleChanged(this->_bind_index);
|
||||||
//
|
}
|
||||||
// this->_bind_u->setSwitchOption(key, options[key]);
|
|
||||||
// }
|
void ListUnitConfiguration::constProviderBind(int value)
|
||||||
//
|
{
|
||||||
// emit this->currentRuleChanged(_bind_index);
|
this->_bind_u->sizeProvider()->setExpression(QString("%1").arg(value));
|
||||||
// });
|
emit this->currentRuleChanged(this->_bind_index);
|
||||||
//
|
}
|
||||||
// connect(append, &QPushButton::clicked, [=]() {
|
|
||||||
// this->_bind_u->setSwitchOption(
|
|
||||||
// this->_index_appoint->value(), this->_bit_means->text());
|
|
||||||
// this->reloadContent(_bind_u);
|
|
||||||
// emit this->currentRuleChanged(this->_bind_index);
|
|
||||||
// });
|
|
||||||
// connect(remove, &QPushButton::clicked, [=]() {
|
|
||||||
// });
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void BitCombineConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i)
|
|
||||||
//{
|
|
||||||
// this->_bind_u = std::dynamic_pointer_cast<extract::AsBitCombine>(u);;
|
|
||||||
// this->_bind_index = i;
|
|
||||||
//
|
|
||||||
// this->reloadContent(this->_bind_u);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void BitCombineConfiguration::reloadContent(std::shared_ptr<extract::AsBitCombine> u)
|
|
||||||
//{
|
|
||||||
// this->_count_input->setValue(u->countWithin());
|
|
||||||
// this->_index_appoint->setRange(0, u->countWithin() * 8);
|
|
||||||
//
|
|
||||||
// this->_bit_model->removeRows(0, this->_bit_model->rowCount());
|
|
||||||
// auto items = this->_bind_u->switchOptions();
|
|
||||||
// auto keys = items.keys();
|
|
||||||
// std::sort(keys.begin(), keys.end());
|
|
||||||
//
|
|
||||||
// for (auto index : keys) {
|
|
||||||
// auto content = items[index];
|
|
||||||
//
|
|
||||||
// QList<QStandardItem*> row;
|
|
||||||
// row << new QStandardItem(QString("%1").arg(index));
|
|
||||||
// row << new QStandardItem(content);
|
|
||||||
// for (auto i : row) i->setEditable(false);
|
|
||||||
//
|
|
||||||
// this->_bit_model->appendRow(row);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this->_bit_items->resizeColumnsToContents();
|
|
||||||
// this->_bit_items->verticalHeader()->setVisible(false);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//#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);
|
|
||||||
//}
|
|
||||||
|
|
|
||||||
|
|
@ -11,77 +11,6 @@
|
||||||
#include "extract_basic.h"
|
#include "extract_basic.h"
|
||||||
|
|
||||||
namespace configuration_panel {
|
namespace configuration_panel {
|
||||||
/// <summary>
|
|
||||||
/// 空白配置面板
|
|
||||||
/// </summary>
|
|
||||||
class EmptyConfiguration : public QWidget {
|
|
||||||
public:
|
|
||||||
EmptyConfiguration(QWidget* p = nullptr);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 字段长度配置面板
|
|
||||||
/// </summary>
|
|
||||||
class CountWithinConfiguration : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
std::shared_ptr<ExtractImpl> _bind_u;
|
|
||||||
QModelIndex _bind_index;
|
|
||||||
QSpinBox* const _count_input;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CountWithinConfiguration(QWidget* p = nullptr);
|
|
||||||
|
|
||||||
void currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void currentRuleChanged(const QModelIndex& idx);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 字符串文本编码配置面板
|
|
||||||
/// </summary>
|
|
||||||
class EncodingConfiguration : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
std::shared_ptr<ExtractImpl> _bind_u;
|
|
||||||
QModelIndex _bind_index;
|
|
||||||
QSpinBox* const _count_input;
|
|
||||||
QComboBox* const _encoding_set;
|
|
||||||
|
|
||||||
public:
|
|
||||||
EncodingConfiguration(QWidget* p = nullptr);
|
|
||||||
|
|
||||||
void currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void currentRuleChanged(const QModelIndex& idx);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 位联合配置面板
|
|
||||||
/// </summary>
|
|
||||||
class BitCombineConfiguration : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
std::shared_ptr<extract::AsBitCombine> _bind_u;
|
|
||||||
QModelIndex _bind_index;
|
|
||||||
|
|
||||||
QSpinBox* const _count_input;
|
|
||||||
QTableView* const _bit_items;
|
|
||||||
QStandardItemModel* const _bit_model;
|
|
||||||
QSpinBox* const _index_appoint;
|
|
||||||
QLineEdit* const _bit_means;
|
|
||||||
|
|
||||||
public:
|
|
||||||
BitCombineConfiguration(QWidget* p = nullptr);
|
|
||||||
|
|
||||||
void currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i);
|
|
||||||
void reloadContent(std::shared_ptr<extract::AsBitCombine> u);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void currentRuleChanged(const QModelIndex& idx);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Áбí×Ö¶ÎÅäÖÃÃæ°å
|
/// Áбí×Ö¶ÎÅäÖÃÃæ°å
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,6 @@
|
||||||
<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="SequenceView.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" />
|
||||||
|
|
@ -108,7 +107,6 @@
|
||||||
<ClInclude Include="convert_basic.h" />
|
<ClInclude Include="convert_basic.h" />
|
||||||
<ClInclude Include="extract_basic.h" />
|
<ClInclude Include="extract_basic.h" />
|
||||||
<ClInclude Include="ParseUntility.h" />
|
<ClInclude Include="ParseUntility.h" />
|
||||||
<QtMoc Include="SequenceView.h" />
|
|
||||||
<QtMoc Include="WrapConfigs.h" />
|
<QtMoc Include="WrapConfigs.h" />
|
||||||
<ClInclude Include="TranslateBasic.h" />
|
<ClInclude Include="TranslateBasic.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,6 @@
|
||||||
<ClCompile Include="WrapConfigs.cpp">
|
<ClCompile Include="WrapConfigs.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="SequenceView.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="common.cpp">
|
<ClCompile Include="common.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -77,9 +74,6 @@
|
||||||
<None Include="ReadMe.md" />
|
<None Include="ReadMe.md" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="SequenceView.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="WrapConfigs.h">
|
<QtMoc Include="WrapConfigs.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
|
using namespace configurations;
|
||||||
|
|
||||||
WrapConfigs::WrapConfigs(std::shared_ptr<TranslateBasic> _base, QWidget* p)
|
WrapConfigs::WrapConfigs(std::shared_ptr<TranslateBasic> _base, QWidget* p)
|
||||||
: QWidget(p), _bind_base(_base),
|
: QWidget(p), _bind_base(_base),
|
||||||
_alias_view(new QTableView(this)),
|
_alias_view(new QTableView(this)),
|
||||||
|
|
@ -33,6 +35,47 @@ WrapConfigs::WrapConfigs(std::shared_ptr<TranslateBasic> _base, QWidget* p)
|
||||||
menu.exec(_alias_view->mapToGlobal(pt));
|
menu.exec(_alias_view->mapToGlobal(pt));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
auto empty_panel = new EmptyConfiguration(this);
|
||||||
|
auto count_panel = new CountWithinConfiguration(this);
|
||||||
|
auto encode_panel = new EncodingConfiguration(this);
|
||||||
|
auto bitcombine_panel = new BitCombineConfiguration(this);
|
||||||
|
_configurations->addWidget(empty_panel);
|
||||||
|
_configurations->addWidget(count_panel);
|
||||||
|
_configurations->addWidget(encode_panel);
|
||||||
|
_configurations->addWidget(bitcombine_panel);
|
||||||
|
connect(count_panel, &CountWithinConfiguration::currentRuleChanged, this, &WrapConfigs::aliasReload);
|
||||||
|
connect(encode_panel, &EncodingConfiguration::currentRuleChanged, this, &WrapConfigs::aliasReload);
|
||||||
|
connect(bitcombine_panel, &BitCombineConfiguration::currentRuleChanged, this, &WrapConfigs::aliasReload);
|
||||||
|
connect(_alias_view, &QTableView::clicked, [=](const QModelIndex& idx) {
|
||||||
|
if (!idx.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto alias_key = _bind_base->delegateAlias()[idx.row()];
|
||||||
|
auto delt_inst = _bind_base->operator[](alias_key);
|
||||||
|
switch (delt_inst->outType()) {
|
||||||
|
case DataType::Flt32:
|
||||||
|
case DataType::Dbl64:
|
||||||
|
_configurations->setCurrentIndex(0);
|
||||||
|
break;
|
||||||
|
default: {
|
||||||
|
if (typeid(*delt_inst) == typeid(extract::AsHex) ||
|
||||||
|
typeid(*delt_inst) == typeid(extract::AsInteger) ||
|
||||||
|
typeid(*delt_inst) == typeid(extract::AsUnsigned)) {
|
||||||
|
_configurations->setCurrentIndex(1);
|
||||||
|
count_panel->currentRuleAccept(delt_inst, idx);
|
||||||
|
}
|
||||||
|
else if (typeid(*delt_inst) == typeid(extract::AsBitCombine)) {
|
||||||
|
_configurations->setCurrentIndex(3);
|
||||||
|
bitcombine_panel->currentRuleAccept(delt_inst, idx);
|
||||||
|
}
|
||||||
|
else if (typeid(*delt_inst) == typeid(extract::AsString)) {
|
||||||
|
_configurations->setCurrentIndex(2);
|
||||||
|
encode_panel->currentRuleAccept(delt_inst, idx);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
@ -58,7 +101,7 @@ void WrapConfigs::aliasReload()
|
||||||
case DataType::UNION_COMBINATE:
|
case DataType::UNION_COMBINATE:
|
||||||
throw new BaseException(u8"Invalid Alias BaseType£¡");
|
throw new BaseException(u8"Invalid Alias BaseType£¡");
|
||||||
case DataType::COMPLEX_RULESET:
|
case DataType::COMPLEX_RULESET:
|
||||||
for(auto it : row) it->setEditable(false);
|
for (auto it : row) it->setEditable(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
row.last()->setEditable(false);
|
row.last()->setEditable(false);
|
||||||
|
|
@ -167,3 +210,191 @@ void RuleSelectDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptio
|
||||||
{
|
{
|
||||||
editor->setGeometry(option.rect);
|
editor->setGeometry(option.rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace configurations;
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QGroupBox>
|
||||||
|
EmptyConfiguration::EmptyConfiguration(QWidget* p/*=nullptr*/)
|
||||||
|
{
|
||||||
|
auto layout = new QVBoxLayout(this);
|
||||||
|
auto label = new QLabel(u8"Can't Configurate.", this);
|
||||||
|
label->setAlignment(Qt::AlignCenter);
|
||||||
|
layout->addWidget(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
CountWithinConfiguration::CountWithinConfiguration(QWidget* p /*= nullptr*/)
|
||||||
|
: QWidget(p), _bind_u(nullptr), _count_input(new QSpinBox(this))
|
||||||
|
{
|
||||||
|
auto layout = new QGridLayout(this);
|
||||||
|
layout->addWidget(new QLabel(tr("BytesCount:")));
|
||||||
|
layout->addWidget(_count_input, 0, 1);
|
||||||
|
_count_input->setRange(1, 100);
|
||||||
|
layout->setRowStretch(1, 1);
|
||||||
|
layout->setColumnStretch(1, 1);
|
||||||
|
|
||||||
|
connect(_count_input, QOverload<int>::of(&QSpinBox::valueChanged), [=](int value) {
|
||||||
|
if (this->_bind_u) {
|
||||||
|
auto ptr = std::dynamic_pointer_cast<extract::AbstractExtractor>(this->_bind_u);
|
||||||
|
if (ptr) {
|
||||||
|
ptr->setCountWithin(value);
|
||||||
|
emit this->currentRuleChanged(_bind_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void CountWithinConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i)
|
||||||
|
{
|
||||||
|
this->_bind_u = u;
|
||||||
|
this->_bind_index = i;
|
||||||
|
|
||||||
|
_count_input->setValue(u->countWithin());
|
||||||
|
}
|
||||||
|
|
||||||
|
EncodingConfiguration::EncodingConfiguration(QWidget* p /*= nullptr*/)
|
||||||
|
: QWidget(p), _bind_u(nullptr), _count_input(new QSpinBox(this)),
|
||||||
|
_encoding_set(new QComboBox(this))
|
||||||
|
{
|
||||||
|
auto layout = new QGridLayout(this);
|
||||||
|
layout->addWidget(new QLabel(tr("BytesCount:")));
|
||||||
|
layout->addWidget(_count_input, 0, 1);
|
||||||
|
layout->addWidget(new QLabel(tr("Encoding:")), 1, 0);
|
||||||
|
layout->addWidget(_encoding_set, 1, 1);
|
||||||
|
layout->setRowStretch(2, 1);
|
||||||
|
layout->setColumnStretch(1, 1);
|
||||||
|
|
||||||
|
|
||||||
|
connect(_count_input, QOverload<int>::of(&QSpinBox::valueChanged), [=](int value) {
|
||||||
|
if (this->_bind_u) {
|
||||||
|
auto ptr = std::dynamic_pointer_cast<extract::AbstractExtractor>(this->_bind_u);
|
||||||
|
if (ptr) {
|
||||||
|
ptr->setCountWithin(value);
|
||||||
|
emit this->currentRuleChanged(_bind_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
auto codec_list = QTextCodec::availableCodecs();
|
||||||
|
for (auto codec : codec_list)
|
||||||
|
_encoding_set->addItem(QString::fromLatin1(codec));
|
||||||
|
connect(_encoding_set, QOverload<const QString&>::of(&QComboBox::currentIndexChanged),
|
||||||
|
[=](const QString& value) {
|
||||||
|
if (this->_bind_u) {
|
||||||
|
auto ptr = std::dynamic_pointer_cast<extract::AsString>(this->_bind_u);
|
||||||
|
if (ptr) {
|
||||||
|
auto insx = QTextCodec::codecForName(value.toUtf8());
|
||||||
|
ptr->setStrCodec(insx);
|
||||||
|
emit this->currentRuleChanged(_bind_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncodingConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i)
|
||||||
|
{
|
||||||
|
this->_bind_u = u;
|
||||||
|
this->_bind_index = i;
|
||||||
|
|
||||||
|
_count_input->setValue(u->countWithin());
|
||||||
|
auto codec_name = std::dynamic_pointer_cast<extract::AsString>(u)->codecName();
|
||||||
|
|
||||||
|
QSignalBlocker x(this->_encoding_set);
|
||||||
|
this->_encoding_set->setCurrentText(codec_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
BitCombineConfiguration::BitCombineConfiguration(QWidget* p /*= nullptr*/)
|
||||||
|
: QWidget(p), _bind_u(nullptr),
|
||||||
|
_count_input(new QSpinBox(this)),
|
||||||
|
_bit_items(new QTableView(this)),
|
||||||
|
_bit_model(new QStandardItemModel(this)),
|
||||||
|
_index_appoint(new QSpinBox(this)),
|
||||||
|
_bit_means(new QLineEdit(this))
|
||||||
|
{
|
||||||
|
auto layout = new QGridLayout(this);
|
||||||
|
layout->addWidget(new QLabel(tr("BytesCount:")));
|
||||||
|
layout->addWidget(_count_input, 0, 1, 1, 2);
|
||||||
|
auto group_box = new QGroupBox(tr("BitsContent"));
|
||||||
|
layout->addWidget(group_box, 1, 0, 3, 3);
|
||||||
|
layout->setColumnStretch(1, 1);
|
||||||
|
|
||||||
|
layout = new QGridLayout(group_box);
|
||||||
|
layout->addWidget(_bit_items, 0, 0, 3, 3);
|
||||||
|
|
||||||
|
layout->addWidget(new QLabel(tr("Bit Index:")), 3, 0);
|
||||||
|
layout->addWidget(_index_appoint, 3, 1, 1, 2);
|
||||||
|
layout->addWidget(new QLabel(tr("Bit Means:")), 4, 0);
|
||||||
|
layout->addWidget(_bit_means, 4, 1, 1, 2);
|
||||||
|
|
||||||
|
auto remove = new QPushButton(tr("RemoveItem"));
|
||||||
|
layout->addWidget(remove, 5, 1);
|
||||||
|
auto append = new QPushButton(tr("AppendNew"));
|
||||||
|
layout->addWidget(append, 5, 2);
|
||||||
|
|
||||||
|
layout->setColumnStretch(1, 1);
|
||||||
|
layout->setColumnStretch(2, 1);
|
||||||
|
|
||||||
|
_bit_items->setModel(this->_bit_model);
|
||||||
|
this->_bit_model->setHorizontalHeaderLabels(QStringList() << tr("No.") << tr("Means"));
|
||||||
|
this->_count_input->setRange(1, 100);
|
||||||
|
|
||||||
|
connect(this->_count_input, QOverload<int>::of(&QSpinBox::valueChanged), [=](int value) {
|
||||||
|
this->_bind_u->setCountWithin(value);
|
||||||
|
this->_index_appoint->setRange(0, value * 8);
|
||||||
|
|
||||||
|
auto options = this->_bind_u->switchOptions();
|
||||||
|
this->_bind_u->clearOptions();
|
||||||
|
for (auto key : options.keys()) {
|
||||||
|
if (key > value * 8)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
this->_bind_u->setSwitchOption(key, options[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit this->currentRuleChanged(_bind_index);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(append, &QPushButton::clicked, [=]() {
|
||||||
|
this->_bind_u->setSwitchOption(
|
||||||
|
this->_index_appoint->value(), this->_bit_means->text());
|
||||||
|
this->reloadContent(_bind_u);
|
||||||
|
emit this->currentRuleChanged(this->_bind_index);
|
||||||
|
});
|
||||||
|
connect(remove, &QPushButton::clicked, [=]() {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitCombineConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i)
|
||||||
|
{
|
||||||
|
this->_bind_u = std::dynamic_pointer_cast<extract::AsBitCombine>(u);;
|
||||||
|
this->_bind_index = i;
|
||||||
|
|
||||||
|
this->reloadContent(this->_bind_u);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <QHeaderView>
|
||||||
|
void BitCombineConfiguration::reloadContent(std::shared_ptr<extract::AsBitCombine> u)
|
||||||
|
{
|
||||||
|
this->_count_input->setValue(u->countWithin());
|
||||||
|
this->_index_appoint->setRange(0, u->countWithin() * 8);
|
||||||
|
|
||||||
|
this->_bit_model->removeRows(0, this->_bit_model->rowCount());
|
||||||
|
auto items = this->_bind_u->switchOptions();
|
||||||
|
auto keys = items.keys();
|
||||||
|
std::sort(keys.begin(), keys.end());
|
||||||
|
|
||||||
|
for (auto index : keys) {
|
||||||
|
auto content = items[index];
|
||||||
|
|
||||||
|
QList<QStandardItem*> row;
|
||||||
|
row << new QStandardItem(QString("%1").arg(index));
|
||||||
|
row << new QStandardItem(content);
|
||||||
|
for (auto i : row) i->setEditable(false);
|
||||||
|
|
||||||
|
this->_bit_model->appendRow(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->_bit_items->resizeColumnsToContents();
|
||||||
|
this->_bit_items->verticalHeader()->setVisible(false);
|
||||||
|
}
|
||||||
|
|
@ -42,3 +42,78 @@ public:
|
||||||
void dataChanged(QStandardItem *cell);
|
void dataChanged(QStandardItem *cell);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
namespace configurations {
|
||||||
|
/// <summary>
|
||||||
|
/// 空白配置面板
|
||||||
|
/// </summary>
|
||||||
|
class EmptyConfiguration : public QWidget {
|
||||||
|
public:
|
||||||
|
EmptyConfiguration(QWidget* p = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字段长度配置面板
|
||||||
|
/// </summary>
|
||||||
|
class CountWithinConfiguration : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
std::shared_ptr<ExtractImpl> _bind_u;
|
||||||
|
QModelIndex _bind_index;
|
||||||
|
QSpinBox* const _count_input;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CountWithinConfiguration(QWidget* p = nullptr);
|
||||||
|
|
||||||
|
void currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void currentRuleChanged(const QModelIndex& idx);
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字符串文本编码配置面板
|
||||||
|
/// </summary>
|
||||||
|
class EncodingConfiguration : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
std::shared_ptr<ExtractImpl> _bind_u;
|
||||||
|
QModelIndex _bind_index;
|
||||||
|
QSpinBox* const _count_input;
|
||||||
|
QComboBox* const _encoding_set;
|
||||||
|
|
||||||
|
public:
|
||||||
|
EncodingConfiguration(QWidget* p = nullptr);
|
||||||
|
|
||||||
|
void currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void currentRuleChanged(const QModelIndex& idx);
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 位联合配置面板
|
||||||
|
/// </summary>
|
||||||
|
class BitCombineConfiguration : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
std::shared_ptr<extract::AsBitCombine> _bind_u;
|
||||||
|
QModelIndex _bind_index;
|
||||||
|
|
||||||
|
QSpinBox* const _count_input;
|
||||||
|
QTableView* const _bit_items;
|
||||||
|
QStandardItemModel* const _bit_model;
|
||||||
|
QSpinBox* const _index_appoint;
|
||||||
|
QLineEdit* const _bit_means;
|
||||||
|
|
||||||
|
public:
|
||||||
|
BitCombineConfiguration(QWidget* p = nullptr);
|
||||||
|
|
||||||
|
void currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i);
|
||||||
|
void reloadContent(std::shared_ptr<extract::AsBitCombine> u);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void currentRuleChanged(const QModelIndex& idx);
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue