Changeset 7451517e in subsurface


Ignore:
Timestamp:
Dec 24, 2017, 8:24:11 AM (4 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
dbcf044
Parents:
668635e
git-author:
Berthold Stoeger <bstoeger@…> (12/23/17 06:49:21)
git-committer:
Dirk Hohndel <dirk@…> (12/24/17 08:24:11)
Message:

Add select-all, deselect-all and invert-selection options to filters

To every filter list add a menu button that allows selection of all,
selection of none or inversion of selection.

Implements #435.

Signed-off-by: Berthold Stoeger <bstoeger@…>

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • desktop-widgets/listfilter.ui

    re49d621 r7451517e  
    5252      </widget>
    5353     </item>
     54     <item>
     55      <widget class="QToolButton" name="selectionButton">
     56       <property name="text">
     57        <string>...</string>
     58       </property>
     59       <property name="popupMode">
     60        <enum>QToolButton::InstantPopup</enum>
     61       </property>
     62      </widget>
     63     </item>
    5464    </layout>
    5565   </item>
  • desktop-widgets/simplewidgets.cpp

    r1a4e7ad0 r7451517e  
    514514        connect(ui.filterInternalList, SIGNAL(textChanged(QString)), filter, SLOT(setFilterFixedString(QString)));
    515515        ui.filterList->setModel(filter);
     516
     517        QMenu *menu = new QMenu(this);
     518        menu->addAction(tr("Select All"), model, &FilterModelBase::selectAll);
     519        menu->addAction(tr("Unselect All"), model, &FilterModelBase::clearFilter);
     520        menu->addAction(tr("Invert Selection"), model, &FilterModelBase::invertSelection);
     521        ui.selectionButton->setMenu(menu);
    516522}
    517523
  • qt-models/filtermodels.cpp

    r668635e r7451517e  
    9898        std::fill(checkState.begin(), checkState.end(), false);
    9999        anyChecked = false;
     100        emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
     101}
     102
     103void FilterModelBase::selectAll()
     104{
     105        std::fill(checkState.begin(), checkState.end(), true);
     106        anyChecked = true;
     107        emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
     108}
     109
     110void FilterModelBase::invertSelection()
     111{
     112        for (char &b: checkState)
     113                b = !b;
     114        anyChecked = std::any_of(checkState.begin(), checkState.end(), [](char b){return !!b;});
    100115        emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
    101116}
  • qt-models/filtermodels.h

    r668635e r7451517e  
    1212        virtual bool doFilter(struct dive *d, QModelIndex &index0, QAbstractItemModel *sourceModel) const = 0;
    1313        void clearFilter();
     14        void selectAll();
     15        void invertSelection();
    1416        std::vector<char> checkState;
    1517        bool anyChecked;
Note: See TracChangeset for help on using the changeset viewer.