mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-09-14 15:15:38 -04:00
62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
// SPDX-FileCopyrightText: 2023 flowln <flowlnlnln@gmail.com>
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "ResourcePackModel.h"
|
|
|
|
#include <QMessageBox>
|
|
#include <utility>
|
|
|
|
namespace ResourceDownload {
|
|
|
|
ResourcePackResourceModel::ResourcePackResourceModel(ResourceFolderModel* resourceList,
|
|
const ResourceAPI* api,
|
|
const QString& debugName,
|
|
QString metaEntryBase)
|
|
: ResourceModel(resourceList, api), m_debugName(debugName + " (Model)"), m_metaEntryBase(std::move(metaEntryBase))
|
|
{}
|
|
|
|
/******** Make data requests ********/
|
|
|
|
ResourceAPI::SearchArgs ResourcePackResourceModel::createSearchArguments()
|
|
{
|
|
auto sort = getCurrentSortingMethodByIndex();
|
|
return {
|
|
.type = ModPlatform::ResourceType::ResourcePack,
|
|
.offset = m_nextSearchOffset,
|
|
.search = m_searchTerm,
|
|
.sorting = sort,
|
|
.loaders = {},
|
|
.versions = {},
|
|
.side = {},
|
|
.categoryIds = {},
|
|
.openSource = {},
|
|
};
|
|
}
|
|
|
|
ResourceAPI::VersionSearchArgs ResourcePackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
|
{
|
|
auto pack = m_packs[entry.row()];
|
|
return { .pack = pack, .mcVersions = {}, .loaders = {}, .resourceType = ModPlatform::ResourceType::ResourcePack };
|
|
}
|
|
|
|
ResourceAPI::ProjectInfoArgs ResourcePackResourceModel::createInfoArguments(const QModelIndex& entry)
|
|
{
|
|
auto pack = m_packs[entry.row()];
|
|
return { .pack = pack };
|
|
}
|
|
|
|
void ResourcePackResourceModel::searchWithTerm(const QString& term, unsigned int sort)
|
|
{
|
|
if (m_searchTerm == term && m_searchTerm.isNull() == term.isNull() && m_currentSortIndex == sort) {
|
|
return;
|
|
}
|
|
|
|
setSearchTerm(term);
|
|
m_currentSortIndex = sort;
|
|
|
|
refresh();
|
|
}
|
|
|
|
} // namespace ResourceDownload
|