update
This commit is contained in:
parent
82511649d2
commit
ff2ca20a6a
|
@ -39,27 +39,7 @@ void IntDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewIt
|
||||||
|
|
||||||
void RuleSetCustom::targetRuleRefresh(const QModelIndex& idx)
|
void RuleSetCustom::targetRuleRefresh(const QModelIndex& idx)
|
||||||
{
|
{
|
||||||
auto rule_insv = (*_view._ruleset)[idx.row()];
|
if (idx.column() == 2) {
|
||||||
|
|
||||||
auto offset_index = idx.sibling(idx.row(), 1);
|
|
||||||
auto offset_number = offset_index.data(Qt::DisplayRole).toInt();
|
|
||||||
rule_insv.second->setOffsetSpan(offset_number);
|
|
||||||
|
|
||||||
auto count_index = idx.sibling(idx.row(), 3);
|
|
||||||
_view._seqs_model->setData(offset_index, rule_insv.second->offsetSpan(), Qt::EditRole);
|
|
||||||
_view._seqs_model->setData(count_index, rule_insv.second->countWithin(), Qt::EditRole);
|
|
||||||
|
|
||||||
auto param_index = idx.sibling(idx.row(), 4);
|
|
||||||
QJsonObject obj;
|
|
||||||
rule_insv.second->saveTo(obj);
|
|
||||||
auto bytes = QJsonDocument(obj).toJson(QJsonDocument::Compact);
|
|
||||||
_view._seqs_model->setData(param_index, QString::fromUtf8(bytes));
|
|
||||||
|
|
||||||
this->resizeColumnsToContents();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleSetCustom::peersRuleChanged(const QModelIndex& idx)
|
|
||||||
{
|
|
||||||
auto field_idx = idx.sibling(idx.row(), 0);
|
auto field_idx = idx.sibling(idx.row(), 0);
|
||||||
auto field_name = field_idx.data(Qt::DisplayRole).toString();
|
auto field_name = field_idx.data(Qt::DisplayRole).toString();
|
||||||
|
|
||||||
|
@ -81,8 +61,25 @@ void RuleSetCustom::peersRuleChanged(const QModelIndex& idx)
|
||||||
conv->setSizeProvider(this->_view.base->defaultSizeProvider());
|
conv->setSizeProvider(this->_view.base->defaultSizeProvider());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
targetRuleRefresh(idx);
|
auto rule_insv = (*_view._ruleset)[idx.row()];
|
||||||
|
|
||||||
|
auto offset_index = idx.sibling(idx.row(), 1);
|
||||||
|
auto offset_number = offset_index.data(Qt::DisplayRole).toInt();
|
||||||
|
rule_insv.second->setOffsetSpan(offset_number);
|
||||||
|
|
||||||
|
auto count_index = idx.sibling(idx.row(), 3);
|
||||||
|
_view._seqs_model->setData(offset_index, rule_insv.second->offsetSpan(), Qt::EditRole);
|
||||||
|
_view._seqs_model->setData(count_index, rule_insv.second->countWithin(), Qt::EditRole);
|
||||||
|
|
||||||
|
auto param_index = idx.sibling(idx.row(), 4);
|
||||||
|
QJsonObject obj;
|
||||||
|
rule_insv.second->saveTo(obj);
|
||||||
|
auto bytes = QJsonDocument(obj).toJson(QJsonDocument::Compact);
|
||||||
|
_view._seqs_model->setData(param_index, QString::fromUtf8(bytes));
|
||||||
|
|
||||||
|
this->resizeColumnsToContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleSetCustom::showEvent(QShowEvent* e)
|
void RuleSetCustom::showEvent(QShowEvent* e)
|
||||||
|
@ -112,7 +109,6 @@ RuleSetCustom::RuleSetCustom(std::shared_ptr<TranslateBasic> base,
|
||||||
|
|
||||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(this, &QTableView::customContextMenuRequested, this, &RuleSetCustom::customTranslateRuleEdit);
|
connect(this, &QTableView::customContextMenuRequested, this, &RuleSetCustom::customTranslateRuleEdit);
|
||||||
connect(rule_delegate, &RuleSelectDelegate::dataChanged, this, &RuleSetCustom::peersRuleChanged);
|
|
||||||
connect(_view._seqs_model, &QAbstractItemModel::dataChanged, this, &RuleSetCustom::targetRuleRefresh);
|
connect(_view._seqs_model, &QAbstractItemModel::dataChanged, this, &RuleSetCustom::targetRuleRefresh);
|
||||||
|
|
||||||
connect(this, &QTableView::clicked, [=](const QModelIndex& curr) {
|
connect(this, &QTableView::clicked, [=](const QModelIndex& curr) {
|
||||||
|
@ -204,8 +200,6 @@ void RuleSelectDelegate::setModelData(QWidget* editor, QAbstractItemModel* model
|
||||||
{
|
{
|
||||||
auto rule_name = dynamic_cast<QComboBox*>(editor)->currentText();
|
auto rule_name = dynamic_cast<QComboBox*>(editor)->currentText();
|
||||||
model->setData(index, rule_name, Qt::EditRole);
|
model->setData(index, rule_name, Qt::EditRole);
|
||||||
|
|
||||||
emit this->dataChanged(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleSelectDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
void RuleSelectDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
|
|
|
@ -36,9 +36,6 @@ namespace unit_func {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<TranslateBasic> _kernel;
|
std::shared_ptr<TranslateBasic> _kernel;
|
||||||
|
|
||||||
signals:
|
|
||||||
void dataChanged(const QModelIndex& idx) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RuleSelectDelegate(std::shared_ptr<TranslateBasic> ins);
|
RuleSelectDelegate(std::shared_ptr<TranslateBasic> ins);
|
||||||
|
|
||||||
|
@ -66,7 +63,6 @@ signals:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void targetRuleRefresh(const QModelIndex& idx);
|
void targetRuleRefresh(const QModelIndex& idx);
|
||||||
void peersRuleChanged(const QModelIndex& idx_rule);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent* e) override;
|
void showEvent(QShowEvent* e) override;
|
||||||
|
|
|
@ -317,10 +317,18 @@ ListUnitConfiguration::ListUnitConfiguration(
|
||||||
|
|
||||||
connect(_size_layout_select, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(_size_layout_select, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
[=](int idx) {
|
[=](int idx) {
|
||||||
this->_configs_stack->setCurrentIndex(this->_size_layout_select->currentIndex());
|
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,
|
connect(this->_rule_select, &QComboBox::currentTextChanged,
|
||||||
this, &ListUnitConfiguration::elmRuleSet);
|
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<ExtractUnit> u,
|
void ListUnitConfiguration::currentRuleAccept(std::shared_ptr<ExtractUnit> u,
|
||||||
|
@ -375,3 +383,39 @@ void ListUnitConfiguration::elmRuleSet(const QString& name)
|
||||||
|
|
||||||
emit this->currentRuleChanged(this->_bind_index);
|
emit this->currentRuleChanged(this->_bind_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListUnitConfiguration::sizeProviderSet(const QString& name)
|
||||||
|
{
|
||||||
|
if (name == this->_bind_u->sizeProvider()->name())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto ninst = this->_bind_core->sizeProviderList()[name]->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->name());
|
||||||
|
}
|
||||||
|
|
||||||
|
emit this->currentRuleChanged(this->_bind_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListUnitConfiguration::fieldProviderBind(const QString& name)
|
||||||
|
{
|
||||||
|
this->_bind_u->sizeProvider()->setExpression(name);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -101,6 +101,9 @@ namespace configuration_panel {
|
||||||
QComboBox* const _prev_field_refer;
|
QComboBox* const _prev_field_refer;
|
||||||
|
|
||||||
void elmRuleSet(const QString &name);
|
void elmRuleSet(const QString &name);
|
||||||
|
void sizeProviderSet(const QString &name);
|
||||||
|
void constProviderBind(int value);
|
||||||
|
void fieldProviderBind(const QString &name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ListUnitConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
ListUnitConfiguration(std::shared_ptr<TranslateBasic> core, QWidget* p = nullptr);
|
||||||
|
|
|
@ -163,9 +163,11 @@ QString InterpretedNumberPrivider::name() const
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
int32_t InterpretedNumberPrivider::value(const QString& expr) const
|
int32_t InterpretedNumberPrivider::value(const QString& expr) const
|
||||||
{
|
{
|
||||||
|
if (this->_refer._context_inst) {
|
||||||
auto value = this->_refer._context_inst->get(expr);
|
auto value = this->_refer._context_inst->get(expr);
|
||||||
if (value.userType() == QMetaType::Int)
|
if (value.userType() == QMetaType::Int)
|
||||||
return value.toInt();
|
return value.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,10 +406,6 @@ void AsList::loadFrom(std::shared_ptr<TranslateBasic> core, const QJsonObject& o
|
||||||
xdev = core->extractUnitList()[bind_unit_name]->newDefault();
|
xdev = core->extractUnitList()[bind_unit_name]->newDefault();
|
||||||
this->_list._bind_unit = std::dynamic_pointer_cast<ExtractUnit>(xdev);
|
this->_list._bind_unit = std::dynamic_pointer_cast<ExtractUnit>(xdev);
|
||||||
|
|
||||||
QString bind_provider_expr = "";
|
|
||||||
STRING_SAVE(bind_provider_expr, obj);
|
|
||||||
this->_list._bind_size_v->setExpression(bind_provider_expr);
|
|
||||||
|
|
||||||
QJsonObject unit_obj;
|
QJsonObject unit_obj;
|
||||||
QJsonObject size_provider_obj;
|
QJsonObject size_provider_obj;
|
||||||
OBJECT_PEAK(unit_obj, obj);
|
OBJECT_PEAK(unit_obj, obj);
|
||||||
|
@ -434,15 +430,12 @@ void AsList::saveTo(QJsonObject& obj) const
|
||||||
OBJECT_SAVE(unit_obj, obj);
|
OBJECT_SAVE(unit_obj, obj);
|
||||||
|
|
||||||
QString bind_size_provider_name = "";
|
QString bind_size_provider_name = "";
|
||||||
QString bind_provider_expr = "";
|
|
||||||
QJsonObject size_provider_obj;
|
QJsonObject size_provider_obj;
|
||||||
if (this->_list._bind_size_v) {
|
if (this->_list._bind_size_v) {
|
||||||
bind_provider_expr = this->_list._bind_size_v->expression();
|
|
||||||
bind_size_provider_name = this->_list._bind_size_v->name();
|
bind_size_provider_name = this->_list._bind_size_v->name();
|
||||||
this->_list._bind_size_v->saveTo(size_provider_obj);
|
this->_list._bind_size_v->saveTo(size_provider_obj);
|
||||||
}
|
}
|
||||||
STRING_SAVE(bind_size_provider_name, obj);
|
STRING_SAVE(bind_size_provider_name, obj);
|
||||||
STRING_SAVE(bind_provider_expr, obj);
|
|
||||||
OBJECT_SAVE(size_provider_obj, obj);
|
OBJECT_SAVE(size_provider_obj, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue