| 734 | } |
| 735 | |
| 736 | int pathDepth(const QString& path) |
| 737 | { |
| 738 | if (path.isEmpty()) |
| 739 | return 0; |
| 740 | |
| 741 | QFileInfo info(path); |
| 742 | |
| 743 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) |
| 744 | auto parts = QDir::toNativeSeparators(info.path()).split(QDir::separator(), QString::SkipEmptyParts); |
| 745 | #else |
| 746 | auto parts = QDir::toNativeSeparators(info.path()).split(QDir::separator(), Qt::SkipEmptyParts); |
| 747 | #endif |
| 748 | |
| 749 | int numParts = parts.length(); |
| 750 | numParts -= parts.count("."); |
| 751 | numParts -= parts.count("..") * 2; |
| 752 | |
| 753 | return numParts; |
| 754 | } |
| 755 | |
| 756 | QString pathTruncate(const QString& path, int depth) |
| 757 | { |