fix map icons in mapList

This commit is contained in:
garak 2019-02-25 20:40:46 -05:00 committed by huderlem
parent 3ab64f493d
commit 34cc6fe5c7
2 changed files with 19 additions and 24 deletions

View file

@ -171,6 +171,7 @@ private:
Editor *editor = nullptr; Editor *editor = nullptr;
QIcon* mapIcon; QIcon* mapIcon;
QIcon* mapEditedIcon; QIcon* mapEditedIcon;
QIcon* mapOpenedIcon;
QWidget *eventTabObjectWidget; QWidget *eventTabObjectWidget;
QWidget *eventTabWarpWidget; QWidget *eventTabWarpWidget;
@ -200,8 +201,7 @@ private:
void setRecentMap(QString map_name); void setRecentMap(QString map_name);
QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum); QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum);
void markAllEdited(QAbstractItemModel *model); void drawMapListIcons(QAbstractItemModel *model);
void markEdited(QModelIndex index);
void updateMapList(); void updateMapList();
void displayMapProperties(); void displayMapProperties();

View file

@ -101,13 +101,9 @@ void MainWindow::initEditor() {
} }
void MainWindow::initMiscHeapObjects() { void MainWindow::initMiscHeapObjects() {
mapIcon = new QIcon; mapIcon = new QIcon(QStringLiteral(":/icons/map.ico"));
mapIcon->addFile(QStringLiteral(":/icons/map.ico"), QSize(), QIcon::Normal, QIcon::Off); mapEditedIcon = new QIcon(QStringLiteral(":/icons/map_edited.ico"));
mapIcon->addFile(QStringLiteral(":/icons/map_opened.ico"), QSize(), QIcon::Normal, QIcon::On); mapOpenedIcon = new QIcon(QStringLiteral(":/icons/map_opened.ico"));
mapEditedIcon = new QIcon;
mapEditedIcon->addFile(QStringLiteral(":/icons/map_edited.ico"), QSize(), QIcon::Normal, QIcon::Off);
mapEditedIcon->addFile(QStringLiteral(":/icons/map_opened.ico"), QSize(), QIcon::Normal , QIcon::On);
mapListModel = new QStandardItemModel; mapListModel = new QStandardItemModel;
mapGroupItemsList = new QList<QStandardItem*>; mapGroupItemsList = new QList<QStandardItem*>;
@ -889,7 +885,7 @@ void MainWindow::on_mapList_activated(const QModelIndex &index)
} }
} }
void MainWindow::markAllEdited(QAbstractItemModel *model) { void MainWindow::drawMapListIcons(QAbstractItemModel *model) {
QList<QModelIndex> list; QList<QModelIndex> list;
list.append(QModelIndex()); list.append(QModelIndex());
while (list.length()) { while (list.length()) {
@ -899,19 +895,18 @@ void MainWindow::markAllEdited(QAbstractItemModel *model) {
if (model->hasChildren(index)) { if (model->hasChildren(index)) {
list.append(index); list.append(index);
} }
markEdited(index); QVariant data = index.data(Qt::UserRole);
} if (!data.isNull()) {
} QString map_name = data.toString();
} if (editor->project && editor->project->map_cache->contains(map_name)) {
QStandardItem *map = mapListModel->itemFromIndex(mapListIndexes.value(map_name));
void MainWindow::markEdited(QModelIndex index) { map->setIcon(*mapIcon);
QVariant data = index.data(Qt::UserRole); if (editor->project->map_cache->value(map_name)->hasUnsavedChanges()) {
if (!data.isNull()) { map->setIcon(*mapEditedIcon);
QString map_name = data.toString(); }
if (editor->project) { if (editor->map->name == map_name) {
if (editor->project->map_cache->contains(map_name)) { map->setIcon(*mapOpenedIcon);
if (editor->project->map_cache->value(map_name)->hasUnsavedChanges()) { }
mapListModel->itemFromIndex(mapListIndexes.value(map_name))->setIcon(*mapEditedIcon);
} }
} }
} }
@ -920,7 +915,7 @@ void MainWindow::markEdited(QModelIndex index) {
void MainWindow::updateMapList() { void MainWindow::updateMapList() {
QAbstractItemModel *model = ui->mapList->model(); QAbstractItemModel *model = ui->mapList->model();
markAllEdited(model); drawMapListIcons(model);
} }
void MainWindow::on_action_Save_Project_triggered() void MainWindow::on_action_Save_Project_triggered()