update
This commit is contained in:
parent
455834048c
commit
912c1c9f45
|
@ -245,3 +245,70 @@ void BitCombineConfiguration::reloadContent(std::shared_ptr<extract::BytesAsBitC
|
|||
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);
|
||||
|
||||
for (auto key : this->_bind_core->customRules().keys())
|
||||
_rule_select->addItem(key, CUSTOM_RULE);
|
||||
for (auto key : this->_bind_core->extractUnitList().keys())
|
||||
_rule_select->addItem(key, BASIC_RULE);
|
||||
for (auto key : this->_bind_core->sizeProviderList().keys())
|
||||
_size_layout_select->addItem(key);
|
||||
}
|
||||
|
||||
void ListUnitConfiguration::currentRuleAccept(
|
||||
std::shared_ptr<ExtractUnit> u, const QModelIndex& i,
|
||||
std::shared_ptr<ScopeFieldsGetter> getter)
|
||||
{
|
||||
this->_bind_u = std::dynamic_pointer_cast<extract::BytesAsList>(u);
|
||||
this->_bind_index = i;
|
||||
|
||||
reloadContent(this->_bind_u);
|
||||
}
|
||||
|
||||
void ListUnitConfiguration::reloadContent(
|
||||
std::shared_ptr<extract::BytesAsList> u,
|
||||
std::shared_ptr<ScopeFieldsGetter> getter)
|
||||
{
|
||||
QSignalBlocker v(_rule_select);
|
||||
_rule_select->setCurrentText(u->elementRule()->name());
|
||||
QSignalBlocker m(_size_layout_select);
|
||||
_size_layout_select->setCurrentText(u->sizeProvider()->name());
|
||||
|
||||
if (typeid(*u->sizeProvider().get()) == typeid(ConstNumberProvider)) {
|
||||
_configs_stack->setCurrentIndex(0);
|
||||
QSignalBlocker v(_const_number_input);
|
||||
auto conv = std::dynamic_pointer_cast<ConstNumberProvider>(u->sizeProvider());
|
||||
_const_number_input->setValue(conv->value(conv->expression()));
|
||||
}
|
||||
else if (typeid(*u->sizeProvider().get()) == typeid(InterpretedNumberPrivider)) {
|
||||
_configs_stack->setCurrentIndex(1);
|
||||
auto conv = std::dynamic_pointer_cast<InterpretedNumberPrivider>(u->sizeProvider());
|
||||
QSignalBlocker v(_prev_field_refer);
|
||||
auto item_list = getter->prevFields();
|
||||
this->_prev_field_refer->clear();
|
||||
this->_prev_field_refer->addItems(item_list.keys());
|
||||
this->_prev_field_refer->setCurrentText(conv->name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,15 @@ public:
|
|||
EmptyConfiguration(QWidget* p = nullptr);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 字段长度配置面板
|
||||
/// </summary>
|
||||
class CountWithinConfiguration : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::shared_ptr<ExtractUnit> _bind_u;
|
||||
QModelIndex _bind_index;
|
||||
QSpinBox *const _count_input;
|
||||
QSpinBox* const _count_input;
|
||||
|
||||
public:
|
||||
CountWithinConfiguration(QWidget* p = nullptr);
|
||||
|
@ -33,6 +36,9 @@ signals:
|
|||
void currentRuleChanged(const QModelIndex& idx);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 字符串文本编码配置面板
|
||||
/// </summary>
|
||||
class EncodingConfiguration : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
|
@ -51,6 +57,9 @@ signals:
|
|||
};
|
||||
|
||||
#include "extract_basic.h"
|
||||
/// <summary>
|
||||
/// 位联合配置面板
|
||||
/// </summary>
|
||||
class BitCombineConfiguration : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
|
@ -58,10 +67,10 @@ private:
|
|||
QModelIndex _bind_index;
|
||||
|
||||
QSpinBox* const _count_input;
|
||||
QTableView *const _bit_items;
|
||||
QStandardItemModel *const _bit_model;
|
||||
QSpinBox *const _index_appoint;
|
||||
QLineEdit *const _bit_means;
|
||||
QTableView* const _bit_items;
|
||||
QStandardItemModel* const _bit_model;
|
||||
QSpinBox* const _index_appoint;
|
||||
QLineEdit* const _bit_means;
|
||||
|
||||
public:
|
||||
BitCombineConfiguration(QWidget* p = nullptr);
|
||||
|
@ -73,6 +82,34 @@ signals:
|
|||
void currentRuleChanged(const QModelIndex& idx);
|
||||
};
|
||||
|
||||
class ListUnitConfiguration : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::shared_ptr<TranslateBasic> _bind_core;
|
||||
std::shared_ptr<extract::BytesAsList> _bind_u;
|
||||
QModelIndex _bind_index;
|
||||
|
||||
QComboBox* const _rule_select;
|
||||
QComboBox* const _size_layout_select;
|
||||
|
||||
QStackedWidget* const _configs_stack;
|
||||
QSpinBox* const _const_number_input;
|
||||
QComboBox* const _prev_field_refer;
|
||||
|
||||
public:
|
||||
ListUnitConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
||||
|
||||
void currentRuleAccept(
|
||||
std::shared_ptr<ExtractUnit> u,
|
||||
const QModelIndex& i,
|
||||
std::shared_ptr<ScopeFieldsGetter> getter);
|
||||
void reloadContent(std::shared_ptr<extract::BytesAsList> u,
|
||||
std::shared_ptr<ScopeFieldsGetter> getter);
|
||||
|
||||
signals:
|
||||
void currentRuleChanged(const QModelIndex& idx);
|
||||
};
|
||||
|
||||
class StructuralRuleView : public QWidget
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -123,8 +123,8 @@ public:
|
|||
std::shared_ptr<ExtractUnit> defaultExtractUnit() const;
|
||||
QHash<QString, std::shared_ptr<ExtractUnit>> extractUnitList() const;
|
||||
|
||||
void setCustomRule(const QString &name, std::shared_ptr<ExtractUnit> inst);
|
||||
void removeCustomRule(const QString &name);
|
||||
void setCustomRule(const QString& name, std::shared_ptr<ExtractUnit> inst);
|
||||
void removeCustomRule(const QString& name);
|
||||
QHash<QString, std::shared_ptr<RuleMatch>> customRules() const;
|
||||
};
|
||||
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
}_setter;
|
||||
|
||||
public:
|
||||
FieldSetterLayer(const QString &self, std::shared_ptr<ScopeFieldsSetter> instp);
|
||||
FieldSetterLayer(const QString& self, std::shared_ptr<ScopeFieldsSetter> instp);
|
||||
|
||||
void setField(const QString& name, DataType type) override;
|
||||
};
|
Loading…
Reference in New Issue