20 #include "unitymenumodelcache.h"
21 #include <unitymenumodel.h>
25 QPointer<UnityMenuModelCache> UnityMenuModelCache::theCache =
nullptr;
27 UnityMenuModelCache* UnityMenuModelCache::singleton()
29 if (theCache.isNull()) {
30 theCache =
new UnityMenuModelCache();
32 return theCache.data();
35 UnityMenuModelCache::UnityMenuModelCache(QObject* parent)
40 QSharedPointer<UnityMenuModel> UnityMenuModelCache::model(
const QByteArray& path)
42 if (m_registry.contains(path))
43 return m_registry[path];
45 UnityMenuModel* model =
new UnityMenuModel;
46 QQmlEngine::setObjectOwnership(model, QQmlEngine::CppOwnership);
48 QSharedPointer<UnityMenuModel> menuModel(model);
56 m_registry[path] = menuModel;
58 menuModel->setMenuObjectPath(path);
62 bool UnityMenuModelCache::contains(
const QByteArray& path)
64 return m_registry.contains(path);