From 9e1995b8672136b196bc4dccdb127e20156a630c Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Sat, 6 Jun 2020 20:12:38 +0200 Subject: Starts to implement history management. --- tabbrowsinghistory.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tabbrowsinghistory.cpp') diff --git a/tabbrowsinghistory.cpp b/tabbrowsinghistory.cpp index 1a2d07f..289d529 100644 --- a/tabbrowsinghistory.cpp +++ b/tabbrowsinghistory.cpp @@ -15,13 +15,30 @@ bool TabBrowsingHistory::canGoForward() const return false; } -void TabBrowsingHistory::pushUrl(const QUrl &url) +QModelIndex TabBrowsingHistory::pushUrl(QModelIndex const & position, const QUrl &url) { this->beginInsertRows(QModelIndex{}, this->history.length(),this->history.length() + 1); + if(position.isValid()) { + this->history.resize(position.row() + 1); + } + this->history.push_back(url); this->endInsertRows(); + + return this->createIndex(this->history.size() - 1, 0); +} + +QUrl TabBrowsingHistory::get(const QModelIndex &index) const +{ + if(not index.isValid()) + return QUrl { }; + + if(index.row() >= history.size()) + return QUrl { }; + else + return history.at(index.row()); } int TabBrowsingHistory::rowCount(const QModelIndex &parent) const -- cgit v1.2.3