From ebed87ea5730f9a49d6cf6d03a2a3a8ef7e2aa52 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Tue, 8 May 2018 20:30:09 +0300 Subject: Don't use shared pointers for cache --- include/AvatarProvider.h | 9 --------- include/Cache.h | 8 ++++++++ include/ChatPage.h | 4 ---- include/QuickSwitcher.h | 5 +---- include/RoomList.h | 3 --- include/TextInputWidget.h | 5 ----- include/dialogs/MemberList.hpp | 4 +--- include/dialogs/RoomSettings.hpp | 6 +----- 8 files changed, 11 insertions(+), 33 deletions(-) (limited to 'include') 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 #include -#include #include -class TimelineItem; -class Cache; - class AvatarProvider : public QObject { Q_OBJECT public: - static void init(QSharedPointer 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 callback); - -private: - static QSharedPointer 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() { return userSettings_; } - QSharedPointer cache() { return cache_; } void deleteConfigs(); signals: @@ -183,9 +182,6 @@ private: // Global user settings. QSharedPointer userSettings_; - - // LMDB wrapper. - QSharedPointer cache_; }; template 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 #include -#include "Cache.h" #include "SuggestionsPopup.hpp" #include "TextField.h" @@ -50,7 +49,7 @@ class QuickSwitcher : public QWidget Q_OBJECT public: - QuickSwitcher(QSharedPointer 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_; }; 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, QWidget *parent = 0); - void setCache(QSharedPointer cache) { cache_ = cache; } void initialize(const QMap &info); void sync(const std::map &info); @@ -102,7 +100,6 @@ private: //! Which rooms to include in the room list. std::vector roomFilter_; - QSharedPointer cache_; QSharedPointer 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; } public slots: void openFileSelection(); @@ -172,7 +169,5 @@ private: FlatButton *sendMessageBtn_; emoji::PickButton *emojiBtn_; - QSharedPointer 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 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, QWidget *parent = nullptr); + MemberList(const QString &room_id, QWidget *parent = nullptr); public slots: void addUsers(const std::vector &users); @@ -57,7 +56,6 @@ private: QString room_id_; QLabel *topLabel_; QListWidget *list_; - QSharedPointer 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, - 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_; - // Button section FlatButton *saveBtn_; FlatButton *cancelBtn_; -- cgit 1.5.1