summaryrefslogtreecommitdiffstats
path: root/apps/ktorrent/scandialog.h
blob: 62a3d7bdd9b9ea10eccc5ea1528905f1a22529ab (plain)
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
/***************************************************************************
 *   Copyright (C) 2005 by Joris Guisson                                   *
 *   joris.guisson@gmail.com                                               *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program 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 this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/

#ifndef SCANDIALOG_H
#define SCANDIALOG_H

#include <tqmutex.h>
#include <tqtimer.h>
#include <datachecker/datacheckerlistener.h>
#include "scandlgbase.h"


namespace kt
{
	class TorrentInterface;
}

class KTorrentCore;

class ScanDialog : public ScanDlgBase, public bt::DataCheckerListener
{
	Q_OBJECT
  
public:
	ScanDialog(KTorrentCore* core,bool auto_import,TQWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = WDestructiveClose  );
	virtual ~ScanDialog();

	/// Starts the scan thread
	void execute(kt::TorrentInterface* tc,bool silently);

protected:
	/// Update progress info, runs in scan thread
	virtual void progress(bt::Uint32 num,bt::Uint32 total);
	
	/// Update status info, runs in scan thread
	virtual void status(bt::Uint32 num_failed,bt::Uint32 num_downloaded);
	
	/// Scan finished, runs in app thread
	virtual void finished();
	
	/// Handle the close event
	virtual void closeEvent(TQCloseEvent* e);
	

protected slots:
	virtual void reject();
	virtual void accept();
	void onCancelPressed();
	/// Updates the GUI in app thread
	void update();
	void scan();

private:
	kt::TorrentInterface* tc;
	TQMutex mutex;
	TQTimer timer;
	bt::Uint32 num_chunks;
	bt::Uint32 total_chunks;
	bt::Uint32 num_downloaded;
	bt::Uint32 num_failed;
	bool silently;
	bool restart;
	bool qm_controlled;
	int qm_priority;
	bool scanning;
	KTorrentCore* core;
};


#endif