1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

code review

This commit is contained in:
Laserlicht 2023-12-25 19:30:40 +01:00 committed by GitHub
parent c2570adad6
commit b1f15983de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 23 deletions

View File

@ -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;
}
}

View File

@ -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();