appimage refactoring | limiting name, desc and publisher in the apps table

This commit is contained in:
Vinicius Moreira
2019-10-09 19:00:07 -03:00
parent 69dd9b9396
commit 589264b096
3 changed files with 34 additions and 8 deletions

View File

@@ -112,7 +112,7 @@ class AppImageManager(SoftwareManager):
if con:
try:
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 app in res.installed:

View File

@@ -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 '%{}%'"
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"

View File

@@ -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'
NAME_MAX_SIZE = 30
DESC_MAX_SIZE = 40
PUBLISHER_MAX_SIZE = 25
class UpdateToggleButton(QWidget):
@@ -308,9 +312,22 @@ class AppsTable(QTableWidget):
def _set_col_name(self, col: int, pkg: PackageView):
item = QTableWidgetItem()
item.setText(pkg.model.name if pkg.model.name else '...')
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()):
with open(pkg.model.get_disk_icon_path(), 'rb') as f:
@@ -338,8 +355,14 @@ class AppsTable(QTableWidget):
else:
desc = '...'
if desc and desc != '...' and len(desc) > 40:
desc = strip_html(desc[0:40]) + '...'
if desc and desc != '...' and len(desc) > DESC_MAX_SIZE:
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)
@@ -358,8 +381,11 @@ class AppsTable(QTableWidget):
publisher = publisher.strip()
full_publisher = publisher
if len(publisher) > 20:
publisher = full_publisher[0:20] + '...'
if len(publisher) > PUBLISHER_MAX_SIZE:
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 pkg.model.installed: