aboutsummaryrefslogtreecommitdiff
path: root/src/tabbrowsinghistory.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-06 23:14:21 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-06 23:14:21 +0200
commit3aed883402dc8da829fc304434c5efd0570cbb97 (patch)
tree48c46ab087a950d80f78819ceb609e93d246b040 /src/tabbrowsinghistory.cpp
parent44e85dce678e7e36f436a6d0a25c212c9a2d3657 (diff)
downloadkristall-3aed883402dc8da829fc304434c5efd0570cbb97.tar.gz
Moves source code into subdirectory.
Diffstat (limited to 'src/tabbrowsinghistory.cpp')
-rw-r--r--src/tabbrowsinghistory.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/tabbrowsinghistory.cpp b/src/tabbrowsinghistory.cpp
new file mode 100644
index 0000000..435bca7
--- /dev/null
+++ b/src/tabbrowsinghistory.cpp
@@ -0,0 +1,79 @@
+#include "tabbrowsinghistory.hpp"
+
+TabBrowsingHistory::TabBrowsingHistory()
+{
+
+}
+
+bool TabBrowsingHistory::canGoBack() const
+{
+ return this->history.size() > 0;
+}
+
+bool TabBrowsingHistory::canGoForward() const
+{
+ return false;
+}
+
+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());
+}
+
+QModelIndex TabBrowsingHistory::oneForward(QModelIndex index) const
+{
+ if(not index.isValid())
+ return QModelIndex{};
+ if(index.row() >= history.size() - 1)
+ return QModelIndex{};
+ return createIndex(index.row() + 1, index.column());
+}
+
+QModelIndex TabBrowsingHistory::oneBackward(QModelIndex index) const
+{
+ if(not index.isValid())
+ return QModelIndex{};
+ if(index.row() == 0)
+ return QModelIndex{};
+ return createIndex(index.row() - 1, index.column());
+}
+
+int TabBrowsingHistory::rowCount(const QModelIndex &parent) const
+{
+ return history.size();
+}
+
+bool TabBrowsingHistory::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ return false;
+}
+
+QVariant TabBrowsingHistory::data(const QModelIndex &index, int role) const
+{
+ if(role != Qt::DisplayRole) {
+ return QVariant{};
+ }
+ return history.at(index.row()).toString();
+}
+