[1f6d2f]: libkwave / FileProgress.h Maximize Restore History

Download this file

FileProgress.h    196 lines (153 with data), 5.1 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
188
189
190
191
192
193
194
195
/***************************************************************************
FileProgress.h - progress window for loading/saving files
-------------------
begin : Mar 11 2001
copyright : (C) 2001 by Thomas Eschenbacher
email : Thomas Eschenbacher <thomas.eschenbacher@gmx.de>
***************************************************************************/
/***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _FILE_PROGRESS_H_
#define _FILE_PROGRESS_H_
#include "config.h"
#include <QDialog>
#include <QUrl>
#include <QLabel>
#include <QTime>
#include <kdemacros.h>
#include "libkwave/Sample.h"
class QCloseEvent;
class QGridLayout;
class QLabel;
class QProgressBar;
class QResizeEvent;
class KProgress;
namespace Kwave
{
class KDE_EXPORT FileProgress: public QDialog
{
Q_OBJECT
public:
/**
* Constructor
* @param parent the parent widget
* @param url the URL of the file
* @param size the size of the file in bytes
* @param samples the number of samples
* @param rate sample rate in samples per second
* @param bits number of bits per sample
* @param tracks number of tracks
*/
FileProgress(QWidget *parent,
const QUrl &url, unsigned int size,
sample_index_t samples, double rate, unsigned int bits,
unsigned int tracks);
/** Destructor */
virtual ~FileProgress() {}
/**
* Returns true if the dialog is unusable or the user
* has pressed the "cancel" button.
*/
inline bool isCanceled() { return m_canceled; }
signals:
/**
* Emitted when the user has pressed the Cancel button and
* has confirmed with "Yes".
*/
void canceled();
public slots:
/**
* Advances the progress to a given position within the file.
* @param percent position within the file, in percent
*/
void setValue(qreal percent);
/**
* Like setValue, but takes position in bytes as argument
* @param pos position within the file, in bytes [0...m_size-1]
*/
void setBytePosition(quint64 pos);
/**
* Updates the length information, needed in stream mode.
* @param samples total number of samples, must be divided through
* the number of tracks for getting the real length
*/
void setLength(quint64 samples);
protected slots:
/**
* Connected to the "cancel" button to set the "m_canceled"
* flag if the user wants to abort.
*/
void cancel();
protected:
/**
* Fits again the URL label on resize events.
* @see fitUrlLabel()
*/
virtual void resizeEvent(QResizeEvent *);
/**
* Called if the window is to be closed.
*/
virtual void closeEvent(QCloseEvent *e);
/**
* Fits the URL text into the available area, with
* shortening it if necessary.
*/
void fitUrlLabel();
/**
* Adds a label to an info field. Used within the constructor.
* @param layout the QGridLayout with the labels
* @param text the content of the label, localized
* @param row the row within the layout [0...rows-1]
* @param column the column within the layout [0...columns-1]
* @return the label if successful, 0 if failed
* @internal
*/
QLabel *addInfoLabel(QGridLayout *layout, const QString text,
int row, int column);
/**
* Updates the statistics of the transferred bytes and
* transfer rate.
* @param rate transfer rate in kilobytes per seconds
* @param rest remaining time in seconds
* @param pos position in the file
* @internal
*/
void updateStatistics(double rate, double rest, quint64 pos);
protected:
/** url of the file */
QUrl m_url;
/** size of the file [Bytes] */
quint64 m_size;
/** label with the url, shortened when too long */
QLabel *m_lbl_url;
/** label with length info, changes in streaming mode */
QLabel *m_lbl_length;
/** progress bar */
QProgressBar *m_progress;
/** label with transfer statistics */
QLabel *m_stat_transfer;
/** label with progress statistics */
QLabel *m_stat_bytes;
/** start time, set on initialization of this dialog */
QTime m_time;
/** true if the dialog is unusable or canceled by the user */
bool m_canceled;
/** last displayed percent value */
int m_last_percent;
/** number of bits per sample */
unsigned int m_bits_per_sample;
/** number of samples per second, used for output */
double m_sample_rate;
/** number of tracks */
unsigned int m_tracks;
};
}
#endif /* _FILE_PROGRESS_H_ */
//***************************************************************************
//***************************************************************************