Atlas Game Manager
A game manager for f95 and dlsite written in c++
Loading...
Searching...
No Matches
FilepathModel.hpp
Go to the documentation of this file.
1//
2// Created by kj16609 on 4/17/23.
3//
4
5#pragma once
6#ifndef ATLASGAMEMANAGER_FILEPATHMODEL_HPP
7#define ATLASGAMEMANAGER_FILEPATHMODEL_HPP
8
9#include <QAbstractItemModel>
10#include <QFuture>
11
12#include <deque>
13#include <filesystem>
14
16
17class FilepathModel final : public QAbstractListModel
18{
19 Q_OBJECT
20
21 std::vector< std::filesystem::path > m_paths {};
22 std::unordered_map< int, std::unique_ptr< atlas::images::ImageLoader > > loaders {};
23 QThread loading_thread {};
24
25 public:
26
33
34 FilepathModel( QObject* parent = nullptr );
35
36 QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override;
37 QModelIndex parent( const QModelIndex& child ) const override;
38 int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
39 QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
40
41 Qt::DropActions supportedDropActions() const override;
42
43 bool insertRows( int row, int col, const QModelIndex& parent = QModelIndex() ) override;
44 bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() ) override;
45 bool moveRows(
46 const QModelIndex& sourceParent,
47 int sourceRow,
48 int count,
49 const QModelIndex& destinationParent,
50 int destinationChild ) override;
51
52 bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override;
53
54 Qt::ItemFlags flags( const QModelIndex& index ) const override;
55
56 std::vector< std::filesystem::path > getFilepaths() const;
57 void refreshOnFuture( QPersistentModelIndex index, QFuture< QPixmap > future );
58 void killLoaders();
59
60 public slots:
61 void setFilepaths( const std::vector< std::filesystem::path >& filepaths );
62 void reloadRecord( QPersistentModelIndex index );
63
64 signals:
65 void reordered();
66};
67
68#endif //ATLASGAMEMANAGER_FILEPATHMODEL_HPP
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition FilepathModel.cpp:29
bool insertRows(int row, int col, const QModelIndex &parent=QModelIndex()) override
Definition FilepathModel.cpp:98
std::vector< std::filesystem::path > m_paths
Definition FilepathModel.hpp:21
std::unordered_map< int, std::unique_ptr< atlas::images::ImageLoader > > loaders
Definition FilepathModel.hpp:22
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition FilepathModel.cpp:47
QThread loading_thread
Definition FilepathModel.hpp:23
FilepathModel(QObject *parent=nullptr)
Definition FilepathModel.cpp:24
void killLoaders()
Definition FilepathModel.cpp:227
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
Definition FilepathModel.cpp:76
void reloadRecord(QPersistentModelIndex index)
Definition FilepathModel.cpp:218
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition FilepathModel.cpp:89
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition FilepathModel.cpp:134
Qt::DropActions supportedDropActions() const override
Definition FilepathModel.cpp:71
std::vector< std::filesystem::path > getFilepaths() const
Definition FilepathModel.cpp:176
void refreshOnFuture(QPersistentModelIndex index, QFuture< QPixmap > future)
Definition FilepathModel.cpp:181
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override
Definition FilepathModel.cpp:145
void setFilepaths(const std::vector< std::filesystem::path > &filepaths)
Definition FilepathModel.cpp:16
QModelIndex parent(const QModelIndex &child) const override
Definition FilepathModel.cpp:37
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition FilepathModel.cpp:42
void reordered()
CustomRoles
Definition FilepathModel.hpp:28
@ StartUserRole
Definition FilepathModel.hpp:29
@ FilepathRole
Definition FilepathModel.hpp:31
@ PixmapRole
Definition FilepathModel.hpp:30