2 * This file is part of CameraPlus.
4 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "fileinfomodel.h"
23 FileInfoModel::FileInfoModel(QObject *parent) :
24 QAbstractListModel(parent) {
28 FileInfoModel::~FileInfoModel() {
32 int FileInfoModel::rowCount(const QModelIndex& parent) const {
33 if (parent.isValid()) {
40 QVariant FileInfoModel::data(const QModelIndex& index, int role) const {
41 if (index.isValid() && index.row() < m_info.count() && role == Qt::DisplayRole) {
42 return m_info[index.row()];
48 void FileInfoModel::setFiles(const QStringList& files) {
54 void FileInfoModel::appendFile(const QString& file) {
55 appendFiles(QStringList() << file);
58 void FileInfoModel::appendFiles(const QStringList& files) {
59 if (files.isEmpty()) {
63 beginInsertRows(QModelIndex(), m_info.size(), files.size() - 1);
68 void FileInfoModel::removeFile(const QString& file) {
69 int index = m_info.indexOf(file);
75 beginRemoveRows(QModelIndex(), index, index);
76 m_info.removeAt(index);
80 void FileInfoModel::clear() {
81 if (m_info.isEmpty()) {
85 beginRemoveRows(QModelIndex(), 0, m_info.size());