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
|
/***************************************************************************
sq_diroperator.cpp - description
-------------------
begin : Thu Nov 29 2007
copyright : (C) 2007 by Baryshev Dmitry
email : ksquirrel.iv@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. *
* *
***************************************************************************/
#include <kurl.h>
#include <konq_operations.h>
#include "sq_diroperator.h"
#include "sq_libraryhandler.h"
#include "sq_downloader.h"
#include "sq_glwidget.h"
SQ_DirOperator * SQ_DirOperator::m_inst = 0;
SQ_DirOperator::SQ_DirOperator(TQObject *parent) : TQObject(parent)
{
m_inst = this;
down = new SQ_Downloader(this, "SQ_Downloader [dirop]");
connect(down, TQT_SIGNAL(result(const KURL &)), this, TQT_SLOT(slotDownloaderResult(const KURL &)));
connect(down, TQT_SIGNAL(percents(int)), this, TQT_SLOT(slotDownloadPercents(int)));
}
SQ_DirOperator::~SQ_DirOperator()
{}
void SQ_DirOperator::execute(KFileItem *fi)
{
down->kill();
SQ_GLWidget::window()->setOriginalURL(fi->url());
if(fi->url().isLocalFile())
executePrivate(fi);
else if(SQ_LibraryHandler::instance()->maybeSupported(fi->url(), fi->mimetype()) != SQ_LibraryHandler::No)
down->start(fi);
}
void SQ_DirOperator::slotDownloaderResult(const KURL &url)
{
SQ_GLWidget::window()->setDownloadPercents(-1);
if(url.isEmpty())
return;
KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, url);
executePrivate(&fi);
}
void SQ_DirOperator::executePrivate(KFileItem *fi)
{
TQString fullpath = fi->url().path();
if(SQ_LibraryHandler::instance()->libraryForFile(fullpath))
SQ_GLWidget::window()->startDecoding(fullpath);
}
void SQ_DirOperator::slotDownloadPercents(int p)
{
SQ_GLWidget::window()->setDownloadPercents(p);
}
void SQ_DirOperator::del(const KURL &u, TQWidget *parent)
{
KURL::List list;
list.append(u);
KonqOperations::del(parent, KonqOperations::DEL, list);
}
#include "sq_diroperator.moc"
|