Skip to content

Instantly share code, notes, and snippets.

@haraki
Created May 17, 2018 01:33
Show Gist options
  • Save haraki/490ffba539bb36e940fc50ac5e1b82e0 to your computer and use it in GitHub Desktop.
Save haraki/490ffba539bb36e940fc50ac5e1b82e0 to your computer and use it in GitHub Desktop.
#include <QSortFilterProxyModel>
#include <QDir>
class QFileSystemModel;
class QFileIconProvider;
class FolderModel : public QSortFilterProxyModel
{
public:
explicit FolderModel(QObject *parent = Q_NULLPTR);
~FolderModel();
using QSortFilterProxyModel::index;
QModelIndex index(const QString &path, int column = 0) const;
void setDotFirst(bool enable);
bool dotFirst();
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) Q_DECL_OVERRIDE;
// QFileSystemModel specific API
QModelIndex setRootPath(const QString &path);
QString filePath(const QModelIndex &index) const;
private:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const Q_DECL_OVERRIDE;
QFileSystemModel* fsModel_;
bool dotFirst_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment