<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def insert_pattern(pattern, model, index=0):
 """ Inserts given pattern into given Model. :param pattern: Pattern. :type pattern: unicode :param model: Model. :type model: PatternsModel :param index: Insertion indes. :type index: int :return: Method success. :rtype: bool """


        if not pattern:
            return False

        pattern = pattern.replace(QChar(QChar.ParagraphSeparator), QString("\n"))
        pattern = foundations.common.get_first_item(foundations.strings.to_string(pattern).split("\n"))

        model.insert_pattern(foundations.strings.to_string(pattern), index)

        return True