dirLister->openUrl(rootUrl, false, true);
}
+void DolphinColumnView::invertSelection()
+{
+ // TODO: this approach of inverting the selection is quite slow. It should
+ // be possible to speedup the implementation by using QItemSelection, but
+ // all adempts have failed yet...
+
+ ColumnWidget* column = activeColumn();
+ QItemSelectionModel* selModel = column->selectionModel();
+
+ KDirLister* dirLister = m_dolphinModel->dirLister();
+ const KFileItemList list = dirLister->itemsForDir(column->url());
+ foreach (KFileItem* item, list) {
+ const QModelIndex index = m_dolphinModel->indexForUrl(item->url());
+ selModel->select(m_proxyModel->mapFromSource(index), QItemSelectionModel::Toggle);
+ }
+}
+
void DolphinColumnView::showColumn(const KUrl& url)
{
const KUrl& rootUrl = m_columns[0]->url();
expandToActiveUrl();
}
+void DolphinColumnView::selectAll()
+{
+ activeColumn()->selectAll();
+}
+
bool DolphinColumnView::isIndexHidden(const QModelIndex& index) const
{
Q_UNUSED(index);
*/
void reload();
+ /** Inverts the selection of the currently active column. */
+ void invertSelection();
+
public slots:
/**
* Shows the column which represents the URL \a url. If the column
*/
void showColumn(const KUrl& url);
+ /** @see QAbstractItemView::selectAll() */
+ virtual void selectAll();
+
protected:
virtual bool isIndexHidden(const QModelIndex& index) const;
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
void DolphinView::invertSelection()
{
- QItemSelectionModel* selectionModel = itemView()->selectionModel();
- const QAbstractItemModel* itemModel = selectionModel->model();
+ if (isColumnViewActive()) {
+ // QAbstractItemView does not offer a virtual method invertSelection()
+ // as counterpart to QAbstractItemView::selectAll(). This makes it
+ // necessary to delegate the inverting of the selection to the
+ // column view, as only the selection of the active column should get
+ // inverted.
+ m_columnView->invertSelection();
+ } else {
+ QItemSelectionModel* selectionModel = 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);
+ const QModelIndex topLeft = itemModel->index(0, 0);
+ const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
+ itemModel->columnCount() - 1);
- QItemSelection selection(topLeft, bottomRight);
- selectionModel->select(selection, QItemSelectionModel::Toggle);
+ const QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Toggle);
+ }
}
bool DolphinView::hasSelection() const