Commit 8ffc6a24 authored by librebob's avatar librebob

Refactor messages into lists.py, fix searching.

parent a1b110cf
Pipeline #53312866 failed with stage
in 1 minute and 48 seconds
......@@ -206,9 +206,14 @@ class Library(QObject):
if query:
tmp = []
query = query.lower()
for game in self._filter:
if query in game.name.lower():
tmp.append(game)
if self.filterValue == 'all':
for game in self._games:
if query in game.name.lower():
tmp.append(game)
else:
for game in self._filters[self.filterValue]:
if query in game.name.lower():
tmp.append(game)
self.filter = tmp
else:
self.filterGames(self.filterValue)
......
......@@ -18,3 +18,14 @@ engineClones = [
'OpenMW',
'ScummVM'
]
loadingMessages = [
'Mining Mese blocks...',
'Peeling bananas...',
'Constructing castles...',
'Collecting cow bells...',
'Summoning demons...',
'Building power plants...',
'Planting mines...',
'Evolving...'
]
......@@ -7,7 +7,7 @@ from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, QProcess, QTimer, QS
import appstream
from models import getMeta, setMeta, getGame, setGame
from game import Game, Screenshot, Release, Url
from lists import badLicenses, badCategories
from lists import badLicenses, badCategories, loadingMessages
class Loader(QObject):
......@@ -25,16 +25,6 @@ class Loader(QObject):
flatHub = {'name':'flathub', 'url':'https://flathub.org/repo/flathub.flatpakrepo', 'git':'https://github.com/flathub'}
messages = [
'Mining Mese blocks...',
'Peeling bananas...',
'Constructing castles...',
'Collecting cow bells...',
'Summoning demons...',
'Building power plants...',
'Planting mines...',
'Evolving...'
]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
......@@ -43,7 +33,7 @@ class Loader(QObject):
self._processes = []
self._timer = QTimer()
self._timer.timeout.connect(self.changeMessage)
self._message = random.choice(self.messages)
self._message = random.choice(loadingMessages)
self._appsteamPath = QStandardPaths.writableLocation(QStandardPaths.GenericDataLocation) + '/flatpak/appstream/{remote}/{arch}/active/appstream.xml.gz'
self._iconsPath = QStandardPaths.writableLocation(QStandardPaths.GenericDataLocation) + '/flatpak/appstream/{remote}/{arch}/active/icons'
self._log = ''
......@@ -246,7 +236,7 @@ class Loader(QObject):
self.stateChanged.emit()
def changeMessage(self):
self.message = random.choice(self.messages)
self.message = random.choice(loadingMessages)
def startLoading(self):
self.loading = True
......
......@@ -8,6 +8,9 @@ class TestGame(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_appendGame(self):
l = library.Library()
......@@ -27,6 +30,25 @@ class TestGame(unittest.TestCase):
l.sortGames()
self.assertEqual('antelope', l.games[0].name)
def test_search(self):
l = library.Library()
l.appendGame(game.Game(name='basketball'))
l.appendGame(game.Game(name='Bear'))
l.appendGame(game.Game(name='Cheetah'))
l.appendGame(game.Game(name='chair'))
l.appendGame(game.Game(name='antelope'))
l.appendGame(game.Game(name='Asparagus'))
l.updateFilters()
l.searchGames('basket')
self.assertEqual('basketball', l.filter[0].name)
l.searchGames('chair')
self.assertEqual('chair', l.filter[0].name)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment