Skip to content

Commit

Permalink
https://github.com/StephaneCouturier/Katalog/issues/556
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneCouturier committed Sep 19, 2024
1 parent ce3bd39 commit 7cdba23
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/filesview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,18 @@ QVariant FilesView::headerData(int section, Qt::Orientation orientation, int rol
}
return QVariant();
}

bool FilesView::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
QVariant leftData = sourceModel()->data(left);
QVariant rightData = sourceModel()->data(right);

if (leftData.typeId() == QMetaType::QString && rightData.typeId() == QMetaType::QString) {
QString leftString = leftData.toString();
QString rightString = rightData.toString();

return QString::compare(leftString, rightString, Qt::CaseInsensitive) < 0;
}

return QSortFilterProxyModel::lessThan(left, right);
}
9 changes: 5 additions & 4 deletions src/filesview.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ class FilesView : public QSortFilterProxyModel
public:
FilesView(QObject *parent = nullptr);

protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const override;

private:
QString percentBrush;
QVariant data( const QModelIndex &index, int role ) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;

QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
};

#endif // FILESVIEW_H

0 comments on commit 7cdba23

Please sign in to comment.