Commit e90f49e0 authored by Elvis Angelaccio's avatar Elvis Angelaccio

Accept drop events when creating a new archive

This fixes a small regression introduced by 1f075366.
parent 6e9bd80e
......@@ -43,8 +43,7 @@ ArchiveView::ArchiveView(QWidget *parent)
setDropIndicatorShown(true);
// #368807: drops must be initially disabled, otherwise they will override the MainWindow's ones.
// They will be enabled in Part::slotLoadingFinished().
setAcceptDrops(false);
setDragDropMode(QAbstractItemView::NoDragDrop);
setDropsEnabled(false);
}
void ArchiveView::startDrag(Qt::DropActions supportedActions)
......@@ -58,6 +57,11 @@ void ArchiveView::startDrag(Qt::DropActions supportedActions)
QTreeView::startDrag(supportedActions);
}
void ArchiveView::setDropsEnabled(bool enabled)
{
setAcceptDrops(enabled);
setDragDropMode(enabled ? QAbstractItemView::DragDrop : QAbstractItemView::NoDragDrop);
}
void ArchiveView::dragEnterEvent(QDragEnterEvent * event)
{
......
......@@ -34,6 +34,11 @@ public:
virtual void dropEvent(class QDropEvent * event) Q_DECL_OVERRIDE;
virtual void dragMoveEvent(class QDragMoveEvent * event) Q_DECL_OVERRIDE;
virtual void startDrag(Qt::DropActions supportedActions) Q_DECL_OVERRIDE;
/**
* Set whether the view should accept drop events.
*/
void setDropsEnabled(bool enabled);
};
#endif /* ARCHIVEVIEW_H */
......@@ -674,6 +674,7 @@ bool Part::openFile()
job->start();
} else {
updateActions();
m_view->setDropsEnabled(true);
}
m_infoPanel->setIndex(QModelIndex());
......@@ -805,8 +806,7 @@ void Part::slotLoadingFinished(KJob *job)
// After loading all files, resize the columns to fit all fields
m_view->header()->resizeSections(QHeaderView::ResizeToContents);
// Now we can start accepting drops in the archive view.
m_view->setAcceptDrops(true);
m_view->setDragDropMode(QAbstractItemView::DragDrop);
m_view->setDropsEnabled(true);
updateActions();
......
......@@ -33,6 +33,7 @@
#include <QModelIndex>
class ArchiveModel;
class ArchiveView;
class InfoPanel;
class KAboutData;
......@@ -145,7 +146,7 @@ private:
void registerJob(KJob *job);
ArchiveModel *m_model;
QTreeView *m_view;
ArchiveView *m_view;
QAction *m_previewAction;
QAction *m_openFileAction;
QAction *m_openFileWithAction;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment