Commit graph

723 commits

Author SHA1 Message Date
Frank Reininghaus 545d872b81 Merge remote-tracking branch 'origin/KDE/4.12' 2013-12-22 13:20:02 +01:00
Frank Reininghaus 2e4991d5f0 Fix crash when dragging children of expanded folders in Details View
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-22 13:17:05 +01:00
Frank Reininghaus d5d1ae124a Update filtered items when the "refreshItems" signal is received
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-22 12:50:14 +01:00
Frank Reininghaus 8210d5e472 Update the roles for filtered items if necessary
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-14 11:51:07 +01:00
Frank Reininghaus 2619cc1c3d Merge remote-tracking branch 'origin/KDE/4.12' 2013-12-06 01:36:42 +01:00
Frank Reininghaus 6e36733058 Make KFileItemModel::createMimeData() faster
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 5c5d87fec4, 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-12-06 01:22:39 +01:00
Frank Reininghaus 03f8c373c5 Lazy-load the item data also in Compact View
The recent changes which prevent that all data for each item are saved
in a QHash already when loading the folder (see
https://git.reviewboard.kde.org/r/112725/), which save both memory and
time, do not work yet in Compact View, because
KItemListWidgetInformant::itemSizeHint() calls the model's data(int)
method for every item, which then initializes the hash.

This patch prevents that by accessing the file name directly if only
the "Name" is shown in the view, just like it's done in Icons View.

REVIEW: 113849
2013-12-02 23:14:39 +01:00
Frank Reininghaus 92cb6b3a18 Merge remote-tracking branch 'origin/KDE/4.11' into KDE/4.12 2013-11-21 00:51:08 +01:00
Yichao Yu c3ad6c7406 Fix incorrect geometry updates in KItemListContainer
When resizing the window and when KItemListContainer::updateGeometries
is called before the scrollbar visibility is updated, a relayout is
triggered in `m_controller->view()->setGeometry` which updates the
scrollbar visibility and calls back to
`KItemListContainer::updateGeometries` again. Since the first call,
which has the wrong geometry (due to the incorrect scrollbar states),
updates the geometries of the scene and viewport after the second call
(which has the right geometry!!) returns, the final result is a size
that corresponded to the old scrollbar state before this commit.

This patch uses the new geometry of the view after updating it (since
it might not be the size we put in) and therefore makes the sizes
consistent.

BUG: 327709
FIXED-IN: 4.11.4
REVIEW: 113939
2013-11-21 00:47:40 +01:00
Frank Reininghaus d0b98ba085 Merge remote-tracking branch 'origin/KDE/4.11' into KDE/4.12 2013-11-18 23:44:45 +01:00
Yichao Yu c89cd8e789 Fix scrollbar spacing when no scrollbar is visible in dolphin.
Before this commit, Dolphin reserved space for the scrollbar spacing
even when no scrollbar is visible resulting in a ugly gap in the view
when:

1. the theme uses QStyle::SH_ScrollView_FrameOnlyAroundContents and
2. the theme has a positive PM_ScrollView_ScrollBarSpacing.

QtCurve can have both while Oxygen have 1 but not 2.
To reproduce the problem with Oxygen style. Replace the
`width += ....` (which returns -2 or 0 for Oxygen) with `width += 2`.

See more info here:
https://github.com/QtCurve/qtcurve-qt4/issues/9#issuecomment-28630517

CCBUG: 306631
FIXED-IN: 4.11.4
REVIEW: 113902
2013-11-18 23:40:45 +01:00
Frank Reininghaus 980846ab36 Merge remote-tracking branch 'origin/KDE/4.11' into KDE/4.12 2013-11-14 09:14:51 +01:00
David Rosca c5ba8a56e7 Do not select items when navigating back/forward with the mouse
If we detect that the user pressed the back/forward buttons while
hovering the empty space of the view, such that
DolphinView::slotMouseButtonPressed(int, Qt::MouseButtons) will request
that Dolphin navigates back/forward in the history, handling the mouse
press event should stop. This prevents the possible unexpected selection
of items in the new directory.

BUG: 327412
FIXED-IN: 4.11.4
2013-11-14 09:08:29 +01:00
Frank Reininghaus 971aa67665 Only do a fast pre-sorting when "Sort by Name" is used
This is a follow-up to commit 0e9f4a3987,
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-11-05 08:44:31 +01:00
Frank Reininghaus fc2ab47898 Store the selected items in a more efficient way
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-30 23:22:23 +01:00
Frank Reininghaus 903381a898 Sort in items in two stages to speed up natural sorting
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-30 17:48:42 +01:00
Frank Reininghaus e518cea0cf Prevent storing some redundant data in KItemListViewLayouter
In KItemListViewLayouter, we have always stored a QRectF for each item,
which is "the area that the item occupies". However, the size of the
QRectF is already stored in the size hint resolver.

Therefore, it is sufficient to store the position of the top left
corner of the QRectF in a QPointF and construct the QRectF on demand.

This patch reduces the memory usage by 16 bytes for each item in the
view:

* a QRectF is 4 doubles -> 32 byes
* a QPointF contains only 2 doubles -> 16 bytes

REVIEW: 113487
2013-10-30 17:40:23 +01:00
Frank Reininghaus 5a019aec3a Restore the tree state in Details View if a folder is re-expanded
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-26 09:36:50 +02:00
Frank Reininghaus 76ae282ad9 Two small simplifications in KItemListViewLayouter
1. Remove the unneeded variable rowCount.

2. Simplify the calculation of the member m_maximumScrollOffset. We can
   just use the current value of "y" because this is the offset that
   the next row would have.

REVIEW: 113233
2013-10-16 23:02:06 +02:00
Frank Reininghaus 77fd0e771a Abort loading the current URL if the user presses Escape
BUG: 323181
FIXED-IN: 4.12.0
REVIEW: 113234
2013-10-16 22:39:47 +02:00
Emmanuel Pescosta 2114210905 Use the icon size from KItemListStyleOption for the width and height of the
expansion area instead of KIconLoad::SizeSmall.

BUG: 325543
REVIEW: 113169
FIXED-IN: 4.12
2013-10-09 19:52:53 +02:00
Frank Reininghaus b4efdc620e Merge remote-tracking branch 'origin/KDE/4.11' 2013-10-07 09:31:45 +02:00
Frank Reininghaus 9f24c02a75 Make the code that removes items from KFileItemModel more robust
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-07 09:26:51 +02:00
Frank Reininghaus 46a27ca937 Include "Space" in the keyboard search string
Before this commit, we only added pressed keys to the search string if
they have no other meaning. This means that files containing a Space in
their name could not be searched because Ctrl+Space toggles the
selection state of the current item, and Space alone selects the
current item.

After this commit, Space is added to the search string if

(a) the key press did not have any other effect, i.e., if Ctrl was not
    pressed, and the current item is selected already, and
(b) a keyboard search has been started already (to prevent unexpected
    effects when pressing Space accidentally - I think that it's rather
    uncommon to have files whose names start with a Space - and to make
    the unit test simpler).

I modified the unit test of KItemListController, which did not test
keyboard search yet. This uncovered a small problem in
KItemListController::slotChangeCurrentItem() when NoSelection mode is
used. It's not really relevant for anything that is executed inside
Dolphin, but I still fixed it to make the unit test happy.

BUG: 324479
FIXED-IN: 4.11.3
REVIEW: 113071
2013-10-07 09:09:00 +02:00
Frank Reininghaus ae587d2682 Save memory and time in KFileItemModel by lazy-loading the "ItemData"
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-02 19:08:39 +02:00
Frank Reininghaus 926782d3be Merge remote-tracking branch 'origin/KDE/4.11' 2013-10-01 00:15:04 +02:00
Frank Reininghaus 08710b05c7 Make sure that removeExpandedItems() also removes filtered items
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-29 15:45:14 +02:00
Frank Reininghaus 4a093f956b Move KItemRange to its own header
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-17 00:11:42 +02:00
Frank Reininghaus 083248d16b Merge remote-tracking branch 'origin/KDE/4.11' 2013-09-14 15:11:17 +02:00
Frank Reininghaus ced472be07 Make preview loading faster when scrolling
KFileItemListView notifies KFileItemModelRolesUpdater of changes of the
visible index range and the icon size with a delay, to prevent that
expensive operations are triggered repeatedly, and that scrolling feels
sluggish because the GUI thread is blocked by icon loading.

This patch ensures that the "long" delay of 300 ms is only used when
the zoom level is changed, and the "short" delay if only the visible
index range has changed.

Thanks to Christoph Feck for helping to analyze this problem!

BUG: 322093
FIXED-IN: 4.11.2
REVIEW: 112580
2013-09-14 14:59:50 +02:00
Emmanuel Pescosta 88a7794097 Fix Bug 311099 - View the underscore when using Ctrl + PagDown
Take the style option vertical/horizontal margin into account
for the calculation of the new scroll offset.

Thanks to Frank for pointing out two other problems with "Page Up/Down" and providing
a better way to fix these problems. :)

