Esempio n. 1
0
    def __update_week_time_counter(self):
        """Update the week time counters."""
        self.week_time_lcd.display(
            minutes_to_time_str(self.week_wrapper.minutes_of_week))
        self.remaining_week_time_lcd.display(
            minutes_to_time_str(
                max(
                    0, self.week_wrapper.minutes_to_work -
                    self.week_wrapper.minutes_of_week)))

        self.__update_week_counter_color()
Esempio n. 2
0
    def data(self, index, role=None):
        """Return the data.

        Return the data stored under the given role for the item referred
        to by the index.
        """
        if not index.isValid():
            return QVariant()

        row = index.row()
        column = index.column()
        if role in (Qt.DisplayRole, Qt.ToolTipRole):
            try:
                value = self._tasks[row][ResultColumn(column)]
            except KeyError:
                return QVariant()
            else:
                if column == ResultColumn.Task.value:
                    if role == Qt.ToolTipRole:
                        # html text allows automatic word-wrapping on tooltip.
                        return '<html>{}</html>'.format(str(value))
                    else:
                        return str(value)
                elif column == ResultColumn.Time.value:
                    return minutes_to_time_str(value)
                elif column == ResultColumn.Man_Day.value:
                    return value
        elif role == Qt.TextAlignmentRole:
            if column == ResultColumn.Task.value:
                return Qt.AlignLeft | Qt.AlignVCenter
            else:
                return Qt.AlignCenter | Qt.AlignVCenter

        return QVariant()
Esempio n. 3
0
    def __update_catch_up_time_counter(self):
        """Update the catch-up time counter."""
        to_work = self.week_wrapper.total_time_to_work
        worked = self.week_wrapper.total_time_worked

        catch_up_time = worked - to_work
        abs_time = abs(catch_up_time)
        time_str = minutes_to_time_str(abs_time)

        if catch_up_time >= 0:
            self.__change_catch_up_color(SettingModel.valid_color())
            self.catch_up_lcd.setToolTip('+' + time_str)
        else:
            self.__change_catch_up_color(SettingModel.invalid_color())
            self.catch_up_lcd.setToolTip('-' + time_str)

        if abs_time >= 6000:
            self.catch_up_lcd.display(abs_time // 60)
        else:
            self.catch_up_lcd.display(time_str)
Esempio n. 4
0
 def __update_day_time_counter(self):
     """Update the day time counter."""
     self.day_time_lcd.display(
         minutes_to_time_str(self.task_model.minutes_of_day))
Esempio n. 5
0
 def test_time_result_without_zero_padded_values(self):
     """Test time result without zero padded values."""
     self.assertEqual(minutes_to_time_str(645), '10:45')
Esempio n. 6
0
 def test_60_minutes_returns_exactly_one_hour(self):
     """Test that 60 minutes returns exactly one hour."""
     self.assertEqual(minutes_to_time_str(60), '01:00')
Esempio n. 7
0
 def test_more_than_60_minutes_returns_more_than_one_hour(self):
     """Test that more than 60 minutes returns more than one hour."""
     self.assertEqual(minutes_to_time_str(65), '01:05')
Esempio n. 8
0
 def test_zero_minutes_returns_00_00(self):
     """Test that zero minutes returns 00:00."""
     self.assertEqual(minutes_to_time_str(0), '00:00')
Esempio n. 9
0
 def test_less_than_60_minutes_returns_less_than_one_hour(self):
     """Test that less than 60 minutes returns less than one hour."""
     self.assertEqual(minutes_to_time_str(50), '00:50')
Esempio n. 10
0
 def test_non_number_string_returns_none(self):
     """Test that non number string returns None."""
     self.assertIsNone(minutes_to_time_str('a string'))
Esempio n. 11
0
 def test_int_int_string_returns_correct_value(self):
     """Test that int in string returns correct value."""
     self.assertEqual(minutes_to_time_str('50'), '00:50')
Esempio n. 12
0
 def test_float_returns_correct_value(self):
     """Test that float returns correct value."""
     self.assertEqual(minutes_to_time_str(50.3), '00:50')
Esempio n. 13
0
 def test_none_returns_none(self):
     """Test that None returns None."""
     self.assertIsNone(minutes_to_time_str(None))
Esempio n. 14
0
 def test_negative_returns_none(self):
     """Test that negative returns None."""
     self.assertIsNone(minutes_to_time_str(-1))