Misc cleanup, and 'Sort by Name' -> 'Sort by Area'

This commit is contained in:
Marcus Huderle 2018-10-05 17:39:50 -05:00
parent cbeb79b7f9
commit 74ce9c9a45
6 changed files with 17 additions and 13 deletions

View file

@ -2373,7 +2373,7 @@
<string>Tileset Editor</string> <string>Tileset Editor</string>
</property> </property>
</action> </action>
<action name="actionSort_by_Name"> <action name="actionSort_by_Area">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -2382,7 +2382,7 @@
<normaloff>:/icons/sort_alphabet.ico</normaloff>:/icons/sort_alphabet.ico</iconset> <normaloff>:/icons/sort_alphabet.ico</normaloff>:/icons/sort_alphabet.ico</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Sort by &amp;Name</string> <string>Sort by &amp;Area</string>
</property> </property>
</action> </action>
<action name="actionSort_by_Group"> <action name="actionSort_by_Group">

View file

@ -168,6 +168,7 @@ private:
void displayMapProperties(); void displayMapProperties();
void checkToolButtons(); void checkToolButtons();
void initCustomUI();
void initExtraShortcuts(); void initExtraShortcuts();
void initExtraSignals(); void initExtraSignals();
void initEditor(); void initEditor();

View file

@ -17,7 +17,6 @@ ICON = resources/icons/porymap-icon-1.ico
SOURCES += src/core/block.cpp \ SOURCES += src/core/block.cpp \
src/core/blockdata.cpp \ src/core/blockdata.cpp \
src/core/event.cpp \ src/core/event.cpp \
src/core/filterchildrenproxymodel.cpp \
src/core/heallocation.cpp \ src/core/heallocation.cpp \
src/core/historyitem.cpp \ src/core/historyitem.cpp \
src/core/map.cpp \ src/core/map.cpp \
@ -31,6 +30,7 @@ SOURCES += src/core/block.cpp \
src/ui/connectionpixmapitem.cpp \ src/ui/connectionpixmapitem.cpp \
src/ui/currentselectedmetatilespixmapitem.cpp \ src/ui/currentselectedmetatilespixmapitem.cpp \
src/ui/eventpropertiesframe.cpp \ src/ui/eventpropertiesframe.cpp \
src/ui/filterchildrenproxymodel.cpp \
src/ui/graphicsview.cpp \ src/ui/graphicsview.cpp \
src/ui/imageproviders.cpp \ src/ui/imageproviders.cpp \
src/ui/mappixmapitem.cpp \ src/ui/mappixmapitem.cpp \
@ -55,7 +55,6 @@ SOURCES += src/core/block.cpp \
HEADERS += include/core/block.h \ HEADERS += include/core/block.h \
include/core/blockdata.h \ include/core/blockdata.h \
include/core/event.h \ include/core/event.h \
include/core/filterchildrenproxymodel.h \
include/core/heallocation.h \ include/core/heallocation.h \
include/core/history.h \ include/core/history.h \
include/core/historyitem.h \ include/core/historyitem.h \
@ -71,6 +70,7 @@ HEADERS += include/core/block.h \
include/ui/connectionpixmapitem.h \ include/ui/connectionpixmapitem.h \
include/ui/currentselectedmetatilespixmapitem.h \ include/ui/currentselectedmetatilespixmapitem.h \
include/ui/eventpropertiesframe.h \ include/ui/eventpropertiesframe.h \
include/ui/filterchildrenproxymodel.h \
include/ui/graphicsview.h \ include/ui/graphicsview.h \
include/ui/imageproviders.h \ include/ui/imageproviders.h \
include/ui/mappixmapitem.h \ include/ui/mappixmapitem.h \

View file

