改了几个bug,提交

This commit is contained in:
Mike Solar
2023-08-15 20:12:36 +08:00
parent 409443e311
commit 46f48b8440
7 changed files with 175 additions and 77 deletions

View File

@ -3,7 +3,7 @@
#include <QProcessEnvironment>
#include <QMessageBox>
#include <sqlitehelper.h>
#include "config.h"
#include "applicationmanager.h"
@ -16,27 +16,34 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
this->row=row;
SQLiteHelper sqlite_helper;
setFixedSize(450, 450);
Record2 record;
sqlite_helper.get_a_software(row->orig_name, &record);
setWindowFlags(Qt::WindowCloseButtonHint);
form = new QFormLayout;
name = new QLineEdit;
form->addRow(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), name);
if(isEdit)
if (isEdit)
{
name_label = new QLabel(orig_name_str);
form->addRow(QString::fromLocal8Bit("ȫ<EFBFBD><EFBFBD>"), name_label);
if(row!=nullptr)
if (!record.orig_name.isEmpty())
{
name_label->setText(row->orig_name);
name_label->setText(record.orig_name);
}
orig_name_str = record.orig_name;
}
else
{
orig_name = new QLineEdit;
form->addRow(QString::fromLocal8Bit("ȫ<EFBFBD><EFBFBD>"), orig_name);
}
if(row==nullptr)
if (record.orig_name.isEmpty())
{
path = new QPushButton(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
connect(path, &QPushButton::clicked, this, &AddApp::broswer_exe);
@ -46,11 +53,12 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
form->addRow(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), sort);
QList<Categrory> categrories;
layout_inner = new QVBoxLayout;
sqlite_helper.get_category(categrories,true);
sqlite_helper.get_category(categrories, true);
for (auto category : categrories)
{
QCheckBox* check_box = new QCheckBox(category.name);
layout_inner->addWidget(check_box);
categories_list.insert(category.id, check_box);
}
@ -61,28 +69,29 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
connect(path, &QPushButton::click, this, &AddApp::broswer_exe);
connect(submit_btn, &QPushButton::clicked, this, &AddApp::submit);
this->isEdit = isEdit;
}else
}
else
{
name->setText(row->name);
name_str=row->name;
sort_str=QString::number(row->sort);
name->setText(record.name);
name_str = record.name;
sort_str = QString::number(record.sort);
path = new QPushButton(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
path_str = row->exe_file;
path_str = record.exe_file;
path->setText(QString::fromWCharArray(fs::path(path_str.toStdWString()).filename().c_str()));
connect(path, &QPushButton::clicked, this, &AddApp::broswer_exe);
form->addRow(QString::fromLocal8Bit("·<EFBFBD><EFBFBD>"), path);
sort = new QLineEdit;
sort->setText(QString::number(row->sort));
sort->setText(QString::number(record.sort));
sort->setValidator(new QIntValidator(10, 100));
form->addRow(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), sort);
QList<Categrory> categrories;
layout_inner = new QVBoxLayout;
sqlite_helper.get_category(categrories,true);
categories = row->categories;
sqlite_helper.get_category(categrories, true);
this->categories = record.categories;
for (auto category : categrories)
{
QCheckBox* check_box = new QCheckBox(category.name);
if(row->categories[category.id-1])
if (record.categories[category.id - 1])
{
check_box->setCheckState(Qt::Checked);
}
@ -112,7 +121,7 @@ AddApp::~AddApp()
delete orig_name;
}
delete path;
delete sort;
//delete sort;
delete submit_btn;
delete form;
}
@ -146,7 +155,6 @@ void AddApp::submit() {
QString sort_str_old = sort_str;
name_str = name->text();
sort_str = sort->text();
if (name_str.isEmpty()) {
name_str = name_str_old;
}
@ -159,7 +167,8 @@ void AddApp::submit() {
QMessageBox::critical(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), QString::fromLocal8Bit("δ<EFBFBD><EFBFBD>д·<EFBFBD><EFBFBD>"));
return;
}
}else
}
else
{
if ((!orig_name->text().isEmpty()) && (!path->text().isEmpty()))
{
@ -167,7 +176,10 @@ void AddApp::submit() {
if (name->text().isEmpty()) {
name_str = orig_name_str;
}
name_str = name->text();
else {
name_str = name->text();
}
sort_str = sort->text();
}
else
@ -176,10 +188,22 @@ void AddApp::submit() {
return;
}
}
categories = new bool[8];
for (int i = 0; i < 8; i++) {
categories[i] = false;
}
categories[ALL-1] = true;
if (row->op == "soft") {
categories[SOFT-1] = true;
}
else if (row->op == "app") {
categories[INNER-1] = true;
}
for(auto key:categories_list.keys())
{
categories[key - 1] = categories_list[key]->checkState();
}
for (int i = 0; i < 8; i++) {
qDebug() << categories[i];
}