BUG: 311099
FIXED-IN: 4.11.2
REVIEW: 112678
2013-09-12 13:58:29 +02:00
Frank Reininghaus e03a687c92 Merge remote-tracking branch 'origin/KDE/4.11' 2013-09-09 21:43:29 +02:00
Frank Reininghaus 4416377eae Always sort items correctly when the refreshItems() signal is received
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 d70a481180. This patch fixes
it.

BUG: 324713
FIXED-IN: 4.11.2
REVIEW: 112561
2013-09-09 21:38:47 +02:00
Frank Reininghaus 7e30467679 Make expandedParentsCount() work without accessing the data hash
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-09-07 18:06:53 +02:00
Emmanuel Pescosta 1848854c6d Nothing special, just a little bit of code cleanup in KItemListViewLayouter::doLayout().
Make use of QSizeF::transpose() and simplify the m_itemInfos usage.

REVIEW: 112535
2013-09-05 17:03:04 +02:00
Frank Reininghaus 4bfc28cb4b Count the items inside directories in another thread
This prevents that the GUI freezes if there are many files inside the
directory, or if the access to the directory is slow for some other
reason.

BUG: 318518
REVIEW: 111920
FIXED-IN: 4.12.0
2013-09-04 21:50:16 +02:00
Frank Reininghaus 8f7c3619ec Try to avoid calling the model's data method if only "text" is needed
Currently, KStandardItemListWidgetInformant::itemSizeHint() calls the
model's data(int) method for every single item, but the full data is
actually only needed for the size calculation in Compact View. In
Details View, no data is needed at all to determine the size required
for the item, and in Icons View, only the name is needed.

This patch makes it possible for subclasses of
KStandardItemListWidgetInformant to provide an alternative way to
obtain the "text", and implements this in the subclass
KFileItemListWidgetInformant.

The final goal is to achieve that the QHash which contains all data
for a file item is only created if it is really needed, e.g., because
the view needs access to the data for displaying the item on the
screen.

REVIEW: 112253
2013-09-04 21:37:01 +02:00
Frank Reininghaus cba24825c9 Merge remote-tracking branch 'origin/KDE/4.11' 2013-08-25 19:17:25 +02:00
Christoph Feck 092c820023 Move cursor to begin/end of selection before canceling it
Makes Left/Right keys consistent with QLineEdit behavior.

BUG: 323946
FIXED-IN: 4.11.1
REVIEW: 112256
2013-08-25 17:40:49 +02:00
Frank Reininghaus f830e1179c Fix filename trucation issues in Icons View with maximum number of lines
When the name of a file is too long to be shown inside the maximum
number of lines, the last line is elided. However, there were several
problems before this commit:

(a) "lastTextLine", which contains the text to be elided, was not
    assigned the complete remaining text, but only the part that would
    be put into the last line if there were more lines following. This
    may be less than what would fit into the line because we try to not
    break the text at random points.

(b) QFontMetrics::elidedText() was not given the width that is available
    for the last line (that would be maxWidth), but only the width that
    would be occupied by the text if there were more lines following
    (line.naturalTextWidth()).

(c) The variable "nameWidth", which is required to calculate the QRectF
    that is reserved for the name, was not updated correctly.

The result is that the text was sometimes trucated too early (especially
if there would be a line break early in the text if we had more lines
available), that there may be insufficient space to show the "...", and
that the hover/selection rectangle might be too narrow.

