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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
#ifndef REPLAYGAINFILELIST_H
#define REPLAYGAINFILELIST_H
#include <tdelistview.h>
#include <tqdatetime.h>
class TagEngine;
class TagData;
class ReplayGain;
class Config;
class Logger;
class TQSimpleRichText;
class KProgress;
class TDEPopupMenu;
class TDEAction;
class TDEActionCollection;
class TDEProcess;
// FIXME differ diffrent sampling rates, too!
/**
* @short The items for the file list of the Replay Gain scanner
* @author Daniel Faust <hessijames@gmail.com>
* @version 0.3
*/
class ReplayGainFileListItem : public TDEListViewItem
{
public:
enum Type {
File,
Album
};
enum Mode {
remove = 0x0001,
force = 0x0002
};
/**
* Constructor
* @param parent The parent list view
*/
ReplayGainFileListItem( TQListView* parent );
/*
* Constructor
* @param parent The parent list view
* @param after The item, the new item should be placed after
*/
//ReplayGainFileListItem( TQListView* parent, TQListViewItem* after );
/**
* Constructor
* @param parent The parent list view item
*/
ReplayGainFileListItem( ReplayGainFileListItem* parent );
/**
* Destructor
*/
virtual ~ReplayGainFileListItem();
virtual void paintCell( TQPainter* p, const TQColorGroup& cg, int column, int width, int alignment );
int compare( TQListViewItem* item, int column, bool ascending ) const;
void updateReplayGainCells( TagData* );
ReplayGainFileListItem* firstChild() const { return static_cast<ReplayGainFileListItem*>( TDEListViewItem::firstChild() ); }
ReplayGainFileListItem* nextSibling() const { return static_cast<ReplayGainFileListItem*>( TDEListViewItem::nextSibling() ); }
//ReplayGainFileListItem* itemBelow() { return static_cast<ReplayGainFileListItem*>( TDEListViewItem::itemBelow() ); }
ReplayGainFileListItem* parent() const { return static_cast<ReplayGainFileListItem*>( TDEListViewItem::parent() ); }
Type type() { return m_type; }
void setType( Type );
// FIXME file list
/* TODO check sampling rate, too
* metaflac: 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, or 48 kHz.
*/
TQString filePathName; // the path and name of the file
//TQString fileName; // just the _name_ of the file
TQString mimeType; // the mime type of the file / the mime type of all files in this album
TQString fileFormat; // just the _format_ of the file / the format of all files in this album (for easier use)
TQString originalFileFormat; // after renaming we need to re-rename the file
bool addingReplayGain; // are we adding replay gain tags at the moment?
bool queued; // is this item queued for adding/removing replay gain?
Mode mode;
float time; // the duration of the track, used for the calculation of the progress bar
private:
Type m_type;
};
/**
* @short The file list of the Replay Gain scanner
* @author Daniel Faust <hessijames@gmail.com>
* @version 0.3
*/
class ReplayGainFileList : public TDEListView
{
TQ_OBJECT
public:
/**
* Constructor
* @param parent The parent widget
* @param name The name of the file list
*/
ReplayGainFileList( TagEngine*, Config*, Logger*, TQWidget *parent=0, const char *name=0 );
/**
* Destructor
*/
virtual ~ReplayGainFileList();
ReplayGainFileListItem* firstChild() const { return static_cast<ReplayGainFileListItem*>( TDEListView::firstChild() ); }
ReplayGainFileListItem* itemAt( const TQPoint& point ) const { return static_cast<ReplayGainFileListItem*>( TDEListView::itemAt(point) ); }
int columnByName( const TQString& name );
protected:
virtual bool acceptDrag( TQDropEvent *e ) const;
private slots:
void columnResizeEvent( int, int, int );
void openAlbums();
void closeAlbums();
void update();
public slots:
void addFile( const TQString& );
void addDir( const TQString&, const TQStringList& filter = "", bool recursive = true );
void calcAllReplayGain( bool force );
void removeAllReplayGain();
void cancelProcess();
private:
/** Lists all file in a directory and adds them to the file list, if @p fast is false. The number of listed files is returned */
int listDir( const TQString& directory, TQStringList filter, bool recursive = true, bool fast = false, int count = 0 );
/** A progressbar, that is shown, when a directory is added recursive */
KProgress* pScanStatus;
TagEngine* tagEngine;
Config* config;
Logger* logger;
TDEProcess* process;
ReplayGain* replayGain;
int logID;
void contentsDragEnterEvent( TQDragEnterEvent *e );
void contentsDragMoveEvent( TQDragMoveEvent *e );
void contentsDropEvent( TQDropEvent *e );
void viewportPaintEvent( TQPaintEvent* );
void viewportResizeEvent( TQResizeEvent* );
TQSimpleRichText* bubble;
void startProcess();
void processNextFile();
void calcReplayGain( ReplayGainFileListItem* );
void removeReplayGain( ReplayGainFileListItem* );
bool queue;
ReplayGainFileListItem::Mode mode;
ReplayGainFileListItem* currentItem;
TQTimer* tUpdateProgress;
bool processing; // true, if the progress is active (hide some options in the context menu)
int percent; // the progress of the current file / album
int lastPercent; // cache the last percent in order to record a 'track change'
float time; // track length of all files
float processedTime; // the sum of all track lengths of the processed files
int files; // the number of files in the current album
int file; // the file that is being 'replay gained'
float timeCount; // the sum of all track lengths in the current album / the track length of the current file
/** The context menu for editing or starting the files */
TDEPopupMenu* contextMenu;
TDEActionCollection* actionCollection;
TDEAction* calc_gain;
TDEAction* remove_gain;
TDEAction* newalbum;
TDEAction* remove;
TDEAction* paste;
TDEAction* open_albums;
TDEAction* close_albums;
private slots:
void showContextMenu( TQListViewItem*, const TQPoint&, int );
/**
* Remove selected items from the file list
*/
void removeSelectedItems();
/**
* Creates a new 'album' item in the list view
*/
void createNewAlbum();
/**
* Calculates the replay gain tags of the selected items
*/
void calcSelectedItemsGain();
/**
* Remove the replay gain tags of the selected items
*/
void removeSelectedItemsGain();
void slotDropped( TQDropEvent*, TQListViewItem*, TQListViewItem* ); // NOTE rename?
void processOutput( TDEProcess*, char*, int );
void processExit( TDEProcess* );
signals:
//void calcGain();
//void removeGain();
// void addFile( const TQString& filename );
void processStarted();
void processStopped();
void updateProgress( int, int );
};
#endif // REPLAYGAINFILELIST_H
|