Commit graph

4780 commits

Author SHA1 Message Date
Frank Reininghaus 4ff27ee637 Kill any running preview jobs before starting a new one
If loading a preview takes long, it was possible before this commit
that a preview for a new item was requested before the first preview
was shown. In that case, there was a race condition, and the first
preview to arrive stayed in the Information Panel.

This commit fixes this by keeping a pointer to the preview job and
killing it before starting a new one.

BUG: 250787
FIXED-IN: 4.12.1
REVIEW: 114561
2014-01-06 20:15:11 +01:00
Frank Reininghaus 24ad08714e Avoid calling KFileItemModel::index() in KFileItemModelRolesUpdater
KFileItemModel allows to find out the index of a KFileItem with its
index(const KFileItem&) method. Calling this method is not extremely
expensive, but it's also not free (it looks up the URL of the KFileItem
in a QHash, i.e., it has to call qHash(QString) for the full URL).

In KFileItemModelRolesUpdater, we sometimes converted the known index to
a KFileItem and then back to an index in applyResolvedRoles(KFileItem).
This patch fixes this by modifying applyResolvedRoles such that it takes
the index directly as its argument.

REVIEW: 114847
2014-01-06 20:10:08 +01:00
Frank Reininghaus 4ddc3cfdde Merge remote-tracking branch 'origin/KDE/4.12' 2013-12-29 09:50:17 +01:00
Frank Reininghaus 9866e4826e Remove redundant data from KItemListViewLayouter's ItemInfo struct
It is not necessary to save the position of each item as a QPointF
because all items in a row will have the same y-coordinate, and all
items in a column will have the same x-coordinate. Therefore, we can
reduce the number of doubles that we store from

(number of items) * 2

to

(number of rows) + (number of colums)

which is at least 50% less.

REVIEW: 114460
2013-12-29 09:42:25 +01:00
Frank Reininghaus 280fa647f1 Disable the "Create folder" action in read-only directories
The action can be triggered, e.g., by pressing F10.

BUG: 294054
FIXED-IN: 4.12.1
REVIEW: 114560
2013-12-29 09:23:17 +01:00
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 c2108b122e Add unit test for KFileItemModel::createMimeData().
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-22 13:12:51 +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 f3537f5b5f Merge remote-tracking branch 'origin/KDE/4.11' into KDE/4.12 2013-12-06 00:56:34 +01:00
Emmanuel Pescosta c4c999d243 Fix Bug 328262 - rename bug if you cancel when folder already exists
Only connect the renamingFailed signal if there is no item with the new name in the model yet.

BUG: 328262
FIXED-IN: 4.11.5
REVIEW: 114228
2013-12-03 19:00:28 +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 32264f5546 Make the "Create New..." menu in the "item context menu" work again
Since https://git.reviewboard.kde.org/r/111989/, the "Create New..."
menu in the context menu that appears when right-clicking a folder was
not a child of the DolphinMainWindow any more, but of the context menu
itself. This is the reason why the dialog that asks for a file name
when choosing one of the "Create New..." options disappeared
immediately.

This patch makes sure that the main window is the parent of the
"Create New..." menu again.

BUG: 327783
REVIEW: 113930
2013-11-21 00:41:33 +01:00
Patrick von Reth d7ed6c8805 dolphinnewfilemenu.cpp is part of dolphinprivate 2013-11-19 19:51:16 +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 ac8722dc7d Update the Places Panel entries when switching the language
Before this commit, we stored the translated "Places" in
.kde4/share/apps/kfileplaces/bookmarks.xml. This was not intentional -
it only happened because
PlacesItem::updateBookmarkForRole(const QByteArray& role) always stored
the translated text (returned by PlacesItem::text()) in the KBookmark.

This is be fixed by first checking if the text() is equal to the
translation of the text that is already stored in the KBookmark, and
not updating it in that case.

Note that we have to make sure that all "Places"-related use the same
context "KFile System Bookmarks" to make that work.

Thanks to Burkhard Lück and Albert Astals Cid for helping to fix this
problem!

BUG: 319282
FIXED-IN: 4.12.0
REVIEW: 113850
2013-11-15 09:20:10 +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
Wolfgang Bauer b1448a0c32 Make it build with QT_STRICT_ITERATORS
Redo commit 81c99da7e0 by Kevin Ottens

