mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-08 08:55:37 -05:00
Refactor map list buttons
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
49
include/ui/maplisttoolbar.h
Normal file
49
include/ui/maplisttoolbar.h
Normal 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
|
||||
Reference in New Issue
Block a user