X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/94ef8919bf196c134706d2ed71f9fadaec68838b..b9f1ebca009cb3da36ebc3d4537aedcc69770077:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index b1c0bf743..fdf93a1da 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -57,12 +57,12 @@ #include "dolphindetailsview.h" #include "dolphin_detailsmodesettings.h" #include "dolphiniconsview.h" -#include "dolphinsettings.h" +#include "settings/dolphinsettings.h" #include "dolphin_generalsettings.h" #include "draganddrophelper.h" #include "folderexpander.h" #include "renamedialog.h" -#include "tooltipmanager.h" +#include "tooltips/tooltipmanager.h" #include "viewproperties.h" #include "zoomlevelinfo.h" @@ -87,6 +87,7 @@ DolphinView::DolphinView(QWidget* parent, m_storedCategorizedSorting(false), m_tabsForFiles(false), m_isContextMenuOpen(false), + m_ignoreViewProperties(false), m_mode(DolphinView::IconsView), m_topLayout(0), m_controller(0), @@ -102,7 +103,7 @@ DolphinView::DolphinView(QWidget* parent, m_toolTipManager(0), m_rootUrl(), m_currentItemUrl(), - m_expandedViews() + m_expandedDragSource(0) { m_topLayout = new QVBoxLayout(this); m_topLayout->setSpacing(0); @@ -148,7 +149,9 @@ DolphinView::DolphinView(QWidget* parent, DolphinView::~DolphinView() { - deleteExpandedViews(); + kDebug() << "Deleted view " << m_expandedDragSource; + delete m_expandedDragSource; + m_expandedDragSource = 0; } const KUrl& DolphinView::url() const @@ -455,6 +458,8 @@ void DolphinView::reload() void DolphinView::refresh() { + m_ignoreViewProperties = false; + const bool oldActivationState = m_active; const int oldZoomLevel = m_controller->zoomLevel(); m_active = true; @@ -844,13 +849,16 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event) break; case QEvent::MouseButtonPress: - if ((watched == itemView()->viewport()) && (m_expandedViews.count() > 0)) { + kDebug() << "m_expandedDragSource = " << m_expandedDragSource; + if ((watched == itemView()->viewport()) && (m_expandedDragSource != 0)) { // Listening to a mousebutton press event to delete expanded views is a // workaround, as it seems impossible for the FolderExpander to know when // a dragging outside a view has been finished. However it works quite well: // A mousebutton press event indicates that a drag operation must be // finished already. - deleteExpandedViews(); + kDebug() << "Deleted view " << m_expandedDragSource; + m_expandedDragSource->deleteLater(); + m_expandedDragSource = 0; } break; @@ -860,6 +868,12 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event) } break; + case QEvent::KeyPress: + if ((watched == itemView()) && (m_toolTipManager != 0)) { + m_toolTipManager->hideTip(); + } + break; + default: break; } @@ -1052,6 +1066,29 @@ bool DolphinView::itemsExpandable() const return (m_detailsView != 0) && m_detailsView->itemsExpandable(); } +void DolphinView::deleteWhenNotDragSource(QAbstractItemView *view) +{ + if (view == 0) + return; + + if (DragAndDropHelper::instance().isDragSource(view)) { + kDebug() << "Is current drag source"; + // We must store for later deletion. + if (m_expandedDragSource != 0) { + // The old stored view is obviously not the drag source anymore. + kDebug() << "Deleted old view " << m_expandedDragSource; + m_expandedDragSource->deleteLater(); + m_expandedDragSource = 0; + } + view->hide(); + m_expandedDragSource = view; + } + else { + kDebug() << "Deleted new view " << view; + view->deleteLater(); + } +} + void DolphinView::emitContentsMoved() { // only emit the contents moved signal if: @@ -1104,16 +1141,6 @@ void DolphinView::restoreCurrentItem() } } -void DolphinView::enterDir(const QModelIndex& index, QAbstractItemView* view) -{ - // Deleting a view that is the root of a drag operation is not allowed, otherwise - // the dragging gets automatically cancelled by Qt. So before entering a new - // directory, the current view is remembered in m_expandedViews and deleted - // later when the drag operation has been finished (see DolphinView::eventFilter()). - m_expandedViews.append(view); - m_controller->triggerItem(index); -} - void DolphinView::loadDirectory(const KUrl& url, bool reload) { if (!url.isValid()) { @@ -1153,6 +1180,10 @@ KUrl DolphinView::viewPropertiesUrl() const void DolphinView::applyViewProperties(const KUrl& url) { + if (m_ignoreViewProperties) { + return; + } + if (isColumnViewActive() && rootUrl().isParentOf(url)) { // The column view is active, hence don't apply the view properties // of sub directories (represented by columns) to the view. The @@ -1222,6 +1253,13 @@ void DolphinView::applyViewProperties(const KUrl& url) // the used zoom level of the controller must be adjusted manually: updateZoomLevel(oldZoomLevel); } + + if (DolphinSettings::instance().generalSettings()->globalViewProps()) { + // During the lifetime of a DolphinView instance the global view properties + // should not be changed. This allows e. g. to split a view and use different + // view properties for each view. + m_ignoreViewProperties = true; + } } void DolphinView::createView() @@ -1265,8 +1303,13 @@ void DolphinView::createView() FolderExpander* folderExpander = new FolderExpander(view, m_proxyModel); folderExpander->setEnabled(enabled); - connect(folderExpander, SIGNAL(enterDir(const QModelIndex&, QAbstractItemView*)), - this, SLOT(enterDir(const QModelIndex&, QAbstractItemView*))); + connect(folderExpander, SIGNAL(enterDir(const QModelIndex&)), + m_controller, SLOT(triggerItem(const QModelIndex&))); + } + else { + // Listen out for requests to delete the current column. + connect(m_columnView, SIGNAL(requestColumnDeletion(QAbstractItemView*)), + this, SLOT(deleteWhenNotDragSource(QAbstractItemView*))); } m_controller->setItemView(view); @@ -1322,29 +1365,22 @@ void DolphinView::deleteView() m_topLayout->removeWidget(view); view->close(); + // m_previewGenerator's parent is not always destroyed, and we + // don't want two active at once - manually delete. + delete m_previewGenerator; + m_previewGenerator = 0; + disconnect(view); m_controller->disconnect(view); view->disconnect(); - bool deleteView = true; - foreach (const QAbstractItemView* expandedView, m_expandedViews) { - if (view == expandedView) { - // the current view got already expanded and must stay alive - // until the dragging has been completed - deleteView = false; - break; - } - } - if (deleteView) { - view->deleteLater(); - } + deleteWhenNotDragSource(view); view = 0; m_iconsView = 0; m_detailsView = 0; m_columnView = 0; m_fileItemDelegate = 0; - m_previewGenerator = 0; m_toolTipManager = 0; } } @@ -1410,17 +1446,6 @@ KUrl::List DolphinView::simplifiedSelectedUrls() const return list; } -void DolphinView::deleteExpandedViews() -{ - const QAbstractItemView* view = itemView(); - foreach (QAbstractItemView* expandedView, m_expandedViews) { - if (expandedView != view) { - expandedView->deleteLater(); - } - } - m_expandedViews.clear(); -} - QMimeData* DolphinView::selectionMimeData() const { if (isColumnViewActive()) {