Fri, 23 Mar 2018 17:13:35 +0200
remove LDPaths
1308
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
1 | #include "librariesmodel.h" |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
2 | #include "generics/migrate.h" |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
3 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
4 | LibrariesModel::LibrariesModel(Libraries& libraries, QObject* parent) : |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
5 | QAbstractTableModel {parent}, |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
6 | libraries {libraries} {} |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
7 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
8 | QString libraryRoleName(decltype(Library::role) role) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
9 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
10 | switch (role) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
11 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
12 | case Library::ReadOnlyStorage: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
13 | return QObject::tr("Storage"); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
14 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
15 | case Library::UnofficialFiles: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
16 | return QObject::tr("Unofficial files"); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
17 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
18 | case Library::WorkingDirectory: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
19 | return QObject::tr("Working directory"); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
20 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
21 | default: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
22 | return ""; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
23 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
24 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
25 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
26 | int LibrariesModel::rowCount(const QModelIndex&) const |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
27 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
28 | return this->libraries.size(); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
29 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
30 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
31 | int LibrariesModel::columnCount(const QModelIndex&) const |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
32 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
33 | return 2; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
34 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
35 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
36 | QVariant LibrariesModel::data(const QModelIndex& index, int role) const |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
37 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
38 | Column column = static_cast<Column>(index.column()); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
39 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
40 | if (index.row() >= 0 and index.row() < this->rowCount()) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
41 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
42 | const Library& library = this->libraries[index.row()]; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
43 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
44 | switch (column) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
45 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
46 | case PathColumn: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
47 | switch (role) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
48 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
49 | case Qt::DisplayRole: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
50 | case Qt::EditRole: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
51 | return library.path; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
52 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
53 | break; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
54 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
55 | case RoleColumn: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
56 | switch (role) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
57 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
58 | case Qt::DisplayRole: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
59 | return libraryRoleName(library.role); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
60 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
61 | case Qt::EditRole: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
62 | return library.role; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
63 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
64 | break; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
65 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
66 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
67 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
68 | return {}; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
69 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
70 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
71 | bool LibrariesModel::setData(const QModelIndex& index, const QVariant& value, int role) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
72 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
73 | if (index.row() >= 0 and index.row() < this->rowCount({}) and role == Qt::EditRole) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
74 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
75 | Library& library = this->libraries[index.row()]; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
76 | Column column = static_cast<Column>(index.column()); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
77 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
78 | switch (column) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
79 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
80 | case PathColumn: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
81 | library.path = value.toString(); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
82 | return true; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
83 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
84 | case RoleColumn: |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
85 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
86 | int intValue = value.toInt(); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
87 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
88 | if (intValue >= 0 and intValue < 3) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
89 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
90 | library.role = static_cast<decltype(Library::role)>(intValue); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
91 | return true; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
92 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
93 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
94 | break; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
95 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
96 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
97 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
98 | return false; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
99 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
100 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
101 | Qt::ItemFlags LibrariesModel::flags(const QModelIndex& index) const |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
102 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
103 | Qt::ItemFlags flags = QAbstractTableModel::flags(index); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
104 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
105 | if (index.isValid()) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
106 | flags |= Qt::ItemIsEditable; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
107 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
108 | return flags; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
109 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
110 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
111 | bool LibrariesModel::moveRows( |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
112 | const QModelIndex&, |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
113 | int sourceRow, |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
114 | int count, |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
115 | const QModelIndex&, |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
116 | int destinationRow |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
117 | ) { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
118 | int sourceRowLast = sourceRow + count - 1; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
119 | this->beginMoveRows({}, sourceRow, sourceRowLast, {}, destinationRow); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
120 | ::migrate(this->libraries, sourceRow, sourceRowLast, destinationRow); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
121 | this->endMoveRows(); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
122 | return true; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
123 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
124 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
125 | bool LibrariesModel::removeRows(int row, int count, const QModelIndex&) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
126 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
127 | if (row >= 0 and row + count - 1 < this->rowCount()) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
128 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
129 | this->beginRemoveRows({}, row, row + count - 1); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
130 | this->libraries.remove(row, count); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
131 | this->endRemoveRows(); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
132 | return true; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
133 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
134 | else |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
135 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
136 | return false; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
137 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
138 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
139 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
140 | bool LibrariesModel::insertRows(int startRow, int count, const QModelIndex&) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
141 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
142 | if (startRow >= 0 and startRow <= this->rowCount()) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
143 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
144 | this->beginInsertRows({}, startRow, startRow + count - 1); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
145 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
146 | for (int row : range(startRow, startRow + 1, startRow + count - 1)) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
147 | this->libraries.insert(row, {}); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
148 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
149 | this->endInsertRows(); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
150 | return true; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
151 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
152 | else |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
153 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
154 | return false; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
155 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
156 | } |