Warning, file /sdk/kdiff3/src/FileNameLineEdit.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // clang-format off
0002 /*
0003  * KDiff3 - Text Diff And Merge Tool
0004  *
0005  * SPDX-FileCopyrightText: 2019-2020 Michael Reeves reeves.87@gmail.com
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 // clang-format on
0009 #include "FileNameLineEdit.h"
0010 
0011 #include "fileaccess.h"
0012 #include "Logging.h"
0013 
0014 #include <QDropEvent>
0015 #include <QDragEnterEvent>
0016 #include <QMimeData>
0017 #include <QUrl>
0018 
0019 void FileNameLineEdit::dropEvent(QDropEvent* event)
0020 {
0021     assert(event->mimeData()->hasUrls());//Debugging aid in case FileNameLineEdit::dragEnterEvent is changed to accept other types.
0022 
0023     qCDebug(kdiffMain) << "Enter FileNameLineEdit::dropEvent";
0024     QList<QUrl> lst = event->mimeData()->urls();
0025 
0026     if(lst.count() > 0)
0027     {
0028         /*
0029             Do not use QUrl::toString() here. Sadly the Qt5 version does not permit Qt4 style
0030             fullydecoded conversions. It also treats empty schemes as non-local.
0031         */
0032         qCDebug(kdiffMain) << "Received Drop Event";
0033         qCDebug(kdiffMain) << "Url List Size: " << lst.count();
0034         qCDebug(kdiffMain) << "lst[0] = " << lst[0];
0035         setText(FileAccess::prettyAbsPath(lst[0]));
0036         qCDebug(kdiffMain) << "Set line edit text to: " << text() ;
0037         setFocus();
0038         Q_EMIT returnPressed();
0039     }
0040     qCDebug(kdiffMain) << "Leave FileNameLineEdit::dropEvent";
0041 }
0042 
0043 void FileNameLineEdit::dragEnterEvent(QDragEnterEvent* e)
0044 {
0045     e->setAccepted(e->mimeData()->hasUrls());
0046 }