aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/BrowserModel.h
blob: 0968b4d445e2640eb57c7c109ec2f6161503ed2c (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//===========================================
//  Lumina Desktop source code
//  Copyright (c) 2017, Ken Moore & JT Pennington
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
//  This is the main browsing backend for the file manager
//===========================================
#ifndef _LUMINA_FM_BROWSER_MODEL_BACKEND_H
#define _LUMINA_FM_BROWSER_MODEL_BACKEND_H

#include <QAbstractItemModel>
#include <QModelIndex>
#include <QMimeData>
#include <QMap>
#include <QVariant>
#include <QHash>

#include <LuminaXDG.h>

class BrowserModel : public QAbstractItemModel {
	Q_OBJECT
public:
	BrowserModel(QObject *parent = 0);
	~BrowserModel();

	//Virtual overrides
	QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
	QModelIndex parent(const QModelIndex &index) const;

	// item management
	int rowCount(const QModelIndex &parent = QModelIndex()) const;
	bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
	bool removeRow(int row, const QModelIndex &parent = QModelIndex());
	bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());

	int columnCount(const QModelIndex &parent = QModelIndex()) const;
	bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
	bool removeColumn(int column, const QModelIndex &parent = QModelIndex());
	bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());

	//bool hasChildren(const QModelIndex &parent = QModelIndex()) const;

	// data functions
	Qt::ItemFlags flags(const QModelIndex &index) const;
	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
	QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
	// data modification functions
	bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
	bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole);

	// drag and drop
	//QMimeData* mimeData(const QModelIndexList &indexes) const;
	//QStringList mimeTypes() const;
	//bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
	//Qt::DropActions supportedDropActions() const;
	//bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);

	//Special Functions (non virtual replacements)
	LFileInfo* fileInfo(QString name);
	QString currentDirectory();

public slots:
	void loadDirectory(QString dir="");
	void loadItem(QString item);

private:
	QHash<quintptr, QModelIndex> HASH; //QString: "row/column"
	QString cDir;
	//simplification functions
	/*QString findInHash(QString path);
	QString findInHash(QModelIndex index);
	LFileInfo* indexToInfo(QString path);*/
	LFileInfo* indexToInfo(QModelIndex index);
	
private slots:

protected:

signals:

};

#endif

bgstack15