feat(ui): merge duplicate packages across providers
When the same package name comes from several providers (pacman, flatpak, plugins), collapse the rows into one: the Fournisseur column lists every provider offering it and installed/updateAvailable are combined, while the first provider stays the routing default. Applies to search and to the aggregated installed/updates lists. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
4 files changed
+154
-2
No files matched your search
+19
-2
@@ -40,6 +40,8 @@ void SearchWorker::run() {
|
||||
results.push_back(pkg);
|
||||
}
|
||||
}
|
||||
// One row per package name, whatever the number of providers offering it.
|
||||
mergeProviderDuplicates(results);
|
||||
emit finished(results);
|
||||
}
|
||||
|
||||
@@ -63,6 +65,8 @@ void ListWorker::run() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// One row per package name, whatever the number of providers offering it.
|
||||
mergeProviderDuplicates(results);
|
||||
emit finished(results);
|
||||
}
|
||||
|
||||
@@ -128,6 +132,19 @@ static QString providerLabel(const PluginManager* pm, const std::string& id) {
|
||||
return QString::fromStdString(id);
|
||||
}
|
||||
|
||||
// Comma-separated display names of every provider offering a package (used by
|
||||
// the Fournisseur column and the details badge).
|
||||
static QString providersLabel(const PluginManager* pm, const PackageInfo& pkg) {
|
||||
QStringList names;
|
||||
for (const auto& id : pkg.providers) {
|
||||
names << providerLabel(pm, id);
|
||||
}
|
||||
if (names.isEmpty() && !pkg.provider.empty()) {
|
||||
names << providerLabel(pm, pkg.provider);
|
||||
}
|
||||
return names.join(", ");
|
||||
}
|
||||
|
||||
// MainWindow implementation
|
||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
|
||||
// Workers emit std::vector<PackageInfo> from another thread (QThread::run);
|
||||
@@ -1335,7 +1352,7 @@ void MainWindow::populatePackageTable(const std::vector<PackageInfo>& results) {
|
||||
pkg.repository.empty() ? "—" : QString::fromStdString(pkg.repository)));
|
||||
|
||||
QTableWidgetItem* providerItem = new QTableWidgetItem(
|
||||
providerLabel(m_pluginManager, pkg.provider));
|
||||
providersLabel(m_pluginManager, pkg));
|
||||
providerItem->setForeground(QColor("#98a0b3"));
|
||||
providerItem->setIcon(loadIcon("package"));
|
||||
m_packageTable->setItem(i, 3, providerItem);
|
||||
@@ -1429,7 +1446,7 @@ void MainWindow::updatePackageInfo(const PackageInfo& pkg) {
|
||||
? "Taille : —"
|
||||
: QString("Taille : %1").arg(QString::fromStdString(pkg.size)));
|
||||
m_packageProvider->setText(
|
||||
QString("Fournisseur : %1").arg(providerLabel(m_pluginManager, pkg.provider)));
|
||||
QString("Fournisseur : %1").arg(providersLabel(m_pluginManager, pkg)));
|
||||
m_packageUpdateBadge->setVisible(pkg.updateAvailable);
|
||||
|
||||
m_packageDescription->setText(QString::fromStdString(pkg.description));
|
||||
|
||||
Reference in new issue
Block a user