BUG: 304558
BUG: 321882
FIXED-IN: 4.11.1
REVIEW: 112265
2013-08-25 16:27:36 +02:00
Emmanuel Pescosta 2bdce34fe1 Adjust the size and position of the selection toggle on icon
resize (when changing the zoomlevel).

BUG: 310412
REVIEW: 112250
FIXED-IN: 4.11.1
2013-08-24 21:00:26 +02:00
Frank Reininghaus ebfcb5e19b Merge remote-tracking branch 'origin/KDE/4.11' 2013-08-24 20:27:30 +02:00
Frank Reininghaus 7ffa66f777 Make determining the mime type faster for folders
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
2013-08-24 20:22:56 +02:00
Frank Reininghaus d7997f16a7 Delay the deletion of the role editor as long as possible
This should prevent crashes that can be caused if the view is closed in
a nested event loop that is run from the role editor.

BUG: 322969
FIXED-IN: 4.11.1
REVIEW: 111988
2013-08-24 20:06:11 +02:00
Emmanuel Pescosta efdef7e40c Make use of the "resort all items timer" in KFileItemModel::slotRefreshItems
to avoid too much expensive resorting calls, in case of many refresh items signals.

Followup to patch 111146

CCBUG: 303873
CCBUG: 299565
BUG: 323789
FIXED-IN: 4.11.1
REVIEW: 111195
2013-08-24 18:13:56 +02:00
Emmanuel Pescosta edcc9d5cee Replaced the loop to fill m_sizeHintCache with QSizeF() by a simple m_sizeHintCache.fill() in KItemListSizeHintResolver::clearCache().
REVIEW: 112179
2013-08-24 18:03:40 +02:00
Frank Reininghaus 6bfa0ccfc7 Merge remote-tracking branch 'origin/KDE/4.11' 2013-08-15 00:15:51 +02:00
Frank Reininghaus 7c99a9c2ad Make sure that the sort order is correct after renaming
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-15 00:07:43 +02:00
Frank Reininghaus 59723fca41 Do not store default values in QHash<QByteArray, QVariant>
Storing values which are equivalent to default-constructed QVariants
does not make much sense because QHash::value returns the same value
even if the corresponding key is not found in the hash.

This commit reduces Dolphin's memory consumption in large folders by
up to 7.3% (tested a folder with 100,000 files in Details View) and
reduces the time required for loading a folder.

BUG: 323517
FIXED-IN: 4.11.1
REVIEW: 111922
2013-08-14 23:57:51 +02:00
Frank Reininghaus fd5ba3b4b2 Fix slow scrolling when hidden files or symbolic links are shown
The problem was that we drawed the overlays using KIconLoader, which can
be very slow, every time an item appeared on the screen. This commit
makes sure that not only the icon, but the icon including overlays is
cached in QPixmapCache. Therefore, the overlay drawing is done just once
for each icon+overlays combination.

For previews, the overlay drawing is done in KFileItemModelRolesUpdater
just after the preview is received.

BUG: 310662
BUG: 314339
FIXED-IN: 4.11.1
REVIEW: 111956
2013-08-14 23:44:57 +02:00
Frank Reininghaus 7e5b7d5626 Fix crash when disabling "Show in groups"
The problem was that items are removed from m_visibleGroups while
a QMutableHashIterator iterates over this hash, such that the iterator
can become invalid. The solution is to use a QHashIterator instead,
which takes a copy of the hash. Therefore, it is not affected if
m_visibleGroups is modified in any way.

BUG: 323248
FIXED-IN: 4.11.1
REVIEW: 111919
2013-08-14 23:40:02 +02:00
Frank Reininghaus 6524bf701a Introduce a new signal "groupsChanged"
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
998954db6d.

REVIEW: 111808
2013-08-04 22:20:37 +02:00
Frank Reininghaus bedf1db916 Fix possible out of range error inKItemListSizeHintResolver::itemsMoved
The function assumes implicitly that the moved range always starts with
the index 0. This is indeed the case at the moment, but it might make
sense to change that in the future. This commit prevents that we get an
out of range problem then.

Thanks to Emmanuel Pescosta for finding this problem, see
https://git.reviewboard.kde.org/r/111808/
2013-08-04 21:46:08 +02:00
Frank Reininghaus 8552eb5d75 Merge remote-tracking branch 'origin/KDE/4.11' 2013-07-29 23:16:58 +02:00
Frank Reininghaus 15107c780c Do not convert a KUrl to a QString and back again
This small change saves a lot of CPU cycles when the items are resorted.

REVIEW: 111700
2013-07-28 23:36:43 +02:00
Frank Reininghaus 611c935e03 Merge remote-tracking branch 'origin/KDE/4.11' 2013-07-25 22:35:37 +02:00
Frank Reininghaus 55a989626d Fix maximum value for scroll bar when deleting items in Details View
The problem was that the view heigt minus the header height was
subtracted from maximumScrollOffset() to determine the maximum value
of the scroll offset of the top of the view.

However, the top of the view is the part that is hiden behind the
header. Therefore, the full view height must be subtracted from
maximumScrollOffset.

The remaining bits of bug 319951 were fixed by other recent commits.

Thanks to Emmanuel Pescosta for helping to track down the problem!

BUG: 319951
FIXED-IN: 4.11.0
REVIEW: 111486
2013-07-25 22:25:18 +02:00
Frank Reininghaus 08c2f7f5fb Prevent that removing items can cause icons to overlap
When items are removed, new items may become visible because of that.
This includes

(a) Items *behind* the removed range. KItemListView may try to create
    their widgets at their "imaginary" old positions and move them to
    the new position with an animation.

(b) Items *before* the removed range, if the deletion causes the view
    to scroll up. In that case, the "imaginary" old position and the new
    position was equal, but KItemListView still tried to determine the
    "old" position by adding the number of removed items to the index.
    The result was that the widgets were created at completely wrong
    positions, and no animation was started to fix this.

Thanks to Emmanuel for helping to find the cause of this bug!

BUG: 302373
FIXED-IN: 4.11.0
REVIEW: 111630
2013-07-25 22:15:19 +02:00
Frank Reininghaus 3991e9d24e Make sure that widgets are initialized when changing the view mode
The problem was that DolphinItemListView overrides the virtual function
onItemLayoutChanged() without calling the base class implementation.
Therefore, KStandardItemListView::updateLayoutOfVisibleItems(), which
calls initializeItemListWidget(), is never called.

