+QModelIndex DolphinColumnView::indexAt(const QPoint& point) const
+{
+ foreach (DolphinColumnWidget* column, m_columns) {
+ const QModelIndex index = column->indexAt(columnPosition(column, point));
+ if (index.isValid()) {
+ return index;
+ }
+ }
+
+ return QModelIndex();
+}
+
+KFileItem DolphinColumnView::itemAt(const QPoint& point) const
+{
+ foreach (DolphinColumnWidget* column, m_columns) {
+ KFileItem item = column->itemAt(columnPosition(column, point));
+ if (!item.isNull()) {
+ return item;
+ }
+ }
+
+ return KFileItem();
+}
+
+void DolphinColumnView::scrollTo(const QModelIndex& index, ScrollHint hint)
+{
+ activeColumn()->scrollTo(index, hint);
+}
+
+QRect DolphinColumnView::visualRect(const QModelIndex& index) const
+{
+ return activeColumn()->visualRect(index);
+}
+
+void DolphinColumnView::invertSelection()
+{
+ QItemSelectionModel* selectionModel = activeColumn()->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 QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Toggle);
+}
+
+void DolphinColumnView::reload()
+{
+ foreach (DolphinColumnWidget* column, m_columns) {
+ column->reload();
+ }
+}
+
+void DolphinColumnView::setRootUrl(const KUrl& url)
+{
+ removeAllColumns();
+ m_columns[0]->setUrl(url);
+}
+
+void DolphinColumnView::setNameFilter(const QString& nameFilter)
+{
+ if (nameFilter != m_nameFilter) {
+ m_nameFilter = nameFilter;
+ foreach (DolphinColumnWidget* column, m_columns) {
+ column->setNameFilter(nameFilter);
+ }
+ }
+}
+
+QString DolphinColumnView::nameFilter() const
+{
+ return m_nameFilter;
+}
+
+KUrl DolphinColumnView::rootUrl() const
+{
+ return m_columns[0]->url();
+}
+
+void DolphinColumnView::showColumn(const KUrl& url)
+{
+ if (!rootUrl().isParentOf(url)) {
+ setRootUrl(url);
+ return;
+ }
+
+ int columnIndex = 0;
+ foreach (DolphinColumnWidget* column, m_columns) {
+ if (column->url() == url) {
+ // the column represents already the requested URL, hence activate it
+ requestActivation(column);
+ layoutColumns();
+ return;
+ } else if (!column->url().isParentOf(url)) {
+ // the column is no parent of the requested URL, hence
+ // just delete all remaining columns
+ if (columnIndex > 0) {
+ QList<DolphinColumnWidget*>::iterator start = m_columns.begin() + columnIndex;
+ QList<DolphinColumnWidget*>::iterator end = m_columns.end();
+ for (QList<DolphinColumnWidget*>::iterator it = start; it != end; ++it) {
+ deleteColumn(*it);
+ }
+ m_columns.erase(start, end);
+
+ const int maxIndex = m_columns.count() - 1;
+ Q_ASSERT(maxIndex >= 0);
+ if (m_index > maxIndex) {
+ m_index = maxIndex;
+ }
+ break;
+ }
+ }
+ ++columnIndex;
+ }
+
+ // Create missing columns. Assuming that the path is "/home/peter/Temp/" and
+ // the target path is "/home/peter/Temp/a/b/c/", then the columns "a", "b" and
+ // "c" will be created.
+ const int lastIndex = m_columns.count() - 1;
+ Q_ASSERT(lastIndex >= 0);
+
+ const KUrl& activeUrl = m_columns[lastIndex]->url();
+ Q_ASSERT(activeUrl.isParentOf(url));
+ Q_ASSERT(activeUrl != url);
+
+ QString path = activeUrl.url(KUrl::AddTrailingSlash);
+ const QString targetPath = url.url(KUrl::AddTrailingSlash);
+
+ columnIndex = lastIndex;
+ int slashIndex = path.count('/');
+ bool hasSubPath = (slashIndex >= 0);
+ while (hasSubPath) {
+ const QString subPath = targetPath.section('/', slashIndex, slashIndex);
+ if (subPath.isEmpty()) {
+ hasSubPath = false;
+ } else {
+ path += subPath + '/';
+ ++slashIndex;
+
+ const KUrl childUrl = KUrl(path);
+ m_columns[columnIndex]->setChildUrl(childUrl);
+ columnIndex++;
+
+ DolphinColumnWidget* column = new DolphinColumnWidget(viewport(), this, childUrl);
+ const QString filter = nameFilter();
+ if (!filter.isEmpty()) {
+ column->setNameFilter(filter);
+ }
+ column->setActive(false);
+
+ m_columns.append(column);
+
+ // Before invoking layoutColumns() the column must be set visible temporary.
+ // To prevent a flickering the initial geometry is set to a hidden position.
+ column->setGeometry(QRect(-1, -1, 1, 1));
+ column->show();
+ layoutColumns();
+ updateScrollBar();
+ }
+ }
+
+ // set the last column as active column without modifying the controller
+ // and hence the history
+ activeColumn()->setActive(false);
+ m_index = columnIndex;
+ activeColumn()->setActive(true);
+ assureVisibleActiveColumn();
+}
+
+void DolphinColumnView::editItem(const KFileItem& item)
+{
+ activeColumn()->editItem(item);
+}
+
+KFileItemList DolphinColumnView::selectedItems() const
+{
+ return activeColumn()->selectedItems();
+}
+
+QMimeData* DolphinColumnView::selectionMimeData() const
+{
+ return activeColumn()->selectionMimeData();
+}
+
+void DolphinColumnView::selectAll()
+{
+ activeColumn()->selectAll();
+}
+
+bool DolphinColumnView::isIndexHidden(const QModelIndex& index) const
+{
+ Q_UNUSED(index);
+ return false;//activeColumn()->isIndexHidden(index);
+}
+
+QModelIndex DolphinColumnView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
+{
+ // Parts of this code have been taken from QColumnView::moveCursor().
+ // Copyright (C) 1992-2007 Trolltech ASA.
+
+ Q_UNUSED(modifiers);
+ if (model() == 0) {
+ return QModelIndex();
+ }
+
+ const QModelIndex current = currentIndex();
+ if (isRightToLeft()) {
+ if (cursorAction == MoveLeft) {
+ cursorAction = MoveRight;
+ } else if (cursorAction == MoveRight) {
+ cursorAction = MoveLeft;
+ }
+ }
+
+ switch (cursorAction) {
+ case MoveLeft:
+ if (m_index > 0) {
+ setActiveColumnIndex(m_index - 1);
+ m_controller->triggerUrlChangeRequest(activeColumn()->url());
+ }
+ break;
+
+ case MoveRight:
+ if (m_index < m_columns.count() - 1) {
+ setActiveColumnIndex(m_index + 1);
+ m_controller->triggerUrlChangeRequest(m_columns[m_index]->url());
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return QModelIndex();
+}
+
+void DolphinColumnView::setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags)
+{
+ Q_UNUSED(rect);
+ Q_UNUSED(flags);
+}
+
+QRegion DolphinColumnView::visualRegionForSelection(const QItemSelection& selection) const
+{
+ Q_UNUSED(selection);
+ return QRegion();
+}
+
+int DolphinColumnView::horizontalOffset() const
+{
+ return -m_contentX;
+}
+
+int DolphinColumnView::verticalOffset() const
+{
+ return 0;
+}
+
+void DolphinColumnView::mousePressEvent(QMouseEvent* event)
+{
+ m_controller->requestActivation();
+ QAbstractItemView::mousePressEvent(event);
+}
+
+void DolphinColumnView::resizeEvent(QResizeEvent* event)