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