// This file is generated by kconfig_compiler_kf6 from contactconfig.kcfg.
// All changes you do to this file will be lost.

#include "contactconfig.h"

#include <qglobal.h>
#include <QFile>
#include <QQmlEngine>

class ContactConfigHelper
{
  public:
    ContactConfigHelper() noexcept : q(nullptr) {}
    ~ContactConfigHelper() noexcept { delete q; q = nullptr; }
    ContactConfigHelper(const ContactConfigHelper&) = delete;
    ContactConfigHelper& operator=(const ContactConfigHelper&) = delete;
    ContactConfig *q;
};
Q_GLOBAL_STATIC(ContactConfigHelper, s_globalContactConfig)
ContactConfig *ContactConfig::self()
{
  if (!s_globalContactConfig()->q) {
    new ContactConfig;
    s_globalContactConfig()->q->read();
  }

  return s_globalContactConfig()->q;
}

ContactConfig *ContactConfig::create(QQmlEngine *, QJSEngine *)
{
  QQmlEngine::setObjectOwnership(self(), QQmlEngine::CppOwnership);
  return self();
}

ContactConfig::ContactConfig( QObject *parent )
  : KConfigSkeleton( QStringLiteral( "kalendarcontactrc" ) )
{
  setParent(parent);
  Q_ASSERT(!s_globalContactConfig()->q);
  s_globalContactConfig()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&ContactConfig::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemShowMenubar;
  KConfigSkeleton::ItemBool  *innerItemShowMenubar;
  innerItemShowMenubar = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "showMenubar" ), mShowMenubar, true );
  itemShowMenubar = new KConfigCompilerSignallingItem(innerItemShowMenubar, this, notifyFunction, signalShowMenubarChanged);
  addItem( itemShowMenubar, QStringLiteral( "showMenubar" ) );
  KConfigCompilerSignallingItem  *itemForceCollapsedMainDrawer;
  KConfigSkeleton::ItemBool  *innerItemForceCollapsedMainDrawer;
  innerItemForceCollapsedMainDrawer = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "forceCollapsedMainDrawer" ), mForceCollapsedMainDrawer, false );
  itemForceCollapsedMainDrawer = new KConfigCompilerSignallingItem(innerItemForceCollapsedMainDrawer, this, notifyFunction, signalForceCollapsedMainDrawerChanged);
  addItem( itemForceCollapsedMainDrawer, QStringLiteral( "forceCollapsedMainDrawer" ) );

  setCurrentGroup( QStringLiteral( "Editor" ) );

  KConfigCompilerSignallingItem  *itemLastUsedAddressBookCollection;
  KConfigSkeleton::ItemInt  *innerItemLastUsedAddressBookCollection;
  innerItemLastUsedAddressBookCollection = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "lastUsedAddressBookCollection" ), mLastUsedAddressBookCollection, -1 );
  itemLastUsedAddressBookCollection = new KConfigCompilerSignallingItem(innerItemLastUsedAddressBookCollection, this, notifyFunction, signalLastUsedAddressBookCollectionChanged);
  addItem( itemLastUsedAddressBookCollection, QStringLiteral( "lastUsedAddressBookCollection" ) );
}

bool ContactConfig::defaultShowMenubarValue_helper()
{

  return true;
}

bool ContactConfig::defaultForceCollapsedMainDrawerValue_helper()
{

  return false;
}

int ContactConfig::defaultLastUsedAddressBookCollectionValue_helper()
{

  return -1;
}

ContactConfig::~ContactConfig()
{
  if (s_globalContactConfig.exists() && !s_globalContactConfig.isDestroyed()) {
    s_globalContactConfig()->q = nullptr;
  }
}


void ContactConfig::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalShowMenubarChanged:
    Q_EMIT showMenubarChanged();
    break;
  case signalForceCollapsedMainDrawerChanged:
    Q_EMIT forceCollapsedMainDrawerChanged();
    break;
  case signalLastUsedAddressBookCollectionChanged:
    Q_EMIT lastUsedAddressBookCollectionChanged();
    break;
  }
}
