#include "dolphincolumnview.h"
#include "dolphincontroller.h"
#include "dolphinsortfilterproxymodel.h"
+#include "draganddrophelper.h"
#include "settings/dolphinsettings.h"
#include "dolphin_columnmodesettings.h"
m_contentX(0),
m_columns(),
m_emptyViewport(0),
- m_animation(0)
+ m_animation(0),
+ m_dragSource(0)
{
Q_ASSERT(controller != 0);
setFrameShape(QFrame::NoFrame);
setLayoutDirection(Qt::LeftToRight);
- connect(this, SIGNAL(viewportEntered()),
- controller, SLOT(emitViewportEntered()));
connect(controller, SIGNAL(activationChanged(bool)),
this, SLOT(updateColumnsBackground(bool)));
DolphinColumnViewContainer::~DolphinColumnViewContainer()
{
+ delete m_dragSource;
+ m_dragSource = 0;
}
KUrl DolphinColumnViewContainer::rootUrl() const
return m_columns[m_index];
}
-bool DolphinColumnViewContainer::showColumn(const KUrl& url)
+void DolphinColumnViewContainer::showColumn(const KUrl& url)
{
if (!rootUrl().isParentOf(url)) {
removeAllColumns();
m_columns[0]->setUrl(url);
- return false;
+ return;
}
int columnIndex = 0;
// the column represents already the requested URL, hence activate it
requestActivation(column);
layoutColumns();
- return false;
+ return;
} else if (!column->url().isParentOf(url)) {
// the column is no parent of the requested URL, hence
// just delete all remaining columns
m_index = columnIndex;
m_columns[m_index]->setActive(true);
assureVisibleActiveColumn();
-
- return true;
}
void DolphinColumnViewContainer::mousePressEvent(QMouseEvent* event)
QScrollArea::mousePressEvent(event);
}
+void DolphinColumnViewContainer::keyPressEvent(QKeyEvent* event)
+{
+ if (event->key() == Qt::Key_Left) {
+ setActiveColumnIndex(m_index - 1);
+ } else {
+ QScrollArea::keyPressEvent(event);
+ }
+}
+
void DolphinColumnViewContainer::resizeEvent(QResizeEvent* event)
{
QScrollArea::resizeEvent(event);
void DolphinColumnViewContainer::setActiveColumnIndex(int index)
{
- if (m_index == index) {
+ if ((m_index == index) || (index < 0) || (index >= m_columns.count())) {
return;
}
void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column)
{
- if (column != 0) {
- if (m_controller->itemView() == column) {
- m_controller->setItemView(0);
+ if (column == 0) {
+ return;
+ }
+
+ if (m_controller->itemView() == column) {
+ m_controller->setItemView(0);
+ }
+ // deleteWhenNotDragSource(column) does not necessarily delete column,
+ // and we want its preview generator destroyed immediately.
+ column->hide();
+ // Prevent automatic destruction of column when this DolphinColumnViewContainer
+ // is destroyed.
+ column->setParent(0);
+ column->disconnect();
+
+ if (DragAndDropHelper::instance().isDragSource(column)) {
+ // The column 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;
}
- // deleteWhenNotDragSource(column) does not necessarily delete column,
- // and we want its preview generator destroyed immediately.
column->hide();
- // Prevent automatic destruction of column when this DolphinColumnViewContainer
- // is destroyed.
column->setParent(0);
column->disconnect();
- emit requestColumnDeletion(column);
+
+ m_dragSource = column;
+ } else {
+ column->deleteLater();
}
}