diff --git a/src/document.cpp b/src/document.cpp index eadd4455..18689789 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -435,6 +435,7 @@ void Document::renameMotion(QUuid motionId, QString name) findMotionResult->second.name = name; emit motionNameChanged(motionId); + emit motionListChanged(); emit optionsChanged(); } @@ -507,6 +508,7 @@ void Document::renamePose(QUuid poseId, QString name) findPoseResult->second.name = name; emit poseNameChanged(poseId); + emit poseListChanged(); emit optionsChanged(); } @@ -3067,6 +3069,7 @@ void Document::renameMaterial(QUuid materialId, QString name) findMaterialResult->second.name = name; emit materialNameChanged(materialId); + emit materialListChanged(); emit optionsChanged(); } diff --git a/src/materiallistwidget.cpp b/src/materiallistwidget.cpp index a7028e5c..0462caca 100644 --- a/src/materiallistwidget.cpp +++ b/src/materiallistwidget.cpp @@ -249,13 +249,22 @@ void MaterialListWidget::reload() setColumnCount(columns); for (int i = 0; i < columns; i++) setColumnWidth(i, columnWidth); + + std::vector orderedMaterialIdList = m_document->materialIdList; + std::sort(orderedMaterialIdList.begin(), orderedMaterialIdList.end(), [&](const QUuid &firstMaterialId, const QUuid &secondMaterialId) { + const auto *firstMaterial = m_document->findMaterial(firstMaterialId); + const auto *secondMaterial = m_document->findMaterial(secondMaterialId); + if (nullptr == firstMaterial || nullptr == secondMaterial) + return false; + return QString::compare(firstMaterial->name, secondMaterial->name, Qt::CaseInsensitive) < 0; + }); - decltype(m_document->materialIdList.size()) materialIndex = 0; - while (materialIndex < m_document->materialIdList.size()) { + decltype(orderedMaterialIdList.size()) materialIndex = 0; + while (materialIndex < orderedMaterialIdList.size()) { QTreeWidgetItem *item = new QTreeWidgetItem(this); item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable)); - for (int col = 0; col < columns && materialIndex < m_document->materialIdList.size(); col++, materialIndex++) { - const auto &materialId = m_document->materialIdList[materialIndex]; + for (int col = 0; col < columns && materialIndex < orderedMaterialIdList.size(); col++, materialIndex++) { + const auto &materialId = orderedMaterialIdList[materialIndex]; item->setSizeHint(col, QSize(columnWidth, MaterialWidget::preferredHeight() + 2)); item->setData(col, Qt::UserRole, materialId.toString()); MaterialWidget *widget = new MaterialWidget(m_document, materialId); diff --git a/src/motionlistwidget.cpp b/src/motionlistwidget.cpp index 061b9279..fffed5dd 100644 --- a/src/motionlistwidget.cpp +++ b/src/motionlistwidget.cpp @@ -240,12 +240,21 @@ void MotionListWidget::reload() for (int i = 0; i < columns; i++) setColumnWidth(i, columnWidth); - decltype(m_document->motionIdList.size()) motionIndex = 0; - while (motionIndex < m_document->motionIdList.size()) { + std::vector orderedMotionIdList = m_document->motionIdList; + std::sort(orderedMotionIdList.begin(), orderedMotionIdList.end(), [&](const QUuid &firstMotionId, const QUuid &secondMotionId) { + const auto *firstMotion = m_document->findMotion(firstMotionId); + const auto *secondMotion = m_document->findMotion(secondMotionId); + if (nullptr == firstMotion || nullptr == secondMotion) + return false; + return QString::compare(firstMotion->name, secondMotion->name, Qt::CaseInsensitive) < 0; + }); + + decltype(orderedMotionIdList.size()) motionIndex = 0; + while (motionIndex < orderedMotionIdList.size()) { QTreeWidgetItem *item = new QTreeWidgetItem(this); item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable)); - for (int col = 0; col < columns && motionIndex < m_document->motionIdList.size(); col++, motionIndex++) { - const auto &motionId = m_document->motionIdList[motionIndex]; + for (int col = 0; col < columns && motionIndex < orderedMotionIdList.size(); col++, motionIndex++) { + const auto &motionId = orderedMotionIdList[motionIndex]; item->setSizeHint(col, QSize(columnWidth, MotionWidget::preferredHeight() + 2)); item->setData(col, Qt::UserRole, motionId.toString()); MotionWidget *widget = new MotionWidget(m_document, motionId); diff --git a/src/poselistwidget.cpp b/src/poselistwidget.cpp index ee875954..e96d4eb4 100644 --- a/src/poselistwidget.cpp +++ b/src/poselistwidget.cpp @@ -240,12 +240,21 @@ void PoseListWidget::reload() for (int i = 0; i < columns; i++) setColumnWidth(i, columnWidth); - decltype(m_document->poseIdList.size()) poseIndex = 0; - while (poseIndex < m_document->poseIdList.size()) { + std::vector orderedPoseIdList = m_document->poseIdList; + std::sort(orderedPoseIdList.begin(), orderedPoseIdList.end(), [&](const QUuid &firstPoseId, const QUuid &secondPoseId) { + const auto *firstPose = m_document->findPose(firstPoseId); + const auto *secondPose = m_document->findPose(secondPoseId); + if (nullptr == firstPose || nullptr == secondPose) + return false; + return QString::compare(firstPose->name, secondPose->name, Qt::CaseInsensitive) < 0; + }); + + decltype(orderedPoseIdList.size()) poseIndex = 0; + while (poseIndex < orderedPoseIdList.size()) { QTreeWidgetItem *item = new QTreeWidgetItem(this); item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable)); - for (int col = 0; col < columns && poseIndex < m_document->poseIdList.size(); col++, poseIndex++) { - const auto &poseId = m_document->poseIdList[poseIndex]; + for (int col = 0; col < columns && poseIndex < orderedPoseIdList.size(); col++, poseIndex++) { + const auto &poseId = orderedPoseIdList[poseIndex]; item->setSizeHint(col, QSize(columnWidth, PoseWidget::preferredHeight() + 2)); item->setData(col, Qt::UserRole, poseId.toString()); PoseWidget *widget = new PoseWidget(m_document, poseId);