Class: Ritsu::SrcFiles::TargetCmakeLists::QtUiTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/ritsu/ext/qt/src_files/target_cmake_lists.rb

Instance Attribute Summary collapse

Attributes included from BlockMixin

#contents, #id, #indent_length, #indent_level, #local_indentation

Instance Method Summary collapse

Methods inherited from Template

#add_content, #add_template, #child_template_with_id, #child_template_with_id_position, #child_templates, #create_block

Methods included from BlockMixin

#add_line, #add_new_line, #block_structure?, #clear_contents, #indent, #initialize_block_mixin, #outdent

Constructor Details

#initialize(target) ⇒ QtUiTemplate

Returns a new instance of QtUiTemplate.



11
12
13
14
# File 'lib/ritsu/ext/qt/src_files/target_cmake_lists.rb', line 11

def initialize(target)
  super("TargetCmakeLists -- #{target.name} -- QtUi")
  @target = target
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



9
10
11
# File 'lib/ritsu/ext/qt/src_files/target_cmake_lists.rb', line 9

def target
  @target
end

Instance Method Details

#ui_header_files_var_nameObject



16
17
18
# File 'lib/ritsu/ext/qt/src_files/target_cmake_lists.rb', line 16

def ui_header_files_var_name
  "#{target.name.upcase}_UI_HEADER_FILES"
end

#update_block(block, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ritsu/ext/qt/src_files/target_cmake_lists.rb', line 20

def update_block(block, options = {})
  block.clear_contents
  
  ui_files = target.src_files.select { |x| x.respond_to?(:ui_file?) && x.ui_file? }
  if ui_files.length == 0
    return
  end
  ui_files.sort! {|x,y| x.src_path <=> y.src_path}
  
  block.add_line "RITSU_QT4_WRAP_UI(#{ui_header_files_var_name}"
  block.indent
  ui_files.each do |ui_file|
    block.add_line("${CMAKE_SOURCE_DIR}/#{ui_file.src_path}")
  end
  block.outdent
  block.add_line ")"
  block.add_new_line
  block.add_line "SET(#{target.name.upcase}_SRC_FILES ${#{target.name.upcase}_SRC_FILES} ${#{ui_header_files_var_name}})"
end