Class: Qt::Settings::Group

Inherits:
Object show all
Defined in:
lib/rui/toolkits/qt/qt.rb

Instance Method Summary collapse

Constructor Details

#initialize(settings, prefix) ⇒ Group

Returns a new instance of Group.



244
245
246
247
# File 'lib/rui/toolkits/qt/qt.rb', line 244

def initialize(settings, prefix)
  @settings = settings
  @prefix = prefix
end

Instance Method Details

#delete_groupObject



255
256
257
# File 'lib/rui/toolkits/qt/qt.rb', line 255

def delete_group
  @settings.remove(@prefix)
end

#each_groupObject



291
292
293
294
295
296
297
298
# File 'lib/rui/toolkits/qt/qt.rb', line 291

def each_group
  names = in_group do
    @settings.child_groups
  end
  names.each do |name|
    yield group(name)
  end
end

#entry_mapObject



282
283
284
285
286
287
288
289
# File 'lib/rui/toolkits/qt/qt.rb', line 282

def entry_map
  in_group do
    @settings.child_keys.inject({}) do |res, key|
      res[key] = @settings.value(key).toString
      res
    end
  end
end

#existsObject



249
250
251
252
253
# File 'lib/rui/toolkits/qt/qt.rb', line 249

def exists
  in_group do
    not @settings.all_keys.empty?
  end
end

#group(name) ⇒ Object



259
260
261
# File 'lib/rui/toolkits/qt/qt.rb', line 259

def group(name)
  Group.new(@settings, prefixed(name))
end

#group_listObject



276
277
278
279
280
# File 'lib/rui/toolkits/qt/qt.rb', line 276

def group_list
  in_group do
    @settings.child_groups
  end
end

#nameObject



300
301
302
303
304
305
306
# File 'lib/rui/toolkits/qt/qt.rb', line 300

def name
  if @prefix =~ /\/([^\/]+)$/
    $1
  else
    @prefix
  end
end

#read_entry(key, default_value = nil) ⇒ Object



268
269
270
# File 'lib/rui/toolkits/qt/qt.rb', line 268

def read_entry(key, default_value = nil)
  @settings.value(prefixed(key)).toString || default_value
end

#syncObject



272
273
274
# File 'lib/rui/toolkits/qt/qt.rb', line 272

def sync
  @settings.sync
end

#write_entry(key, value) ⇒ Object



263
264
265
266
# File 'lib/rui/toolkits/qt/qt.rb', line 263

def write_entry(key, value)
  @settings.set_value(prefixed(key), 
                      Qt::Variant.new(value))
end