应该完成了
This commit is contained in:
@ -6,14 +6,11 @@
|
||||
|
||||
#include "applicationmanager.h"
|
||||
|
||||
#if _MSC_VER >=1936
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#else
|
||||
|
||||
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#endif
|
||||
|
||||
|
||||
AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
||||
: QDialog(parent)
|
||||
@ -29,6 +26,10 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
||||
{
|
||||
name_label = new QLabel(orig_name_str);
|
||||
form->addRow(QString::fromLocal8Bit("ȫ<EFBFBD><EFBFBD>"), name_label);
|
||||
if(row!=nullptr)
|
||||
{
|
||||
name_label->setText(row->orig_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -45,14 +46,10 @@ 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);
|
||||
sqlite_helper.get_category(categrories,true);
|
||||
|
||||
for (auto category : categrories)
|
||||
{
|
||||
if ((category.id == 1) || (category.id == 8) || (category.id == 4) || (category.id == 5 || category.id == 3))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QCheckBox* check_box = new QCheckBox(category.name);
|
||||
layout_inner->addWidget(check_box);
|
||||
categories_list.insert(category.id, check_box);
|
||||
@ -66,6 +63,9 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
||||
this->isEdit = isEdit;
|
||||
}else
|
||||
{
|
||||
name->setText(row->name);
|
||||
name_str=row->name;
|
||||
sort_str=QString::number(row->sort);
|
||||
path = new QPushButton(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
path_str = row->exe_file;
|
||||
path->setText(QString::fromWCharArray(fs::path(path_str.toStdWString()).filename().c_str()));
|
||||
@ -77,16 +77,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);
|
||||
|
||||
sqlite_helper.get_category(categrories,true);
|
||||
categories = row->categories;
|
||||
for (auto category : categrories)
|
||||
{
|
||||
if ((category.id == 1) || (category.id == 8) || (category.id == 4) || (category.id == 5 || category.id == 3))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QCheckBox* check_box = new QCheckBox(category.name);
|
||||
if(row->categories[category.id])
|
||||
if(row->categories[category.id-1])
|
||||
{
|
||||
check_box->setCheckState(Qt::Checked);
|
||||
}
|
||||
@ -122,43 +118,72 @@ AddApp::~AddApp()
|
||||
}
|
||||
|
||||
void AddApp::broswer_exe(){
|
||||
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
QApplication::applicationDirPath(), QString::fromLocal8Bit("Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD> (*.exe)"));
|
||||
fs::path file(path_str.toStdWString());
|
||||
path->setText(QString::fromStdWString(file.filename().c_str()));
|
||||
}
|
||||
|
||||
void AddApp::submit() {
|
||||
if((!orig_name->text().isEmpty())&&(!path->text().isEmpty()))
|
||||
QString path_str_old = path_str;
|
||||
if(path_str.isEmpty())
|
||||
{
|
||||
orig_name_str = orig_name->text();
|
||||
name_str = orig_name_str;
|
||||
sort_str = sort->text();
|
||||
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
QApplication::applicationDirPath(), QString::fromLocal8Bit("Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD> (*.exe)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), QString::fromLocal8Bit("δ<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>·<EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
path_str, QString::fromLocal8Bit("Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD> (*.exe)"));
|
||||
}
|
||||
categories = new bool[8];
|
||||
categories[0] = true;
|
||||
categories[2] = true;
|
||||
categories[7] = true;
|
||||
categories[3] = false;
|
||||
categories[4] = false;
|
||||
for(auto key:categories_list.keys())
|
||||
if (path_str.isEmpty()) {
|
||||
path_str = path_str_old;
|
||||
}
|
||||
fs::path file(path_str.toStdWString());
|
||||
path->setText(QString::fromStdWString(file.filename().c_str()));
|
||||
|
||||
}
|
||||
|
||||
void AddApp::submit() {
|
||||
if(isEdit)
|
||||
{
|
||||
if(key==0||key==2||key==7||key==3||key==4)
|
||||
if (!path->text().isEmpty())
|
||||
{
|
||||
continue;
|
||||
QString name_str_old = name_str;
|
||||
QString sort_str_old = sort_str;
|
||||
name_str = name->text();
|
||||
sort_str = sort->text();
|
||||
|
||||
if (name_str.isEmpty()) {
|
||||
name_str = name_str_old;
|
||||
}
|
||||
if (sort_str.isEmpty()) {
|
||||
sort_str = sort_str_old;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
categories[key - 1] = categories_list[key]->checkState();
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), QString::fromLocal8Bit("δ<EFBFBD><EFBFBD>д·<EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
}
|
||||
}else
|
||||
{
|
||||
if ((!orig_name->text().isEmpty()) && (!path->text().isEmpty()))
|
||||
{
|
||||
orig_name_str = orig_name->text();
|
||||
if (name->text().isEmpty()) {
|
||||
name_str = orig_name_str;
|
||||
}
|
||||
name_str = name->text();
|
||||
sort_str = sort->text();
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), QString::fromLocal8Bit("δ<EFBFBD><EFBFBD>дȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
categories[0] = true;
|
||||
categories[7] = true;
|
||||
for(auto key:categories_list.keys())
|
||||
{
|
||||
categories[key - 1] = categories_list[key]->checkState();
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
qDebug() << categories[i];
|
||||
}
|
||||
|
||||
changed = true;
|
||||
close();
|
||||
}
|
||||
|
Reference in New Issue
Block a user