From 3c9ed6ef8fd263615fe6352ab757d3d0236992fc Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 5 Feb 2021 17:38:08 +0200 Subject: [PATCH] Deprecated qSort => std::sort This change gets rid of some GCC's -Wdeprecated-declarations warnings. --- YACReader/main_window_viewer.cpp | 5 ++--- YACReaderLibrary/db/folder_model.cpp | 5 +++-- YACReaderLibrary/db_helper.cpp | 3 ++- YACReaderLibrary/library_creator.cpp | 10 +++++----- YACReaderLibrary/library_window.cpp | 3 ++- .../server/controllers/v1/foldercontroller.cpp | 6 ++++-- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index b86056bf..5f351935 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -948,7 +948,7 @@ void MainWindowViewer::openFolderFromPath(QString pathDir, QString atFileName) d.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware); QStringList list = d.entryList(); - qSort(list.begin(), list.end(), naturalSortLessThanCI); + std::sort(list.begin(), list.end(), naturalSortLessThanCI); int i = 0; foreach (QString path, list) { if (path.endsWith(atFileName)) @@ -1560,8 +1560,7 @@ void MainWindowViewer::getSiblingComics(QString path, QString currentComic) #endif d.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware); QStringList list = d.entryList(); - qSort(list.begin(), list.end(), naturalSortLessThanCI); - //std::sort(list.begin(),list.end(),naturalSortLessThanCI); + std::sort(list.begin(), list.end(), naturalSortLessThanCI); int index = list.indexOf(currentComic); if (index == -1) //comic not found { diff --git a/YACReaderLibrary/db/folder_model.cpp b/YACReaderLibrary/db/folder_model.cpp index 576ebbed..4464dc99 100644 --- a/YACReaderLibrary/db/folder_model.cpp +++ b/YACReaderLibrary/db/folder_model.cpp @@ -11,6 +11,8 @@ #include +#include + #ifdef Q_OS_MAC #include QIcon finishedFolderIcon; @@ -413,8 +415,7 @@ QStringList FolderModel::getSubfoldersNames(const QModelIndex &mi) } QSqlDatabase::removeDatabase(connectionName); - //TODO sort result)) - qSort(result.begin(), result.end(), naturalSortLessThanCI); + std::sort(result.begin(), result.end(), naturalSortLessThanCI); return result; } diff --git a/YACReaderLibrary/db_helper.cpp b/YACReaderLibrary/db_helper.cpp index dae8a979..341ea50e 100644 --- a/YACReaderLibrary/db_helper.cpp +++ b/YACReaderLibrary/db_helper.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include "reading_list.h" @@ -166,7 +167,7 @@ QString DBHelper::getFolderName(qulonglong libraryId, qulonglong id) QList DBHelper::getLibrariesNames() { QStringList names = getLibraries().getNames(); - qSort(names.begin(), names.end(), naturalSortLessThanCI); + std::sort(names.begin(), names.end(), naturalSortLessThanCI); return names; } QString DBHelper::getLibraryName(int id) diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index 7318bce8..fc426513 100644 --- a/YACReaderLibrary/library_creator.cpp +++ b/YACReaderLibrary/library_creator.cpp @@ -333,8 +333,8 @@ void LibraryCreator::update(QDir dirS) dirS.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware); QFileInfoList listSFiles = dirS.entryInfoList(); - qSort(listSFolders.begin(), listSFolders.end(), naturalSortLessThanCIFileInfo); - qSort(listSFiles.begin(), listSFiles.end(), naturalSortLessThanCIFileInfo); + std::sort(listSFolders.begin(), listSFolders.end(), naturalSortLessThanCIFileInfo); + std::sort(listSFiles.begin(), listSFiles.end(), naturalSortLessThanCIFileInfo); QFileInfoList listS; listS.append(listSFolders); @@ -351,8 +351,8 @@ void LibraryCreator::update(QDir dirS) //QLOG_TRACE() << "END Getting info from DB" << dirS.absolutePath(); QList listD; - qSort(folders.begin(), folders.end(), naturalSortLessThanCILibraryItem); - qSort(comics.begin(), comics.end(), naturalSortLessThanCILibraryItem); + std::sort(folders.begin(), folders.end(), naturalSortLessThanCILibraryItem); + std::sort(comics.begin(), comics.end(), naturalSortLessThanCILibraryItem); listD.append(folders); listD.append(comics); //QLOG_DEBUG() << "---------------------------------------------------------"; @@ -651,7 +651,7 @@ void ThumbnailCreator::create() if (_coverPage > _numPages) { _coverPage = 1; } - qSort(fileNames.begin(), fileNames.end(), naturalSortLessThanCI); + std::sort(fileNames.begin(), fileNames.end(), naturalSortLessThanCI); int index = order.indexOf(fileNames.at(_coverPage - 1)); if (_target == "") { diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index a605bc5b..65f5a76b 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -2494,7 +2495,7 @@ QModelIndexList LibraryWindow::getSelectedComics() //avoid selection.count()==0 forcing selection in comicsView QModelIndexList selection = comicsViewsManager->comicsView->selectionModel()->selectedRows(); QLOG_TRACE() << "selection count " << selection.length(); - qSort(selection.begin(), selection.end(), lessThanModelIndexRow); + std::sort(selection.begin(), selection.end(), lessThanModelIndexRow); if (selection.count() == 0) { comicsViewsManager->comicsView->selectIndex(0); diff --git a/YACReaderLibrary/server/controllers/v1/foldercontroller.cpp b/YACReaderLibrary/server/controllers/v1/foldercontroller.cpp index 8da40c95..e3148543 100644 --- a/YACReaderLibrary/server/controllers/v1/foldercontroller.cpp +++ b/YACReaderLibrary/server/controllers/v1/foldercontroller.cpp @@ -16,6 +16,8 @@ #include "QsLog.h" +#include + using stefanfrings::HttpRequest; using stefanfrings::HttpResponse; using stefanfrings::HttpSession; @@ -79,7 +81,7 @@ void FolderController::service(HttpRequest &request, HttpResponse &response) folderContent.append(folderComics); - qSort(folderContent.begin(), folderContent.end(), LibraryItemSorter()); + std::sort(folderContent.begin(), folderContent.end(), LibraryItemSorter()); folderComics.clear(); //qulonglong backId = DBHelper::getParentFromComicFolderId(libraryName,folderId); @@ -265,7 +267,7 @@ void FolderController::service(HttpRequest &request, HttpResponse &response) if (index.length() > 1) { t.setCondition("alphaIndex", true); - qSort(index.begin(), index.end(), naturalSortLessThanCI); + std::sort(index.begin(), index.end(), naturalSortLessThanCI); t.loop("index", index.length()); int i = 0; int count = 0;