#pragma once #include #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(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& packages); void appendRows(const std::vector& 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 m_results; std::vector 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; };