This patch refactors the "change item layout"/"supports item expanding"
code a bit to make it more robust and fix the problem that the view
looks "messed up" when switching from Details View without expandable
folders to Icons View.

I'm only pushing this patch to master (going to be KDE 4.12).
The patch is a bit too intrusive for the KDE/4.11 branch for my taste
at this point of the release cycle, and the bug is not a real
showstopper. If it works well in master, one could consider backporting
it to a 4.11.x bug fix release.

Thanks to Emmanuel Pescosta for helping to analyze this issue.

BUG: 302703
REVIEW: 111632
FIXED-IN: 4.12.0
2013-07-24 22:31:48 +02:00
Frank Reininghaus 0ad86983f4 Do not try to smooth-scroll past the end of the view
KItemListSmoothScroller::scrollTo(qreal position) did not check if
'position' is a valid value. Even if the view is scrolled to the bottom
already, it tried to scroll further and activated "smooth scrolling"
when the mouse wheel is used. Because it never got out of the "smooth
scrolling" state then, it got confused when changing the directory, and
restoring the correct scroll offset could fail.

BUG: 322212
FIXED-IN: 4.11.0
REVIEW: 111557
2013-07-22 19:16:07 +02:00
Frank Reininghaus 9d6d998a51 Fix "truncated header" in Details View with non-Oxygen styles
The code for painting the "empty header" was inconsistent with the
headers of the other columns, which is probably the reason why the other
styles got confused

a) No QStyleOptionHeader is used
b) Even if an empty header must be drawn, the last column is drawn with
   the option QStyleOptionHeader::End.

According to Christoph, it still doesn't work with the Skulpture style,
but it seems that the patch does at least not make things worse.

BUG: 301800
FIXED-IN: 4.11.0
REVIEW: 111608
2013-07-22 19:04:14 +02:00
Frank Reininghaus 0f853681ab Fix build if HAVE_NEPOMUK is not defined
We really have to make nepomuk-core and nepomuk-widgets a hard
dependency in the framworks era.
2013-07-18 22:51:21 +02:00
Emmanuel Pescosta aa2dda8cb4 Overwrite the changed role value with an empty QVariant,
because the nepomuk roles provider doesn't overwrite it when the property
value list is empty.

BUG: 322348
REVIEW: 111505
FIXED-IN: 4.11.0
2013-07-18 17:07:34 +02:00
Frank Reininghaus 63b26cbf2c Load unknown icons for items just before showing items in the view
Rather than loading many icons (without full mime type determination)
in advance, we make sure that an item has an icon just before it is
shown in the view. This makes sure that no "unknown" icons are shown
unnecessarily, and saves some resources.

REVIEW: 111396
2013-07-12 08:27:05 +02:00
Frank Reininghaus 6028bd7cf6 Fix O(N^2) complexity issue in KItemListView::slotItemsRemoved()
If many item ranges are removed, KItemListView::slotItemsRemoved()
could take very long because it looped over all items after the first
removed one for every removed range, even if most of these items are
not visible at all.

This commit improves this by just looping over the visible items (whose
number is limited by the window size) for each range.

Test case (for very large N):

touch {1..N}.png
touch {1..N}.jpg

(wait until all files are shown in the view)

rm *.jpg

REVIEW: 111398
2013-07-05 19:51:14 +02:00
Frank Reininghaus 837be34333 Keep the "item size hints" of moved items
It's quite expensive to re-calculate them, so we should better just move
them to the correct position, rather than throwing them away.

REVIEW: 111399
2013-07-05 19:42:39 +02:00
Frank Reininghaus 786cea0076 Make sure that KItemListSizeHintResolver is always consistent
This was the root cause of bug 317827. The assert tried to make sure
that we never access KItemListSizeHintResolver from
KItemListViewLayouter inside the loop over the item ranges. This would
be dangerous because it might be in an inconsistent state - the removed
item ranges were removed step by step, so accessing the item size hints
before the operation was finished could lead to wrong results.

The solution is to insert/remove all item ranges immediately. A nice
side effect is that there are no sources of O(N^2) complexity in
KItemListSizeHintResolver any more if many item ranges are
inserted/removed.

BUG: 317827
FIXED-IN: 4.11.0
REVIEW: 111382
2013-07-04 23:35:01 +02:00
Frank Reininghaus 82ea33762f Prevent some unnecessary layoutings when the view size is changed
In Icons/Details (Compact) View, no layouting is necessary if the view
height (width) changes.

REVIEW: 111322
2013-07-02 19:13:43 +02:00
Frank Reininghaus 2a612e12ce Replace QList by QVector if the elements are larger than a pointer
If the elements are larger than a pointer, QList does not store the
elements themselves, but pointers to them in a contiguous block of
memory. This wastes quite a bit of memory. This can be prevented easily
by using QVector instead.

REVIEW: 111304
2013-06-30 14:26:24 +02:00
Frank Reininghaus 7799bf1828 Fix memory leak in KFileItemModel
Since m_pendingItemsToInsert is a list of pointers now (and not a list
of KFileItems, as in the 4.10 branch), we have to delete all pointers
when clearing or destroying the model.

I think that no review request is necessary for this small and obvious
change.

CCMAIL: emmanuelpescosta099@gmail.com
2013-06-28 21:39:35 +02:00
Emmanuel Pescosta 5ca5a8f3b6 Remove the space (1 pixel) between the file name and the file
icon in Compact View and Details View mode.

BUG: 320899
FIXED-IN: 4.11.0
REVIEW: 111244
2013-06-26 22:07:57 +02:00
Emmanuel Pescosta 391d36edf7 Re-enable expandable folders for network top level folders (remote:/)
Added a hash table for target url to url mapping. So when the dir lister
sends us the target url as directory url, we can use the url mapping table
to get the right "Dolphin internal" directory url, which is the non-target url.

BUG: 306219
FIXED-IN: 4.11.0
REVIEW: 111252
2013-06-26 22:04:52 +02:00
Frank Reininghaus d72ce53141 Fix performance regression when loading folders in Details View
When using Details View, only insert all pending items immediately if
new items are inserted which might be children of a pending item. Fixes
the problem that inserting the items in multiple bunches slows down the
folder loading.

