┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests/kfileitemmodeltest.cpp
AgeCommit message (Collapse)Author
2013-12-22Add unit test for KFileItemModel::createMimeData().Frank Reininghaus
The test verifies that creating the mime data for a child of an expanced folder does not cause a crash. The regression happenened in the master branch, but it doesn't hurt to have the test also in KDE/4.12. CCBUG: 329119
2013-12-22Update filtered items when the "refreshItems" signal is receivedFrank Reininghaus
This fixes the problem that the new file name is not shown in the view if an item is renamed while it is filtered. BUG: 329118 FIXED-IN: 4.12.1 REVIEW: 114459
2013-12-14Update the roles for filtered items if necessaryFrank Reininghaus
Since Dolphin 4.11, we store not only KFileItems, but also the corresponding ItemData struct for filtered items. This is required for keeping track of the parent-child relationships, and has the nice side effect that the ItemData need not be re-determined when the items are shown again. However, this can become a problem if the visible roles or the sort role change while some items are filtered. This is fixed by is fixed by clearing the QHash "values" for the filtered items if the visible roles change. The hash will be re-populated with all requested data as soon as the items are shown again and the data(int) method of the model is called. Moreover, before the items are inserted into the model after filtering, we have to make sure that the sort role "Permissions"/"User"/etc. is present in the hash "values". This is achieved by factoring out the code that currently does this job for new items in createItemDataList() into a new function, and calling this in insertItems(), because the same treatment is required for the previously filtered files. BUG: 328791 FIXED-IN: 4.12.1 REVIEW: 114266
2013-10-07Make the code that removes items from KFileItemModel more robustFrank Reininghaus
When we remove items from the model, we called the function KFileItemModel::removeItems(const KFileItemList&, RemoveItemsBehavior). This function then looked up the indexes of the items using the hash m_items. This is wasteful in the situations when the indexes of the removed items are known in advance (like when an expanded folder is collapsed in Details View), and it can cause trouble if one item is contained in the model multiple times (can happen when searching, and a file both matches the search and is a child of a folder that matches the search). Even if expanding folders in the search results list might not be particularly useful most of the time, it makes sense to make the model more robust to prevent crashes and other unexpected behavior in such situations. This patch makes the following changes to achieve that goal: * Change the argument of removeItems() from KFileItemList to KItemRangeList. To make this work, the "look the indexes up in m_items" code is moved from that function to slotItemsDeleted(). In the other places where removeItems() is called, the indexes are calculated directly (which is not more difficult than determining the removed items as a KFileItemList, if one considers that we needed the function childItems(KFileItem) for that, which is not needed any more with this patch). * Also removeFilteredChildren() takes a KItemRangeList now. Rather than putting the parent KFileItems into a QSet for O(1) lookup (which prevents O(N^2) worst case behavior for the entire function), it uses a QSet<ItemData*> now, which should even be more efficient (hashing a pointer is cheaper than hashing a KFileItem/KUrl). BUG: 324371 BUG: 325359 FIXED-IN: 4.12.0 REVIEW: 113070
2013-10-01Merge remote-tracking branch 'origin/KDE/4.11'Frank Reininghaus
2013-10-01Add unit test for the calculation of "name" groups with expanded itemsFrank Reininghaus
This prevents a possible regression that would have happened with the first version of https://git.reviewboard.kde.org/r/112725/ The problem was that isChildItem(int index) would return "false" incorrectly when the QHash for that item was not initialized yet. The grouping code would then try to read the "text" from the empty QHash, which yielded an empty QString, and then accessing the first character of that string caused a crash.
2013-09-29Make sure that removeExpandedItems() also removes filtered itemsFrank Reininghaus
This fixes the problem that filtered child items in Details View may reappear when switching the view mode and the clearing the filter. BUG: 325344 REVIEW: 112962 FIXED-IN: 4.11.3
2013-09-09Merge remote-tracking branch 'origin/KDE/4.11'Frank Reininghaus
2013-09-09Always sort items correctly when the refreshItems() signal is receivedFrank Reininghaus
When sorting by, e.g., "Size", and the name is used as a fallback because there are multiple files with the same size, the refreshItems signal that is received when a file's name is changed either with the dialog or outside the current view did not cause the view to be resorted after commit d70a4811807776966c3241a72121242f4d1eaee8. This patch fixes it. BUG: 324713 FIXED-IN: 4.11.2 REVIEW: 112561
2013-09-09Merge remote-tracking branch 'origin/KDE/4.11'Frank Reininghaus
The most recent commit from the KDE/4.11 branch (new unit test) had to be modified slightly due to the changed signal emission when resorting the model changes only the groups, and not the order of the items (groupsChaged instead of itemsMoved).
2013-09-09Test if the groups are updated correctly when items are refreshedFrank Reininghaus
This unit test will hopefully prevent regressions in the future. It is the first part of https://git.reviewboard.kde.org/r/112561/.
2013-09-07Make expandedParentsCount() work without accessing the data hashFrank Reininghaus
The idea is that we no longer assume that the "expandedParentsCount" for each item will be stored in the QHash. It is only accessed for items which are expanded, and which are not top-level items (i.e., which have an expandedParentsCount > 1). Some unit tests are added to improve the coverage of the affected code. REVIEW: 112562
2013-08-15Merge remote-tracking branch 'origin/KDE/4.11'Frank Reininghaus
2013-08-15Make sure that the sort order is correct after renamingFrank Reininghaus
KFileItemModel::setData() should not only cause a resorting when the sort role is changed. The name is always used as a fallback if the sort role of multiple files is equal, therefore, renaming a file can change the correct order of the files even if the files are not sorted by "name". Unit test included. BUG: 323518 FIXED-IN: 4.11.1 REVIEW: 111721
2013-08-04Introduce a new signal "groupsChanged"Frank Reininghaus
Sometimes when items are renamed, the order of the items in the directory is not affected, but the groups still change (simple example: with files a, b, c, e, rename "c" to "d"). At the moment, we always emit the itemsMoved signal in such a case to make sure that the view is updated. However, it would be preferable if this signal was not emitted because it can trigger some quite expensive operations which are not needed at all. This commit introduces a new signal groupsChanged and modifies KFileItemModel and KItemListView such that these classes make use of it. Some unit tests for the new functionality are included as well. Thanks to Emmanuel Pescosta for finding a latent bug in the code which was triggered by this change and fixed in 998954db6d53999dfa75d380cbb4ca3111589f66. REVIEW: 111808
2013-08-04Add some unit tests for grouping in KFileItemModelFrank Reininghaus
Hopefully, this will prevent regressions in the future. REVIEW: 111807
2013-08-04Make KFileItemModelTest fasterFrank Reininghaus
The 500 ms timeout before items are resorted does not make much sense in the unit test. Removing this delay makes the test run much faster.
2013-06-20Merge remote-tracking branch 'origin/KDE/4.10'Dawit Alemayehu
2013-06-18Ensure that the "Sort by Type" setting is respectedFrank Reininghaus
Before this commit, switching from, e.g., "Sort by Name" to "Sort by Type" sometimes had no effect until the view was refreshed. The problem was that the re-sorting was triggered before the type information was actually added to the model. BUG: 310705 BUG: 312014 FIXED-IN: 4.10.5 REVIEW: 111004
2013-06-13Remove trailing white spaceFrank Reininghaus
2013-05-22Merge remote-tracking branch 'origin/KDE/4.10'Frank Reininghaus
2013-05-22Do not reset the 'isExpanded' state when an expanded folder is refreshedFrank Reininghaus
If an item is moved out of an expanded folder, the model receives the dir lister's refreshItems signal for the folder. The method retrieveData() then updates the folder's properties. This commit makes sure that the 'isExpanded' state is not touched by retrieveData(). A side-effect is that the 'isExpanded' role is not initialized to 'false', but this does not matter because trying to read a non-existing role from the QHash<QByteArray, QVariant> yields a default-constructed QVariant, which evaluates to 'false'. BUG: 299675 FIXED-IN: 4.10.4 REVIEW: 110401
2013-03-15Improve handling of filtered items when folders are deleted/collapsedFrank Reininghaus
If an expanded folder with filtered children is collapsed or removed, and the parent-child relationship cannot be determined by parsing the URLs, this patch makes sure that the filtered children do not reappear when the filter bar is cleared. REVIEW: 109455
2013-03-10Merge remote-tracking branch 'origin/KDE/4.10'Frank Reininghaus
Conflicts: dolphin/src/kitemviews/kfileitemmodel.cpp
2013-03-10Remove filtered children if the parent folder is collapsedFrank Reininghaus
This is analogous to commit e053ecdcd57cc39fdcbc314fc8dd22c8b9dbdd4f, which fixes the same problem for the case that the parent folder is deleted. BUG: 316335 FIXED-IN: 4.10.2 REVIEW: 109343
2013-02-27Big Thanks to Frank Reininghaus, who helped me a lot with theseEmmanuel Pescosta
changes! :) * Fixed the "Network browser" and "timeline" issues, by using the KDirLister's itemsAdded(KUrl,KFileItemList) signal -> Use the given Url to define the parent-child relationship. * Changed the name of the slot "slotNewItems" to "slotItemsAdded" for consistency with the signal. * Use a QHash<KFileItem, ItemData*> instead of a QSet<KFileItem> to store the filtered data (needed to keep the O(1) lookup for filtered KFileItems in slotItemsDeleted + needed to fix bug 311912 "After erasing a filter, some thumbnails randomly disappear") * Made the determination of the "expandedParentsCount" slightly simpler - just adding 1 to the parent's level (Also needed to fix the "Network browser" and "timeline" issues) FIXED-IN: 4.11.0 REVIEW: 109180 BUG: 304565 BUG: 311912 BUG: 312890 BUG: 315593
2013-02-19Merge remote-tracking branch 'origin/KDE/4.10'Frank Reininghaus
Conflicts: dolphin/src/tests/kfileitemmodeltest.cpp lib/konq/konq_operations.cpp
2013-02-18Remove items from m_filteredItems if their parent is deletedFrank Reininghaus
Fixes the problem that filtered children of expanded deleted folders reappear if the filter is cleared. BUG: 315210 FIXED-IN: 4.10.1 REVIEW: 108976
2013-02-10Re-organize the code that compares expanded itemsFrank Reininghaus
The previous approach, which was based on comparing the URLs as strings, was not only very complex, but also could lead to inconsistencies in the model, namely, that not all children were removed from the model when the dir lister reported the parent as deleted. Later on, this could even lead to a crash. BUG: 311947 FIXED-IN: 4.11 REVIEW: 108766
2013-02-10Include parent-child relationships in KFileItemModel's consistency checkFrank Reininghaus
2013-01-30Merge remote-tracking branch 'origin/KDE/4.10'Frank Reininghaus
Conflicts: dolphin/src/tests/kfileitemmodeltest.cpp
2013-01-30Add unit test for bug 314046Frank Reininghaus
The regression happened in the master branch only, but I think it doesn't hurt to add the test to the stable branch. CCBUG: 314046
2013-01-27Merge remote-tracking branch 'origin/KDE/4.10'Frank Reininghaus
Conflicts: dolphin/src/tests/kfileitemmodeltest.cpp
2013-01-27Move the consistency check for KFileItemModel from the test to the classFrank Reininghaus
This makes it possible to check the model's consistency also in other places, e.g., in KFileItemModel's benchmark.
2013-01-27Add a unit test for a recently fixed crashFrank Reininghaus
Before commit 90c7fd400c34e6d4d583c54c04631856c387d359, adding a KFileItem with an empty path caused a crash in KFileItemModel::expandedParentsCountCompare().
2012-10-30Fix some indentation issuesFrank Reininghaus
2012-06-08Krazy fixesPeter Penz
2012-05-26Use an italic font for symbolic linksFrank Reininghaus
BUG: 298218 FIXED-IN: 4.9.0
2012-04-21Prepare view-engine for non-KFileItem usecasePeter Penz
Up to now the view-engine only provided a model-implementation that supports file-items. The view-engine always had been designed to be able to work with any kind of model, so now a KStandardItemModel is available. The plan is to convert the places panel to the new view-engine. It should be no problem to fix this until the feature freeze - in the worst case the places-panel code could be reverted while still keeping the KStandardItemModel changes.
2012-04-11KFileItemModel: interface cleanupsPeter Penz
Fix some naming inconsistencies regarding the usage of 'dir' vs. 'directory' vs. 'folder'.
2012-04-11KItemViews: Internal directory restructurationPeter Penz
- Move all private headers from the kitemviews-directory into the 'private' subdirectory. - Get rid of DolphinDirLister and just use a directory-lister internally in KFileItemModel. - Minor interface-cleanups for signals
2012-03-20Fix sorting-issue when "Sort folders first" is disabledPeter Penz
The comparison of expanded trees may not assume that directories are always sorted first and must respect the "Sort folders first" setting. The sorting-unittest has been extended by a sub-tree and the usecase of bug 296437. The already deactivated test for KFileItemModel::expandedParentsCountCompare() has been completely removed as it has been replaced by testSorting(). BUG: 296437 FIXED-IN: 4.8.2
2012-03-20KFileItemModel: Remove minimum-update timerPeter Penz
The timer became unnecessary after introducing the behavior to collect all new items until KDirLister emits a completed()-signal.
2012-02-23Whitespace cleanups and documentation fixesPeter Penz
2012-02-14Details view: Fix indicator-branchesPeter Penz
Up to now no indicator-branches have been drawn when showing a tree. The patch fixes this so that that the style-dependent branches are drawn. The main part of the patch is the implementation of KItemListView::updateSiblingsInformation(). Most of the other changes are related due to an internal renaming of the expansionsLevel-role to expandedParentsCount and some related cleanups. BUG: 290276 FIXED-IN: 4.8.1
2012-02-05Replace setExpanded(const QSet<KUrl>&) by expandParentItems(const KUrl&)Frank Reininghaus
The use case of this function (Folders Panel) requires the expansion of the parent items of a single URL, so it's not needed to handle a full set of URLs in this function. Moreover, the issue that not only the parents, but also the URLs themselves were expanded is fixed by this commit. (cherry picked from commit 89082ca391807abdc26d8985efe6b4c27183a9b1)
2012-01-05Temporary skip 2 unit-tests in KFileItemModelPeter Penz
KFileItemModel::resortAllItems() always emits a itemsMoved() signal since some time. Before blindly adjusting the tests lets discuss first whether resortAllItems() should be used in this context.
2011-12-23Introduce "isExpandable" rolePeter Penz
The role is used to determine whether a directory can be expanded at all. This is e.g. not the case if a directory has 0 items or the target-URL is different from the item-URL. The expansion toggle will get hidden if a directory is not expandable. CCBUG: 288521
2011-12-14Improve private method KFileItemModel::expansionLevelsCompare()Peter Penz
Get rid of the hack to access the m_itemData member for getting the parent of an item during sorting. ItemData has been extended by a parent-member which allows a fast and save way to do this. Sadly this makes the unit-test for expansionLevelsCompare() more complex and it has been temporary deactivated. I'll take care to fix this during the next week.
2011-12-04Fix crash #1 when filtering itemsPeter Penz
When filtering items it was possible that the current index got an invalid value which resulted in accessing the URL of a null-KFileItem. There is still one (general) open issue in KFileItemModelRolesUpdater (crash #2) where a KFileItem that is already null gets read. It is not really related to filtering but can be triggered quite easy when filtering huge directories with enabled previews. CCBUG: 287642