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

#include "kweathersettings.h"

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

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

  return s_globalKWeatherSettings()->q;
}

KWeatherSettings::KWeatherSettings( QObject *parent )
  : KConfigSkeleton( QStringLiteral( "kweather/kweatherrc" ) )
{
  setParent(parent);
  Q_ASSERT(!s_globalKWeatherSettings()->q);
  s_globalKWeatherSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&KWeatherSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemFirstStartup;
  KConfigSkeleton::ItemBool  *innerItemFirstStartup;
  innerItemFirstStartup = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "firstStartup" ), mFirstStartup, true );
  itemFirstStartup = new KConfigCompilerSignallingItem(innerItemFirstStartup, this, notifyFunction, signalFirstStartupChanged);
  addItem( itemFirstStartup, QStringLiteral( "firstStartup" ) );
  KConfigCompilerSignallingItem  *itemForecastStyle;
  KConfigSkeleton::ItemString  *innerItemForecastStyle;
  innerItemForecastStyle = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "forecastStyle" ), mForecastStyle, QStringLiteral( "Dynamic" ) );
  itemForecastStyle = new KConfigCompilerSignallingItem(innerItemForecastStyle, this, notifyFunction, signalForecastStyleChanged);
  addItem( itemForecastStyle, QStringLiteral( "forecastStyle" ) );
  KConfigCompilerSignallingItem  *itemTemperatureUnits;
  KConfigSkeleton::ItemString  *innerItemTemperatureUnits;
  innerItemTemperatureUnits = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "temperatureUnits" ), mTemperatureUnits, QStringLiteral( "Use System Default" ) );
  itemTemperatureUnits = new KConfigCompilerSignallingItem(innerItemTemperatureUnits, this, notifyFunction, signalTemperatureUnitsChanged);
  addItem( itemTemperatureUnits, QStringLiteral( "temperatureUnits" ) );
  KConfigCompilerSignallingItem  *itemSpeedUnits;
  KConfigSkeleton::ItemString  *innerItemSpeedUnits;
  innerItemSpeedUnits = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "speedUnits" ), mSpeedUnits, QStringLiteral( "kph" ) );
  itemSpeedUnits = new KConfigCompilerSignallingItem(innerItemSpeedUnits, this, notifyFunction, signalSpeedUnitsChanged);
  addItem( itemSpeedUnits, QStringLiteral( "speedUnits" ) );
  KConfigCompilerSignallingItem  *itemPressureUnits;
  KConfigSkeleton::ItemString  *innerItemPressureUnits;
  innerItemPressureUnits = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "pressureUnits" ), mPressureUnits, QStringLiteral( "hPa" ) );
  itemPressureUnits = new KConfigCompilerSignallingItem(innerItemPressureUnits, this, notifyFunction, signalPressureUnitsChanged);
  addItem( itemPressureUnits, QStringLiteral( "pressureUnits" ) );
  KConfigCompilerSignallingItem  *itemPrecipitationUnits;
  KConfigSkeleton::ItemString  *innerItemPrecipitationUnits;
  innerItemPrecipitationUnits = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "precipitationUnits" ), mPrecipitationUnits, QStringLiteral( "mm" ) );
  itemPrecipitationUnits = new KConfigCompilerSignallingItem(innerItemPrecipitationUnits, this, notifyFunction, signalPrecipitationUnitsChanged);
  addItem( itemPrecipitationUnits, QStringLiteral( "precipitationUnits" ) );
}

bool KWeatherSettings::defaultFirstStartupValue_helper()
{

  return true;
}

QString KWeatherSettings::defaultForecastStyleValue_helper()
{

  return QStringLiteral( "Dynamic" );
}

QString KWeatherSettings::defaultTemperatureUnitsValue_helper()
{

  return QStringLiteral( "Use System Default" );
}

QString KWeatherSettings::defaultSpeedUnitsValue_helper()
{

  return QStringLiteral( "kph" );
}

QString KWeatherSettings::defaultPressureUnitsValue_helper()
{

  return QStringLiteral( "hPa" );
}

QString KWeatherSettings::defaultPrecipitationUnitsValue_helper()
{

  return QStringLiteral( "mm" );
}

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


void KWeatherSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalFirstStartupChanged:
    Q_EMIT firstStartupChanged();
    break;
  case signalForecastStyleChanged:
    Q_EMIT forecastStyleChanged();
    break;
  case signalTemperatureUnitsChanged:
    Q_EMIT temperatureUnitsChanged();
    break;
  case signalSpeedUnitsChanged:
    Q_EMIT speedUnitsChanged();
    break;
  case signalPressureUnitsChanged:
    Q_EMIT pressureUnitsChanged();
    break;
  case signalPrecipitationUnitsChanged:
    Q_EMIT precipitationUnitsChanged();
    break;
  }
}
