NOISSUE Fixed code for PR
This commit is contained in:
parent
df6e66101c
commit
97b74ef56a
@ -64,14 +64,10 @@ FtbFilterModel::Sorting FtbFilterModel::getCurrentSorting()
|
|||||||
|
|
||||||
FtbListModel::FtbListModel(QObject *parent) : QAbstractListModel(parent)
|
FtbListModel::FtbListModel(QObject *parent) : QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
m_logoPool = new QThreadPool(this);
|
|
||||||
m_logoPool->setMaxThreadCount(4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FtbListModel::~FtbListModel()
|
FtbListModel::~FtbListModel()
|
||||||
{
|
{
|
||||||
m_logoPool->waitForDone(500);
|
|
||||||
m_logoPool->deleteLater();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FtbListModel::translatePackType(FtbPackType type) const
|
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
|
QVariant FtbListModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
int pos = index.row();
|
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);
|
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)) {
|
if(m_logoMap.contains(pack.logo)) {
|
||||||
return (m_logoMap.value(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);
|
((FtbListModel *)this)->requestLogo(pack.logo);
|
||||||
return pixmap;
|
return icon;
|
||||||
} else if(role == Qt::TextColorRole) {
|
} else if(role == Qt::TextColorRole) {
|
||||||
if(pack.broken) {
|
if(pack.broken) {
|
||||||
//FIXME: Hardcoded color
|
//FIXME: Hardcoded color
|
||||||
@ -153,11 +149,11 @@ FtbModpack FtbListModel::at(int row)
|
|||||||
return modpacks.at(row);
|
return modpacks.at(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FtbListModel::logoLoaded(QString logo, QPixmap out)
|
void FtbListModel::logoLoaded(QString logo, QIcon out)
|
||||||
{
|
{
|
||||||
m_loadingLogos.removeAll(logo);
|
m_loadingLogos.removeAll(logo);
|
||||||
m_logoMap.insert(logo, out);
|
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)
|
void FtbListModel::logoFailed(QString logo)
|
||||||
@ -178,10 +174,7 @@ void FtbListModel::requestLogo(QString file)
|
|||||||
|
|
||||||
auto fullPath = entry->getFullPath();
|
auto fullPath = entry->getFullPath();
|
||||||
QObject::connect(job, &NetJob::finished, this, [this, file, fullPath]{
|
QObject::connect(job, &NetJob::finished, this, [this, file, fullPath]{
|
||||||
QPixmap pixmap;
|
emit logoLoaded(file, QIcon(fullPath));
|
||||||
pixmap.load(fullPath);
|
|
||||||
pixmap = pixmap.scaled(QSize(42, 42));
|
|
||||||
emit logoLoaded(file, pixmap);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(job, &NetJob::failed, this, [this, file]{
|
QObject::connect(job, &NetJob::failed, this, [this, file]{
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
#include <RWStorage.h>
|
#include <RWStorage.h>
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QIcon>
|
||||||
|
|
||||||
typedef QMap<QString, QPixmap> FtbLogoMap;
|
typedef QMap<QString, QIcon> FtbLogoMap;
|
||||||
|
|
||||||
class FtbFilterModel : public QSortFilterProxyModel
|
class FtbFilterModel : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
@ -39,7 +39,6 @@ class FtbListModel : public QAbstractListModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
FtbModpackList modpacks;
|
FtbModpackList modpacks;
|
||||||
QThreadPool *m_logoPool;
|
|
||||||
QStringList m_failedLogos;
|
QStringList m_failedLogos;
|
||||||
QStringList m_loadingLogos;
|
QStringList m_loadingLogos;
|
||||||
FtbLogoMap m_logoMap;
|
FtbLogoMap m_logoMap;
|
||||||
@ -50,7 +49,7 @@ private:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void logoFailed(QString logo);
|
void logoFailed(QString logo);
|
||||||
void logoLoaded(QString logo, QPixmap out);
|
void logoLoaded(QString logo, QIcon out);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FtbListModel(QObject *parent);
|
FtbListModel(QObject *parent);
|
||||||
|
@ -26,6 +26,7 @@ FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent)
|
|||||||
ui->publicPackList->setSortingEnabled(true);
|
ui->publicPackList->setSortingEnabled(true);
|
||||||
ui->publicPackList->header()->hide();
|
ui->publicPackList->header()->hide();
|
||||||
ui->publicPackList->setIndentation(0);
|
ui->publicPackList->setIndentation(0);
|
||||||
|
ui->publicPackList->setIconSize(QSize(42, 42));
|
||||||
|
|
||||||
for(int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++)
|
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->setSortingEnabled(true);
|
||||||
ui->thirdPartyPackList->header()->hide();
|
ui->thirdPartyPackList->header()->hide();
|
||||||
ui->thirdPartyPackList->setIndentation(0);
|
ui->thirdPartyPackList->setIndentation(0);
|
||||||
|
ui->thirdPartyPackList->setIconSize(QSize(42, 42));
|
||||||
|
|
||||||
thirdPartyFilterModel->setSorting(publicFilterModel->getCurrentSorting());
|
thirdPartyFilterModel->setSorting(publicFilterModel->getCurrentSorting());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ private:
|
|||||||
FtbListModel *thirdPartyModel = nullptr;
|
FtbListModel *thirdPartyModel = nullptr;
|
||||||
FtbFilterModel *thirdPartyFilterModel = nullptr;
|
FtbFilterModel *thirdPartyFilterModel = nullptr;
|
||||||
|
|
||||||
FtbPackFetchTask *ftbFetchTask;
|
FtbPackFetchTask *ftbFetchTask = nullptr;
|
||||||
NewInstanceDialog* dialog = nullptr;
|
NewInstanceDialog* dialog = nullptr;
|
||||||
|
|
||||||
Ui::FTBPage *ui = nullptr;
|
Ui::FTBPage *ui = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user