Skip to content

Commit

Permalink
Fix updating of number of problems when filter items
Browse files Browse the repository at this point in the history
Ref #309
  • Loading branch information
algorys committed Apr 12, 2018
1 parent f8b0d33 commit c457677
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions alignak_app/qobjects/alignak/problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def initialize(self, spy_widget):

self.update_problems_data()

def get_curent_user_role_item(self):
def get_current_user_role_item(self):
"""
Return current selected item by ``Qt.UserRole``
Expand All @@ -106,7 +106,7 @@ def update_action_buttons(self):
"""

# Get item by UserRole
item = self.get_curent_user_role_item()
item = self.get_current_user_role_item()

if item:
# If the elements had been ack or downtimed, they would not be present
Expand Down Expand Up @@ -226,7 +226,7 @@ def add_spied_host(self):
"""

# Get item by UserRole
item = self.get_curent_user_role_item()
item = self.get_current_user_role_item()

if item:
if 'service' in item.item_type:
Expand Down Expand Up @@ -256,6 +256,13 @@ def update_problems_data(self, item_type=''):
self.parent().parent().indexOf(self),
_("Problems (%d)") % len(problems_data['problems'])
)
self.problems_title.setText(
_('There are %d problems to manage (hosts: %d, services: %d)') % (
len(problems_data['problems']),
problems_data['hosts_nb'],
problems_data['services_nb']
)
)

if self.filter_hosts_btn.is_checked() and not self.filter_services_btn.is_checked():
item_type = 'host'
Expand All @@ -277,13 +284,6 @@ def update_problems_data(self, item_type=''):

proxy_filter = self.problems_table.update_view(problems_data)
if problems_data['problems']:
self.problems_title.setText(
_('There are %d problems to manage (hosts: %d, services: %d)') % (
len(problems_data['problems']),
problems_data['hosts_nb'],
problems_data['services_nb']
)
)
self.line_search.textChanged.connect(proxy_filter.setFilterRegExp)
else:
self.problems_title.setText(_('If problems are found, they will be displayed here.'))
Expand Down
2 changes: 1 addition & 1 deletion alignak_app/qobjects/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def set_host_from_problems(self):
"""

item = self.problems_widget.get_curent_user_role_item()
item = self.problems_widget.get_current_user_role_item()
if item:
if 'service' in item.item_type:
hostname = data_manager.get_item('host', item.data['host']).name
Expand Down
4 changes: 2 additions & 2 deletions test/test_panel_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def test_set_host_from_problems(self):
under_test.initialize()

self.assertEqual('', under_test.synthesis_widget.line_search.text())
self.assertIsNone(under_test.problems_widget.get_curent_user_role_item())
self.assertIsNone(under_test.problems_widget.get_current_user_role_item())

# Make an item as current in problems table
under_test.problems_widget.problems_table.update_view({'problems': [self.host_list[8]]})
Expand All @@ -217,7 +217,7 @@ def test_set_host_from_problems(self):
QItemSelectionModel.SelectCurrent
)

self.assertIsNotNone(under_test.problems_widget.get_curent_user_role_item())
self.assertIsNotNone(under_test.problems_widget.get_current_user_role_item())
self.assertEqual('', under_test.synthesis_widget.line_search.text())

under_test.set_host_from_problems()
Expand Down

0 comments on commit c457677

Please sign in to comment.