Lomiri
Loading...
Searching...
No Matches
SessionsModel.h
1/*
2 * Copyright (C) 2015-2016 Canonical Ltd.
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; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#pragma once
19
20#include <lomirisortfilterproxymodelqml.h>
21#include <QLightDM/SessionsModel>
22#include <QtCore/QHash>
23#include <QtCore/QLoggingCategory>
24#include <QtCore/QObject>
25#include <QtCore/QUrl>
26
27Q_DECLARE_LOGGING_CATEGORY(SessionsModelLogger)
28
29class SessionsModel : public LomiriSortFilterProxyModelQML
30{
31 Q_OBJECT
32
33 Q_PROPERTY(QList<QUrl> iconSearchDirectories READ iconSearchDirectories
34 WRITE setIconSearchDirectories NOTIFY iconSearchDirectoriesChanged)
35
36Q_SIGNALS:
37 void iconSearchDirectoriesChanged();
38
39public:
40 enum SessionModelRoles {
41 /* This is tricky / ugly. Since we are ultimately chaining 3 enums together,
42 * the _first_ value of this enum MUST be the _last_ value of
43 * QLightDM::SessionsModel::SessionModelRoles and consquently, this must
44 * also match the last value in the corresponding enum of the integrated lib
45 */
46 TypeRole = QLightDM::SessionsModel::SessionModelRoles::TypeRole,
47 IconRole
48 };
49 Q_ENUM(SessionModelRoles)
50
51 explicit SessionsModel(QObject* parent=nullptr);
52
53 QHash<int, QByteArray> roleNames() const override;
54 int rowCount(const QModelIndex& parent) const override;
55 QVariant data(const QModelIndex& index, int role) const override;
56 QList<QUrl> iconSearchDirectories() const;
57 Q_INVOKABLE QUrl iconUrl(const QString sessionName) const;
58
59 void setIconSearchDirectories(const QList<QUrl> searchDirectories);
60
61private:
62 QLightDM::SessionsModel* m_model;
63 QHash<int, QByteArray> m_roleNames;
64 QList<QUrl> m_iconSearchDirectories{
65 QUrl("/usr/local/share/lomiri-greeter"),
66 QUrl("/usr/share/lomiri-greeter"),
67 QUrl("/usr/share/ayatana-greeter/badges"),
68 QUrl(SHELL_APP_FULL_DIR "/Greeter/graphics/session_icons"),
69 };
70
71};