Skip to content

Commit

Permalink
selection: fix row selection when sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Feb 11, 2025
1 parent a365ffb commit f8d6551
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ PluginSettingsModel::PluginSettingsModel(
QSettings& set, const score::ApplicationContext& ctx)
: score::SettingsDelegateModel{}
, localPlugins{ctx}
, remoteSelection{&remotePlugins}
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once
#include <score/plugins/settingsdelegate/SettingsDelegateModel.hpp>

#include <QItemSelectionModel>

#include <PackageManager/PluginItemModel.hpp>

class QAbstractItemModel;
Expand All @@ -19,6 +17,5 @@ class PluginSettingsModel : public score::SettingsDelegateModel

LocalPackagesModel localPlugins;
RemotePackagesModel remotePlugins;
QItemSelectionModel remoteSelection;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <QApplication>
#include <QDebug>
#include <QHeaderView>
#include <QItemSelectionModel>
#include <QListView>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
Expand Down Expand Up @@ -65,14 +66,17 @@ PluginSettingsPresenter::PluginSettingsPresenter(
ps_view.remoteView()->setColumnWidth(4, 30);
ps_view.remoteView()->horizontalHeader()->setStretchLastSection(true);

// ps_view.remoteView()->setSelectionModel(&ps_model.remoteSelection);
auto selection = new QItemSelectionModel{remoteProxyModel, this};
ps_view.remoteView()->setSelectionModel(selection);
connect(
&ps_model.remoteSelection, &QItemSelectionModel::currentRowChanged, this,
[&](const QModelIndex& current, const QModelIndex& previous) {
Package& addon = ps_model.remotePlugins.addons().at(current.row());
selection, &QItemSelectionModel::currentRowChanged, this,
[remoteProxyModel, &ps_model,
&ps_view](const QModelIndex& current, const QModelIndex& previous) {
auto selected = remoteProxyModel->mapToSource(current);
Package& addon = ps_model.remotePlugins.addons().at(selected.row());

ps_view.installButton().setEnabled(!addon.files.empty() || addon.kind == "sdk");
});
});

ps_view.installButton().setEnabled(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ namespace PM

void PluginSettingsView::checkAll()
{

std::vector<Package*> to_update;
for(auto& addon : m_localModel->addons())
{
Expand Down

0 comments on commit f8d6551

Please sign in to comment.