diff options
author | Janrupf <werbung.janrupf@t-online.de> | 2018-04-06 15:08:59 +0200 |
---|---|---|
committer | Janrupf <werbung.janrupf@t-online.de> | 2018-04-06 19:39:12 +0200 |
commit | 97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25 (patch) | |
tree | 461a6963a8f822e700aae30549ccb02f5c6bb160 /application/FtbListModel.cpp | |
parent | df6e66101c2ce5635f20df2f1d7954a681845ab1 (diff) | |
download | PrismLauncher-97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25.tar.gz PrismLauncher-97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25.tar.bz2 PrismLauncher-97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25.zip |
NOISSUE Fixed code for PR
Diffstat (limited to 'application/FtbListModel.cpp')
-rw-r--r-- | application/FtbListModel.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/application/FtbListModel.cpp b/application/FtbListModel.cpp index 41e49b65..7bf0a601 100644 --- a/application/FtbListModel.cpp +++ b/application/FtbListModel.cpp @@ -64,14 +64,10 @@ FtbFilterModel::Sorting FtbFilterModel::getCurrentSorting() FtbListModel::FtbListModel(QObject *parent) : QAbstractListModel(parent) { - m_logoPool = new QThreadPool(this); - m_logoPool->setMaxThreadCount(4); } FtbListModel::~FtbListModel() { - m_logoPool->waitForDone(500); - m_logoPool->deleteLater(); } QString FtbListModel::translatePackType(FtbPackType type) const @@ -100,7 +96,7 @@ int FtbListModel::columnCount(const QModelIndex &parent) const QVariant FtbListModel::data(const QModelIndex &index, int role) const { int pos = index.row(); - if(modpacks.size() <= pos || pos < 0 || !index.isValid()) { + if(pos >= modpacks.size() || pos < 0 || !index.isValid()) { return QString("INVALID INDEX %1").arg(pos); } @@ -120,9 +116,9 @@ QVariant FtbListModel::data(const QModelIndex &index, int role) const if(m_logoMap.contains(pack.logo)) { return (m_logoMap.value(pack.logo)); } - QPixmap pixmap = MMC->getThemedIcon("screenshot-placeholder").pixmap(QSize(42, 42)); + QIcon icon = MMC->getThemedIcon("screenshot-placeholder"); ((FtbListModel *)this)->requestLogo(pack.logo); - return pixmap; + return icon; } else if(role == Qt::TextColorRole) { if(pack.broken) { //FIXME: Hardcoded color @@ -153,11 +149,11 @@ FtbModpack FtbListModel::at(int row) return modpacks.at(row); } -void FtbListModel::logoLoaded(QString logo, QPixmap out) +void FtbListModel::logoLoaded(QString logo, QIcon out) { m_loadingLogos.removeAll(logo); m_logoMap.insert(logo, out); - emit dataChanged(createIndex(0, 0), createIndex(modpacks.size(), 0)); + emit dataChanged(createIndex(0, 0), createIndex(1, 0)); } void FtbListModel::logoFailed(QString logo) @@ -178,10 +174,7 @@ void FtbListModel::requestLogo(QString file) auto fullPath = entry->getFullPath(); QObject::connect(job, &NetJob::finished, this, [this, file, fullPath]{ - QPixmap pixmap; - pixmap.load(fullPath); - pixmap = pixmap.scaled(QSize(42, 42)); - emit logoLoaded(file, pixmap); + emit logoLoaded(file, QIcon(fullPath)); }); QObject::connect(job, &NetJob::failed, this, [this, file]{ |