-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary.h
50 lines (34 loc) · 1.06 KB
/
library.h
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
49
50
#ifndef LIBRARY_H
#define LIBRARY_H
#include <QSortFilterProxyModel>
#include "documenthandler.h"
#include <QDir>
#include <QFileInfo>
#include <QFileSystemModel>
#include <QList>
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(EDIM_LIBRARY)
class Library : public QSortFilterProxyModel
{
public:
enum ItemDataRole {
DocumentContentRole = Qt::UserRole
};
Library(QObject* parent = nullptr);
QDir basePath() const;
bool contains(const QFileInfo& document) const;
QList<QFileInfo> search(const QString& text) const;
using QSortFilterProxyModel::index;
QModelIndex index(const QFileInfo& document) const;
QFileInfo fileInfo(const QModelIndex& index) const;
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
public slots:
void import(const QFileInfo& document);
void update(const QFileInfo& document);
private:
QFileSystemModel _sourceModel;
DocumentHandler _documentHandler;
void setupDatabase();
QString libraryPath(const QFileInfo& document) const;
};
#endif // LIBRARY_H