Module: QtFlags

Included in:
ObjectTableModel, Qt::CheckBox
Defined in:
lib/qtext/flags.rb

Overview

The Qt bindings look up constants for each call. This module

caches the constant values. Most of these are called for each
cell in a table, so caching them gives us a good performance
increase.

Instance Method Summary collapse

Instance Method Details

#const_as_string(constant) ⇒ Object

ewww



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/qtext/flags.rb', line 83

def const_as_string( constant )
  case constant
    when qt_text_alignment_role; 'Qt::TextAlignmentRole'
    when qt_checkstate_role; 'Qt::CheckStateRole'
    when qt_edit_role; 'Qt:EditRole'
    when qt_display_role; 'Qt::DisplayRole'
    when Qt::ToolTipRole; 'Qt::ToolTipRole'
    when Qt::StatusTipRole; 'Qt::StatusTipRole'
    when Qt::DecorationRole; 'Qt::DecorationRole'
    when Qt::BackgroundRole; 'Qt::BackgroundRole'
    when Qt::FontRole; 'Qt::FontRole'
    when Qt::ForegroundRole; 'Qt::ForegroundRole'
    when Qt::TextColorRole; 'Qt::TextColorRole'
    
    else "#{constant} unknown"
  end
end

#item_boolean_flagsObject



10
11
12
# File 'lib/qtext/flags.rb', line 10

def item_boolean_flags
  @item_boolean_flags ||= Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable
end

#qt_aligncenterObject



58
59
60
# File 'lib/qtext/flags.rb', line 58

def qt_aligncenter
  @qt_aligncenter ||= Qt::AlignCenter
end

#qt_alignleftObject



50
51
52
# File 'lib/qtext/flags.rb', line 50

def qt_alignleft
  @qt_alignleft ||= Qt::AlignLeft
end

#qt_alignrightObject



54
55
56
# File 'lib/qtext/flags.rb', line 54

def qt_alignright
  @qt_alignright ||= Qt::AlignRight
end

#qt_background_roleObject



66
67
68
# File 'lib/qtext/flags.rb', line 66

def qt_background_role
  @qt_background_role ||= Qt::BackgroundRole
end

#qt_checkedObject



42
43
44
# File 'lib/qtext/flags.rb', line 42

def qt_checked
  @qt_checked ||= Qt::Checked
end

#qt_checkstate_roleObject



30
31
32
# File 'lib/qtext/flags.rb', line 30

def qt_checkstate_role
  @qt_checkstate_role ||= Qt::CheckStateRole
end

#qt_decoration_roleObject



62
63
64
# File 'lib/qtext/flags.rb', line 62

def qt_decoration_role
  @qt_decoration_role ||= Qt::DecorationRole
end

#qt_display_roleObject



18
19
20
# File 'lib/qtext/flags.rb', line 18

def qt_display_role
  @qt_display_role ||= Qt::DisplayRole
end

#qt_edit_roleObject



22
23
24
# File 'lib/qtext/flags.rb', line 22

def qt_edit_role
  @qt_edit_role ||= Qt::EditRole
end

#qt_font_roleObject



70
71
72
# File 'lib/qtext/flags.rb', line 70

def qt_font_role
  @qt_font_role ||= Qt::FontRole
end

#qt_foreground_roleObject



74
75
76
# File 'lib/qtext/flags.rb', line 74

def qt_foreground_role
  @qt_foreground_role ||= Qt::ForegroundRole
end

#qt_item_is_editableObject



14
15
16
# File 'lib/qtext/flags.rb', line 14

def qt_item_is_editable
  @qt_item_is_editable ||= Qt::ItemIsEditable
end

#qt_paste_roleObject



26
27
28
# File 'lib/qtext/flags.rb', line 26

def qt_paste_role
  @qt_paste_role ||= Qt::PasteRole
end

#qt_size_hint_roleObject



38
39
40
# File 'lib/qtext/flags.rb', line 38

def qt_size_hint_role
  @qt_size_hint_role ||= Qt::SizeHintRole
end

#qt_text_alignment_roleObject



34
35
36
# File 'lib/qtext/flags.rb', line 34

def qt_text_alignment_role
  @qt_text_alignment_role ||= Qt::TextAlignmentRole
end

#qt_tooltip_roleObject



78
79
80
# File 'lib/qtext/flags.rb', line 78

def qt_tooltip_role
  @qt_tooltip_role ||= Qt::ToolTipRole
end

#qt_uncheckedObject



46
47
48
# File 'lib/qtext/flags.rb', line 46

def qt_unchecked
  @qt_unchecked ||= Qt::Unchecked
end