update
This commit is contained in:
parent
68b3b86fb9
commit
357ed5642b
|
@ -35,7 +35,7 @@ void IntDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewIt
|
|||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
void SequenceRulesView::currentRuleRefresh(const QModelIndex& idx)
|
||||
void RuleSetCustom::targetRuleRefresh(const QModelIndex& idx)
|
||||
{
|
||||
auto rule_insv = _view._ruleset->_bind[idx.row()];
|
||||
|
||||
|
@ -56,7 +56,7 @@ void SequenceRulesView::currentRuleRefresh(const QModelIndex& idx)
|
|||
this->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
void SequenceRulesView::peersRuleChanged(const QModelIndex& idx)
|
||||
void RuleSetCustom::peersRuleChanged(const QModelIndex& idx)
|
||||
{
|
||||
auto field_idx = idx.sibling(idx.row(), 0);
|
||||
auto field_name = field_idx.data(Qt::DisplayRole).toString();
|
||||
|
@ -80,10 +80,10 @@ void SequenceRulesView::peersRuleChanged(const QModelIndex& idx)
|
|||
}
|
||||
}
|
||||
|
||||
currentRuleRefresh(idx);
|
||||
targetRuleRefresh(idx);
|
||||
}
|
||||
|
||||
void SequenceRulesView::showEvent(QShowEvent* e)
|
||||
void RuleSetCustom::showEvent(QShowEvent* e)
|
||||
{
|
||||
QTableView::showEvent(e);
|
||||
|
||||
|
@ -91,8 +91,7 @@ void SequenceRulesView::showEvent(QShowEvent* e)
|
|||
}
|
||||
|
||||
#include <QItemSelectionModel>
|
||||
SequenceRulesView::SequenceRulesView(
|
||||
std::shared_ptr<TranslateBasic> base,
|
||||
RuleSetCustom::RuleSetCustom(std::shared_ptr<TranslateBasic> base,
|
||||
std::shared_ptr<extract::BytesAsRuleSet> rule_set, QWidget* p /*= nullptr*/)
|
||||
:QTableView(p)
|
||||
{
|
||||
|
@ -111,9 +110,9 @@ SequenceRulesView::SequenceRulesView(
|
|||
this->setItemDelegateForColumn(2, rule_delegate);
|
||||
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, &QTableView::customContextMenuRequested, this, &SequenceRulesView::customTranslateRuleEdit);
|
||||
connect(rule_delegate, &RuleSelectDelegate::dataChanged, this, &SequenceRulesView::peersRuleChanged);
|
||||
connect(int_delegate, &IntDelegate::valueChanged, this, &SequenceRulesView::currentRuleRefresh);
|
||||
connect(this, &QTableView::customContextMenuRequested, this, &RuleSetCustom::customTranslateRuleEdit);
|
||||
connect(rule_delegate, &RuleSelectDelegate::dataChanged, this, &RuleSetCustom::peersRuleChanged);
|
||||
connect(int_delegate, &IntDelegate::valueChanged, this, &RuleSetCustom::targetRuleRefresh);
|
||||
|
||||
connect(this, &QTableView::clicked, [=](const QModelIndex& curr) {
|
||||
if (!curr.isValid())
|
||||
|
@ -124,15 +123,15 @@ SequenceRulesView::SequenceRulesView(
|
|||
}
|
||||
|
||||
#include <QMenu>
|
||||
void SequenceRulesView::customTranslateRuleEdit(const QPoint& pos)
|
||||
void RuleSetCustom::customTranslateRuleEdit(const QPoint& pos)
|
||||
{
|
||||
QMenu immediate;
|
||||
immediate.addAction(u8"Add Unit", this, &SequenceRulesView::addTranslateUnit);
|
||||
immediate.addAction(u8"Remove Unit", this, &SequenceRulesView::removeTranslateUnit);
|
||||
immediate.addAction(u8"Add Unit", this, &RuleSetCustom::addTranslateUnit);
|
||||
immediate.addAction(u8"Remove Unit", this, &RuleSetCustom::removeTranslateUnit);
|
||||
immediate.exec(this->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void SequenceRulesView::addTranslateUnit()
|
||||
void RuleSetCustom::addTranslateUnit()
|
||||
{
|
||||
auto curr_rule = _view.base->defaultExtractUnit()->newDefault();
|
||||
this->_view._ruleset->_bind.append(
|
||||
|
@ -145,7 +144,7 @@ void SequenceRulesView::addTranslateUnit()
|
|||
membersPresent(this->_view._ruleset, this->_view._seqs_model);
|
||||
}
|
||||
|
||||
void SequenceRulesView::removeTranslateUnit()
|
||||
void RuleSetCustom::removeTranslateUnit()
|
||||
{
|
||||
auto idx_curr = this->currentIndex();
|
||||
if (!idx_curr.isValid())
|
||||
|
@ -155,7 +154,7 @@ void SequenceRulesView::removeTranslateUnit()
|
|||
_view._seqs_model->removeRow(idx_curr.row());
|
||||
}
|
||||
|
||||
void SequenceRulesView::membersPresent(std::shared_ptr<extract::BytesAsRuleSet> ruleset, QStandardItemModel* model)
|
||||
void RuleSetCustom::membersPresent(std::shared_ptr<extract::BytesAsRuleSet> ruleset, QStandardItemModel* model)
|
||||
{
|
||||
model->removeRows(0, model->rowCount());
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
/// <summary>
|
||||
/// ÐòÁл¯¹æÔòÊÓͼ
|
||||
/// </summary>
|
||||
class SequenceRulesView : public QTableView {
|
||||
class RuleSetCustom : public QTableView {
|
||||
Q_OBJECT
|
||||
private:
|
||||
struct __Private {
|
||||
|
@ -68,15 +68,14 @@ signals:
|
|||
void currentRuleChanged(std::shared_ptr<ExtractUnit> u, const QModelIndex& i) const;
|
||||
|
||||
public:
|
||||
void currentRuleRefresh(const QModelIndex& idx);
|
||||
void targetRuleRefresh(const QModelIndex& idx);
|
||||
void peersRuleChanged(const QModelIndex& idx_rule);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* e) override;
|
||||
|
||||
public:
|
||||
SequenceRulesView(
|
||||
std::shared_ptr<TranslateBasic> base,
|
||||
RuleSetCustom(std::shared_ptr<TranslateBasic> base,
|
||||
std::shared_ptr<extract::BytesAsRuleSet> rule_set, QWidget* p = nullptr);
|
||||
|
||||
void customTranslateRuleEdit(const QPoint& pos);
|
||||
|
|
|
@ -12,7 +12,7 @@ StructuralRuleView::StructuralRuleView(
|
|||
std::shared_ptr<TranslateBasic> base,
|
||||
std::shared_ptr<extract::BytesAsRuleSet> inst_r, QWidget* p /*= nullptr*/)
|
||||
: QWidget(p), _rule_base(inst_r),
|
||||
_sequence_view(new SequenceRulesView(base, inst_r, this)),
|
||||
_sequence_view(new RuleSetCustom(base, inst_r, this)),
|
||||
_configs_stack(new QStackedWidget(this))
|
||||
{
|
||||
this->_current_fields_cache = std::make_shared<FieldManagerLayer>("", nullptr);
|
||||
|
@ -35,13 +35,13 @@ StructuralRuleView::StructuralRuleView(
|
|||
_configs_stack->addWidget(list_config);
|
||||
|
||||
connect(count_span, &CountWithinConfiguration::currentRuleChanged,
|
||||
_sequence_view, &SequenceRulesView::currentRuleRefresh);
|
||||
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
||||
connect(encode_config, &EncodingConfiguration::currentRuleChanged,
|
||||
_sequence_view, &SequenceRulesView::currentRuleRefresh);
|
||||
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
||||
connect(combine_config, &BitCombineConfiguration::currentRuleChanged,
|
||||
_sequence_view, &SequenceRulesView::currentRuleRefresh);
|
||||
_sequence_view, &RuleSetCustom::targetRuleRefresh);
|
||||
|
||||
connect(_sequence_view, &SequenceRulesView::currentRuleChanged,
|
||||
connect(_sequence_view, &RuleSetCustom::currentRuleChanged,
|
||||
[=](std::shared_ptr<ExtractUnit> u, const QModelIndex& i) {
|
||||
switch (u->outType()) {
|
||||
case DataType::TextString:
|
||||
|
|
|
@ -116,7 +116,7 @@ signals:
|
|||
class StructuralRuleView : public QWidget
|
||||
{
|
||||
private:
|
||||
SequenceRulesView* const _sequence_view;
|
||||
RuleSetCustom* const _sequence_view;
|
||||
QStackedWidget* const _configs_stack;
|
||||
|
||||
std::shared_ptr<extract::BytesAsRuleSet> _rule_base;
|
||||
|
|
Loading…
Reference in New Issue