aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.hpp
diff options
context:
space:
mode:
authorMike Skec <skec@protonmail.ch>2021-01-03 13:01:47 +1100
committerFelix Queißner <felix@ib-queissner.de>2021-01-06 10:51:18 +0100
commitd815c8badabb347537f26612a5edab3a71cba866 (patch)
tree31cad5baf317fbe1bad63ae7b9a0cd3104317d42 /src/mainwindow.hpp
parent522184bf155d22728d1a829e5f30847ae3e7aeb7 (diff)
downloadkristall-d815c8badabb347537f26612a5edab3a71cba866.tar.gz
Basic caching functionality implemented
Diffstat (limited to 'src/mainwindow.hpp')
-rw-r--r--src/mainwindow.hpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp
index e02ecfd..cfc35bf 100644
--- a/src/mainwindow.hpp
+++ b/src/mainwindow.hpp
@@ -21,6 +21,24 @@ class BrowserTab;
enum class UIDensity : int;
+struct CachedPage
+{
+ QUrl url;
+
+ QByteArray body;
+
+ MimeType mime;
+
+ // TODO: last scroll position
+
+ // also: maybe compress page contents? May test
+ // to see if it's worth it
+
+ CachedPage(const QUrl &url, const QByteArray &body, const MimeType &mime)
+ : url(url), body(body), mime(mime)
+ {}
+};
+
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -44,6 +62,12 @@ public:
void mousePressEvent(QMouseEvent *event) override;
+ std::shared_ptr<CachedPage> cacheFind(QString const &url);
+
+ bool cacheContains(QUrl const & url) const;
+
+ void cachePage(QUrl const & url, QByteArray const & body, MimeType const & mime);
+
private slots:
void on_browser_tabs_currentChanged(int index);
@@ -115,5 +139,8 @@ private:
QLabel * file_size;
QLabel * file_mime;
QLabel * load_time;
+
+ // This is where we store our current in-memory cache.
+ std::unordered_map<QString, std::shared_ptr<CachedPage>> page_cache;
};
#endif // MAINWINDOW_HPP