┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2011-08-15 13:05:53 +0200
committerFrank Reininghaus <[email protected]>2011-08-15 13:05:53 +0200
commitdd71994b6cea7730c126f0b68351a96a0c624634 (patch)
tree8d70500b21572c5f8d6dc9f20926cfe1201096d0 /src
parentc12f0f8c61d7ec269be689a42836fe4d67a96253 (diff)
Fix for KFileItemModel::expansionLevelsCompare
Before this commit, expanding and collapsing folders in the details view would lead to strange results in a folder with the items "a", "a/a/", "a/a/1", "a/a-1/", and "a/a-1/1". The problem was that the comparison between "a/a/1" and "a/a-1/1" went wrong: the first character in which the paths differ is a "/" in one of the items, such that the code that reduces this 'index' in KFileItemModel::expansionLevelsCompare in order to find the 'common path' did nothing because it checked that only *one* of the two items does not have an "/" at the position 'index'.
Diffstat (limited to 'src')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp2
-rw-r--r--src/tests/kfileitemmodeltest.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index ddc56209b..c54a982f6 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -831,7 +831,7 @@ int KFileItemModel::expansionLevelsCompare(const KFileItem& a, const KFileItem&
if (index > maxIndex) {
index = maxIndex;
}
- while (pathA.at(index) != QLatin1Char('/') && index > 0) {
+ while ((pathA.at(index) != QLatin1Char('/') || pathB.at(index) != QLatin1Char('/')) && index > 0) {
--index;
}
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index 74706d49a..0e40b3bc4 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -228,6 +228,7 @@ void KFileItemModelTest::testExpansionLevelsCompare_data()
QTest::newRow("Equal") << "/a/b" << "/a/b" << 0;
QTest::newRow("Sub path: A < B") << "/a/b" << "/a/b/c" << -1;
QTest::newRow("Sub path: A > B") << "/a/b/c" << "/a/b" << +1;
+ QTest::newRow("Same level: /a/1 < /a-1/1") << "/a/1" << "/a-1/1" << -1;
}
void KFileItemModelTest::testExpansionLevelsCompare()