FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
WinDiffusion/draggablelistwidget.cpp at master · ZDisket/WinDiffusion · GitHub
ZDisket
/
WinDiffusion
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
12
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
WinDiffusion
/
draggablelistwidget.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (40 loc) · 1.5 KB
Breadcrumbs
WinDiffusion
/
draggablelistwidget.cpp
Copy path
File metadata and controls
48 lines (40 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
DraggableListWidget.cpp
#
include
"
draggablelistwidget.h
"
#
include
"
pathwidgetitem.h
"
#
include
"
qevent.h
"
#
include
<
QFileInfo
>
DraggableListWidget::DraggableListWidget
(QWidget *parent) : QListWidget(parent) {
//
Enable drag and drop
setAcceptDrops
(
true
);
}
void
DraggableListWidget::dragEnterEvent
(QDragEnterEvent *event) {
//
Accept the drag event if it contains URLs (file paths)
if
(event->
mimeData
()->
hasUrls
()) {
event->
acceptProposedAction
();
}
}
void
DraggableListWidget::dragMoveEvent
(QDragMoveEvent *event) {
//
Accept the drag move event if it contains URLs
if
(event->
mimeData
()->
hasUrls
()) {
event->
acceptProposedAction
();
}
}
void
DraggableListWidget::dropEvent
(QDropEvent *event) {
const
QMimeData *mimeData = event->
mimeData
();
//
Check if the dropped data contains URLs
if
(mimeData->
hasUrls
()) {
QList<QUrl> urlList = mimeData->
urls
();
//
Process each URL
for
(
const
QUrl &url : urlList) {
QFileInfo
fileInfo
(url.
toLocalFile
());
QString filePath = fileInfo.
absoluteFilePath
();
//
Filter for .png, .jpg, .jpeg files
if
(fileInfo.
suffix
().
compare
(
"
png
"
, Qt::CaseInsensitive) ==
0
||
fileInfo.
suffix
().
compare
(
"
jpg
"
, Qt::CaseInsensitive) ==
0
||
fileInfo.
suffix
().
compare
(
"
jpeg
"
, Qt::CaseInsensitive) ==
0
) {
//
Add the file as a PathWidgetItem
new
PathWidgetItem
(filePath,
this
);
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL