diff --git a/OfficeAssistant_msvc/applicationmanager.cpp b/OfficeAssistant_msvc/applicationmanager.cpp index 9999d47..3a5b264 100644 --- a/OfficeAssistant_msvc/applicationmanager.cpp +++ b/OfficeAssistant_msvc/applicationmanager.cpp @@ -119,13 +119,15 @@ void ApplicationManager::onclick1(QString op, QString func, QString path, QStrin add_app.exec(); if(add_app.changed) { - bool ok = sqlite_helper.insert_software(add_app.get_name(), add_app.get_orig_name(), add_app.get_exe_path(), + int ok = sqlite_helper.insert_software(add_app.get_name(), add_app.get_orig_name(), add_app.get_exe_path(), add_app.get_sort(), add_app.get_categories()); if (!ok) { - QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("插入失败,全名是否重名?")); + QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("插入失败。")); + }else if(ok==FIND) + { + QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("已存在。")); } - emit refresh_tab(); } } diff --git a/OfficeAssistant_msvc/config.h b/OfficeAssistant_msvc/config.h index 765fc42..586c613 100644 --- a/OfficeAssistant_msvc/config.h +++ b/OfficeAssistant_msvc/config.h @@ -43,4 +43,6 @@ #define CUSTOM_2 7 #define OTHERS 8 #define CATEGORIES_NUM 8 + +#define FIND 2 #endif //OFFICEASSISTANT_CONFIG_H diff --git a/OfficeAssistant_msvc/netio.h b/OfficeAssistant_msvc/netio.h index 22c9aff..46ee414 100644 --- a/OfficeAssistant_msvc/netio.h +++ b/OfficeAssistant_msvc/netio.h @@ -139,4 +139,11 @@ public: OpenWeChatRequest():RequestBodyBase(){} QString sendRequest(bool notuse=false/*为了构成函数重载,凑数的*/); }; + +class OpenAppRequest:public RequestBodyBase +{ +public: + OpenAppRequest():RequestBodyBase(){} + QString sendRequest(QString app_name); +}; #endif //OFFICEASSISTANT_NETIO_H diff --git a/OfficeAssistant_msvc/sqlitehelper.cpp b/OfficeAssistant_msvc/sqlitehelper.cpp index 0f784cc..f89eb9d 100644 --- a/OfficeAssistant_msvc/sqlitehelper.cpp +++ b/OfficeAssistant_msvc/sqlitehelper.cpp @@ -1340,10 +1340,21 @@ bool SQLiteHelper::insert_software(QString name, QString orig_name, QString path return true; } -bool SQLiteHelper::insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories) { +int SQLiteHelper::insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories) { QSqlQuery begin(db); begin.exec("BEGIN;"); + QSqlQuery select; QSqlQuery query(db); + QSqlQuery query_sel(db); + QString sql_sel = "select id from kmd_menu where orig_name = :orig_name;"; + query_sel.prepare(sql_sel); + query_sel.bindValue(":orig_name", orig_name); + if(query_sel.exec()) + { + if(query_sel.next()){ + return FIND; + } + } QString categories_str = ""; categories[ALL - 1] = true; QString sql = "insert into kmd_menu " diff --git a/OfficeAssistant_msvc/sqlitehelper.h b/OfficeAssistant_msvc/sqlitehelper.h index 40b5f8b..2b27d2b 100644 --- a/OfficeAssistant_msvc/sqlitehelper.h +++ b/OfficeAssistant_msvc/sqlitehelper.h @@ -52,7 +52,7 @@ public: SQLiteHelper(QObject *parent = nullptr); bool update_software(); bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories, QString logo, QString img,QString type,bool locked,QString op,QString func,QString url,bool is_navbar,bool is_elite,QString dev); - bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories); + int insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories); bool edit_software(QString name, QString orig_name, QString path, QString sort, bool* categories,QString type=""); bool get_software(QList* buttons, ConfigResponse* config_response); bool get_software(QList* button_structs,QString background_color , QString title_color, QString title_cover_color);