Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F629448
RepositoriesTreeWidget.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
RepositoriesTreeWidget.cpp
View Options
#include
"RepositoriesTreeWidget.h"
#include
<QDropEvent>
#include
<QDebug>
#include
<QMimeData>
#include
<QApplication>
#include
"CloneFromGitHubDialog.h"
#include
"MainWindow.h"
RepositoriesTreeWidget
::
RepositoriesTreeWidget
(
QWidget
*
parent
)
:
QTreeWidget
(
parent
)
{
connect
(
this
,
&
RepositoriesTreeWidget
::
currentItemChanged
,
[
&
](
QTreeWidgetItem
*
current
,
QTreeWidgetItem
*
){
current_item
=
current
;
});
}
MainWindow
*
RepositoriesTreeWidget
::
mainwindow
()
{
return
qobject_cast
<
MainWindow
*>
(
window
());
}
void
RepositoriesTreeWidget
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
if
(
QApplication
::
modalWindow
())
return
;
if
(
event
->
mimeData
()
->
hasUrls
())
{
event
->
acceptProposedAction
();
event
->
accept
();
return
;
}
QTreeWidget
::
dragEnterEvent
(
event
);
}
void
RepositoriesTreeWidget
::
dropEvent
(
QDropEvent
*
event
)
{
if
(
QApplication
::
modalWindow
())
return
;
if
(
0
)
{
QMimeData
const
*
mimedata
=
event
->
mimeData
();
QByteArray
encoded
=
mimedata
->
data
(
"application/x-qabstractitemmodeldatalist"
);
QDataStream
stream
(
&
encoded
,
QIODevice
::
ReadOnly
);
while
(
!
stream
.
atEnd
())
{
int
row
,
col
;
QMap
<
int
,
QVariant
>
roledatamap
;
stream
>>
row
>>
col
>>
roledatamap
;
}
}
if
(
event
->
mimeData
()
->
hasUrls
())
{
Q_ASSERT
(
mainwindow
());
QStringList
paths
;
QByteArray
ba
=
event
->
mimeData
()
->
data
(
"text/uri-list"
);
if
(
ba
.
size
()
>
4
&&
memcmp
(
ba
.
data
(),
"h
\0
t
\0
t
\0
p
\0
"
,
8
)
==
0
)
{
QString
path
=
QString
::
fromUtf16
((
ushort
const
*
)
ba
.
data
(),
ba
.
size
()
/
2
);
int
i
=
path
.
indexOf
(
'\n'
);
if
(
i
>=
0
)
{
path
=
path
.
mid
(
0
,
i
);
}
if
(
!
path
.
isEmpty
())
{
paths
.
push_back
(
path
);
}
}
else
{
QList
<
QUrl
>
urls
=
event
->
mimeData
()
->
urls
();
for
(
QUrl
const
&
url
:
urls
)
{
QString
path
=
url
.
url
();
paths
.
push_back
(
path
);
}
}
for
(
QString
const
&
path
:
paths
)
{
if
(
path
.
startsWith
(
"file://"
))
{
int
i
=
7
;
#ifdef Q_OS_WIN
if
(
path
.
utf16
()[
i
]
==
'/'
)
{
i
++
;
}
#endif
mainwindow
()
->
addWorkingCopyDir
(
path
.
mid
(
i
),
false
);
}
else
if
(
path
.
startsWith
(
"https://github.com/"
))
{
int
i
=
19
;
int
j
=
path
.
indexOf
(
'/'
,
i
);
if
(
j
>
i
)
{
QString
username
=
path
.
mid
(
i
,
j
-
i
);
QString
reponame
=
path
.
mid
(
j
+
1
);
mainwindow
()
->
postOpenRepositoryFromGitHub
(
username
,
reponame
);
}
}
}
}
else
{
QTreeWidgetItem
*
item
=
current_item
;
QTreeWidget
::
dropEvent
(
event
);
setCurrentItem
(
item
);
emit
dropped
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sun, Nov 15, 6:51 AM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
130954
Default Alt Text
RepositoriesTreeWidget.cpp (2 KB)
Attached To
Mode
R77 Guitar
Attached
Detach File
Event Timeline