void DolphinView::invertSelection()
{
- if (isColumnViewActive()) {
- // In opposite to QAbstractItemView::selectAll() there is no virtual method
- // for adjusting the invertion of a selection. As the generic approach by using
- // the selection model does not work for the column view, we delegate this task:
- m_columnView->invertSelection();
- } else {
- QItemSelectionModel* selectionModel = itemView()->selectionModel();
- const QAbstractItemModel* itemModel = selectionModel->model();
+ 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);
- }
+ QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Toggle);
}
bool DolphinView::hasSelection() const
QList<KFileItem> itemList;
const QModelIndexList indexList = selection.indexes();
- QModelIndexList::const_iterator end = indexList.end();
- for (QModelIndexList::const_iterator it = indexList.begin(); it != end; ++it) {
- Q_ASSERT((*it).isValid());
-
- KFileItem item = m_dirModel->itemForIndex(*it);
+ foreach (QModelIndex index, indexList) {
+ KFileItem item = m_dirModel->itemForIndex(index);
if (!item.isNull()) {
itemList.append(item);
}
void DolphinView::setContentsPosition(int x, int y)
{
QAbstractItemView* view = itemView();
- view->horizontalScrollBar()->setValue(x);
+
+ // the ColumnView takes care itself for the horizontal scrolling
+ if (!isColumnViewActive()) {
+ view->horizontalScrollBar()->setValue(x);
+ }
view->verticalScrollBar()->setValue(y);
m_loadingDirectory = false;
applyViewProperties(url);
startDirLister(url);
+ itemView()->setFocus();
}
void DolphinView::mouseReleaseEvent(QMouseEvent* event)
this, SLOT(emitContentsMoved()));
connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(emitContentsMoved()));
+ view->setFocus();
}
QAbstractItemView* DolphinView::itemView() const
void DolphinView::updateViewportColor()
{
- QColor color = KColorScheme(KColorScheme::View).background();
+ QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
if (m_active) {
emit urlChanged(url()); // Hmm, this is a hack; the url hasn't really changed.
emit selectionChanged(selectedItems());