kget
btdetailswidget.cpp
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 00003 Copyright (C) 2007 Lukas Appelhans <l.appelhans@gmx.de> 00004 00005 This program is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 */ 00010 00011 #include "btdetailswidget.h" 00012 00013 #include "bttransferhandler.h" 00014 #include "ui_btdetailswidgetfrm.h" 00015 00016 #include <kdebug.h> 00017 00018 BTDetailsWidget::BTDetailsWidget(BTTransferHandler * transfer) 00019 : m_transfer(transfer) 00020 { 00021 setupUi(this); 00022 00023 // Update the view with the correct values 00024 srcEdit->setText(transfer->source().url()); 00025 destEdit->setText(transfer->dest().url()); 00026 00027 seederLabel->setText(i18nc("not available", "n/a")); 00028 leecherLabel->setText(i18nc("not available", "n/a")); 00029 chunksDownloadedLabel->setText(i18nc("not available", "n/a")); 00030 chunksExcludedLabel->setText(i18nc("not available", "n/a")); 00031 chunksAllLabel->setText(i18nc("not available", "n/a")); 00032 chunksLeftLabel->setText(i18nc("not available", "n/a")); 00033 dlSpeedLabel->setText(i18nc("not available", "n/a")); 00034 ulSpeedLabel->setText(i18nc("not available", "n/a")); 00035 00036 progressBar->setValue(m_transfer->percent()); 00037 transfer->addObserver(this); 00038 } 00039 00040 BTDetailsWidget::~BTDetailsWidget() 00041 { 00042 m_transfer->delObserver(this); 00043 } 00044 00045 void BTDetailsWidget::transferChangedEvent(TransferHandler * transfer) 00046 { 00047 Q_UNUSED(transfer); 00048 TransferHandler::ChangesFlags transferFlags = m_transfer->changesFlags(this); 00049 00050 if(transferFlags & Transfer::Tc_DownloadSpeed) 00051 dlSpeedLabel->setText(KGlobal::locale()->formatByteSize(m_transfer->downloadSpeed())); 00052 00053 if(transferFlags & Transfer::Tc_UploadSpeed) 00054 ulSpeedLabel->setText(KGlobal::locale()->formatByteSize(m_transfer->uploadSpeed())); 00055 00056 if(transferFlags & BTTransfer::Tc_SeedsConnected) 00057 seederLabel->setText(QString().setNum(m_transfer->seedsConnected()) + '(' + QString().setNum(m_transfer->seedsDisconnected()) + ')'); 00058 00059 if(transferFlags & BTTransfer::Tc_LeechesConnected) 00060 leecherLabel->setText(QString().setNum(m_transfer->leechesConnected()) + '(' + QString().setNum(m_transfer->leechesDisconnected()) + ')'); 00061 00062 if(transferFlags & BTTransfer::Tc_ChunksDownloaded) 00063 chunksDownloadedLabel->setText(QString().setNum(m_transfer->chunksDownloaded())); 00064 00065 if(transferFlags & BTTransfer::Tc_ChunksExcluded) 00066 chunksExcludedLabel->setText(QString().setNum(m_transfer->chunksExcluded())); 00067 00068 if(transferFlags & BTTransfer::Tc_ChunksTotal) 00069 chunksAllLabel->setText(QString().setNum(m_transfer->chunksTotal())); 00070 00071 if(transferFlags & BTTransfer::Tc_ChunksLeft) 00072 chunksLeftLabel->setText(QString().setNum(m_transfer->chunksLeft())); 00073 00074 if(transferFlags & Transfer::Tc_Percent) 00075 progressBar->setValue(m_transfer->percent()); 00076 00077 m_transfer->resetChangesFlags(this); 00078 } 00079 00080 #include "btdetailswidget.moc"
KDE 4.2 API Reference