File indexing completed on 2024-05-19 09:32:17

0001 /*
0002  *   SPDX-FileCopyrightText: 2009 Ben Cooksley <bcooksley@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "BaseData.h"
0008 
0009 #include "MenuItem.h"
0010 
0011 #include <KConfigGroup>
0012 #include <KSharedConfig>
0013 
0014 class DataHelper
0015 {
0016 public:
0017     DataHelper()
0018     {
0019     }
0020     ~DataHelper()
0021     {
0022         delete object;
0023     }
0024     BaseData *object = nullptr;
0025 };
0026 
0027 Q_GLOBAL_STATIC(DataHelper, internalInstance)
0028 
0029 BaseData::BaseData()
0030 {
0031     internalInstance->object = this;
0032 }
0033 
0034 BaseData::~BaseData()
0035 {
0036 }
0037 
0038 BaseData *BaseData::instance()
0039 {
0040     if (!internalInstance->object) {
0041         new BaseData();
0042     }
0043     return internalInstance->object;
0044 }
0045 
0046 MenuItem *BaseData::menuItem()
0047 {
0048     return rootMenu;
0049 }
0050 
0051 void BaseData::setMenuItem(MenuItem *item)
0052 {
0053     rootMenu = item;
0054 }
0055 
0056 MenuItem *BaseData::homeItem()
0057 {
0058     return m_homeItem;
0059 }
0060 
0061 void BaseData::setHomeItem(MenuItem *item)
0062 {
0063     m_homeItem = item;
0064 }
0065 
0066 KConfigGroup BaseData::configGroup(const QString &pluginName)
0067 {
0068     return KSharedConfig::openConfig()->group(pluginName);
0069 }
0070 
0071 #include "moc_BaseData.cpp"