diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-31 22:18:11 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:38:18 +0100 |
| commit | bd34b532230d92bd6232ceb1ab2b0092cac79d22 (patch) | |
| tree | 27187c95e57702d66f6df2c61db45c03cb6c762b /src/pluginlist.cpp | |
| parent | 25a2123e5ffe66715d0a1ec09297ee91a9fcbe1c (diff) | |
Move plugin list context menu to its own class and to PluginListView.
Diffstat (limited to 'src/pluginlist.cpp')
| -rw-r--r-- | src/pluginlist.cpp | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 053f91b3..f6a52a80 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -338,43 +338,21 @@ int PluginList::findPluginByPriority(int priority) return -1;
}
-void PluginList::enableSelected(const QItemSelectionModel *selectionModel)
+void PluginList::setEnabled(const QModelIndexList& indices, bool enabled)
{
- if (selectionModel->hasSelection()) {
- QStringList dirty;
- for (auto row : selectionModel->selectedRows(COL_PRIORITY)) {
- int rowIndex = findPluginByPriority(row.data().toInt());
- if (!m_ESPs[rowIndex].enabled) {
- m_ESPs[rowIndex].enabled = true;
- dirty.append(m_ESPs[rowIndex].name);
- }
- }
- if (!dirty.isEmpty()) {
- emit writePluginsList();
- pluginStatesChanged(dirty, IPluginList::PluginState::STATE_ACTIVE);
+ QStringList dirty;
+ for (auto& idx : indices) {
+ if (m_ESPs[idx.row()].enabled != enabled) {
+ m_ESPs[idx.row()].enabled = enabled;
+ dirty.append(m_ESPs[idx.row()].name);
}
}
-}
-
-void PluginList::disableSelected(const QItemSelectionModel *selectionModel)
-{
- if (selectionModel->hasSelection()) {
- QStringList dirty;
- for (auto row : selectionModel->selectedRows(COL_PRIORITY)) {
- int rowIndex = findPluginByPriority(row.data().toInt());
- if (!m_ESPs[rowIndex].forceEnabled && m_ESPs[rowIndex].enabled) {
- m_ESPs[rowIndex].enabled = false;
- dirty.append(m_ESPs[rowIndex].name);
- }
- }
- if (!dirty.isEmpty()) {
- emit writePluginsList();
- pluginStatesChanged(dirty, IPluginList::PluginState::STATE_INACTIVE);
- }
+ if (!dirty.isEmpty()) {
+ emit writePluginsList();
+ pluginStatesChanged(dirty, IPluginList::PluginState::STATE_ACTIVE);
}
}
-
void PluginList::enableAll()
{
if (QMessageBox::question(nullptr, tr("Confirm"), tr("Really enable all plugins?"),
@@ -393,7 +371,6 @@ void PluginList::enableAll() }
}
-
void PluginList::disableAll()
{
if (QMessageBox::question(nullptr, tr("Confirm"), tr("Really disable all plugins?"),
@@ -416,9 +393,8 @@ void PluginList::sendToPriority(const QModelIndexList& indices, int newPriority) {
std::vector<int> pluginsToMove;
for (auto& idx : indices) {
- int rowIndex = findPluginByPriority(idx.row());
- if (!m_ESPs[rowIndex].forceEnabled) {
- pluginsToMove.push_back(rowIndex);
+ if (!m_ESPs[idx.row()].forceEnabled) {
+ pluginsToMove.push_back(idx.row());
}
}
if (pluginsToMove.size()) {
|
