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

#include "skanpage_state.h"

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

class SkanpageStatePrivate
{
  public:

    // General
    QString deviceName;
    QString deviceModel;
    QString deviceVendor;

    // UiSettings
    bool showOptions;
    bool showAllOptions;
    uint splitViewItemWidth;

    // items
    KConfigCompilerSignallingItem *itemDeviceName;
    KConfigCompilerSignallingItem *itemDeviceModel;
    KConfigCompilerSignallingItem *itemDeviceVendor;
    KConfigCompilerSignallingItem *itemShowOptions;
    KConfigCompilerSignallingItem *itemShowAllOptions;
    KConfigCompilerSignallingItem *itemSplitViewItemWidth;
};

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

  return s_globalSkanpageState()->q;
}

SkanpageState::SkanpageState( )
  : KConfigSkeleton( KSharedConfig::openStateConfig(QStringLiteral( "skanpagerc") ) )
{
  d = new SkanpageStatePrivate;
  Q_ASSERT(!s_globalSkanpageState()->q);
  s_globalSkanpageState()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&SkanpageState::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigSkeleton::ItemString  *innerItemDeviceName;
  innerItemDeviceName = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "deviceName" ), d->deviceName );
  d->itemDeviceName = new KConfigCompilerSignallingItem(innerItemDeviceName, this, notifyFunction, signalDeviceNameChanged);
  d->itemDeviceName->setWriteFlags(KConfigBase::Notify);
  addItem( d->itemDeviceName, QStringLiteral( "deviceName" ) );
  KConfigSkeleton::ItemString  *innerItemDeviceModel;
  innerItemDeviceModel = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "deviceModel" ), d->deviceModel );
  d->itemDeviceModel = new KConfigCompilerSignallingItem(innerItemDeviceModel, this, notifyFunction, signalDeviceModelChanged);
  d->itemDeviceModel->setWriteFlags(KConfigBase::Notify);
  addItem( d->itemDeviceModel, QStringLiteral( "deviceModel" ) );
  KConfigSkeleton::ItemString  *innerItemDeviceVendor;
  innerItemDeviceVendor = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "deviceVendor" ), d->deviceVendor );
  d->itemDeviceVendor = new KConfigCompilerSignallingItem(innerItemDeviceVendor, this, notifyFunction, signalDeviceVendorChanged);
  d->itemDeviceVendor->setWriteFlags(KConfigBase::Notify);
  addItem( d->itemDeviceVendor, QStringLiteral( "deviceVendor" ) );

  setCurrentGroup( QStringLiteral( "UiSettings" ) );

  KConfigSkeleton::ItemBool  *innerItemShowOptions;
  innerItemShowOptions = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "showOptions" ), d->showOptions, 
      true
     );
  d->itemShowOptions = new KConfigCompilerSignallingItem(innerItemShowOptions, this, notifyFunction, signalShowOptionsChanged);
  d->itemShowOptions->setWriteFlags(KConfigBase::Notify);
  addItem( d->itemShowOptions, QStringLiteral( "showOptions" ) );
  KConfigSkeleton::ItemBool  *innerItemShowAllOptions;
  innerItemShowAllOptions = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "showAllOptions" ), d->showAllOptions, 
      false
     );
  d->itemShowAllOptions = new KConfigCompilerSignallingItem(innerItemShowAllOptions, this, notifyFunction, signalShowAllOptionsChanged);
  d->itemShowAllOptions->setWriteFlags(KConfigBase::Notify);
  addItem( d->itemShowAllOptions, QStringLiteral( "showAllOptions" ) );
  KConfigSkeleton::ItemUInt  *innerItemSplitViewItemWidth;
  innerItemSplitViewItemWidth = new KConfigSkeleton::ItemUInt( currentGroup(), QStringLiteral( "splitViewItemWidth" ), d->splitViewItemWidth, 
        300
     );
  d->itemSplitViewItemWidth = new KConfigCompilerSignallingItem(innerItemSplitViewItemWidth, this, notifyFunction, signalSplitViewItemWidthChanged);
  d->itemSplitViewItemWidth->setWriteFlags(KConfigBase::Notify);
  addItem( d->itemSplitViewItemWidth, QStringLiteral( "splitViewItemWidth" ) );
}

