mirror of
https://github.com/MountCloud/FireDog.git
synced 2026-10-17 04:31:05 +08:00
完善新规则引擎的规则树编辑
This commit is contained in:
@@ -151,7 +151,7 @@ FeatureLibrary* FeatureLibrary::createByYaml(std::string yaml, int* errorcode) {
|
||||
tree = ryml::parse_in_place(ryml::to_substr(yaml));
|
||||
parseStatus = true;
|
||||
}
|
||||
catch (std::runtime_error const&) {
|
||||
catch (...) {
|
||||
parseStatus = false;
|
||||
|
||||
}
|
||||
@@ -482,7 +482,30 @@ std::vector<mountcloud::Rule*> FeatureLibrary::parseRulesByYaml(c4::yml::NodeRef
|
||||
for (size_t child_id = tree->first_child(nodeid); child_id != ryml::NONE; child_id = tree->next_sibling(child_id)) {
|
||||
auto key = tree->key(child_id);
|
||||
auto childrule = node[key];
|
||||
if (key == "$and" || key == "$or" || key == "$not") {
|
||||
if (key == "$all") {
|
||||
vector<string> ids;
|
||||
long num = 1L;
|
||||
|
||||
if (childrule.is_keyval()) {
|
||||
string id;
|
||||
childrule >> id;
|
||||
ids.push_back(id);
|
||||
}
|
||||
else if (childrule.is_seq()) {
|
||||
int idslen = childrule.num_children();
|
||||
for (int i = 0; i < idslen; i++) {
|
||||
auto crj = childrule[i];
|
||||
string id;
|
||||
crj >> id;
|
||||
ids.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (ids.size() > 0) {
|
||||
AllRule* allRule = new AllRule(ids);
|
||||
rules.push_back(allRule);
|
||||
}
|
||||
}else if (key == "$and" || key == "$or" || key == "$not") {
|
||||
LogicRule* logicRule = NULL;
|
||||
vector<Rule*> childRules = parseRulesByYaml(childrule);
|
||||
if (childRules.size() > 0) {
|
||||
@@ -526,7 +549,12 @@ std::vector<mountcloud::Rule*> FeatureLibrary::parseRulesByYaml(c4::yml::NodeRef
|
||||
auto crj = childrule[i];
|
||||
string id;
|
||||
crj >> id;
|
||||
ids.push_back(id);
|
||||
if (StringUtil::isNumber(id)&&i==idslen-1) {
|
||||
num = atoi(id.c_str());
|
||||
}
|
||||
else {
|
||||
ids.push_back(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ bool OrRule::check(RuleData* data) {
|
||||
}
|
||||
|
||||
NotRule::NotRule() {
|
||||
baseType = RULE_TYPE_LOGIC_NOT;
|
||||
type = RULE_TYPE_LOGIC_NOT;
|
||||
}
|
||||
|
||||
bool NotRule::check(RuleData* data) {
|
||||
|
||||
@@ -669,20 +669,31 @@ void FireDogEditor::slots_featureInfoRuleTreeOpenMenu(QPoint pos) {
|
||||
QModelIndex currIndex = ui.treeViewLibraryInfoRules->currentIndex();;
|
||||
int curRow = currIndex.row(); //选中行
|
||||
|
||||
bool isKey = false;
|
||||
if (curRow != -1) {
|
||||
QStandardItem* item = this->featureLibraryInfoRuleTreeModel->itemFromIndex(currIndex);
|
||||
QString text = item->text();
|
||||
if (text != "$and" && text != "$or") {
|
||||
isKey = true;
|
||||
bool isLogic = false;
|
||||
bool isCompareChild = false;
|
||||
if (curRow != -1) {
|
||||
QStandardItem* item = this->featureLibraryInfoRuleTreeModel->itemFromIndex(currIndex);
|
||||
QString text = item->text();
|
||||
if (text == "$and" || text == "$or" || text == "$not") {
|
||||
isLogic = true;
|
||||
}
|
||||
else if(text.startsWith("$count")||text.startsWith("$int")) {
|
||||
QStandardItem* pitem = item->parent();
|
||||
if (pitem != NULL) {
|
||||
QString ptext = pitem->text();
|
||||
if (ptext == "$lt"||ptext == "$le" || ptext == "$gt" || ptext == "$ge") {
|
||||
isCompareChild = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isKey || (this->featureLibraryInfoRuleTreeModel->rowCount() != 0 && curRow == -1)) {
|
||||
this->featureLibraryInfoRuleTreeMenuAddAction->setEnabled(false);
|
||||
if (isLogic || (this->featureLibraryInfoRuleTreeModel->rowCount() == 0 && curRow == -1)) {
|
||||
this->featureLibraryInfoRuleTreeMenuAddAction->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
this->featureLibraryInfoRuleTreeMenuAddAction->setEnabled(true);
|
||||
this->featureLibraryInfoRuleTreeMenuAddAction->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -695,6 +706,13 @@ void FireDogEditor::slots_featureInfoRuleTreeOpenMenu(QPoint pos) {
|
||||
featureLibraryInfoRuleTreeMenuDelAction->setEnabled(true);
|
||||
}
|
||||
|
||||
if (isCompareChild) {
|
||||
featureLibraryInfoRuleTreeMenuDelAction->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
featureLibraryInfoRuleTreeMenuDelAction->setEnabled(true);
|
||||
}
|
||||
|
||||
auto index = ui.treeViewLibraryInfoRules->indexAt(pos);
|
||||
featureLibraryInfoRuleTreeMenu->exec(QCursor::pos()); // 菜单出现的位置为当前鼠标的位置
|
||||
}
|
||||
@@ -740,16 +758,16 @@ void FireDogEditor::slots_selectFeatureTableEvent(const QModelIndex& current, co
|
||||
|
||||
QStandardItem* FireDogEditor::ruleToItem(mountcloud::Rule* rule) {
|
||||
QStandardItem* ruleitem = new QStandardItem();
|
||||
|
||||
if (rule->getBaseType() == RULE_BASE_TYPE_ALL) {
|
||||
ruleitem->setText(QStringLiteral("$all"));
|
||||
mountcloud::AllRule* allRule = (mountcloud::AllRule*) rule;
|
||||
std::vector<std::string> ids = allRule->getIds();
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
QStandardItem* idsItem = new QStandardItem();
|
||||
idsItem->setText(QString(ids[i].c_str()));
|
||||
ruleitem->appendRow(idsItem);
|
||||
}
|
||||
if (rule->getBaseType() == RULE_BASE_TYPE_ALL) {
|
||||
mountcloud::AllRule* allRule = (mountcloud::AllRule*)rule;
|
||||
QString allText = "$all:";
|
||||
for (int i = 0; i < allRule->getIds().size(); i++) {
|
||||
allText += QString::fromStdString(allRule->getIds().at(i));
|
||||
if (i != allRule->getIds().size() - 1) {
|
||||
allText += ",";
|
||||
}
|
||||
}
|
||||
ruleitem->setText(allText);
|
||||
}
|
||||
else if(rule->getBaseType() == RULE_BASE_TYPE_LOGIC) {
|
||||
mountcloud::LogicRule* logicRule = (mountcloud::LogicRule*)rule;
|
||||
@@ -773,21 +791,21 @@ QStandardItem* FireDogEditor::ruleToItem(mountcloud::Rule* rule) {
|
||||
}
|
||||
else if (rule->getType() == RULE_TYPE_NUMBER_INT) {
|
||||
mountcloud::IntRule* intRule = (mountcloud::IntRule*)rule;
|
||||
|
||||
ruleitem->setText(QStringLiteral("$int"));
|
||||
QStandardItem* citem = new QStandardItem();
|
||||
citem->setText(QString::number(intRule->getNum()));
|
||||
ruleitem->appendRow(citem);
|
||||
QString intText = "$int:";
|
||||
intText += QString::number(intRule->getNum());
|
||||
ruleitem->setText(intText);
|
||||
}
|
||||
else if (rule->getType() == RULE_TYPE_NUMBER_COUNT) {
|
||||
mountcloud::CountRule* countRule = (mountcloud::CountRule*)rule;
|
||||
|
||||
ruleitem->setText(QStringLiteral("$count"));
|
||||
QString countText = "$count:";
|
||||
for (int i = 0; i < countRule->getIds().size(); i++) {
|
||||
QStandardItem* idsItem = new QStandardItem();
|
||||
idsItem->setText(QString(countRule->getIds()[i].c_str()));
|
||||
ruleitem->appendRow(idsItem);
|
||||
}
|
||||
countText += QString::fromStdString(countRule->getIds().at(i));
|
||||
if (i!= countRule->getIds().size() - 1) {
|
||||
countText += ",";
|
||||
}
|
||||
}
|
||||
ruleitem->setText(countText);
|
||||
}
|
||||
else if (rule->getBaseType() == RULE_BASE_TYPE_COMPARE) {
|
||||
|
||||
@@ -971,15 +989,20 @@ void FireDogEditor::clearInfoContent(bool isFeatureAdd) {
|
||||
}
|
||||
|
||||
void FireDogEditor::slots_featureLibraryInfoRuleMenuAddEvent() {
|
||||
QModelIndex currIndex = ui.treeViewLibraryInfoRules->currentIndex();;
|
||||
int curRow = currIndex.row(); //选中行
|
||||
|
||||
bool ruleIsEmpty = this->featureLibraryInfoRuleTreeModel->rowCount() == 0;
|
||||
bool isRoot = false;
|
||||
if (ruleIsEmpty) {
|
||||
isRoot = true;
|
||||
bool ruleIsEmpty = this->featureLibraryInfoRuleTreeModel->rowCount() == 0;
|
||||
|
||||
QVector<QString> childs;
|
||||
QString parent;
|
||||
if (curRow != -1) {
|
||||
QStandardItem* selectItem = this->featureLibraryInfoRuleTreeModel->itemFromIndex(currIndex);
|
||||
parent = selectItem->text();
|
||||
}
|
||||
|
||||
QString rule;
|
||||
bool isOk = this->fireDogFeatureRuleInfoView->updateRule(&rule, isRoot);
|
||||
bool isOk = this->fireDogFeatureRuleInfoView->updateRule(&rule, &childs, parent);
|
||||
if (isOk) {
|
||||
QStandardItem* ruleitem = new QStandardItem(rule);
|
||||
//如果是空的
|
||||
@@ -987,7 +1010,6 @@ void FireDogEditor::slots_featureLibraryInfoRuleMenuAddEvent() {
|
||||
featureLibraryInfoRuleTreeModel->appendRow(ruleitem);
|
||||
}
|
||||
else {
|
||||
QModelIndex currIndex = ui.treeViewLibraryInfoRules->currentIndex();;
|
||||
QStandardItem* selectItem = this->featureLibraryInfoRuleTreeModel->itemFromIndex(currIndex);
|
||||
selectItem->appendRow(ruleitem);
|
||||
}
|
||||
@@ -1005,8 +1027,22 @@ void FireDogEditor::slots_featureLibraryInfoRuleMenuEditEvent() {
|
||||
|
||||
bool isRoot = selectItem->parent() == NULL;
|
||||
|
||||
QVector<QString> childs;
|
||||
QString parent;
|
||||
QString rule = selectItem->text();
|
||||
bool isOk = this->fireDogFeatureRuleInfoView->updateRule(&rule, isRoot);
|
||||
|
||||
QStandardItem* selectItemParent = selectItem->parent();
|
||||
if (selectItemParent!=NULL) {
|
||||
parent = selectItemParent->text();
|
||||
}
|
||||
|
||||
int count = selectItem->rowCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
QStandardItem* childItem = selectItem->child(i);
|
||||
childs.push_back(childItem->text());
|
||||
}
|
||||
|
||||
bool isOk = this->fireDogFeatureRuleInfoView->updateRule(&rule, &childs, parent);
|
||||
if (isOk) {
|
||||
selectItem->setText(rule);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,6 @@ void FireDogFeatureInfo::slots_cancel() {
|
||||
this->hide();
|
||||
}
|
||||
|
||||
|
||||
FireDogFeatureInfo::~FireDogFeatureInfo()
|
||||
{
|
||||
delete ui;
|
||||
|
||||
@@ -25,41 +25,96 @@ void FireDogFeatureRuleInfo::init() {
|
||||
this->keyValidator = new QRegExpValidator(keyregx, ui->lineEditKey);
|
||||
ui->lineEditKey->setValidator(keyValidator);
|
||||
|
||||
ui->comboBoxNum1Type->addItem("$count");
|
||||
ui->comboBoxNum1Type->addItem("$int");
|
||||
ui->spinBoxNum1Int->setVisible(false);
|
||||
|
||||
ui->comboBoxNum2Type->addItem("$count");
|
||||
ui->comboBoxNum2Type->addItem("$int");
|
||||
ui->spinBoxNum2Int->setVisible(false);
|
||||
|
||||
connect(ui->radioButtonAnd, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
connect(ui->radioButtonOr, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
connect(ui->radioButtonKey, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
connect(ui->radioButtonNot, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
|
||||
connect(ui->radioButtonAll, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
connect(ui->radioButtonCount, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
connect(ui->radioButtonInt, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
|
||||
connect(ui->radioButtonLt, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
connect(ui->radioButtonLe, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
connect(ui->radioButtonGt, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
connect(ui->radioButtonGe, &QRadioButton::clicked, this, &FireDogFeatureRuleInfo::slots_radioClick);
|
||||
|
||||
connect(ui->pushButtonSave, &QPushButton::clicked, this, &FireDogFeatureRuleInfo::slots_saveClick);
|
||||
connect(ui->pushButtonCancel, &QPushButton::clicked, this, &FireDogFeatureRuleInfo::slots_cancelClick);
|
||||
|
||||
|
||||
connect(ui->comboBoxNum1Type, SIGNAL(currentIndexChanged(QString)), this, SLOT(currentIndexChanged(QString)));
|
||||
connect(ui->comboBoxNum2Type, SIGNAL(currentIndexChanged(QString)), this, SLOT(currentIndexChanged(QString)));
|
||||
|
||||
//i18n
|
||||
Gui18nUtil::SetText(ui->labelType, "feature-rule-info-type");
|
||||
//Gui18nUtil::SetText(ui->labelType, "feature-rule-info-type");
|
||||
Gui18nUtil::SetText(ui->labelKey, "feature-rule-info-key");
|
||||
Gui18nUtil::SetText(ui->pushButtonSave, "feature-rule-info-save");
|
||||
Gui18nUtil::SetText(ui->pushButtonCancel, "feature-rule-info-cancel");
|
||||
}
|
||||
|
||||
void FireDogFeatureRuleInfo::slots_radioClick() {
|
||||
if (ui->radioButtonAnd->isChecked() || ui->radioButtonOr->isChecked()) {
|
||||
ui->lineEditKey->setReadOnly(true);
|
||||
if (ui->radioButtonAll->isChecked() || ui->radioButtonCount->isChecked()) {
|
||||
ui->stackedWidgetRuleInfo->setCurrentIndex(0);
|
||||
ui->lineEditKey->setReadOnly(false);
|
||||
}
|
||||
else {
|
||||
ui->lineEditKey->setReadOnly(false);
|
||||
ui->lineEditKey->setReadOnly(true);
|
||||
}
|
||||
|
||||
if (ui->radioButtonInt->isChecked()) {
|
||||
ui->stackedWidgetRuleInfo->setCurrentIndex(1);
|
||||
ui->spinBoxInt->setReadOnly(false);
|
||||
ui->spinBoxInt->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
ui->spinBoxInt->setReadOnly(true);
|
||||
ui->spinBoxInt->setEnabled(false);
|
||||
}
|
||||
|
||||
if (ui->radioButtonLt->isChecked()|| ui->radioButtonLe->isChecked()|| ui->radioButtonGt->isChecked()|| ui->radioButtonGe->isChecked()) {
|
||||
ui->stackedWidgetRuleInfo->setCurrentIndex(2);
|
||||
|
||||
ui->comboBoxNum1Type->setEnabled(true);
|
||||
ui->lineEditNum1Count->setEnabled(true);
|
||||
ui->spinBoxNum1Int->setEnabled(true);
|
||||
|
||||
ui->comboBoxNum2Type->setEnabled(true);
|
||||
ui->lineEditNum2Count->setEnabled(true);
|
||||
ui->spinBoxNum2Int->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
|
||||
ui->comboBoxNum1Type->setEnabled(false);
|
||||
ui->lineEditNum1Count->setEnabled(false);
|
||||
ui->spinBoxNum1Int->setEnabled(false);
|
||||
|
||||
ui->comboBoxNum2Type->setEnabled(false);
|
||||
ui->lineEditNum2Count->setEnabled(false);
|
||||
ui->spinBoxNum2Int->setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FireDogFeatureRuleInfo::slots_saveClick() {
|
||||
this->isOk = true;
|
||||
|
||||
if (ui->radioButtonKey->isChecked()){
|
||||
if (ui->lineEditKey->text().isEmpty()) {
|
||||
QString titleStr = Gui18n::GetInstance()->GetConfig("text-message-box-title-warning", "Warning");
|
||||
QString messageStr = Gui18n::GetInstance()->GetConfig("feature-rule-please-enter-key", "Please enter [Key].");
|
||||
QssMessageBox::warn(messageStr, this, titleStr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//if (ui->radioButtonKey->isChecked()){
|
||||
// if (ui->lineEditKey->text().isEmpty()) {
|
||||
// QString titleStr = Gui18n::GetInstance()->GetConfig("text-message-box-title-warning", "Warning");
|
||||
// QString messageStr = Gui18n::GetInstance()->GetConfig("feature-rule-please-enter-key", "Please enter [Key].");
|
||||
// QssMessageBox::warn(messageStr, this, titleStr);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
this->hide();
|
||||
}
|
||||
@@ -69,32 +124,99 @@ void FireDogFeatureRuleInfo::slots_cancelClick() {
|
||||
this->hide();
|
||||
}
|
||||
|
||||
bool FireDogFeatureRuleInfo::updateRule(QString* rule, bool isRoot) {
|
||||
bool FireDogFeatureRuleInfo::updateRule(QString* rule, QVector<QString>* childs, QString parent) {
|
||||
this->isOk = false;
|
||||
setDefaultValue();
|
||||
|
||||
if (isRoot) {
|
||||
ui->radioButtonKey->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
ui->radioButtonKey->setEnabled(true);
|
||||
}
|
||||
// if (isRoot) {
|
||||
// //ui->radioButtonKey->setEnabled(false);
|
||||
// }
|
||||
//else {
|
||||
// //ui->radioButtonKey->setEnabled(true);
|
||||
// }
|
||||
|
||||
if (rule->isEmpty() || *rule == "$and") {
|
||||
ui->radioButtonAnd->setChecked(true);
|
||||
ui->lineEditKey->setReadOnly(true);
|
||||
auto getRuleInfoByStr = [](QString& rulestr) {
|
||||
int index = rulestr.lastIndexOf(":");
|
||||
QString infostr = rulestr.mid(index+1);
|
||||
return infostr;
|
||||
};
|
||||
|
||||
ui->lineEditKey->setText("");
|
||||
}else if(*rule == "$or") {
|
||||
ui->radioButtonOr->setChecked(true);
|
||||
ui->lineEditKey->setReadOnly(true);
|
||||
if (!rule->isEmpty()) {
|
||||
if (*rule == "$and") {
|
||||
ui->radioButtonAnd->setChecked(true);
|
||||
}
|
||||
else if (*rule == "$or") {
|
||||
ui->radioButtonOr->setChecked(true);
|
||||
}
|
||||
else if (*rule == "$not") {
|
||||
ui->radioButtonNot->setChecked(true);
|
||||
}
|
||||
//////////////////////////
|
||||
else if (rule->startsWith("$all")) {
|
||||
ui->radioButtonAll->setChecked(true);
|
||||
}
|
||||
else if (rule->startsWith("$count")) {
|
||||
ui->radioButtonCount->setChecked(true);
|
||||
}
|
||||
else if (rule->startsWith("$int")) {
|
||||
ui->radioButtonInt->setChecked(true);
|
||||
}
|
||||
//////////////////////////
|
||||
else if (*rule == "$lt") {
|
||||
ui->radioButtonLt->setChecked(true);
|
||||
}
|
||||
else if (*rule == "$le") {
|
||||
ui->radioButtonLe->setChecked(true);
|
||||
}
|
||||
else if (*rule == "$gt") {
|
||||
ui->radioButtonGt->setChecked(true);
|
||||
}
|
||||
else if (*rule == "$ge") {
|
||||
ui->radioButtonGe->setChecked(true);
|
||||
}
|
||||
|
||||
ui->lineEditKey->setText("");
|
||||
}
|
||||
else {
|
||||
ui->radioButtonKey->setChecked(true);
|
||||
ui->lineEditKey->setReadOnly(false);
|
||||
ui->lineEditKey->setText(*rule);
|
||||
}
|
||||
//设置默认值
|
||||
if (rule->startsWith("$all") || rule->startsWith("$count")) {
|
||||
QString infostr = getRuleInfoByStr(*rule);
|
||||
ui->lineEditKey->setText(infostr);
|
||||
}
|
||||
else if (rule->startsWith("$int")) {
|
||||
QString infostr = getRuleInfoByStr(*rule);
|
||||
int intval = infostr.toInt();
|
||||
ui->spinBoxInt->setValue(intval);
|
||||
}
|
||||
else if (*rule == "$lt" || *rule == "$le" || *rule == "$gt" || *rule == "$ge") {
|
||||
QString num1 = childs->at(0);
|
||||
QString num2 = childs->at(1);
|
||||
|
||||
if (num1.startsWith("$count")) {
|
||||
ui->comboBoxNum1Type->setCurrentIndex(0);
|
||||
QString infostr = getRuleInfoByStr(num1);
|
||||
ui->lineEditNum1Count->setText(infostr);
|
||||
}
|
||||
else {
|
||||
ui->comboBoxNum1Type->setCurrentIndex(1);
|
||||
QString infostr = getRuleInfoByStr(num1);
|
||||
int intval = infostr.toInt();
|
||||
ui->spinBoxNum1Int->setValue(intval);
|
||||
}
|
||||
|
||||
if (num2.startsWith("$count")) {
|
||||
ui->comboBoxNum2Type->setCurrentIndex(0);
|
||||
QString infostr = getRuleInfoByStr(num2);
|
||||
ui->lineEditNum2Count->setText(infostr);
|
||||
}
|
||||
else {
|
||||
ui->comboBoxNum2Type->setCurrentIndex(1);
|
||||
QString infostr = getRuleInfoByStr(num2);
|
||||
int intval = infostr.toInt();
|
||||
ui->spinBoxNum2Int->setValue(intval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//触发一下刷新
|
||||
slots_radioClick();
|
||||
|
||||
this->exec();
|
||||
|
||||
@@ -115,3 +237,47 @@ bool FireDogFeatureRuleInfo::updateRule(QString* rule, bool isRoot) {
|
||||
|
||||
return this->isOk;
|
||||
}
|
||||
|
||||
|
||||
void FireDogFeatureRuleInfo::currentIndexChanged(const QString text) {
|
||||
QObject* obj = sender();
|
||||
if (obj == ui->comboBoxNum1Type) {
|
||||
if (text == "$count") {
|
||||
ui->spinBoxNum1Int->setVisible(false);
|
||||
ui->lineEditNum1Count->setVisible(true);
|
||||
}
|
||||
else {
|
||||
ui->spinBoxNum1Int->setVisible(true);
|
||||
ui->lineEditNum1Count->setVisible(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (text == "$count") {
|
||||
ui->spinBoxNum2Int->setVisible(false);
|
||||
ui->lineEditNum2Count->setVisible(true);
|
||||
}
|
||||
else {
|
||||
ui->spinBoxNum2Int->setVisible(true);
|
||||
ui->lineEditNum2Count->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FireDogFeatureRuleInfo::setDefaultValue() {
|
||||
ui->radioButtonAnd->setChecked(true);
|
||||
|
||||
ui->lineEditKey->setText("");
|
||||
|
||||
ui->spinBoxInt->setValue(1);
|
||||
|
||||
ui->lineEditNum1Count->setText("");
|
||||
ui->spinBoxNum1Int->setValue(1);
|
||||
|
||||
ui->lineEditNum2Count->setText("");
|
||||
ui->spinBoxNum2Int->setValue(1);
|
||||
|
||||
ui->stackedWidgetRuleInfo->setCurrentIndex(0);
|
||||
|
||||
slots_radioClick();
|
||||
}
|
||||
|
||||
@@ -21,12 +21,13 @@ public:
|
||||
explicit FireDogFeatureRuleInfo(QWidget *parent = nullptr);
|
||||
~FireDogFeatureRuleInfo();
|
||||
|
||||
bool updateRule(QString* rule,bool isRoot);
|
||||
bool updateRule(QString* rule,QVector<QString>* childs,QString parent);
|
||||
|
||||
private slots:
|
||||
void slots_radioClick();
|
||||
void slots_saveClick();
|
||||
void slots_cancelClick();
|
||||
void currentIndexChanged(const QString text);
|
||||
|
||||
private:
|
||||
Ui::FireDogFeatureRuleInfo *ui;
|
||||
@@ -36,6 +37,7 @@ private:
|
||||
bool isOk = false;
|
||||
|
||||
void init();
|
||||
void setDefaultValue();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>310</width>
|
||||
<height>190</height>
|
||||
<width>373</width>
|
||||
<height>378</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -19,121 +19,11 @@
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="labelType">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>72</width>
|
||||
<height>15</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonAnd">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>35</y>
|
||||
<width>61</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$and</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonOr">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>35</y>
|
||||
<width>61</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$or</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonKey">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>35</y>
|
||||
<width>61</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelKey">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>80</y>
|
||||
<width>72</width>
|
||||
<height>15</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>60</y>
|
||||
<width>311</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEditKey">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>105</y>
|
||||
<width>291</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>0-9a-zA-Z</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>130</y>
|
||||
<width>311</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButtonSave">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>150</y>
|
||||
<y>340</y>
|
||||
<width>93</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
@@ -145,8 +35,8 @@
|
||||
<widget class="QPushButton" name="pushButtonCancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>150</y>
|
||||
<x>270</x>
|
||||
<y>340</y>
|
||||
<width>93</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
@@ -155,6 +45,503 @@
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBoxType">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>351</width>
|
||||
<height>145</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButtonInt">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>235</x>
|
||||
<y>71</y>
|
||||
<width>59</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$int</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonOr">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>123</x>
|
||||
<y>26</y>
|
||||
<width>51</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$or</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>123</x>
|
||||
<y>71</y>
|
||||
<width>75</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$count</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonAnd">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>26</y>
|
||||
<width>59</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$and</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonAll">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>71</y>
|
||||
<width>59</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$all</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonNot">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>235</x>
|
||||
<y>26</y>
|
||||
<width>59</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$not</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>50</y>
|
||||
<width>331</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>90</y>
|
||||
<width>331</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonLt">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>111</y>
|
||||
<width>51</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$lt</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonLe">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>95</x>
|
||||
<y>111</y>
|
||||
<width>51</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$le</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonGt">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>179</x>
|
||||
<y>111</y>
|
||||
<width>51</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$gt</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonGe">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>263</x>
|
||||
<y>111</y>
|
||||
<width>51</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>$ge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBoxRuleInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>351</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>RuleInfo</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QStackedWidget" name="stackedWidgetRuleInfo">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pageKey">
|
||||
<widget class="QLineEdit" name="lineEditKey">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>20</y>
|
||||
<width>261</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>0-9a-zA-Z,</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelKey">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>31</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelKeyTips">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>311</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:rgb(99, 99, 99);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Separate multiple ids with commas (,).</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageInt">
|
||||
<widget class="QLabel" name="labelInt">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>31</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Int</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBoxInt">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>20</y>
|
||||
<width>271</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelNumTips">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>311</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:rgb(99, 99, 99);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Only numbers are allowed.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageCompage">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>301</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelNum1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Num1</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelNum2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>50</y>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Num2</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBoxNum1Type">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>10</y>
|
||||
<width>91</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBoxNum2Type">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>50</y>
|
||||
<width>91</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelCompageTips">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>80</y>
|
||||
<width>311</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:rgb(99, 99, 99);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Separate multiple ids with commas (,).</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>10</y>
|
||||
<width>161</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEditNum1Count">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>0-9a-zA-Z,</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxNum1Int">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>50</y>
|
||||
<width>161</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEditNum2Count">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>0-9a-zA-Z,</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxNum2Int">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>320</y>
|
||||
<width>351</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>160</y>
|
||||
<width>351</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user