#include <QTimer>
#include <QScrollBar>
-#include <kactioncollection.h>
-#include <kcolorscheme.h>
-#include <kdirlister.h>
-#include <kiconeffect.h>
-#include <kfileitem.h>
-#include <kfileitemlistproperties.h>
-#include <klocale.h>
-#include <kio/deletejob.h>
-#include <kio/netaccess.h>
-#include <kio/previewjob.h>
-#include <kjob.h>
-#include <kmenu.h>
-#include <kmessagebox.h>
+#include <KActionCollection>
+#include <KColorScheme>
+#include <KDirLister>
+#include <KIconEffect>
+#include <KFileItem>
+#include <KFileItemListProperties>
+#include <KLocale>
+#include <KIO/DeleteJob>
+#include <KIO/NetAccess>
+#include <KIO/PreviewJob>
+#include <KJob>
+#include <KMenu>
+#include <KMessageBox>
#include <konq_fileitemcapabilities.h>
#include <konq_operations.h>
#include <konqmimedata.h>
-#include <ktoggleaction.h>
-#include <kurl.h>
+#include <KToggleAction>
+#include <KUrl>
#include "additionalinfoaccessor.h"
#include "dolphindirlister.h"
void DolphinView::invertSelection()
{
- QItemSelectionModel* selectionModel = m_viewAccessor.itemView()->selectionModel();
- const QAbstractItemModel* itemModel = selectionModel->model();
-
- const QModelIndex topLeft = itemModel->index(0, 0);
- const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
- itemModel->columnCount() - 1);
+ // Implementation note: Using selectionModel->select(selection, QItemSelectionModel::Toggle) does not
+ // work, as QItemSelectionModel::hasSelection() provides invalid values in this case. This might be a Qt-issue -
+ // when changing the implementation with an updated Qt-version don't forget to run the Dolphin-unit-tests that
+ // verify this usecase.
+ const KFileItemList selItems = selectedItems();
+ clearSelection();
+
+ QItemSelection invertedSelection;
+ foreach (const KFileItem& item, items()) {
+ if (!selItems.contains(item)) {
+ const QModelIndex index = m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
+ invertedSelection.select(index, index);
+ }
+ }
- const QItemSelection selection(topLeft, bottomRight);
- selectionModel->select(selection, QItemSelectionModel::Toggle);
+ QItemSelectionModel* selectionModel = m_viewAccessor.itemView()->selectionModel();
+ selectionModel->select(invertedSelection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current);
}
void DolphinView::clearSelection()
foreach(const KFileItem& item, m_selectedItems) {
url = item.url().upUrl();
if (baseUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
- QModelIndex index = m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
+ const QModelIndex index = m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
newSelection.select(index, index);
}
}
connect(dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(slotRedirection(KUrl,KUrl)));
connect(dirLister, SIGNAL(started(KUrl)), this, SLOT(slotDirListerStarted(KUrl)));
connect(dirLister, SIGNAL(completed()), this, SLOT(slotDirListerCompleted()));
- connect(dirLister, SIGNAL(canceled()), this, SLOT(slotDirListerCompleted()));
connect(dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
this, SLOT(slotRefreshItems()));
disconnect(dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(slotRedirection(KUrl,KUrl)));
disconnect(dirLister, SIGNAL(started(KUrl)), this, SLOT(slotDirListerStarted(KUrl)));
disconnect(dirLister, SIGNAL(completed()), this, SLOT(slotDirListerCompleted()));
- disconnect(dirLister, SIGNAL(canceled()), this, SLOT(slotDirListerCompleted()));
disconnect(dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
this, SLOT(slotRefreshItems()));