]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
The &-shortcut from another action is not set until the action has been shown at...
[dolphin.git] / src / views / dolphinview.cpp
index 6cda685d9dcee3a65bfbe0e12af09cd46aa1044a..346c7b691800a3037f7a78cc735c9ae09e81d734 100644 (file)
@@ -314,16 +314,6 @@ KFileItemList DolphinView::selectedItems() const
     return itemList;
 }
 
-KUrl::List DolphinView::selectedUrls() const
-{
-    KUrl::List urls;
-    const KFileItemList list = selectedItems();
-    foreach (const KFileItem &item, list) {
-        urls.append(item.url());
-    }
-    return urls;
-}
-
 int DolphinView::selectedItemsCount() const
 {
     const QAbstractItemView* view = m_viewAccessor.itemView();
@@ -537,6 +527,7 @@ void DolphinView::setUrl(const KUrl& url)
 
     // The selection model might change in the case of the column view. Disconnect
     // from the current selection model and reconnect later after the URL switch.
+    const bool hadSelection = hasSelection();
     QAbstractItemView* view = m_viewAccessor.itemView();
     disconnect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
                this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
@@ -558,6 +549,9 @@ void DolphinView::setUrl(const KUrl& url)
     view = m_viewAccessor.itemView();
     connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
             this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+    if (hadSelection || hasSelection()) {
+        emitSelectionChangedSignal();
+    }
 }
 
 void DolphinView::selectAll()
@@ -705,40 +699,6 @@ void DolphinView::setCategorizedSorting(bool categorized)
     emit categorizedSortingChanged();
 }
 
