'Change to uppercase current line or selection.'

def transform_to_uppercase(self):

    cursor = self.textCursor()
    prev_pos = cursor.position()
    selected_text = to_text_string(cursor.selectedText())
    if (len(selected_text) == 0):
        prev_pos = cursor.position()
        cursor.select(QTextCursor.WordUnderCursor)
        selected_text = to_text_string(cursor.selectedText())
    s = selected_text.upper()
    cursor.insertText(s)
    self.set_cursor_position(prev_pos)
