src/platform/qt/LibraryModel.h (view raw)
1/* Copyright (c) 2013-2016 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef QGBA_LIBRARY_MODEL
7#define QGBA_LIBRARY_MODEL
8
9#include <QAbstractItemModel>
10
11extern "C" {
12#include "core/library.h"
13}
14
15struct VDir;
16
17namespace QGBA {
18
19class LibraryModel : public QAbstractItemModel {
20Q_OBJECT
21
22public:
23 LibraryModel(QObject* parent = nullptr);
24 virtual ~LibraryModel();
25
26 void loadDirectory(VDir* dir);
27
28 const mLibraryEntry* entryAt(int row) const;
29
30 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
31 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
32
33 virtual QModelIndex index(int row, int column, const QModelIndex& parent) const override;
34 virtual QModelIndex parent(const QModelIndex& index) const override;
35
36 virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override;
37 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
38
39private:
40 mLibrary m_library;
41
42};
43
44}
45
46#endif