File indexing completed on 2024-04-28 05:31:42
0001 /* 0002 KSysGuard, the KDE System Guard 0003 0004 SPDX-FileCopyrightText: 1999, 2000 Chris Schlaeger <cs@kde.org> 0005 SPDX-FileCopyrightText: 2006 John Tapsell <john.tapsell@kdemail.net> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 0009 */ 0010 0011 #ifndef PROCESSFILTER_H_ 0012 #define PROCESSFILTER_H_ 0013 0014 #include <QObject> 0015 #include <QSortFilterProxyModel> 0016 0017 #include "processui_export.h" 0018 0019 class QModelIndex; 0020 0021 #ifdef Q_OS_WIN 0022 // this workaround is needed to make krunner link under msvc 0023 // please keep it this way even if you port this library to have a _export.h header file 0024 #define KSYSGUARD_EXPORT 0025 #else 0026 #define KSYSGUARD_EXPORT PROCESSUI_EXPORT 0027 #endif 0028 0029 class KSYSGUARD_EXPORT ProcessFilter : public QSortFilterProxyModel 0030 { 0031 Q_OBJECT 0032 Q_ENUMS(State) 0033 0034 public: 0035 enum State { AllProcesses = 0, AllProcessesInTreeForm, SystemProcesses, UserProcesses, OwnProcesses, ProgramsOnly }; 0036 explicit ProcessFilter(QObject *parent = nullptr) 0037 : QSortFilterProxyModel(parent) 0038 { 0039 mFilter = AllProcesses; 0040 } 0041 ~ProcessFilter() override 0042 { 0043 } 0044 bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; 0045 State filter() const 0046 { 0047 return mFilter; 0048 } 0049 0050 public Q_SLOTS: 0051 void setFilter(State index); 0052 0053 protected: 0054 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 0055 0056 State mFilter; 0057 }; 0058 0059 #endif