All the business logic now lives in AppCore (providers, workers, history, plugins, sudo and pacman-lock handling), freed from any widget so it runs headless and is testable on its own. The Qt window becomes a thin frame around one file per screen under pages/, wired through a common Page contract and a shared ui-kit. CMake gains the app-core-test target, which links Qt Core only to enforce the headless guarantee. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
86 lines
2.9 KiB
C++
86 lines
2.9 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;
|
|
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;
|
|
};
|