mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-22 15:59:54 -05:00
reengineered the transfer list display
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2349 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
082d5732b0
commit
3014a9a233
@ -66,8 +66,8 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the background color
|
// draw the background color if not the progress column or if progress is not displayed
|
||||||
if(index.column() != PROGRESS) {
|
if(index.column() != PROGRESS || ((FileProgressInfo)index.data().value<FileProgressInfo>()).nb_chunks == 0) {
|
||||||
if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
|
if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
|
||||||
if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
|
if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
|
||||||
cg = QPalette::Inactive;
|
cg = QPalette::Inactive;
|
||||||
@ -83,8 +83,8 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case SIZE:
|
case SIZE:
|
||||||
fileSize = index.data().toLongLong();
|
fileSize = index.data().toLongLong();
|
||||||
if(fileSize < 0){
|
if(fileSize <= 0){
|
||||||
temp = "Unknown";
|
temp = "";
|
||||||
} else {
|
} else {
|
||||||
multi = 1.0;
|
multi = 1.0;
|
||||||
for(int i = 0; i < 5; ++i) {
|
for(int i = 0; i < 5; ++i) {
|
||||||
@ -122,8 +122,8 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
break;
|
break;
|
||||||
case COMPLETED:
|
case COMPLETED:
|
||||||
completed = index.data().toLongLong();
|
completed = index.data().toLongLong();
|
||||||
if(completed < 0){
|
if(completed <= 0){
|
||||||
temp = "Unknown";
|
temp = "";
|
||||||
} else {
|
} else {
|
||||||
multi = 1.0;
|
multi = 1.0;
|
||||||
for(int i = 0; i < 5; ++i) {
|
for(int i = 0; i < 5; ++i) {
|
||||||
@ -141,15 +141,20 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
break;
|
break;
|
||||||
case DLSPEED:
|
case DLSPEED:
|
||||||
dlspeed = index.data().toDouble();
|
dlspeed = index.data().toDouble();
|
||||||
|
if (dlspeed <= 0) {
|
||||||
|
temp = "";
|
||||||
|
} else {
|
||||||
temp.clear();
|
temp.clear();
|
||||||
temp.sprintf("%.2f", dlspeed/1024.);
|
temp.sprintf("%.2f", dlspeed/1024.);
|
||||||
temp += " KB/s";
|
temp += " KB/s";
|
||||||
|
}
|
||||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||||
break;
|
break;
|
||||||
case PROGRESS:
|
case PROGRESS:
|
||||||
{
|
{
|
||||||
// create a xProgressBar
|
// create a xProgressBar
|
||||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||||
|
if (pinfo.nb_chunks != 0) {
|
||||||
xProgressBar progressBar(pinfo,option.rect, painter); // the 3rd param is the color schema (0 is the default value)
|
xProgressBar progressBar(pinfo,option.rect, painter); // the 3rd param is the color schema (0 is the default value)
|
||||||
if(pinfo.type == FileProgressInfo::DOWNLOAD_LINE)
|
if(pinfo.type == FileProgressInfo::DOWNLOAD_LINE)
|
||||||
{
|
{
|
||||||
@ -164,18 +169,21 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
progressBar.setVerticalSpan(1);
|
progressBar.setVerticalSpan(1);
|
||||||
progressBar.paint(); // paint the progress bar
|
progressBar.paint(); // paint the progress bar
|
||||||
}
|
}
|
||||||
|
}
|
||||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||||
break;
|
break;
|
||||||
case NAME:
|
case NAME:
|
||||||
// decoration
|
// decoration
|
||||||
value = index.data(Qt::DecorationRole);
|
value = index.data(Qt::DecorationRole);
|
||||||
|
temp = index.data().toString();
|
||||||
pixmap = qvariant_cast<QIcon>(value).pixmap(option.decorationSize, option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled, option.state & QStyle::State_Open ? QIcon::On : QIcon::Off);
|
pixmap = qvariant_cast<QIcon>(value).pixmap(option.decorationSize, option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled, option.state & QStyle::State_Open ? QIcon::On : QIcon::Off);
|
||||||
pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0): QRect(QPoint(0, 0), option.decorationSize));
|
pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0): QRect(QPoint(0, 0), option.decorationSize));
|
||||||
if (pixmapRect.isValid()){
|
if (pixmapRect.isValid()){
|
||||||
QPoint p = QStyle::alignedRect(option.direction, Qt::AlignLeft, pixmap.size(), option.rect).topLeft();
|
QPoint p = QStyle::alignedRect(option.direction, Qt::AlignLeft, pixmap.size(), option.rect).topLeft();
|
||||||
painter->drawPixmap(p, pixmap);
|
painter->drawPixmap(p, pixmap);
|
||||||
|
temp = " " + temp;
|
||||||
}
|
}
|
||||||
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, index.data().toString());
|
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, temp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
||||||
|
@ -97,7 +97,7 @@ void FileTransferInfoWidget::updateDisplay()
|
|||||||
|
|
||||||
void FileTransferInfoWidget::paintEvent(QPaintEvent *event)
|
void FileTransferInfoWidget::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
std::cout << "In paint event" << std::endl ;
|
//std::cout << "In paint event" << std::endl ;
|
||||||
QStylePainter painter(this);
|
QStylePainter painter(this);
|
||||||
|
|
||||||
painter.drawPixmap(0, 0, pixmap2);
|
painter.drawPixmap(0, 0, pixmap2);
|
||||||
|
@ -159,14 +159,8 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
_header->resizeSection ( PRIORITY, 100 );
|
_header->resizeSection ( PRIORITY, 100 );
|
||||||
_header->resizeSection ( REMAINING, 100 );
|
_header->resizeSection ( REMAINING, 100 );
|
||||||
|
|
||||||
connect(_header, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSortIndicatorDwl(int, Qt::SortOrder)));
|
|
||||||
|
|
||||||
// set default column and sort order for download
|
|
||||||
_sortColDwl = 0;
|
|
||||||
_sortOrderDwl = Qt::AscendingOrder;
|
|
||||||
|
|
||||||
// Set Upload list model
|
// Set Upload list model
|
||||||
ULListModel = new QStandardItemModel(0,7);
|
ULListModel = new QStandardItemModel(0,8);
|
||||||
ULListModel->setHeaderData(UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
ULListModel->setHeaderData(UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
||||||
ULListModel->setHeaderData(USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
ULListModel->setHeaderData(USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
||||||
ULListModel->setHeaderData(USERNAME, Qt::Horizontal, tr("Peer", "i.e: user name"));
|
ULListModel->setHeaderData(USERNAME, Qt::Horizontal, tr("Peer", "i.e: user name"));
|
||||||
@ -174,6 +168,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
ULListModel->setHeaderData(ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed"));
|
ULListModel->setHeaderData(ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed"));
|
||||||
ULListModel->setHeaderData(USTATUS, Qt::Horizontal, tr("Status"));
|
ULListModel->setHeaderData(USTATUS, Qt::Horizontal, tr("Status"));
|
||||||
ULListModel->setHeaderData(UTRANSFERRED, Qt::Horizontal, tr("Transferred", ""));
|
ULListModel->setHeaderData(UTRANSFERRED, Qt::Horizontal, tr("Transferred", ""));
|
||||||
|
ULListModel->setHeaderData(UHASH, Qt::Horizontal, tr("Hash", ""));
|
||||||
ui.uploadsList->setModel(ULListModel);
|
ui.uploadsList->setModel(ULListModel);
|
||||||
ULDelegate = new ULListDelegate();
|
ULDelegate = new ULListDelegate();
|
||||||
ui.uploadsList->setItemDelegate(ULDelegate);
|
ui.uploadsList->setItemDelegate(ULDelegate);
|
||||||
@ -207,10 +202,6 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
|
|
||||||
connect(upheader, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSortIndicatorUpl(int, Qt::SortOrder)));
|
connect(upheader, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSortIndicatorUpl(int, Qt::SortOrder)));
|
||||||
|
|
||||||
// set default column and sort order for upload
|
|
||||||
_sortColUpl = 0;
|
|
||||||
_sortOrderUpl = Qt::AscendingOrder;
|
|
||||||
|
|
||||||
FileTransferInfoWidget *ftiw = new FileTransferInfoWidget();
|
FileTransferInfoWidget *ftiw = new FileTransferInfoWidget();
|
||||||
ui.fileTransferInfoWidget->setWidget(ftiw);
|
ui.fileTransferInfoWidget->setWidget(ftiw);
|
||||||
ui.fileTransferInfoWidget->setWidgetResizable(true);
|
ui.fileTransferInfoWidget->setWidgetResizable(true);
|
||||||
@ -321,15 +312,7 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||||||
pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste retroshare Link" ), this );
|
pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste retroshare Link" ), this );
|
||||||
connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
||||||
|
|
||||||
rootisnotdecoratedAct = new QAction(QIcon(), tr( "Set Root is not Decorated" ), this );
|
|
||||||
connect( rootisnotdecoratedAct , SIGNAL( triggered() ), this, SLOT( rootisnotdecorated() ) );
|
|
||||||
|
|
||||||
rootisdecoratedAct = new QAction(QIcon(), tr( "Set Root is Decorated" ), this );
|
|
||||||
connect( rootisdecoratedAct , SIGNAL( triggered() ), this, SLOT( rootdecorated() ) );
|
|
||||||
|
|
||||||
QMenu *viewMenu = new QMenu( tr("View"), this );
|
QMenu *viewMenu = new QMenu( tr("View"), this );
|
||||||
viewMenu->addAction(rootisnotdecoratedAct);
|
|
||||||
viewMenu->addAction(rootisdecoratedAct);
|
|
||||||
|
|
||||||
clearQueueAct = new QAction(QIcon(), tr("Remove all queued"), this);
|
clearQueueAct = new QAction(QIcon(), tr("Remove all queued"), this);
|
||||||
connect(clearQueueAct, SIGNAL(triggered()), this, SLOT(clearQueue()));
|
connect(clearQueueAct, SIGNAL(triggered()), this, SLOT(clearQueue()));
|
||||||
@ -474,16 +457,6 @@ void TransfersDialog::playSelectedTransfer()
|
|||||||
playFiles(playList);
|
playFiles(playList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TransfersDialog::updateProgress(int value)
|
|
||||||
{
|
|
||||||
// for(int i = 0; i <= DLListModel->rowCount(); i++) {
|
|
||||||
// if(selection->isRowSelected(i, QModelIndex())) {
|
|
||||||
// editItem(i, PROGRESS, QVariant((double)value));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
TransfersDialog::~TransfersDialog()
|
TransfersDialog::~TransfersDialog()
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
@ -494,15 +467,16 @@ int TransfersDialog::addItem(const QString& symbol, const QString& name, const Q
|
|||||||
const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining)
|
const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining)
|
||||||
{
|
{
|
||||||
int row;
|
int row;
|
||||||
QString sl;
|
QList<QStandardItem *> list = DLListModel->findItems(coreID, Qt::MatchExactly, ID);
|
||||||
//QIcon icon(symbol);
|
QStandardItem* item;
|
||||||
//name.insert(0, " ");
|
if (list.size() > 0) {
|
||||||
//sl.sprintf("%d / %d", seeds, leechs);
|
row = list.front()->row();
|
||||||
|
} else {
|
||||||
row = DLListModel->rowCount();
|
row = DLListModel->rowCount();
|
||||||
DLListModel->insertRow(row);
|
DLListModel->insertRow(row);
|
||||||
|
}
|
||||||
|
|
||||||
//DLListModel->setData(DLListModel->index(row, NAME), QVariant((QIcon)icon), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(name));
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant((QString)" "+name), Qt::DisplayRole);
|
|
||||||
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)fileSize));
|
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)fileSize));
|
||||||
DLListModel->setData(DLListModel->index(row, COMPLETED), QVariant((qlonglong)completed));
|
DLListModel->setData(DLListModel->index(row, COMPLETED), QVariant((qlonglong)completed));
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)dlspeed));
|
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)dlspeed));
|
||||||
@ -514,78 +488,69 @@ int TransfersDialog::addItem(const QString& symbol, const QString& name, const Q
|
|||||||
DLListModel->setData(DLListModel->index(row, ID), QVariant((QString)coreID));
|
DLListModel->setData(DLListModel->index(row, ID), QVariant((QString)coreID));
|
||||||
|
|
||||||
|
|
||||||
QString ext = QFileInfo(name).suffix();
|
// QString ext = QFileInfo(name).suffix();
|
||||||
if (ext == "jpg" || ext == "jpeg" || ext == "tif" || ext == "tiff" || ext == "JPG"|| ext == "png" || ext == "gif"
|
// if (ext == "jpg" || ext == "jpeg" || ext == "tif" || ext == "tiff" || ext == "JPG"|| ext == "png" || ext == "gif"
|
||||||
|| ext == "bmp" || ext == "ico" || ext == "svg")
|
// || ext == "bmp" || ext == "ico" || ext == "svg") {
|
||||||
{
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypePicture.png")), Qt::DecorationRole);
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypePicture.png")), Qt::DecorationRole);
|
// } else if (ext == "avi" ||ext == "AVI" || ext == "mpg" || ext == "mpeg" || ext == "wmv" || ext == "divx" || ext == "ts"
|
||||||
}
|
// || ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov" || ext == "asf" || ext == "xvid"
|
||||||
else if (ext == "avi" ||ext == "AVI" || ext == "mpg" || ext == "mpeg" || ext == "wmv" || ext == "divx" || ext == "ts"
|
// || ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp" || ext == "mpeg" || ext == "ogm") {
|
||||||
|| ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov" || ext == "asf" || ext == "xvid"
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeVideo.png")), Qt::DecorationRole);
|
||||||
|| ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp" || ext == "mpeg" || ext == "ogm")
|
// } else if (ext == "ogg" || ext == "mp3" || ext == "MP3" || ext == "mp1" || ext == "mp2" || ext == "wav" || ext == "wma") {
|
||||||
{
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeAudio.png")), Qt::DecorationRole);
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeVideo.png")), Qt::DecorationRole);
|
// } else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz" || ext == "7z" || ext == "msi"
|
||||||
}
|
// || ext == "rar" || ext == "rpm" || ext == "ace" || ext == "jar" || ext == "tgz" || ext == "lha"
|
||||||
else if (ext == "ogg" || ext == "mp3" || ext == "MP3" || ext == "mp1" || ext == "mp2" || ext == "wav" || ext == "wma")
|
// || ext == "cab" || ext == "cbz"|| ext == "cbr" || ext == "alz" || ext == "sit" || ext == "arj" || ext == "deb") {
|
||||||
{
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeArchive.png")), Qt::DecorationRole);
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeAudio.png")), Qt::DecorationRole);
|
// }else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com"
|
||||||
}
|
// || ext == "exe" || ext == "js" || ext == "pif"
|
||||||
else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz" || ext == "7z" || ext == "msi"
|
// || ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws") {
|
||||||
|| ext == "rar" || ext == "rpm" || ext == "ace" || ext == "jar" || ext == "tgz" || ext == "lha"
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeProgram.png")), Qt::DecorationRole);
|
||||||
|| ext == "cab" || ext == "cbz"|| ext == "cbr" || ext == "alz" || ext == "sit" || ext == "arj" || ext == "deb")
|
// } else if (ext == "iso" || ext == "nrg" || ext == "mdf" || ext == "img" || ext == "dmg" || ext == "bin" ) {
|
||||||
{
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeCDImage.png")), Qt::DecorationRole);
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeArchive.png")), Qt::DecorationRole);
|
// } else if (ext == "txt" || ext == "cpp" || ext == "c" || ext == "h") {
|
||||||
}
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")), Qt::DecorationRole);
|
||||||
else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com"
|
// } else if (ext == "doc" || ext == "rtf" || ext == "sxw" || ext == "xls" || ext == "pps" || ext == "xml"
|
||||||
|| ext == "exe" || ext == "js" || ext == "pif"
|
// || ext == "sxc" || ext == "odt" || ext == "ods" || ext == "dot" || ext == "ppt" || ext == "css" ) {
|
||||||
|| ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws")
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")), Qt::DecorationRole);
|
||||||
{
|
// } else if (ext == "html" || ext == "htm" || ext == "php") {
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeProgram.png")), Qt::DecorationRole);
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")), Qt::DecorationRole);
|
||||||
}
|
// } else {
|
||||||
else if (ext == "iso" || ext == "nrg" || ext == "mdf" || ext == "img" || ext == "dmg" || ext == "bin" )
|
// DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeAny.png")), Qt::DecorationRole);
|
||||||
{
|
// }
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeCDImage.png")), Qt::DecorationRole);
|
|
||||||
}
|
|
||||||
else if (ext == "txt" || ext == "cpp" || ext == "c" || ext == "h")
|
|
||||||
{
|
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")), Qt::DecorationRole);
|
|
||||||
}
|
|
||||||
else if (ext == "doc" || ext == "rtf" || ext == "sxw" || ext == "xls" || ext == "pps" || ext == "xml"
|
|
||||||
|| ext == "sxc" || ext == "odt" || ext == "ods" || ext == "dot" || ext == "ppt" || ext == "css" )
|
|
||||||
{
|
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")), Qt::DecorationRole);
|
|
||||||
}
|
|
||||||
else if (ext == "html" || ext == "htm" || ext == "php")
|
|
||||||
{
|
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")), Qt::DecorationRole);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeAny.png")), Qt::DecorationRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TransfersDialog::addPeerToItem(int row, const QString& symbol, const QString& name, const QString& coreID, qlonglong fileSize, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, qlonglong completed, qlonglong remaining)
|
bool TransfersDialog::addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, const QString& status)
|
||||||
{
|
{
|
||||||
QStandardItem *dlItem = DLListModel->item(row);
|
QStandardItem *dlItem = DLListModel->item(row);
|
||||||
if (!dlItem) return false;
|
if (!dlItem) return false;
|
||||||
|
|
||||||
|
//try to find the item
|
||||||
|
int childRow = -1;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
while (QStandardItem* childId = dlItem->child(count, ID)) {
|
||||||
|
if (childId->data(Qt::DisplayRole).toString() == coreID) {
|
||||||
|
childRow = count;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if (childRow == -1) {
|
||||||
//set this false if you want to expand on double click
|
//set this false if you want to expand on double click
|
||||||
dlItem->setEditable(false);
|
dlItem->setEditable(false);
|
||||||
|
|
||||||
//name.insert(0, " ");
|
|
||||||
|
|
||||||
QList<QStandardItem *> items;
|
QList<QStandardItem *> items;
|
||||||
QStandardItem *i1 = new QStandardItem(); i1->setData(QVariant((QString)" "+name), Qt::DisplayRole);
|
QStandardItem *i1 = new QStandardItem(); i1->setData(QVariant((QString)" "+name), Qt::DisplayRole);
|
||||||
QStandardItem *i2 = new QStandardItem(); i2->setData(QVariant((qlonglong)fileSize), Qt::DisplayRole);
|
QStandardItem *i2 = new QStandardItem(); i2->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
QStandardItem *i3 = new QStandardItem(); i3->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
|
QStandardItem *i3 = new QStandardItem(); i3->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
QStandardItem *i4 = new QStandardItem(); i4->setData(QVariant((double)dlspeed), Qt::DisplayRole);
|
QStandardItem *i4 = new QStandardItem(); i4->setData(QVariant((double)dlspeed), Qt::DisplayRole);
|
||||||
QStandardItem *i5 = new QStandardItem(); i5->setData(QVariant::fromValue(pinfo), Qt::DisplayRole);
|
QStandardItem *i5 = new QStandardItem(); i5->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
QStandardItem *i6 = new QStandardItem(); i6->setData(QVariant((QString)sources), Qt::DisplayRole);
|
QStandardItem *i6 = new QStandardItem(); i6->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
QStandardItem *i7 = new QStandardItem(); i7->setData(QVariant((QString)status), Qt::DisplayRole);
|
QStandardItem *i7 = new QStandardItem(); i7->setData(QVariant((QString)status), Qt::DisplayRole);
|
||||||
QStandardItem *i8 = new QStandardItem(); i8->setData(QVariant((QString)tr("")), Qt::DisplayRole); // blank field for priority
|
QStandardItem *i8 = new QStandardItem(); i8->setData(QVariant(QString()), Qt::DisplayRole); // blank field for priority
|
||||||
QStandardItem *i9 = new QStandardItem(); i9->setData(QVariant(QString()), Qt::DisplayRole);
|
QStandardItem *i9 = new QStandardItem(); i9->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
QStandardItem *i10 = new QStandardItem(); i10->setData(QVariant((QString)coreID), Qt::DisplayRole);
|
QStandardItem *i10 = new QStandardItem(); i10->setData(QVariant((QString)coreID), Qt::DisplayRole);
|
||||||
|
|
||||||
@ -613,8 +578,25 @@ bool TransfersDialog::addPeerToItem(int row, const QString& symbol, const QStrin
|
|||||||
items.append(i8);
|
items.append(i8);
|
||||||
items.append(i9);
|
items.append(i9);
|
||||||
items.append(i10);
|
items.append(i10);
|
||||||
|
|
||||||
dlItem->appendRow(items);
|
dlItem->appendRow(items);
|
||||||
|
} else {
|
||||||
|
//just update the child (peer)
|
||||||
|
dlItem->child(childRow, DLSPEED)->setData(QVariant((double)dlspeed), Qt::DisplayRole);
|
||||||
|
dlItem->child(childRow, STATUS)->setData(QVariant((QString)status), Qt::DisplayRole);
|
||||||
|
/* set status icon in the name field */
|
||||||
|
if (status == "Downloading") {
|
||||||
|
dlItem->child(childRow, NAME)->setData(QIcon(QString::fromUtf8(":/images/Client0.png")), Qt::DecorationRole);
|
||||||
|
} else if (status == "Failed") {
|
||||||
|
dlItem->child(childRow, NAME)->setData(QIcon(QString::fromUtf8(":/images/Client1.png")), Qt::DecorationRole);
|
||||||
|
} else if (status == "Okay") {
|
||||||
|
dlItem->child(childRow, NAME)->setData(QIcon(QString::fromUtf8(":/images/Client2.png")), Qt::DecorationRole);
|
||||||
|
} else if (status == "Waiting") {
|
||||||
|
dlItem->child(childRow, NAME)->setData(QIcon(QString::fromUtf8(":/images/Client3.png")), Qt::DecorationRole);
|
||||||
|
} else if (status == "Unknown") {
|
||||||
|
dlItem->child(childRow, NAME)->setData(QIcon(QString::fromUtf8(":/images/Client4.png")), Qt::DecorationRole);
|
||||||
|
} else if (status == "Complete") {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -623,11 +605,14 @@ bool TransfersDialog::addPeerToItem(int row, const QString& symbol, const QStrin
|
|||||||
int TransfersDialog::addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong fileSize, const FileProgressInfo& pinfo, double dlspeed, const QString& source, const QString& status, qlonglong completed, qlonglong remaining)
|
int TransfersDialog::addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong fileSize, const FileProgressInfo& pinfo, double dlspeed, const QString& source, const QString& status, qlonglong completed, qlonglong remaining)
|
||||||
{
|
{
|
||||||
int row;
|
int row;
|
||||||
QString sl;
|
QList<QStandardItem *> list = ULListModel->findItems(coreID, Qt::MatchExactly, UHASH);
|
||||||
//QIcon icon(symbol);
|
QStandardItem* item;
|
||||||
//name.insert(0, " ");
|
if (list.size() > 0) {
|
||||||
|
row = list.front()->row();
|
||||||
|
} else {
|
||||||
row = ULListModel->rowCount();
|
row = ULListModel->rowCount();
|
||||||
ULListModel->insertRow(row);
|
ULListModel->insertRow(row);
|
||||||
|
}
|
||||||
|
|
||||||
ULListModel->setData(ULListModel->index(row, UNAME), QVariant((QString)" "+name), Qt::DisplayRole);
|
ULListModel->setData(ULListModel->index(row, UNAME), QVariant((QString)" "+name), Qt::DisplayRole);
|
||||||
ULListModel->setData(ULListModel->index(row, USIZE), QVariant((qlonglong)fileSize));
|
ULListModel->setData(ULListModel->index(row, USIZE), QVariant((qlonglong)fileSize));
|
||||||
@ -636,6 +621,7 @@ int TransfersDialog::addUploadItem(const QString& symbol, const QString& name, c
|
|||||||
ULListModel->setData(ULListModel->index(row, UPROGRESS), QVariant::fromValue(pinfo));
|
ULListModel->setData(ULListModel->index(row, UPROGRESS), QVariant::fromValue(pinfo));
|
||||||
ULListModel->setData(ULListModel->index(row, USTATUS), QVariant((QString)status));
|
ULListModel->setData(ULListModel->index(row, USTATUS), QVariant((QString)status));
|
||||||
ULListModel->setData(ULListModel->index(row, USERNAME), QVariant((QString)source));
|
ULListModel->setData(ULListModel->index(row, USERNAME), QVariant((QString)source));
|
||||||
|
ULListModel->setData(ULListModel->index(row, UHASH), QVariant((QString)coreID));
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@ -651,140 +637,70 @@ void TransfersDialog::delUploadItem(int row)
|
|||||||
ULListModel->removeRow(row, QModelIndex());
|
ULListModel->removeRow(row, QModelIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::editItem(int row, int column, QVariant data)
|
|
||||||
{
|
|
||||||
//QIcon *icon;
|
|
||||||
switch(column) {
|
|
||||||
//case SYMBOL:
|
|
||||||
// icon = new QIcon(data.toString());
|
|
||||||
// DLListModel->setData(DLListModel->index(row, NAME), QVariant((QIcon)*icon), Qt::DecorationRole);
|
|
||||||
// delete icon;
|
|
||||||
// break;
|
|
||||||
case NAME:
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), data, Qt::DisplayRole);
|
|
||||||
break;
|
|
||||||
case SIZE:
|
|
||||||
DLListModel->setData(DLListModel->index(row, SIZE), data);
|
|
||||||
break;
|
|
||||||
// case PROGRESS:
|
|
||||||
// DLListModel->setData(DLListModel->index(row, PROGRESS), data);
|
|
||||||
// break;
|
|
||||||
case DLSPEED:
|
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), data);
|
|
||||||
break;
|
|
||||||
case SOURCES:
|
|
||||||
DLListModel->setData(DLListModel->index(row, SOURCES), data);
|
|
||||||
break;
|
|
||||||
case STATUS:
|
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), data);
|
|
||||||
break;
|
|
||||||
case PRIORITY:
|
|
||||||
DLListModel->setData(DLListModel->index(row, PRIORITY), data);
|
|
||||||
break;
|
|
||||||
case COMPLETED:
|
|
||||||
DLListModel->setData(DLListModel->index(row, COMPLETED), data);
|
|
||||||
break;
|
|
||||||
case REMAINING:
|
|
||||||
DLListModel->setData(DLListModel->index(row, REMAINING), data);
|
|
||||||
break;
|
|
||||||
case ID:
|
|
||||||
DLListModel->setData(DLListModel->index(row, ID), data);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the list of Transfers from the RsIface. **/
|
/* get the list of Transfers from the RsIface. **/
|
||||||
void TransfersDialog::updateDisplay()
|
void TransfersDialog::updateDisplay()
|
||||||
{
|
{
|
||||||
insertTransfers();
|
insertTransfers();
|
||||||
}
|
}
|
||||||
void TransfersDialog::insertTransfers()
|
void TransfersDialog::insertTransfers() {
|
||||||
{
|
/* get the download lists */
|
||||||
QString symbol, name, sources, status, priority, coreId;
|
|
||||||
qlonglong fileSize, completed, remaining;
|
|
||||||
double progress, dlspeed;
|
|
||||||
|
|
||||||
|
|
||||||
/* get current selection */
|
|
||||||
std::list<std::string> selectedIds;
|
|
||||||
|
|
||||||
for (int i = 0; i < DLListModel->rowCount(); i++) {
|
|
||||||
if (selection->isRowSelected(i, QModelIndex())) {
|
|
||||||
std::string id = getID(i, DLListModel).toStdString();
|
|
||||||
selectedIds.push_back(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStandardItem *parent = DLListModel->item(i);
|
|
||||||
//if (!parent) continue;
|
|
||||||
int childs = parent->rowCount();
|
|
||||||
for (int j = 0; j < childs; j++) {
|
|
||||||
QModelIndex parentIndex = DLListModel->indexFromItem(parent);
|
|
||||||
if (selection->isRowSelected(j, parentIndex)) {
|
|
||||||
QStandardItem *child = parent->child(j, ID);
|
|
||||||
std::string id = child->data(Qt::DisplayRole).toString().toStdString();
|
|
||||||
selectedIds.push_back(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* view will be scrolled to first selected index */
|
|
||||||
QModelIndex firstSelIdx;
|
|
||||||
|
|
||||||
/* get expanded donwload items */
|
|
||||||
std::list<std::string> expandedIds;
|
|
||||||
|
|
||||||
for (int i = 0; i < DLListModel->rowCount(); i++) {
|
|
||||||
QStandardItem *item = DLListModel->item(i);
|
|
||||||
QModelIndex index = DLListModel->indexFromItem(item);
|
|
||||||
if (ui.downloadList->isExpanded(index)) {
|
|
||||||
std::string id = getID(i, DLListModel).toStdString();
|
|
||||||
expandedIds.push_back(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//remove all Items
|
|
||||||
for(int i = DLListModel->rowCount(); i >= 0; i--)
|
|
||||||
{
|
|
||||||
delItem(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = ULListModel->rowCount(); i >= 0; i--)
|
|
||||||
{
|
|
||||||
delUploadItem(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.downloadList->sortByColumn(_sortColDwl, _sortOrderDwl);
|
|
||||||
/* disable for performance issues, enable after insert all transfers */
|
|
||||||
ui.downloadList->setSortingEnabled(false);
|
|
||||||
|
|
||||||
/* get the download and upload lists */
|
|
||||||
std::list<std::string> downHashes;
|
std::list<std::string> downHashes;
|
||||||
std::list<std::string> upHashes;
|
|
||||||
|
|
||||||
rsFiles->FileDownloads(downHashes);
|
rsFiles->FileDownloads(downHashes);
|
||||||
rsFiles->FileUploads(upHashes);
|
|
||||||
|
|
||||||
uint32_t dlCount = 0;
|
std::list<DwlDetails> dwlDetails;
|
||||||
uint32_t ulCount = 0;
|
rsFiles->getDwlDetails(dwlDetails);
|
||||||
|
|
||||||
|
//first clean the model in case some files are not download anymore
|
||||||
|
//remove items that are not fiends anymore
|
||||||
|
int removeIndex = 0;
|
||||||
|
while (removeIndex < DLListModel->rowCount()) {
|
||||||
|
std::string hash = DLListModel->item(removeIndex, ID)->data(Qt::EditRole).toString().toStdString();
|
||||||
|
std::list<std::string>::iterator downHashesIt;
|
||||||
|
bool found = false;
|
||||||
|
for (downHashesIt = downHashes.begin(); downHashesIt != downHashes.end(); downHashesIt++) {
|
||||||
|
if (hash == *downHashesIt) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
//look in the queued files
|
||||||
|
std::list<DwlDetails>::iterator dwlDetailsIt;
|
||||||
|
for (dwlDetailsIt = dwlDetails.begin(); dwlDetailsIt != dwlDetails.end(); dwlDetailsIt++) {
|
||||||
|
if (hash == dwlDetailsIt->hash) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
DLListModel->takeRow(removeIndex);
|
||||||
|
} else {
|
||||||
|
removeIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
for (it = downHashes.begin(); it != downHashes.end(); it++)
|
for (it = downHashes.begin(); it != downHashes.end(); it++) {
|
||||||
{
|
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) {
|
||||||
//if file transfer is a cache file index file, don't show it
|
//if file transfer is a cache file index file, don't show it
|
||||||
//
|
|
||||||
if (/*(!_show_cache_transfers) &&*/ (info.flags & CB_CODE_CACHE))
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
symbol = "";
|
if ((info.flags & CB_CODE_CACHE)) {
|
||||||
name = QString::fromUtf8(info.fname.c_str());
|
/*(!_show_cache_transfers) &&*/
|
||||||
coreId = QString::fromStdString(info.hash);
|
continue;
|
||||||
fileSize = info.size;
|
}
|
||||||
progress = (info.transfered * 100.0) / info.size;
|
|
||||||
dlspeed = info.tfRate * 1024.0;
|
|
||||||
|
|
||||||
/* get number of online peers */
|
QString fileName = QString::fromUtf8(info.fname.c_str());
|
||||||
|
QString fileHash = QString::fromStdString(info.hash);
|
||||||
|
qlonglong fileSize = info.size;
|
||||||
|
double fileProgress = (info.transfered * 100.0) / info.size;
|
||||||
|
double fileDlspeed = info.tfRate * 1024.0;
|
||||||
|
|
||||||
|
/* get the sources (number of online peers) */
|
||||||
int online = 0;
|
int online = 0;
|
||||||
std::list<TransferInfo>::iterator pit;
|
std::list<TransferInfo>::iterator pit;
|
||||||
for (pit = info.peers.begin(); pit != info.peers.end(); pit++) {
|
for (pit = info.peers.begin(); pit != info.peers.end(); pit++) {
|
||||||
@ -792,41 +708,28 @@ void TransfersDialog::insertTransfers()
|
|||||||
online++;
|
online++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QString sources = QString("%1 (%2)").arg(online).arg(info.peers.size() - online);
|
||||||
|
|
||||||
sources = QString("%1 (%2)").arg(online).arg(info.peers.size() - online);
|
QString status;
|
||||||
|
|
||||||
switch (info.downloadStatus) {
|
switch (info.downloadStatus) {
|
||||||
case FT_STATE_FAILED:
|
case FT_STATE_FAILED: status = tr("Failed"); break;
|
||||||
status = tr("Failed"); break;
|
case FT_STATE_OKAY: status = tr("Okay"); break;
|
||||||
case FT_STATE_OKAY:
|
case FT_STATE_WAITING: status = tr("Waiting"); break;
|
||||||
status = tr("Okay"); break;
|
case FT_STATE_DOWNLOADING: status = tr("Downloading"); break;
|
||||||
case FT_STATE_WAITING:
|
case FT_STATE_COMPLETE: status = tr("Complete"); break;
|
||||||
status = tr("Waiting"); break;
|
default: status = tr("Unknown"); break;
|
||||||
case FT_STATE_DOWNLOADING:
|
|
||||||
status = tr("Downloading"); break;
|
|
||||||
case FT_STATE_COMPLETE:
|
|
||||||
status = tr("Complete"); break;
|
|
||||||
default:
|
|
||||||
status = tr("Unknown"); break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString priority;
|
||||||
switch (info.priority) {
|
switch (info.priority) {
|
||||||
case SPEED_LOW:
|
case SPEED_LOW: priority = tr("Slower");break;
|
||||||
priority = tr("Slower");
|
case SPEED_NORMAL: priority = tr("Average");break;
|
||||||
break;
|
case SPEED_HIGH: priority = tr("Faster");break;
|
||||||
case SPEED_NORMAL:
|
default: priority = tr("Average");break;
|
||||||
priority = tr("Average");
|
|
||||||
break;
|
|
||||||
case SPEED_HIGH:
|
|
||||||
priority = tr("Faster");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
priority = tr("Average");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completed = info.transfered;
|
qlonglong completed = info.transfered;
|
||||||
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
qlonglong remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
||||||
|
|
||||||
FileChunksInfo fcinfo ;
|
FileChunksInfo fcinfo ;
|
||||||
if(!rsFiles->FileDownloadChunksDetails(*it,fcinfo))
|
if(!rsFiles->FileDownloadChunksDetails(*it,fcinfo))
|
||||||
@ -838,24 +741,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
pinfo.progress = completed*100.0/info.size ;
|
pinfo.progress = completed*100.0/info.size ;
|
||||||
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:fcinfo.chunks.size() ;
|
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:fcinfo.chunks.size() ;
|
||||||
|
|
||||||
int addedRow = addItem(symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, priority, completed, remaining);
|
int addedRow = addItem("", fileName, fileHash, fileSize, pinfo, fileDlspeed, sources, status, priority, completed, remaining);
|
||||||
|
|
||||||
/* if found in selectedIds -> select again */
|
|
||||||
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash)) {
|
|
||||||
selection->select(DLListModel->index(dlCount, NAME),
|
|
||||||
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
|
||||||
if (!firstSelIdx.isValid())
|
|
||||||
firstSelIdx = DLListModel->index(dlCount, NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* expand last expanded items */
|
|
||||||
if (expandedIds.end() != std::find(expandedIds.begin(), expandedIds.end(), info.hash)) {
|
|
||||||
QStandardItem *item = DLListModel->item(dlCount);
|
|
||||||
QModelIndex index = DLListModel->indexFromItem(item);
|
|
||||||
ui.downloadList->setExpanded(index, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
dlCount++;
|
|
||||||
|
|
||||||
/* continue to next download item if no peers to add */
|
/* continue to next download item if no peers to add */
|
||||||
if (!info.peers.size()) continue;
|
if (!info.peers.size()) continue;
|
||||||
@ -864,179 +750,128 @@ void TransfersDialog::insertTransfers()
|
|||||||
std::map<std::string, std::string> versions;
|
std::map<std::string, std::string> versions;
|
||||||
bool retv = rsDisc->getDiscVersions(versions);
|
bool retv = rsDisc->getDiscVersions(versions);
|
||||||
|
|
||||||
int dlPeers = 0;
|
|
||||||
for (pit = info.peers.begin(); pit != info.peers.end(); pit++) {
|
for (pit = info.peers.begin(); pit != info.peers.end(); pit++) {
|
||||||
symbol = "";
|
QString peerName = getPeerName(pit->peerId);
|
||||||
name = getPeerName(pit->peerId);
|
//unique combination: fileHash + peerId, variant: hash + peerName (too long)
|
||||||
//unique combination: fileName + peerName, variant: hash + peerName (too long)
|
QString hashFileAndPeerId = fileHash + QString::fromStdString(pit->peerId);
|
||||||
coreId = QString::fromStdString(info.fname) + getPeerName(pit->peerId);
|
QString version;
|
||||||
fileSize = info.size;
|
|
||||||
progress = (info.transfered * 100.0) / info.size;
|
|
||||||
sources = "";
|
|
||||||
if (retv && versions.end() != (vit = versions.find(pit->peerId))) {
|
if (retv && versions.end() != (vit = versions.find(pit->peerId))) {
|
||||||
sources = QString("rShare v") + QString::fromStdString(vit->second);
|
version = tr("version: ") + QString::fromStdString(vit->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pit->status == FT_STATE_COMPLETE) {
|
QString status;
|
||||||
status = tr("Complete");
|
|
||||||
} else {
|
|
||||||
status = tr("Unknown");
|
|
||||||
switch (pit->status) {
|
switch (pit->status) {
|
||||||
case FT_STATE_FAILED:
|
case FT_STATE_FAILED: status = tr("Failed"); break;
|
||||||
status = tr("Failed"); break;
|
case FT_STATE_OKAY: status = tr("Okay"); break;
|
||||||
case FT_STATE_OKAY:
|
case FT_STATE_WAITING: status = tr(""); break;
|
||||||
status = tr("Okay"); break;
|
case FT_STATE_DOWNLOADING: status = tr("Downloading"); break;
|
||||||
case FT_STATE_WAITING:
|
case FT_STATE_COMPLETE: status = tr("Complete"); break;
|
||||||
status = tr("Waiting"); break;
|
default: status = tr(""); break;
|
||||||
case FT_STATE_DOWNLOADING:
|
|
||||||
status = tr("Downloading"); break;
|
|
||||||
case FT_STATE_COMPLETE:
|
|
||||||
status = tr("Complete"); break;
|
|
||||||
}
|
}
|
||||||
|
double peerDlspeed = 0;
|
||||||
|
if (pit->status == FT_STATE_DOWNLOADING) {
|
||||||
|
peerDlspeed = pit->tfRate * 1024.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dlspeed = 0;
|
// FileProgressInfo peerpinfo ;
|
||||||
if (status == "Downloading")
|
// peerpinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ;
|
||||||
dlspeed = pit->tfRate * 1024.0;
|
// peerpinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId];
|
||||||
|
// peerpinfo.progress = 0.0 ; // we don't display completion for sources.
|
||||||
|
// peerpinfo.nb_chunks = peerpinfo.cmap._map.empty()?0:fcinfo.chunks.size();
|
||||||
|
|
||||||
completed = info.transfered;
|
addPeerToItem(addedRow, peerName, hashFileAndPeerId, peerDlspeed, status);
|
||||||
remaining = (info.size - info.transfered) / (pit->tfRate * 1024.0);
|
|
||||||
|
|
||||||
FileProgressInfo pinfo ;
|
|
||||||
pinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ;
|
|
||||||
pinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId] ;
|
|
||||||
pinfo.progress = 0.0 ; // we don't display completion for sources.
|
|
||||||
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:fcinfo.chunks.size() ;
|
|
||||||
|
|
||||||
if (!addPeerToItem(addedRow, symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, completed, remaining))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* if peers found in selectedIds, select again */
|
|
||||||
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.fname + getPeerName(pit->peerId).toStdString())) {
|
|
||||||
QStandardItem *dlItem = DLListModel->item(addedRow);
|
|
||||||
QModelIndex childIndex = DLListModel->indexFromItem(dlItem).child(dlPeers, 0);
|
|
||||||
selection->select(childIndex, QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
|
||||||
}
|
|
||||||
dlPeers++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* here i will insert files from the download queue - which are
|
/* here i will insert files from the download queue - which are
|
||||||
* not started yet and can't be find in FileDownloads
|
* not started yet and can't be find in FileDownloads
|
||||||
* */
|
* */
|
||||||
std::list<DwlDetails> details;
|
|
||||||
std::list<DwlDetails>::iterator dit;
|
std::list<DwlDetails>::iterator dit;
|
||||||
rsFiles->getDwlDetails(details);
|
for (dit = dwlDetails.begin(); dit != dwlDetails.end(); dit ++)
|
||||||
for (dit = details.begin(); dit != details.end(); dit ++)
|
|
||||||
{
|
{
|
||||||
name = QString::fromUtf8(dit->fname.c_str());
|
// switch (dit->priority) {
|
||||||
coreId = QString::fromStdString(dit->hash);
|
// case 0: priority = tr("Low"); break;
|
||||||
fileSize = dit->count;
|
// case 1: priority = tr("Normal"); break;
|
||||||
progress = 0;
|
// case 2: priority = tr("High"); break;
|
||||||
dlspeed = 0;
|
// case 3: priority = tr("Auto"); break;
|
||||||
sources = "";
|
// default: priority = tr("Auto"); break;
|
||||||
completed = 0;
|
// }
|
||||||
status = tr("Queued");
|
|
||||||
remaining = 0;
|
|
||||||
|
|
||||||
switch (dit->priority) {
|
|
||||||
case 0:
|
|
||||||
priority = tr("Low");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
priority = tr("Normal");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
priority = tr("High");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
priority = tr("Auto");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
priority = tr("Auto");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileProgressInfo pinfo ;
|
FileProgressInfo pinfo ;
|
||||||
pinfo.progress = 0.0 ;
|
pinfo.progress = 0.0 ;
|
||||||
pinfo.nb_chunks = 0 ;
|
pinfo.nb_chunks = 0 ;
|
||||||
|
|
||||||
addItem("", name, coreId, fileSize, pinfo, dlspeed, sources, status, priority, completed, remaining);
|
addItem("", QString::fromUtf8(dit->fname.c_str()),
|
||||||
|
QString::fromStdString(dit->hash), dit->count, pinfo, 0, 0,
|
||||||
/* if found in selectedIds -> select again */
|
tr("Queued"), "", 0, 0);
|
||||||
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), dit->hash)) {
|
|
||||||
selection->select(DLListModel->index(dlCount, NAME),
|
|
||||||
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
|
||||||
if (!firstSelIdx.isValid())
|
|
||||||
firstSelIdx = DLListModel->index(dlCount, NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dlCount++;
|
|
||||||
|
std::list<std::string> upHashes;
|
||||||
|
rsFiles->FileUploads(upHashes);
|
||||||
|
//first clean the model in case some files are not uploaded anymore
|
||||||
|
//remove items that are not fiends anymore
|
||||||
|
removeIndex = 0;
|
||||||
|
while (removeIndex < ULListModel->rowCount()) {
|
||||||
|
if (!ULListModel->item(removeIndex, UHASH)) {
|
||||||
|
removeIndex++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::string hash = ULListModel->item(removeIndex, UHASH)->data(Qt::EditRole).toString().toStdString();
|
||||||
|
std::list<std::string>::iterator upHashesIt;
|
||||||
|
bool found = false;
|
||||||
|
for (upHashesIt = upHashes.begin(); upHashesIt != upHashes.end(); upHashesIt++) {
|
||||||
|
if (hash == *upHashesIt) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
ULListModel->takeRow(removeIndex);
|
||||||
|
} else {
|
||||||
|
removeIndex++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scroll to first selected index if any */
|
for(it = upHashes.begin(); it != upHashes.end(); it++) {
|
||||||
if (firstSelIdx.isValid())
|
|
||||||
ui.downloadList->scrollTo(firstSelIdx);
|
|
||||||
|
|
||||||
ui.downloadList->setSortingEnabled(true);
|
|
||||||
|
|
||||||
ui.uploadsList->sortByColumn(_sortColUpl, _sortOrderUpl);
|
|
||||||
/* disable for performance issues, enable after insert all transfers */
|
|
||||||
ui.uploadsList->setSortingEnabled(false);
|
|
||||||
for(it = upHashes.begin(); it != upHashes.end(); it++)
|
|
||||||
{
|
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info))
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (/*(!_show_cache_transfers) &&*/ (info.flags & CB_CODE_CACHE))
|
if (/*(!_show_cache_transfers) &&*/ (info.flags & CB_CODE_CACHE))
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
std::list<TransferInfo>::iterator pit;
|
std::list<TransferInfo>::iterator pit;
|
||||||
for(pit = info.peers.begin(); pit != info.peers.end(); pit++)
|
for(pit = info.peers.begin(); pit != info.peers.end(); pit++) {
|
||||||
{
|
if (pit->peerId == rsPeers->getOwnId()) //don't display transfer to ourselves
|
||||||
symbol = "";
|
continue ;
|
||||||
coreId = QString::fromStdString(info.hash);
|
|
||||||
name = QString::fromUtf8(info.fname.c_str());
|
|
||||||
sources = getPeerName(pit->peerId);
|
|
||||||
|
|
||||||
|
QString fileHash = QString::fromStdString(info.hash);
|
||||||
|
QString fileName = QString::fromUtf8(info.fname.c_str());
|
||||||
|
QString sources = getPeerName(pit->peerId);
|
||||||
|
|
||||||
|
QString status;
|
||||||
switch(pit->status)
|
switch(pit->status)
|
||||||
{
|
{
|
||||||
case FT_STATE_FAILED:
|
case FT_STATE_FAILED: status = tr("Failed"); break;
|
||||||
status = tr("Failed");
|
case FT_STATE_OKAY: status = tr("Okay"); break;
|
||||||
break;
|
case FT_STATE_WAITING: status = tr("Waiting"); break;
|
||||||
case FT_STATE_OKAY:
|
case FT_STATE_DOWNLOADING: status = tr("Uploading"); break;
|
||||||
status = tr("Okay");
|
case FT_STATE_COMPLETE: status = tr("Complete"); break;
|
||||||
break;
|
default: status = tr("Complete"); break;
|
||||||
case FT_STATE_WAITING:
|
|
||||||
status = tr("Waiting");
|
|
||||||
break;
|
|
||||||
case FT_STATE_DOWNLOADING:
|
|
||||||
status = tr("Uploading");
|
|
||||||
break;
|
|
||||||
case FT_STATE_COMPLETE:
|
|
||||||
default:
|
|
||||||
status = tr("Complete");
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (info.downloadStatus == FT_STATE_COMPLETE)
|
|
||||||
// {
|
|
||||||
// status = "Complete";
|
|
||||||
// }
|
|
||||||
|
|
||||||
FileProgressInfo pinfo ;
|
FileProgressInfo pinfo ;
|
||||||
|
|
||||||
if(!rsFiles->FileUploadChunksDetails(*it,pit->peerId,pinfo.cmap) )
|
if(!rsFiles->FileUploadChunksDetails(*it,pit->peerId,pinfo.cmap) )
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
dlspeed = pit->tfRate * 1024.0;
|
double dlspeed = pit->tfRate * 1024.0;
|
||||||
fileSize = info.size;
|
qlonglong fileSize = info.size;
|
||||||
completed = info.transfered;
|
double completed = info.transfered;
|
||||||
progress = info.transfered * 100.0 / info.size;
|
double progress = info.transfered * 100.0 / info.size;
|
||||||
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
qlonglong remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
||||||
|
|
||||||
// Estimate the completion. We need something more accurate, meaning that we need to
|
// Estimate the completion. We need something more accurate, meaning that we need to
|
||||||
// transmit the completion info.
|
// transmit the completion info.
|
||||||
@ -1049,51 +884,38 @@ void TransfersDialog::insertTransfers()
|
|||||||
uint32_t filled_chunks = pinfo.cmap.filledChunks(nb_chunks) ;
|
uint32_t filled_chunks = pinfo.cmap.filledChunks(nb_chunks) ;
|
||||||
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:nb_chunks ;
|
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:nb_chunks ;
|
||||||
|
|
||||||
if(filled_chunks > 1)
|
if(filled_chunks > 1) {
|
||||||
{
|
|
||||||
pinfo.progress = filled_chunks*100.0/nb_chunks ;
|
pinfo.progress = filled_chunks*100.0/nb_chunks ;
|
||||||
completed = std::min(info.size,((uint64_t)filled_chunks)*chunk_size) ;
|
completed = std::min(info.size,((uint64_t)filled_chunks)*chunk_size) ;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
pinfo.progress = progress ;
|
pinfo.progress = progress ;
|
||||||
|
|
||||||
addUploadItem(symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, completed, remaining);
|
|
||||||
ulCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.peers.size() == 0)
|
addUploadItem("", fileName, fileHash, fileSize, pinfo, dlspeed, sources, status, completed, remaining);
|
||||||
{
|
}
|
||||||
symbol = "";
|
|
||||||
coreId = QString::fromStdString(info.hash);
|
|
||||||
name = QString::fromUtf8(info.fname.c_str());
|
|
||||||
sources = tr("Unknown");
|
|
||||||
|
|
||||||
|
if (info.peers.size() == 0) { //it has not been added (maybe only turtle tunnels
|
||||||
|
QString fileHash = QString::fromStdString(info.hash);
|
||||||
|
QString fileName = QString::fromUtf8(info.fname.c_str());
|
||||||
|
QString sources = tr("");
|
||||||
|
|
||||||
|
QString status;
|
||||||
switch(info.downloadStatus)
|
switch(info.downloadStatus)
|
||||||
{
|
{
|
||||||
case FT_STATE_FAILED:
|
case FT_STATE_FAILED: status = tr("Failed"); break;
|
||||||
status = tr("Failed");
|
case FT_STATE_OKAY: status = tr("Okay"); break;
|
||||||
break;
|
case FT_STATE_WAITING: status = tr("Waiting"); break;
|
||||||
case FT_STATE_OKAY:
|
case FT_STATE_DOWNLOADING: status = tr("Uploading");break;
|
||||||
status = tr("Okay");
|
case FT_STATE_COMPLETE:status = tr("Complete"); break;
|
||||||
break;
|
default: status = tr("Complete"); break;
|
||||||
case FT_STATE_WAITING:
|
|
||||||
status = tr("Waiting");
|
|
||||||
break;
|
|
||||||
case FT_STATE_DOWNLOADING:
|
|
||||||
status = tr("Uploading");
|
|
||||||
break;
|
|
||||||
case FT_STATE_COMPLETE:
|
|
||||||
default:
|
|
||||||
status = tr("Complete");
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dlspeed = info.tfRate * 1024.0;
|
double dlspeed = info.tfRate * 1024.0;
|
||||||
fileSize = info.size;
|
qlonglong fileSize = info.size;
|
||||||
completed = info.transfered;
|
double completed = info.transfered;
|
||||||
progress = info.transfered * 100.0 / info.size;
|
double progress = info.transfered * 100.0 / info.size;
|
||||||
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
qlonglong remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
||||||
|
|
||||||
FileProgressInfo pinfo ;
|
FileProgressInfo pinfo ;
|
||||||
pinfo.progress = progress ;
|
pinfo.progress = progress ;
|
||||||
@ -1101,12 +923,9 @@ void TransfersDialog::insertTransfers()
|
|||||||
pinfo.type = FileProgressInfo::DOWNLOAD_LINE ;
|
pinfo.type = FileProgressInfo::DOWNLOAD_LINE ;
|
||||||
pinfo.nb_chunks = 0 ;
|
pinfo.nb_chunks = 0 ;
|
||||||
|
|
||||||
addUploadItem(symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, completed, remaining);
|
addUploadItem("", fileName, fileHash, fileSize, pinfo, dlspeed, sources, status, completed, remaining);
|
||||||
ulCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.uploadsList->setSortingEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TransfersDialog::getPeerName(const std::string& id) const
|
QString TransfersDialog::getPeerName(const std::string& id) const
|
||||||
@ -1565,28 +1384,6 @@ void TransfersDialog::clearcompleted()
|
|||||||
rsFiles->FileClearCompleted();
|
rsFiles->FileClearCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::rootdecorated()
|
|
||||||
{
|
|
||||||
ui.downloadList->setRootIsDecorated(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransfersDialog::rootisnotdecorated()
|
|
||||||
{
|
|
||||||
ui.downloadList->setRootIsDecorated(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransfersDialog::saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order)
|
|
||||||
{
|
|
||||||
_sortColDwl = logicalIndex;;
|
|
||||||
_sortOrderDwl = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransfersDialog::saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order)
|
|
||||||
{
|
|
||||||
_sortColUpl = logicalIndex;;
|
|
||||||
_sortOrderUpl = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransfersDialog::showFileDetails()
|
void TransfersDialog::showFileDetails()
|
||||||
{
|
{
|
||||||
std::string file_hash ;
|
std::string file_hash ;
|
||||||
|
@ -46,9 +46,9 @@ class QStandardItemModel;
|
|||||||
|
|
||||||
class TransfersDialog : public RsAutoUpdatePage
|
class TransfersDialog : public RsAutoUpdatePage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
TransfersDialog(QWidget *parent = 0);
|
TransfersDialog(QWidget *parent = 0);
|
||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
@ -62,7 +62,7 @@ class TransfersDialog : public RsAutoUpdatePage
|
|||||||
|
|
||||||
void handleDownloadRequest(const QString& url);
|
void handleDownloadRequest(const QString& url);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
/** Create the context popup menu and it's submenus */
|
/** Create the context popup menu and it's submenus */
|
||||||
void downloadListCostumPopupMenu( QPoint point );
|
void downloadListCostumPopupMenu( QPoint point );
|
||||||
@ -75,8 +75,8 @@ class TransfersDialog : public RsAutoUpdatePage
|
|||||||
void copyLink();
|
void copyLink();
|
||||||
void pasteLink();
|
void pasteLink();
|
||||||
|
|
||||||
void rootdecorated();
|
// void rootdecorated();
|
||||||
void rootisnotdecorated();
|
// void rootisnotdecorated();
|
||||||
|
|
||||||
void pauseFileTransfer();
|
void pauseFileTransfer();
|
||||||
void resumeFileTransfer();
|
void resumeFileTransfer();
|
||||||
@ -104,15 +104,15 @@ class TransfersDialog : public RsAutoUpdatePage
|
|||||||
void chunkStreaming();
|
void chunkStreaming();
|
||||||
|
|
||||||
/** save sort indicators for next transfers display */
|
/** save sort indicators for next transfers display */
|
||||||
void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
|
// void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
|
||||||
void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
|
// void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
|
||||||
|
|
||||||
void showDetailsDialog();
|
void showDetailsDialog();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void playFiles(QStringList files);
|
void playFiles(QStringList files);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getPeerName(const std::string& peer_id) const ;
|
QString getPeerName(const std::string& peer_id) const ;
|
||||||
|
|
||||||
QStandardItemModel *DLListModel;
|
QStandardItemModel *DLListModel;
|
||||||
@ -122,14 +122,9 @@ class TransfersDialog : public RsAutoUpdatePage
|
|||||||
|
|
||||||
DLListDelegate *DLDelegate;
|
DLListDelegate *DLDelegate;
|
||||||
ULListDelegate *ULDelegate;
|
ULListDelegate *ULDelegate;
|
||||||
qlonglong fileSize;
|
|
||||||
double progress;
|
|
||||||
double dlspeed;
|
|
||||||
QString status, icon, name;
|
|
||||||
qlonglong completed, remaining;
|
|
||||||
|
|
||||||
int _sortColDwl, _sortColUpl;
|
// int _sortColDwl, _sortColUpl;
|
||||||
Qt::SortOrder _sortOrderDwl, _sortOrderUpl;
|
// Qt::SortOrder _sortOrderDwl, _sortOrderUpl;
|
||||||
|
|
||||||
/** Create the actions on the tray menu or menubar */
|
/** Create the actions on the tray menu or menubar */
|
||||||
void createActions();
|
void createActions();
|
||||||
@ -176,16 +171,14 @@ class TransfersDialog : public RsAutoUpdatePage
|
|||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::TransfersDialog ui;
|
Ui::TransfersDialog ui;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
int addItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining);
|
int addItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining);
|
||||||
bool addPeerToItem(int row, const QString& symbol, const QString& name, const QString& coreID, qlonglong fileSize, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, qlonglong completed, qlonglong remaining);
|
bool addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, const QString& status);
|
||||||
void delItem(int row);
|
void delItem(int row);
|
||||||
|
|
||||||
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, qlonglong completed, qlonglong remaining);
|
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, qlonglong completed, qlonglong remaining);
|
||||||
void delUploadItem(int row);
|
void delUploadItem(int row);
|
||||||
|
|
||||||
void editItem(int row, int column, QVariant data);
|
|
||||||
void updateProgress(int value);
|
|
||||||
void showFileDetails() ;
|
void showFileDetails() ;
|
||||||
|
|
||||||
double getProgress(int row, QStandardItemModel *model);
|
double getProgress(int row, QStandardItemModel *model);
|
||||||
|
@ -644,7 +644,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="rootIsDecorated">
|
<property name="rootIsDecorated">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -652,6 +652,15 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="allColumnsShowFocus">
|
<property name="allColumnsShowFocus">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="headerStretchLastSection">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="headerStretchLastSection">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -727,8 +736,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>596</width>
|
<width>598</width>
|
||||||
<height>102</height>
|
<height>99</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@ -834,8 +843,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>578</width>
|
<width>98</width>
|
||||||
<height>117</height>
|
<height>28</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@ -850,7 +859,6 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="images.qrc"/>
|
<include location="images.qrc"/>
|
||||||
<include location="../../../../../../../.designer/backup/images.qrc"/>
|
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -82,8 +82,8 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case USIZE:
|
case USIZE:
|
||||||
fileSize = index.data().toLongLong();
|
fileSize = index.data().toLongLong();
|
||||||
if(fileSize < 0){
|
if(fileSize <= 0){
|
||||||
temp = "Unknown";
|
temp = "";
|
||||||
} else {
|
} else {
|
||||||
multi = 1.0;
|
multi = 1.0;
|
||||||
for(int i = 0; i < 5; ++i) {
|
for(int i = 0; i < 5; ++i) {
|
||||||
@ -101,8 +101,8 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
break;
|
break;
|
||||||
case UTRANSFERRED:
|
case UTRANSFERRED:
|
||||||
transferred = index.data().toLongLong();
|
transferred = index.data().toLongLong();
|
||||||
if(transferred < 0){
|
if(transferred <= 0){
|
||||||
temp = "Unknown";
|
temp = "";
|
||||||
} else {
|
} else {
|
||||||
multi = 1.0;
|
multi = 1.0;
|
||||||
for(int i = 0; i < 5; ++i) {
|
for(int i = 0; i < 5; ++i) {
|
||||||
@ -120,9 +120,13 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
break;
|
break;
|
||||||
case ULSPEED:
|
case ULSPEED:
|
||||||
ulspeed = index.data().toDouble();
|
ulspeed = index.data().toDouble();
|
||||||
|
if (ulspeed <= 0) {
|
||||||
|
temp = "";
|
||||||
|
} else {
|
||||||
temp.clear();
|
temp.clear();
|
||||||
temp.sprintf("%.2f", ulspeed/1024.);
|
temp.sprintf("%.2f", ulspeed/1024.);
|
||||||
temp += " KB/s";
|
temp += " KB/s";
|
||||||
|
}
|
||||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||||
break;
|
break;
|
||||||
case UPROGRESS:
|
case UPROGRESS:
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#define UPROGRESS 4
|
#define UPROGRESS 4
|
||||||
#define USTATUS 5
|
#define USTATUS 5
|
||||||
#define USERNAME 6
|
#define USERNAME 6
|
||||||
|
#define UHASH 7
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user