Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "profilepagecache.h"
- #include "profilepage.h"
- ProfilePageCache* ProfilePageCache::m_instance = NULL;
- ProfilePageCache::ProfilePageCache(QObject *parent) :
- QObject(parent)
- {
- }
- ProfilePage* ProfilePageCache::getProfilePage(QString profileId)
- {
- if (m_cachedProfilePages.contains(profileId)) {
- return m_cachedProfilePages.value(profileId);
- } else {
- ProfilePage *profilePage = new ProfilePage(NULL, profileId);
- m_cachedProfilePages.insert(profileId, profilePage);
- return profilePage;
- }
- }
- ProfilePageCache* ProfilePageCache::instance()
- {
- if (m_instance == NULL)
- m_instance = new ProfilePageCache;
- return m_instance;
- }
- /////////////////////////
- #ifndef PROFILEPAGECACHE_H
- #define PROFILEPAGECACHE_H
- #include <QObject>
- #include <QMap>
- class ProfilePage;
- class ProfilePageCache : public QObject
- {
- Q_OBJECT
- public:
- explicit ProfilePageCache(QObject *parent = 0);
- static ProfilePageCache* instance();
- ProfilePage *getProfilePage(QString profileId);
- signals:
- public slots:
- private:
- QMap<QString,ProfilePage*> m_cachedProfilePages;
- static ProfilePageCache *m_instance;
- };
- #endif // PROFILEPAGECACHE_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement