mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
ensure history list will contain crc32 (#13883)
This commit is contained in:
parent
f377c0d041
commit
141bba0464
@ -45,6 +45,7 @@
|
||||
#include <QDropEvent>
|
||||
#include <QtConcurrentRun>
|
||||
#include <QtNetwork>
|
||||
#include <QFile>
|
||||
|
||||
#include "ui_qt.h"
|
||||
#include "qt/gridview.h"
|
||||
@ -82,6 +83,7 @@ extern "C" {
|
||||
#include "../../command.h"
|
||||
#include "../ui_companion_driver.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../encodings/crc32.h"
|
||||
#include "../../frontend/frontend.h"
|
||||
#include "../../frontend/frontend_driver.h"
|
||||
#include "../../file_path_special.h"
|
||||
@ -2599,7 +2601,7 @@ void MainWindow::onFileDoubleClicked(const QModelIndex &proxyIndex)
|
||||
if (m_fileModel->isDir(index))
|
||||
m_dirTree->setCurrentIndex(m_dirModel->index(m_fileModel->filePath(index)));
|
||||
else
|
||||
loadContent(getFileContentHash(index));
|
||||
loadContent(getFileContentHashWithCRC32(index));
|
||||
}
|
||||
|
||||
void MainWindow::selectBrowserDir(QString path)
|
||||
@ -2670,6 +2672,29 @@ QHash<QString, QString> MainWindow::getFileContentHash(const QModelIndex &index)
|
||||
return hash;
|
||||
}
|
||||
|
||||
QHash<QString, QString> MainWindow::getFileContentHashWithCRC32(const QModelIndex &index)
|
||||
{
|
||||
QHash<QString, QString> hash = getFileContentHash(index);
|
||||
hash["crc32"] = getFileCRC32(hash["path"]);
|
||||
return hash;
|
||||
}
|
||||
|
||||
QString MainWindow::getFileCRC32(const QString &path)
|
||||
{
|
||||
QString crc32;
|
||||
QFile file(path);
|
||||
if (file.exists() && file.open(QIODevice::ReadOnly)) {
|
||||
const QByteArray buf = file.readAll();
|
||||
file.close();
|
||||
crc32 = QString::number(encoding_crc32(0, (const uint8_t *) buf.data(), buf.size()), 16).toUpper();
|
||||
while (crc32.length() < 8) {
|
||||
crc32 = crc32.prepend('0');
|
||||
}
|
||||
}
|
||||
|
||||
return crc32;
|
||||
}
|
||||
|
||||
void MainWindow::onContentItemDoubleClicked(const QModelIndex &index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
@ -2933,7 +2958,7 @@ void MainWindow::onRunClicked()
|
||||
switch (m_currentBrowser)
|
||||
{
|
||||
case BROWSER_TYPE_FILES:
|
||||
contentHash = getFileContentHash(
|
||||
contentHash = getFileContentHashWithCRC32(
|
||||
m_proxyFileModel->mapToSource(m_fileTableView->currentIndex()));
|
||||
break;
|
||||
case BROWSER_TYPE_PLAYLISTS:
|
||||
|
@ -398,6 +398,8 @@ public:
|
||||
QModelIndex getCurrentContentIndex();
|
||||
QHash<QString, QString> getCurrentContentHash();
|
||||
QHash<QString, QString> getFileContentHash(const QModelIndex &index);
|
||||
QHash<QString, QString> getFileContentHashWithCRC32(const QModelIndex &index);
|
||||
QString getFileCRC32(const QString &path);
|
||||
static double lerp(double x, double y, double a, double b, double d);
|
||||
QString getSpecialPlaylistPath(SpecialPlaylist playlist);
|
||||
QVector<QPair<QString, QString> > getPlaylists();
|
||||
|
Loading…
x
Reference in New Issue
Block a user