Пример #1
0
 def append(self, element: str) -> None:
     if not element.lower() in self:
         super().append(element.lower())
         if not self._custom_sort:
             self.sort()
         SAVE_NEEDED.set()
         LIST_SIGNALS.category_list_changed.emit()
Пример #2
0
 def add_new_article(self, name: str, category: str) -> ShoppingArticle:
     article = ShoppingArticle(name, category)
     self.append_silent(article)
     self.shopping_articles_list.append(article)
     article.selection += 1
     self.sort_by_shop()
     SAVE_NEEDED.set()
     LIST_SIGNALS.list_changed.emit()
     return article
Пример #3
0
 def move_bottom(self, element: str):
     index = self.index(element)
     if index == len(self) - 1:
         raise AttributeError(
             f'Attribute {element} is already at the bottom of the list')
     self.append(self.pop(index))
     self._custom_sort = True
     SAVE_NEEDED.set()
     LIST_SIGNALS.category_list_changed.emit()
Пример #4
0
 def move_top(self, element: str):
     index = self.index(element)
     if index == 0:
         raise AttributeError(
             f'Attribute {element} is already at the top of the list')
     self.insert(0, self.pop(index))
     self._custom_sort = True
     SAVE_NEEDED.set()
     LIST_SIGNALS.category_list_changed.emit()
 def add_button_pressed(self):
     selected_to_add = self.combobox_layout.category_combobox.currentText()
     selected_on_list = self.category_list_layout.category_list_widget.currentIndex(
     ).row()
     if selected_to_add in self._shops_list.selected_shop.category_list:
         raise RuntimeError(f'Category {selected_to_add} already in shop')
     if selected_on_list:
         self._shops_list.selected_shop.category_list.insert(
             selected_on_list + 1, selected_to_add)
         SAVE_NEEDED.set()
         LIST_SIGNALS.category_list_changed.emit()
Пример #6
0
 def remove_article(self, name: str):
     self.remove_silent(self.get_article_by_name(name))
     self.sort_by_shop()
     SAVE_NEEDED.set()
     LIST_SIGNALS.list_changed.emit()
Пример #7
0
 def add_existing_article(self, element: ShoppingArticle):
     self.append_silent(element)
     element.selection += 1
     self.sort_by_shop()
     SAVE_NEEDED.set()
     LIST_SIGNALS.list_changed.emit()
Пример #8
0
 def clear(self):
     self.clear_silent()
     SAVE_NEEDED.set()
     LIST_SIGNALS.list_changed.emit()
Пример #9
0
 def remove(self, item) -> None:
     self.remove_silent(item)
     SAVE_NEEDED.set()
     LIST_SIGNALS.list_changed.emit()
Пример #10
0
 def __setitem__(self, key, value):
     super(ShoppingListWithoutDuplicates, self).__setitem__(key, value)
     SAVE_NEEDED.set()
     LIST_SIGNALS.list_changed.emit()
Пример #11
0
 def append(self, element: Union['ShoppingArticle', 'Shop']) -> None:
     self.append_silent(element)
     SAVE_NEEDED.set()
     LIST_SIGNALS.list_changed.emit()
Пример #12
0
 def remove(self, item) -> None:
     super(StringListWithoutDuplicates, self).remove(item)
     SAVE_NEEDED.set()
     LIST_SIGNALS.category_list_changed.emit()
Пример #13
0
 def __setattr__(self, key, value):
     super(ShoppingArticle, self).__setattr__(key, value)
     SAVE_NEEDED.set()
Пример #14
0
 def selected_shop(self, value):
     if value not in self:
         raise AttributeError(f'Shop {value} does not exist')
     self._selected_shop = value
     SAVE_NEEDED.set()
     LIST_SIGNALS.shop_changed.emit()