!59 replace deprecated qSort with std::sort

From: @hou-hongxun 
Reviewed-by: @peijiankang 
Signed-off-by: @peijiankang
This commit is contained in:
openeuler-ci-bot 2024-05-10 01:27:52 +00:00 committed by Gitee
commit e60a3161e4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 169 additions and 1 deletions

View File

@ -0,0 +1,164 @@
From 240cdbfd5dd8802a70d5a3404dfa03a9d9e5e73c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BE=AF=E7=BA=A2=E5=8B=8B?= <houhongxun@kylinos.cn>
Date: Wed, 8 May 2024 15:52:27 +0800
Subject: [PATCH] use std::sort to sort items as recommended
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 侯红勋 <houhongxun@kylinos.cn>
---
.../Interface/ukuimenuinterface.cpp | 28 +++++++++----------
src/BackProcess/Search/searchappthread.cpp | 8 +++---
src/BackProcess/tablet/getmodeldata.cpp | 4 +--
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/BackProcess/Interface/ukuimenuinterface.cpp b/src/BackProcess/Interface/ukuimenuinterface.cpp
index d7438fb..f526bc8 100755
--- a/src/BackProcess/Interface/ukuimenuinterface.cpp
+++ b/src/BackProcess/Interface/ukuimenuinterface.cpp
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-
+#include <algorithm>
#include "ukuimenuinterface.h"
#include <QDir>
#include <QDebug>
@@ -783,8 +783,8 @@ bool UkuiMenuInterface::initAppIni()
}
}
- qSort(appInitVector.begin(), appInitVector.end(), cmpApp); //按中英文字母排序
- qSort(tencentInitVectorList.begin(), tencentInitVectorList.end(), cmpApp); //按中英文字母排序
+ std::sort(appInitVector.begin(), appInitVector.end(), cmpApp); //按中英文字母排序
+ std::sort(tencentInitVectorList.begin(), tencentInitVectorList.end(), cmpApp); //按中英文字母排序
//腾讯应用的精准类应用处理
if (precise_practiceVector.contains(english)) {
@@ -799,8 +799,8 @@ bool UkuiMenuInterface::initAppIni()
tencentInitVectorList.insert(0, chainese);
}
- qSort(customizedVectorList.begin(), customizedVectorList.end(), cmpApp); //按中英文字母排序
- qSort(thirdPartyVectorList.begin(), thirdPartyVectorList.end(), cmpApp); //按中英文字母排序
+ std::sort(customizedVectorList.begin(), customizedVectorList.end(), cmpApp); //按中英文字母排序
+ std::sort(thirdPartyVectorList.begin(), thirdPartyVectorList.end(), cmpApp); //按中英文字母排序
setting->beginGroup("tencent");
for (int i = 0; i < tencentInitVectorList.count(); i++) {
@@ -909,8 +909,8 @@ bool UkuiMenuInterface::initAppIni()
}
}
- qSort(appInitVector.begin(), appInitVector.end(), cmpApp); //按中英文字母排序
- qSort(tencentInitVector.begin(), tencentInitVector.end(), cmpApp); //按中英文字母排序
+ std::sort(appInitVector.begin(), appInitVector.end(), cmpApp); //按中英文字母排序
+ std::sort(tencentInitVector.begin(), tencentInitVector.end(), cmpApp); //按中英文字母排序
//腾讯应用的精准类应用处理
if (precise_practiceVector.contains(english)) {
@@ -925,8 +925,8 @@ bool UkuiMenuInterface::initAppIni()
tencentInitVector.insert(0, chainese);
}
- qSort(customizedVector.begin(), customizedVector.end(), cmpApp); //按中英文字母排序
- qSort(thirdPartyVector.begin(), thirdPartyVector.end(), cmpApp); //按中英文字母排序
+ std::sort(customizedVector.begin(), customizedVector.end(), cmpApp); //按中英文字母排序
+ std::sort(thirdPartyVector.begin(), thirdPartyVector.end(), cmpApp); //按中英文字母排序
setting->beginGroup("application");
for (int i = 0; i < preorderAppVector.count(); i++) {
@@ -1003,7 +1003,7 @@ QVector<QString> UkuiMenuInterface::getAllClassification()
index++;
}
- qSort(appVector.begin(), appVector.end(), cmpApp);
+ std::sort(appVector.begin(), appVector.end(), cmpApp);
Q_FOREACH(QString desktopfp, commonVector) {
allAppVector.append(desktopfp);
@@ -1366,7 +1366,7 @@ QVector<QStringList> UkuiMenuInterface::getAlphabeticClassification()
for (int i = 0; i < 26; i++) {
QStringList desktopfpList;
desktopfpList.clear();
- qSort(appVector[i].begin(), appVector[i].end(), cmpApp);
+ std::sort(appVector[i].begin(), appVector[i].end(), cmpApp);
for (int j = 0; j < appVector[i].size(); j++) {
desktopfpList.append(appVector[i].at(j).at(0));
@@ -1389,8 +1389,8 @@ QVector<QStringList> UkuiMenuInterface::getAlphabeticClassification()
}
}
- qSort(otherVector.begin(), otherVector.end(), cmpApp);
- qSort(numberVector.begin(), numberVector.end(), cmpApp);
+ std::sort(otherVector.begin(), otherVector.end(), cmpApp);
+ std::sort(numberVector.begin(), numberVector.end(), cmpApp);
QStringList otherfpList;
otherfpList.clear();
@@ -1479,7 +1479,7 @@ QVector<QStringList> UkuiMenuInterface::getFunctionalClassification()
for (int i = 0; i < 11; i++) {
QStringList desktopfpList;
desktopfpList.clear();
- qSort(appVector[i].begin(), appVector[i].end(), cmpApp);
+ std::sort(appVector[i].begin(), appVector[i].end(), cmpApp);
for (int j = 0; j < appVector[i].size(); j++) {
desktopfpList.append(appVector[i].at(j).at(0));
diff --git a/src/BackProcess/Search/searchappthread.cpp b/src/BackProcess/Search/searchappthread.cpp
index e1368f1..8200b4b 100755
--- a/src/BackProcess/Search/searchappthread.cpp
+++ b/src/BackProcess/Search/searchappthread.cpp
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-
+#include <algorithm>
#include "searchappthread.h"
#include <syslog.h>
#include "file-utils.h"
@@ -81,12 +81,12 @@ void SearchAppThread::run()
}
}
- qSort(m_searchFirstVector.begin(), m_searchFirstVector.end(), UkuiMenuInterface::cmpApp);
- qSort(m_searchRestVector.begin(), m_searchRestVector.end(), UkuiMenuInterface::cmpApp);
+ std::sort(m_searchFirstVector.begin(), m_searchFirstVector.end(), UkuiMenuInterface::cmpApp);
+ std::sort(m_searchRestVector.begin(), m_searchRestVector.end(), UkuiMenuInterface::cmpApp);
//对中文搜索结果进行排序
if (m_searchResultVector.size() != 0) {
- qSort(m_searchResultVector.begin(), m_searchResultVector.end(), UkuiMenuInterface::cmpApp);
+ std::sort(m_searchResultVector.begin(), m_searchResultVector.end(), UkuiMenuInterface::cmpApp);
}
//优先将严格匹配结果加入列表
diff --git a/src/BackProcess/tablet/getmodeldata.cpp b/src/BackProcess/tablet/getmodeldata.cpp
index 0f8080f..ef273d9 100755
--- a/src/BackProcess/tablet/getmodeldata.cpp
+++ b/src/BackProcess/tablet/getmodeldata.cpp
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-
+#include <algorithm>
#include "getmodeldata.h"
#include <QTranslator>
#include <QDir>
@@ -125,7 +125,7 @@ QVector<QStringList> GetModelData::getRecentData()
}
}
- qSort(recentDataVector.begin(), recentDataVector.end(), cmpApp);
+ std::sort(recentDataVector.begin(), recentDataVector.end(), cmpApp);
return recentDataVector;
}
--
2.43.0

View File

@ -1,6 +1,6 @@
Name: ukui-menu
Version: 3.1.1
Release: 13
Release: 14
Summary: Advanced ukui menu
License: GPL-3.0-or-later
URL: http://www.ukui.org
@ -34,6 +34,7 @@ Patch25: 0001-fix-uninstall-failed-issue.patch
Patch26: disable-Suspend-and-Sleep-of-ukui-menu.patch
%endif
Patch27: 0022-fix-thumbnail-potential-memory-leak.patch
Patch28: 0001-use-std-sort-to-sort-items-as-recommended.patch
BuildRequires: qt5-qtbase-devel
BuildRequires: libqtxdg-devel
@ -86,6 +87,9 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/ukui-menu/translations/
%changelog
* Wed May 08 2024 houhongxun <houhongxun@kylinos.cn> - 3.1.1-14
- use std::sort, replace deprecated qSort
* Tue May 07 2024 douyan <douyan@kylinos.cn> - 3.1.1-13
- Type:bugfix
- ID:NA