mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-20 07:36:31 -05:00
add drag-drop reordering for maps in groups
This commit is contained in:
12
include/ui/eventfilters.h
Normal file
12
include/ui/eventfilters.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <QObject>
|
||||
#include <QEvent>
|
||||
|
||||
|
||||
|
||||
class WheelFilter : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
WheelFilter(QObject *parent) : QObject(parent) {}
|
||||
virtual ~WheelFilter() {}
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
};
|
||||
@@ -2,6 +2,8 @@
|
||||
#ifndef MAPLISTMODELS_H
|
||||
#define MAPLISTMODELS_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QFontDatabase>
|
||||
#include <QStandardItemModel>
|
||||
#include <QMap>
|
||||
|
||||
@@ -17,6 +19,20 @@ enum MapListRoles {
|
||||
|
||||
|
||||
|
||||
class MapTree : public QTreeView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MapTree(QWidget *parent) : QTreeView(parent) {
|
||||
this->setDropIndicatorShown(true);
|
||||
this->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
}
|
||||
|
||||
public slots:
|
||||
void removeSelected();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MapGroupModel : public QStandardItemModel {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -26,11 +42,16 @@ public:
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
QStringList mimeTypes() const override;
|
||||
virtual QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
|
||||
public:
|
||||
void setMap(QString mapName) { this->openMap = mapName; }
|
||||
|
||||
QStandardItem *createGroupItem(QString groupName, int groupIndex);
|
||||
QStandardItem *createMapItem(QString mapName, int groupIndex, int mapIndex);
|
||||
QStandardItem *createMapItem(QString mapName, QStandardItem *fromItem = nullptr);
|
||||
|
||||
QStandardItem *insertMapItem(QString mapName, QString groupName);
|
||||
|
||||
@@ -39,6 +60,9 @@ public:
|
||||
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
void updateProject();
|
||||
|
||||
private:
|
||||
Project *project;
|
||||
QStandardItem *root = nullptr;
|
||||
@@ -50,7 +74,7 @@ private:
|
||||
QString openMap;
|
||||
|
||||
signals:
|
||||
void edited();
|
||||
void dragMoveCompleted();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@ public slots:
|
||||
void deactivateTab(int tabIndex);
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
void actionCopyTab(int index);
|
||||
void actionAddDeleteTab(int index);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user