Was removed by mistake during the last merge with KDE/4.11, sorry!
2013-11-06 17:53:43 +01:00
Wolfgang Bauer ee92ff0d42 Merge branch 'KDE/4.11' into KDE/4.12
Revert "Files passed as arguments: Ignore unsupported files"

This reverts commit cd9e50ae4f.

See bug#327224 for details.
2013-11-06 17:07:10 +01:00
Wolfgang Bauer ae1911e6b0 Revert "Files passed as arguments: Ignore unsupported files"
This reverts commit cd9e50ae4f.

See bug#327224 for details.
2013-11-06 16:46:09 +01:00
Frank Reininghaus a5e266e538 Merge remote-tracking branch 'origin/KDE/4.11' into KDE/4.12 2013-11-05 08:47:37 +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
Emmanuel Pescosta c2bf208fe6 Fix Bug 287983 - Dolphin truncates tooltip information for long file names
Use KStringHandler and QTextLayout to wrap the text (file name)
into the maximum width of the label "name".

Make use of QFontMetrics to calculate a font size aware tooltip size.

BUG: 287983
FIXED-IN: 4.11.3
REVIEW: 113101
2013-11-02 00:12:33 +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 70cd04df40 Merge remote-tracking branch 'origin/KDE/4.11' 2013-10-26 09:30:18 +02:00
Frank Reininghaus f55119945f Fix broken view state restoration
The fix for bug 161385 (which was about Dolphin still showing an empty
view if a device that had been unmounted earlier was clicked in the
Places Panel) caused a regression: the view state (current item, scroll
position, Details View expansion state) was not restored any more when
going "Back".

The reason is that "m_view->reload()" in
DolphinViewContainer::setUrl(const KUrl& newUrl) was always executed
just after entering a directory, and that command overwrites this
information.

Distinguishing between "change URL" and "reload the view" works better
if it's done in DolphinMainWindow instead of DolphinViewContainer.

BUG: 326039
FIXED-IN: 4.11.3
REVIEW: 113290
2013-10-26 09:24:04 +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
Kevin Ottens 011299eb6e Make it build with QT_STRICT_ITERATORS 2013-10-16 19:24:01 +02:00
David Faure 8bbddb3b63 Merge remote-tracking branch 'origin/KDE/4.11' 2013-10-15 09:08:47 +02:00
Frank Reininghaus 96ba990d86 Fix crash when triggereing the "Compare files" action via D-Bus
If the number of selected items is not two, Dolphin disables this
action. However, it is still possible to trigger it via D-Bus, and this
could cause a crash in DolphinMainWindow::compareFiles() because this
function did not test at all if there are really two items selected.

This patch adds such a check and simplifies the code in that function.

BUG: 325517
FIXED-IN: 4.11.3
2013-10-13 10:55:21 +02:00
Erik Hahn 0c55297ce4 Files passed as arguments: Ignore unsupported files
With this patch, Dolphin ignores all files passed to it that it can't

Also, archives are now opened inside Dolphin so it can be used as an
archive manager at least for local files. If the user tries to open a
remote archive Dolphin still opens it externally; I have observed that
if it receives one as an argument, it will display a pseudo-folder that
contains only said archive. So having it set as the archive handler is
still broken, but in a less annoying way.

CCBUG: 318683
REVIEW: 113191
FIXED-IN: 4.11.3
2013-10-13 10:48:00 +02:00
Dawit Alemayehu e3b840e4aa Moved all the extension code into dolphinpart_ext.*
REVIEW: 113132
2013-10-12 13:33:42 -04: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 5bfb5031a5 Reload the view if a previously unmounted device is mounted again
The problem was that DolphinViewContainer::setUrl(newUrl) was ignored
if newUrl is equal to the URL which is shown in the view already.

The new approach is to reload the view in that method if it is empty, to
make sure that we do not miss that a previously unmounted device has
been re-mounted.

Thanks to Grigoriadis Grigoris for analyzing the root cause of this
issue!

BUG: 161385
FIXED-IN: 4.11.3
2013-10-07 09:17:48 +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