-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathslideshowlistmodel.h
More file actions
187 lines (159 loc) · 6.4 KB
/
Copy pathslideshowlistmodel.h
File metadata and controls
187 lines (159 loc) · 6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/****************************************************************************
**
** Copyright (C) 2011 Alexander Vos <alexander.vos@stud.fh-swf.de>,
** Till Althaus <till.althaus@stud.fh-swf.de>
**
** This file is part of Qt Slideshow Manager (QSM).
**
** QSM is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** QSM is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with QSM. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef SLIDESHOWLISTMODEL_H
#define SLIDESHOWLISTMODEL_H
#include <QAbstractListModel>
#include <QList>
#include "slideshow.h"
/*!
\brief The SlideshowListModel class provides a model of multiple slideshows
which can be presented to the user with the SlideshowListView class.
\sa SlideshowListView
*/
class SlideshowListModel : public QAbstractListModel
{
Q_OBJECT
public:
/*!
\brief Constructs a new SlideshowListModel with the given \a parent.
\param parent The parent widget.
*/
explicit SlideshowListModel(QObject *parent = 0);
/*!
\brief Returns the item flags for the given \a index.
\param index The QModelIndex of the item.
\return The item flags.
*/
Qt::ItemFlags flags(const QModelIndex &index) const;
/*!
\brief Returns the row count.
\return The row count.
*/
inline int rowCount(const QModelIndex & = QModelIndex()) const { return m_slideshowList.count(); }
/*!
\brief Returns the data stored under the given \a role for the item
referred to by the \a index.
\param index The QModelIndex of the item.
\param role The role of the item.
\return The stored data.
\sa setData()
*/
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
/*!
\brief Sets the \a role data for the item at \a index to \a value.
\param index The QModelIndex of the item.
\param value The data of the item.
\param role The role of the item.
\return \c True if successful; otherwise \c false.
\sa data(), slideshowRenamed()
*/
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
/*!
\brief Returns the slideshow referred to by the \a index or \c NULL if
the \a index is invalid or out of bounds.
\param index The QModelIndex of the slideshow item.
\return The slideshow or \c NULL.
\sa slideshowList(), currentSlideshow()
*/
Slideshow* slideshow(const QModelIndex &index) const;
/*!
\brief Returns the slideshow referred to by the \a name or \c NULL if
the there is no slideshow with that \a name.
\param name The name of the slideshow item.
\return The slideshow or \c NULL.
\sa slideshowList(), currentSlideshow()
*/
Slideshow* slideshow(const QString &name) const;
/*!
\brief Returns the internal list of all slideshows stored in this model.
\return The list of all slieshows.
\sa slideshow()
*/
inline QList<Slideshow>& slideshowList() { return m_slideshowList; }
/*!
\brief Returns the currently active slideshow in this model or \c NULL if
there is no active slideshow.
\return The current slieshow or \c NULL.
\sa currentSlideshowIndex(), slideshow(), slideshowList()
*/
inline Slideshow* currentSlideshow() const { return m_currentSlideshow; }
/*!
\brief Returns the currently active slideshow index in this model or
an invalid model index if there is no active slideshow.
\return The current slieshow or \c NULL.
\sa currentSlideshow(), slideshow(), slideshowList()
*/
inline const QModelIndex& currentSlideshowIndex() const { return m_currentSlideshowIndex; }
signals:
/*!
\brief This signal is emitted after a slideshow has been renamed.
\param oldName The name before the slideshow has been renamed.
\param newName The name after the slideshow has been renamed.
\sa setData()
*/
void slideshowRenamed(const QString &oldName, const QString &newName);
public slots:
/*!
\brief Adds a slideshow to this model.
\param slideshow The slideshow to add.
\return The model index of the inserted slideshow.
\sa removeSlideshow(), clear()
*/
QModelIndex addSlideshow(const Slideshow &slideshow);
/*!
\brief Removes a slideshow from this model.
\param index The model index of the slideshow to remove.
\return \c True if the slideshow was removed from this model;
otherwise \c false.
\sa addSlideshow(), clear()
*/
bool removeSlideshow(const QModelIndex &index);
/*!
\brief Removes all slideshows from this model.
\sa addSlideshow(), removeSlideshow()
*/
void clear();
/*!
\brief Convenience method to add an image to the active slideshow.
\param image The slideshow image to add.
\return The index of the inserted image or \c -1 if the image could not
be added (usually because there is no active slideshow).
\sa currentSlideshow(), Slideshow::addImage(), removeImage()
*/
int addImage(const SlideshowImage &image);
/*!
\brief Convenience method to remove an image from the active slideshow.
\param index The model index of the image to remove.
\sa currentSlideshow(), Slideshow::removeImage(), addImage()
*/
void removeImage(const QModelIndex &index);
/*!
\brief Sets a slideshow referred to by the \a index to the active one.
\param index The model index of the slideshow.
*/
bool setCurrentSlideshow(const QModelIndex &index);
private:
QList<Slideshow> m_slideshowList; //!< The list of all slideshows in this model.
Slideshow *m_currentSlideshow; //!< The active slieshow in this model.
QModelIndex m_currentSlideshowIndex; //!< The index of the active slideshow in this model.
};
#endif // SLIDESHOWLISTMODEL_H