mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-26 07:39:45 -06:00
Use const reference, explicit, final, and override in DQt2.
This commit is contained in:
@ -29,7 +29,7 @@ static QMap<DiscIO::IVolume::ELanguage, QString> ConvertLanguageMap(
|
||||
return result;
|
||||
}
|
||||
|
||||
GameFile::GameFile(QString path) : m_path(path)
|
||||
GameFile::GameFile(const QString& path) : m_path(path)
|
||||
{
|
||||
m_valid = false;
|
||||
|
||||
@ -81,7 +81,7 @@ void GameFile::ReadBanner(const DiscIO::IVolume& volume)
|
||||
m_banner = Resources::GetMisc(Resources::BANNER_MISSING);
|
||||
}
|
||||
|
||||
bool GameFile::LoadFileInfo(QString path)
|
||||
bool GameFile::LoadFileInfo(const QString& path)
|
||||
{
|
||||
QFileInfo info(path);
|
||||
if (!info.exists() || !info.isReadable())
|
||||
@ -184,7 +184,7 @@ void GameFile::SaveCache()
|
||||
// TODO
|
||||
}
|
||||
|
||||
QString GameFile::GetLanguageString(QMap<DiscIO::IVolume::ELanguage, QString> m) const
|
||||
QString GameFile::GetLanguageString(const QMap<DiscIO::IVolume::ELanguage, QString>& m) const
|
||||
{
|
||||
// Try the settings language, then English, then just pick one.
|
||||
if (m.isEmpty())
|
||||
|
@ -15,7 +15,7 @@
|
||||
class GameFile final
|
||||
{
|
||||
public:
|
||||
explicit GameFile(QString path);
|
||||
explicit GameFile(const QString& path);
|
||||
|
||||
bool IsValid() const { return m_valid; }
|
||||
|
||||
@ -62,11 +62,11 @@ public:
|
||||
|
||||
private:
|
||||
DiscIO::IVolume::ELanguage GetDefaultLanguage() const;
|
||||
QString GetLanguageString(QMap<DiscIO::IVolume::ELanguage, QString> m) const;
|
||||
QString GetLanguageString(const QMap<DiscIO::IVolume::ELanguage, QString>& m) const;
|
||||
|
||||
QString GetCacheFileName() const;
|
||||
void ReadBanner(const DiscIO::IVolume& volume);
|
||||
bool LoadFileInfo(QString path);
|
||||
bool LoadFileInfo(const QString& path);
|
||||
void LoadState();
|
||||
bool IsElfOrDol();
|
||||
bool TryLoadElfDol();
|
||||
|
@ -18,10 +18,10 @@ public:
|
||||
explicit GameListModel(QObject* parent = nullptr);
|
||||
|
||||
// Qt's Model/View stuff uses these overrides.
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
int rowCount(const QModelIndex& parent) const;
|
||||
int columnCount(const QModelIndex& parent) const;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex& parent) const override;
|
||||
int columnCount(const QModelIndex& parent) const override;
|
||||
|
||||
// Path of the Game at the specified index.
|
||||
QString GetPath(int index) const { return m_games[index]->GetPath(); }
|
||||
|
@ -51,7 +51,7 @@ void GameTracker::AddDirectory(QString dir)
|
||||
UpdateDirectory(dir);
|
||||
}
|
||||
|
||||
void GameTracker::UpdateDirectory(QString dir)
|
||||
void GameTracker::UpdateDirectory(const QString& dir)
|
||||
{
|
||||
QDirIterator it(dir, game_filters);
|
||||
while (it.hasNext())
|
||||
@ -66,7 +66,7 @@ void GameTracker::UpdateDirectory(QString dir)
|
||||
}
|
||||
}
|
||||
|
||||
void GameTracker::UpdateFile(QString file)
|
||||
void GameTracker::UpdateFile(const QString& file)
|
||||
{
|
||||
if (QFileInfo(file).exists())
|
||||
{
|
||||
|
@ -18,7 +18,9 @@ class GameLoader;
|
||||
|
||||
// Watches directories and loads GameFiles in a separate thread.
|
||||
// To use this, just add directories using AddDirectory, and listen for the
|
||||
// GameLoaded and GameRemoved signals.
|
||||
// GameLoaded and GameRemoved signals. Ignore the PathChanged signal, it's
|
||||
// only there because the Qt people made fileChanged and directoryChanged
|
||||
// private.
|
||||
class GameTracker final : public QFileSystemWatcher
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -37,15 +39,15 @@ signals:
|
||||
void PathChanged(QString path);
|
||||
|
||||
private:
|
||||
void UpdateDirectory(QString dir);
|
||||
void UpdateFile(QString path);
|
||||
void UpdateDirectory(const QString& dir);
|
||||
void UpdateFile(const QString& path);
|
||||
|
||||
QSet<QString> m_tracked_files;
|
||||
QThread m_loader_thread;
|
||||
GameLoader* m_loader;
|
||||
};
|
||||
|
||||
class GameLoader : public QObject
|
||||
class GameLoader final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -4,11 +4,13 @@
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
// This subclass of QSortFilterProxyModel transforms the raw data into a
|
||||
// single-column large icon + name to be displayed in a QListView.
|
||||
class ListProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ListProxyModel(QObject* parent = nullptr);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
explicit ListProxyModel(QObject* parent = nullptr);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
};
|
||||
|
@ -14,6 +14,6 @@ class TableProxyModel final : public QSortFilterProxyModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TableProxyModel(QObject* parent = nullptr);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
explicit TableProxyModel(QObject* parent = nullptr);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user