┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Bird <[email protected]>2013-01-15 11:11:11 -0500
committerSimeon Bird <[email protected]>2013-01-15 11:11:11 -0500
commit72de114a94c9a8d313c517a694be63662a7d10c2 (patch)
tree403f753638f2fdbfbc449e818c3290f81854dcfc
parent4f0cd0b4470a76f649d8d7017672f47d0cae320d (diff)
parente7fe50bd3d5a2a1f8427878086ff94deb31091bb (diff)
Merge branch 'KDE/4.10'
-rw-r--r--src/dolphinmainwindow.cpp2
-rw-r--r--src/kitemviews/kitemlistselectionmanager.cpp42
-rw-r--r--src/kitemviews/kitemlistselectionmanager.h7
-rw-r--r--src/tests/kitemlistselectionmanagertest.cpp2
-rw-r--r--src/views/versioncontrol/versioncontrolobserver.cpp2
5 files changed, 33 insertions, 22 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index d72fb2305..8ed31dea4 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -1485,6 +1485,7 @@ void DolphinMainWindow::setupActions()
KMenu* menu = m_newFileMenu->menu();
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
menu->setIcon(KIcon("document-new"));
+ m_newFileMenu->setDelayed(false);
connect(menu, SIGNAL(aboutToShow()),
this, SLOT(updateNewMenu()));
@@ -1578,6 +1579,7 @@ void DolphinMainWindow::setupActions()
m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this);
m_recentTabsMenu->setIcon(KIcon("edit-undo"));
+ m_recentTabsMenu->setDelayed(false);
actionCollection()->addAction("closed_tabs", m_recentTabsMenu);
connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction*)),
this, SLOT(restoreClosedTab(QAction*)));
diff --git a/src/kitemviews/kitemlistselectionmanager.cpp b/src/kitemviews/kitemlistselectionmanager.cpp
index 383914df0..833f7aad0 100644
--- a/src/kitemviews/kitemlistselectionmanager.cpp
+++ b/src/kitemviews/kitemlistselectionmanager.cpp
@@ -284,27 +284,23 @@ void KItemListSelectionManager::itemsRemoved(const KItemRangeList& itemRanges)
{
// Store the current selection (needed in the selectionChanged() signal)
const QSet<int> previousSelection = selectedItems();
+ const int previousCurrent = m_currentItem;
// Update the current item
- if (m_currentItem >= 0) {
- const int previousCurrent = m_currentItem;
- // Calling setCurrentItem() would trigger the selectionChanged signal, but we want to
- // emit it only once in this function -> change the current item manually and emit currentChanged
- m_currentItem = indexAfterRangesRemoving(m_currentItem, itemRanges);
- if (m_currentItem != previousCurrent) {
- emit currentChanged(m_currentItem, previousCurrent);
- }
-
+ m_currentItem = indexAfterRangesRemoving(m_currentItem, itemRanges, DiscardRemovedIndex);
+ if (m_currentItem != previousCurrent) {
+ emit currentChanged(m_currentItem, previousCurrent);
if (m_currentItem < 0) {
- // The current item has been removed.
- m_currentItem = qMin(previousCurrent, m_model->count() - 1);
+ // Calling setCurrentItem() would trigger the selectionChanged signal, but we want to
+ // emit it only once in this function -> change the current item manually and emit currentChanged
+ m_currentItem = indexAfterRangesRemoving(previousCurrent, itemRanges, AdjustRemovedIndex);
emit currentChanged(m_currentItem, -1);
}
}
// Update the anchor item
if (m_anchorItem >= 0) {
- m_anchorItem = indexAfterRangesRemoving(m_anchorItem, itemRanges);
+ m_anchorItem = indexAfterRangesRemoving(m_anchorItem, itemRanges, DiscardRemovedIndex);
if (m_anchorItem < 0) {
m_isAnchoredSelectionActive = false;
}
@@ -317,7 +313,7 @@ void KItemListSelectionManager::itemsRemoved(const KItemRangeList& itemRanges)
m_selectedItems.reserve(previous.count());
QSetIterator<int> it(previous);
while (it.hasNext()) {
- const int index = indexAfterRangesRemoving(it.next(), itemRanges);
+ const int index = indexAfterRangesRemoving(it.next(), itemRanges, DiscardRemovedIndex);
if (index >= 0) {
m_selectedItems.insert(index);
}
@@ -377,7 +373,8 @@ void KItemListSelectionManager::itemsMoved(const KItemRange& itemRange, const QL
}
}
-int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges) const
+int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges,
+ const RangesRemovingBehaviour behaviour) const
{
int dec = 0;
foreach (const KItemRange& itemRange, itemRanges) {
@@ -385,13 +382,20 @@ int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRa
break;
}
- if (index < itemRange.index + itemRange.count) {
+ dec += itemRange.count;
+
+ const int firstIndexAfterRange = itemRange.index + itemRange.count;
+ if (index < firstIndexAfterRange) {
// The index is part of the removed range
- return -1;
+ if (behaviour == DiscardRemovedIndex) {
+ return -1;
+ } else {
+ // Use the first item after the range as new index
+ index = firstIndexAfterRange;
+ break;
+ }
}
-
- dec += itemRange.count;
}
- return index - dec;
+ return qBound(-1, index - dec, m_model->count() - 1);
}
#include "kitemlistselectionmanager.moc"
diff --git a/src/kitemviews/kitemlistselectionmanager.h b/src/kitemviews/kitemlistselectionmanager.h
index 43d0dcb80..c89b8a4b8 100644
--- a/src/kitemviews/kitemlistselectionmanager.h
+++ b/src/kitemviews/kitemlistselectionmanager.h
@@ -39,6 +39,11 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListSelectionManager : public QObject
{
Q_OBJECT
+ enum RangesRemovingBehaviour {
+ DiscardRemovedIndex,
+ AdjustRemovedIndex
+ };
+
public:
enum SelectionMode {
Select,
@@ -81,7 +86,7 @@ private:
* Helper method for itemsRemoved. Returns the changed index after removing
* the given range. If the index is part of the range, -1 will be returned.
*/
- int indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges) const;
+ int indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges, const RangesRemovingBehaviour behaviour) const;
private:
int m_currentItem;
diff --git a/src/tests/kitemlistselectionmanagertest.cpp b/src/tests/kitemlistselectionmanagertest.cpp
index 3a8400930..302985a5f 100644
--- a/src/tests/kitemlistselectionmanagertest.cpp
+++ b/src/tests/kitemlistselectionmanagertest.cpp
@@ -499,7 +499,7 @@ void KItemListSelectionManagerTest::testDeleteCurrentItem_data()
QTest::newRow("Remove before") << 50 << 0 << 10 << 40;
QTest::newRow("Remove after") << 50 << 51 << 10 << 50;
QTest::newRow("Remove exactly current item") << 50 << 50 << 1 << 50;
- QTest::newRow("Remove around current item") << 50 << 45 << 10 << 50;
+ QTest::newRow("Remove around current item") << 50 << 45 << 10 << 45;
QTest::newRow("Remove all except one item") << 50 << 1 << 99 << 0;
}
diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp
index 42e00de42..64bc26867 100644
--- a/src/views/versioncontrol/versioncontrolobserver.cpp
+++ b/src/views/versioncontrol/versioncontrolobserver.cpp
@@ -245,7 +245,7 @@ void VersionControlObserver::updateItemStates()
connect(m_updateItemStatesThread, SIGNAL(finished()),
m_updateItemStatesThread, SLOT(deleteLater()));
}
- if (m_updateItemStatesThread->isRunning()) {
+ else {
// An update is currently ongoing. Wait until the thread has finished
// the update (see slotThreadFinished()).
m_pendingItemStatesUpdate = true;