void SkanpageState::setDeviceName( const QString & v )
{
    if (v != self()->d->deviceName && !self()->SkanpageState::isDeviceNameImmutable()) {
      self()->d->deviceName = v;
      Q_EMIT self()->deviceNameChanged();
    }
}

QString SkanpageState::deviceName()
{
  return self()->d->deviceName;
}

bool  SkanpageState::isDeviceNameImmutable()
{
    return self()->isImmutable( QStringLiteral( "deviceName" ) );
}


void SkanpageState::setDeviceModel( const QString & v )
{
    if (v != self()->d->deviceModel && !self()->SkanpageState::isDeviceModelImmutable()) {
      self()->d->deviceModel = v;
      Q_EMIT self()->deviceModelChanged();
    }
}

QString SkanpageState::deviceModel()
{
  return self()->d->deviceModel;
}

bool  SkanpageState::isDeviceModelImmutable()
{
    return self()->isImmutable( QStringLiteral( "deviceModel" ) );
}


void SkanpageState::setDeviceVendor( const QString & v )
{
    if (v != self()->d->deviceVendor && !self()->SkanpageState::isDeviceVendorImmutable()) {
      self()->d->deviceVendor = v;
      Q_EMIT self()->deviceVendorChanged();
    }
}

QString SkanpageState::deviceVendor()
{
  return self()->d->deviceVendor;
}

bool  SkanpageState::isDeviceVendorImmutable()
{
    return self()->isImmutable( QStringLiteral( "deviceVendor" ) );
}


void SkanpageState::setShowOptions( bool v )
{
    if (v != self()->d->showOptions && !self()->SkanpageState::isShowOptionsImmutable()) {
      self()->d->showOptions = v;
      Q_EMIT self()->showOptionsChanged();
    }
}

bool SkanpageState::showOptions()
{
  return self()->d->showOptions;
}

bool  SkanpageState::isShowOptionsImmutable()
{
    return self()->isImmutable( QStringLiteral( "showOptions" ) );
}


void SkanpageState::setShowAllOptions( bool v )
{
    if (v != self()->d->showAllOptions && !self()->SkanpageState::isShowAllOptionsImmutable()) {
      self()->d->showAllOptions = v;
      Q_EMIT self()->showAllOptionsChanged();
    }
}

bool SkanpageState::showAllOptions()
{
  return self()->d->showAllOptions;
}

bool  SkanpageState::isShowAllOptionsImmutable()
{
    return self()->isImmutable( QStringLiteral( "showAllOptions" ) );
}


void SkanpageState::setSplitViewItemWidth( uint v )
{
    if (v != self()->d->splitViewItemWidth && !self()->SkanpageState::isSplitViewItemWidthImmutable()) {
      self()->d->splitViewItemWidth = v;
      Q_EMIT self()->splitViewItemWidthChanged();
    }
}

uint SkanpageState::splitViewItemWidth()
{
  return self()->d->splitViewItemWidth;
}

bool  SkanpageState::isSplitViewItemWidthImmutable()
{
    return self()->isImmutable( QStringLiteral( "splitViewItemWidth" ) );
}


SkanpageState::~SkanpageState()
{
  delete d;
  if (s_globalSkanpageState.exists() && !s_globalSkanpageState.isDestroyed()) {
    s_globalSkanpageState()->q = nullptr;
  }
}


void SkanpageState::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalDeviceNameChanged:
    Q_EMIT deviceNameChanged();
    break;
  case signalDeviceModelChanged:
    Q_EMIT deviceModelChanged();
    break;
  case signalDeviceVendorChanged:
    Q_EMIT deviceVendorChanged();
    break;
  case signalShowOptionsChanged:
    Q_EMIT showOptionsChanged();
    break;
  case signalShowAllOptionsChanged:
    Q_EMIT showAllOptionsChanged();
    break;
  case signalSplitViewItemWidthChanged:
    Q_EMIT splitViewItemWidthChanged();
    break;
  }
}
