mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 03:25:16 +00:00
Rewrite Drag&Drop classification
This commit is contained in:
parent
af11ad6253
commit
b671bb72dc
1 changed files with 32 additions and 39 deletions
|
@ -1122,62 +1122,54 @@ int game_list_frame::IsValidFile(const QMimeData& md, QStringList* dropPaths)
|
|||
|
||||
const QList<QUrl> list = md.urls(); // get list of all the dropped file urls
|
||||
|
||||
for (int i = 0; i < list.count(); i++) // check each file in url list for valid type
|
||||
for (auto&& url : list) // check each file in url list for valid type
|
||||
{
|
||||
const QString path = list[i].toLocalFile(); // convert url to filepath
|
||||
const QString path = url.toLocalFile(); // convert url to filepath
|
||||
|
||||
const QFileInfo info = path;
|
||||
|
||||
// check for directories first, only valid if all other paths led to directories until now.
|
||||
if (QFileInfo(path).isDir())
|
||||
if (info.isDir())
|
||||
{
|
||||
if (i != 0 && dropType != DROP_DIR) return DROP_ERROR;
|
||||
if (dropType != DROP_DIR && dropType != DROP_ERROR)
|
||||
{
|
||||
return DROP_ERROR;
|
||||
}
|
||||
|
||||
dropType = DROP_DIR;
|
||||
|
||||
if (dropPaths)
|
||||
}
|
||||
else if (info.fileName() == "PS3UPDAT.PUP")
|
||||
{
|
||||
if (list.size() != 1)
|
||||
{
|
||||
dropPaths->append(path);
|
||||
return DROP_ERROR;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// now that we know it has to be a file we get the file ending
|
||||
QString suffix = QFileInfo(list[i].fileName()).suffix().toLower();
|
||||
|
||||
if (suffix.isEmpty()) return DROP_ERROR; // NANI the heck would you want such a file?
|
||||
|
||||
QString last_suffix;
|
||||
|
||||
if (i == 0) // the first item defines our file type
|
||||
{
|
||||
last_suffix = suffix;
|
||||
}
|
||||
else if (last_suffix == "pup" || last_suffix == "bin") // we only accept one firmware or eboot file
|
||||
{
|
||||
return list.count() != 1 ? dropType : DROP_ERROR;
|
||||
}
|
||||
else if (last_suffix != suffix) // we don't accept multiple file types
|
||||
{
|
||||
return DROP_ERROR;
|
||||
}
|
||||
|
||||
// set drop type by file ending
|
||||
if (suffix == "pkg")
|
||||
{
|
||||
dropType = DROP_PKG;
|
||||
}
|
||||
else if (suffix == "pup")
|
||||
{
|
||||
dropType = DROP_PUP;
|
||||
}
|
||||
else if (suffix == "rap")
|
||||
else if (info.suffix().toLower() == "pkg")
|
||||
{
|
||||
if (dropType != DROP_PKG && dropType != DROP_ERROR)
|
||||
{
|
||||
return DROP_ERROR;
|
||||
}
|
||||
|
||||
dropType = DROP_PKG;
|
||||
}
|
||||
else if (info.suffix() == "rap")
|
||||
{
|
||||
if (dropType != DROP_RAP && dropType != DROP_ERROR)
|
||||
{
|
||||
return DROP_ERROR;
|
||||
}
|
||||
|
||||
dropType = DROP_RAP;
|
||||
}
|
||||
else if (suffix == "bin")
|
||||
else if (list.size() == 1)
|
||||
{
|
||||
dropType = DROP_GAME;
|
||||
}
|
||||
else // if (suffix == "kuso")
|
||||
else
|
||||
{
|
||||
return DROP_ERROR;
|
||||
}
|
||||
|
@ -1187,6 +1179,7 @@ int game_list_frame::IsValidFile(const QMimeData& md, QStringList* dropPaths)
|
|||
dropPaths->append(path);
|
||||
}
|
||||
}
|
||||
|
||||
return dropType;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue