CuteLogger
Fast and simple logging solution for Qt based applications
extensionmodel.h
1/*
2 * Copyright (c) 2025 Meltytech, LLC
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 3 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, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef EXTENSIONMODEL_H
19#define EXTENSIONMODEL_H
20
21#include "qmltypes/qmlextension.h"
22
23#include <QAbstractItemModel>
24
25class ExtensionModel : public QAbstractItemModel
26{
27 Q_OBJECT
28
29public:
30 enum Columns {
31 COLUMN_STATUS = 0,
32 COLUMN_NAME,
33 COLUMN_SIZE,
34 COLUMN_COUNT,
35 };
36 explicit ExtensionModel(QObject *parent = 0);
37 virtual ~ExtensionModel();
38 void load(const QString &id);
39 int count();
40 QString getName(int row) const;
41 QString getFormattedDataSize(int row) const;
42 QString localPath(int row) const;
43 QString url(int row) const;
44 bool downloaded(int row) const;
45 void deleteFile(int row);
46 int getStandardIndex() const;
47 QModelIndex getIndexForPath(QString path);
48
49protected:
50 // Implement QAbstractItemModel
51 int rowCount(const QModelIndex &parent) const;
52 int columnCount(const QModelIndex &parent) const;
53 QVariant data(const QModelIndex &index, int role) const;
54 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
55 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
56 QModelIndex parent(const QModelIndex &index) const;
57
58private:
59 QmlExtension *m_ext;
60};
61
62#endif // EXTENSIONMODEL_H