change:格式化xml单元设定一个窗口,可以选择性格式化哪些具体内容。
This commit is contained in:
87
form/qformatset.cpp
Normal file
87
form/qformatset.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "qformatset.h"
|
||||
|
||||
#include "../public_def.h"
|
||||
#include "ui_qformatset.h"
|
||||
|
||||
QFormatSet::QFormatSet(QWidget* parent)
|
||||
: QDialog(parent), ui(new Ui::QFormatSet)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->btnOk, &QPushButton::clicked, this, [&]() { handle(); });
|
||||
connect(ui->btnCancel, &QPushButton::clicked, this, [&]() {
|
||||
isok_ = false;
|
||||
close();
|
||||
});
|
||||
connect(ui->cbAll, &QCheckBox::toggled, this, [&]() { check_select(); });
|
||||
connect(ui->btnSelect, &QPushButton::clicked, this, [&]() {
|
||||
QString file = CUtil::select_file(this, u8"请选择xml文件",
|
||||
u8"XML(*.xml);;所有文件 (*)");
|
||||
if (file.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ui->edXmlPath->setText(file);
|
||||
});
|
||||
}
|
||||
|
||||
QFormatSet::~QFormatSet()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void QFormatSet::handle()
|
||||
{
|
||||
values_.clear();
|
||||
if (ui->cbAdd->isChecked()) {
|
||||
values_.push_back("+");
|
||||
}
|
||||
if (ui->cbAnd->isChecked()) {
|
||||
values_.push_back("&&");
|
||||
}
|
||||
if (ui->cbOr->isChecked()) {
|
||||
values_.push_back("||");
|
||||
}
|
||||
if (ui->cbMul->isChecked()) {
|
||||
values_.push_back("*");
|
||||
}
|
||||
if (ui->cbSub->isChecked()) {
|
||||
values_.push_back("-");
|
||||
}
|
||||
if (ui->cbDiv->isChecked()) {
|
||||
values_.push_back("/");
|
||||
}
|
||||
if (ui->cbLess->isChecked()) {
|
||||
values_.push_back("<");
|
||||
}
|
||||
if (ui->cbMore->isChecked()) {
|
||||
values_.push_back(">");
|
||||
}
|
||||
if (ui->cbEq->isChecked()) {
|
||||
values_.push_back("==");
|
||||
}
|
||||
if (ui->cbNotEq->isChecked()) {
|
||||
values_.push_back("!=");
|
||||
}
|
||||
xml_path_ = ui->edXmlPath->text().toStdString();
|
||||
isok_ = true;
|
||||
close();
|
||||
}
|
||||
|
||||
void QFormatSet::check_select()
|
||||
{
|
||||
auto set_check = [&](QCheckBox* ed, bool check) {
|
||||
if (ed) {
|
||||
ed->setChecked(check);
|
||||
}
|
||||
};
|
||||
bool check = ui->cbAll->isChecked();
|
||||
set_check(ui->cbAdd, check);
|
||||
set_check(ui->cbSub, check);
|
||||
set_check(ui->cbMul, check);
|
||||
set_check(ui->cbDiv, check);
|
||||
set_check(ui->cbLess, check);
|
||||
set_check(ui->cbMore, check);
|
||||
set_check(ui->cbOr, check);
|
||||
set_check(ui->cbAnd, check);
|
||||
set_check(ui->cbEq, check);
|
||||
set_check(ui->cbNotEq, check);
|
||||
}
|
||||
32
form/qformatset.h
Normal file
32
form/qformatset.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef QFORMATSET_H
|
||||
#define QFORMATSET_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <string>
|
||||
|
||||
namespace Ui {
|
||||
class QFormatSet;
|
||||
}
|
||||
|
||||
class QFormatSet : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QFormatSet(QWidget *parent = nullptr);
|
||||
~QFormatSet();
|
||||
|
||||
private:
|
||||
void handle();
|
||||
void check_select();
|
||||
|
||||
private:
|
||||
Ui::QFormatSet *ui;
|
||||
|
||||
public:
|
||||
std::vector<std::string> values_{};
|
||||
std::string xml_path_{};
|
||||
bool isok_{false};
|
||||
};
|
||||
|
||||
#endif // QFORMATSET_H
|
||||
202
form/qformatset.ui
Normal file
202
form/qformatset.ui
Normal file
@@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QFormatSet</class>
|
||||
<widget class="QDialog" name="QFormatSet">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>529</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>重排版</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>操作</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCustomQLineEdit" name="edXmlPath"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSelect">
|
||||
<property name="text">
|
||||
<string>选择</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>设置值内容指定字符前后空格</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbAnd">
|
||||
<property name="text">
|
||||
<string>与(双&&)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbOr">
|
||||
<property name="text">
|
||||
<string>或(||)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbLess">
|
||||
<property name="text">
|
||||
<string>小于(<)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbMore">
|
||||
<property name="text">
|
||||
<string>大于(>)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbAdd">
|
||||
<property name="text">
|
||||
<string>加(+)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbSub">
|
||||
<property name="text">
|
||||
<string>减(-)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbMul">
|
||||
<property name="text">
|
||||
<string>乘(*)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbDiv">
|
||||
<property name="text">
|
||||
<string>除(/)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbEq">
|
||||
<property name="text">
|
||||
<string>等(==)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbNotEq">
|
||||
<property name="text">
|
||||
<string>不等(!=)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbAll">
|
||||
<property name="text">
|
||||
<string>全选</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnOk">
|
||||
<property name="text">
|
||||
<string>确认</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnCancel">
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QCustomQLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>QCustomQLineEdit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user