diff --git a/include/mainwindow.h b/include/mainwindow.h index bb7d98c1..4fbb2d22 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -171,6 +171,7 @@ private: Editor *editor = nullptr; QIcon* mapIcon; QIcon* mapEditedIcon; + QIcon* mapOpenedIcon; QWidget *eventTabObjectWidget; QWidget *eventTabWarpWidget; @@ -200,8 +201,7 @@ private: void setRecentMap(QString map_name); QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum); - void markAllEdited(QAbstractItemModel *model); - void markEdited(QModelIndex index); + void drawMapListIcons(QAbstractItemModel *model); void updateMapList(); void displayMapProperties(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 730925b9..42ee5900 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -101,13 +101,9 @@ void MainWindow::initEditor() { } void MainWindow::initMiscHeapObjects() { - mapIcon = new QIcon; - mapIcon->addFile(QStringLiteral(":/icons/map.ico"), QSize(), QIcon::Normal, QIcon::Off); - mapIcon->addFile(QStringLiteral(":/icons/map_opened.ico"), QSize(), QIcon::Normal, QIcon::On); - - 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); + mapIcon = new QIcon(QStringLiteral(":/icons/map.ico")); + mapEditedIcon = new QIcon(QStringLiteral(":/icons/map_edited.ico")); + mapOpenedIcon = new QIcon(QStringLiteral(":/icons/map_opened.ico")); mapListModel = new QStandardItemModel; mapGroupItemsList = new QList; @@ -889,7 +885,7 @@ void MainWindow::on_mapList_activated(const QModelIndex &index) } } -void MainWindow::markAllEdited(QAbstractItemModel *model) { +void MainWindow::drawMapListIcons(QAbstractItemModel *model) { QList list; list.append(QModelIndex()); while (list.length()) { @@ -899,19 +895,18 @@ void MainWindow::markAllEdited(QAbstractItemModel *model) { if (model->hasChildren(index)) { list.append(index); } - markEdited(index); - } - } -} - -void MainWindow::markEdited(QModelIndex index) { - QVariant data = index.data(Qt::UserRole); - if (!data.isNull()) { - QString map_name = data.toString(); - if (editor->project) { - if (editor->project->map_cache->contains(map_name)) { - if (editor->project->map_cache->value(map_name)->hasUnsavedChanges()) { - mapListModel->itemFromIndex(mapListIndexes.value(map_name))->setIcon(*mapEditedIcon); + 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)); + map->setIcon(*mapIcon); + if (editor->project->map_cache->value(map_name)->hasUnsavedChanges()) { + map->setIcon(*mapEditedIcon); + } + if (editor->map->name == map_name) { + map->setIcon(*mapOpenedIcon); + } } } } @@ -920,7 +915,7 @@ void MainWindow::markEdited(QModelIndex index) { void MainWindow::updateMapList() { QAbstractItemModel *model = ui->mapList->model(); - markAllEdited(model); + drawMapListIcons(model); } void MainWindow::on_action_Save_Project_triggered()