fix:v1.3.1修复BUG。
This commit is contained in:
parent
b05783191f
commit
f2b1525b92
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -19,7 +19,7 @@
|
||||
"visualizerFile": "${workspaceRoot}/.vscode/qt6.natvis"
|
||||
},
|
||||
"cmake.environment": {
|
||||
"PATH": "${env:PATH};C:/Qt/6.6.3/msvc2019_64/bin"
|
||||
"PATH": "${env:PATH};C:/Qt/6.7.2/bin"
|
||||
},
|
||||
"cmake.options.statusBarVisibility": "visible",
|
||||
"cmake.generator": "Ninja",
|
||||
|
@ -13,7 +13,8 @@ endif()
|
||||
message(STATUS "User home directory: ${USER_HOME}")
|
||||
|
||||
set(CMAKE_PREFIX_PATH
|
||||
"C:/Qt/6.6.3/msvc2019_64"
|
||||
${CMAKE_PREFIX_PATH}
|
||||
"C:/Qt/6.7.2"
|
||||
"${USER_HOME}/Qt5.14.2/5.14.2/gcc_64/"
|
||||
)
|
||||
|
||||
|
@ -18,7 +18,7 @@ MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowTitle(u8"OneLevelXmlOpr v1.3.0");
|
||||
setWindowTitle(u8"OneLevelXmlOpr v1.3.1");
|
||||
setWindowIcon(QIcon("://resource/xml.ico"));
|
||||
|
||||
QScreen* primaryScreen = QGuiApplication::primaryScreen();
|
||||
@ -483,7 +483,7 @@ bool MainWidget::edit_property(Element_t* target, int row)
|
||||
}
|
||||
|
||||
attri_edit_->get_attribute(property);
|
||||
if (property[0].value != value_pre) {
|
||||
if (property[0].value == value_pre) {
|
||||
while (xml_.check_key_exists(property)) {
|
||||
CUtil::msg(attri_edit_, u8"不能有相同的key,请检查。");
|
||||
attri_edit_->exec();
|
||||
|
@ -4,4 +4,4 @@
|
||||
|
||||
# 编译环境
|
||||
|
||||
在 `msvc Qt5.14.2` 和 `vs2017` 环境下通过。
|
||||
`windows`下,`Qt6`可正常使用无乱码。
|
BIN
resource/xml.ico
BIN
resource/xml.ico
Binary file not shown.
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 17 KiB |
BIN
resource/xml.png
BIN
resource/xml.png
Binary file not shown.
Before Width: | Height: | Size: 9.1 KiB |
@ -1,4 +1,5 @@
|
||||
#include "attribute_edit.h"
|
||||
|
||||
#include "ui_attribute_edit.h"
|
||||
|
||||
CAttributeEdit::CAttributeEdit(QWidget* parent) : QDialog(parent), ui(new Ui::CAttributeEdit)
|
||||
@ -22,13 +23,12 @@ void CAttributeEdit::handle_ok()
|
||||
for (int i = 0; i < row; ++i) {
|
||||
QString key = table_->item(i, 0)->text();
|
||||
QString value = table_->item(i, 1)->text();
|
||||
property_.emplace_back(key.toLocal8Bit().constData(), value.toLocal8Bit().constData());
|
||||
property_.emplace_back(key.toStdString().c_str(), value.toStdString().c_str());
|
||||
}
|
||||
is_ok_ = true;
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
CAttributeEdit::~CAttributeEdit()
|
||||
{
|
||||
delete ui;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <filesystem>
|
||||
|
||||
@ -13,7 +14,7 @@ void CGroupIni::default_set()
|
||||
QDir dir;
|
||||
std::string path = dir.homePath().toStdString();
|
||||
fs::path p(path);
|
||||
p.append(".config");
|
||||
p.append(".config/OneLevelXmlOpr");
|
||||
|
||||
if (!fs::exists(p)) {
|
||||
fs::create_directories(p);
|
||||
@ -41,7 +42,7 @@ void CGroupIni::get_all_node(StrVec_t& vec)
|
||||
{
|
||||
vec.clear();
|
||||
|
||||
CSimpleIni::TNamesDepend secs;
|
||||
CSimpleIniA::TNamesDepend secs;
|
||||
ini_.GetAllSections(secs);
|
||||
for (const auto& sec : secs) {
|
||||
vec.push_back(sec.pItem);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <SimpleIni.h>
|
||||
|
||||
#include <vector>
|
||||
/*
|
||||
|
||||
[Basic]
|
||||
|
@ -1,11 +1,14 @@
|
||||
#include "data_edit.h"
|
||||
#include "ui_data_edit.h"
|
||||
#include <QScreen>
|
||||
#include <QClipboard>
|
||||
|
||||
#include <tinyxml2.h>
|
||||
#include <vector>
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QScreen>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../public_def.h"
|
||||
#include "ui_data_edit.h"
|
||||
|
||||
CDataEdit::CDataEdit(QWidget* parent) : QDialog(parent), ui(new Ui::CDataEdit)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ void CHistory::default_set()
|
||||
QDir dir;
|
||||
std::string path = dir.homePath().toStdString();
|
||||
fs::path p(path);
|
||||
p.append(".config");
|
||||
p.append(".config/OneLevelXmlOpr");
|
||||
|
||||
if (!fs::exists(p)) {
|
||||
fs::create_directories(p);
|
||||
|
@ -1,7 +1,9 @@
|
||||
#include "xml_opr.h"
|
||||
#include "../public_def.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "../public_def.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
CXmlOpr::CXmlOpr() = default;
|
||||
@ -13,12 +15,13 @@ bool CXmlOpr::open(const std::string& xml_path)
|
||||
if (doc_.LoadFile(CUtil::utf8_to_gbk(xml_path).c_str()) != tinyxml2::XML_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
xml_path_ = CUtil::utf8_to_gbk(xml_path);
|
||||
#else
|
||||
if (doc_.LoadFile(xml_path.c_str()) != tinyxml2::XML_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
xml_path_ = xml_path;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -44,21 +47,21 @@ bool CXmlOpr::get_all_elements(std::vector<Element_t*>& vec, const std::string&
|
||||
{
|
||||
vec.clear();
|
||||
|
||||
Element_t* temp = parent_node_;
|
||||
parent_node2_ = parent_node_;
|
||||
|
||||
if (!unit.empty()) {
|
||||
temp = temp->FirstChildElement(unit.c_str());
|
||||
parent_node2_ = parent_node2_->FirstChildElement(unit.c_str());
|
||||
}
|
||||
|
||||
if (!opr_base_.relative_nodes.empty()) {
|
||||
auto v = CUtil::splitString(opr_base_.relative_nodes, ",");
|
||||
// 向下子项跳跃
|
||||
for (const auto& it : v) {
|
||||
temp = temp->FirstChildElement(it.c_str());
|
||||
parent_node2_ = parent_node2_->FirstChildElement(it.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
auto purpose_node = temp->FirstChildElement(opr_base_.item_key.c_str());
|
||||
auto purpose_node = parent_node2_->FirstChildElement(opr_base_.item_key.c_str());
|
||||
while (purpose_node) {
|
||||
vec.push_back(purpose_node);
|
||||
purpose_node = purpose_node->NextSiblingElement();
|
||||
@ -81,7 +84,6 @@ bool CXmlOpr::parse_xml(std::vector<tinyxml2::XMLElement*>& vec)
|
||||
|
||||
auto nodes = CUtil::splitString(opr_base_.main_nodes, "/");
|
||||
for (const auto& item : nodes) {
|
||||
|
||||
if (item.empty()) {
|
||||
continue;
|
||||
}
|
||||
@ -93,6 +95,10 @@ bool CXmlOpr::parse_xml(std::vector<tinyxml2::XMLElement*>& vec)
|
||||
}
|
||||
}
|
||||
|
||||
if (parent_node_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (opr_base_.is_same) {
|
||||
units_.clear();
|
||||
auto p = parent_node_->FirstChildElement();
|
||||
@ -121,7 +127,7 @@ void CXmlOpr::copy_and_del(std::vector<Element_t*>& vec, std::vector<Element_t*>
|
||||
{
|
||||
out.clear();
|
||||
// 先找到最后一个节点
|
||||
Element_t* last_node = parent_node_->LastChildElement(opr_base_.item_key.c_str());
|
||||
Element_t* last_node = parent_node2_->LastChildElement(opr_base_.item_key.c_str());
|
||||
Element_t* last_node_bk = last_node;
|
||||
if (last_node == nullptr) {
|
||||
return;
|
||||
@ -133,14 +139,14 @@ void CXmlOpr::copy_and_del(std::vector<Element_t*>& vec, std::vector<Element_t*>
|
||||
last_node = n;
|
||||
}
|
||||
// 删除原有的节点
|
||||
Element_t* fnode = parent_node_->FirstChildElement(opr_base_.item_key.c_str());
|
||||
Element_t* fnode = parent_node2_->FirstChildElement(opr_base_.item_key.c_str());
|
||||
Element_t* fnext = fnode->NextSiblingElement();
|
||||
while (fnode != last_node_bk) {
|
||||
parent_node_->DeleteChild(fnode);
|
||||
parent_node2_->DeleteChild(fnode);
|
||||
fnode = fnext;
|
||||
fnext = fnode->NextSiblingElement();
|
||||
}
|
||||
parent_node_->DeleteChild(last_node_bk);
|
||||
parent_node2_->DeleteChild(last_node_bk);
|
||||
}
|
||||
|
||||
void CXmlOpr::insert_brother_node(Element_t* brother, Element_t* newer)
|
||||
@ -148,7 +154,7 @@ void CXmlOpr::insert_brother_node(Element_t* brother, Element_t* newer)
|
||||
if (!brother || !newer) {
|
||||
return;
|
||||
}
|
||||
parent_node_->InsertAfterChild(brother, newer);
|
||||
parent_node2_->InsertAfterChild(brother, newer);
|
||||
}
|
||||
|
||||
Element_t* CXmlOpr::copy_element(Element_t* ele)
|
||||
@ -177,7 +183,7 @@ bool CXmlOpr::check_valid_xml_data(const std::string& data)
|
||||
|
||||
bool CXmlOpr::check_same_struct(const std::string& data)
|
||||
{
|
||||
auto* own_ele = parent_node_->FirstChildElement(opr_base_.item_key.c_str());
|
||||
auto* own_ele = parent_node2_->FirstChildElement(opr_base_.item_key.c_str());
|
||||
if (own_ele == nullptr) {
|
||||
return true;
|
||||
}
|
||||
@ -219,7 +225,7 @@ bool CXmlOpr::check_same_struct(const std::string& data)
|
||||
bool CXmlOpr::import_newer_data(const std::vector<std::string>& vec, std::size_t& success_count)
|
||||
{
|
||||
success_count = 0;
|
||||
auto* last_item = parent_node_->LastChildElement(opr_base_.item_key.c_str());
|
||||
auto* last_item = parent_node2_->LastChildElement(opr_base_.item_key.c_str());
|
||||
if (last_item == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@ -244,7 +250,7 @@ bool CXmlOpr::import_newer_data(const std::vector<std::string>& vec, std::size_t
|
||||
|
||||
void CXmlOpr::del_element(Element_t* ele)
|
||||
{
|
||||
parent_node_->DeleteChild(ele);
|
||||
parent_node2_->DeleteChild(ele);
|
||||
}
|
||||
|
||||
bool CXmlOpr::check_key_exists(const Property_t& property)
|
||||
@ -252,7 +258,7 @@ bool CXmlOpr::check_key_exists(const Property_t& property)
|
||||
if (keys_.size() < 1 || property.size() < 1) {
|
||||
return false;
|
||||
}
|
||||
return check_key_exists(property[0].key);
|
||||
return check_key_exists(property[0].value);
|
||||
}
|
||||
|
||||
bool CXmlOpr::check_key_exists(const std::string& key)
|
||||
@ -260,7 +266,7 @@ bool CXmlOpr::check_key_exists(const std::string& key)
|
||||
if (keys_.size() < 1 || key.empty()) {
|
||||
return false;
|
||||
}
|
||||
Element_t* purpose_node = parent_node_->FirstChildElement(opr_base_.item_key.c_str());
|
||||
Element_t* purpose_node = parent_node2_->FirstChildElement(opr_base_.item_key.c_str());
|
||||
while (purpose_node) {
|
||||
const char* value = purpose_node->Attribute(keys_[0].c_str());
|
||||
if (key == std::string(value)) {
|
||||
|
@ -52,6 +52,7 @@ private:
|
||||
OneGroupIni opr_base_{};
|
||||
std::string xml_path_{};
|
||||
Element_t* parent_node_{};
|
||||
Element_t* parent_node2_{};
|
||||
std::vector<std::string> keys_{};
|
||||
std::vector<std::string> units_{};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user