mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-07-01 12:26:26 +00:00
init
This commit is contained in:
33
ui/extends/components/chartSelector.py
Normal file
33
ui/extends/components/chartSelector.py
Normal file
@ -0,0 +1,33 @@
|
||||
from arcaea_offline.database import Database
|
||||
from arcaea_offline.models import Chart
|
||||
from arcaea_offline.utils import rating_class_to_short_text
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QStandardItem, QStandardItemModel
|
||||
|
||||
|
||||
class FuzzySearchCompleterModel(QStandardItemModel):
|
||||
def fillDbFuzzySearchResults(self, db: Database, kw: str):
|
||||
self.clear()
|
||||
|
||||
results = db.fuzzy_search_song_id(kw, limit=10)
|
||||
results = sorted(results, key=lambda r: r.confidence, reverse=True)
|
||||
songIds = [r.song_id for r in results]
|
||||
charts: list[Chart] = []
|
||||
for songId in songIds:
|
||||
dbChartRows = db.get_charts_by_song_id(songId)
|
||||
_charts = [Chart.from_db_row(dbRow) for dbRow in dbChartRows]
|
||||
_charts = sorted(_charts, key=lambda c: c.rating_class, reverse=True)
|
||||
charts += _charts
|
||||
|
||||
for chart in charts:
|
||||
displayText = (
|
||||
f"{chart.name_en} [{rating_class_to_short_text(chart.rating_class)}]"
|
||||
)
|
||||
item = QStandardItem(kw)
|
||||
item.setData(kw)
|
||||
item.setData(displayText, Qt.ItemDataRole.UserRole + 75)
|
||||
item.setData(
|
||||
f"{chart.song_id}, {chart.package_id}", Qt.ItemDataRole.UserRole + 76
|
||||
)
|
||||
item.setData(chart, Qt.ItemDataRole.UserRole + 10)
|
||||
self.appendRow(item)
|
5
ui/extends/components/dbTableViewer.py
Normal file
5
ui/extends/components/dbTableViewer.py
Normal file
@ -0,0 +1,5 @@
|
||||
from PySide6.QtCore import QAbstractTableModel
|
||||
|
||||
|
||||
class DbTableModel(QAbstractTableModel):
|
||||
pass
|
Reference in New Issue
Block a user