From 752700298d4073c733b3b13cc4b37a9b814a39db Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 5 Feb 2021 16:29:07 +0200 Subject: [PATCH 1/6] Remove duplicate resource image alias --- YACReaderLibrary/images.qrc | 1 - 1 file changed, 1 deletion(-) diff --git a/YACReaderLibrary/images.qrc b/YACReaderLibrary/images.qrc index 3b117b640..56759398f 100644 --- a/YACReaderLibrary/images.qrc +++ b/YACReaderLibrary/images.qrc @@ -7,7 +7,6 @@ ../images/comic_vine/previousPage.png ../images/comic_vine/radioChecked.png ../images/comic_vine/radioUnchecked.png - ../images/comic_vine/radioUnchecked.png ../images/comic_vine/rowDown.png ../images/comic_vine/rowUp.png ../images/comic_vine/upArrow.png From 62ee67e56d8605bdf197248705a42587182717b7 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 5 Feb 2021 17:38:08 +0200 Subject: [PATCH 2/6] 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 b86056bf3..5f351935f 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 576ebbedb..4464dc995 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 dae8a979f..341ea50e2 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 7318bce81..fc4265134 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 a605bc5bd..65f5a76b9 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 8da40c951..e31485430 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; From aeb569e10b051bcf5f2b84b7205942340e7404d3 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 5 Feb 2021 21:49:45 +0200 Subject: [PATCH 3/6] Eliminate QStringList <=> QList conversions The conversions prevented return value optimization and caused a -Wreturn-std-move Clang warning. --- YACReaderLibrary/db_helper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/db_helper.cpp b/YACReaderLibrary/db_helper.cpp index 341ea50e2..3a0107560 100644 --- a/YACReaderLibrary/db_helper.cpp +++ b/YACReaderLibrary/db_helper.cpp @@ -166,7 +166,7 @@ QString DBHelper::getFolderName(qulonglong libraryId, qulonglong id) } QList DBHelper::getLibrariesNames() { - QStringList names = getLibraries().getNames(); + auto names = getLibraries().getNames(); std::sort(names.begin(), names.end(), naturalSortLessThanCI); return names; } From b45d7e1745d2b30bb15f4b7878e48b059211e7f0 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 5 Feb 2021 21:34:55 +0200 Subject: [PATCH 4/6] Port away from deprecated QFlags(Zero) constructor This change gets rid of a few GCC's -Wdeprecated-declarations warnings. --- YACReaderLibrary/db/comic_model.cpp | 2 +- YACReaderLibrary/db/folder_model.cpp | 2 +- YACReaderLibrary/db/reading_list_model.cpp | 4 ++-- shortcuts_management/actions_shortcuts_model.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/YACReaderLibrary/db/comic_model.cpp b/YACReaderLibrary/db/comic_model.cpp index 247e2e788..da6c8a46a 100644 --- a/YACReaderLibrary/db/comic_model.cpp +++ b/YACReaderLibrary/db/comic_model.cpp @@ -317,7 +317,7 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const Qt::ItemFlags ComicModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return {}; if (index.column() == ComicModel::Rating) return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; diff --git a/YACReaderLibrary/db/folder_model.cpp b/YACReaderLibrary/db/folder_model.cpp index 4464dc995..2a3afdb22 100644 --- a/YACReaderLibrary/db/folder_model.cpp +++ b/YACReaderLibrary/db/folder_model.cpp @@ -144,7 +144,7 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const Qt::ItemFlags FolderModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return {}; return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; } diff --git a/YACReaderLibrary/db/reading_list_model.cpp b/YACReaderLibrary/db/reading_list_model.cpp index b1991d4de..5f3012572 100644 --- a/YACReaderLibrary/db/reading_list_model.cpp +++ b/YACReaderLibrary/db/reading_list_model.cpp @@ -101,11 +101,11 @@ QVariant ReadingListModel::data(const QModelIndex &index, int role) const Qt::ItemFlags ReadingListModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return {}; auto item = static_cast(index.internalPointer()); if (typeid(*item) == typeid(ReadingListSeparatorItem)) - return 0; + return {}; if (typeid(*item) == typeid(ReadingListItem) && static_cast(item)->parent->getId() != 0) return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; //only sublists are dragable diff --git a/shortcuts_management/actions_shortcuts_model.cpp b/shortcuts_management/actions_shortcuts_model.cpp index eee5961e6..914472319 100644 --- a/shortcuts_management/actions_shortcuts_model.cpp +++ b/shortcuts_management/actions_shortcuts_model.cpp @@ -33,7 +33,7 @@ QModelIndex ActionsShortcutsModel::index(int row, int column, const QModelIndex Qt::ItemFlags ActionsShortcutsModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return {}; if (index.column() == KEYS) return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; From a729d6d8c94223d9e1599eb8b3db8be3e1b99eb5 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 5 Feb 2021 22:08:17 +0200 Subject: [PATCH 5/6] Deprecated QSortFilterProxyModel::clear() => invalidate() --- YACReaderLibrary/db/folder_model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/db/folder_model.cpp b/YACReaderLibrary/db/folder_model.cpp index 2a3afdb22..35271125a 100644 --- a/YACReaderLibrary/db/folder_model.cpp +++ b/YACReaderLibrary/db/folder_model.cpp @@ -625,5 +625,5 @@ void FolderModelProxy::clear() filteredItems.clear(); - QSortFilterProxyModel::clear(); + QSortFilterProxyModel::invalidate(); } From 629eb264aa87d9229206db0cd3a6effa1bf797a2 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 5 Feb 2021 17:42:56 +0200 Subject: [PATCH 6/6] YACReaderFlowGL: initialize data member texture pointers Moving the initialization of defaultTexture out of the member initializer list gets rid of a GCC's -Wreorder warning. Initialize other texture pointers to improve safety and consistency. --- common/gl/yacreader_flow_gl.cpp | 2 +- common/gl/yacreader_flow_gl.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/gl/yacreader_flow_gl.cpp b/common/gl/yacreader_flow_gl.cpp index ad59daf73..867a13636 100644 --- a/common/gl/yacreader_flow_gl.cpp +++ b/common/gl/yacreader_flow_gl.cpp @@ -191,7 +191,7 @@ struct Preset pressetYACReaderFlowDownConfig = { }; /*Constructor*/ YACReaderFlowGL::YACReaderFlowGL(QWidget *parent, struct Preset p) - : QOpenGLWidget(/*QOpenGLWidget migration QGLFormat(QGL::SampleBuffers),*/ parent), numObjects(0), lazyPopulateObjects(-1), defaultTexture(nullptr), hasBeenInitialized(false), bUseVSync(false), flowRightToLeft(false) + : QOpenGLWidget(/*QOpenGLWidget migration QGLFormat(QGL::SampleBuffers),*/ parent), numObjects(0), lazyPopulateObjects(-1), hasBeenInitialized(false), bUseVSync(false), flowRightToLeft(false) { updateCount = 0; config = p; diff --git a/common/gl/yacreader_flow_gl.h b/common/gl/yacreader_flow_gl.h index 6fc965a78..c47345d86 100644 --- a/common/gl/yacreader_flow_gl.h +++ b/common/gl/yacreader_flow_gl.h @@ -119,9 +119,9 @@ class YACReaderFlowGL : public QOpenGLWidget, public ScrollManagement int updateCount; int fontSize; - QOpenGLTexture *defaultTexture; - QOpenGLTexture *markTexture; - QOpenGLTexture *readingTexture; + QOpenGLTexture *defaultTexture = nullptr; + QOpenGLTexture *markTexture = nullptr; + QOpenGLTexture *readingTexture = nullptr; void initializeGL(); void paintGL(); void timerEvent(QTimerEvent *);