summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-08 20:30:09 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-08 20:30:09 +0300
commitebed87ea5730f9a49d6cf6d03a2a3a8ef7e2aa52 (patch)
treeb022e968f92dee9c52e73b07de7fadd304cc5299 /include
parentReplace shared pointers of MatrixClient with a single instance (diff)
downloadnheko-ebed87ea5730f9a49d6cf6d03a2a3a8ef7e2aa52.tar.xz
Don't use shared pointers for cache
Diffstat (limited to 'include')
-rw-r--r--include/AvatarProvider.h9
-rw-r--r--include/Cache.h8
-rw-r--r--include/ChatPage.h4
-rw-r--r--include/QuickSwitcher.h5
-rw-r--r--include/RoomList.h3
-rw-r--r--include/TextInputWidget.h5
-rw-r--r--include/dialogs/MemberList.hpp4
-rw-r--r--include/dialogs/RoomSettings.hpp6
8 files changed, 11 insertions, 33 deletions
diff --git a/include/AvatarProvider.h b/include/AvatarProvider.h
index af13a577..ce82f2aa 100644
--- a/include/AvatarProvider.h
+++ b/include/AvatarProvider.h
@@ -17,27 +17,18 @@
 
 #pragma once
 
-#include <QHash>
 #include <QImage>
-#include <QSharedPointer>
 #include <functional>
 
-class TimelineItem;
-class Cache;
-
 class AvatarProvider : public QObject
 {
         Q_OBJECT
 
 public:
-        static void init(QSharedPointer<Cache> cache) { cache_ = cache; }
         //! The callback is called with the downloaded avatar for the given user
         //! or the avatar is downloaded first and then saved for re-use.
         static void resolve(const QString &room_id,
                             const QString &userId,
                             QObject *receiver,
                             std::function<void(QImage)> callback);
-
-private:
-        static QSharedPointer<Cache> cache_;
 };
diff --git a/include/Cache.h b/include/Cache.h
index 7ecc5d59..c038b3d9 100644
--- a/include/Cache.h
+++ b/include/Cache.h
@@ -435,3 +435,11 @@ private:
         QString localUserId_;
         QString cacheDirectory_;
 };
+
+namespace cache {
+void
+init(const QString &userId, QObject *parent);
+
+Cache *
+client();
+}
diff --git a/include/ChatPage.h b/include/ChatPage.h
index 057ce698..799f7a2e 100644
--- a/include/ChatPage.h
+++ b/include/ChatPage.h
@@ -69,7 +69,6 @@ public:
         static ChatPage *instance() { return instance_; }
 
         QSharedPointer<UserSettings> userSettings() { return userSettings_; }
-        QSharedPointer<Cache> cache() { return cache_; }
         void deleteConfigs();
 
 signals:
@@ -183,9 +182,6 @@ private:
 
         // Global user settings.
         QSharedPointer<UserSettings> userSettings_;
-
-        // LMDB wrapper.
-        QSharedPointer<Cache> cache_;
 };
 
 template<class Collection>
diff --git a/include/QuickSwitcher.h b/include/QuickSwitcher.h
index ce3c4f25..254d7a16 100644
--- a/include/QuickSwitcher.h
+++ b/include/QuickSwitcher.h
@@ -22,7 +22,6 @@
 #include <QVBoxLayout>
 #include <QWidget>
 
-#include "Cache.h"
 #include "SuggestionsPopup.hpp"
 #include "TextField.h"
 
@@ -50,7 +49,7 @@ class QuickSwitcher : public QWidget
         Q_OBJECT
 
 public:
-        QuickSwitcher(QSharedPointer<Cache> cache, QWidget *parent = nullptr);
+        QuickSwitcher(QWidget *parent = nullptr);
 
 signals:
         void closing();
@@ -77,6 +76,4 @@ private:
 
         //! Autocomplete popup box with the room suggestions.
         SuggestionsPopup popup_;
-        //! Cache client for room quering.
-        QSharedPointer<Cache> cache_;
 };
