94 * @brief Adds a new library to the end of the libraries list. |
94 * @brief Adds a new library to the end of the libraries list. |
95 * @param library Library to add |
95 * @param library Library to add |
96 */ |
96 */ |
97 void LibraryManager::addLibrary(const Library& library) |
97 void LibraryManager::addLibrary(const Library& library) |
98 { |
98 { |
99 emit layoutAboutToBeChanged(); |
99 Q_EMIT layoutAboutToBeChanged(); |
100 libraries.append(library); |
100 libraries.append(library); |
101 emit layoutChanged(); |
101 Q_EMIT layoutChanged(); |
102 } |
102 } |
103 |
103 |
104 /** |
104 /** |
105 * @brief Removes a library by index. Does nothing if the index is not valid. |
105 * @brief Removes a library by index. Does nothing if the index is not valid. |
106 * @param libraryIndex Index of the library |
106 * @param libraryIndex Index of the library |
108 void LibraryManager::removeLibrary(const int libraryIndex) |
108 void LibraryManager::removeLibrary(const int libraryIndex) |
109 { |
109 { |
110 Q_ASSERT(isValidIndex(libraryIndex)); |
110 Q_ASSERT(isValidIndex(libraryIndex)); |
111 if (isValidIndex(libraryIndex)) |
111 if (isValidIndex(libraryIndex)) |
112 { |
112 { |
113 emit layoutAboutToBeChanged(); |
113 Q_EMIT layoutAboutToBeChanged(); |
114 libraries.remove(libraryIndex); |
114 libraries.remove(libraryIndex); |
115 emit layoutChanged(); |
115 Q_EMIT layoutChanged(); |
116 } |
116 } |
117 } |
117 } |
118 |
118 |
119 /** |
119 /** |
120 * @brief Gets a library by index. |
120 * @brief Gets a library by index. |
187 { |
187 { |
188 if (isValidIndex(libraryFromIndex) and |
188 if (isValidIndex(libraryFromIndex) and |
189 (isValidIndex(libraryToIndex) or libraryToIndex == count()) and |
189 (isValidIndex(libraryToIndex) or libraryToIndex == count()) and |
190 libraryFromIndex != libraryToIndex) |
190 libraryFromIndex != libraryToIndex) |
191 { |
191 { |
192 emit layoutAboutToBeChanged(); |
192 Q_EMIT layoutAboutToBeChanged(); |
193 const Library library = this->library(libraryFromIndex); |
193 const Library library = this->library(libraryFromIndex); |
194 if (libraryToIndex > libraryFromIndex) |
194 if (libraryToIndex > libraryFromIndex) |
195 { |
195 { |
196 this->libraries.insert(libraryToIndex, library); |
196 this->libraries.insert(libraryToIndex, library); |
197 this->libraries.removeAt(libraryFromIndex); |
197 this->libraries.removeAt(libraryFromIndex); |
199 else if (libraryToIndex < libraryFromIndex) |
199 else if (libraryToIndex < libraryFromIndex) |
200 { |
200 { |
201 this->libraries.removeAt(libraryFromIndex); |
201 this->libraries.removeAt(libraryFromIndex); |
202 this->libraries.insert(libraryToIndex, library); |
202 this->libraries.insert(libraryToIndex, library); |
203 } |
203 } |
204 emit layoutChanged(); |
204 Q_EMIT layoutChanged(); |
205 } |
205 } |
206 } |
206 } |
207 |
207 |
208 /** |
208 /** |
209 * @brief Checks whether the specified index points to a valid library. |
209 * @brief Checks whether the specified index points to a valid library. |
347 void LibraryManager::signalLibraryChange(int libraryIndex) |
347 void LibraryManager::signalLibraryChange(int libraryIndex) |
348 { |
348 { |
349 Q_ASSERT(isValidIndex(libraryIndex)); |
349 Q_ASSERT(isValidIndex(libraryIndex)); |
350 const QModelIndex topLeft = this->index(libraryIndex, 0); |
350 const QModelIndex topLeft = this->index(libraryIndex, 0); |
351 const QModelIndex bottomRight = this->index(libraryIndex, columnCount({}) - 1); |
351 const QModelIndex bottomRight = this->index(libraryIndex, columnCount({}) - 1); |
352 emit dataChanged(topLeft, bottomRight); |
352 Q_EMIT dataChanged(topLeft, bottomRight); |
353 } |
353 } |
354 |
354 |
355 /** |
355 /** |
356 * @brief Overload for operator<< to allow serializing a library into the configuration file. |
356 * @brief Overload for operator<< to allow serializing a library into the configuration file. |
357 * @param stream Stream to write the library into |
357 * @param stream Stream to write the library into |