mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Add a method to get the list of libraries sorted like they are shown in the UI
This commit is contained in:
parent
a4f36396f5
commit
7c1e9298ee
@ -1,4 +1,5 @@
|
||||
#include "yacreader_libraries.h"
|
||||
#include "qnaturalsorting.h"
|
||||
#include "yacreader_global.h"
|
||||
|
||||
void writeIdToLibraryFolder(const QString &path, const QUuid &id)
|
||||
@ -117,6 +118,13 @@ QList<YACReaderLibrary> YACReaderLibraries::getLibraries() const
|
||||
return libraries;
|
||||
}
|
||||
|
||||
QList<YACReaderLibrary> YACReaderLibraries::sortedLibraries() const
|
||||
{
|
||||
auto sortedLibraries = libraries;
|
||||
std::sort(sortedLibraries.begin(), sortedLibraries.end(), [](const YACReaderLibrary &library1, const YACReaderLibrary &library2) { return naturalSortLessThanCI(library1.getName(), library2.getName()); });
|
||||
return sortedLibraries;
|
||||
}
|
||||
|
||||
QUuid YACReaderLibraries::getLibraryIdFromLegacyId(int legacyId) const
|
||||
{
|
||||
auto library = std::find_if(libraries.cbegin(), libraries.cend(), [legacyId](const YACReaderLibrary &library) { return library.getLegacyId() == legacyId; });
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
int getIdFromUuid(const QUuid &uuid);
|
||||
YACReaderLibraries &operator=(const YACReaderLibraries &source);
|
||||
QList<YACReaderLibrary> getLibraries() const;
|
||||
QList<YACReaderLibrary> sortedLibraries() const;
|
||||
QUuid getLibraryIdFromLegacyId(int legacyId) const;
|
||||
public slots:
|
||||
void addLibrary(const QString &name, const QString &path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user