nodes: 0, module; 1, function_definition; 2, function_name:add_ordered_combo_item; 3, parameters; 4, block; 5, identifier:combo; 6, identifier:text; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, for_statement; 14, comment:# otherwise just add it to the end; 15, if_statement; 16, identifier:data; 17, None; 18, identifier:count_selected_features; 19, None; 20, identifier:icon; 21, None; 22, comment:"""Add a combo item ensuring that all items are listed alphabetically.
  
      Although QComboBox allows you to set an InsertAlphabetically enum
      this only has effect when a user interactively adds combo items to
      an editable combo. This we have this little function to ensure that
      combos are always sorted alphabetically.
  
      :param combo: Combo box receiving the new item.
      :type combo: QComboBox
  
      :param text: Display text for the combo.
      :type text: str
  
      :param data: Optional UserRole data to be associated with the item.
      :type data: QVariant, str
  
      :param count_selected_features: A count to display if the layer has some
      selected features. Default to None, nothing will be displayed.
      :type count_selected_features: None, int
  
      :param icon: Icon to display in the combobox.
      :type icon: QIcon
      """; 23, comparison_operator:count_selected_features is not None; 24, block; 25, assignment; 26, identifier:combo_index; 27, call; 28, block; 29, identifier:icon; 30, block; 31, else_clause; 32, identifier:count_selected_features; 33, None; 34, expression_statement; 35, identifier:size; 36, call; 37, identifier:range; 38, argument_list; 39, expression_statement; 40, comment:# see if text alphabetically precedes item_text; 41, if_statement; 42, expression_statement; 43, block; 44, augmented_assignment; 45, attribute; 46, argument_list; 47, integer:0; 48, identifier:size; 49, assignment; 50, comparison_operator:cmp(text.lower(), item_text.lower()) < 0; 51, block; 52, call; 53, expression_statement; 54, identifier:text; 55, binary_operator:' (' + tr('{count} selected features').format(
              count=count_selected_features) + ')'; 56, identifier:combo; 57, identifier:count; 58, identifier:item_text; 59, call; 60, call; 61, integer:0; 62, if_statement; 63, return_statement; 64, attribute; 65, argument_list; 66, call; 67, binary_operator:' (' + tr('{count} selected features').format(
              count=count_selected_features); 68, string; 69, attribute; 70, argument_list; 71, identifier:cmp; 72, argument_list; 73, identifier:icon; 74, block; 75, else_clause; 76, identifier:combo; 77, identifier:insertItem; 78, identifier:size; 79, identifier:icon; 80, identifier:text; 81, identifier:data; 82, attribute; 83, argument_list; 84, string; 85, call; 86, string_content:); 87, identifier:combo; 88, identifier:itemText; 89, identifier:combo_index; 90, call; 91, call; 92, expression_statement; 93, block; 94, identifier:combo; 95, identifier:insertItem; 96, identifier:size; 97, identifier:text; 98, identifier:data; 99, string_content:(; 100, attribute; 101, argument_list; 102, attribute; 103, argument_list; 104, attribute; 105, argument_list; 106, call; 107, expression_statement; 108, call; 109, identifier:format; 110, keyword_argument; 111, identifier:text; 112, identifier:lower; 113, identifier:item_text; 114, identifier:lower; 115, attribute; 116, argument_list; 117, call; 118, identifier:tr; 119, argument_list; 120, identifier:count; 121, identifier:count_selected_features; 122, identifier:combo; 123, identifier:insertItem; 124, identifier:combo_index; 125, identifier:icon; 126, identifier:text; 127, identifier:data; 128, attribute; 129, argument_list; 130, string; 131, identifier:combo; 132, identifier:insertItem; 133, identifier:combo_index; 134, identifier:text; 135, identifier:data; 136, string_content:{count} selected features
code: def add_ordered_combo_item(
          combo, text, data=None, count_selected_features=None, icon=None):
      """Add a combo item ensuring that all items are listed alphabetically.
  
      Although QComboBox allows you to set an InsertAlphabetically enum
      this only has effect when a user interactively adds combo items to
      an editable combo. This we have this little function to ensure that
      combos are always sorted alphabetically.
  
      :param combo: Combo box receiving the new item.
      :type combo: QComboBox
  
      :param text: Display text for the combo.
      :type text: str
  
      :param data: Optional UserRole data to be associated with the item.
      :type data: QVariant, str
  
      :param count_selected_features: A count to display if the layer has some
      selected features. Default to None, nothing will be displayed.
      :type count_selected_features: None, int
  
      :param icon: Icon to display in the combobox.
      :type icon: QIcon
      """
      if count_selected_features is not None:
          text += ' (' + tr('{count} selected features').format(
              count=count_selected_features) + ')'
      size = combo.count()
      for combo_index in range(0, size):
          item_text = combo.itemText(combo_index)
          # see if text alphabetically precedes item_text
          if cmp(text.lower(), item_text.lower()) < 0:
              if icon:
                  combo.insertItem(combo_index, icon, text, data)
              else:
                  combo.insertItem(combo_index, text, data)
              return
  
      # otherwise just add it to the end
      if icon:
          combo.insertItem(size, icon, text, data)
      else:
          combo.insertItem(size, text, data)