| 144 | }; |
| 145 | |
| 146 | struct ProjectFile { |
| 147 | QUrl url; |
| 148 | QString displayNameOverride = {}; |
| 149 | |
| 150 | ProjectFile() = default; |
| 151 | |
| 152 | ProjectFile(const QUrl& url, const QString& displayNameOverride = {}) |
| 153 | : url(url), displayNameOverride(displayNameOverride) {} |
| 154 | |
| 155 | ProjectFile(const muse::io::path_t& path, const QString& displayNameOverride = {}) |
| 156 | : url(path.toQUrl()), displayNameOverride(displayNameOverride) {} |
| 157 | |
| 158 | bool isNull() const |
| 159 | { |
| 160 | return url.isEmpty(); |
| 161 | } |
| 162 | |
| 163 | bool isValid() const |
| 164 | { |
| 165 | return url.isValid(); |
| 166 | } |
| 167 | |
| 168 | bool hasDisplayName() const |
| 169 | { |
| 170 | if (!displayNameOverride.isEmpty()) { |
| 171 | return true; |
| 172 | } |
| 173 | |
| 174 | return url.isLocalFile(); |
| 175 | } |
| 176 | |
| 177 | QString displayName(bool includingExtension) const |
| 178 | { |
| 179 | if (!displayNameOverride.isEmpty()) { |
| 180 | return displayNameOverride; |
| 181 | } |
| 182 | |
| 183 | return muse::io::filename(path(), includingExtension).toQString(); |
| 184 | } |
| 185 | |
| 186 | muse::io::path_t path() const |
| 187 | { |
| 188 | assert(url.isEmpty() || url.isLocalFile()); |
| 189 | |
| 190 | return muse::io::path_t(url); |
| 191 | } |
| 192 | |
| 193 | bool operator ==(const ProjectFile& other) const |
| 194 | { |
| 195 | return url == other.url |
| 196 | && displayNameOverride == other.displayNameOverride; |
| 197 | } |
| 198 | |
| 199 | bool operator !=(const ProjectFile& other) const |
| 200 | { |
| 201 | return !(*this == other); |
| 202 | } |
| 203 | }; |
no outgoing calls
no test coverage detected