DolphinQt2: Avoid an unnecessary string conversion
This commit is contained in:
parent
68152faf43
commit
f2103c1b51
|
@ -18,8 +18,7 @@ const QSize GAMECUBE_BANNER_SIZE(96, 32);
|
||||||
GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent)
|
GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
connect(&m_tracker, &GameTracker::GameLoaded, this, &GameListModel::UpdateGame);
|
connect(&m_tracker, &GameTracker::GameLoaded, this, &GameListModel::UpdateGame);
|
||||||
connect(&m_tracker, &GameTracker::GameRemoved, this,
|
connect(&m_tracker, &GameTracker::GameRemoved, this, &GameListModel::RemoveGame);
|
||||||
[this](const QString& path) { RemoveGame(path.toStdString()); });
|
|
||||||
connect(&Settings::Instance(), &Settings::PathAdded, &m_tracker, &GameTracker::AddDirectory);
|
connect(&Settings::Instance(), &Settings::PathAdded, &m_tracker, &GameTracker::AddDirectory);
|
||||||
connect(&Settings::Instance(), &Settings::PathRemoved, &m_tracker, &GameTracker::RemoveDirectory);
|
connect(&Settings::Instance(), &Settings::PathRemoved, &m_tracker, &GameTracker::RemoveDirectory);
|
||||||
connect(&Settings::Instance(), &Settings::PathReloadRequested, &m_tracker,
|
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) {
|
auto emit_game_loaded = [this](const std::shared_ptr<const UICommon::GameFile>& game) {
|
||||||
emit GameLoaded(std::move(game));
|
emit GameLoaded(std::move(game));
|
||||||
};
|
};
|
||||||
auto emit_game_removed = [this](const std::string& path) {
|
auto emit_game_removed = [this](const std::string& path) { emit GameRemoved(path); };
|
||||||
emit GameRemoved(QString::fromStdString(path));
|
|
||||||
};
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_mutex);
|
std::lock_guard<std::mutex> lk(m_mutex);
|
||||||
|
|
||||||
|
@ -159,7 +157,7 @@ void GameTracker::RemoveDirectoryInternal(const QString& dir)
|
||||||
removePath(path);
|
removePath(path);
|
||||||
m_tracked_files.remove(path);
|
m_tracked_files.remove(path);
|
||||||
if (m_started)
|
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);
|
m_tracked_files.remove(missing);
|
||||||
if (m_started)
|
if (m_started)
|
||||||
GameRemoved(missing);
|
GameRemoved(missing.toStdString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +203,7 @@ void GameTracker::UpdateFileInternal(const QString& file)
|
||||||
if (QFileInfo(file).exists())
|
if (QFileInfo(file).exists())
|
||||||
{
|
{
|
||||||
if (m_started)
|
if (m_started)
|
||||||
GameRemoved(file);
|
GameRemoved(file.toStdString());
|
||||||
addPath(file);
|
addPath(file);
|
||||||
LoadGame(file);
|
LoadGame(file);
|
||||||
}
|
}
|
||||||
|
@ -213,7 +211,7 @@ void GameTracker::UpdateFileInternal(const QString& file)
|
||||||
{
|
{
|
||||||
m_tracked_files.remove(file);
|
m_tracked_files.remove(file);
|
||||||
if (m_started)
|
if (m_started)
|
||||||
emit GameRemoved(file);
|
emit GameRemoved(file.toStdString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
@ -39,7 +40,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void GameLoaded(std::shared_ptr<const UICommon::GameFile> game);
|
void GameLoaded(std::shared_ptr<const UICommon::GameFile> game);
|
||||||
void GameRemoved(const QString& path);
|
void GameRemoved(const std::string& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadCache();
|
void LoadCache();
|
||||||
|
@ -80,3 +81,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr<const UICommon::GameFile>)
|
Q_DECLARE_METATYPE(std::shared_ptr<const UICommon::GameFile>)
|
||||||
|
Q_DECLARE_METATYPE(std::string)
|
||||||
|
|
Loading…
Reference in New Issue