# This file is generated by rbkconfig_compiler from test5.kcfg.
# All changes you do to this file will be lost.

require 'singleton'

class Test5 < KDE::ConfigSkeleton
  include Singleton
  Encrypt = 0
  Decrypt = 1
  CrashNBurn = 2
  PumpNDump = 3

  Right = 0
  Mid = 1
  Left = 2

  def EnumButtonToString(i)
    ["Right", "Mid", "Left"].at(i)
  end

  #
  # Set Block colors.
  #
  def setColor(i, v)
    item = findItem("Color%s" % i)
    if !item.immutable?
      item.property = @color[i] = Qt::Variant.fromValue(v)
    end
  end

  #
  # Get Block colors.
  #
  def color(i)
    @color[i] = findItem("Color%s" % i).property
    return @color[i].value
  end

  #
  # Set Mouse actions.
  #
  def setMouseAction(i, v)
    item = findItem("MouseAction%s" % EnumButtonToString(i))
    if !item.immutable?
      item.property = @mouseAction[i] = Qt::Variant.fromValue(v)
    end
  end

  #
  # Get Mouse actions.
  #
  def mouseAction(i)
    @mouseAction[i] = findItem("MouseAction%s" %  EnumButtonToString(i)).property
    return @mouseAction[i].toInt
  end

  #
  # Set foo bar
  #
  def setFooBar(v)
    item = findItem("FooBar")
    if !item.immutable?
      item.property = @fooBar = Qt::Variant.fromValue(v)
    end
  end

  def fooBar=(v)
    setFooBar(v)
  end

  #
  # Get foo bar
  #
  def fooBar
    @fooBar = findItem("FooBar").property
    return @fooBar.value
  end

  #
  # Set Age
  #
  def setAge(v)
    if v < 8
      puts "setAge: value #{v} is less than the minimum value of 8"
      v = 8
    end

    if v > 88
      puts "setAge: value #{v} is greater than the maximum value of 88"
      v = 88
    end

    item = findItem("Age")
    if !item.immutable?
      item.property = @age = Qt::Variant.fromValue(v)
    end
  end

  def age=(v)
    setAge(v)
  end

  #
  # Get Age
  #
  def age
    @age = findItem("Age").property
    return @age.value
  end

  def initialize()
    super("test4rc")

    # Foo
    @color = [Qt::Variant.fromValue(Qt::Color.new), Qt::Variant.fromValue(Qt::Color.new), Qt::Variant.fromValue(Qt::Color.new), Qt::Variant.fromValue(Qt::Color.new)]
    @mouseAction = [Qt::Variant.fromValue(0), Qt::Variant.fromValue(0), Qt::Variant.fromValue(0)]
    @fooBar = Qt::Variant.fromValue("")
    @age = Qt::Variant.fromValue(0)
    setCurrentGroup("Foo")

    defaultColor = [Qt::Color.new(Qt::red), Qt::Color.new(Qt::blue), Qt::Color.new(Qt::green), Qt::Color.new(Qt::black)]
    itemColor = Array.new(4)
    itemColor[0] = ItemColor.new(currentGroup(), "color #0", @color[0].value, defaultColor[0])
    addItem(itemColor[0], "Color0")
    itemColor[1] = ItemColor.new(currentGroup(), "color #1", @color[1].value, defaultColor[1])
    addItem(itemColor[1], "Color1")
    itemColor[2] = ItemColor.new(currentGroup(), "color #2", @color[2].value, defaultColor[2])
    addItem(itemColor[2], "Color2")
    itemColor[3] = ItemColor.new(currentGroup(), "color #3", @color[3].value, defaultColor[3])
    addItem(itemColor[3], "Color3")
    valuesMouseAction = []
    choice = ItemEnum::Choice.new
    choice.name = "Encrypt"
    valuesMouseAction << choice
    choice = ItemEnum::Choice.new
    choice.name = "Decrypt"
    valuesMouseAction << choice
    choice = ItemEnum::Choice.new
    choice.name = "CrashNBurn"
    valuesMouseAction << choice
    choice = ItemEnum::Choice.new
    choice.name = "PumpNDump"
    valuesMouseAction << choice
    itemMouseAction = Array.new(3)
    itemMouseAction[0] = ItemEnum.new(currentGroup(), "right_mouse_action", @mouseAction[0].toInt, valuesMouseAction, Decrypt)
    addItem(itemMouseAction[0], "MouseActionRight")
    itemMouseAction[1] = ItemEnum.new(currentGroup(), "mid_mouse_action", @mouseAction[1].toInt, valuesMouseAction, Encrypt)
    addItem(itemMouseAction[1], "MouseActionMid")
    itemMouseAction[2] = ItemEnum.new(currentGroup(), "left_mouse_action", @mouseAction[2].toInt, valuesMouseAction, PumpNDump)
    addItem(itemMouseAction[2], "MouseActionLeft")
    itemFooBar = ItemString.new(currentGroup(), "foo bar", @fooBar.value)
    itemFooBar.property = @fooBar
    addItem(itemFooBar, "FooBar")
    itemAge = ItemInt.new(currentGroup(), "Age", @age.value, 35)
    itemAge.property = @age
    itemAge.minValue = 8
    itemAge.maxValue = 88
    addItem(itemAge)
    readConfig
  end

end
