mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
code review
This commit is contained in:
parent
c2570adad6
commit
b1f15983de
@ -52,16 +52,6 @@ void CModListView::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void CModListView::dragMoveEvent(QDragMoveEvent* event)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void CModListView::dragLeaveEvent(QDragLeaveEvent* event)
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void CModListView::dropEvent(QDropEvent* event)
|
||||
{
|
||||
@ -69,21 +59,21 @@ void CModListView::dropEvent(QDropEvent* event)
|
||||
|
||||
if(mimeData->hasUrls())
|
||||
{
|
||||
QStringList pathList;
|
||||
QList<QUrl> urlList = mimeData->urls();
|
||||
const QList<QUrl> urlList = mimeData->urls();
|
||||
|
||||
for (int i = 0; i < urlList.size(); i++)
|
||||
for (auto & url : urlList)
|
||||
{
|
||||
QString url = urlList.at(i).toString();
|
||||
if(url.endsWith(".zip", Qt::CaseInsensitive))
|
||||
downloadFile(url.split("/").last().toLower()
|
||||
QString urlStr = url.toString();
|
||||
QString fileName = url.fileName();
|
||||
if(urlStr.endsWith(".zip", Qt::CaseInsensitive))
|
||||
downloadFile(fileName.toLower()
|
||||
// mod name currently comes from zip file -> remove suffixes from github zip download
|
||||
.replace(QRegularExpression("-[0-9a-f]{40}"), "")
|
||||
.replace(QRegularExpression("-vcmi-.*\\.zip"), ".zip")
|
||||
.replace(QRegularExpression("-main.zip"), ".zip")
|
||||
, url, "mods", 0);
|
||||
.replace(QRegularExpression("-vcmi-.+\\.zip"), ".zip")
|
||||
.replace("-main.zip", ".zip")
|
||||
, urlStr, "mods", 0);
|
||||
else
|
||||
downloadFile(url.split("/").last(), url, "mods", 0);
|
||||
downloadFile(fileName, urlStr, "mods", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1021,4 +1011,3 @@ void CModListView::on_allModsView_doubleClicked(const QModelIndex &index)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,6 @@ class CModListView : public QWidget
|
||||
|
||||
void changeEvent(QEvent *event) override;
|
||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
void dragMoveEvent(QDragMoveEvent* event) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
||||
void dropEvent(QDropEvent *event) override;
|
||||
signals:
|
||||
void modsChanged();
|
||||
|
Loading…
Reference in New Issue
Block a user