mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[improvement][ui] search: always putting the installed on top if no name filter is provided
This commit is contained in:
@@ -291,6 +291,14 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
if man:
|
||||
return man.uninstall(app, root_password, handler)
|
||||
|
||||
def _fill_post_transaction_status(self, pkg: SoftwarePackage, installed: bool):
|
||||
pkg.installed = installed
|
||||
|
||||
pkg.update = False
|
||||
|
||||
if pkg.latest_version:
|
||||
pkg.version = pkg.latest_version
|
||||
|
||||
def install(self, app: SoftwarePackage, root_password: str, disk_loader: DiskCacheLoader, handler: ProcessWatcher) -> TransactionResult:
|
||||
man = self._get_manager_for(app)
|
||||
|
||||
@@ -300,13 +308,23 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
disk_loader.start()
|
||||
try:
|
||||
self.logger.info('Installing {}'.format(app))
|
||||
return man.install(app, root_password, disk_loader, handler)
|
||||
res = man.install(app, root_password, disk_loader, handler)
|
||||
disk_loader.stop_working()
|
||||
disk_loader.join()
|
||||
|
||||
if res.success:
|
||||
if res.installed:
|
||||
for p in res.installed:
|
||||
self._fill_post_transaction_status(p, True)
|
||||
if res.removed:
|
||||
for p in res.removed:
|
||||
self._fill_post_transaction_status(p, False)
|
||||
|
||||
return res
|
||||
except:
|
||||
traceback.print_exc()
|
||||
return TransactionResult(success=False, installed=[], removed=[])
|
||||
finally:
|
||||
disk_loader.stop_working()
|
||||
disk_loader.join()
|
||||
tf = time.time()
|
||||
self.logger.info('Installation of {}'.format(app) + 'took {0:.2f} minutes'.format((tf - ti)/60))
|
||||
|
||||
|
||||
@@ -898,10 +898,10 @@ class ApplyFilters(AsyncAction):
|
||||
commons.update_info(pkgv, pkgs_info)
|
||||
commons.apply_filters(pkgv, self.filters, pkgs_info, limit=not name_filtering)
|
||||
|
||||
if name_filtering and pkgs_info['pkgs_displayed']:
|
||||
pkgs_info['pkgs_displayed'] = self._sort_by_word(word=self.filters['name'],
|
||||
pkgs=pkgs_info['pkgs_displayed'],
|
||||
limit=self.filters['display_limit'])
|
||||
if pkgs_info['pkgs_displayed'] and name_filtering:
|
||||
pkgs_info['pkgs_displayed'] = self._sort_by_word(word=self.filters['name'],
|
||||
pkgs=pkgs_info['pkgs_displayed'],
|
||||
limit=self.filters['display_limit'])
|
||||
|
||||
self.wait_table_update = True
|
||||
self.signal_table.emit(pkgs_info)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import operator
|
||||
import time
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
@@ -1210,15 +1211,31 @@ class ManageWindow(QWidget):
|
||||
models_updated.extend(res[key])
|
||||
|
||||
if models_updated:
|
||||
view_to_update = []
|
||||
installed_available_idxs = []
|
||||
for idx, available in enumerate(self.pkgs_available):
|
||||
for pidx, p in enumerate(models_updated):
|
||||
if available.model == p:
|
||||
available.model = p
|
||||
if p.installed:
|
||||
installed_available_idxs.append((idx, pidx, available))
|
||||
|
||||
# re-indexing all installed so they always will be be displayed when no filters are applied
|
||||
if installed_available_idxs:
|
||||
# removing from available
|
||||
installed_available_idxs.sort(key=operator.itemgetter(0))
|
||||
for decrement, data in enumerate(installed_available_idxs):
|
||||
del self.pkgs_available[data[0] - decrement]
|
||||
|
||||
# re-inserting into the available
|
||||
installed_available_idxs.sort(key=operator.itemgetter(1))
|
||||
for new_idx, data in enumerate(installed_available_idxs):
|
||||
self.pkgs_available.insert(new_idx, data[2])
|
||||
|
||||
# updating the respective table rows:
|
||||
for displayed in self.pkgs:
|
||||
for p in models_updated:
|
||||
if displayed.model == p:
|
||||
displayed.model = p
|
||||
view_to_update.append(displayed)
|
||||
|
||||
for pkgv in view_to_update:
|
||||
self.table_apps.update_package(pkgv)
|
||||
self.table_apps.update_package(displayed)
|
||||
|
||||
self.ref_bt_installed.setVisible(False)
|
||||
self.ref_checkbox_only_apps.setVisible(False)
|
||||
|
||||
Reference in New Issue
Block a user