Sort material, pose, and motion list by name
parent
7a33fa2531
commit
4689ed163a
|
@ -435,6 +435,7 @@ void Document::renameMotion(QUuid motionId, QString name)
|
||||||
|
|
||||||
findMotionResult->second.name = name;
|
findMotionResult->second.name = name;
|
||||||
emit motionNameChanged(motionId);
|
emit motionNameChanged(motionId);
|
||||||
|
emit motionListChanged();
|
||||||
emit optionsChanged();
|
emit optionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,6 +508,7 @@ void Document::renamePose(QUuid poseId, QString name)
|
||||||
|
|
||||||
findPoseResult->second.name = name;
|
findPoseResult->second.name = name;
|
||||||
emit poseNameChanged(poseId);
|
emit poseNameChanged(poseId);
|
||||||
|
emit poseListChanged();
|
||||||
emit optionsChanged();
|
emit optionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3067,6 +3069,7 @@ void Document::renameMaterial(QUuid materialId, QString name)
|
||||||
|
|
||||||
findMaterialResult->second.name = name;
|
findMaterialResult->second.name = name;
|
||||||
emit materialNameChanged(materialId);
|
emit materialNameChanged(materialId);
|
||||||
|
emit materialListChanged();
|
||||||
emit optionsChanged();
|
emit optionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,12 +250,21 @@ void MaterialListWidget::reload()
|
||||||
for (int i = 0; i < columns; i++)
|
for (int i = 0; i < columns; i++)
|
||||||
setColumnWidth(i, columnWidth);
|
setColumnWidth(i, columnWidth);
|
||||||
|
|
||||||
decltype(m_document->materialIdList.size()) materialIndex = 0;
|
std::vector<QUuid> orderedMaterialIdList = m_document->materialIdList;
|
||||||
while (materialIndex < m_document->materialIdList.size()) {
|
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(orderedMaterialIdList.size()) materialIndex = 0;
|
||||||
|
while (materialIndex < orderedMaterialIdList.size()) {
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(this);
|
QTreeWidgetItem *item = new QTreeWidgetItem(this);
|
||||||
item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable));
|
item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable));
|
||||||
for (int col = 0; col < columns && materialIndex < m_document->materialIdList.size(); col++, materialIndex++) {
|
for (int col = 0; col < columns && materialIndex < orderedMaterialIdList.size(); col++, materialIndex++) {
|
||||||
const auto &materialId = m_document->materialIdList[materialIndex];
|
const auto &materialId = orderedMaterialIdList[materialIndex];
|
||||||
item->setSizeHint(col, QSize(columnWidth, MaterialWidget::preferredHeight() + 2));
|
item->setSizeHint(col, QSize(columnWidth, MaterialWidget::preferredHeight() + 2));
|
||||||
item->setData(col, Qt::UserRole, materialId.toString());
|
item->setData(col, Qt::UserRole, materialId.toString());
|
||||||
MaterialWidget *widget = new MaterialWidget(m_document, materialId);
|
MaterialWidget *widget = new MaterialWidget(m_document, materialId);
|
||||||
|
|
|
@ -240,12 +240,21 @@ void MotionListWidget::reload()
|
||||||
for (int i = 0; i < columns; i++)
|
for (int i = 0; i < columns; i++)
|
||||||
setColumnWidth(i, columnWidth);
|
setColumnWidth(i, columnWidth);
|
||||||
|
|
||||||
decltype(m_document->motionIdList.size()) motionIndex = 0;
|
std::vector<QUuid> orderedMotionIdList = m_document->motionIdList;
|
||||||
while (motionIndex < m_document->motionIdList.size()) {
|
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);
|
QTreeWidgetItem *item = new QTreeWidgetItem(this);
|
||||||
item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable));
|
item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable));
|
||||||
for (int col = 0; col < columns && motionIndex < m_document->motionIdList.size(); col++, motionIndex++) {
|
for (int col = 0; col < columns && motionIndex < orderedMotionIdList.size(); col++, motionIndex++) {
|
||||||
const auto &motionId = m_document->motionIdList[motionIndex];
|
const auto &motionId = orderedMotionIdList[motionIndex];
|
||||||
item->setSizeHint(col, QSize(columnWidth, MotionWidget::preferredHeight() + 2));
|
item->setSizeHint(col, QSize(columnWidth, MotionWidget::preferredHeight() + 2));
|
||||||
item->setData(col, Qt::UserRole, motionId.toString());
|
item->setData(col, Qt::UserRole, motionId.toString());
|
||||||
MotionWidget *widget = new MotionWidget(m_document, motionId);
|
MotionWidget *widget = new MotionWidget(m_document, motionId);
|
||||||
|
|
|
@ -240,12 +240,21 @@ void PoseListWidget::reload()
|
||||||
for (int i = 0; i < columns; i++)
|
for (int i = 0; i < columns; i++)
|
||||||
setColumnWidth(i, columnWidth);
|
setColumnWidth(i, columnWidth);
|
||||||
|
|
||||||
decltype(m_document->poseIdList.size()) poseIndex = 0;
|
std::vector<QUuid> orderedPoseIdList = m_document->poseIdList;
|
||||||
while (poseIndex < m_document->poseIdList.size()) {
|
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);
|
QTreeWidgetItem *item = new QTreeWidgetItem(this);
|
||||||
item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable));
|
item->setFlags((item->flags() | Qt::ItemIsEnabled) & ~(Qt::ItemIsSelectable) & ~(Qt::ItemIsEditable));
|
||||||
for (int col = 0; col < columns && poseIndex < m_document->poseIdList.size(); col++, poseIndex++) {
|
for (int col = 0; col < columns && poseIndex < orderedPoseIdList.size(); col++, poseIndex++) {
|
||||||
const auto &poseId = m_document->poseIdList[poseIndex];
|
const auto &poseId = orderedPoseIdList[poseIndex];
|
||||||
item->setSizeHint(col, QSize(columnWidth, PoseWidget::preferredHeight() + 2));
|
item->setSizeHint(col, QSize(columnWidth, PoseWidget::preferredHeight() + 2));
|
||||||
item->setData(col, Qt::UserRole, poseId.toString());
|
item->setData(col, Qt::UserRole, poseId.toString());
|
||||||
PoseWidget *widget = new PoseWidget(m_document, poseId);
|
PoseWidget *widget = new PoseWidget(m_document, poseId);
|
||||||
|
|
Loading…
Reference in New Issue