Atlas Game Manager
A game manager for f95 and dlsite written in c++
Loading...
Searching...
No Matches
RecordListModel.hpp
Go to the documentation of this file.
1//
2// Created by kj16609 on 3/15/23.
3//
4
5#pragma once
6#ifndef ATLAS_RECORDLISTMODEL_HPP
7#define ATLAS_RECORDLISTMODEL_HPP
8
9#include <QAbstractListModel>
10#include <QFutureWatcher>
11
12#include <iostream>
13
16
17class RecordListModel final : public QAbstractListModel
18{
19 Q_OBJECT
20 Q_DISABLE_COPY_MOVE( RecordListModel )
21
22 std::vector< atlas::records::Game > m_records {};
23
24 //Map of active loading images
25 QThread loading_thread {};
26 std::unordered_map< int, std::unique_ptr< atlas::images::ImageLoader > > loaders {};
27
28 public:
29
31 {
32 Raw = Qt::ItemDataRole::UserRole,
37 };
38
39 RecordListModel( QObject* parent = nullptr ) : QAbstractListModel( parent ) { loading_thread.start(); }
40
41 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
42 int rowCount( const QModelIndex& index = QModelIndex() ) const override;
43 QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
44
45 void refreshOnFuture( QPersistentModelIndex index, QFuture< QPixmap > );
46 void killLoaders();
47
48 public slots:
49 void setRecords( std::vector< atlas::records::Game > records );
50
55 void addRecord( atlas::records::Game record, const std::size_t place_at = 0 );
56
57 void removeRecord( QPersistentModelIndex index );
58
59 void reloadRecord( QPersistentModelIndex index );
60
61 signals:
62 void recordsChanged( std::vector< atlas::records::Game > records );
63 void emitReloadRecord( QPersistentModelIndex index );
64};
65
66#endif //ATLAS_RECORDLISTMODEL_HPP
void addRecord(atlas::records::Game record, const std::size_t place_at=0)
Definition RecordListModel.cpp:23
std::vector< atlas::records::Game > m_records
Definition RecordListModel.hpp:22
void reloadRecord(QPersistentModelIndex index)
Definition RecordListModel.cpp:72
void setRecords(std::vector< atlas::records::Game > records)
Definition RecordListModel.cpp:15
RecordListModel(QObject *parent=nullptr)
Definition RecordListModel.hpp:39
void refreshOnFuture(QPersistentModelIndex index, QFuture< QPixmap >)
Definition RecordListModel.cpp:81
void killLoaders()
Definition RecordListModel.cpp:118
RecordListModelRoles
Definition RecordListModel.hpp:31
@ NormalBanner
Definition RecordListModel.hpp:33
@ LogoBanner
Definition RecordListModel.hpp:35
@ WideBanner
Definition RecordListModel.hpp:34
@ Raw
Definition RecordListModel.hpp:32
@ CoverBanner
Definition RecordListModel.hpp:36
int rowCount(const QModelIndex &index=QModelIndex()) const override
Definition RecordListModel.cpp:44
void removeRecord(QPersistentModelIndex index)
Definition RecordListModel.cpp:33
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition RecordListModel.cpp:49
QThread loading_thread
Definition RecordListModel.hpp:25
void emitReloadRecord(QPersistentModelIndex index)
std::unordered_map< int, std::unique_ptr< atlas::images::ImageLoader > > loaders
Definition RecordListModel.hpp:26
void recordsChanged(std::vector< atlas::records::Game > records)
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition RecordListModel.cpp:123
Definition Game.hpp:34
Definition banners.cpp:15
Definition Column.hpp:15