update 重构更新逻辑
This commit is contained in:
parent
fbf498de9d
commit
cf9af911b8
|
@ -33,20 +33,16 @@ void IntDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewIt
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "TranslateBasic.h"
|
#include "TranslateBasic.h"
|
||||||
void SequenceView::tidyRuleAt(const QModelIndex& idx)
|
void SequenceView::currentRuleRefresh(const QModelIndex& idx)
|
||||||
{
|
{
|
||||||
auto rule_idx = idx.sibling(idx.row(), 3);
|
auto new_inst = _rule_sequence.at(idx.row());
|
||||||
auto rule_nm = base->extactors()[rule_idx.data(Qt::DisplayRole).toString()];
|
|
||||||
auto new_inst = std::dynamic_pointer_cast<ExtractUnit>(rule_nm->newDefault());
|
|
||||||
_rule_sequence.replace(idx.row(), new_inst);
|
|
||||||
|
|
||||||
auto offset_index = idx.sibling(idx.row(), 1);
|
|
||||||
auto offset_number = offset_index.data(Qt::DisplayRole).toInt();
|
|
||||||
auto count_index = idx.sibling(idx.row(), 2);
|
|
||||||
auto count_number = count_index.data(Qt::DisplayRole).toInt();
|
|
||||||
auto rule_insv = std::dynamic_pointer_cast<AbstractExtractor>(new_inst);
|
auto rule_insv = std::dynamic_pointer_cast<AbstractExtractor>(new_inst);
|
||||||
|
|
||||||
|
auto offset_index = idx.sibling(idx.row(), 1);
|
||||||
|
auto count_index = idx.sibling(idx.row(), 2);
|
||||||
if (rule_insv) {
|
if (rule_insv) {
|
||||||
|
auto offset_number = offset_index.data(Qt::DisplayRole).toInt();
|
||||||
|
auto count_number = count_index.data(Qt::DisplayRole).toInt();
|
||||||
rule_insv->setOffsetFromPrevious(offset_number);
|
rule_insv->setOffsetFromPrevious(offset_number);
|
||||||
rule_insv->setCountWithinParse(count_number);
|
rule_insv->setCountWithinParse(count_number);
|
||||||
}
|
}
|
||||||
|
@ -63,6 +59,16 @@ void SequenceView::tidyRuleAt(const QModelIndex& idx)
|
||||||
this->resizeColumnsToContents();
|
this->resizeColumnsToContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SequenceView::peersRuleChanged(const QModelIndex& idx)
|
||||||
|
{
|
||||||
|
auto rule_idx = idx.sibling(idx.row(), 3);
|
||||||
|
auto rule_nm = base->extactors()[rule_idx.data(Qt::DisplayRole).toString()];
|
||||||
|
auto new_inst = std::dynamic_pointer_cast<ExtractUnit>(rule_nm->newDefault());
|
||||||
|
_rule_sequence.replace(idx.row(), new_inst);
|
||||||
|
|
||||||
|
currentRuleRefresh(idx);
|
||||||
|
}
|
||||||
|
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
SequenceView::SequenceView(QWidget* p /*= nullptr*/)
|
SequenceView::SequenceView(QWidget* p /*= nullptr*/)
|
||||||
:QTableView(p),
|
:QTableView(p),
|
||||||
|
@ -82,8 +88,8 @@ SequenceView::SequenceView(QWidget* p /*= nullptr*/)
|
||||||
|
|
||||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(this, &QTableView::customContextMenuRequested, this, &SequenceView::customTranslateRuleEdit);
|
connect(this, &QTableView::customContextMenuRequested, this, &SequenceView::customTranslateRuleEdit);
|
||||||
connect(rule_delegate, &RuleSelectDelegate::dataChanged, this, &SequenceView::tidyRuleAt);
|
connect(rule_delegate, &RuleSelectDelegate::dataChanged, this, &SequenceView::peersRuleChanged);
|
||||||
connect(int_delegate, &IntDelegate::valueChanged, this, &SequenceView::tidyRuleAt);
|
connect(int_delegate, &IntDelegate::valueChanged, this, &SequenceView::currentRuleRefresh);
|
||||||
|
|
||||||
auto select_model = this->selectionModel();
|
auto select_model = this->selectionModel();
|
||||||
connect(select_model, &QItemSelectionModel::currentRowChanged, [=](const QModelIndex& curr) {
|
connect(select_model, &QItemSelectionModel::currentRowChanged, [=](const QModelIndex& curr) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ public:
|
||||||
|
|
||||||
std::shared_ptr<ExtractUnit> defaultRule() const;
|
std::shared_ptr<ExtractUnit> defaultRule() const;
|
||||||
QHash<QString, std::shared_ptr<ExtractUnit>> extactors() const;
|
QHash<QString, std::shared_ptr<ExtractUnit>> extactors() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +80,8 @@ signals:
|
||||||
void currentRuleChanged(std::shared_ptr<ExtractUnit> u) const;
|
void currentRuleChanged(std::shared_ptr<ExtractUnit> u) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void tidyRuleAt(const QModelIndex& idx_rule);
|
void currentRuleRefresh(const QModelIndex &idx);
|
||||||
|
void peersRuleChanged(const QModelIndex &idx_rule);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SequenceView(QWidget* p = nullptr);
|
SequenceView(QWidget* p = nullptr);
|
||||||
|
|
Loading…
Reference in New Issue