-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsidebarmodel.h
More file actions
122 lines (107 loc) · 4.88 KB
/
Copy pathsidebarmodel.h
File metadata and controls
122 lines (107 loc) · 4.88 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#pragma once
#include <QAbstractItemModel>
#include <QList>
#include <QModelIndex>
#include <QVariant>
class LibraryFeature;
class QTimer;
class SidebarModel : public QAbstractItemModel {
Q_OBJECT
public:
// Keep object tree functions from QObject accessible
// for parented_ptr
using QObject::parent;
enum Roles {
IconNameRole = Qt::UserRole + 1,
DataRole,
UrlRole,
};
Q_ENUM(Roles);
explicit SidebarModel(
QObject* parent = nullptr);
~SidebarModel() override = default;
void addLibraryFeature(LibraryFeature* feature);
QModelIndex getDefaultSelection();
void setDefaultSelection(unsigned int index);
void activateDefaultSelection();
// Required for QAbstractItemModel
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;
QVariant data(const QModelIndex& index,
int role = Qt::DisplayRole) const override;
QStringList mimeTypes() const override;
QMimeData* mimeData(const QModelIndexList& indexes) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
QModelIndex resolveDropIndex(int row, int column, const QModelIndex& index) const;
bool canDropMimeData(const QMimeData* data,
Qt::DropAction action,
int row,
int column,
const QModelIndex& index) const override;
bool dropMimeData(const QMimeData* data,
Qt::DropAction action,
int row,
int column,
const QModelIndex& index) override;
void setSourceOfCurrentDragDropEvent(QObject* source);
bool dropAccept(const QModelIndex& index, const QList<QUrl>& urls, QObject* pSource);
bool dragMoveAccept(const QModelIndex& index, const QList<QUrl>& urls) const;
bool hasChildren(const QModelIndex& parent = QModelIndex()) const override;
bool hasTrackTable(const QModelIndex& index) const;
QModelIndex translateChildIndex(const QModelIndex& index) {
return translateIndex(index, index.model());
}
QModelIndex getFeatureRootIndex(LibraryFeature* pFeature);
void clear(const QModelIndex& index);
void paste(const QModelIndex& index);
public slots:
void pressed(const QModelIndex& index);
void clicked(const QModelIndex& index);
void doubleClicked(const QModelIndex& index);
void rightClicked(const QPoint& globalPos, const QModelIndex& index);
void renameItem(const QModelIndex& index);
void deleteItem(const QModelIndex& index);
void slotFeatureSelect(LibraryFeature* pFeature,
const QModelIndex& index = QModelIndex(),
bool scrollTo = true);
// Slots for every single QAbstractItemModel signal
// void slotColumnsAboutToBeInserted(const QModelIndex& parent, int start, int end);
// void slotColumnsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
// void slotColumnsInserted(const QModelIndex& parent, int start, int end);
// void slotColumnsRemoved(const QModelIndex& parent, int start, int end);
void slotDataChanged(const QModelIndex& topLeft, const QModelIndex & bottomRight);
//void slotHeaderDataChanged(Qt::Orientation orientation, int first, int last);
// void slotLayoutAboutToBeChanged();
// void slotLayoutChanged();
// void slotModelAboutToBeReset();
// void slotModelReset();
void slotRowsAboutToBeInserted(const QModelIndex& parent, int start, int end);
void slotRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
void slotRowsInserted(const QModelIndex& parent, int start, int end);
void slotRowsRemoved(const QModelIndex& parent, int start, int end);
void slotModelAboutToBeReset();
void slotModelReset();
void slotFeatureIsLoading(LibraryFeature*, bool selectFeature);
void slotFeatureLoadingFinished(LibraryFeature*);
signals:
void selectIndex(const QModelIndex& index, bool scrollTo);
private slots:
void slotPressedUntilClickedTimeout();
protected:
QList<LibraryFeature*> m_sFeatures;
private:
QList<QUrl> collectUrls(const QModelIndexList& indexes) const;
QModelIndex translateSourceIndex(const QModelIndex& parent);
QModelIndex translateIndex(const QModelIndex& index, const QAbstractItemModel* model);
void featureRenamed(LibraryFeature*);
unsigned int m_iDefaultSelectedIndex; /** Index of the item in the sidebar model to select at startup. */
QTimer* const m_pressedUntilClickedTimer;
QModelIndex m_pressedIndex;
QStringList m_mimeTypes;
QObject* m_sourceOfCurrentDragDropEvent;
void startPressedUntilClickedTimer(const QModelIndex& pressedIndex);
void stopPressedUntilClickedTimer();
};