add areaList model and filtering, scrolling for all trees

This commit is contained in:
garak
2023-02-06 23:48:37 -05:00
parent 9918159caa
commit e2ff93e5e7
7 changed files with 241 additions and 208 deletions

View File

@@ -266,6 +266,8 @@ 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 *);
@@ -318,6 +320,9 @@ private:
FilterChildrenProxyModel *groupListProxyModel;
MapGroupModel *mapGroupModel;
FilterChildrenProxyModel *areaListProxyModel;
MapAreaModel *mapAreaModel;
FilterChildrenProxyModel *layoutListProxyModel;
LayoutTreeModel *layoutTreeModel;
@@ -348,13 +353,13 @@ private:
bool newMapDefaultsSet = false;
MapSortOrder mapSortOrder;
enum MapListTab { Groups, Areas, Layouts };
enum MapListTab { Groups = 0, Areas, Layouts };
bool tilesetNeedsRedraw = false;
bool setLayout(QString layoutId);
bool setMap(QString, bool scrollTreeView = false);
bool setMap(QString, bool scroll = false);
void unsetMap();
void redrawMapScene();
void refreshMapScene();
@@ -363,11 +368,11 @@ private:
bool populateMapList();
void sortMapList();
void openSubWindow(QWidget * window);
void scrollTreeView(QString itemName);
QString getExistingDirectory(QString);
bool openProject(QString dir);
QString getDefaultMap();
void setRecentMap(QString map_name);
QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum);
void updateMapList();

View File

@@ -15,7 +15,8 @@ enum MapListRoles {
TypeRole2, // Used for various extra data needed.
};
// or QStandardItemModel??
class MapGroupModel : public QStandardItemModel {
Q_OBJECT
@@ -52,6 +53,42 @@ signals:
class MapAreaModel : public QStandardItemModel {
Q_OBJECT
public:
MapAreaModel(Project *project, QObject *parent = nullptr);
~MapAreaModel() {}
QVariant data(const QModelIndex &index, int role) const override;
public:
void setMap(QString mapName) { this->openMap = mapName; }
QStandardItem *createAreaItem(QString areaName, int areaIndex);
QStandardItem *createMapItem(QString mapName, int areaIndex, int mapIndex);
QStandardItem *getItem(const QModelIndex &index) const;
QModelIndex indexOfMap(QString mapName);
void initialize();
private:
Project *project;
QStandardItem *root = nullptr;
QMap<QString, QStandardItem *> areaItems;
QMap<QString, QStandardItem *> mapItems;
// TODO: if reordering, will the item be the same?
QString openMap;
signals:
void edited();
};
class LayoutTreeModel : public QStandardItemModel {
Q_OBJECT