Removed extra code
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
f738d7566e
commit
248920a221
@ -95,7 +95,6 @@ struct IndexedPack {
|
||||
|
||||
bool versionsLoaded = false;
|
||||
QVector<IndexedVersion> versions;
|
||||
QVariant loadedFileId; // to check for already downloaded mods
|
||||
|
||||
// Don't load by default, since some modplatform don't have that info
|
||||
bool extraDataLoaded = true;
|
||||
@ -111,8 +110,6 @@ struct IndexedPack {
|
||||
}
|
||||
[[nodiscard]] bool isAnyVersionSelected() const
|
||||
{
|
||||
if (loadedFileId.isValid())
|
||||
return true;
|
||||
if (!versionsLoaded)
|
||||
return false;
|
||||
|
||||
|
@ -161,8 +161,8 @@ void ResourceDownloadDialog::addResource(ModPlatform::IndexedPack& pack, ModPlat
|
||||
|
||||
void ResourceDownloadDialog::removeResource(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& ver)
|
||||
{
|
||||
dynamic_cast<ResourcePage*>(m_container->getPage(Modrinth::id()))->removeResourceFromPage(pack.name);
|
||||
dynamic_cast<ResourcePage*>(m_container->getPage(Flame::id()))->removeResourceFromPage(pack.name);
|
||||
for (auto page : m_container->getPages())
|
||||
static_cast<ResourcePage*>(page)->removeResourceFromPage(pack.name);
|
||||
|
||||
// Deselect the new version too, since all versions of that pack got removed.
|
||||
ver.is_currently_selected = false;
|
||||
|
@ -13,16 +13,7 @@
|
||||
|
||||
namespace ResourceDownload {
|
||||
|
||||
ModModel::ModModel(BaseInstance const& base_inst, ResourceAPI* api) : ResourceModel(api), m_base_instance(base_inst)
|
||||
{
|
||||
auto folder = static_cast<MinecraftInstance const&>(m_base_instance).loaderModList();
|
||||
for (auto mod : folder->allMods()) {
|
||||
auto meta = mod->metadata();
|
||||
ModPlatform::IndexedPack pack{ meta->project_id, meta->provider, meta->name, meta->slug };
|
||||
pack.loadedFileId = meta->file_id;
|
||||
addPack(pack);
|
||||
}
|
||||
}
|
||||
ModModel::ModModel(BaseInstance const& base_inst, ResourceAPI* api) : ResourceModel(api), m_base_instance(base_inst) {}
|
||||
|
||||
/******** Make data requests ********/
|
||||
|
||||
|
@ -148,8 +148,8 @@ void ModPage::updateVersionList()
|
||||
void ModPage::addResourceToDialog(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& version)
|
||||
{
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
m_model->addPack(pack);
|
||||
m_parent_dialog->addResource(pack, version, is_indexed);
|
||||
m_model->addPack(pack);
|
||||
}
|
||||
|
||||
} // namespace ResourceDownload
|
||||
|
@ -343,7 +343,6 @@ void ResourceModel::searchRequestSucceeded(QJsonDocument& doc)
|
||||
sel != m_selected.end()) {
|
||||
pack.versionsLoaded = sel->versionsLoaded;
|
||||
pack.versions = sel->versions;
|
||||
pack.loadedFileId = sel->loadedFileId;
|
||||
}
|
||||
newList.append(pack);
|
||||
} catch (const JSONValidationError& e) {
|
||||
@ -408,12 +407,6 @@ void ResourceModel::versionRequestSucceeded(QJsonDocument& doc, ModPlatform::Ind
|
||||
try {
|
||||
auto arr = doc.isObject() ? Json::ensureArray(doc.object(), "data") : doc.array();
|
||||
loadIndexedPackVersions(current_pack, arr);
|
||||
if (current_pack.loadedFileId.isValid())
|
||||
if (auto ver =
|
||||
std::find_if(current_pack.versions.begin(), current_pack.versions.end(),
|
||||
[¤t_pack](const ModPlatform::IndexedVersion& v) { return v.fileId == current_pack.loadedFileId; });
|
||||
ver != current_pack.versions.end())
|
||||
ver->is_currently_selected = true;
|
||||
} catch (const JSONValidationError& e) {
|
||||
qDebug() << doc;
|
||||
qWarning() << "Error while reading " << debugName() << " resource version: " << e.cause();
|
||||
@ -463,41 +456,19 @@ void ResourceModel::removePack(QString& rem)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
||||
m_selected.removeIf(pred);
|
||||
#else
|
||||
{ // well partial implementation of remove_if in case the QT Version is not high enough
|
||||
const auto cbegin = m_selected.cbegin();
|
||||
const auto cend = m_selected.cend();
|
||||
const auto t_it = std::find_if(cbegin, cend, pred);
|
||||
auto result = std::distance(cbegin, t_it);
|
||||
if (result != m_selected.size()) {
|
||||
// now detach:
|
||||
const auto e = m_selected.end();
|
||||
|
||||
auto it = std::next(m_selected.begin(), result);
|
||||
auto dest = it;
|
||||
|
||||
// Loop Invariants:
|
||||
// - it != e
|
||||
// - [next(it), e[ still to be checked
|
||||
// - [c.begin(), dest[ are result
|
||||
while (++it != e) {
|
||||
if (!pred(*it)) {
|
||||
*dest = std::move(*it);
|
||||
++dest;
|
||||
}
|
||||
}
|
||||
|
||||
result = std::distance(dest, e);
|
||||
m_selected.erase(dest, e);
|
||||
}
|
||||
{
|
||||
for (auto it = m_selected.begin(); it != m_selected.end();)
|
||||
if (pred(*it))
|
||||
it = m_selected.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
#endif
|
||||
// m_selected.removeAt(qsizetype i)
|
||||
auto pack = std::find_if(m_packs.begin(), m_packs.end(), [&rem](const ModPlatform::IndexedPack& i) { return rem == i.name; });
|
||||
if (pack == m_packs.end()) { // ignore it if is not in the current search
|
||||
return;
|
||||
}
|
||||
if (!pack->versionsLoaded) {
|
||||
pack->loadedFileId = {};
|
||||
return;
|
||||
}
|
||||
for (auto& ver : pack->versions)
|
||||
|
@ -308,8 +308,8 @@ void ResourcePage::onVersionSelectionChanged(QString data)
|
||||
|
||||
void ResourcePage::addResourceToDialog(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& version)
|
||||
{
|
||||
m_model->addPack(pack);
|
||||
m_parent_dialog->addResource(pack, version);
|
||||
m_model->addPack(pack);
|
||||
}
|
||||
|
||||
void ResourcePage::removeResourceFromDialog(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& version)
|
||||
|
@ -47,8 +47,8 @@ void ShaderPackResourcePage::addResourceToDialog(ModPlatform::IndexedPack& pack,
|
||||
{
|
||||
if (version.loaders.contains(QStringLiteral("canvas")))
|
||||
version.custom_target_folder = QStringLiteral("resourcepacks");
|
||||
m_model->addPack(pack);
|
||||
m_parent_dialog->addResource(pack, version);
|
||||
m_model->addPack(pack);
|
||||
}
|
||||
|
||||
} // namespace ResourceDownload
|
||||
|
@ -135,6 +135,11 @@ BasePage* PageContainer::getPage(QString pageId)
|
||||
return m_model->findPageEntryById(pageId);
|
||||
}
|
||||
|
||||
const QList<BasePage*> PageContainer::getPages() const
|
||||
{
|
||||
return m_model->pages();
|
||||
}
|
||||
|
||||
void PageContainer::refreshContainer()
|
||||
{
|
||||
m_proxyModel->invalidate();
|
||||
|
@ -80,6 +80,7 @@ public:
|
||||
|
||||
virtual bool selectPage(QString pageId) override;
|
||||
BasePage* getPage(QString pageId) override;
|
||||
const QList<BasePage*> getPages() const;
|
||||
|
||||
void refreshContainer() override;
|
||||
virtual void setParentContainer(BasePageContainer * container)
|
||||
|
Loading…
Reference in New Issue
Block a user