mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
[Places Panel] Make use of KFilePlacesView::dragAutoActivationDelay
Code moved to KIO
This commit is contained in:
parent
32c072fe5f
commit
e9bd295b3c
|
@ -95,17 +95,9 @@ void PlacesPanel::proceedWithTearDown()
|
||||||
void PlacesPanel::readSettings()
|
void PlacesPanel::readSettings()
|
||||||
{
|
{
|
||||||
if (GeneralSettings::autoExpandFolders()) {
|
if (GeneralSettings::autoExpandFolders()) {
|
||||||
if (!m_dragActivationTimer) {
|
setDragAutoActivationDelay(750);
|
||||||
m_dragActivationTimer = new QTimer(this);
|
|
||||||
m_dragActivationTimer->setInterval(750);
|
|
||||||
m_dragActivationTimer->setSingleShot(true);
|
|
||||||
connect(m_dragActivationTimer, &QTimer::timeout,
|
|
||||||
this, &PlacesPanel::slotDragActivationTimeout);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
delete m_dragActivationTimer;
|
setDragAutoActivationDelay(0);
|
||||||
m_dragActivationTimer = nullptr;
|
|
||||||
m_pendingDragActivation = QPersistentModelIndex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int iconSize = qMax(0, PlacesPanelSettings::iconSize());
|
const int iconSize = qMax(0, PlacesPanelSettings::iconSize());
|
||||||
|
@ -135,46 +127,6 @@ void PlacesPanel::showEvent(QShowEvent* event)
|
||||||
KFilePlacesView::showEvent(event);
|
KFilePlacesView::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlacesPanel::dragMoveEvent(QDragMoveEvent *event)
|
|
||||||
{
|
|
||||||
KFilePlacesView::dragMoveEvent(event);
|
|
||||||
|
|
||||||
if (!m_dragActivationTimer) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QModelIndex index = indexAt(event->pos());
|
|
||||||
if (!index.isValid()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPersistentModelIndex persistentIndex(index);
|
|
||||||
if (!m_pendingDragActivation.isValid() || m_pendingDragActivation != persistentIndex) {
|
|
||||||
m_pendingDragActivation = persistentIndex;
|
|
||||||
m_dragActivationTimer->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlacesPanel::dragLeaveEvent(QDragLeaveEvent *event)
|
|
||||||
{
|
|
||||||
KFilePlacesView::dragLeaveEvent(event);
|
|
||||||
|
|
||||||
if (m_dragActivationTimer) {
|
|
||||||
m_dragActivationTimer->stop();
|
|
||||||
m_pendingDragActivation = QPersistentModelIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlacesPanel::dropEvent(QDropEvent *event)
|
|
||||||
{
|
|
||||||
KFilePlacesView::dropEvent(event);
|
|
||||||
|
|
||||||
if (m_dragActivationTimer) {
|
|
||||||
m_dragActivationTimer->stop();
|
|
||||||
m_pendingDragActivation = QPersistentModelIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlacesPanel::slotConfigureTrash()
|
void PlacesPanel::slotConfigureTrash()
|
||||||
{
|
{
|
||||||
const QUrl url = currentIndex().data(KFilePlacesModel::UrlRole).toUrl();
|
const QUrl url = currentIndex().data(KFilePlacesModel::UrlRole).toUrl();
|
||||||
|
@ -185,16 +137,6 @@ void PlacesPanel::slotConfigureTrash()
|
||||||
settingsDialog->show();
|
settingsDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlacesPanel::slotDragActivationTimeout()
|
|
||||||
{
|
|
||||||
if (!m_pendingDragActivation.isValid()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto *placesModel = static_cast<KFilePlacesModel *>(model());
|
|
||||||
Q_EMIT placeActivated(KFilePlacesModel::convertedUrl(placesModel->url(m_pendingDragActivation)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent)
|
void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent)
|
||||||
{
|
{
|
||||||
KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent);
|
KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent);
|
||||||
|
|
|
@ -54,13 +54,9 @@ Q_SIGNALS:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
|
||||||
void dragLeaveEvent(QDragLeaveEvent *event) override;
|
|
||||||
void dropEvent(QDropEvent *event) override;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void slotConfigureTrash();
|
void slotConfigureTrash();
|
||||||
void slotDragActivationTimeout();
|
|
||||||
void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
|
void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
|
||||||
void slotContextMenuAboutToShow(const QModelIndex &index, QMenu *menu);
|
void slotContextMenuAboutToShow(const QModelIndex &index, QMenu *menu);
|
||||||
void slotTearDownRequested(const QModelIndex &index);
|
void slotTearDownRequested(const QModelIndex &index);
|
||||||
|
@ -75,9 +71,6 @@ private:
|
||||||
QUrl m_url; // only used for initial setUrl
|
QUrl m_url; // only used for initial setUrl
|
||||||
QList<QAction*> m_customContextMenuActions;
|
QList<QAction*> m_customContextMenuActions;
|
||||||
|
|
||||||
QTimer *m_dragActivationTimer = nullptr;
|
|
||||||
QPersistentModelIndex m_pendingDragActivation;
|
|
||||||
|
|
||||||
Solid::StorageAccess *m_deviceToTearDown = nullptr;
|
Solid::StorageAccess *m_deviceToTearDown = nullptr;
|
||||||
|
|
||||||
QAction *m_configureTrashAction;
|
QAction *m_configureTrashAction;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user