Manage sets window: "Enable all/selected" button toggling never disabled (#3337)

## Related Ticket(s)
- Fixes #3314 

## Short roundup of the initial problem
When the view was sorted in the manage sets window, the "Enable/Disable All" buttons never toggled to "Enable/Disable selected" buttons, even when more sets were selected.

## What will change with this Pull Request?
- Selected sets can be enabled/disabled in sorted view as well
This commit is contained in:
David Szabo 2018-07-25 14:39:42 +02:00 committed by tooomm
parent 451e1874a7
commit 283ce23111
2 changed files with 14 additions and 14 deletions

View file

@ -21,6 +21,8 @@
WndSets::WndSets(QWidget *parent) : QMainWindow(parent)
{
setOrderIsSorted = false;
// left toolbar
setsEditToolBar = new QToolBar;
setsEditToolBar->setOrientation(Qt::Vertical);
@ -252,27 +254,24 @@ void WndSets::actDisableSortButtons(int index)
{
if (index != SORT_RESET) {
view->setDragEnabled(false);
actToggleButtons(QItemSelection(), QItemSelection());
disconnect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
this, SLOT(actToggleButtons(const QItemSelection &, const QItemSelection &)));
setOrderIsSorted = true;
} else {
actToggleButtons(view->selectionModel()->selection(), QItemSelection());
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this,
SLOT(actToggleButtons(const QItemSelection &, const QItemSelection &)));
if (!view->selectionModel()->selection().empty()) {
view->scrollTo(view->selectionModel()->selectedRows().first());
}
setOrderIsSorted = false;
view->setDragEnabled(true);
}
if (!view->selectionModel()->selection().empty()) {
view->scrollTo(view->selectionModel()->selectedRows().first());
}
actToggleButtons(view->selectionModel()->selection(), QItemSelection());
}
void WndSets::actToggleButtons(const QItemSelection &selected, const QItemSelection &)
{
bool disabled = selected.empty();
aTop->setDisabled(disabled);
aUp->setDisabled(disabled);
aDown->setDisabled(disabled);
aBottom->setDisabled(disabled);
bool emptySelection = selected.empty();
aTop->setDisabled(emptySelection || setOrderIsSorted);
aUp->setDisabled(emptySelection || setOrderIsSorted);
aDown->setDisabled(emptySelection || setOrderIsSorted);
aBottom->setDisabled(emptySelection || setOrderIsSorted);
int rows = view->selectionModel()->selectedRows().size();
rebuildMainLayout((rows > 1) ? SOME_SETS_SELECTED : NO_SETS_SELECTED);

View file

@ -36,6 +36,7 @@ private:
int sortIndex;
Qt::SortOrder sortOrder;
void rebuildMainLayout(int actionToTake);
bool setOrderIsSorted;
enum
{
NO_SETS_SELECTED,