Commit 1f075366 authored by Elvis Angelaccio's avatar Elvis Angelaccio

Stop crashing when dropping on empty ArchiveView

ArchiveView was accepting drops events unconditionally, overriding the
MainWindow's ones. This resulted in a crash when the ArchiveView was
empty. Now we initially disable drop events, so that we can actually
open an archive by dropping it to any position in the Ark window.

BUG: 368807
FIXED-IN: 16.08.2
parent 9a9a8510
......@@ -33,23 +33,18 @@
ArchiveView::ArchiveView(QWidget *parent)
: QTreeView(parent)
{
}
void ArchiveView::setModel(QAbstractItemModel *model)
{
QTreeView::setModel(model);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setAlternatingRowColors(true);
setAnimated(true);
setAllColumnsShowFocus(true);
setSortingEnabled(true);
//drag and drop
setDragEnabled(true);
setAcceptDrops(true);
setDropIndicatorShown(true);
setDragDropMode(QAbstractItemView::DragDrop);
// #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);
}
void ArchiveView::startDrag(Qt::DropActions supportedActions)
......
......@@ -34,8 +34,6 @@ 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;
void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
};
#endif /* ARCHIVEVIEW_H */
......@@ -287,8 +287,6 @@ void Part::setupView()
m_view->setModel(m_model);
m_view->setSortingEnabled(true);
connect(m_view->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &Part::updateActions);
connect(m_view->selectionModel(), &QItemSelectionModel::selectionChanged,
......@@ -810,6 +808,9 @@ 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);
updateActions();
......
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