Sorting order for "modified"

This commit is contained in:
Scharel Clemens 2019-11-13 13:22:20 +01:00
parent cefa7259ad
commit 2ff9b06c99
3 changed files with 12 additions and 1 deletions

View file

@ -217,7 +217,7 @@ Page {
section.criteria: appSettings.sortBy === "title" ? ViewSection.FirstCharacter : ViewSection.FullString
section.labelPositioning: appSettings.sortBy === "title" ? ViewSection.CurrentLabelAtStart | ViewSection.NextLabelAtEnd : ViewSection.InlineLabels
section.delegate: SectionHeader {
text: section
text: appSettings.sortBy === "modified" ? new Date(section) : section
}
BusyIndicator {

View file

@ -8,6 +8,7 @@
NotesProxyModel::NotesProxyModel(QObject *parent) {
m_favoritesOnTop = true;
connect(this, SIGNAL(favoritesOnTopChanged(bool)), this, SLOT(resort()));
}
NotesProxyModel::~NotesProxyModel() {
@ -47,6 +48,13 @@ bool NotesProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex
return source->data(source_left, sortRole()) < source->data(source_right, sortRole());
}
void NotesProxyModel::resort() {
if (sortRole() == ModifiedRole)
sort(Qt::DescendingOrder);
else
sort(Qt::AscendingOrder);
}
NotesModel::NotesModel(QObject *parent) {
}

View file

@ -29,6 +29,9 @@ public:
protected:
virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
private slots:
void resort();
signals:
void favoritesOnTopChanged(bool favoritesOnTop);