src/libraries.cpp

changeset 381
80bea7a6e84f
parent 380
16f6717a218b
equal deleted inserted replaced
380:16f6717a218b 381:80bea7a6e84f
116 /** 116 /**
117 * @brief Changes the role of the specified library 117 * @brief Changes the role of the specified library
118 * @param libraryIndex Index of the library 118 * @param libraryIndex Index of the library
119 * @param role New role 119 * @param role New role
120 */ 120 */
121 void LibrariesModel::setLibraryRole(index_t libraryIndex, const Library::Role role) 121 void LibrariesModel::setLibraryRole(index_t libraryIndex, const library_role_e role)
122 { 122 {
123 if (this->isValidIndex(libraryIndex)) 123 if (this->isValidIndex(libraryIndex))
124 { 124 {
125 this->libraries[libraryIndex].role = role; 125 this->libraries[libraryIndex].role = role;
126 this->signalLibraryChange(libraryIndex); 126 this->signalLibraryChange(libraryIndex);
213 /** 213 /**
214 * @brief Gets a human-readable string for the specified role 214 * @brief Gets a human-readable string for the specified role
215 * @param role Role to get a string for 215 * @param role Role to get a string for
216 * @returns string 216 * @returns string
217 */ 217 */
218 QString Library::libraryRoleName(const Role role) 218 QString library_role_name(const library_role_e role)
219 { 219 {
220 switch (role) 220 switch (role)
221 { 221 {
222 case Library::OfficialLibrary: 222 case library_role_e::official:
223 return LibrariesModel::tr("Official library"); 223 return LibrariesModel::tr("Official library");
224 case Library::UnofficialLibrary: 224 case library_role_e::unofficial:
225 return LibrariesModel::tr("Unofficial library"); 225 return LibrariesModel::tr("Unofficial library");
226 case Library::WorkingLibrary: 226 case library_role_e::working:
227 return LibrariesModel::tr("Working library"); 227 return LibrariesModel::tr("Working library");
228 } 228 }
229 return "???"; 229 return "???";
230 } 230 }
231 231
258 const Column column = static_cast<Column>(index.column()); 258 const Column column = static_cast<Column>(index.column());
259 const Library& library = this->library(index.row()); 259 const Library& library = this->library(index.row());
260 switch (column) 260 switch (column)
261 { 261 {
262 case RoleColumn: 262 case RoleColumn:
263 return Library::libraryRoleName(library.role); 263 return library_role_name(library.role);
264 case PathColumn: 264 case PathColumn:
265 return library.path.absolutePath(); 265 return library.path.absolutePath();
266 } 266 }
267 return {}; 267 return {};
268 } 268 }
349 { 349 {
350 QString path; 350 QString path;
351 int role; 351 int role;
352 QDataStream& result = stream >> path >> role; 352 QDataStream& result = stream >> path >> role;
353 library.path.setPath(path); 353 library.path.setPath(path);
354 library.role = static_cast<Library::Role>(role); 354 library.role = static_cast<library_role_e>(role);
355 return result; 355 return result;
356 } 356 }
357 357
358 bool operator==(const Library& one, const Library& other) 358 bool operator==(const Library& one, const Library& other)
359 { 359 {

mercurial