mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-02 04:41:08 +00:00
Fix sorting for texture viewer texture list
This commit is contained in:
@@ -2113,7 +2113,7 @@ void RDStyle::drawControl(ControlElement control, const QStyleOption *opt, QPain
|
||||
arrowRect.setLeft(arrowRect.right() - Constants::SpinButtonDim);
|
||||
|
||||
qreal yoffset = 2.5f;
|
||||
if(header->sortIndicator == QStyleOptionHeader::SortDown)
|
||||
if(header->sortIndicator == QStyleOptionHeader::SortUp)
|
||||
yoffset = -yoffset;
|
||||
|
||||
qreal ycentre = arrowRect.center().y();
|
||||
|
||||
@@ -310,14 +310,46 @@ void RDTreeWidgetItem::checkForResourceId(int col)
|
||||
|
||||
void RDTreeWidgetItem::sort(int column, Qt::SortOrder order)
|
||||
{
|
||||
ICaptureContext *ctx = getCaptureContext(m_widget);
|
||||
|
||||
std::sort(m_children.begin(), m_children.end(),
|
||||
[column, order](const RDTreeWidgetItem *a, const RDTreeWidgetItem *b) {
|
||||
[ctx, column, order](const RDTreeWidgetItem *a, const RDTreeWidgetItem *b) {
|
||||
QVariant va = a->data(column, Qt::DisplayRole);
|
||||
QVariant vb = b->data(column, Qt::DisplayRole);
|
||||
|
||||
QString sa, sb;
|
||||
|
||||
if(ctx)
|
||||
{
|
||||
sa = RichResourceTextFormat(*ctx, va);
|
||||
sb = RichResourceTextFormat(*ctx, vb);
|
||||
}
|
||||
else
|
||||
{
|
||||
sa = va.toString();
|
||||
sb = vb.toString();
|
||||
}
|
||||
|
||||
bool da_ok = false, db_ok = false;
|
||||
double da = sa.toDouble(&da_ok);
|
||||
double db = sb.toDouble(&db_ok);
|
||||
|
||||
int comp;
|
||||
|
||||
if(da_ok && db_ok)
|
||||
{
|
||||
if(order == Qt::AscendingOrder)
|
||||
return da < db;
|
||||
return da > db;
|
||||
}
|
||||
else
|
||||
{
|
||||
comp = QString::compare(sa, sb, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
if(order == Qt::AscendingOrder)
|
||||
return va < vb;
|
||||
return va > vb;
|
||||
return comp < 0;
|
||||
return comp > 0;
|
||||
});
|
||||
|
||||
for(RDTreeWidgetItem *child : m_children)
|
||||
|
||||
@@ -647,8 +647,7 @@ TextureViewer::TextureViewer(ICaptureContext &ctx, QWidget *parent)
|
||||
header->setColumnStretchHints({1, -1, -1, -1, -1, -1, -1});
|
||||
}
|
||||
|
||||
ui->textureList->header()->sortIndicatorChanged(TextureListFilter::Column_TexName,
|
||||
Qt::SortOrder::DescendingOrder);
|
||||
ui->textureList->sortByColumn(TextureListFilter::Column_TexName, Qt::SortOrder::AscendingOrder);
|
||||
|
||||
ui->zoomOption->setCurrentText(QString());
|
||||
ui->fitToWindow->toggle();
|
||||
@@ -3068,6 +3067,9 @@ void TextureViewer::refreshTextureList(FilterType filterType, const QString &fil
|
||||
|
||||
ui->textureList->setSelectedItem(root);
|
||||
|
||||
ui->textureList->sortByColumn(ui->textureList->header()->sortIndicatorSection(),
|
||||
ui->textureList->header()->sortIndicatorOrder());
|
||||
|
||||
ui->textureList->setUpdatesEnabled(true);
|
||||
|
||||
ui->textureList->endUpdate();
|
||||
|
||||
Reference in New Issue
Block a user