22 #include <QCloseEvent>
24 #include <kmessagebox.h>
25 #include <kstandardguiitem.h>
26 #include <util/error.h>
28 #include <interfaces/torrentinterface.h>
33 #if LIBKTORRENT_VERSION >= 0x010100
35 :
KDialog(parent), m_job(static_cast<Job*>(job))
37 setButtons(KDialog::None);
41 setMainWidget(widget);
42 m_torrent_label = ui.torrent_label;
43 m_chunks_found = ui.chunks_found;
44 m_chunks_failed = ui.chunks_failed;
45 m_chunks_downloaded = ui.chunks_downloaded;
46 m_chunks_not_downloaded = ui.chunks_not_downloaded;
47 m_progress = ui.progress;
49 m_cancel->setGuiItem(KStandardGuiItem::cancel());
50 connect(m_cancel,SIGNAL(clicked()),
this,SLOT(reject()));
51 m_progress->setMaximum(100);
52 m_progress->setValue(0);
55 connect(m_job, SIGNAL(result(
KJob*)),
57 connect(m_job, SIGNAL(percent(
KJob*,ulong)),
58 SLOT(percent(
KJob*,ulong)));
74 void ScanDlg::reject()
84 void ScanDlg::accept()
92 m_chunks_found->setText(field1.first);
93 m_chunks_failed->setText(field1.second);
94 m_chunks_downloaded->setText(field1.first);
95 m_chunks_not_downloaded->setText(field2.second);
98 void ScanDlg::result(
KJob *job)
100 if (job->error() && job->error() != KIO::ERR_USER_CANCELED) {
101 KMessageBox::error(0,i18n(
"Error scanning data: %1",job->errorString()));
104 m_progress->setValue(100);
105 disconnect(m_cancel,SIGNAL(clicked()),
this,SLOT(reject()));
106 connect(m_cancel,SIGNAL(clicked()),
this,SLOT(accept()));
109 void ScanDlg::percent(
KJob *job,
unsigned long percent)
111 m_progress->setValue(percent);
115 :
KDialog(parent),bt::DataCheckerListener(false),mutex(
QMutex::Recursive)
117 setButtons(KDialog::None);
121 setMainWidget(widget);
122 m_torrent_label = ui.torrent_label;
123 m_chunks_found = ui.chunks_found;
124 m_chunks_failed = ui.chunks_failed;
125 m_chunks_downloaded = ui.chunks_downloaded;
126 m_chunks_not_downloaded = ui.chunks_not_downloaded;
127 m_progress = ui.progress;
128 m_cancel = ui.cancel;
129 m_cancel->setGuiItem(KStandardGuiItem::cancel());
131 connect(&timer,SIGNAL(timeout()),
this,SLOT(
update()));
141 num_not_downloaded = 0;
154 tc->startDataCheck(
this);
158 catch (bt::Error & err)
160 KMessageBox::error(0,i18n(
"Error scanning data: %1",err.toString()));
166 m_torrent_label->
setText(i18n(
"Scanning data of <b>%1</b> :",tc->getStats().torrent_name));
168 m_cancel->setEnabled(
true);
169 this->silently = silently;
176 num_not_downloaded = 0;
177 if (auto_import || tc->getStats().running)
180 qm_priority = tc->getPriority();
182 if (tc->getStats().running)
194 total_chunks = total;
197 void ScanDlg::status(bt::Uint32 failed,Uint32 found,Uint32 downloaded,Uint32 not_downloaded)
202 num_downloaded = downloaded;
203 num_not_downloaded = not_downloaded;
225 m_cancel->setGuiItem(KStandardGuiItem::close());
227 connect(m_cancel,SIGNAL(clicked()),
this,SLOT(
accept()));
243 KMessageBox::error(0,i18n(
"Error scanning data: %1",message));
289 #include "scandlg.moc"
void setMaximum(int maximum)
void update()
Updates the GUI in app thread.
virtual void closeEvent(QCloseEvent *e)
Handle the close event.
virtual void error(const QString &)
virtual void progress(bt::Uint32 num, bt::Uint32 total)
Update progress info, runs in scan threadnted"))
QString number(int n, int base)
void setText(const QString &)
virtual void finished()
Scan finished, runs in app thread.
virtual void status(bt::Uint32 failed, bt::Uint32 found, bt::Uint32 downloaded, bt::Uint32 not_downloaded)
Update status info, runs in scan thread.
void execute(bt::TorrentInterface *tc, bool silently)
Starts the scan threadvent(QC.