forked from qt-creator/qt-creator
Editors: Support dragging from file system view to splits
Change-Id: I17d08fa3cf018f036f88f6be027e4c3740e90f74 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -75,6 +75,7 @@ public:
|
|||||||
explicit DotRemovalFilter(QObject *parent = 0);
|
explicit DotRemovalFilter(QObject *parent = 0);
|
||||||
protected:
|
protected:
|
||||||
virtual bool filterAcceptsRow(int source_row, const QModelIndex &parent) const;
|
virtual bool filterAcceptsRow(int source_row, const QModelIndex &parent) const;
|
||||||
|
Qt::DropActions supportedDragActions() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
DotRemovalFilter::DotRemovalFilter(QObject *parent) : QSortFilterProxyModel(parent)
|
DotRemovalFilter::DotRemovalFilter(QObject *parent) : QSortFilterProxyModel(parent)
|
||||||
@@ -90,12 +91,18 @@ bool DotRemovalFilter::filterAcceptsRow(int source_row, const QModelIndex &paren
|
|||||||
return fileName != QLatin1String(".");
|
return fileName != QLatin1String(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions DotRemovalFilter::supportedDragActions() const
|
||||||
|
{
|
||||||
|
return sourceModel()->supportedDragActions();
|
||||||
|
}
|
||||||
|
|
||||||
// FolderNavigationModel: Shows path as tooltip.
|
// FolderNavigationModel: Shows path as tooltip.
|
||||||
class FolderNavigationModel : public QFileSystemModel
|
class FolderNavigationModel : public QFileSystemModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit FolderNavigationModel(QObject *parent = 0);
|
explicit FolderNavigationModel(QObject *parent = 0);
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
Qt::DropActions supportedDragActions() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
FolderNavigationModel::FolderNavigationModel(QObject *parent) :
|
FolderNavigationModel::FolderNavigationModel(QObject *parent) :
|
||||||
@@ -111,6 +118,11 @@ QVariant FolderNavigationModel::data(const QModelIndex &index, int role) const
|
|||||||
return QFileSystemModel::data(index, role);
|
return QFileSystemModel::data(index, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions FolderNavigationModel::supportedDragActions() const
|
||||||
|
{
|
||||||
|
return Qt::MoveAction;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class FolderNavigationWidget
|
\class FolderNavigationWidget
|
||||||
|
|
||||||
@@ -141,6 +153,8 @@ FolderNavigationWidget::FolderNavigationWidget(QWidget *parent)
|
|||||||
m_listView->setModel(m_filterModel);
|
m_listView->setModel(m_filterModel);
|
||||||
m_listView->setFrameStyle(QFrame::NoFrame);
|
m_listView->setFrameStyle(QFrame::NoFrame);
|
||||||
m_listView->setAttribute(Qt::WA_MacShowFocusRect, false);
|
m_listView->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||||
|
m_listView->setDragEnabled(true);
|
||||||
|
m_listView->setDragDropMode(QAbstractItemView::DragOnly);
|
||||||
setFocusProxy(m_listView);
|
setFocusProxy(m_listView);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
|
|||||||
Reference in New Issue
Block a user