Permalink
Browse files

DolphinQt2: Avoid an unnecessary string conversion

  • Loading branch information...
JosJuice committed May 26, 2018
1 parent 68152fa commit f2103c1b511d4cc8521a768e132ac6e5ce4651a1
@@ -18,8 +18,7 @@ const QSize GAMECUBE_BANNER_SIZE(96, 32);
GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent)
{
connect(&m_tracker, &GameTracker::GameLoaded, this, &GameListModel::UpdateGame);
connect(&m_tracker, &GameTracker::GameRemoved, this,
[this](const QString& path) { RemoveGame(path.toStdString()); });
connect(&m_tracker, &GameTracker::GameRemoved, this, &GameListModel::RemoveGame);
connect(&Settings::Instance(), &Settings::PathAdded, &m_tracker, &GameTracker::AddDirectory);
connect(&Settings::Instance(), &Settings::PathRemoved, &m_tracker, &GameTracker::RemoveDirectory);
connect(&Settings::Instance(), &Settings::PathReloadRequested, &m_tracker,
@@ -90,9 +90,7 @@ void GameTracker::StartInternal()
auto emit_game_loaded = [this](const std::shared_ptr<const UICommon::GameFile>& game) {
emit GameLoaded(std::move(game));
};
auto emit_game_removed = [this](const std::string& path) {
emit GameRemoved(QString::fromStdString(path));
};
auto emit_game_removed = [this](const std::string& path) { emit GameRemoved(path); };
std::lock_guard<std::mutex> lk(m_mutex);
@@ -159,7 +157,7 @@ void GameTracker::RemoveDirectoryInternal(const QString& dir)
removePath(path);
m_tracked_files.remove(path);
if (m_started)
emit GameRemoved(path);
emit GameRemoved(path.toStdString());
}
}
}
@@ -195,7 +193,7 @@ void GameTracker::UpdateDirectoryInternal(const QString& dir)
{
m_tracked_files.remove(missing);
if (m_started)
GameRemoved(missing);
GameRemoved(missing.toStdString());
}
}
}
@@ -205,15 +203,15 @@ void GameTracker::UpdateFileInternal(const QString& file)
if (QFileInfo(file).exists())
{
if (m_started)
GameRemoved(file);
GameRemoved(file.toStdString());
addPath(file);
LoadGame(file);
}
else if (removePath(file))
{
m_tracked_files.remove(file);
if (m_started)
emit GameRemoved(file);
emit GameRemoved(file.toStdString());
}
}
@@ -6,6 +6,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <QFileSystemWatcher>
#include <QMap>
@@ -39,7 +40,7 @@ class GameTracker final : public QFileSystemWatcher
signals:
void GameLoaded(std::shared_ptr<const UICommon::GameFile> game);
void GameRemoved(const QString& path);
void GameRemoved(const std::string& path);
private:
void LoadCache();
@@ -80,3 +81,4 @@ class GameTracker final : public QFileSystemWatcher
};
Q_DECLARE_METATYPE(std::shared_ptr<const UICommon::GameFile>)
Q_DECLARE_METATYPE(std::string)

0 comments on commit f2103c1

Please sign in to comment.