Change action order in context menu
This commit is contained in:
		
							parent
							
								
									eff7552d07
								
							
						
					
					
						commit
						5be05c46d8
					
				@ -339,9 +339,10 @@ void Model::initView(QTreeView *view)
 | 
				
			|||||||
  connect(view, &QAbstractItemView::customContextMenuRequested,  //
 | 
					  connect(view, &QAbstractItemView::customContextMenuRequested,  //
 | 
				
			||||||
          this, [this, view, proxy] {
 | 
					          this, [this, view, proxy] {
 | 
				
			||||||
            QMenu menu;
 | 
					            QMenu menu;
 | 
				
			||||||
            menu.addAction(toString(Action::NoAction));
 | 
					            using A = Action;
 | 
				
			||||||
            menu.addAction(toString(Action::Remove));
 | 
					            QMap<QAction *, Action> actions;
 | 
				
			||||||
            menu.addAction(toString(Action::Install));
 | 
					            for (auto i : QVector<A>{A::Install, A::Remove, A::NoAction})
 | 
				
			||||||
 | 
					              actions[menu.addAction(toString(i))] = i;
 | 
				
			||||||
            menu.addSeparator();
 | 
					            menu.addSeparator();
 | 
				
			||||||
            auto updateAll = menu.addAction(tr("Select all updates"));
 | 
					            auto updateAll = menu.addAction(tr("Select all updates"));
 | 
				
			||||||
            auto reset = menu.addAction(tr("Reset actions"));
 | 
					            auto reset = menu.addAction(tr("Reset actions"));
 | 
				
			||||||
@ -366,13 +367,13 @@ void Model::initView(QTreeView *view)
 | 
				
			|||||||
            if (indexes.isEmpty())
 | 
					            if (indexes.isEmpty())
 | 
				
			||||||
              return;
 | 
					              return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const auto action = menu.actions().indexOf(menuItem);
 | 
					            const auto action = actions[menuItem];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (const auto &proxyIndex : indexes) {
 | 
					            for (const auto &proxyIndex : indexes) {
 | 
				
			||||||
              auto modelIndex = proxy->mapToSource(proxyIndex);
 | 
					              auto modelIndex = proxy->mapToSource(proxyIndex);
 | 
				
			||||||
              if (!modelIndex.isValid() || rowCount(modelIndex) > 0)
 | 
					              if (!modelIndex.isValid() || rowCount(modelIndex) > 0)
 | 
				
			||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
              setData(modelIndex, action, Qt::EditRole);
 | 
					              setData(modelIndex, int(action), Qt::EditRole);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user