# Path: alignak_app/backend/datamanager.py
# class DataManager(object):
#     def __init__(self):
#     def is_ready(self):
#     def update_database(self, item_type, items_list):
#     def get_item(self, item_type, key, value=None):
#     def remove_item(self, item_type, key, value=None):
#     def update_item_data(self, item_type, item_id, data):
#     def get_realm_name(self, realm):
#     def get_period_name(self, period):
#     def get_synthesis_count(self):
#     def get_all_hostnames(self):
#     def get_host_services(self, host_id):
#     def get_host_with_services(self, host_field):
#     def get_events(self):
#     def get_items_and_problems(self):
#     def update_problems(self):
#     def get_problems(self):
#     def is_problem(item_type, item_data):
# 
# Path: alignak_app/items/item.py
# def get_icon_name(item_type, state, acknowledge, downtime, monitored):
#     """
#     Return icon for a host or a service item
# 
#     :param item_type: type of item: host | service
#     :type item_type: str
#     :param state: state of item
#     :type state: str
#     :param acknowledge: if item is acknowledged or not
#     :type acknowledge: bool
#     :param downtime: if item is downtimed
#     :type downtime: bool
#     :param monitored: define if host is monitored or not (0 is not monitored, 1 or 2 is monitored)
#     :type monitored: int
#     :return: icon name for icon
#     :rtype: str
#     """
# 
#     if downtime:
#         return 'downtime'
#     if acknowledge:
#         return 'acknowledge'
#     if monitored == 0:
#         if 'host' in item_type:
#             return 'hosts_not_monitored'
# 
#         return 'services_not_monitored'
# 
#     available_icons = {
#         'host': {
#             'UP': 'hosts_up',
#             'UNREACHABLE': 'hosts_unreachable',
#             'DOWN': 'hosts_down',
#         },
#         'service': {
#             'OK': 'services_ok',
#             'WARNING': 'services_warning',
#             'CRITICAL': 'services_critical',
#             'UNKNOWN': 'services_unknown',
#             'UNREACHABLE': 'services_unreachable'
#         }
#     }
#     try:
#         return available_icons[item_type][state]
#     except KeyError as e:
#         logger.error('Wrong KEY for get_icon_name(): %s', e)
#         return 'error'
# 
# Path: alignak_app/utils/config.py
# class Settings(object):
#     def __init__(self):
#     def init_config(self):
#     def get_config(self, section, option, boolean=False):
#     def set_config(self, section, option, new_value):
#     def get_image(self, name):
#     def init_css(self):
# def open_url(endpoint='login'):  # pragma: no cover
# def get_url_endpoint_from_icon_name(icon_name):


from logging import getLogger
from PyQt5.Qt import QIcon, QTreeWidgetItem
from alignak_app.backend.datamanager import data_manager
from alignak_app.items.item import get_icon_name
from alignak_app.utils.config import settings
        :param service_item: service item with its data
        :type service_item: alignak_app.core.models.service.Service
        """

        self.service_item = service_item
        self.service_id = service_item.item_id
        self.setText(0, self.service_item.get_display_name())

        monitored = service_item.data[
            'passive_checks_enabled'] + service_item.data['active_checks_enabled']
        icon_name = get_icon_name(
            'service',
            service_item.data['ls_state'],
            service_item.data['ls_acknowledged'],
            service_item.data['ls_downtimed'],
            monitored
        )

        self.setIcon(0, QIcon(settings.get_image(icon_name)))

    def update_item(self):
        """
        Update QIcon of service

        """

        service = data_manager.get_item('service', '_id', self.service_id)

        monitored = self.service_item.data[
            'passive_checks_enabled'] + self.service_item.data['active_checks_enabled']

# Path: alignak_app/backend/datamanager.py
# class DataManager(object):
#     def __init__(self):
#     def is_ready(self):
#     def update_database(self, item_type, items_list):
#     def get_item(self, item_type, key, value=None):
#     def remove_item(self, item_type, key, value=None):
#     def update_item_data(self, item_type, item_id, data):
#     def get_realm_name(self, realm):
#     def get_period_name(self, period):
#     def get_synthesis_count(self):
#     def get_all_hostnames(self):
#     def get_host_services(self, host_id):
#     def get_host_with_services(self, host_field):
#     def get_events(self):
#     def get_items_and_problems(self):
#     def update_problems(self):
#     def get_problems(self):
#     def is_problem(item_type, item_data):
# 
# Path: alignak_app/items/item.py
# def get_icon_name(item_type, state, acknowledge, downtime, monitored):
#     """
#     Return icon for a host or a service item
# 
#     :param item_type: type of item: host | service
#     :type item_type: str
#     :param state: state of item
#     :type state: str
#     :param acknowledge: if item is acknowledged or not
#     :type acknowledge: bool
#     :param downtime: if item is downtimed
#     :type downtime: bool
#     :param monitored: define if host is monitored or not (0 is not monitored, 1 or 2 is monitored)
#     :type monitored: int
#     :return: icon name for icon
#     :rtype: str
#     """
# 
#     if downtime:
#         return 'downtime'
#     if acknowledge:
#         return 'acknowledge'
#     if monitored == 0:
#         if 'host' in item_type:
#             return 'hosts_not_monitored'
# 
#         return 'services_not_monitored'
# 
#     available_icons = {
#         'host': {
#             'UP': 'hosts_up',
#             'UNREACHABLE': 'hosts_unreachable',
#             'DOWN': 'hosts_down',
#         },
#         'service': {
#             'OK': 'services_ok',
#             'WARNING': 'services_warning',
#             'CRITICAL': 'services_critical',
#             'UNKNOWN': 'services_unknown',
#             'UNREACHABLE': 'services_unreachable'
#         }
#     }
#     try:
#         return available_icons[item_type][state]
#     except KeyError as e:
#         logger.error('Wrong KEY for get_icon_name(): %s', e)
#         return 'error'
# 
# Path: alignak_app/utils/config.py
# class Settings(object):
#     def __init__(self):
#     def init_config(self):
#     def get_config(self, section, option, boolean=False):
#     def set_config(self, section, option, new_value):
#     def get_image(self, name):
#     def init_css(self):
# def open_url(endpoint='login'):  # pragma: no cover
# def get_url_endpoint_from_icon_name(icon_name):


# Path: alignak_app/qobjects/service/tree_item.py
from logging import getLogger
from PyQt5.Qt import QIcon, QTreeWidgetItem
from alignak_app.backend.datamanager import data_manager
from alignak_app.items.item import get_icon_name
from alignak_app.utils.config import settings

        :param service_item: service item with its data
        :type service_item: alignak_app.core.models.service.Service
        """

        self.service_item = service_item
        self.service_id = service_item.item_id
        self.setText(0, self.service_item.get_display_name())

        monitored = service_item.data[
            'passive_checks_enabled'] + service_item.data['active_checks_enabled']
        icon_name = get_icon_name(
            'service',
            service_item.data['ls_state'],
            service_item.data['ls_acknowledged'],
            service_item.data['ls_downtimed'],
            monitored
        )

        self.setIcon(0, QIcon(settings.get_image(icon_name)))

    def update_item(self):
        """
        Update QIcon of service

        """

        service = data_manager.get_item('service', '_id', self.service_id)

        monitored = self.service_item.data[
            'passive_checks_enabled'] + self.service_item.data['active_checks_enabled']

        icon_name = get_icon_name(