blob: 5189d89b88960951d47aead65d6eb4860a9e70db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#ifndef SIMPLEFILETREEMODEL_H
#define SIMPLEFILETREEMODEL_H
#include <QAbstractItemModel>
#include <QIcon>
#include <QLineEdit>
#include <QModelIndex>
#include <QVariant>
#include <uibase/filterwidget.h>
using namespace MOBase;
class SimpleFileTreeItem;
class SimpleFileTreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit SimpleFileTreeModel(const QStringList& data, QObject* parent = nullptr);
~SimpleFileTreeModel();
void setFilterWidgetList(QAbstractItemView* list) { m_FilterWidget.setList(list); }
void setFilterWidgetEdit(QLineEdit* edit) { m_FilterWidget.setEdit(edit); }
QVariant data(const QModelIndex& index, int role) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column,
const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& index) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
private:
// takes a list of relative file paths assumed with the same base folder and generates
// the filetree model
void setupModelData(const QStringList& lines, SimpleFileTreeItem* parent);
const int m_ColumnCount = 1;
SimpleFileTreeItem* m_RootItem;
FilterWidget m_FilterWidget;
QIcon m_FileIcon;
QIcon m_FolderIcon;
};
#endif // SIMPLEFILETREEMODEL_H
|