Skip to content

Commit

Permalink
Merge pull request #3376 from spxtr/DQt2
Browse files Browse the repository at this point in the history
Use const reference, explicit, final, and override consistently in DQt2
  • Loading branch information
lioncash committed Dec 22, 2015
2 parents ce6de78 + 21032d7 commit 98c0c79
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 33 deletions.
6 changes: 3 additions & 3 deletions Source/Core/DolphinQt2/GameList/GameFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/DolphinQt2/GameList/GameFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class GameFile final
{
public:
explicit GameFile(QString path);
explicit GameFile(const QString& path);

bool IsValid() const { return m_valid; }

Expand Down Expand Up @@ -62,11 +62,11 @@ class GameFile final

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();
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/DolphinQt2/GameList/GameListModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class GameListModel final : public QAbstractTableModel
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(); }
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt2/GameList/GameTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -66,7 +66,7 @@ void GameTracker::UpdateDirectory(QString dir)
}
}

void GameTracker::UpdateFile(QString file)
void GameTracker::UpdateFile(const QString& file)
{
if (QFileInfo(file).exists())
{
Expand Down
10 changes: 6 additions & 4 deletions Source/Core/DolphinQt2/GameList/GameTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,15 +39,15 @@ public slots:
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

Expand Down
6 changes: 4 additions & 2 deletions Source/Core/DolphinQt2/GameList/ListProxyModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt2/GameList/TableProxyModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
5 changes: 1 addition & 4 deletions Source/Core/DolphinQt2/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <QAction>
#include <QDir>
#include <QFile>
#include <QFileDialog>
#include <QIcon>
#include <QLineEdit>
#include <QMenu>
#include <QMessageBox>

#include "Core/BootManager.h"
Expand Down Expand Up @@ -194,7 +191,7 @@ void MainWindow::ScreenShot()
Core::SaveScreenShot();
}

void MainWindow::StartGame(QString path)
void MainWindow::StartGame(const QString& path)
{
// If we're running, only start a new game once we've stopped the last.
if (Core::GetState() != Core::CORE_UNINITIALIZED)
Expand Down
5 changes: 4 additions & 1 deletion Source/Core/DolphinQt2/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ private slots:
void Browse();
void Play();
void Pause();

// May ask for confirmation. Returns whether or not it actually stopped.
bool Stop();
void ForceStop();

void FullScreen();
void ScreenShot();

Expand All @@ -44,7 +47,7 @@ private slots:
void MakeStack();
void MakeToolBar();

void StartGame(QString path);
void StartGame(const QString& path);
void ShowRenderWidget();
void HideRenderWidget();

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt2/MenuBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MenuBar final : public QMenuBar
Q_OBJECT

public:
MenuBar(QWidget* parent = nullptr);
explicit MenuBar(QWidget* parent = nullptr);

signals:
void Open();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt2/RenderWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RenderWidget final : public QWidget
Q_OBJECT

public:
RenderWidget(QWidget* parent = nullptr);
explicit RenderWidget(QWidget* parent = nullptr);

bool event(QEvent* event);

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt2/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ QString Settings::GetLastGame() const
return value(QStringLiteral("GameList/LastGame")).toString();
}

void Settings::SetLastGame(QString path)
void Settings::SetLastGame(const QString& path)
{
setValue(QStringLiteral("GameList/LastGame"), path);
}
Expand All @@ -39,7 +39,7 @@ QStringList Settings::GetPaths() const
return value(QStringLiteral("GameList/Paths")).toStringList();
}

void Settings::SetPaths(QStringList paths)
void Settings::SetPaths(const QStringList& paths)
{
setValue(QStringLiteral("GameList/Paths"), paths);
}
Expand Down
7 changes: 4 additions & 3 deletions Source/Core/DolphinQt2/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@

#include "DiscIO/Volume.h"

// UI settings to be stored in the config directory.
class Settings final : public QSettings
{
Q_OBJECT

public:
Settings(QObject* parent = nullptr);
explicit Settings(QObject* parent = nullptr);

// UI
QString GetThemeDir() const;

// GameList
QString GetLastGame() const;
void SetLastGame(QString path);
void SetLastGame(const QString& path);
QStringList GetPaths() const;
void SetPaths(QStringList paths);
void SetPaths(const QStringList& paths);
DiscIO::IVolume::ELanguage GetWiiSystemLanguage() const;
DiscIO::IVolume::ELanguage GetGCSystemLanguage() const;

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt2/ToolBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ToolBar final : public QToolBar
Q_OBJECT

public:
ToolBar(QWidget* parent = nullptr);
explicit ToolBar(QWidget* parent = nullptr);

public slots:
void EmulationStarted();
Expand Down

0 comments on commit 98c0c79

Please sign in to comment.