Note that the cause of the slowness when inserting in multiple bunches
is that KItemListSizeHintResolver needs O(N^2) time in the worst case
for inserting N items into a model with N existing ones.

REVIEW: 111226
2013-06-26 21:18:37 +02:00
Frank Reininghaus 51b978f7fd Merge remote-tracking branch 'origin/KDE/4.10' 2013-06-24 22:02:04 +02:00
Emmanuel Pescosta aebe7a9010 Use the target url of a item when creating the QMimeData in KFileItemModel::createMimeData.
BUG: 307336
FIXED-IN: 4.10.5
REVIEW: 111209
2013-06-24 11:11:37 +02:00
Vishesh Handa e715b9a8a4 Dolphin Nepomuk Roles: Handle values which are resource lists
It is common for music files to have more than one artist

BUG: 321359
2013-06-22 19:06:22 +05:30
Vishesh Handa 8188c70a00 Remove knepomukdatamanagement_export.h
It is no longer required. In fact it hasn't been required since
nepomuk-core was introdcued.
2013-06-22 19:06:22 +05:30
Vishesh Handa 5778e10e9b Dolphin: Do not try to connect to Nepomuk if it is not running
Each time one uses any of the Nepomuk classes, an attempt is made to
connect to the database. This slows down the application since
connecting to Nepomuk is not so cheap.

BUG: 321299
2013-06-22 04:31:15 +05:30
Frank Reininghaus a05db2f0d0 Merge remote-tracking branch 'origin/KDE/4.10' 2013-06-20 19:44:06 +02:00
Frank Reininghaus 7496f007cc Make it possible to select files like "a_b" using keyboard search
The problem was that pressing the Shift key would reset the keyboard
search.

BUG: 321286
FIXED-IN: 4.11.0
REVIEW: 111102
2013-06-20 19:32:25 +02:00
Frank Reininghaus 51f2bdaeab Hide the "drop" indicator when an item is not hovered any more
This fixes the problem that the drop indicator might still be shown
after the drag&drop operation in the Places Panel is finished.

REVIEW: 111037
2013-06-20 19:29:10 +02:00
Frank Reininghaus 6db55f5443 Some simplifications in KFileItemModelRolesUpdater
This removes some things that are obsolete after the recent commits:

(a) resolveNextPendingRoles() is not called any more when the preview
    job is running.

(b) In applyResolvedRoles(), we always load the icon if it isn't known
    yet. This ensures that every item has an icon.

REVIEW: 111012
2013-06-20 19:23:43 +02:00
Frank Reininghaus eda483436b Try to do at least a "fast" icon loading for all items
If all icons for the visible items could be loaded in 200 ms, we
continue loading icons without mime type determination for all items
until the 200 ms are over. This reduces the risk that the user ever
sees "unknown" icons.

REVIEW: 111011
2013-06-20 19:22:24 +02:00
Emmanuel Pescosta 0c0c86f220 Avoid a unnecessary resorting when items are changed, only resort the items when the sorting role value is changed.
BUG: 299565
FIXED-IN: 4.11
REVIEW: 111146
2013-06-20 19:19:47 +02:00
Frank Reininghaus 015957c5a2 Make sure that all visible items have an icon
We try to determine "final" icons, i.e., icons with known mime type,
for 200 ms. If this does not succeed, we at least load "fast" icons,
i.e., load the icons without determining the mime type.

REVIEW: 111009
2013-06-20 19:13:35 +02:00
Emmanuel Pescosta 584574e07d Prevent the selection rectangle from being reduced to 0px
width or 0px height, so the selected items can not be accidently
unselected when the rectangle width/height becomes 0px.

BUG: 320897
REVIEW: 111144
FIXED-IN: 4.10.5
2013-06-20 19:02:06 +02:00
Frank Reininghaus 4b8c4124cb Simplify handling of preview jobs
This patch changes two things about the way we handle the preview jobs:

(a) Rather than passing a KFileItemList to startPreviewJob(),
    remembering the leftovers in the member variable
    m_pendingPreviewItems and then starting a new preview job for
    these, we append items that need a preview to this member, and let
    startPreviewJob() take its input from there. This simplifies the
    code greatly.

(b) To prevent that we start preview jobs with just one item and also
    that the GUI is frozen too long by startPreviewJob(), we take the
    following approach:

    * If the mime type of the first pending item is known, the function
      has probably been called by startUpdating(), which has determined
      mime types for the visible items already. startUpdating() has
      also blocked the GUI, so we just take all items at the beginning
      of the list with known mime type, and do not do any expensive
      mime type determination in startPreviewJob().

    * If the mime type of the first pending item is unknown, the
      function has probably been called by slotPreviewJobFinished(). In
      that case, we can afford to block the GUI for a short while, so
      we determine mime types for 200 ms.

REVIEW: 111008
2013-06-20 18:10:07 +02:00
Dawit Alemayehu fda88516e9 Merge remote-tracking branch 'origin/KDE/4.10' 2013-06-20 08:41:12 -04:00
Frank Reininghaus 75ed1946f8 Ensure that the "Sort by Type" setting is respected
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-18 17:39:56 +02:00
Frank Reininghaus e8c3df5f60 Merge remote-tracking branch 'origin/KDE/4.10' 2013-06-10 21:40:41 +02:00
Frank Reininghaus 15b34a0d05 Do not rename files unexpectedly when changing the URL
If the role editor loses focus, it considers the current renaming
operation finished, and tells DolphinView to rename the file. This is a
problem when changing the directory, because the URL change happens
before DolphinView receives the signal, which results in a file in the
new directory being renamed unexpectedly.

The solution is to establish the connection to the
slotRoleEditingFinished signal only when the "rename inline" editor is
opened, and disconnect it when renaming is finished or canceled or the
URL changes.

BUG: 319912
FIXED-IN: 4.10.5
REVIEW: 110908
2013-06-10 21:19:56 +02:00
Frank Reininghaus bd88f237b1 Remove unused argument
I saw a runtime warning from QMetaObject::invokeMethod() that KJob* is
not a registered type. Since we don't use that argument in
slotPreviewJobFinished(KJob*) anyway, it's best to remove it.
2013-06-07 09:24:24 +02:00
Frank Reininghaus 39c7c343cf Ignore a changed item if it cannot be found in the model
This prevents repeated attempts to reload the data for the non-existing
item. This was the root cause of bug 320791.

