1 #include "sortedlibrary.h"
5 SortedLibrary::SortedLibrary(QObject *parent):
6 QSortFilterProxyModel(parent), mSortBy(SortByTitle)
8 setSourceModel(Library::instance());
12 void SortedLibrary::sortBy(SortBy key)
17 bool SortedLibrary::lessThan(const QModelIndex &left,
18 const QModelIndex &right) const
20 Book *leftBook = Library::instance()->book(left);
21 Book *rightBook = Library::instance()->book(right);
28 leftString = leftBook->shortName();
29 rightString = rightBook->shortName();
32 leftString = leftBook->creators[0];
33 rightString = rightBook->creators[0];
37 return QString::localeAwareCompare(leftString, rightString) < 0;