Commit 51407074 authored by Jonah Brüchert's avatar Jonah Brüchert
Browse files

Save lastVisited to disk and sort accordingly

parent 81a2d68b
......@@ -23,6 +23,7 @@ import QtQuick 2.3
import QtQuick.Layouts 1.0
import org.kde.kirigami 2.2 as Kirigami
import org.kde.mobile.angelfish 1.0
Kirigami.ScrollablePage {
id: history
......@@ -34,7 +35,9 @@ Kirigami.ScrollablePage {
interactive: height < contentHeight
clip: true
model: browserManager.history
model: UrlFilterProxyModel {
sourceModel: browserManager.history
}
delegate: UrlDelegate {
onClicked: pageStack.layers.pop()
......
......@@ -80,6 +80,7 @@ Kirigami.ApplicationWindow {
request.url = currentWebView.url;
request.title = currentWebView.title;
request.icon = currentWebView.icon;
request.lastVisited = new Date();
browserManager.addToHistory(request);
}
......
......@@ -22,6 +22,8 @@
#include "urlfilterproxymodel.h"
#include "browsermanager.h"
#include <QDateTime>
#include "urlmodel.h"
using namespace AngelFish;
......@@ -42,9 +44,10 @@ bool UrlFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sou
bool UrlFilterProxyModel::lessThan(const QModelIndex &source_left,
const QModelIndex &source_right) const
{
// as we currently don't write the lastVisited role to disk, we simply sort by index/position in
// the model
return source_left.row() < source_right.row();
auto leftDate = QDateTime::fromString(sourceModel()->data(source_left, UrlModel::lastVisited).toString(), Qt::ISODate);
auto rightDate = QDateTime::fromString(sourceModel()->data(source_right, UrlModel::lastVisited).toString(), Qt::ISODate);
return leftDate < rightDate;
}
void UrlFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment