diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-06-23 14:38:30 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-06-23 14:38:30 +0300 |
commit | 85bbab0e9284e35b0fec26405537c9160496974f (patch) | |
tree | fcbceeb50d29cde8f5378246aceebea33b60bcc1 /launcher/minecraft/mod/ResourceFolderModel.h | |
parent | 67db141203864123f65d93723e7eed43328b8d97 (diff) | |
parent | 8df5ab8aa7ec32ee3c44e2b57dc9c9f04e093d9d (diff) | |
download | PrismLauncher-85bbab0e9284e35b0fec26405537c9160496974f.tar.gz PrismLauncher-85bbab0e9284e35b0fec26405537c9160496974f.tar.bz2 PrismLauncher-85bbab0e9284e35b0fec26405537c9160496974f.zip |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into net_job_crash
Diffstat (limited to 'launcher/minecraft/mod/ResourceFolderModel.h')
-rw-r--r-- | launcher/minecraft/mod/ResourceFolderModel.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index 0a35e1bc..eb1d7c4f 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -1,5 +1,8 @@ #pragma once +#include <QHeaderView> +#include <QAction> +#include <QTreeView> #include <QAbstractListModel> #include <QDir> #include <QFileSystemWatcher> @@ -29,6 +32,8 @@ class ResourceFolderModel : public QAbstractListModel { ResourceFolderModel(QDir, BaseInstance* instance, QObject* parent = nullptr, bool create_dir = true); ~ResourceFolderModel() override; + virtual QString id() const { return "resource"; } + /** Starts watching the paths for changes. * * Returns whether starting to watch all the paths was successful. @@ -92,6 +97,7 @@ class ResourceFolderModel : public QAbstractListModel { /* Basic columns */ enum Columns { ACTIVE_COLUMN = 0, NAME_COLUMN, DATE_COLUMN, NUM_COLUMNS }; + QStringList columnNames(bool translated = true) const { return translated ? m_column_names_translated : m_column_names; }; [[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : static_cast<int>(size()); } [[nodiscard]] int columnCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : NUM_COLUMNS; }; @@ -110,6 +116,11 @@ class ResourceFolderModel : public QAbstractListModel { [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + void setupHeaderAction(QAction* act, int column); + void saveHiddenColumn(int column, bool hidden); + void loadHiddenColumns(QTreeView* tree); + QMenu* createHeaderContextMenu(QTreeView* tree); + /** This creates a proxy model to filter / sort the model for a UI. * * The actual comparisons and filtering are done directly by the Resource, so to modify behavior go there instead! @@ -117,6 +128,7 @@ class ResourceFolderModel : public QAbstractListModel { QSortFilterProxyModel* createFilterProxyModel(QObject* parent = nullptr); [[nodiscard]] SortType columnToSortKey(size_t column) const; + [[nodiscard]] QList<QHeaderView::ResizeMode> columnResizeModes() const { return m_column_resize_modes; } class ProxyModel : public QSortFilterProxyModel { public: @@ -187,6 +199,9 @@ class ResourceFolderModel : public QAbstractListModel { // Represents the relationship between a column's index (represented by the list index), and it's sorting key. // As such, the order in with they appear is very important! QList<SortType> m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::DATE }; + QStringList m_column_names = {"Enable", "Name", "Last Modified"}; + QStringList m_column_names_translated = {tr("Enable"), tr("Name"), tr("Last Modified")}; + QList<QHeaderView::ResizeMode> m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Stretch, QHeaderView::ResizeToContents }; bool m_can_interact = true; |