Subversion Repositories spk

Rev

Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
#ifndef __QTPROGRESS_H__
2
#define __QTPROGRESS_H__
3
 
4
#include "../spk.h"
5
#include <QProgressBar.h>
6
 
7
class QtMyProgress : public CProgressInfo7Zip
8
{
9
public:
10
	QtMyProgress ( QProgressBar *bar ) { m_pBar = bar; }
11
 
12
	virtual void ProgressUpdated ( const long cur, const long max )
13
	{
14
		if ( m_pBar )
15
			m_pBar->setProgress ( cur, max );
16
	}
17
	virtual void DoingFile ( CFile *file ) {}
18
 
19
protected:
20
	QProgressBar *m_pBar;
21
};
22
 
23
class QtFullProgress : public QtMyProgress
24
{
25
public:
26
	QtFullProgress ( QProgressBar *bar, long fullsize ) : QtMyProgress ( bar )
27
	{
28
		m_lFullSize = fullsize;
29
		m_lFileSize = 0;
30
		m_lCurrent = 0;
31
	}
32
	virtual void ProgressUpdated ( const long cur, const long max )
33
	{
34
		float diff = (float)m_lFileSize / (float)(int)max;
35
		UInt64 newCur = (UInt64)((int)cur * diff);
36
 
37
		QtMyProgress::ProgressUpdated ( (UInt64)(m_lCurrent + newCur), (UInt64)m_lFullSize );
38
	}
39
	void SetNextFile ( long size )
40
	{
41
		m_lCurrent += m_lFileSize;
42
		m_lFileSize = size;
43
	}
44
	virtual void DoingFile ( CFile *file ) { SetNextFile ( file->GetUncompressedDataSize() ); }
45
 
46
private:
47
	long m_lFullSize;
48
	long m_lFileSize;
49
	long m_lCurrent;
50
};
51
 
52
#endif //__QTPROGRESS_H__