+ emit itemTriggered(item); // caught by DolphinViewContainer or DolphinPart
+}
+
+void DolphinView::slotSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
+{
+ const int count = selectedItemsCount();
+ const bool selectionStateChanged = ((count > 0) && (selected.count() == count)) ||
+ ((count == 0) && !deselected.isEmpty());
+
+ // If nothing has been selected before and something got selected (or if something
+ // was selected before and now nothing is selected) the selectionChangedSignal must
+ // be emitted asynchronously as fast as possible to update the edit-actions.
+ m_selectionChangedTimer->setInterval(selectionStateChanged ? 0 : 300);
+ m_selectionChangedTimer->start();
+}
+
+void DolphinView::emitSelectionChangedSignal()
+{
+ emit selectionChanged(DolphinView::selectedItems());
+}
+
+void DolphinView::openContextMenu(const QPoint& pos,
+ const QList<QAction*>& customActions)
+{
+ KFileItem item;
+ const QModelIndex index = m_viewAccessor.itemView()->indexAt(pos);
+ if (index.isValid() && (index.column() == DolphinModel::Name)) {
+ const QModelIndex dolphinModelIndex = m_viewAccessor.proxyModel()->mapToSource(index);
+ item = m_viewAccessor.dirModel()->itemForIndex(dolphinModelIndex);
+ }
+
+ m_isContextMenuOpen = true; // TODO: workaround for Qt-issue 207192
+ emit requestContextMenu(item, url(), customActions);
+ m_isContextMenuOpen = false;
+}
+
+void DolphinView::dropUrls(const KFileItem& destItem,
+ const KUrl& destPath,
+ QDropEvent* event)
+{
+ addNewFileNames(event->mimeData());
+ DragAndDropHelper::instance().dropUrls(destItem, destPath, event, this);
+}
+
+void DolphinView::updateSorting(DolphinView::Sorting sorting)
+{
+ ViewProperties props(rootUrl());
+ props.setSorting(sorting);
+
+ m_viewAccessor.proxyModel()->setSorting(sorting);
+
+ emit sortingChanged(sorting);
+}
+
+void DolphinView::updateSortOrder(Qt::SortOrder order)
+{
+ ViewProperties props(rootUrl());
+ props.setSortOrder(order);
+
+ m_viewAccessor.proxyModel()->setSortOrder(order);
+
+ emit sortOrderChanged(order);
+}
+
+void DolphinView::updateSortFoldersFirst(bool foldersFirst)
+{
+ ViewProperties props(rootUrl());
+ props.setSortFoldersFirst(foldersFirst);
+
+ m_viewAccessor.proxyModel()->setSortFoldersFirst(foldersFirst);
+
+ emit sortFoldersFirstChanged(foldersFirst);
+}
+
+void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList& info)
+{
+ ViewProperties props(rootUrl());
+ props.setAdditionalInfo(info);
+ props.save();
+
+ m_viewAccessor.itemDelegate()->setShowInformation(info);
+
+ emit additionalInfoChanged();
+}
+
+void DolphinView::updateAdditionalInfoActions(KActionCollection* collection)
+{
+ const AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
+
+ const KFileItemDelegate::InformationList checkedInfos = m_viewAccessor.itemDelegate()->showInformation();
+ const KFileItemDelegate::InformationList infos = infoAccessor.keys();
+
+ const bool enable = (m_mode == DolphinView::DetailsView) ||
+ (m_mode == DolphinView::IconsView);
+
+ foreach (const KFileItemDelegate::Information& info, infos) {
+ const QString name = infoAccessor.actionCollectionName(info, AdditionalInfoAccessor::AdditionalInfoType);
+ QAction* action = collection->action(name);
+ Q_ASSERT(action != 0);
+ action->setEnabled(enable);
+ action->setChecked(checkedInfos.contains(info));
+ }
+}
+
+QPair<bool, QString> DolphinView::pasteInfo() const
+{
+ return KonqOperations::pasteInfo(url());
+}
+
+void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
+{
+ m_tabsForFiles = tabsForFiles;
+}
+
+bool DolphinView::isTabsForFilesEnabled() const
+{
+ return m_tabsForFiles;
+}
+
+bool DolphinView::itemsExpandable() const
+{
+ return m_viewAccessor.itemsExpandable();
+}
+
+void DolphinView::restoreState(QDataStream& stream)
+{
+ // current item
+ stream >> m_activeItemUrl;
+
+ // view position
+ stream >> m_restoredContentsPosition;
+
+ // expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
+ QSet<KUrl> urlsToExpand;
+ stream >> urlsToExpand;
+ const DolphinDetailsViewExpander* expander = m_viewAccessor.setExpandedUrls(urlsToExpand);
+ if (expander != 0) {
+ m_expanderActive = true;
+ connect (expander, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
+ }
+ else {
+ m_expanderActive = false;
+ }
+}
+
+void DolphinView::saveState(QDataStream& stream)
+{
+ // current item
+ KFileItem currentItem;
+ const QAbstractItemView* view = m_viewAccessor.itemView();
+
+ if (view != 0) {
+ const QModelIndex proxyIndex = view->currentIndex();
+ const QModelIndex dirModelIndex = m_viewAccessor.proxyModel()->mapToSource(proxyIndex);
+ currentItem = m_viewAccessor.dirModel()->itemForIndex(dirModelIndex);
+ }
+
+ KUrl currentUrl;
+ if (!currentItem.isNull()) {
+ currentUrl = currentItem.url();
+ }
+
+ stream << currentUrl;
+
+ // view position
+ const int x = view->horizontalScrollBar()->value();
+ const int y = view->verticalScrollBar()->value();
+ stream << QPoint(x, y);
+
+ // expanded folders (only relevant for the details view - the set will be empty in other view modes)
+ stream << m_viewAccessor.expandedUrls();
+}
+
+void DolphinView::observeCreatedItem(const KUrl& url)
+{
+ m_createdItemUrl = url;
+ connect(m_viewAccessor.dirModel(), SIGNAL(rowsInserted(const QModelIndex&, int, int)),
+ this, SLOT(selectAndScrollToCreatedItem()));
+}
+
+void DolphinView::selectAndScrollToCreatedItem()
+{
+ const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForUrl(m_createdItemUrl);
+ if (dirIndex.isValid()) {
+ const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
+ m_viewAccessor.itemView()->setCurrentIndex(proxyIndex);
+ }
+
+ disconnect(m_viewAccessor.dirModel(), SIGNAL(rowsInserted(const QModelIndex&, int, int)),
+ this, SLOT(selectAndScrollToCreatedItem()));
+ m_createdItemUrl = KUrl();
+}
+
+void DolphinView::showHoverInformation(const KFileItem& item)
+{