┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemmodel.cpp
AgeCommit message (Collapse)Author
2016-03-16[CLAZY] Fixed all level 1 and level 2 warnings with small exceptionsArtur Puzio
REVIEW: 126771
2016-03-16Add case sensitive sorting modeArnav Dhamija
Dolphin users can now choose between 3 different sorting modes: * natural sorting * case insensitive sorting * case sensitive sorting REVIEW: 126467 BUG: 148550 FIXED-IN: 16.04.0
2016-02-09Support KFileMetadata OriginUrl as "Downloaded From"Kai Uwe Broulik
This brings back the functionality to show where a file originally was downloaded from using xattr originUrl. REVIEW: 126927
2015-04-23Enable translation scripting for date groupsLasse Liehu
This allows to work around limitations in Qt's date formatting. Examples: * Uppercasing the first character in a string because it's a title: Day of the week and month names returned by QDateTime::toString are usually lowercase. * Correcting the noun case of a month name from "of [month]" to "in [month]" in Finnish: "of [month]" is correct when talking about a specific day, but wrong when talking about a specific month. REVIEW: 123278
2015-04-23Rewrap lines in KFileItemModel::dateRoleGroupsLasse Liehu
Now they are under 100 characters.
2015-02-24Replace kDebug/kWarning by categorized logging (org.kde.dolphin)Emmanuel Pescosta
2015-02-20Fix a QDateTime porting bug (different format expressions) in ↵Emmanuel Pescosta
KFileItemModel::dateRoleGroups REVIEW: 122625
2015-02-06Fix includesMontel Laurent
2015-01-31Port away from KGlobalSettings::naturalSorting() by moving it to Dolphin's ↵Emmanuel Pescosta
GeneralSettings REVIEW: 122310
2015-01-04Fix for crash which was introduced by commitEmmanuel Pescosta
c2a0d3e889666539669562a6c1f7a080a0f29b11 (use QCollator instead of KStringHandler) REVIEW: 121817 BUG: 342316
2014-12-17Port from KStringHandler naturalCompare to QCollator compare.Emmanuel Pescosta
Make use of the QCollator instance (m_collator) in nameRoleGroups instead of using QString::localeAwareCompare (uses QCollator internally) We don't need the m_caseSensitivity anymore, because the QCollator instance also holds this information. (This patch doesn't make use of QCollatorSortKey) Reviewed by Kai REVIEW: 121480
2014-10-21port Dolphin from KUrl to QUrlLukáš Tinkl
REVIEW: 120688
2014-10-21port Konqueror from KUrl to QUrlLukáš Tinkl
REVIEW: 120650
2014-10-18Fix includesMontel Laurent
2014-10-18Fix includesMontel Laurent
2014-06-29Merge remote-tracking branch 'origin/master' into frameworksFrank Reininghaus
Conflicts: dolphin/src/dolphinmainwindow.cpp dolphin/src/dolphinmainwindow.h
2014-06-29Remove the automoc noiseChristophe Giboudeaux
2014-06-19Implement TODO concerning changed rolesFrank Reininghaus
When emitting the itemsChanged signal in KFileItemModel::setRoles, use the changed roles in the argument of the signal. A warning message which was related to this issue was removed in 7a83252e0d919d8408e0808ccbd7b401d57444d3 REVIEW: 118815
2014-06-19Remove confusing warning messageFrank Reininghaus
The message "TODO: Emitting itemsChanged() with no information what has changed!" is not helpful for the user. The implementation of the TODO will be done in master, see https://git.reviewboard.kde.org/r/118815/ CCBUG: 336174
2014-06-05Merge remote-tracking branch 'origin/master' into frameworksFrank Reininghaus
2014-06-04Fix possible crash if a kioslave adds multiple items with the same URLFrank Reininghaus
When opening the URL "man:", there are multiple items with the same name (for example, _exit is shown twice here). When opening a new tab, the kioslave reports some items as deleted (I have not quite understood why). The problem is that it reports some of the duplicate items twice in the list of deleted items. This confused KFileItemModel and corrupted the internal data structures, and finally, caused a crash. The fix is to remove all duplicates from KItemRangeList::fromSortedContainer(const Container& container). New unit tests included. BUG: 335672 REVIEW: 118507 FIXED-IN: 4.13.2
2014-05-21Merge remote-tracking branch 'origin/master' into frameworksFrank Reininghaus
Conflicts: dolphin/src/search/filenamesearchprotocol.cpp
2014-05-13Stop listing children of collapsed foldersFrank Reininghaus
Before this patch, KDirLister would continue listing any children of collapsed folders, even though the children themselves were removed from the model. This could lead to new items being inserted as top-level items at some later point, because no parent could be found for them. This inconsistent model state could lead to a crash later on. Many thanks to Martin Koller for helping to debug this problem! BUG: 332102 REVIEW: 118055 FIXED-IN: 4.13.2
2014-05-13Ensure that all children of a collapsed folder are removedFrank Reininghaus
Before this patch, any (direct or indirect) children that might have been in m_pendingItemsToInsert, i.e., that were not inserted into the model yet because KDirLister had not finished listing the directory yet, would be added to the model later without a proper parent. This could cause a crash later on. CCBUG: 332102 FIXED-IN: 4.13.2
2014-05-13Merge remote-tracking branch 'origin/master' into frameworksFrank Reininghaus
Since the master branch had never been merged into frameworks since the creation of the frameworks branch, I had to fix a couple of merge conflicts and make another change in order to make it build - I hope I did not get anything wrong. We should probably merge master into frameworks on a regular basis from now on. CCMAIL:[email protected] Conflicts: dolphin/src/dolphinmainwindow.cpp dolphin/src/search/dolphinfacetswidget.cpp dolphin/src/statusbar/dolphinstatusbar.cpp dolphin/src/views/dolphinview.cpp
2014-05-05dolphin: convert kitemviews/ to qt5 signal slot syntaxAlex Richardson
This conversion was performed automatically using convert2qt5signalslot. The only manual changes required were changing the overloaded signal KDirLister::redirection and KDirLister::completed from KUrl to QUrl. All other cases were no problem since these signals are not overloaded and a static_cast for disambiguation is not necessary. Code inside HAVE_BALOO is not converted yet, will do that once I can build a version with Baloo.
2014-05-05Allow compiling Dolphin with KF5Alex Richardson
This does not work properly yet, there are probably quite a few bad signal/ slot connections due to KUrl -> QUrl. However dolphin starts without crashing. Accessibility is not ported since that changed quite a lot from Qt4 -> Qt5 and I have no idea how it is supposed to be used. This is the first commit for review 117395
2014-04-24Scroll to the right position when going back and show hidden files is enabled.Emmanuel Pescosta
Instead of emitting the directoryLoadingCompleted signal (via slotCompleted) in KFileItemModel::setShowHiddenFiles directly, we now call dispatchPendingItemsToInsert instead. @Frank: Thanks for your help! FIXED-IN: 4.13.1 BUG: 332159 REVIEW: 117021
2014-02-11Remove some unused functions.Emmanuel Pescosta
void KFileItemModel::slotClear(const KUrl& url) bool UpdateItemsThread::lockPlugin() <- Done with QMutexLocker void UpdateItemsThread::unlockPlugin() REVIEW: 115627
2014-02-07Only initialize the hash m_items in KFileItemModel if it is neededFrank Reininghaus
Moreover, clear the entire hash if items are added or removed. This saves time and memory when loading a directory, and it fixes problems that might occur if the model is in an inconsistent state, such as crashes that can happen when we try to remove individual items from m_items. BUG: 329494 FIXED-IN: 4.13.0 REVIEW: 115432
2014-02-06Port Dolphin to BalooVishesh Handa
Nepomuk is being replaced with Baloo
2013-12-22Merge remote-tracking branch 'origin/KDE/4.12'Frank Reininghaus
2013-12-22Fix crash when dragging children of expanded folders in Details ViewFrank Reininghaus
The problem was that the loop in KFileItemModel::createMimeData() which is supposed to find out if any parent of an item has been added to the QMimeData already (because it is not necessary to add the item in that case) did not loop through the parents of the item, but incorrectly replaced the local variable 'itemData' by its parent. BUG: 329119 REVIEW: 114562
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-12-06Make KFileItemModel::createMimeData() fasterFrank Reininghaus
Moreover, this commit ensures that the order of the URLs in the QMimeData object is the same as the order of the items in the view. Selecting many items and copying them to the clipboard could take quite a bit of time. This is because we used KDirModel::simplifiedUrlList(urls) to remove child items from the list of URLs, and this function sorts the URLs internally to make it easier to find out which of them are child URLs. However, since commit 5c5d87fec44e7c5934e4b24060200173153f0ff4, the selected indices are already stored in ascending order, and this makes it easy to detect if an item is a child of the last item that has been added to the QMimeData. BUG: 283409 REVIEW: 113515 FIXED-IN: 4.13.0
2013-11-05Only do a fast pre-sorting when "Sort by Name" is usedFrank Reininghaus
This is a follow-up to commit 0e9f4a398735cfc19ae783d2ab054d2400d95416, which tries to speed up sorting the items naturally by their name using the idea that a fast non-natural pre-sorting already sorts the items mostly correctly and thus reduces the number of expensive natural comparisons. This change only makes sense if the view is really sorted by "Name". In other cases, the pre-sorting will most likely not be useful. Thanks to Christoph Feck for pointing this out!
2013-10-30Store the selected items in a more efficient wayFrank Reininghaus
Since Dolphin 2.0, we have stored the selected items in a QSet<int>, which is neither space-efficient nor particularly fast when inserting many items which are in a consecutive range. This commit replaces the QSet<int> by a new class "KItemSet", which stores the items in a sorted list of ranges. For each range, we only store the first index and the length of the range, so we need a lot less memory for most common selection patterns, and we also save quite a few CPU cycles in many situations, because adding an item to the KItemSet will in many cases not need a memory allocation at all, and it's particularly easy when inserting sorted items into the KItemSet in a row. KItemSet contains a minimal subset of QSet's API which makes it suitable as a drop-in replacement for our needs. It also has iterators, such that the items can be iterated through easily, also with foreach. One advantage of KItemSet compared to QSet<int> is that the items are always iterated through in ascending order. REVIEW: 113488
2013-10-30Sort in items in two stages to speed up natural sortingFrank Reininghaus
Sort the items in a folder first according to their name, without doing a natural/locale-aware sorting. This is very fast, but the order of the items is then already close to the final order in most cases. The number of expensive natural comparisons required to sort the items is thus greatly reduced. In my experiments with a folder with 100,000 items, the time required to sort the files was reduced by 63% with this patch. REVIEW: 113485
2013-10-26Restore the tree state in Details View if a folder is re-expandedFrank Reininghaus
This patch actually does two things when collapsing an expanded folder with expanded children: (a) It removes all expanded children (which are removed from the model) from m_expandedDirs. (b) It remembers the expanded children and restores them if the top-level folder is re-expanded. BUG: 304363 FIXED-IN: 4.12.0 REVIEW: 113293
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-02Save memory and time in KFileItemModel by lazy-loading the "ItemData"Frank Reininghaus
To reduce unnecessary memory comsumption and CPU usage, we only fill the QHash<QByteArray, QVariant> if the methods data(int) or setData(int) are called for the corresponding index, or the data is necessary for sorting the model. According to my tests, this patch reduces the memory usage when loading a folder with 100,000 items by 17% in Icons View, and by 26% in Details View. REVIEW: 112725
2013-10-01Merge remote-tracking branch 'origin/KDE/4.11'Frank Reininghaus
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-17Move KItemRange to its own headerFrank Reininghaus
Also factor out the code that transforms a sorted list of ints to a KItemRangeList. This removes some duplicated code from KFileItemModel. Note that overriding operator<<() in KItemRangeList was necessary because it's not a typedef for QList<KItemRange>, but a class derived from that now, and some code fails to compile if the return type of that function is QList<KItemRange> and not KItemRangeList. REVIEW: 112728
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-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-24Merge remote-tracking branch 'origin/KDE/4.11'Frank Reininghaus
2013-08-24Make determining the mime type faster for foldersFrank Reininghaus
KFileItem::determineMimeType() not only determines the mime type, but also the icon. For folders, it looks for a .directory file inside the folder, where a custom icon might be stored. This can take quite a bit of time and cause the problem that some folder's type still appears to be "unknown" when the view is shown. We can work around this problem by caching the folder mime type in a static QString and applying to to all folders, which can be identified easily with KFileItem::isDir(), BUG: 321710 FIXED-IN: 4.11.1 REVIEW: 111830