Thanks to Hrvoje Senjan and Jekyll Wu for testing the new code and
finding this bug!

BUG: 320791
2013-06-06 10:00:47 +02:00
Frank Reininghaus f114564523 Make calls to resolveNextPendingRoles and resolveNextSortRole delayed
This prevents that functions that call these indirectly call themselves
recursively and cause trouble.

BUG: 320791
2013-06-06 08:49:12 +02:00
Frank Reininghaus e7a9d5590b startPreviewJob: if items is empty, delay call to slotPreviewJobFinshed
This should prevent that other functions, which start preview jobs,
eventually call themselves and thus cause trouble.

CCBUG: 320791
2013-06-06 08:38:58 +02:00
Frank Reininghaus 2bdc5eff54 KFileItemModelRolesUpdater: waste less ressources and fix some bugs
The main change in this commit is that we do not determine expensive
roles (like previews, mime types, etc) for all items, but only for the
visible ones and those close to the visible area or on the first and
the last page of the view.

This prevents that the CPU and hard drive are kept busy for quite some
time after entering a folder while all items are handled asynchronously.

There is one known problem at the moment: when sorting by "Type" or
another role that can be resolved by KFileItemModelRolesUpdater, the
icons of the visible items are sometimes not loaded while the sorting is
still in progress. I will try to fix this issue during the next few
days.

REVIEW: 110839
2013-06-05 23:31:01 +02:00
Frank Reininghaus c6494823c8 Reduce KFileItemModel memory usage by making use of implicit sharing
The idea is based on
http://milianw.de/blog/katekdevelop-sprint-vienna-2012-take-1

REVIEW: 110686
2013-06-05 23:18:26 +02:00
Thomas Lübking c756bc6c89 set KItemListView palette from scenes first view
REVIEW: 110505
2013-05-25 14:20:43 +02:00
Frank Reininghaus 04e825d022 Merge remote-tracking branch 'origin/KDE/4.10' 2013-05-22 18:34:25 +02:00
Frank Reininghaus bf85483c99 KFileItemModel::insertItems(): guarantee O(N) run time complexity
This commit prevents repeated insertions of single items into the list
m_itemData, which shift all following items by one position and result
in O(N^2) worst case complexity for the entire function.

Moreover, the hash m_items is updated only for the items starting from
the first inserted/removed item to save some superfluous calculations
of hash values.

