Refactor map list buttons

This commit is contained in:
GriffinR
2024-10-18 14:22:34 -04:00
parent 40d34b2d5b
commit 7da2375998
16 changed files with 772 additions and 899 deletions

View File

@@ -173,11 +173,6 @@ private slots:
void on_action_Open_Project_triggered();
void on_action_Reload_Project_triggered();
void on_action_Close_Project_triggered();
void on_mapList_activated(const QModelIndex &index);
void on_areaList_activated(const QModelIndex &index);
void on_layoutList_activated(const QModelIndex &index);
void on_action_Save_Project_triggered();
void openWarpMap(QString map_name, int event_id, Event::Group event_group);
@@ -275,10 +270,6 @@ private slots:
void on_actionTileset_Editor_triggered();
void on_lineEdit_filterBox_textChanged(const QString &arg1);
void on_lineEdit_filterBox_Areas_textChanged(const QString &arg1);
void on_lineEdit_filterBox_Layouts_textChanged(const QString &arg1);
void moveEvent(QMoveEvent *event);
void closeEvent(QCloseEvent *);
@@ -292,19 +283,9 @@ private slots:
void on_slider_EmergeMapOpacity_valueChanged(int value);
void on_horizontalSlider_CollisionTransparency_valueChanged(int value);
void do_HideShow();
void do_ExpandAll();
void do_CollapseAll();
void on_toolButton_HideShow_Groups_clicked();
void on_toolButton_ExpandAll_Groups_clicked();
void on_toolButton_CollapseAll_Groups_clicked();
void on_toolButton_EnableDisable_EditGroups_clicked();
void on_toolButton_HideShow_Areas_clicked();
void on_toolButton_ExpandAll_Areas_clicked();
void on_toolButton_CollapseAll_Areas_clicked();
void on_toolButton_HideShow_Layouts_clicked();
void on_toolButton_ExpandAll_Layouts_clicked();
void on_toolButton_CollapseAll_Layouts_clicked();
void mapListShortcut_ToggleEmptyFolders();
void mapListShortcut_ExpandAll();
void mapListShortcut_CollapseAll();
void on_actionAbout_Porymap_triggered();
void on_actionOpen_Log_File_triggered();
@@ -347,14 +328,12 @@ private:
QPointer<GridSettingsDialog> gridSettingsDialog = nullptr;
QPointer<CustomScriptsEditor> customScriptsEditor = nullptr;
FilterChildrenProxyModel *groupListProxyModel;
MapGroupModel *mapGroupModel;
FilterChildrenProxyModel *areaListProxyModel;
MapAreaModel *mapAreaModel;
FilterChildrenProxyModel *layoutListProxyModel;
LayoutTreeModel *layoutTreeModel;
QPointer<FilterChildrenProxyModel> groupListProxyModel = nullptr;
QPointer<MapGroupModel> mapGroupModel = nullptr;
QPointer<FilterChildrenProxyModel> areaListProxyModel = nullptr;
QPointer<MapAreaModel> mapAreaModel = nullptr;
QPointer<FilterChildrenProxyModel> layoutListProxyModel = nullptr;
QPointer<LayoutTreeModel> layoutTreeModel = nullptr;
QPointer<UpdatePromoter> updatePromoter = nullptr;
QPointer<NetworkAccessManager> networkAccessManager = nullptr;
@@ -375,9 +354,10 @@ private:
bool tilesetNeedsRedraw = false;
bool setLayout(QString layoutId);
bool setMap(QString, bool scroll = false);
bool setMap(QString);
void unsetMap();
bool userSetMap(QString, bool scrollTreeView = false);
bool userSetLayout(QString layoutId);
bool userSetMap(QString);
void redrawMapScene();
void redrawLayoutScene();
void refreshMapScene();
@@ -389,7 +369,10 @@ private:
void clearProjectUI();
void openSubWindow(QWidget * window);
void scrollTreeView(QString itemName);
void scrollMapList(MapTree *list, QString itemName);
void scrollMapListToCurrentMap(MapTree *list);
void scrollMapListToCurrentLayout(MapTree *list);
void resetMapListFilters();
QString getExistingDirectory(QString);
bool openProject(QString dir, bool initial = false);
bool closeProject();
@@ -403,31 +386,29 @@ private:
void refreshRecentProjectsMenu();
void updateMapList();
void mapListAddItem();
void mapListRemoveItem();
void mapListAddGroup();
void mapListAddLayout();
void mapListAddArea();
void mapListRemoveGroup();
void mapListRemoveArea();
void mapListRemoveLayout();
void openMapListItem(const QModelIndex &index);
void displayMapProperties();
void checkToolButtons();
void clickToolButtonFromEditAction(Editor::EditAction editAction);
void showWindowTitle();
void updateWindowTitle();
void initWindow();
void initCustomUI();
void initExtraSignals();
void initEditor();
void initMiscHeapObjects();
void initMapSortOrder();
void initMapList();
void initShortcuts();
void initExtraShortcuts();
void loadUserSettings();
void applyMapListFilter(QString filterText);
void restoreWindowState();
void setTheme(QString);
void updateTilesetEditor();
@@ -447,6 +428,7 @@ private:
double getMetatilesZoomScale();
void redrawMetatileSelection();
void scrollMetatileSelectorToSelection();
MapListToolBar* getCurrentMapListToolBar();
QObjectList shortcutableObjects() const;
void addCustomHeaderValue(QString key, QJsonValue value, bool isNew = false);

