Skip to content

Commit 83b615b

Browse files
samamoujcelerier
authored andcommitted
fix category filtering and uninstall ai-models
1 parent f087439 commit 83b615b

2 files changed

Lines changed: 40 additions & 7 deletions

File tree

src/plugins/score-plugin-packagemanager/PackageManager/View.cpp

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ PluginSettingsView::PluginSettingsView()
115115
auto categoryLabel = new QLabel("Select Kind:");
116116
vlay->addWidget(categoryLabel);
117117

118-
categoryComboBox = new QComboBox(m_widget);
119-
vlay->addWidget(categoryComboBox);
118+
m_categoryComboBox = new QComboBox(m_widget);
119+
vlay->addWidget(m_categoryComboBox);
120120
vlay->addSpacing(20);
121121

122122
m_link->setToolTip(tr("Open external package link in default browser."));
@@ -193,6 +193,10 @@ PluginSettingsView::PluginSettingsView()
193193

194194
connect(&mgr, &QNetworkAccessManager::finished, this, &PluginSettingsView::on_message);
195195

196+
connect(m_categoryComboBox, &QComboBox::currentIndexChanged, this, [this](int index) {
197+
onCategoryChanged(index);
198+
});
199+
196200
refresh();
197201
}
198202

@@ -418,7 +422,7 @@ void PluginSettingsView::uninstall()
418422

419423
const auto& library{score::AppContext().settings<Library::Settings::Model>()};
420424

421-
if(addon.kind == "addon" || addon.kind == "nodes" || addon.kind == "media")
425+
if(addon.kind == "addon" || addon.kind == "nodes" || addon.kind == "media" || addon.kind == "ai-model")
422426
{
423427
success = QDir{library.getPackagesPath() + '/' + addon.raw_name}.removeRecursively();
424428
}
@@ -711,8 +715,8 @@ void PluginSettingsView::progress_from_bytes(qint64 bytesReceived, qint64 bytesT
711715

712716
void PluginSettingsView::updateCategoryComboBox(int tabIndex)
713717
{
714-
categoryComboBox->clear();
715-
categoryComboBox->addItem("All");
718+
m_categoryComboBox->clear();
719+
m_categoryComboBox->addItem("All");
716720

717721
PackagesModel* model = nullptr;
718722
if(tabIndex == 0) // Local packages tab
@@ -739,8 +743,36 @@ void PluginSettingsView::updateCategoryComboBox(int tabIndex)
739743

740744
for(const QString& kind : uniqueKinds)
741745
{
742-
categoryComboBox->addItem(kind);
746+
m_categoryComboBox->addItem(kind);
747+
}
748+
}
749+
}
750+
751+
void PluginSettingsView::onCategoryChanged(int index)
752+
{
753+
// Filter table view to show only packages of the selected kind
754+
QString selectedKind = m_categoryComboBox->itemText(index);
755+
756+
QTableView* activeView = m_install->isVisible() ? m_remoteAddons : m_addonsOnSystem;
757+
PackagesModel* model = static_cast<PackagesModel*>(activeView->model());
758+
759+
if(!model)
760+
return;
761+
762+
if(selectedKind == "All")
763+
{
764+
for(int row = 0; row < model->addons().size(); ++row)
765+
{
766+
activeView->setRowHidden(row, false);
743767
}
768+
return;
769+
}
770+
771+
for(int row = 0; row < model->addons().size(); ++row)
772+
{
773+
QString rowKind = model->addons()[row].kind;
774+
activeView->setRowHidden(row, rowKind != selectedKind);
744775
}
745776
}
777+
746778
}

src/plugins/score-plugin-packagemanager/PackageManager/View.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class PluginSettingsView : public score::GlobalSettingsView
6767
void reset_progress();
6868
void progress_from_bytes(qint64 bytesReceived, qint64 bytesTotal);
6969
void updateCategoryComboBox(int tabIndex);
70+
void onCategoryChanged(int index);
7071

7172
QWidget* m_widget{new QWidget};
7273

@@ -85,7 +86,7 @@ class PluginSettingsView : public score::GlobalSettingsView
8586

8687
QStorageInfo storage;
8788
QLabel* m_storage{new QLabel};
88-
QComboBox* categoryComboBox = nullptr;
89+
QComboBox* m_categoryComboBox = nullptr;
8990

9091
bool m_firstTimeCheck{false};
9192
};

0 commit comments

Comments
 (0)