mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-10 22:34:14 +02:00
appimage refactoring | limiting name, desc and publisher in the apps table
This commit is contained in:
@@ -112,7 +112,7 @@ class AppImageManager(SoftwareManager):
|
|||||||
if con:
|
if con:
|
||||||
try:
|
try:
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
cursor.execute(query.FIND_APPS_LATEST_VERSIONS.format(','.join(names)))
|
cursor.execute(query.FIND_APPS_BY_NAME.format(','.join(names)))
|
||||||
|
|
||||||
for tup in cursor.fetchall():
|
for tup in cursor.fetchall():
|
||||||
for app in res.installed:
|
for app in res.installed:
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ RELEASE_ATTRS = ('version', 'url_download', 'published_at')
|
|||||||
|
|
||||||
SEARCH_APPS_BY_NAME_OR_DESCRIPTION = "SELECT {} FROM apps".format(','.join(APP_ATTRS)) + " WHERE lower(name) LIKE '%{}%' or lower(description) LIKE '%{}%'"
|
SEARCH_APPS_BY_NAME_OR_DESCRIPTION = "SELECT {} FROM apps".format(','.join(APP_ATTRS)) + " WHERE lower(name) LIKE '%{}%' or lower(description) LIKE '%{}%'"
|
||||||
FIND_APP_ID_BY_NAME_AND_GITHUB = "SELECT id FROM apps WHERE lower(name) = '{}' and lower(github) = '{}'"
|
FIND_APP_ID_BY_NAME_AND_GITHUB = "SELECT id FROM apps WHERE lower(name) = '{}' and lower(github) = '{}'"
|
||||||
FIND_APPS_LATEST_VERSIONS = "SELECT name, github, version, url_download FROM apps WHERE lower(name) IN ({})"
|
FIND_APPS_BY_NAME = "SELECT name, github, version, url_download FROM apps WHERE lower(name) IN ({})"
|
||||||
FIND_RELEASES_BY_APP_ID = "SELECT {} FROM releases".format(','.join(RELEASE_ATTRS)) + " WHERE app_id = {} ORDER BY version desc"
|
FIND_RELEASES_BY_APP_ID = "SELECT {} FROM releases".format(','.join(RELEASE_ATTRS)) + " WHERE app_id = {} ORDER BY version desc"
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ from bauh.view.qt.view_model import PackageView, PackageViewStatus
|
|||||||
|
|
||||||
INSTALL_BT_STYLE = 'background: {back}; color: white; font-size: 10px; font-weight: bold'
|
INSTALL_BT_STYLE = 'background: {back}; color: white; font-size: 10px; font-weight: bold'
|
||||||
|
|
||||||
|
NAME_MAX_SIZE = 30
|
||||||
|
DESC_MAX_SIZE = 40
|
||||||
|
PUBLISHER_MAX_SIZE = 25
|
||||||
|
|
||||||
|
|
||||||
class UpdateToggleButton(QWidget):
|
class UpdateToggleButton(QWidget):
|
||||||
|
|
||||||
@@ -308,9 +312,22 @@ class AppsTable(QTableWidget):
|
|||||||
|
|
||||||
def _set_col_name(self, col: int, pkg: PackageView):
|
def _set_col_name(self, col: int, pkg: PackageView):
|
||||||
item = QTableWidgetItem()
|
item = QTableWidgetItem()
|
||||||
item.setText(pkg.model.name if pkg.model.name else '...')
|
|
||||||
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
||||||
item.setToolTip(self.i18n['app.name'].lower())
|
|
||||||
|
if pkg.model.name:
|
||||||
|
name = pkg.model.name
|
||||||
|
item.setToolTip('{}: {}'.format(self.i18n['app.name'].lower(), name))
|
||||||
|
else:
|
||||||
|
name = '...'
|
||||||
|
item.setToolTip(self.i18n['app.name'].lower())
|
||||||
|
|
||||||
|
if len(name) > NAME_MAX_SIZE:
|
||||||
|
name = name[0:NAME_MAX_SIZE - 3] + '...'
|
||||||
|
|
||||||
|
if len(name) < NAME_MAX_SIZE:
|
||||||
|
name = name + ' ' * (NAME_MAX_SIZE-len(name))
|
||||||
|
|
||||||
|
item.setText(name)
|
||||||
|
|
||||||
if self.disk_cache and pkg.model.supports_disk_cache() and pkg.model.get_disk_icon_path() and os.path.exists(pkg.model.get_disk_icon_path()):
|
if self.disk_cache and pkg.model.supports_disk_cache() and pkg.model.get_disk_icon_path() and os.path.exists(pkg.model.get_disk_icon_path()):
|
||||||
with open(pkg.model.get_disk_icon_path(), 'rb') as f:
|
with open(pkg.model.get_disk_icon_path(), 'rb') as f:
|
||||||
@@ -338,8 +355,14 @@ class AppsTable(QTableWidget):
|
|||||||
else:
|
else:
|
||||||
desc = '...'
|
desc = '...'
|
||||||
|
|
||||||
if desc and desc != '...' and len(desc) > 40:
|
if desc and desc != '...' and len(desc) > DESC_MAX_SIZE:
|
||||||
desc = strip_html(desc[0:40]) + '...'
|
desc = strip_html(desc[0: DESC_MAX_SIZE - 1]) + '...'
|
||||||
|
|
||||||
|
if not desc:
|
||||||
|
desc = ' ' * DESC_MAX_SIZE
|
||||||
|
|
||||||
|
if len(desc) < DESC_MAX_SIZE:
|
||||||
|
desc = desc + ' ' * (DESC_MAX_SIZE - len(desc))
|
||||||
|
|
||||||
item.setText(desc)
|
item.setText(desc)
|
||||||
|
|
||||||
@@ -358,8 +381,11 @@ class AppsTable(QTableWidget):
|
|||||||
publisher = publisher.strip()
|
publisher = publisher.strip()
|
||||||
full_publisher = publisher
|
full_publisher = publisher
|
||||||
|
|
||||||
if len(publisher) > 20:
|
if len(publisher) > PUBLISHER_MAX_SIZE:
|
||||||
publisher = full_publisher[0:20] + '...'
|
publisher = full_publisher[0: PUBLISHER_MAX_SIZE - 3] + '...'
|
||||||
|
|
||||||
|
if len(publisher) < PUBLISHER_MAX_SIZE:
|
||||||
|
publisher = publisher + ' ' * (PUBLISHER_MAX_SIZE - len(publisher))
|
||||||
|
|
||||||
if not publisher:
|
if not publisher:
|
||||||
if not pkg.model.installed:
|
if not pkg.model.installed:
|
||||||
|
|||||||
Reference in New Issue
Block a user