| 266 | } |
| 267 | |
| 268 | int Path::compare(const Path& other, Qt::CaseSensitivity cs) const |
| 269 | { |
| 270 | const int size = m_data.size(); |
| 271 | const int otherSize = other.m_data.size(); |
| 272 | const int toCompare = std::min(size, otherSize); |
| 273 | |
| 274 | // compare each Path segment in turn and try to return early |
| 275 | for (int i = 0; i < toCompare; ++i) { |
| 276 | const int comparison = m_data.at(i).compare(other.m_data.at(i), cs); |
| 277 | if (comparison != 0) { |
| 278 | return comparison; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | // when we reach this point, all elements that we compared where equal |
| 283 | // thus return the segment count difference between the two paths |
| 284 | return size - otherSize; |
| 285 | } |
| 286 | |
| 287 | QUrl Path::toUrl() const |
| 288 | { |