def countCheckedItems(widget_list, what_to_count):
    """
    Calculation of the amount of records marked in the list.

    :param widget_list: the current list for which the number of marked records is counted.
    :param what_to_count: A parameter that tells the function what to count, for example: number of checked items.
    :returns: boolean or number (of checked items).
    """

    def isAtLeastOneItemChecked():
        for index in range(widget_list.count()):
            if widget_list.item(index).checkState() == 2:
                return True
        return False

    def isAtLeastOneItemNotChecked():
        for index in range(widget_list.count()):
            if widget_list.item(index).checkState() == 0:
                return True
        return False

    def isNoItemChecked():
        for index in range(widget_list.count()):
            if widget_list.item(index).checkState() == 2:
                return False
        return True

    def numOfCheckedItems():
        counter = 0
        for index in range(widget_list.count()):
            if widget_list.item(index).checkState() == 2:
                counter = counter + 1
        return counter

    return {'at_list_one_checked': isAtLeastOneItemChecked,
            'at_list_one_not_checked': isAtLeastOneItemNotChecked,
            'not_items_checked': isNoItemChecked,
            'num_of_check_items': numOfCheckedItems
            }[what_to_count]()