Relicense all GPLv2 only code to GPLv2+.
[kdenetwork.git] / kget / ui / transferdetails.cpp
blob5b4b2164b2117cc930d0650f97761cd6e99fcee3
1 /* This file is part of the KDE project
3 Copyright (C) 2005 Dario Massarin <nekkar@libero.it>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9 */
11 #include "transferdetails.h"
13 #include "ui_transferdetailsfrm.h"
14 #include "core/kget.h"
16 #include <klocale.h>
17 #include <kio/global.h>
19 #include <QVBoxLayout>
21 TransferDetails::TransferDetails(TransferHandler * transfer)
22 : m_transfer(transfer)
24 m_genericWidget = new QWidget(this);
26 Ui::TransferDetailsFrm frm;
27 frm.setupUi(m_genericWidget);
29 m_detailsWidget = KGet::factory(transfer)->createDetailsWidget(transfer);
31 m_layout = new QVBoxLayout(this);
32 m_layout->addWidget(m_genericWidget);
33 m_layout->addWidget(m_detailsWidget);
34 setLayout(m_layout);
36 frm.sourceLabel->setText(i18n("Source:"));
37 frm.destLabel->setText(i18n("Saving to:"));
38 frm.statusLabel->setText(i18n("Status:"));
40 frm.sourceContentEdit->setText(transfer->source().url());
41 frm.destContentEdit->setText(transfer->dest().url());
43 m_statusPixmapLabel = frm.statusPixmapContentLabel;
44 m_statusTextLabel = frm.statusTextContentLabel;
45 m_completedLabel = frm.completedContentLabel;
46 m_speedLabel = frm.speedContentLabel;
47 m_progressBar = frm.progressBar;
49 transfer->addObserver(this);
50 //This updates the widget with the right values
51 transferChangedEvent(transfer);
54 TransferDetails::~TransferDetails()
56 m_transfer->delObserver(this);
59 void TransferDetails::transferChangedEvent(TransferHandler * transfer)
61 Q_UNUSED(transfer);
63 TransferHandler::ChangesFlags transferFlags = m_transfer->changesFlags(this);
65 if(transferFlags & Transfer::Tc_Status)
67 m_statusPixmapLabel->setPixmap(m_transfer->statusPixmap());
68 m_statusTextLabel->setText(m_transfer->statusText());
71 if(transferFlags & Transfer::Tc_TotalSize)
73 m_completedLabel->setText(KIO::convertSize(m_transfer->processedSize())
74 + i18n(" of ") +
75 KIO::convertSize(m_transfer->totalSize()));
78 if(transferFlags & Transfer::Tc_ProcessedSize)
80 m_completedLabel->setText(KIO::convertSize(m_transfer->processedSize())
81 + i18n(" of ") +
82 KIO::convertSize(m_transfer->totalSize()));
85 if(transferFlags & Transfer::Tc_Percent)
87 m_progressBar->setValue(m_transfer->percent());
90 if(transferFlags & Transfer::Tc_Speed)
92 int speed = m_transfer->speed();
94 if(speed==0)
96 if(m_transfer->status() == Job::Running)
97 m_speedLabel->setText(i18n("Stalled") );
98 else
99 m_speedLabel->setText(QString());
101 else
102 m_speedLabel->setText(i18n("%1/s", KIO::convertSize(speed)));
106 m_transfer->resetChangesFlags(this);
109 #include "transferdetails.moc"