位联合配置面板
This commit is contained in:
parent
bf6e6d694f
commit
1c43423cbe
|
@ -25,11 +25,15 @@ StructuralRuleView::StructuralRuleView(QWidget* p /*= nullptr*/)
|
||||||
_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);
|
||||||
|
_configs_stack->addWidget(combine_config);
|
||||||
|
|
||||||
connect(count_span, &CountWithinConfiguration::currentRuleChanged,
|
connect(count_span, &CountWithinConfiguration::currentRuleChanged,
|
||||||
_sequence_view, &SequenceRulesView::currentRuleRefresh);
|
_sequence_view, &SequenceRulesView::currentRuleRefresh);
|
||||||
connect(encode_config, &EncodingConfiguration::currentRuleChanged,
|
connect(encode_config, &EncodingConfiguration::currentRuleChanged,
|
||||||
_sequence_view, &SequenceRulesView::currentRuleRefresh);
|
_sequence_view, &SequenceRulesView::currentRuleRefresh);
|
||||||
|
connect(combine_config, &BitCombineConfiguration::currentRuleChanged,
|
||||||
|
_sequence_view, &SequenceRulesView::currentRuleRefresh);
|
||||||
|
|
||||||
connect(_sequence_view, &SequenceRulesView::currentRuleChanged,
|
connect(_sequence_view, &SequenceRulesView::currentRuleChanged,
|
||||||
[=](std::shared_ptr<ExtractUnit> u, const QModelIndex& i) {
|
[=](std::shared_ptr<ExtractUnit> u, const QModelIndex& i) {
|
||||||
|
@ -40,6 +44,11 @@ StructuralRuleView::StructuralRuleView(QWidget* p /*= nullptr*/)
|
||||||
encode_config->currentRuleAccept(u, i);
|
encode_config->currentRuleAccept(u, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if (typeid(*u.get()) == typeid(extract::BytesAsBitCombine)) {
|
||||||
|
_configs_stack->setCurrentIndex(3);
|
||||||
|
combine_config->currentRuleAccept(u, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case DataType::Integer:
|
case DataType::Integer:
|
||||||
case DataType::Unsigned:
|
case DataType::Unsigned:
|
||||||
_configs_stack->setCurrentIndex(1);
|
_configs_stack->setCurrentIndex(1);
|
||||||
|
@ -55,7 +64,7 @@ StructuralRuleView::StructuralRuleView(QWidget* p /*= nullptr*/)
|
||||||
EmptyConfiguration::EmptyConfiguration(QWidget* p/*=nullptr*/)
|
EmptyConfiguration::EmptyConfiguration(QWidget* p/*=nullptr*/)
|
||||||
{
|
{
|
||||||
auto layout = new QVBoxLayout(this);
|
auto layout = new QVBoxLayout(this);
|
||||||
auto label = new QLabel(u8"µ±Ç°¹æÔòÎÞÐèÅäÖÃ", this);
|
auto label = new QLabel(u8"Can't Configurate.", this);
|
||||||
label->setAlignment(Qt::AlignCenter);
|
label->setAlignment(Qt::AlignCenter);
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
}
|
}
|
||||||
|
@ -115,10 +124,10 @@ EncodingConfiguration::EncodingConfiguration(QWidget* p /*= nullptr*/)
|
||||||
});
|
});
|
||||||
|
|
||||||
auto codec_list = QTextCodec::availableCodecs();
|
auto codec_list = QTextCodec::availableCodecs();
|
||||||
for(auto codec : codec_list)
|
for (auto codec : codec_list)
|
||||||
_encoding_set->addItem(QString::fromLatin1(codec));
|
_encoding_set->addItem(QString::fromLatin1(codec));
|
||||||
connect(_encoding_set, QOverload<const QString&>::of(&QComboBox::currentIndexChanged),
|
connect(_encoding_set, QOverload<const QString&>::of(&QComboBox::currentIndexChanged),
|
||||||
[=](const QString &value) {
|
[=](const QString& value) {
|
||||||
if (this->_bind_u) {
|
if (this->_bind_u) {
|
||||||
auto ptr = std::dynamic_pointer_cast<extract::BytesAsString>(this->_bind_u);
|
auto ptr = std::dynamic_pointer_cast<extract::BytesAsString>(this->_bind_u);
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
|
@ -141,3 +150,98 @@ void EncodingConfiguration::currentRuleAccept(std::shared_ptr<ExtractUnit> u, co
|
||||||
QSignalBlocker x(this->_encoding_set);
|
QSignalBlocker x(this->_encoding_set);
|
||||||
this->_encoding_set->setCurrentText(codec_name);
|
this->_encoding_set->setCurrentText(codec_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <QHeaderView>
|
||||||
|
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<ExtractUnit> u, const QModelIndex& i)
|
||||||
|
{
|
||||||
|
this->_bind_u = std::dynamic_pointer_cast<extract::BytesAsBitCombine>(u);;
|
||||||
|
this->_bind_index = i;
|
||||||
|
|
||||||
|
this->reloadContent(this->_bind_u);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitCombineConfiguration::reloadContent(std::shared_ptr<extract::BytesAsBitCombine> 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);
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,29 @@ signals:
|
||||||
void currentRuleChanged(const QModelIndex& idx);
|
void currentRuleChanged(const QModelIndex& idx);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include "extract_basic.h"
|
||||||
|
class BitCombineConfiguration : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
std::shared_ptr<extract::BytesAsBitCombine> _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<ExtractUnit> u, const QModelIndex& i);
|
||||||
|
void reloadContent(std::shared_ptr<extract::BytesAsBitCombine> u);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void currentRuleChanged(const QModelIndex& idx);
|
||||||
|
};
|
||||||
|
|
||||||
class StructuralRuleView : public QWidget
|
class StructuralRuleView : public QWidget
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -132,7 +132,8 @@ void BytesAsBitCombine::saveTo(QJsonObject& obj) const
|
||||||
|
|
||||||
QStringList value_list;
|
QStringList value_list;
|
||||||
for (auto key : _switch_options.keys()) {
|
for (auto key : _switch_options.keys()) {
|
||||||
auto pair = QString("%1=%2").arg(key).arg(_switch_options[key]);
|
auto pair_str = QString("%1=%2").arg(key).arg(_switch_options[key]);
|
||||||
|
value_list << pair_str;
|
||||||
}
|
}
|
||||||
STRLIST_SAVE(value_list);
|
STRLIST_SAVE(value_list);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue