Pith - whittle
whittle/src/ui/FolderTreeModel.h [1.2 kb]
Modified: 19:51:45 130 026 (27 Jul 026)
0 Days Ago
#pragma once
#include <QFileSystemModel>
#include <QSet>
#include <QString>
#include <QStringList>

namespace whittle {

class FolderTreeModel : public QFileSystemModel {
    Q_OBJECT
public:
    explicit FolderTreeModel(QObject* parent = nullptr);

    void setRecursive(bool on);
    bool recursive() const { return m_recursive; }
    QStringList scanRoots() const { return QStringList(m_checked.values()); }
    QStringList excludedPaths() const { return QStringList(m_excluded.values()); }
    void setCheckedRoots(const QStringList& roots,
                         const QStringList& excluded = {});
    void clearChecks();

    Qt::ItemFlags flags(const QModelIndex&) const override;
    QVariant data(const QModelIndex&, int role) const override;
    bool setData(const QModelIndex&, const QVariant&, int role) override;

signals:
    void selectionChanged();

private:
    Qt::CheckState stateFor(const QString& path) const;
    bool effectivelyChecked(const QString& path) const;
    void check(const QString& path);
    void uncheck(const QString& path);
    void emitSubtree(const QModelIndex&);
    void emitAncestors(const QModelIndex&);

    QSet<QString> m_checked;
    QSet<QString> m_excluded;
    bool m_recursive = true;
};

}
Updates
Whittle - Linux 130.026
Wedge - Android 126.026
Wedge - Linux 124.026
Shim - Android 117.026
Miter - 114.026
Dev
TVShow (227) 'CSA'
TVShow (228) 'APT'
TVProgram (83) 'BXT'
Miter Update(s)
Peen (Messaging)

Menu
Calendar
Project Tin (024/029)
Miter
RSS Feed
User Avatar
@vgmlr
=SUM(parts)