File indexing completed on 2024-04-28 15:39:43
0001 /* SPDX-FileCopyrightText: 2014 Jesper K. Pedersen <blackie@kde.org> 0002 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "ThumbnailModel.h" 0007 #include "ImageStore.h" 0008 0009 namespace RemoteControl 0010 { 0011 0012 ThumbnailModel::ThumbnailModel(QObject *parent) 0013 : QAbstractListModel(parent) 0014 { 0015 } 0016 0017 int ThumbnailModel::rowCount(const QModelIndex &) const 0018 { 0019 return m_images.count(); 0020 } 0021 0022 QVariant ThumbnailModel::data(const QModelIndex &index, int role) const 0023 { 0024 if (role == ImageIdRole) 0025 return m_images[index.row()]; 0026 return {}; 0027 } 0028 0029 RoleMap ThumbnailModel::roleNames() const 0030 { 0031 return { { ImageIdRole, "imageId" } }; 0032 } 0033 0034 void ThumbnailModel::setImages(const QList<int> &images) 0035 { 0036 beginResetModel(); 0037 m_images = images; 0038 endResetModel(); 0039 } 0040 0041 int ThumbnailModel::indexOf(int imageId) 0042 { 0043 return m_images.indexOf(imageId); 0044 } 0045 0046 } // namespace RemoteControl 0047 0048 #include "moc_ThumbnailModel.cpp"