REVIEW: 110355
2013-05-22 18:27:44 +02:00
Frank Reininghaus 2f51debbea Do not reset the 'isExpanded' state when an expanded folder is refreshed
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-05-22 18:14:38 +02:00
Frank Reininghaus e66c3221ce KFileItemModelRolesUpdater: only update the size for changed folders
When using inotify, we also receive signals for modified files, even if
we only ask KDirWatch to watch the directory containing them. In that
case, we must not set the size to -1 (which means "unknown number of
items" for folders) temporarily, or we end up with an apparent file size
of 2^64 - 1 bytes.

BUG: 309740
FIXED-IN: 4.10.4
REVIEW: 110428
2013-05-22 18:09:42 +02:00
Vishesh Handa cc4947d1ac Dolphin Places: Make it easier to drag and drop items
When doing a drop, a check is performed to see if it is within x pixels
from the top or x pixel from the bottom of the rect. If it is, then the
drop is considered a drop between items.

This x was fixed to qMax( 4, myStyleOption.padding ) which would
generally be 4. This is fine for some cases, but when the rectangle size
increases then this 4 pixels is not enough. Hence this 'x' is now being
set to 30% of the rectangle height.

By default the rectangle height is 20 pixels, so x is now 6 instead of 4
in the default case, which does make it slightly easier.

Also, this in-between-items check is only performed when moving from one
item to another. This is not good since if you enter the item and the
bottom, the indicator is shown, and then as to start moving it up it
stops showing, and then it should start showing again as you approach
the top edge.

Modified the code to run the check on every mouse drag event even if the
hovered item has not changed.

Both these changes combined make it much easier to drag and drop items.

REVIEW: 110342
2013-05-13 14:39:23 +05:30
Frank Reininghaus cad78cdfcf Merge remote-tracking branch 'origin/KDE/4.10'
Conflicts:
	CMakeLists.txt
2013-05-11 18:47:58 +02:00
Vishesh Handa 38bb5f1547 Dolphin Places: React to Nepomuk system changes
Reload the places panel when Nepomuk starts up and shutsdown. This way
the user does not need to restart Dolphin to see the custom searches and
places after Nepomuk switches on.

BUG: 304918
REVIEW: 110323
2013-05-07 01:36:37 +05:30
Frank Reininghaus 692e7d4d32 Merge remote-tracking branch 'origin/KDE/4.10' 2013-05-02 19:45:08 +02:00
Frank Reininghaus 9480a1ee44 Use the same text color for selected hidden and non-hidden items
This fixes the problem that the names of selected hidden items are
unreadable with some color schemes.

BUG: 305734
FIXED-IN: 4.10.3
REVIEW: 110164
2013-05-02 19:28:10 +02:00
Frank Reininghaus 7f381a34cb Merge remote-tracking branch 'origin/KDE/4.10'
Conflicts:
	plasma/applets/folderview/folderview.cpp

CCMAIL: ignat.semenov@blue-systems.com

@Ignat: We've been following a merge-based approach in kde-baseapps
for quite some time now, see

http://lists.kde.org/?t=134744909400005&r=1&w=1

It would be nice if you could merge KDE/4.10 into master after any
non-trivial changes in folderview to prevent that others have to
figure out how to resolve the merge conflicts. Thanks!
2013-04-23 19:40:42 +02:00
Frank Reininghaus 8f4d13dab8 Disable Find/Replace in the "rename inline" line edit
These actions do not work correctly because renaming is considered
finished as soon as the line edit loses focus, which happens when the
"Replace" dialog pops up.

BUG: 317772
FIXED-IN: 4.10.3
2013-04-23 19:31:08 +02:00
Frank Reininghaus 8a40b0ee4a Do not dereference null pointer in KItemListViewAccessible
BUG: 316285
FIXED-IN: 4.10.3
2013-04-23 19:25:52 +02:00
Frank Reininghaus 37e796522b Comment out assertion to fix a crash when filtering in Icons/Compat View
I'm not sure yet if there is a problem somewhere else in the code. For
the time being, I think it's better to replace the assert by a TODO
comment to prevent that users find out the hard way that there is
something that we're not quite sure about.

BUG: 317827
FIXED-IN: 4.10.3
2013-04-22 21:36:57 +02:00
Frank Reininghaus 151c8d8c42 Always determine icons for the visible items first
When entering a folder, KFileItemModelRolesUpdater has not yet been
informed about the visible index range by the view when it tries to
determine icons synchronously. This resulted in the problem that it
tried to determine icons for all items in random order, and some visible
icons were somtimes still unknown after the "synchronous icon loading"
timeout of 200 ms.

This commit tries to improve the situation by loading icons starting
with the first item in increasing order. This should make it less likely
that some visible items still have unknown icons after 200 ms.

BUG: 316129
FIXED-IN: 4.10.3
REVIEW: 109843
2013-04-22 21:21:31 +02:00
Aurélien Gâteau 1cd7bfb991 Merge remote-tracking branch 'origin/KDE/4.10' 2013-04-12 16:31:03 +02:00
Aurélien Gâteau bf1b4b4881 Fix moving image while transitioning to hover pixmap
See: http://youtu.be/OMYO0U0kSL0

REVIEW: 109960
FIXED-IN: 4.10.3
2013-04-12 16:28:52 +02:00
Luca Beltrame 8cc479518b Merge remote-tracking branch 'origin/KDE/4.10'
Conflicts:
	plasma/applets/folderview/folderview.cpp
2013-03-27 16:50:22 +01:00
David Faure df8d439c55 Update icon if it couldn't be determined upfront (.desktop file on slow mount)
This requires an up-to-date kdelibs >= 4.10.

CCBUG: 290666
2013-03-27 15:19:09 +01:00
Frank Reininghaus f28ab78825 Improve grouping by name for non-ASCII file names
This commit prevents that all non-ASCII letters which are not umlauts
are grouped in a single group "Others", and that the joint group of
an ASCII letter and the associated umlaut in some locales is called
"Others" if there is only the umlaut in the group.

BUG: 315569
REVIEW: 109457
FIXED-IN: 4.10.2
2013-03-26 01:21:34 +01:00
Aurélien Gâteau 6dfcd7afd9 Merge remote-tracking branch 'origin/KDE/4.10'
@emmanuel: this merge includes your fix from
https://git.reviewboard.kde.org/r/109488/ . I assume this is not a
problem.

CCMAIL: emmanuelpescosta099@gmail.com
2013-03-21 14:14:55 +01:00
Aurélien Gâteau e2a89fc2e0 Fix transition between m_pixmap and m_hoverPixmap
The default SourceOver composition mode of QPainter cannot be used
to interpolate between two images, we must use intermediate buffers
to perform the interpolation and blend the result on the widget.

More details are available in the review request.

REVIEW: 109614
FIXED-IN: 4.10.2
2013-03-21 14:06:07 +01:00
Emmanuel Pescosta 7198437118 Refresh all expanded directories too, when reloading a directory.
BUG: 295300
FIXED-IN: 4.10.2
REVIEW: 109488
2013-03-17 20:13:55 +01:00
Frank Reininghaus 31b0b565fe Merge remote-tracking branch 'origin/KDE/4.10' 2013-03-15 00:28:40 +01:00
Frank Reininghaus 90dd897752 Improve handling of filtered items when folders are deleted/collapsed
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-15 00:23:57 +01:00
Frank Reininghaus a97fe0c7ff Fix recent regressions when "Sort by Type" is used
This commit ensures that the mime types and icons are determined
synchronously for 200 ms when "Sort by Type" is enabled.

REVIEW: 109344
2013-03-12 19:26:36 +01:00
Frank Reininghaus 9ea5eb2164 Do not skip rows in when clicking the empty area of the scroll bar
The height of the header widget must be subtracted from the view's
height in Details View to determine the "pageStep" for the scroll bar.

BUG: 315619
FIXED-IN: 4.10.2
REVIEW: 109210
2013-03-11 18:18:44 +01:00
Frank Reininghaus f71e0881d2 Merge remote-tracking branch 'origin/KDE/4.10'
Conflicts:
	dolphin/src/kitemviews/kfileitemmodel.cpp
2013-03-10 18:31:23 +01:00
Frank Reininghaus 9dd728cb98 Remove filtered children if the parent folder is collapsed
This is analogous to commit e053ecdcd5,
which fixes the same problem for the case that the parent folder is
deleted.

BUG: 316335
FIXED-IN: 4.10.2
REVIEW: 109343
2013-03-10 18:26:37 +01:00
Daniel Kreuter 0ae259e098 Use a consistent way to group files by "Date"
Before this change, files were grouped by calendar weeks if they were
modified in the current month and ignoring the "first week day setting",
but by the actual distance measured in multiples of seven days if the
were modified last month.

This not only fixes the "ignores first week day" bug, but also the
problem that the inconsistencies in the algorithm could lead to a broken
grouping in the first days of a month (see screenshot in the review
request).

BUG: 181337
FIXED-IN: 4.11
REVIEW: 108667
2013-03-03 18:27:00 +01:00
Emmanuel Pescosta 4e4078c66a Removed everything related to m_expandedParentsCountRoot ->
This concept is not needed anymore because of the new "determine parents and
expansion levels" approach

Side effect:
Enables treeview for trash, ...

REVIEW: 109191
2013-02-27 19:56:55 +01:00
Emmanuel Pescosta f2d70693db Big Thanks to Frank Reininghaus, who helped me a lot with these
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-27 13:35:20 +01:00
Frank Reininghaus cc1455c0e6 Merge remote-tracking branch 'origin/KDE/4.10'
Conflicts:
	dolphin/src/tests/kfileitemmodeltest.cpp
	lib/konq/konq_operations.cpp
2013-02-19 15:45:44 +01:00
Frank Reininghaus 6938241ebc Remove items from m_filteredItems if their parent is deleted
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-18 23:50:38 +01:00
Frank Reininghaus e6ef1eec3a Merge remote-tracking branch 'origin/KDE/4.10' 2013-02-17 12:17:01 +01:00
Frank Reininghaus fc0c3f9d4e Prevent repeated re-layouting of all items while previews are generated
There was some code in KStandardItemListView::itemSizeHintUpdateRequired
already that was supposed to prevent an expensive re-layouting of all
items when a preview is received. However, it didn't quite work as
intended because also the "iconOverlays" role changed.

The new approach is to only re-layout if text of a visible role changes,
because this is the only way how the space needed by an item might
change (see KStandardItemListWidgetInformant::itemSizeHint()).

BUG: 315315
FIXED-IN: 4.10.1
REVIEW: 108984
2013-02-17 11:30:38 +01:00
Aurélien Gâteau a7705b04dd Merge remote-tracking branch 'origin/KDE/4.10' 2013-02-11 10:53:52 +01:00
Aurélien Gâteau 66af7c390c Fix blinking when moving the mouse over an hidden item
The opacity of the unhovered pixmap must be gradually reduced while
animating otherwise the alpha channel saturates.

REVIEW: 108858
BUG: 299371
FIXED-IN: 4.10.1
2013-02-11 10:38:28 +01:00
Frank Reininghaus ced9de5b82 Merge remote-tracking branch 'origin/KDE/4.10' 2013-02-10 19:27:21 +01:00
Frank Reininghaus dc6322dc09 Re-organize the code that compares expanded items
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-10 18:09:07 +01:00
Frank Reininghaus 4f5a2eb943 Include parent-child relationships in KFileItemModel's consistency check 2013-02-10 18:06:07 +01:00
Frank Reininghaus ac6d3d8250 KFileItemModel::insertItems(): reserve sufficient space for m_items
This prevents expensive and unnecessary repeated rehashing when many
items are inserted into the model.
2013-02-06 18:58:54 +01:00
Aniket Anvit 85ed71eb30 Apply changes of the KGlobalSettings::singleClick() setting immediately
Fixes a regression introduced by commit
7a364cbf48.

Patch reviewed and pushed by Frank Reininghaus.

BUG: 313342
FIXED-IN: 4.10.1
2013-02-05 19:58:06 +01:00
Frank Reininghaus 687d5145a2 Two small optimizations in KFileItemModel::removeItems()
1. It seems that it really can happen that KFileItems that we get from
   the dir lister's itemsDeleted signal are not in the model any more,
   e.g., if a folder where hidden files are shown is left and a folder
   where hidden files are not shown is entered. There is no need to
   output warnings then.
2. Remove the emptiness-check for the KFileItemList at the beginning.
   Even in the unlikely event that we do get an empty list, we return
   just a few lines later in the code.
2013-02-03 23:28:57 +01:00
Frank Reininghaus 01dc86f0df const QList<int> -> const QList<int>& 2013-02-03 23:19:58 +01:00
Frank Reininghaus 8371fb6d75 Fix crashes in KFileItemModel::removeItems()
These crashes were caused by the recent commit
ff3267c6dc. It introduced two problems:

a) A logic error in the code that removes the ItemData pointers from
   m_itemData that could cause crashes if multiple item ranges are
   removed, and there were un-removed items behind the last one.
