Repository navigation
Expand file tree
/
Copy pathccditemmodel.h
More file actions
177 lines (156 loc) · 7.18 KB
/
Copy pathccditemmodel.h
File metadata and controls
177 lines (156 loc) · 7.18 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
/**
* Copyright (C) 2021 Jo2003 (olenka.joerg@gmail.com)
* This file is part of cd2netmd_gui
*
* cd2netmd 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.
*
* cd2netmd 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
*/
#pragma once
#include <QAbstractTableModel>
#include <QObject>
#include <QStringList>
#include <QVector>
#include <QVariant>
#include "defines.h"
//------------------------------------------------------------------------------
//! @brief This class describes a cd item model.
//------------------------------------------------------------------------------
class CCDItemModel : public QAbstractTableModel
{
Q_OBJECT
public:
/// so called typedefs
using CDTitles = QStringList;
using TrackTimes = QVector<time_t>;
static constexpr int TSTAMP_ROLE = Qt::UserRole + 1;
//--------------------------------------------------------------------------
//! @brief delete default constructor
//--------------------------------------------------------------------------
CCDItemModel() = delete;
//--------------------------------------------------------------------------
//! @brief Constructs a new instance.
//!
//! @param[in] tracks The audio tracks vector
//! @param parent The parent
//--------------------------------------------------------------------------
explicit CCDItemModel(const c2n::AudioTracks& tracks, QObject *parent = nullptr);
//--------------------------------------------------------------------------
//! @brief Destroys the object.
//--------------------------------------------------------------------------
virtual ~CCDItemModel();
//--------------------------------------------------------------------------
//! @brief get the row count
//!
//! @param[in] parent The parent
//!
//! @return row count
//--------------------------------------------------------------------------
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
//--------------------------------------------------------------------------
//! @brief get the column count
//!
//! @param[in] parent The parent
//!
//! @return column count
//--------------------------------------------------------------------------
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
//--------------------------------------------------------------------------
//! @brief get item data
//!
//! @param[in] index The index
//! @param[in] role The role
//!
//! @return item data
//--------------------------------------------------------------------------
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
//--------------------------------------------------------------------------
//! @brief Sets the data.
//!
//! @param[in] index The index
//! @param[in] value The value
//! @param[in] role The role
//!
//! @return true if OK, else error
//--------------------------------------------------------------------------
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override;
//--------------------------------------------------------------------------
//! @brief get item flags
//!
//! @param[in] index The index
//!
//! @return item flags
//--------------------------------------------------------------------------
Qt::ItemFlags flags(const QModelIndex & index) const override;
//--------------------------------------------------------------------------
//! @brief get header data
//!
//! @param[in] section The section
//! @param[in] orientation The orientation
//! @param[in] role The role
//!
//! @return header data
//--------------------------------------------------------------------------
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
//--------------------------------------------------------------------------
//! @brief tells what dropactions are supported
//!
//! @return supported drop actions
//--------------------------------------------------------------------------
Qt::DropActions supportedDropActions() const override;
//--------------------------------------------------------------------------
//! @brief Information carried when dragging
//!
//! @return pointer to mime data
//--------------------------------------------------------------------------
QMimeData *mimeData(const QModelIndexList &indexes) const override;
//--------------------------------------------------------------------------
//! @brief Process the drop according to the information carried by drag
//!
//! @param[in] data mime date needed for drop
//! @param[in] action what needs to be done
//! @param[in] row target row
//! @param[in] column target column
//! @param[in] parent parent modell index
//!
//! @return true if handled
//--------------------------------------------------------------------------
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
//--------------------------------------------------------------------------
//! @brief export mime types
//--------------------------------------------------------------------------
QStringList mimeTypes() const override;
//--------------------------------------------------------------------------
//! @brief remove [count] rows starting from [row]
//!
//! @param[in] row target row
//! @param[in] count row count
//! @param[in] parent parent modell index
//!
//! @return true if handled
//--------------------------------------------------------------------------
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
//--------------------------------------------------------------------------
//! @brief get length of audio in kist
//!
//! @return length in blocks
//--------------------------------------------------------------------------
long audioLength() const;
//--------------------------------------------------------------------------
//! @brief return current audio tracks
//!
//! @return audio tracks
//--------------------------------------------------------------------------
c2n::AudioTracks audioTracks() const;
protected:
/// backend data storage
c2n::AudioTracks mTracks;
};