View File

@@ -9,7 +9,7 @@ class FilterChildrenProxyModel : public QSortFilterProxyModel
public:
explicit FilterChildrenProxyModel(QObject *parent = nullptr);
void toggleHideEmpty() { this->hideEmpty = !this->hideEmpty; }
bool toggleHideEmpty() { return this->hideEmpty = !this->hideEmpty; }
protected:
bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const;
private:

View File

@@ -53,7 +53,17 @@ private:
class QRegularExpressionValidator;
class MapGroupModel : public QStandardItemModel {
class MapListModel : public QStandardItemModel {
Q_OBJECT
public:
MapListModel(QObject *parent = nullptr) : QStandardItemModel(parent) {};
~MapListModel() { }
virtual QModelIndex indexOf(QString id) const = 0;
};
class MapGroupModel : public MapListModel {
Q_OBJECT
public:
@@ -80,7 +90,7 @@ public:
void removeGroup(int groupIndex);
QStandardItem *getItem(const QModelIndex &index) const;
QModelIndex indexOfMap(QString mapName);
virtual QModelIndex indexOf(QString mapName) const override;
void initialize();
@@ -103,7 +113,7 @@ signals:
class MapAreaModel : public QStandardItemModel {
class MapAreaModel : public MapListModel {
Q_OBJECT
public:
@@ -123,7 +133,7 @@ public:
void removeArea(int groupIndex);
QStandardItem *getItem(const QModelIndex &index) const;
QModelIndex indexOfMap(QString mapName);
virtual QModelIndex indexOf(QString mapName) const override;
void initialize();
@@ -143,7 +153,7 @@ signals:
class LayoutTreeModel : public QStandardItemModel {
class LayoutTreeModel : public MapListModel {
Q_OBJECT
public:
@@ -162,7 +172,7 @@ public:
QStandardItem *insertMapItem(QString mapName, QString layoutId);
QStandardItem *getItem(const QModelIndex &index) const;
QModelIndex indexOfLayout(QString layoutName);
virtual QModelIndex indexOf(QString layoutName) const override;
void initialize();

View File

@@ -0,0 +1,49 @@
#ifndef MAPLISTTOOLBAR_H
#define MAPLISTTOOLBAR_H
#include "maplistmodels.h"
#include "filterchildrenproxymodel.h"
#include <QFrame>
#include <QPointer>
namespace Ui {
class MapListToolBar;
}
class MapListToolBar : public QFrame
{
Q_OBJECT
public:
explicit MapListToolBar(QWidget *parent = nullptr);
~MapListToolBar();
MapTree* list() const { return m_list; }
void setList(MapTree *list);
void setEditsAllowedButtonHidden(bool hidden);
void toggleEmptyFolders();
void expandList();
void collapseList();
void toggleEditsAllowed();
void applyFilter(const QString &filterText);
void clearFilter();
void setFilterLocked(bool locked) { m_filterLocked = locked; }
bool isFilterLocked() const { return m_filterLocked; }
signals:
void filterCleared(MapTree*);
void addFolderClicked();
private:
Ui::MapListToolBar *ui;
QPointer<MapTree> m_list;
bool m_filterLocked = false;
void setEditsAllowed(bool allowed);
};
#endif // MAPLISTTOOLBAR_H