diff --git a/include/RoomList.h b/include/RoomList.h
index 202e075c..98d9443e 100644
--- a/include/RoomList.h
+++ b/include/RoomList.h
@@ -30,7 +30,6 @@ class OverlayModal;
 class RoomInfoListItem;
 class Sync;
 class UserSettings;
-class Cache;
 struct DescInfo;
 struct RoomInfo;
 
@@ -41,7 +40,6 @@ class RoomList : public QWidget
 public:
         RoomList(QSharedPointer<UserSettings> userSettings, QWidget *parent = 0);
 
-        void setCache(QSharedPointer<Cache> cache) { cache_ = cache; }
         void initialize(const QMap<QString, RoomInfo> &info);
         void sync(const std::map<QString, RoomInfo> &info);
 
@@ -102,7 +100,6 @@ private:
         //! Which rooms to include in the room list.
         std::vector<QString> roomFilter_;
 
-        QSharedPointer<Cache> cache_;
         QSharedPointer<UserSettings> userSettings_;
 
         bool isSortPending_ = false;
diff --git a/include/TextInputWidget.h b/include/TextInputWidget.h
index 1f122504..c679b9b2 100644
--- a/include/TextInputWidget.h
+++ b/include/TextInputWidget.h
@@ -36,8 +36,6 @@
 
 #include "emoji/PickButton.h"
 
-class Cache;
-
 namespace dialogs {
 class PreviewUploadOverlay;
 }
@@ -131,7 +129,6 @@ public:
 
         QColor borderColor() const { return borderColor_; }
         void setBorderColor(QColor &color) { borderColor_ = color; }
-        void setCache(QSharedPointer<Cache> cache) { cache_ = cache; }
 
 public slots:
         void openFileSelection();
@@ -172,7 +169,5 @@ private:
         FlatButton *sendMessageBtn_;
         emoji::PickButton *emojiBtn_;
 
-        QSharedPointer<Cache> cache_;
-
         QColor borderColor_;
 };
diff --git a/include/dialogs/MemberList.hpp b/include/dialogs/MemberList.hpp
index bdc11486..9c3dc5dc 100644
--- a/include/dialogs/MemberList.hpp
+++ b/include/dialogs/MemberList.hpp
@@ -4,7 +4,6 @@
 #include <QListWidget>
 
 class Avatar;
-class Cache;
 class FlatButton;
 class QHBoxLayout;
 class QLabel;
@@ -38,7 +37,7 @@ class MemberList : public QFrame
 {
         Q_OBJECT
 public:
-        MemberList(const QString &room_id, QSharedPointer<Cache> cache, QWidget *parent = nullptr);
+        MemberList(const QString &room_id, QWidget *parent = nullptr);
 
 public slots:
         void addUsers(const std::vector<RoomMember> &users);
@@ -57,7 +56,6 @@ private:
         QString room_id_;
         QLabel *topLabel_;
         QListWidget *list_;
-        QSharedPointer<Cache> cache_;
         FlatButton *moreBtn_;
 };
 } // dialogs
diff --git a/include/dialogs/RoomSettings.hpp b/include/dialogs/RoomSettings.hpp
index fbbc2e02..2acbf4b1 100644
--- a/include/dialogs/RoomSettings.hpp
+++ b/include/dialogs/RoomSettings.hpp
@@ -59,9 +59,7 @@ class RoomSettings : public QFrame
 {
         Q_OBJECT
 public:
-        RoomSettings(const QString &room_id,
-                     QSharedPointer<Cache> cache,
-                     QWidget *parent = nullptr);
+        RoomSettings(const QString &room_id, QWidget *parent = nullptr);
 
 signals:
         void closing();
@@ -74,8 +72,6 @@ private:
 
         void setAvatar(const QImage &img) { avatarImg_ = img; }
 
-        QSharedPointer<Cache> cache_;
-
         // Button section
         FlatButton *saveBtn_;
         FlatButton *cancelBtn_;