32 /** |
32 /** |
33 * @brief Searches the libraries for the specified file name. |
33 * @brief Searches the libraries for the specified file name. |
34 * @param fileName File to search for |
34 * @param fileName File to search for |
35 * @return Full path to the file, or empty string if not found. |
35 * @return Full path to the file, or empty string if not found. |
36 */ |
36 */ |
37 QString LibrariesModel::findFile(QString fileName) const |
37 QFileInfo LibrariesModel::findFile(QString fileName) const |
38 { |
38 { |
39 QString path; |
39 QFileInfo result; |
40 fileName.replace("\\", "/"); |
40 fileName.replace("\\", "/"); |
41 bool found = false; |
41 bool found = false; |
42 for (const Library& library : this->libraries) |
42 for (const Library& library : this->libraries) |
43 { |
43 { |
44 for (const QString& subdirectory : {"parts", "p"}) |
44 for (const QString& subdirectory : {"parts", "p"}) |
46 QDir directory = library.path; |
46 QDir directory = library.path; |
47 directory.cd(subdirectory); |
47 directory.cd(subdirectory); |
48 QFileInfo fileInfo{directory.absoluteFilePath(fileName)}; |
48 QFileInfo fileInfo{directory.absoluteFilePath(fileName)}; |
49 if (fileInfo.exists() && fileInfo.isFile()) |
49 if (fileInfo.exists() && fileInfo.isFile()) |
50 { |
50 { |
51 path = fileInfo.absoluteFilePath(); |
51 result = fileInfo; |
52 found = true; |
52 found = true; |
53 break; |
53 break; |
54 } |
54 } |
55 } |
55 } |
56 if (found) |
56 if (found) |
57 { |
57 { |
58 break; |
58 break; |
59 } |
59 } |
60 } |
60 } |
61 return path; |
61 return result; |
62 } |
62 } |
63 |
63 |
64 /** |
64 /** |
65 * @brief Adds a new library to the end of the libraries list. |
65 * @brief Adds a new library to the end of the libraries list. |
66 * @param library Library to add |
66 * @param library Library to add |