summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorJanrupf <werbung.janrupf@t-online.de>2018-04-06 15:08:59 +0200
committerJanrupf <werbung.janrupf@t-online.de>2018-04-06 19:39:12 +0200
commit97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25 (patch)
tree461a6963a8f822e700aae30549ccb02f5c6bb160 /application
parentdf6e66101c2ce5635f20df2f1d7954a681845ab1 (diff)
downloadMultiMC-97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25.tar
MultiMC-97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25.tar.gz
MultiMC-97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25.tar.lz
MultiMC-97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25.tar.xz
MultiMC-97b74ef56ae3f9ff3215477eb8b0cf0f2a19ef25.zip
NOISSUE Fixed code for PR
Diffstat (limited to 'application')
-rw-r--r--application/FtbListModel.cpp19
-rw-r--r--application/FtbListModel.h7
-rw-r--r--application/pages/modplatform/FTBPage.cpp3
-rw-r--r--application/pages/modplatform/FTBPage.h2
4 files changed, 13 insertions, 18 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]{
diff --git a/application/FtbListModel.h b/application/FtbListModel.h
index 747c65bd..12b26be1 100644
--- a/application/FtbListModel.h
+++ b/application/FtbListModel.h
@@ -7,9 +7,9 @@
#include <RWStorage.h>
-#include <QPixmap>
+#include <QIcon>
-typedef QMap<QString, QPixmap> FtbLogoMap;
+typedef QMap<QString, QIcon> FtbLogoMap;
class FtbFilterModel : public QSortFilterProxyModel
{
@@ -39,7 +39,6 @@ class FtbListModel : public QAbstractListModel
Q_OBJECT
private:
FtbModpackList modpacks;
- QThreadPool *m_logoPool;
QStringList m_failedLogos;
QStringList m_loadingLogos;
FtbLogoMap m_logoMap;
@@ -50,7 +49,7 @@ private:
private slots:
void logoFailed(QString logo);
- void logoLoaded(QString logo, QPixmap out);
+ void logoLoaded(QString logo, QIcon out);
public:
FtbListModel(QObject *parent);
diff --git a/application/pages/modplatform/FTBPage.cpp b/application/pages/modplatform/FTBPage.cpp
index 8c8d8a7d..2cc8c4fd 100644
--- a/application/pages/modplatform/FTBPage.cpp
+++ b/application/pages/modplatform/FTBPage.cpp
@@ -26,6 +26,7 @@ FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent)
ui->publicPackList->setSortingEnabled(true);
ui->publicPackList->header()->hide();
ui->publicPackList->setIndentation(0);
+ ui->publicPackList->setIconSize(QSize(42, 42));
for(int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++)
{
@@ -44,6 +45,8 @@ FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent)
ui->thirdPartyPackList->setSortingEnabled(true);
ui->thirdPartyPackList->header()->hide();
ui->thirdPartyPackList->setIndentation(0);
+ ui->thirdPartyPackList->setIconSize(QSize(42, 42));
+
thirdPartyFilterModel->setSorting(publicFilterModel->getCurrentSorting());
}
diff --git a/application/pages/modplatform/FTBPage.h b/application/pages/modplatform/FTBPage.h
index 413f5e28..a5327d31 100644
--- a/application/pages/modplatform/FTBPage.h
+++ b/application/pages/modplatform/FTBPage.h
@@ -89,7 +89,7 @@ private:
FtbListModel *thirdPartyModel = nullptr;
FtbFilterModel *thirdPartyFilterModel = nullptr;
- FtbPackFetchTask *ftbFetchTask;
+ FtbPackFetchTask *ftbFetchTask = nullptr;
NewInstanceDialog* dialog = nullptr;
Ui::FTBPage *ui = nullptr;