Files
FWS-PacManage/pages/browse-page.h
T
BlackAngelTV eb39905bf5 feat(flatpak): let the user choose which installation to act on
The same application can be present twice — in the user installation
and system-wide, or from two remotes or two branches — and flatpak then
refuses to act on the application id alone: "Multiple installed refs
match 'com.hoptodesk.HopToDesk'". Removing either copy was impossible
from the app.

A row now stands for the application and carries the copies it is made
of, so the details panel lists them and Remove opens one checkbox per
copy; the provider gets back the exact target it listed, and naming a
ref plus its installation is what makes the call unambiguous. Update
gains the same resolution, since it hit the very same refusal, and
removing one copy of two no longer takes the other one's launcher entry
away with it.

The listing that feeds it now asks flatpak for the ref, the branch and
the installation, and reads those columns by position: a branch
installed from a subdirectory has no version, and dropping that empty
column shifted every field after it.
2026-09-27 21:33:41 +02:00

98 lines
3.5 KiB
C++

#pragma once
#include <optional>
#include <QString>
#include <vector>
#include "page.h"
class QLabel;
class QLineEdit;
class QProgressBar;
class QPushButton;
class QStackedWidget;
class QTableWidget;
// The browsing screen. Search, installed and updates share this page because
// they are the same table with a different query behind it; the sidebar exposes
// three entries, all landing here with a different mode.
class BrowsePage : public Page {
Q_OBJECT
public:
enum class Mode { Search, Installed, Updates };
explicit BrowsePage(AppCore* core, QWidget* parent = nullptr);
QString navTitle() const override;
QString navSubtitle() const override;
void refresh() override;
// Entry points used by the sidebar, the dashboard shortcuts and the menu.
void showSearch();
void showInstalled(const QString& select = QString());
void showUpdates();
// Package to select once the next listing arrives: lets the frame open a
// package from the dashboard without loading the list twice.
void selectOnNextLoad(const QString& name) { m_pendingSelect = name; }
// Puts the caret in the search field (Ctrl+F), selecting the current term.
void focusSearch();
int resultCount() const { return static_cast<int>(m_results.size()); }
// Exports the displayed list to a CSV file (the file dialog is the frame's
// business, the content is this page's).
void exportCsv();
private:
void setMode(Mode mode);
void reloadCurrentView();
void onSearch();
void onPackageSelected(int row);
void onFilterChanged(const QString& text);
void populateTable(const std::vector<PackageInfo>& packages);
void appendRows(const std::vector<PackageInfo>& packages);
void addRow(int row, const PackageInfo& pkg);
// Which installations of the selected package to remove, when the provider
// holds it more than once. Empty when there is only one to remove, nothing
// (std::nullopt) when the user cancels the chooser.
std::optional<std::vector<std::string>> chooseInstancesToRemove();
void updateDetails(const PackageInfo& pkg);
void resetDetails();
Mode m_mode = Mode::Search;
// Everything the current query returned, and the last installed listing
// kept aside for the instant local filter.
std::vector<PackageInfo> m_results;
std::vector<PackageInfo> m_installed;
PackageInfo m_selected;
// Package to select once the next listing arrives (after a click on the
// dashboard history, or after an operation).
QString m_pendingSelect;
QWidget* m_searchRow = nullptr;
QLineEdit* m_searchBar = nullptr;
QPushButton* m_searchButton = nullptr;
QWidget* m_filterRow = nullptr;
QLineEdit* m_filterBar = nullptr;
QLabel* m_resultCount = nullptr;
QPushButton* m_installButton = nullptr;
QPushButton* m_removeButton = nullptr;
QPushButton* m_updateButton = nullptr;
QPushButton* m_updateAllButton = nullptr;
QProgressBar* m_progressBar = nullptr;
// Highest percentage reported by the running operation, so the bar never
// moves backwards when a provider restarts its own count.
int m_progressValue = 0;
QTableWidget* m_table = nullptr;
QStackedWidget* m_tableStack = nullptr;
QLabel* m_pkgName = nullptr;
QLabel* m_pkgVersion = nullptr;
QLabel* m_pkgRepo = nullptr;
QLabel* m_pkgSize = nullptr;
QLabel* m_pkgProvider = nullptr;
// The copies a multi-installed package is made of, shown only when there is
// more than one.
QLabel* m_pkgInstances = nullptr;
QLabel* m_pkgDescription = nullptr;
};