From 2d9944bd0b5cd1dd202d9dc6318d612e1aca4241 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 8 Jan 2018 19:34:26 +0100 Subject: Load extensions with a model --- framework/src/extensionmodel.h | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 framework/src/extensionmodel.h (limited to 'framework/src/extensionmodel.h') diff --git a/framework/src/extensionmodel.h b/framework/src/extensionmodel.h new file mode 100644 index 00000000..6e984005 --- /dev/null +++ b/framework/src/extensionmodel.h @@ -0,0 +1,52 @@ +/* + Copyright (c) 2018 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#pragma once + +#include +#include + +namespace Kube { + +class ExtensionModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + + ExtensionModel(QObject *parent = Q_NULLPTR); + ~ExtensionModel() = default; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + + bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; + + enum Roles { + Name = Qt::UserRole + 1, + Tooltip, + Icon, + Source + }; + + QHash roleNames() const Q_DECL_OVERRIDE; + +private slots: + void load(); +}; + +} -- cgit v1.2.3