hide and show owned items
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import requests
|
||||
from gui.gui import Ui_MainWindow
|
||||
from modules.database import Database
|
||||
from modules.config import Config
|
||||
from PyQt5 import QtWidgets, QtGui
|
||||
from gui.modules.handlers import fill_info
|
||||
|
||||
@@ -22,8 +23,25 @@ def refill_list(ui: Ui_MainWindow):
|
||||
if not (ui.filter_class_box.currentText() == 'All' or item.item_class == ui.filter_class_box.currentText()):
|
||||
continue
|
||||
|
||||
if (not ui.filter_show_owned_items_check.isChecked()) and item.item_name in \
|
||||
Database.get().profiles[Config.get().profile].owned_items:
|
||||
continue
|
||||
|
||||
list_item = QtWidgets.QListWidgetItem()
|
||||
list_item.setText(f'{item.item_name} - ${"{:,}".format(item.price)}')
|
||||
if Config.get().profile:
|
||||
ui.own_button.setEnabled(True)
|
||||
|
||||
if item.item_name in Database.get().profiles[Config.get().profile].owned_items:
|
||||
ui.own_button.setText("Mark this item as unowned")
|
||||
else:
|
||||
ui.own_button.setText("Mark this item as owned")
|
||||
else:
|
||||
ui.own_button.setEnabled(False)
|
||||
ui.own_button.setText("Select profile first")
|
||||
|
||||
list_item.setText(f''
|
||||
f'{"☑" if Config.get().profile and item.item_name in Database.get().profiles[Config.get().profile].owned_items else ""}'
|
||||
f'{item.item_name} - ${"{:,}".format(item.price)}')
|
||||
pixmap = QtGui.QPixmap()
|
||||
try:
|
||||
pixmap.loadFromData(requests.get(item.image).content)
|
||||
|
||||
@@ -2,12 +2,14 @@ import requests
|
||||
from PyQt5 import QtWidgets, QtGui, QtCore
|
||||
from gui.gui import Ui_MainWindow
|
||||
from modules.database import Database
|
||||
from modules.config import Config
|
||||
|
||||
|
||||
def on_item_click(ui: Ui_MainWindow, mode: str):
|
||||
if ui.items_list.currentItem():
|
||||
item = Database.get().items[
|
||||
ui.items_list.currentItem().text().removesuffix(' - ' + ui.items_list.currentItem().text().split(' - ')[-1])
|
||||
.replace("☑", "")
|
||||
]
|
||||
|
||||
pixmap = QtGui.QPixmap()
|
||||
@@ -18,6 +20,17 @@ def on_item_click(ui: Ui_MainWindow, mode: str):
|
||||
ui.properties_image.clear()
|
||||
print(f"Failed to load {item.image}, {e}")
|
||||
|
||||
if Config.get().profile:
|
||||
ui.own_button.setEnabled(True)
|
||||
|
||||
if item.item_name in Database.get().profiles[Config.get().profile].owned_items:
|
||||
ui.own_button.setText("Mark this item as unowned")
|
||||
else:
|
||||
ui.own_button.setText("Mark this item as owned")
|
||||
else:
|
||||
ui.own_button.setEnabled(False)
|
||||
ui.own_button.setText("Select profile first")
|
||||
|
||||
ui.properties_name.setText(item.item_name)
|
||||
ui.properties_price.setText(f'${"{:,}".format(item.price)}')
|
||||
ui.properties_class_type.setText(f'{item.item_class} - {item.item_type}')
|
||||
|
||||
@@ -9,6 +9,7 @@ def on_rm_click(ui: Ui_MainWindow):
|
||||
if ui.items_list.currentItem():
|
||||
Database.remove_item(
|
||||
ui.items_list.currentItem().text().removesuffix(' - ' + ui.items_list.currentItem().text().split(' - ')[-1])
|
||||
.replace("☑", "")
|
||||
)
|
||||
items_list.refill_list(ui)
|
||||
refill_filters(ui)
|
||||
|
||||
Reference in New Issue
Block a user