b) The implicit assumption that any call of removeItems() will actually
   result in items being removed in the model. This is incorrect if
   the model is first cleared and then the hidden-files setting is
   modified, which happens if "Save view properties for each folder" is
   enabled, and a folder where hidden files are shown is left. In that
   case, the dir lister emits itemsDeleted for the hidden items after
   they have been removed from the model due to the folder change.

I'll add a unit test covering these issues soon.

Many thanks to Romário Rios and Hrvoje Senjan for testing!

BUG: 314046
2013-01-29 19:08:28 +01:00
Frank Reininghaus f76f3a1654 Move the consistency check for KFileItemModel from the test to the class
This makes it possible to check the model's consistency also in other
places, e.g., in KFileItemModel's benchmark.
2013-01-27 15:19:39 +01:00
Frank Reininghaus d1b75d1d64 Performance improvements in KFileItemModel::removeItems()
The performance of this method is improved by:
a) Not removing items one by one, but doing it in a way that minimizes
   the number of moves to prevent O(N^2) worst-case complexity.
b) Not sorting the removed items using the potentially extremely slow
   KFileItemModel::lessThan. We can get the indexes of the removed items
   very easily from the hash m_items, and sorting ints is a lot faster.
c) Preventing repeated rehashing of m_items when removing the deleted
   URLs by replacing remove() by erase().

REVIEW: 108540
2013-01-27 13:07:46 +01:00
Frank Reininghaus 71be8f2bee Add some benchmarks for KFileItemModel
The benchmark executable must be run manually. It is not run
automatically with the other unit tests to prevent waste of CPU cycles
in the not-so-uncommon situation that only test failures attract
attention.
2013-01-27 12:55:37 +01:00
Luca Beltrame dfa170cb49 Merge remote-tracking branch 'origin/KDE/4.10' 2013-01-24 23:49:59 +01:00
Vishesh Handa d27c16d751 KFileItemModelRolesUpdater: Avoid multiple updates for Nepomuk data
The Nepomuk ResourceWatcher emits 3 signals - propertyChanged,
propertyAdded and propertyRemoved. We should only listen to either the
propertyChanged signal or the propertyAdded + Removed signals. There is
no point in listening to all 3 signals. That will just result in
unnecessary updates.

Additionally, we do not need to listen to the resourceCreated signal.
That is only emitted when we are watching for a specific types, which we
are not.

REVIEW: 108543
2013-01-24 23:16:27 +05:30
Frank Reininghaus 48231488bd Remove incorrect comments about the sorting functions
In fact, we could use the sorting functions provided by Qt or the STL.
The reason why we have our own is that we want to support parallel
sorting because sorting many items naturally by name can be expensive.
2013-01-15 19:07:36 +01:00
Frank Reininghaus d9680ead80 Re-organise the sorting code
The KFileItemModel-specific parts are now separated from the generic
ones, like the parallel sorting implementation.

REVIEW: 108386
2013-01-15 18:50:37 +01:00