This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
forked from manjaro/manjaro-settings-manager
/
KernelModel.h
87 lines (73 loc) · 2.49 KB
/
KernelModel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* This file is part of Namib Settings Manager.
*
* Ramon Buldó <ramon@namib.org>
*
* Namib Settings Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Namib Settings Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Namib Settings Manager. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KERNELMODEL_H
#define KERNELMODEL_H
#include "Kernel.h"
#include <QtCore/QAbstractListModel>
#include <QtCore/QObject>
#include <QtCore/QSortFilterProxyModel>
class KernelModel : public QAbstractListModel
{
Q_OBJECT
public:
enum KernelRoles
{
PackageRole = Qt::UserRole + 1,
VersionRole,
MajorVersionRole,
MinorVersionRole,
AvailableModulesRole,
InstalledModulesRole, /* Installed modules or will be installed if kernel is not installed */
IsAvailableRole,
IsInstalledRole,
IsLtsRole,
IsRecommendedRole,
IsRunningRole,
IsUnsupportedRole,
IsRcRole,
IsRealtimeRole
};
KernelModel( QObject* parent = 0 );
void update();
void add( const Kernel& kernel );
int rowCount( const QModelIndex& parent = QModelIndex() ) const;
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
bool remove( int position, int rows, const QModelIndex& parent );
Kernel latestInstalledKernel();
QList<Kernel> newerKernels( const Kernel& auxKernel );
QList<Kernel> unsupportedKernels() const;
protected:
QHash<int, QByteArray> roleNames() const;
private:
QList<Kernel> m_kernels;
QHash<QString, QString> getInstalledPackages() const;
QHash<QString, QString> getAvailablePackages() const;
Kernel getRunningKernel() const;
QStringList getLtsKernels() const;
QStringList getRecommendedKernels() const;
};
class KernelSortFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
KernelSortFilterProxyModel( QObject* parent = 0 );
protected:
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
};
#endif // KERNELMODEL_H