@ -36,6 +36,7 @@ MainWindow::MainWindow(QWidget *parent) :
QApplication::setWindowIcon(QIcon(":/icons/porymap-icon-1.ico")); QApplication::setWindowIcon(QIcon(":/icons/porymap-icon-1.ico"));
ui->setupUi(this); ui->setupUi(this);
this->initCustomUI();
this->initExtraSignals(); this->initExtraSignals();
this->initExtraShortcuts(); this->initExtraShortcuts();
this->initEditor(); this->initEditor();
@ -57,6 +58,13 @@ void MainWindow::initExtraShortcuts() {
ui->actionZoom_In->setShortcuts({QKeySequence("Ctrl++"), QKeySequence("Ctrl+=")}); ui->actionZoom_In->setShortcuts({QKeySequence("Ctrl++"), QKeySequence("Ctrl+=")});
} }
void MainWindow::initCustomUI() {
// Right-clicking on items in the map list tree view brings up a context menu.
ui->mapList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->mapList, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(onOpenMapListContextMenu(const QPoint &)));
}
void MainWindow::initExtraSignals() { void MainWindow::initExtraSignals() {
connect(ui->newEventToolButton, SIGNAL(newEventAdded(QString)), this, SLOT(addNewEvent(QString))); connect(ui->newEventToolButton, SIGNAL(newEventAdded(QString)), this, SLOT(addNewEvent(QString)));
} }
@ -96,12 +104,12 @@ void MainWindow::initMapSortOrder() {
QActionGroup *mapSortOrderActionGroup = new QActionGroup(ui->toolButton_MapSortOrder); QActionGroup *mapSortOrderActionGroup = new QActionGroup(ui->toolButton_MapSortOrder);
mapSortOrderMenu->addAction(ui->actionSort_by_Group); mapSortOrderMenu->addAction(ui->actionSort_by_Group);
mapSortOrderMenu->addAction(ui->actionSort_by_Name); mapSortOrderMenu->addAction(ui->actionSort_by_Area);
mapSortOrderMenu->addAction(ui->actionSort_by_Layout); mapSortOrderMenu->addAction(ui->actionSort_by_Layout);
ui->toolButton_MapSortOrder->setMenu(mapSortOrderMenu); ui->toolButton_MapSortOrder->setMenu(mapSortOrderMenu);
mapSortOrderActionGroup->addAction(ui->actionSort_by_Group); mapSortOrderActionGroup->addAction(ui->actionSort_by_Group);
mapSortOrderActionGroup->addAction(ui->actionSort_by_Name); mapSortOrderActionGroup->addAction(ui->actionSort_by_Area);
mapSortOrderActionGroup->addAction(ui->actionSort_by_Layout); mapSortOrderActionGroup->addAction(ui->actionSort_by_Layout);
connect(ui->toolButton_MapSortOrder, &QToolButton::triggered, this, &MainWindow::mapSortOrder_changed); connect(ui->toolButton_MapSortOrder, &QToolButton::triggered, this, &MainWindow::mapSortOrder_changed);
@ -119,7 +127,7 @@ void MainWindow::mapSortOrder_changed(QAction *action)
int i = 0; int i = 0;
for (; i < items.count(); i++) for (; i < items.count(); i++)
{ {
if(items[i] == action) if (items[i] == action)
{ {
break; break;
} }
@ -602,11 +610,6 @@ void MainWindow::sortMapList() {
} }
} }
// Right-clicking on items in the map list tree view brings up a context menu.
ui->mapList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->mapList, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(onOpenMapListContextMenu(const QPoint &)));
ui->mapList->setUpdatesEnabled(true); ui->mapList->setUpdatesEnabled(true);
ui->mapList->expandToDepth(0); ui->mapList->expandToDepth(0);
ui->mapList->repaint(); ui->mapList->repaint();
@ -639,7 +642,7 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point)
if (itemType == "map_group") { if (itemType == "map_group") {
QString groupName = selectedItem->data(Qt::UserRole).toString(); QString groupName = selectedItem->data(Qt::UserRole).toString();
int groupNum = selectedItem->data(MapListUserRoles::GroupRole).toInt(); int groupNum = selectedItem->data(MapListUserRoles::GroupRole).toInt();
QMenu* menu = new QMenu(); QMenu* menu = new QMenu(this);
QActionGroup* actions = new QActionGroup(menu); QActionGroup* actions = new QActionGroup(menu);
actions->addAction(menu->addAction("Add New Map to Group"))->setData(groupNum); actions->addAction(menu->addAction("Add New Map to Group"))->setData(groupNum);
connect(actions, SIGNAL(triggered(QAction*)), this, SLOT(onAddNewMapToGroupClick(QAction*))); connect(actions, SIGNAL(triggered(QAction*)), this, SLOT(onAddNewMapToGroupClick(QAction*)));