pacman restarts its "(1/24)" counter at every phase of a transaction, so the bar was fed 0 percent, 100 percent, 0 percent again a few times per update — and Flatpak/AUR buffered their whole output, which left it indeterminate for the entire run. A shared ProgressTracker now folds every counter, file percentage and package step into one value that only moves forward, the providers stream their output as it is produced, and each provider owns a slice of the bar so a multi-provider update keeps advancing. pacman -Qu is cached like the other read queries, so the sidebar badge, the updates screen and the update button share a single process. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
89 lines
3.1 KiB
C++
89 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include <QString>
|
|
|
|
#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);
|
|
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;
|
|
QLabel* m_pkgDescription = nullptr;
|
|
};
|