-void DolphinView::toggleSortOrder()
-{
-    const Qt::SortOrder order = (sortOrder() == Qt::AscendingOrder) ?
-                                Qt::DescendingOrder :
-                                Qt::AscendingOrder;
-    setSortOrder(order);
-}
-
-void DolphinView::toggleSortFoldersFirst()
-{
-    setSortFoldersFirst(!sortFoldersFirst());
-}
-
-void DolphinView::toggleAdditionalInfo(QAction* action)
-{
-    const KFileItemDelegate::Information info =
-        static_cast<KFileItemDelegate::Information>(action->data().toInt());
-
-    KFileItemDelegate::InformationList list = additionalInfo();
-
-    const bool show = action->isChecked();
-
-    const int index = list.indexOf(info);
-    const bool containsInfo = (index >= 0);
-    if (show && !containsInfo) {
-        list.append(info);
-        setAdditionalInfo(list);
-    } else if (!show && containsInfo) {
-        list.removeAt(index);
-        setAdditionalInfo(list);
-        Q_ASSERT(list.indexOf(info) < 0);
-    }
-}
-
 void DolphinView::mouseReleaseEvent(QMouseEvent* event)
 {
     QWidget::mouseReleaseEvent(event);
@@ -832,7 +792,8 @@ void DolphinView::slotSelectionChanged(const QItemSelection& selected, const QIt
 
 void DolphinView::emitSelectionChangedSignal()
 {
-    emit selectionChanged(DolphinView::selectedItems());
+    m_selectionChangedTimer->stop();
+    emit selectionChanged(selectedItems());
 }
 
 void DolphinView::openContextMenu(const QPoint& pos,
@@ -1191,18 +1152,13 @@ void DolphinView::applyViewProperties()
 
 void DolphinView::createView()
 {
-    QAbstractItemView* view = m_viewAccessor.itemView();
-    if ((view != 0) && (view->selectionModel() != 0)) {
-        disconnect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
-                   this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
-    }
-
     deleteView();
 
     Q_ASSERT(m_viewAccessor.itemView() == 0);
+    Q_ASSERT(m_dolphinViewController->itemView() == 0);
     m_viewAccessor.createView(this, m_dolphinViewController, m_viewModeController, m_mode);
 
-    view = m_viewAccessor.itemView();
+    QAbstractItemView* view = m_viewAccessor.itemView();
     Q_ASSERT(view != 0);
     view->installEventFilter(this);
     view->viewport()->installEventFilter(this);
@@ -1222,7 +1178,15 @@ void DolphinView::createView()
 void DolphinView::deleteView()
 {
     QAbstractItemView* view = m_viewAccessor.itemView();
+    Q_ASSERT((m_dolphinViewController->itemView() == 0) || (m_dolphinViewController->itemView() == view));
+    m_dolphinViewController->setItemView(0);
+
     if (view != 0) {
+        if (view->selectionModel() != 0) {
+            disconnect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+                       this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+        }
+
         // It's important to set the keyboard focus to the parent
         // before deleting the view: Otherwise when having a split
         // view the other view will get the focus and will request
@@ -1230,13 +1194,7 @@ void DolphinView::deleteView()
         setFocusProxy(0);
         setFocus();
 
-        m_topLayout->removeWidget(view);
-        view->close();
-
-        // disconnect all signal/slots
-        disconnect(view);
         m_viewModeController->disconnect(view);
-        view->disconnect();
 
         m_viewAccessor.deleteView();
     }
@@ -1259,11 +1217,19 @@ void DolphinView::updateZoomLevel(int oldZoomLevel)
 
 KUrl::List DolphinView::simplifiedSelectedUrls() const
 {
-    KUrl::List list = selectedUrls();
-    if (itemsExpandable() ) {
-        list = KDirModel::simplifiedUrlList(list);
+    KUrl::List urls;
+
+    const KFileItemList items = selectedItems();
+    foreach (const KFileItem &item, items) {
+        urls.append(item.url());
+    }
+
+
+    if (itemsExpandable()) {
+        urls = KDirModel::simplifiedUrlList(urls);
     }
-    return list;
+
+    return urls;
 }
 
 QMimeData* DolphinView::selectionMimeData() const
@@ -1332,32 +1298,38 @@ void DolphinView::ViewAccessor::createView(QWidget* parent,
 
 void DolphinView::ViewAccessor::deleteView()
 {
-    QAbstractItemView* view = itemView();
-    if (view != 0) {
-        if (DragAndDropHelper::instance().isDragSource(view)) {
-            // The view is a drag source (the feature "Open folders
-            // during drag operations" is used). Deleting the view
-            // during an ongoing drag operation is not allowed, so
-            // this will postponed.
-            if (m_dragSource != 0) {
-                // the old stored view is obviously not the drag source anymore
-                m_dragSource->deleteLater();
-                m_dragSource = 0;
+    if (m_columnsContainer != 0) {
+        m_columnsContainer->close();
+        m_columnsContainer->disconnect();
+        m_columnsContainer->deleteLater();
+        m_columnsContainer = 0;
+    } else {
+        QAbstractItemView* view = itemView();
+        if (view != 0) {
+            view->close();
+            view->disconnect();
+
+            if (DragAndDropHelper::instance().isDragSource(view)) {
+                // The view is a drag source (the feature "Open folders
+                // during drag operations" is used). Deleting the view
+                // during an ongoing drag operation is not allowed, so
+                // this will postponed.
+                if (m_dragSource != 0) {
+                    // the old stored view is obviously not the drag source anymore
+                    m_dragSource->deleteLater();
+                    m_dragSource = 0;
+                }
+                view->hide();
+                m_dragSource = view;
+            } else {
+                view->deleteLater();
+                view = 0;
             }
-            view->hide();
-            m_dragSource = view;
-        } else {
-            view->deleteLater();
         }
-    }
 
-    m_iconsView = 0;
-    m_detailsView = 0;
-
-    if (m_columnsContainer != 0) {
-        m_columnsContainer->deleteLater();
+        m_iconsView = 0;
+        m_detailsView = 0;
     }
-    m_columnsContainer = 0;
 }