Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/sortedsystemtraymodel.h
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 Konrad Materka <materka@gmail.com> * | ||||
3 | * * | ||||
4 | * This program is free software; you can redistribute it and/or modify * | ||||
5 | * it under the terms of the GNU General Public License as published by * | ||||
6 | * the Free Software Foundation; either version 2 of the License, or * | ||||
7 | * (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This program is distributed in the hope that it will be useful, * | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
12 | * GNU General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU General Public License * | ||||
15 | * along with this program; if not, write to the * | ||||
16 | * Free Software Foundation, Inc., * | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||||
18 | ***************************************************************************/ | ||||
19 | | ||||
20 | #ifndef SORTEDSYSTEMTRAYMODEL_H | ||||
21 | #define SORTEDSYSTEMTRAYMODEL_H | ||||
22 | | ||||
23 | #include <QSortFilterProxyModel> | ||||
24 | | ||||
25 | class SortedSystemTrayModel : public QSortFilterProxyModel { | ||||
26 | Q_OBJECT | ||||
27 | public: | ||||
28 | enum class SortingType { | ||||
29 | ConfigurationPage, | ||||
30 | SystemTray | ||||
31 | }; | ||||
32 | | ||||
33 | explicit SortedSystemTrayModel(SortingType sorting, QObject *parent = nullptr); | ||||
34 | | ||||
35 | protected: | ||||
36 | virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override; | ||||
37 | | ||||
38 | private: | ||||
39 | bool lessThanConfigurationPage(const QModelIndex &left, const QModelIndex &right) const; | ||||
40 | bool lessThanByCategories(const QModelIndex &left, const QModelIndex &right) const; | ||||
41 | | ||||
42 | int compareDisplayAlphabetically(const QModelIndex &left, const QModelIndex &right) const; | ||||
43 | int compareCategoriesAlphabetically(const QModelIndex &left, const QModelIndex &right) const; | ||||
44 | int compareCategoriesOrderly(const QModelIndex &left, const QModelIndex &right) const; | ||||
45 | | ||||
46 | SortingType m_sorting; | ||||
47 | }; | ||||
48 | | ||||
49 | #endif // SORTEDSYSTEMTRAYMODEL_H |