2008-12-12 16:42:44 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006,2007 crypton
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2009-05-20 18:06:20 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2008-12-12 16:42:44 -05:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
2009-07-31 09:12:46 -04:00
|
|
|
#ifdef WIN32
|
2009-09-05 14:15:23 -04:00
|
|
|
#include <windows.h>
|
2009-07-31 09:12:46 -04:00
|
|
|
#endif
|
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
#include <set>
|
2008-12-12 16:42:44 -05:00
|
|
|
|
|
|
|
#include "rshare.h"
|
|
|
|
#include "TransfersDialog.h"
|
2010-03-10 16:38:26 -05:00
|
|
|
#include "RetroShareLink.h"
|
2010-01-05 19:10:15 -05:00
|
|
|
#include "DetailsDialog.h"
|
2008-12-12 16:42:44 -05:00
|
|
|
#include "DLListDelegate.h"
|
|
|
|
#include "ULListDelegate.h"
|
2009-11-17 07:45:06 -05:00
|
|
|
#include "FileTransferInfoWidget.h"
|
2010-02-14 04:06:37 -05:00
|
|
|
#include "TurtleRouterDialog.h"
|
2010-01-11 11:00:42 -05:00
|
|
|
#include "xprogressbar.h"
|
2008-12-12 16:42:44 -05:00
|
|
|
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QCursor>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QStandardItemModel>
|
2009-07-02 14:40:31 -04:00
|
|
|
#include <QUrl>
|
2008-12-12 16:42:44 -05:00
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include "rsiface/rsfiles.h"
|
|
|
|
#include "rsiface/rspeers.h"
|
2009-06-28 16:57:02 -04:00
|
|
|
#include "rsiface/rsdisc.h"
|
2009-07-28 06:21:19 -04:00
|
|
|
#include "rsiface/rstypes.h"
|
2008-11-02 10:20:42 -05:00
|
|
|
#include <algorithm>
|
2009-07-05 12:27:58 -04:00
|
|
|
#include "util/misc.h"
|
2008-12-12 16:42:44 -05:00
|
|
|
|
|
|
|
/* Images for context menu icons */
|
|
|
|
#define IMAGE_INFO ":/images/fileinfo.png"
|
|
|
|
#define IMAGE_CANCEL ":/images/delete.png"
|
|
|
|
#define IMAGE_CLEARCOMPLETED ":/images/deleteall.png"
|
2009-05-18 10:23:55 -04:00
|
|
|
#define IMAGE_PLAY ":/images/player_play.png"
|
|
|
|
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
|
|
|
#define IMAGE_PASTELINK ":/images/pasterslink.png"
|
2009-07-02 19:47:38 -04:00
|
|
|
#define IMAGE_PAUSE ":/images/pause.png"
|
|
|
|
#define IMAGE_RESUME ":/images/resume.png"
|
|
|
|
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
|
|
|
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
|
|
|
#define IMAGE_STOP ":/images/stop.png"
|
2009-07-04 19:36:04 -04:00
|
|
|
#define IMAGE_PREVIEW ":/images/preview.png"
|
2009-07-27 07:57:58 -04:00
|
|
|
#define IMAGE_PRIORITY ":/images/filepriority.png"
|
|
|
|
#define IMAGE_PRIORITYLOW ":/images/prioritylow.png"
|
|
|
|
#define IMAGE_PRIORITYNORMAL ":/images/prioritynormal.png"
|
|
|
|
#define IMAGE_PRIORITYHIGH ":/images/priorityhigh.png"
|
|
|
|
#define IMAGE_PRIORITYAUTO ":/images/priorityauto.png"
|
2009-07-04 19:36:04 -04:00
|
|
|
|
2010-01-11 11:00:42 -05:00
|
|
|
Q_DECLARE_METATYPE(FileProgressInfo)
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
/** Constructor */
|
|
|
|
TransfersDialog::TransfersDialog(QWidget *parent)
|
2009-11-17 07:45:06 -05:00
|
|
|
: RsAutoUpdatePage(1000,parent)
|
2008-12-12 16:42:44 -05:00
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
connect( ui.downloadList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( downloadListCostumPopupMenu( QPoint ) ) );
|
|
|
|
|
|
|
|
// Set Download list model
|
2009-08-11 16:27:59 -04:00
|
|
|
DLListModel = new QStandardItemModel(0,ID + 1);
|
2008-12-12 16:42:44 -05:00
|
|
|
DLListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
|
|
|
DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
|
|
|
DLListModel->setHeaderData(COMPLETED, Qt::Horizontal, tr("Completed", ""));
|
|
|
|
DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("Speed", "i.e: Download speed"));
|
2010-01-26 18:25:00 -05:00
|
|
|
DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress / Availability", "i.e: % downloaded"));
|
2008-12-12 16:42:44 -05:00
|
|
|
DLListModel->setHeaderData(SOURCES, Qt::Horizontal, tr("Sources", "i.e: Sources"));
|
|
|
|
DLListModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status"));
|
2010-03-06 18:29:47 -05:00
|
|
|
DLListModel->setHeaderData(PRIORITY, Qt::Horizontal, tr("Speed / Queue position"));
|
2010-03-01 17:47:48 -05:00
|
|
|
DLListModel->setHeaderData(REMAINING, Qt::Horizontal, tr("Remaining"));
|
|
|
|
DLListModel->setHeaderData(DOWNLOADTIME, Qt::Horizontal, tr("Download time", "i.e: Estimated Time of Arrival / Time left"));
|
2008-12-12 16:42:44 -05:00
|
|
|
DLListModel->setHeaderData(ID, Qt::Horizontal, tr("Core-ID"));
|
|
|
|
ui.downloadList->setModel(DLListModel);
|
2009-05-07 18:40:57 -04:00
|
|
|
ui.downloadList->hideColumn(ID);
|
2008-12-12 16:42:44 -05:00
|
|
|
DLDelegate = new DLListDelegate();
|
|
|
|
ui.downloadList->setItemDelegate(DLDelegate);
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2009-05-07 18:40:57 -04:00
|
|
|
ui.downloadList->setAutoScroll(false) ;
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
//Selection Setup
|
2009-05-07 18:40:57 -04:00
|
|
|
selection = ui.downloadList->selectionModel();
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2009-05-07 18:40:57 -04:00
|
|
|
ui.downloadList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
|
2009-05-20 18:06:20 -04:00
|
|
|
ui.downloadList->setRootIsDecorated(true);
|
|
|
|
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
/* Set header resize modes and initial section sizes Downloads TreeView*/
|
2009-05-07 18:40:57 -04:00
|
|
|
QHeaderView * _header = ui.downloadList->header () ;
|
2009-05-20 18:06:20 -04:00
|
|
|
_header->setResizeMode (NAME, QHeaderView::Interactive);
|
|
|
|
_header->setResizeMode (SIZE, QHeaderView::Interactive);
|
|
|
|
_header->setResizeMode (COMPLETED, QHeaderView::Interactive);
|
|
|
|
_header->setResizeMode (DLSPEED, QHeaderView::Interactive);
|
|
|
|
_header->setResizeMode (PROGRESS, QHeaderView::Interactive);
|
|
|
|
_header->setResizeMode (SOURCES, QHeaderView::Interactive);
|
|
|
|
_header->setResizeMode (STATUS, QHeaderView::Interactive);
|
2009-08-11 16:27:59 -04:00
|
|
|
_header->setResizeMode (PRIORITY, QHeaderView::Interactive);
|
2009-05-20 18:06:20 -04:00
|
|
|
_header->setResizeMode (REMAINING, QHeaderView::Interactive);
|
|
|
|
|
|
|
|
_header->resizeSection ( NAME, 170 );
|
|
|
|
_header->resizeSection ( SIZE, 70 );
|
|
|
|
_header->resizeSection ( COMPLETED, 75 );
|
|
|
|
_header->resizeSection ( DLSPEED, 75 );
|
2009-05-07 18:40:57 -04:00
|
|
|
_header->resizeSection ( PROGRESS, 170 );
|
2009-05-20 18:06:20 -04:00
|
|
|
_header->resizeSection ( SOURCES, 90 );
|
|
|
|
_header->resizeSection ( STATUS, 100 );
|
2009-08-11 16:27:59 -04:00
|
|
|
_header->resizeSection ( PRIORITY, 100 );
|
2009-05-20 18:06:20 -04:00
|
|
|
_header->resizeSection ( REMAINING, 100 );
|
|
|
|
|
2009-05-07 18:40:57 -04:00
|
|
|
// Set Upload list model
|
2010-02-16 21:10:25 -05:00
|
|
|
ULListModel = new QStandardItemModel(0,8);
|
2008-12-12 16:42:44 -05:00
|
|
|
ULListModel->setHeaderData(UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
|
|
|
ULListModel->setHeaderData(USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
2009-07-24 18:39:34 -04:00
|
|
|
ULListModel->setHeaderData(USERNAME, Qt::Horizontal, tr("Peer", "i.e: user name"));
|
2008-12-12 16:42:44 -05:00
|
|
|
ULListModel->setHeaderData(UPROGRESS, Qt::Horizontal, tr("Progress", "i.e: % uploaded"));
|
|
|
|
ULListModel->setHeaderData(ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed"));
|
|
|
|
ULListModel->setHeaderData(USTATUS, Qt::Horizontal, tr("Status"));
|
|
|
|
ULListModel->setHeaderData(UTRANSFERRED, Qt::Horizontal, tr("Transferred", ""));
|
2010-02-16 21:10:25 -05:00
|
|
|
ULListModel->setHeaderData(UHASH, Qt::Horizontal, tr("Hash", ""));
|
2008-12-12 16:42:44 -05:00
|
|
|
ui.uploadsList->setModel(ULListModel);
|
|
|
|
ULDelegate = new ULListDelegate();
|
|
|
|
ui.uploadsList->setItemDelegate(ULDelegate);
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2009-05-07 18:40:57 -04:00
|
|
|
ui.uploadsList->setAutoScroll(false) ;
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
ui.uploadsList->setRootIsDecorated(false);
|
2009-05-20 18:06:20 -04:00
|
|
|
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
//Selection Setup
|
2009-07-24 19:28:20 -04:00
|
|
|
selectionup = ui.uploadsList->selectionModel();
|
2009-07-24 18:39:34 -04:00
|
|
|
ui.uploadsList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
|
|
|
|
/* Set header resize modes and initial section sizes Uploads TreeView*/
|
|
|
|
QHeaderView * upheader = ui.uploadsList->header () ;
|
|
|
|
upheader->setResizeMode (UNAME, QHeaderView::Interactive);
|
|
|
|
upheader->setResizeMode (USIZE, QHeaderView::Interactive);
|
2009-07-26 11:02:16 -04:00
|
|
|
upheader->setResizeMode (UTRANSFERRED, QHeaderView::Interactive);
|
|
|
|
upheader->setResizeMode (ULSPEED, QHeaderView::Interactive);
|
|
|
|
upheader->setResizeMode (UPROGRESS, QHeaderView::Interactive);
|
|
|
|
upheader->setResizeMode (USTATUS, QHeaderView::Interactive);
|
|
|
|
upheader->setResizeMode (USERNAME, QHeaderView::Interactive);
|
2009-07-24 18:39:34 -04:00
|
|
|
|
2009-07-26 11:02:16 -04:00
|
|
|
upheader->resizeSection ( UNAME, 170 );
|
2009-07-24 18:39:34 -04:00
|
|
|
upheader->resizeSection ( USIZE, 70 );
|
|
|
|
upheader->resizeSection ( UTRANSFERRED, 75 );
|
2009-07-26 11:02:16 -04:00
|
|
|
upheader->resizeSection ( ULSPEED, 75 );
|
|
|
|
upheader->resizeSection ( UPROGRESS, 170 );
|
|
|
|
upheader->resizeSection ( USTATUS, 100 );
|
|
|
|
upheader->resizeSection ( USERNAME, 75 );
|
|
|
|
|
2009-09-15 14:37:03 -04:00
|
|
|
connect(upheader, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSortIndicatorUpl(int, Qt::SortOrder)));
|
|
|
|
|
2009-11-17 07:45:06 -05:00
|
|
|
FileTransferInfoWidget *ftiw = new FileTransferInfoWidget();
|
|
|
|
ui.fileTransferInfoWidget->setWidget(ftiw);
|
|
|
|
ui.fileTransferInfoWidget->setWidgetResizable(true);
|
|
|
|
ui.fileTransferInfoWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
ui.fileTransferInfoWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
|
|
ui.fileTransferInfoWidget->viewport()->setBackgroundRole(QPalette::NoRole);
|
|
|
|
ui.fileTransferInfoWidget->setFrameStyle(QFrame::NoFrame);
|
|
|
|
ui.fileTransferInfoWidget->setFocusPolicy(Qt::NoFocus);
|
2009-09-15 14:37:03 -04:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
QObject::connect(ui.downloadList,SIGNAL(clicked(const QModelIndex&)),this,SLOT(showFileDetails())) ;
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-02-14 04:06:37 -05:00
|
|
|
TurtleRouterDialog *trdl = new TurtleRouterDialog();
|
|
|
|
ui.tunnelInfoWidget->setWidget(trdl);
|
|
|
|
ui.tunnelInfoWidget->setWidgetResizable(true);
|
|
|
|
ui.tunnelInfoWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
ui.tunnelInfoWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
|
|
ui.tunnelInfoWidget->viewport()->setBackgroundRole(QPalette::NoRole);
|
|
|
|
ui.tunnelInfoWidget->setFrameStyle(QFrame::NoFrame);
|
|
|
|
ui.tunnelInfoWidget->setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
|
|
|
#endif
|
2009-07-24 18:39:34 -04:00
|
|
|
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
|
|
|
|
2009-05-07 18:40:57 -04:00
|
|
|
void TransfersDialog::keyPressEvent(QKeyEvent *e)
|
|
|
|
{
|
|
|
|
if(e->key() == Qt::Key_Delete)
|
|
|
|
{
|
|
|
|
cancel() ;
|
|
|
|
e->accept() ;
|
|
|
|
}
|
|
|
|
else
|
2009-11-17 07:45:06 -05:00
|
|
|
RsAutoUpdatePage::keyPressEvent(e) ;
|
2009-05-07 18:40:57 -04:00
|
|
|
}
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|
|
|
{
|
2010-01-22 18:23:37 -05:00
|
|
|
QMenu contextMnu( this );
|
|
|
|
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
std::set<QStandardItem *> items;
|
|
|
|
std::set<QStandardItem *>::iterator it;
|
|
|
|
getIdOfSelectedItems(items);
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
bool single = (items.size() == 1) ;
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
/* check which item is selected
|
|
|
|
* - if it is completed - play should appear in menu
|
|
|
|
*/
|
2008-12-12 16:42:44 -05:00
|
|
|
std::cerr << "TransfersDialog::downloadListCostumPopupMenu()" << std::endl;
|
2010-02-19 20:52:44 -05:00
|
|
|
|
|
|
|
FileInfo info;
|
|
|
|
|
|
|
|
for (it = items.begin(); it != items.end(); it ++) {
|
|
|
|
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
|
|
|
break;
|
|
|
|
}
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2009-11-17 07:45:06 -05:00
|
|
|
bool addPlayOption = false;
|
2010-02-19 20:52:44 -05:00
|
|
|
bool addOpenFileOption = false;
|
2009-11-17 07:45:06 -05:00
|
|
|
|
2010-02-19 20:52:44 -05:00
|
|
|
if (info.downloadStatus == FT_STATE_COMPLETE)
|
|
|
|
{
|
|
|
|
std::cerr << "Add Play Option" << std::endl;
|
|
|
|
|
|
|
|
addOpenFileOption = true;
|
|
|
|
|
|
|
|
size_t pos = info.fname.find_last_of('.');
|
2010-03-07 09:10:51 -05:00
|
|
|
|
|
|
|
if (pos == std::string::npos) return; /* can't identify type of file */
|
2010-02-19 20:52:44 -05:00
|
|
|
|
|
|
|
/* check if the file is a media file */
|
|
|
|
if (misc::isPreviewable(info.fname.substr(pos + 1).c_str()))
|
|
|
|
{
|
|
|
|
addPlayOption = true;
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
2010-02-19 20:52:44 -05:00
|
|
|
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
2010-02-19 20:52:44 -05:00
|
|
|
|
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
QAction *playAct = NULL;
|
2008-12-12 16:42:44 -05:00
|
|
|
if (addPlayOption)
|
|
|
|
{
|
2010-01-22 18:23:37 -05:00
|
|
|
playAct = new QAction(QIcon(IMAGE_PLAY), tr( "Play" ), this );
|
2010-02-19 20:52:44 -05:00
|
|
|
connect( playAct , SIGNAL( triggered() ), this, SLOT( openTransfer() ) );
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
2010-01-22 18:23:37 -05:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
pauseAct = new QAction(QIcon(IMAGE_PAUSE), tr("Pause"), this);
|
|
|
|
connect(pauseAct, SIGNAL(triggered()), this, SLOT(pauseFileTransfer()));
|
2010-01-22 18:23:37 -05:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
resumeAct = new QAction(QIcon(IMAGE_RESUME), tr("Resume"), this);
|
|
|
|
connect(resumeAct, SIGNAL(triggered()), this, SLOT(resumeFileTransfer()));
|
2010-01-22 18:23:37 -05:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this );
|
|
|
|
connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) );
|
2010-01-22 18:23:37 -05:00
|
|
|
|
2010-02-19 20:52:44 -05:00
|
|
|
openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
|
|
|
|
connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openFolderTransfer()));
|
2010-01-22 18:23:37 -05:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
|
|
|
|
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openTransfer()));
|
2010-01-22 18:23:37 -05:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
previewfileAct = new QAction(QIcon(IMAGE_PREVIEW), tr("Preview File"), this);
|
|
|
|
connect(previewfileAct, SIGNAL(triggered()), this, SLOT(previewTransfer()));
|
2010-01-22 18:23:37 -05:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
detailsfileAct = new QAction(QIcon(IMAGE_INFO), tr("Details..."), this);
|
|
|
|
connect(detailsfileAct, SIGNAL(triggered()), this, SLOT(showDetailsDialog()));
|
2010-01-22 18:23:37 -05:00
|
|
|
|
|
|
|
clearcompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this );
|
|
|
|
connect( clearcompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) );
|
|
|
|
|
|
|
|
#ifndef RS_RELEASE_VERSION
|
|
|
|
copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
|
|
|
|
connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste retroshare Link" ), this );
|
|
|
|
connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
|
|
|
|
|
|
|
QMenu *viewMenu = new QMenu( tr("View"), this );
|
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
// clearQueueAct = new QAction(QIcon(), tr("Remove all queued"), this);
|
|
|
|
// connect(clearQueueAct, SIGNAL(triggered()), this, SLOT(clearQueue()));
|
2010-01-22 18:23:37 -05:00
|
|
|
|
2010-03-08 16:07:53 -05:00
|
|
|
queueDownAct = new QAction(QIcon(":/images/go-down.png"), tr("Down"), this);
|
|
|
|
connect(queueDownAct, SIGNAL(triggered()), this, SLOT(priorityQueueDown()));
|
|
|
|
queueUpAct = new QAction(QIcon(":/images/go-up.png"), tr("Up"), this);
|
|
|
|
connect(queueUpAct, SIGNAL(triggered()), this, SLOT(priorityQueueUp()));
|
|
|
|
queueTopAct = new QAction(QIcon(":/images/go-top.png"), tr("Top"), this);
|
|
|
|
connect(queueTopAct, SIGNAL(triggered()), this, SLOT(priorityQueueTop()));
|
|
|
|
queueBottomAct = new QAction(QIcon(":/images/go-bottom.png"), tr("Bottom"), this);
|
|
|
|
connect(queueBottomAct, SIGNAL(triggered()), this, SLOT(priorityQueueBottom()));
|
2010-01-26 18:25:00 -05:00
|
|
|
|
|
|
|
prioritySlowAct = new QAction(QIcon(IMAGE_PRIORITYLOW), tr("Slower"), this);
|
|
|
|
connect(prioritySlowAct, SIGNAL(triggered()), this, SLOT(speedSlow()));
|
|
|
|
priorityMediumAct = new QAction(QIcon(IMAGE_PRIORITYNORMAL), tr("Average"), this);
|
|
|
|
connect(priorityMediumAct, SIGNAL(triggered()), this, SLOT(speedAverage()));
|
|
|
|
priorityFastAct = new QAction(QIcon(IMAGE_PRIORITYHIGH), tr("Faster"), this);
|
|
|
|
connect(priorityFastAct, SIGNAL(triggered()), this, SLOT(speedFast()));
|
|
|
|
|
2010-03-08 16:07:53 -05:00
|
|
|
QMenu *priorityQueueMenu = new QMenu(tr("Move in Queue..."), this);
|
2010-01-26 18:25:00 -05:00
|
|
|
priorityQueueMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
2010-03-08 16:07:53 -05:00
|
|
|
priorityQueueMenu->addAction(queueTopAct);
|
|
|
|
priorityQueueMenu->addAction(queueUpAct);
|
|
|
|
priorityQueueMenu->addAction(queueDownAct);
|
|
|
|
priorityQueueMenu->addAction(queueBottomAct);
|
2010-01-26 18:25:00 -05:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
QMenu *prioritySpeedMenu = new QMenu(tr("Priority (Speed)..."), this);
|
2010-01-26 18:25:00 -05:00
|
|
|
prioritySpeedMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
|
|
|
prioritySpeedMenu->addAction(prioritySlowAct);
|
|
|
|
prioritySpeedMenu->addAction(priorityMediumAct);
|
|
|
|
prioritySpeedMenu->addAction(priorityFastAct);
|
|
|
|
|
|
|
|
chunkStreamingAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Streaming"), this);
|
|
|
|
connect(chunkStreamingAct, SIGNAL(triggered()), this, SLOT(chunkStreaming()));
|
|
|
|
chunkRandomAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Random"), this);
|
|
|
|
connect(chunkRandomAct, SIGNAL(triggered()), this, SLOT(chunkRandom()));
|
|
|
|
|
|
|
|
QMenu *chunkMenu = new QMenu(tr("Chunk strategy"), this);
|
|
|
|
chunkMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
|
|
|
chunkMenu->addAction(chunkStreamingAct);
|
|
|
|
chunkMenu->addAction(chunkRandomAct);
|
2010-01-22 18:23:37 -05:00
|
|
|
|
|
|
|
contextMnu.clear();
|
2010-01-26 18:25:00 -05:00
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
if (addPlayOption)
|
|
|
|
contextMnu.addAction(playAct);
|
2010-01-26 18:25:00 -05:00
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
contextMnu.addSeparator();
|
|
|
|
|
|
|
|
if(!items.empty())
|
|
|
|
{
|
|
|
|
bool all_paused = true ;
|
|
|
|
bool all_downld = true ;
|
2010-01-26 18:25:00 -05:00
|
|
|
bool all_downloading = true ;
|
|
|
|
bool all_queued = true ;
|
2010-01-22 18:23:37 -05:00
|
|
|
|
|
|
|
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
|
|
|
|
|
|
|
for (int i = 0; i < lst.count (); i++)
|
|
|
|
{
|
2010-02-22 12:45:55 -05:00
|
|
|
if ( lst[i].column() == 0 && info.downloadStatus == FT_STATE_WAITING )
|
2010-01-22 18:23:37 -05:00
|
|
|
all_downld = false ;
|
2010-02-22 12:45:55 -05:00
|
|
|
if ( lst[i].column() == 0 && info.downloadStatus == FT_STATE_DOWNLOADING )
|
2010-01-22 18:23:37 -05:00
|
|
|
all_paused = false ;
|
2010-01-26 18:25:00 -05:00
|
|
|
|
|
|
|
if ( lst[i].column() == 0)
|
2010-03-07 09:10:51 -05:00
|
|
|
{
|
2010-01-26 18:25:00 -05:00
|
|
|
if(lst[i].model ()->data (lst[i].model ()->index (lst[i].row (), STATUS )).toString() == "Queued")
|
|
|
|
all_downloading = false ;
|
|
|
|
else
|
|
|
|
all_queued = false ;
|
2010-03-07 09:10:51 -05:00
|
|
|
}
|
2010-01-22 18:23:37 -05:00
|
|
|
}
|
|
|
|
|
2010-01-26 18:25:00 -05:00
|
|
|
if(all_downloading)
|
|
|
|
contextMnu.addMenu(prioritySpeedMenu);
|
|
|
|
else if(all_queued)
|
|
|
|
contextMnu.addMenu(priorityQueueMenu) ;
|
|
|
|
|
|
|
|
if(all_downloading)
|
|
|
|
contextMnu.addMenu( chunkMenu);
|
2010-01-22 18:23:37 -05:00
|
|
|
|
|
|
|
if(!all_paused)
|
|
|
|
contextMnu.addAction( pauseAct);
|
|
|
|
if(!all_downld)
|
|
|
|
contextMnu.addAction( resumeAct);
|
2010-03-06 18:29:47 -05:00
|
|
|
|
|
|
|
if(info.downloadStatus != FT_STATE_COMPLETE)
|
|
|
|
contextMnu.addAction( cancelAct);
|
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
contextMnu.addSeparator();
|
|
|
|
}
|
2010-01-26 09:57:05 -05:00
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
if(single)
|
|
|
|
{
|
2010-02-19 20:52:44 -05:00
|
|
|
if (addOpenFileOption)
|
2010-01-22 18:23:37 -05:00
|
|
|
contextMnu.addAction( openfileAct);
|
2010-02-19 20:52:44 -05:00
|
|
|
|
|
|
|
#ifndef RS_RELEASE_VERSION
|
2010-01-22 18:23:37 -05:00
|
|
|
contextMnu.addAction( previewfileAct);
|
2010-01-26 09:57:05 -05:00
|
|
|
#endif
|
|
|
|
contextMnu.addAction( openfolderAct);
|
2010-01-22 18:23:37 -05:00
|
|
|
contextMnu.addAction( detailsfileAct);
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
}
|
2010-01-26 09:57:05 -05:00
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
contextMnu.addAction( clearcompletedAct);
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
#ifndef RS_RELEASE_VERSION
|
2010-03-10 16:38:26 -05:00
|
|
|
if(single)
|
|
|
|
contextMnu.addAction( copylinkAct);
|
2010-01-22 18:23:37 -05:00
|
|
|
#endif
|
|
|
|
contextMnu.addAction( pastelinkAct);
|
|
|
|
contextMnu.addSeparator();
|
2010-03-06 18:29:47 -05:00
|
|
|
// contextMnu.addAction( clearQueueAct);
|
2010-01-22 18:23:37 -05:00
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addMenu( viewMenu);
|
|
|
|
|
|
|
|
contextMnu.exec( mevent->globalPos() );
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
TransfersDialog::~TransfersDialog()
|
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-07 09:10:51 -05:00
|
|
|
int TransfersDialog::addItem(const QString&, const QString& name, const QString& coreID, qlonglong fileSize, const FileProgressInfo& pinfo, double dlspeed,
|
2010-03-01 17:47:48 -05:00
|
|
|
const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining, qlonglong downloadtime)
|
2008-12-12 16:42:44 -05:00
|
|
|
{
|
2009-05-27 09:09:03 -04:00
|
|
|
int row;
|
2010-02-16 21:10:25 -05:00
|
|
|
QList<QStandardItem *> list = DLListModel->findItems(coreID, Qt::MatchExactly, ID);
|
|
|
|
if (list.size() > 0) {
|
|
|
|
row = list.front()->row();
|
|
|
|
} else {
|
|
|
|
row = DLListModel->rowCount();
|
|
|
|
DLListModel->insertRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(name));
|
2009-05-27 09:09:03 -04:00
|
|
|
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)fileSize));
|
|
|
|
DLListModel->setData(DLListModel->index(row, COMPLETED), QVariant((qlonglong)completed));
|
|
|
|
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)dlspeed));
|
2010-02-16 21:10:25 -05:00
|
|
|
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant::fromValue(pinfo));
|
2009-05-27 09:09:03 -04:00
|
|
|
DLListModel->setData(DLListModel->index(row, SOURCES), QVariant((QString)sources));
|
|
|
|
DLListModel->setData(DLListModel->index(row, STATUS), QVariant((QString)status));
|
2009-08-11 16:27:59 -04:00
|
|
|
DLListModel->setData(DLListModel->index(row, PRIORITY), QVariant((QString)priority));
|
2009-05-27 09:09:03 -04:00
|
|
|
DLListModel->setData(DLListModel->index(row, REMAINING), QVariant((qlonglong)remaining));
|
2010-03-01 17:47:48 -05:00
|
|
|
DLListModel->setData(DLListModel->index(row, DOWNLOADTIME), QVariant((qlonglong)downloadtime));
|
2009-05-27 09:09:03 -04:00
|
|
|
DLListModel->setData(DLListModel->index(row, ID), QVariant((QString)coreID));
|
|
|
|
|
|
|
|
|
2010-02-16 21:57:07 -05:00
|
|
|
QString ext = QFileInfo(name).suffix();
|
|
|
|
if (ext == "jpg" || ext == "jpeg" || ext == "tif" || ext == "tiff" || ext == "JPG"|| ext == "png" || ext == "gif"
|
|
|
|
|| ext == "bmp" || ext == "ico" || ext == "svg") {
|
|
|
|
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"
|
|
|
|
|| ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp" || ext == "mpeg" || ext == "ogm") {
|
|
|
|
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeVideo.png")), Qt::DecorationRole);
|
|
|
|
} 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);
|
|
|
|
} 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"
|
|
|
|
|| 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);
|
|
|
|
}else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com"
|
|
|
|
|| ext == "exe" || ext == "js" || ext == "pif"
|
|
|
|
|| ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws") {
|
|
|
|
DLListModel->setData(DLListModel->index(row,NAME), QIcon(QString::fromUtf8(":/images/FileTypeProgram.png")), Qt::DecorationRole);
|
|
|
|
} 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);
|
|
|
|
} 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);
|
|
|
|
}
|
2010-02-16 21:10:25 -05:00
|
|
|
|
|
|
|
return row;
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
|
|
|
|
2010-03-07 09:10:51 -05:00
|
|
|
int TransfersDialog::addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, const QString& status, const FileProgressInfo& peerInfo)
|
2009-05-20 18:06:20 -04:00
|
|
|
{
|
|
|
|
QStandardItem *dlItem = DLListModel->item(row);
|
2010-03-07 09:10:51 -05:00
|
|
|
if (!dlItem) return -1;
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
//try to find the item
|
|
|
|
int childRow = -1;
|
|
|
|
int count = 0;
|
2010-03-06 18:29:47 -05:00
|
|
|
QStandardItem* childId=NULL ;
|
2009-05-27 18:21:09 -04:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
for(count=0; (childId = dlItem->child(count, ID)) != NULL;++count)
|
|
|
|
if (childId->data(Qt::DisplayRole).toString() == coreID)
|
|
|
|
{
|
2010-02-16 21:10:25 -05:00
|
|
|
childRow = count;
|
|
|
|
break;
|
|
|
|
}
|
2010-03-07 09:10:51 -05:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
if (childRow == -1) {
|
|
|
|
//set this false if you want to expand on double click
|
|
|
|
dlItem->setEditable(false);
|
|
|
|
|
|
|
|
QList<QStandardItem *> items;
|
|
|
|
QStandardItem *i1 = new QStandardItem(); i1->setData(QVariant((QString)" "+name), Qt::DisplayRole);
|
|
|
|
QStandardItem *i2 = new QStandardItem(); i2->setData(QVariant(QString()), Qt::DisplayRole);
|
|
|
|
QStandardItem *i3 = new QStandardItem(); i3->setData(QVariant(QString()), Qt::DisplayRole);
|
|
|
|
QStandardItem *i4 = new QStandardItem(); i4->setData(QVariant((double)dlspeed), Qt::DisplayRole);
|
2010-02-18 11:29:04 -05:00
|
|
|
QStandardItem *i5 = new QStandardItem(); i5->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole);
|
2010-02-16 21:10:25 -05:00
|
|
|
QStandardItem *i6 = new QStandardItem(); i6->setData(QVariant(QString()), Qt::DisplayRole);
|
|
|
|
QStandardItem *i7 = new QStandardItem(); i7->setData(QVariant((QString)status), Qt::DisplayRole);
|
|
|
|
QStandardItem *i8 = new QStandardItem(); i8->setData(QVariant(QString()), Qt::DisplayRole); // blank field for priority
|
|
|
|
QStandardItem *i9 = new QStandardItem(); i9->setData(QVariant(QString()), Qt::DisplayRole);
|
2010-03-06 18:29:47 -05:00
|
|
|
QStandardItem *i10 = new QStandardItem(); i10->setData(QVariant(QString()), Qt::DisplayRole);
|
|
|
|
QStandardItem *i11 = new QStandardItem(); i11->setData(QVariant((QString)coreID), Qt::DisplayRole);
|
2010-02-16 21:10:25 -05:00
|
|
|
|
|
|
|
/* set status icon in the name field */
|
|
|
|
if (status == "Downloading") {
|
|
|
|
i1->setData(QIcon(QString::fromUtf8(":/images/Client0.png")), Qt::DecorationRole);
|
|
|
|
} else if (status == "Failed") {
|
|
|
|
i1->setData(QIcon(QString::fromUtf8(":/images/Client1.png")), Qt::DecorationRole);
|
|
|
|
} else if (status == "Okay") {
|
|
|
|
i1->setData(QIcon(QString::fromUtf8(":/images/Client2.png")), Qt::DecorationRole);
|
|
|
|
} else if (status == "Waiting") {
|
|
|
|
i1->setData(QIcon(QString::fromUtf8(":/images/Client3.png")), Qt::DecorationRole);
|
|
|
|
} else if (status == "Unknown") {
|
|
|
|
i1->setData(QIcon(QString::fromUtf8(":/images/Client4.png")), Qt::DecorationRole);
|
|
|
|
} else if (status == "Complete") {
|
|
|
|
}
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2010-02-16 21:10:25 -05:00
|
|
|
items.append(i1);
|
|
|
|
items.append(i2);
|
|
|
|
items.append(i3);
|
|
|
|
items.append(i4);
|
|
|
|
items.append(i5);
|
|
|
|
items.append(i6);
|
|
|
|
items.append(i7);
|
|
|
|
items.append(i8);
|
|
|
|
items.append(i9);
|
|
|
|
items.append(i10);
|
2010-03-06 18:29:47 -05:00
|
|
|
items.append(i11);
|
2010-02-16 21:10:25 -05:00
|
|
|
dlItem->appendRow(items);
|
2010-03-07 09:10:51 -05:00
|
|
|
|
|
|
|
childRow = dlItem->rowCount()-1 ;
|
2010-02-16 21:10:25 -05:00
|
|
|
} 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);
|
2010-02-18 17:30:36 -05:00
|
|
|
dlItem->child(childRow, PROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole);
|
2010-02-16 21:10:25 -05:00
|
|
|
/* 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") {
|
|
|
|
}
|
|
|
|
}
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2010-03-07 09:10:51 -05:00
|
|
|
return childRow;
|
2009-05-20 18:06:20 -04:00
|
|
|
}
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-03-07 09:10:51 -05:00
|
|
|
int TransfersDialog::addUploadItem(const QString&, const QString& name, const QString& coreID, qlonglong fileSize, const FileProgressInfo& pinfo, double dlspeed, const QString& source, const QString& status, qlonglong completed, qlonglong)
|
2008-12-12 16:42:44 -05:00
|
|
|
{
|
2010-02-16 21:10:25 -05:00
|
|
|
int row;
|
|
|
|
QList<QStandardItem *> list = ULListModel->findItems(coreID, Qt::MatchExactly, UHASH);
|
|
|
|
if (list.size() > 0) {
|
|
|
|
row = list.front()->row();
|
|
|
|
} else {
|
|
|
|
row = ULListModel->rowCount();
|
|
|
|
ULListModel->insertRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
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, UTRANSFERRED), QVariant((qlonglong)completed));
|
|
|
|
ULListModel->setData(ULListModel->index(row, ULSPEED), QVariant((double)dlspeed));
|
|
|
|
ULListModel->setData(ULListModel->index(row, UPROGRESS), QVariant::fromValue(pinfo));
|
|
|
|
ULListModel->setData(ULListModel->index(row, USTATUS), QVariant((QString)status));
|
|
|
|
ULListModel->setData(ULListModel->index(row, USERNAME), QVariant((QString)source));
|
|
|
|
ULListModel->setData(ULListModel->index(row, UHASH), QVariant((QString)coreID));
|
|
|
|
|
|
|
|
return row;
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
|
|
|
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
void TransfersDialog::delItem(int row)
|
|
|
|
{
|
|
|
|
DLListModel->removeRow(row, QModelIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransfersDialog::delUploadItem(int row)
|
|
|
|
{
|
|
|
|
ULListModel->removeRow(row, QModelIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the list of Transfers from the RsIface. **/
|
2009-11-17 07:45:06 -05:00
|
|
|
void TransfersDialog::updateDisplay()
|
|
|
|
{
|
|
|
|
insertTransfers();
|
|
|
|
}
|
2010-03-06 18:29:47 -05:00
|
|
|
void TransfersDialog::insertTransfers()
|
|
|
|
{
|
|
|
|
/* get the download lists */
|
2010-02-16 21:10:25 -05:00
|
|
|
std::list<std::string> downHashes;
|
|
|
|
rsFiles->FileDownloads(downHashes);
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
// std::list<DwlDetails> dwlDetails;
|
|
|
|
// 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++;
|
|
|
|
}
|
|
|
|
}
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
// clear all source peers.
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
for (it = downHashes.begin(); it != downHashes.end(); it++) {
|
|
|
|
FileInfo info;
|
|
|
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) {
|
|
|
|
//if file transfer is a cache file index file, don't show it
|
|
|
|
continue;
|
|
|
|
}
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
if ((info.flags & CB_CODE_CACHE)) {
|
|
|
|
/*(!_show_cache_transfers) &&*/
|
|
|
|
continue;
|
|
|
|
}
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
QString fileName = QString::fromUtf8(info.fname.c_str());
|
|
|
|
QString fileHash = QString::fromStdString(info.hash);
|
|
|
|
qlonglong fileSize = info.size;
|
|
|
|
double fileDlspeed = info.tfRate * 1024.0;
|
|
|
|
|
|
|
|
/* get the sources (number of online peers) */
|
|
|
|
int online = 0;
|
|
|
|
std::list<TransferInfo>::iterator pit;
|
|
|
|
for (pit = info.peers.begin(); pit != info.peers.end(); pit++) {
|
|
|
|
if (rsPeers->isOnline(pit->peerId)) {
|
|
|
|
online++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QString sources = QString("%1 (%2)").arg(online).arg(info.peers.size());
|
|
|
|
|
|
|
|
QString status;
|
|
|
|
switch (info.downloadStatus) {
|
|
|
|
case FT_STATE_FAILED: status = tr("Failed"); break;
|
|
|
|
case FT_STATE_OKAY: status = tr("Okay"); break;
|
|
|
|
case FT_STATE_WAITING: status = tr("Waiting"); break;
|
|
|
|
case FT_STATE_DOWNLOADING: status = tr("Downloading"); break;
|
|
|
|
case FT_STATE_COMPLETE: status = tr("Complete"); break;
|
|
|
|
case FT_STATE_QUEUED: status = tr("Queued"); break;
|
|
|
|
default: status = tr("Unknown"); break;
|
|
|
|
}
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
QString priority;
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
if(info.downloadStatus == FT_STATE_QUEUED)
|
|
|
|
priority = QString::number(info.queue_position) ;
|
|
|
|
else
|
|
|
|
switch (info.priority)
|
|
|
|
{
|
|
|
|
case SPEED_LOW: priority = tr("Slower");break;
|
|
|
|
case SPEED_NORMAL: priority = tr("Average");break;
|
|
|
|
case SPEED_HIGH: priority = tr("Faster");break;
|
|
|
|
default: priority = tr("Average");break;
|
|
|
|
}
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
qlonglong completed = info.transfered;
|
|
|
|
qlonglong remaining = info.size - info.transfered;
|
|
|
|
qlonglong downloadtime = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
FileChunksInfo fcinfo ;
|
|
|
|
if(!rsFiles->FileDownloadChunksDetails(*it,fcinfo))
|
|
|
|
continue ;
|
2009-05-20 18:06:20 -04:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
FileProgressInfo pinfo ;
|
|
|
|
pinfo.cmap = fcinfo.chunks ;
|
|
|
|
pinfo.type = FileProgressInfo::DOWNLOAD_LINE ;
|
|
|
|
pinfo.progress = completed*100.0/info.size ;
|
|
|
|
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:fcinfo.chunks.size() ;
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
int addedRow = addItem("", fileName, fileHash, fileSize, pinfo, fileDlspeed, sources, status, priority, completed, remaining, downloadtime);
|
2008-12-12 16:42:44 -05:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
/* continue to next download item if no peers to add */
|
|
|
|
if (!info.peers.size()) continue;
|
|
|
|
|
|
|
|
std::map<std::string, std::string>::iterator vit;
|
|
|
|
std::map<std::string, std::string> versions;
|
|
|
|
bool retv = rsDisc->getDiscVersions(versions);
|
|
|
|
|
2010-03-07 09:10:51 -05:00
|
|
|
std::set<int> used_rows ;
|
|
|
|
|
|
|
|
for (pit = info.peers.begin(); pit != info.peers.end(); pit++)
|
|
|
|
{
|
2010-03-06 18:29:47 -05:00
|
|
|
QString peerName = getPeerName(pit->peerId);
|
|
|
|
//unique combination: fileHash + peerId, variant: hash + peerName (too long)
|
|
|
|
QString hashFileAndPeerId = fileHash + QString::fromStdString(pit->peerId);
|
|
|
|
QString version;
|
|
|
|
if (retv && versions.end() != (vit = versions.find(pit->peerId))) {
|
|
|
|
version = tr("version: ") + QString::fromStdString(vit->second);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString status;
|
|
|
|
switch (pit->status) {
|
|
|
|
case FT_STATE_FAILED: status = tr("Failed"); break;
|
|
|
|
case FT_STATE_OKAY: status = tr("Okay"); break;
|
|
|
|
case FT_STATE_WAITING: status = tr(""); break;
|
|
|
|
case FT_STATE_DOWNLOADING: status = tr("Downloading"); break;
|
|
|
|
case FT_STATE_COMPLETE: status = tr("Complete"); break;
|
|
|
|
default: status = tr(""); break;
|
|
|
|
}
|
|
|
|
double peerDlspeed = 0;
|
2010-03-07 09:10:51 -05:00
|
|
|
if ((uint32_t)pit->status == FT_STATE_DOWNLOADING)
|
|
|
|
{
|
2010-03-06 18:29:47 -05:00
|
|
|
peerDlspeed = pit->tfRate * 1024.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileProgressInfo peerpinfo ;
|
|
|
|
peerpinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId];
|
|
|
|
peerpinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ;
|
|
|
|
peerpinfo.progress = 0.0 ; // we don't display completion for sources.
|
|
|
|
peerpinfo.nb_chunks = peerpinfo.cmap._map.empty()?0:fcinfo.chunks.size();
|
|
|
|
|
|
|
|
// std::cerr << std::endl ;
|
|
|
|
// std::cerr << "Source " << pit->peerId << " as map " << peerpinfo.cmap._map.size() << " compressed chunks" << std::endl ;
|
|
|
|
// for(uint j=0;j<peerpinfo.cmap._map.size();++j)
|
|
|
|
// std::cerr << peerpinfo.cmap._map[j] ;
|
|
|
|
// std::cerr << std::endl ;
|
|
|
|
// std::cerr << std::endl ;
|
|
|
|
|
|
|
|
std::cout << "adding peer " << peerName.toStdString() << " to row " << addedRow << ", hashfile and peerid=" << hashFileAndPeerId.toStdString() << std::endl ;
|
2010-03-07 09:10:51 -05:00
|
|
|
int row_id = addPeerToItem(addedRow, peerName, hashFileAndPeerId, peerDlspeed, status, peerpinfo);
|
|
|
|
|
|
|
|
used_rows.insert(row_id) ;
|
2010-03-06 18:29:47 -05:00
|
|
|
}
|
2010-03-07 09:10:51 -05:00
|
|
|
|
|
|
|
QStandardItem *dlItem = DLListModel->item(addedRow);
|
|
|
|
|
|
|
|
// This is not optimal, but we deal with a small number of elements. The reverse order is really important,
|
|
|
|
// because rows after the deleted rows change positions !
|
|
|
|
//
|
|
|
|
for(int r=dlItem->rowCount()-1;r>=0;--r)
|
|
|
|
if(used_rows.find(r) == used_rows.end())
|
|
|
|
dlItem->takeRow(r) ;
|
2010-03-06 18:29:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* here i will insert files from the download queue - which are
|
|
|
|
* not started yet and can't be find in FileDownloads
|
|
|
|
* */
|
|
|
|
// std::list<DwlDetails>::iterator dit;
|
|
|
|
// for (dit = dwlDetails.begin(); dit != dwlDetails.end(); dit ++)
|
|
|
|
// {
|
|
|
|
//// 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 ;
|
|
|
|
// pinfo.progress = 0.0 ;
|
|
|
|
// pinfo.nb_chunks = 0 ;
|
|
|
|
//
|
|
|
|
// addItem("", QString::fromUtf8(dit->fname.c_str()),
|
|
|
|
// QString::fromStdString(dit->hash), dit->count, pinfo, 0, 0,
|
|
|
|
// tr("Queued"), "", 0, 0, 0);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
|
|
|
|
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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(it = upHashes.begin(); it != upHashes.end(); it++) {
|
|
|
|
FileInfo info;
|
|
|
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (/*(!_show_cache_transfers) &&*/ (info.flags & CB_CODE_CACHE))
|
|
|
|
continue ;
|
|
|
|
|
|
|
|
std::list<TransferInfo>::iterator pit;
|
|
|
|
for(pit = info.peers.begin(); pit != info.peers.end(); pit++) {
|
|
|
|
if (pit->peerId == rsPeers->getOwnId()) //don't display transfer to ourselves
|
|
|
|
continue ;
|
|
|
|
|
|
|
|
QString fileHash = QString::fromStdString(info.hash);
|
|
|
|
QString fileName = QString::fromUtf8(info.fname.c_str());
|
|
|
|
QString sources = getPeerName(pit->peerId);
|
|
|
|
|
|
|
|
QString status;
|
|
|
|
switch(pit->status)
|
|
|
|
{
|
|
|
|
case FT_STATE_FAILED: status = tr("Failed"); break;
|
|
|
|
case FT_STATE_OKAY: status = tr("Okay"); break;
|
|
|
|
case FT_STATE_WAITING: status = tr("Waiting"); break;
|
|
|
|
case FT_STATE_DOWNLOADING: status = tr("Uploading"); break;
|
|
|
|
case FT_STATE_COMPLETE: status = tr("Complete"); break;
|
|
|
|
default: status = tr("Complete"); break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FileProgressInfo pinfo ;
|
|
|
|
|
|
|
|
if(!rsFiles->FileUploadChunksDetails(*it,pit->peerId,pinfo.cmap) )
|
|
|
|
continue ;
|
|
|
|
|
|
|
|
double dlspeed = pit->tfRate * 1024.0;
|
|
|
|
qlonglong fileSize = info.size;
|
|
|
|
double completed = info.transfered;
|
|
|
|
double progress = info.transfered * 100.0 / info.size;
|
|
|
|
qlonglong remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
|
|
|
|
|
|
|
// Estimate the completion. We need something more accurate, meaning that we need to
|
|
|
|
// transmit the completion info.
|
|
|
|
//
|
|
|
|
uint32_t chunk_size = 1024*1024 ;
|
|
|
|
uint32_t nb_chunks = (uint32_t)(info.size / (uint64_t)(chunk_size) ) ;
|
|
|
|
if((info.size % (uint64_t)chunk_size) != 0)
|
|
|
|
++nb_chunks ;
|
|
|
|
|
|
|
|
uint32_t filled_chunks = pinfo.cmap.filledChunks(nb_chunks) ;
|
|
|
|
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:nb_chunks ;
|
|
|
|
|
|
|
|
if(filled_chunks > 1) {
|
|
|
|
pinfo.progress = filled_chunks*100.0/nb_chunks ;
|
|
|
|
completed = std::min(info.size,((uint64_t)filled_chunks)*chunk_size) ;
|
|
|
|
} else {
|
|
|
|
pinfo.progress = progress ;
|
|
|
|
}
|
|
|
|
|
|
|
|
addUploadItem("", fileName, fileHash, fileSize, pinfo, dlspeed, sources, status, completed, remaining);
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
case FT_STATE_FAILED: status = tr("Failed"); break;
|
|
|
|
case FT_STATE_OKAY: status = tr("Okay"); break;
|
|
|
|
case FT_STATE_WAITING: status = tr("Waiting"); break;
|
|
|
|
case FT_STATE_DOWNLOADING: status = tr("Uploading");break;
|
|
|
|
case FT_STATE_COMPLETE:status = tr("Complete"); break;
|
|
|
|
default: status = tr("Complete"); break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
double dlspeed = info.tfRate * 1024.0;
|
|
|
|
qlonglong fileSize = info.size;
|
|
|
|
double completed = info.transfered;
|
|
|
|
double progress = info.transfered * 100.0 / info.size;
|
|
|
|
qlonglong remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
|
|
|
|
|
|
|
FileProgressInfo pinfo ;
|
|
|
|
pinfo.progress = progress ;
|
|
|
|
pinfo.cmap = CompressedChunkMap() ;
|
|
|
|
pinfo.type = FileProgressInfo::DOWNLOAD_LINE ;
|
|
|
|
pinfo.nb_chunks = 0 ;
|
|
|
|
|
|
|
|
addUploadItem("", fileName, fileHash, fileSize, pinfo, dlspeed, sources, status, completed, remaining);
|
|
|
|
}
|
|
|
|
}
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
|
|
|
|
2009-06-03 14:47:14 -04:00
|
|
|
QString TransfersDialog::getPeerName(const std::string& id) const
|
|
|
|
{
|
|
|
|
QString res = QString::fromStdString(rsPeers->getPeerName(id)) ;
|
|
|
|
|
|
|
|
// This is because turtle tunnels have no name (I didn't want to bother with
|
|
|
|
// connect mgr). In such a case their id can suitably hold for a name.
|
|
|
|
//
|
|
|
|
if(res == "")
|
|
|
|
return QString::fromStdString(id) ;
|
|
|
|
else
|
|
|
|
return res ;
|
|
|
|
}
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
void TransfersDialog::cancel()
|
|
|
|
{
|
2009-08-14 16:48:53 -04:00
|
|
|
QString queryWrn2;
|
2010-01-26 18:25:00 -05:00
|
|
|
queryWrn2.clear();
|
|
|
|
queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?"));
|
|
|
|
|
|
|
|
if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok)
|
|
|
|
for(int i = 0; i <= DLListModel->rowCount(); i++)
|
|
|
|
if(selection->isRowSelected(i, QModelIndex()))
|
|
|
|
{
|
|
|
|
std::string id = getID(i, DLListModel).toStdString();
|
2009-05-07 18:40:57 -04:00
|
|
|
|
2009-08-14 16:48:53 -04:00
|
|
|
rsFiles->FileCancel(id); /* hash */
|
2010-01-26 18:25:00 -05:00
|
|
|
}
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
|
|
|
|
2010-03-10 16:38:26 -05:00
|
|
|
//void TransfersDialog::handleDownloadRequest(const QString& url)
|
|
|
|
//{
|
|
|
|
// RetroShareLink link(url);
|
|
|
|
//
|
|
|
|
// if (!link.valid ())
|
|
|
|
// {
|
|
|
|
// QMessageBox::critical(NULL,"Link error","This link could not be parsed. This is a bug. Please contact the developers.") ;
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// QVector<RetroShareLinkData> linkList;
|
|
|
|
// analyzer.getFileInformation (linkList);
|
|
|
|
//
|
|
|
|
// std::list<std::string> srcIds;
|
|
|
|
//
|
|
|
|
// for (int i = 0, n = linkList.size (); i < n; ++i)
|
|
|
|
// {
|
|
|
|
// const RetroShareLinkData& linkData = linkList[i];
|
|
|
|
//
|
|
|
|
// rsFiles->FileRequest (linkData.getName ().toStdString (), linkData.getHash ().toStdString (),
|
|
|
|
// linkData.getSize ().toInt (), "", 0, srcIds);
|
|
|
|
// }
|
|
|
|
//}
|
2009-05-18 10:23:55 -04:00
|
|
|
|
|
|
|
void TransfersDialog::copyLink ()
|
|
|
|
{
|
2010-03-10 16:38:26 -05:00
|
|
|
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
2009-05-18 10:23:55 -04:00
|
|
|
|
2010-03-10 16:38:26 -05:00
|
|
|
for (int i = 0; i < lst.count (); i++)
|
|
|
|
if ( lst[i].column() == 0 )
|
|
|
|
{
|
|
|
|
QModelIndex & ind = lst[i];
|
|
|
|
QString fhash= ind.model ()->data (ind.model ()->index (ind.row (), ID )).toString() ;
|
|
|
|
qulonglong fsize= ind.model ()->data (ind.model ()->index (ind.row (), SIZE)).toULongLong() ;
|
|
|
|
QString fname= ind.model ()->data (ind.model ()->index (ind.row (), NAME)).toString() ;
|
2009-05-18 10:23:55 -04:00
|
|
|
|
2010-03-10 16:38:26 -05:00
|
|
|
RetroShareLink link(fname, fsize, fhash);
|
2009-05-18 10:23:55 -04:00
|
|
|
|
2010-03-10 16:38:26 -05:00
|
|
|
QApplication::clipboard()->setText(link.toString());
|
|
|
|
break ;
|
|
|
|
}
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
|
|
|
|
2010-01-05 19:10:15 -05:00
|
|
|
void TransfersDialog::showDetailsDialog()
|
|
|
|
{
|
|
|
|
static DetailsDialog *detailsdlg = new DetailsDialog();
|
|
|
|
|
|
|
|
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
2010-01-26 09:57:05 -05:00
|
|
|
|
|
|
|
std::string file_hash ;
|
2010-01-05 19:10:15 -05:00
|
|
|
|
|
|
|
for (int i = 0; i < lst.count (); i++)
|
|
|
|
{
|
|
|
|
if (lst[i].column () == 0)
|
|
|
|
{
|
|
|
|
QModelIndex& ind = lst[i];
|
|
|
|
QString fhash = ind.model ()->data (ind.model ()->index (ind.row (), ID )).toString() ;
|
|
|
|
QString fsize = ind.model ()->data (ind.model ()->index (ind.row (), SIZE)).toString() ;
|
|
|
|
QString fname = ind.model ()->data (ind.model ()->index (ind.row (), NAME)).toString() ;
|
|
|
|
QString fstatus = ind.model ()->data (ind.model ()->index (ind.row (), STATUS)).toString() ;
|
|
|
|
QString fpriority = ind.model ()->data (ind.model ()->index (ind.row (), PRIORITY)).toString() ;
|
|
|
|
QString fsources= ind.model ()->data (ind.model ()->index (ind.row (), SOURCES)).toString() ;
|
|
|
|
|
|
|
|
qulonglong filesize = ind.model ()->data (ind.model ()->index (ind.row (), SIZE)).toULongLong() ;
|
|
|
|
double fdatarate = ind.model ()->data (ind.model ()->index (ind.row (), DLSPEED)).toDouble() ;
|
|
|
|
qulonglong fcompleted = ind.model ()->data (ind.model ()->index (ind.row (), COMPLETED)).toULongLong() ;
|
|
|
|
qulonglong fremaining = ind.model ()->data (ind.model ()->index (ind.row (), REMAINING)).toULongLong() ;
|
|
|
|
|
2010-03-01 17:47:48 -05:00
|
|
|
qulonglong fdownloadtime = ind.model ()->data (ind.model ()->index (ind.row (), DOWNLOADTIME)).toULongLong() ;
|
|
|
|
|
2010-01-26 09:57:05 -05:00
|
|
|
int nb_select = 0 ;
|
|
|
|
|
|
|
|
for(int i = 0; i <= DLListModel->rowCount(); i++)
|
|
|
|
if(selection->isRowSelected(i, QModelIndex()))
|
|
|
|
{
|
|
|
|
file_hash = getID(i, DLListModel).toStdString();
|
|
|
|
++nb_select ;
|
|
|
|
}
|
|
|
|
|
|
|
|
detailsdlg->setFileHash(file_hash);
|
|
|
|
|
2010-01-05 19:10:15 -05:00
|
|
|
// Set Details.. Window Title
|
|
|
|
detailsdlg->setWindowTitle(tr("Details:") + fname);
|
|
|
|
|
|
|
|
// General GroupBox
|
|
|
|
detailsdlg->setHash(fhash);
|
|
|
|
detailsdlg->setFileName(fname);
|
|
|
|
detailsdlg->setSize(filesize);
|
|
|
|
detailsdlg->setStatus(fstatus);
|
|
|
|
detailsdlg->setPriority(fpriority);
|
|
|
|
detailsdlg->setType(QFileInfo(fname).suffix());
|
|
|
|
|
|
|
|
// Transfer GroupBox
|
|
|
|
detailsdlg->setSources(fsources);
|
|
|
|
detailsdlg->setDatarate(fdatarate);
|
|
|
|
detailsdlg->setCompleted(fcompleted);
|
|
|
|
detailsdlg->setRemaining(fremaining);
|
|
|
|
|
2010-03-01 17:47:48 -05:00
|
|
|
//Date GroupBox
|
|
|
|
detailsdlg->setDownloadtime(fdownloadtime);
|
|
|
|
|
2010-01-05 19:10:15 -05:00
|
|
|
// retroshare link(s) Tab
|
2010-03-10 16:38:26 -05:00
|
|
|
RetroShareLink link(fname, filesize, fhash);
|
|
|
|
detailsdlg->setLink(link.toString());
|
2010-01-05 19:10:15 -05:00
|
|
|
|
|
|
|
detailsdlg->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-18 10:23:55 -04:00
|
|
|
void TransfersDialog::pasteLink()
|
|
|
|
{
|
2010-03-10 16:38:26 -05:00
|
|
|
RetroShareLink link(QApplication::clipboard()->text());
|
2009-05-18 10:23:55 -04:00
|
|
|
|
2010-03-10 16:38:26 -05:00
|
|
|
if (!link.valid())
|
2009-05-18 10:23:55 -04:00
|
|
|
return;
|
|
|
|
|
2010-03-10 16:38:26 -05:00
|
|
|
rsFiles->FileRequest(link.name().toStdString(), link.hash().toStdString(),link.size(), "", RS_FILE_HINTS_NETWORK_WIDE, std::list<std::string>());
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
void TransfersDialog::getIdOfSelectedItems(std::set<QStandardItem *>& items)
|
2009-07-02 14:40:31 -04:00
|
|
|
{
|
2009-07-04 17:54:58 -04:00
|
|
|
items.clear();
|
2009-07-02 14:40:31 -04:00
|
|
|
|
|
|
|
int i, imax = DLListModel->rowCount();
|
|
|
|
for (i = 0; i < imax; i++) {
|
|
|
|
bool isParentSelected = false;
|
|
|
|
bool isChildSelected = false;
|
|
|
|
|
|
|
|
QStandardItem *parent = DLListModel->item(i);
|
|
|
|
if (!parent) continue;
|
|
|
|
QModelIndex pindex = parent->index();
|
|
|
|
if (selection->isSelected(pindex)) {
|
|
|
|
isParentSelected = true;
|
|
|
|
} else {
|
|
|
|
int j, jmax = parent->rowCount();
|
|
|
|
for (j = 0; j < jmax && !isChildSelected; j++) {
|
|
|
|
QStandardItem *child = parent->child(j);
|
|
|
|
if (!child) continue;
|
|
|
|
QModelIndex cindex = child->index();
|
|
|
|
if (selection->isSelected(cindex)) {
|
|
|
|
isChildSelected = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if transfered file or it's peers are selected control it*/
|
|
|
|
if (isParentSelected || isChildSelected) {
|
|
|
|
QStandardItem *id = DLListModel->item(i, ID);
|
2010-01-22 18:23:37 -05:00
|
|
|
items.insert(id);
|
2009-07-02 14:40:31 -04:00
|
|
|
}
|
|
|
|
}
|
2009-07-04 17:54:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TransfersDialog::controlTransferFile(uint32_t flags)
|
|
|
|
{
|
|
|
|
bool result = true;
|
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
std::set<QStandardItem *> items;
|
|
|
|
std::set<QStandardItem *>::iterator it;
|
2009-07-04 17:54:58 -04:00
|
|
|
getIdOfSelectedItems(items);
|
|
|
|
for (it = items.begin(); it != items.end(); it ++) {
|
|
|
|
result &= rsFiles->FileControl((*it)->data(Qt::DisplayRole).toString().toStdString(), flags);
|
|
|
|
}
|
2009-07-02 14:40:31 -04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransfersDialog::pauseFileTransfer()
|
|
|
|
{
|
|
|
|
if (!controlTransferFile(RS_FILE_CTRL_PAUSE))
|
|
|
|
{
|
|
|
|
std::cerr << "pauseFileTransfer(): can't pause file transfer" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransfersDialog::resumeFileTransfer()
|
|
|
|
{
|
|
|
|
if (!controlTransferFile(RS_FILE_CTRL_START))
|
|
|
|
{
|
|
|
|
std::cerr << "resumeFileTransfer(): can't resume file transfer" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-05 12:27:58 -04:00
|
|
|
void TransfersDialog::openFolderTransfer()
|
2009-07-02 14:40:31 -04:00
|
|
|
{
|
|
|
|
FileInfo info;
|
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
std::set<QStandardItem *> items;
|
|
|
|
std::set<QStandardItem *>::iterator it;
|
2009-07-04 17:54:58 -04:00
|
|
|
getIdOfSelectedItems(items);
|
|
|
|
for (it = items.begin(); it != items.end(); it ++) {
|
|
|
|
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
|
|
|
break;
|
|
|
|
}
|
2009-07-02 14:40:31 -04:00
|
|
|
|
2009-07-04 17:54:58 -04:00
|
|
|
/* make path for downloaded or downloading files */
|
|
|
|
QFileInfo qinfo;
|
|
|
|
std::string path;
|
|
|
|
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
2009-07-05 12:27:58 -04:00
|
|
|
path = info.path;
|
2009-07-04 17:54:58 -04:00
|
|
|
} else {
|
|
|
|
path = rsFiles->getPartialsDirectory();
|
2009-07-05 12:27:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* open folder with a suitable application */
|
|
|
|
qinfo.setFile(path.c_str());
|
|
|
|
if (qinfo.exists() && qinfo.isDir()) {
|
|
|
|
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
|
|
|
std::cerr << "openFolderTransfer(): can't open folder " << path << std::endl;
|
2009-07-04 17:54:58 -04:00
|
|
|
}
|
|
|
|
}
|
2009-07-05 12:27:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void TransfersDialog::previewTransfer()
|
|
|
|
{
|
|
|
|
FileInfo info;
|
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
std::set<QStandardItem *> items;
|
|
|
|
std::set<QStandardItem *>::iterator it;
|
2009-07-05 12:27:58 -04:00
|
|
|
getIdOfSelectedItems(items);
|
|
|
|
for (it = items.begin(); it != items.end(); it ++) {
|
|
|
|
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t pos = info.fname.find_last_of('.');
|
2010-03-07 09:10:51 -05:00
|
|
|
if (pos == std::string::npos)
|
|
|
|
return; /* can't identify type of file */
|
2009-07-05 12:27:58 -04:00
|
|
|
|
|
|
|
/* check if the file is a media file */
|
|
|
|
if (!misc::isPreviewable(info.fname.substr(pos + 1).c_str())) return;
|
|
|
|
|
|
|
|
/* make path for downloaded or downloading files */
|
2009-07-28 11:29:21 -04:00
|
|
|
bool complete = false;
|
2009-07-05 12:27:58 -04:00
|
|
|
std::string path;
|
|
|
|
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
|
|
|
path = info.path + "/" + info.fname;
|
2009-07-28 11:29:21 -04:00
|
|
|
complete = true;
|
2009-07-05 12:27:58 -04:00
|
|
|
} else {
|
2009-07-28 11:29:21 -04:00
|
|
|
path = rsFiles->getPartialsDirectory() + "/" + info.hash;
|
2009-07-05 12:27:58 -04:00
|
|
|
}
|
2009-07-02 14:40:31 -04:00
|
|
|
|
2009-07-04 17:54:58 -04:00
|
|
|
/* open or preview them with a suitable application */
|
2009-07-28 11:29:21 -04:00
|
|
|
QFileInfo qinfo;
|
|
|
|
if (complete) {
|
|
|
|
qinfo.setFile(QString::fromStdString(path));
|
|
|
|
if (qinfo.exists()) {
|
|
|
|
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
|
|
|
std::cerr << "previewTransfer(): can't preview file " << path << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
QString linkName = QString::fromStdString(path) +
|
|
|
|
QString::fromStdString(info.fname.substr(info.fname.find_last_of('.')));
|
|
|
|
if (QFile::link(QString::fromStdString(path), linkName)) {
|
|
|
|
qinfo.setFile(linkName);
|
|
|
|
if (qinfo.exists()) {
|
|
|
|
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
|
|
|
std::cerr << "previewTransfer(): can't preview file " << path << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* wait for the file to open then remove the link */
|
|
|
|
#ifdef WIN32
|
|
|
|
Sleep(2000);
|
|
|
|
#else
|
|
|
|
sleep(2);
|
|
|
|
#endif
|
|
|
|
QFile::remove(linkName);
|
|
|
|
} else {
|
|
|
|
std::cerr << "previewTransfer(): can't create link for file " << path << std::endl;
|
2009-07-02 14:40:31 -04:00
|
|
|
}
|
|
|
|
}
|
2009-07-04 17:54:58 -04:00
|
|
|
}
|
2009-07-02 14:40:31 -04:00
|
|
|
|
2009-07-05 12:27:58 -04:00
|
|
|
void TransfersDialog::openTransfer()
|
2009-07-04 17:54:58 -04:00
|
|
|
{
|
2009-07-05 12:27:58 -04:00
|
|
|
FileInfo info;
|
2009-07-04 17:54:58 -04:00
|
|
|
|
2010-01-22 18:23:37 -05:00
|
|
|
std::set<QStandardItem *> items;
|
|
|
|
std::set<QStandardItem *>::iterator it;
|
2009-07-05 12:27:58 -04:00
|
|
|
getIdOfSelectedItems(items);
|
|
|
|
for (it = items.begin(); it != items.end(); it ++) {
|
|
|
|
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make path for downloaded or downloading files */
|
|
|
|
std::string path;
|
|
|
|
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
|
|
|
path = info.path + "/" + info.fname;
|
|
|
|
|
|
|
|
/* open file with a suitable application */
|
|
|
|
QFileInfo qinfo;
|
|
|
|
qinfo.setFile(path.c_str());
|
|
|
|
if (qinfo.exists()) {
|
|
|
|
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
|
|
|
std::cerr << "openTransfer(): can't open file " << path << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* rise a message box for incompleted download file */
|
|
|
|
QMessageBox::information(this, tr("Open Transfer"),
|
|
|
|
tr("File %1 is not completed. If it is a media file, try to preview it.").arg(info.fname.c_str()));
|
|
|
|
}
|
2009-07-02 14:40:31 -04:00
|
|
|
}
|
|
|
|
|
2009-07-27 13:22:56 -04:00
|
|
|
/* clear download or all queue - for pending dwls */
|
2010-01-26 18:25:00 -05:00
|
|
|
//void TransfersDialog::clearQueuedDwl()
|
|
|
|
//{
|
|
|
|
// std::set<QStandardItem *> items;
|
|
|
|
// std::set<QStandardItem *>::iterator it;
|
|
|
|
// getIdOfSelectedItems(items);
|
|
|
|
//
|
|
|
|
// for (it = items.begin(); it != items.end(); it ++) {
|
|
|
|
// std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
|
|
|
// rsFiles->clearDownload(hash);
|
|
|
|
// }
|
|
|
|
//}
|
2010-03-06 18:29:47 -05:00
|
|
|
//void TransfersDialog::clearQueue()
|
|
|
|
//{
|
|
|
|
// rsFiles->clearQueue();
|
|
|
|
//}
|
2009-07-27 13:22:56 -04:00
|
|
|
|
2009-12-08 17:29:52 -05:00
|
|
|
void TransfersDialog::chunkStreaming()
|
|
|
|
{
|
|
|
|
setChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_STREAMING) ;
|
|
|
|
}
|
|
|
|
void TransfersDialog::chunkRandom()
|
|
|
|
{
|
|
|
|
setChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_RANDOM) ;
|
|
|
|
}
|
|
|
|
void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
|
|
|
{
|
2010-01-22 18:23:37 -05:00
|
|
|
std::set<QStandardItem *> items;
|
|
|
|
std::set<QStandardItem *>::iterator it;
|
2009-12-08 17:29:52 -05:00
|
|
|
getIdOfSelectedItems(items);
|
|
|
|
|
|
|
|
for (it = items.begin(); it != items.end(); it ++) {
|
|
|
|
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
|
|
|
rsFiles->setChunkStrategy(hash, s);
|
|
|
|
}
|
|
|
|
}
|
2009-07-27 13:22:56 -04:00
|
|
|
/* modify download priority actions */
|
2010-01-26 18:25:00 -05:00
|
|
|
void TransfersDialog::speedSlow()
|
2009-07-27 13:22:56 -04:00
|
|
|
{
|
2010-01-26 18:25:00 -05:00
|
|
|
changeSpeed(0);
|
2009-07-27 13:22:56 -04:00
|
|
|
}
|
2010-01-26 18:25:00 -05:00
|
|
|
void TransfersDialog::speedAverage()
|
2009-07-27 13:22:56 -04:00
|
|
|
{
|
2010-01-26 18:25:00 -05:00
|
|
|
changeSpeed(1);
|
2009-07-27 13:22:56 -04:00
|
|
|
}
|
2010-01-26 18:25:00 -05:00
|
|
|
void TransfersDialog::speedFast()
|
2009-07-27 13:22:56 -04:00
|
|
|
{
|
2010-01-26 18:25:00 -05:00
|
|
|
changeSpeed(2);
|
2009-07-27 13:22:56 -04:00
|
|
|
}
|
2010-01-26 18:25:00 -05:00
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
void TransfersDialog::priorityQueueUp()
|
2009-07-27 13:22:56 -04:00
|
|
|
{
|
2010-03-06 18:29:47 -05:00
|
|
|
changeQueuePosition(QUEUE_UP);
|
2010-01-26 18:25:00 -05:00
|
|
|
}
|
2010-03-06 18:29:47 -05:00
|
|
|
void TransfersDialog::priorityQueueDown()
|
2010-01-26 18:25:00 -05:00
|
|
|
{
|
2010-03-06 18:29:47 -05:00
|
|
|
changeQueuePosition(QUEUE_DOWN);
|
2010-01-26 18:25:00 -05:00
|
|
|
}
|
2010-03-06 18:29:47 -05:00
|
|
|
void TransfersDialog::priorityQueueTop()
|
2010-01-26 18:25:00 -05:00
|
|
|
{
|
2010-03-06 18:29:47 -05:00
|
|
|
changeQueuePosition(QUEUE_TOP);
|
2010-01-26 18:25:00 -05:00
|
|
|
}
|
2010-03-06 18:29:47 -05:00
|
|
|
void TransfersDialog::priorityQueueBottom()
|
2010-01-26 18:25:00 -05:00
|
|
|
{
|
2010-03-06 18:29:47 -05:00
|
|
|
changeQueuePosition(QUEUE_BOTTOM);
|
2009-07-27 13:22:56 -04:00
|
|
|
}
|
|
|
|
|
2010-01-26 18:25:00 -05:00
|
|
|
void TransfersDialog::changeSpeed(int speed)
|
2009-07-27 13:22:56 -04:00
|
|
|
{
|
2010-01-22 18:23:37 -05:00
|
|
|
std::set<QStandardItem *> items;
|
|
|
|
std::set<QStandardItem *>::iterator it;
|
2009-07-27 13:22:56 -04:00
|
|
|
getIdOfSelectedItems(items);
|
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
for (it = items.begin(); it != items.end(); it ++)
|
|
|
|
{
|
2009-07-27 13:22:56 -04:00
|
|
|
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
2010-01-26 18:25:00 -05:00
|
|
|
rsFiles->changeDownloadSpeed(hash, speed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-06 18:29:47 -05:00
|
|
|
void TransfersDialog::changeQueuePosition(QueueMove mv)
|
2010-01-26 18:25:00 -05:00
|
|
|
{
|
2010-03-06 18:29:47 -05:00
|
|
|
std::cerr << "In changeQueuePosition (gui)"<< std::endl ;
|
2010-01-26 18:25:00 -05:00
|
|
|
std::set<QStandardItem *> items;
|
|
|
|
std::set<QStandardItem *>::iterator it;
|
|
|
|
getIdOfSelectedItems(items);
|
|
|
|
|
|
|
|
for (it = items.begin(); it != items.end(); it ++)
|
|
|
|
{
|
|
|
|
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
2010-03-06 18:29:47 -05:00
|
|
|
rsFiles->changeQueuePosition(hash, mv);
|
2009-07-27 13:22:56 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
void TransfersDialog::clearcompleted()
|
|
|
|
{
|
|
|
|
std::cerr << "TransfersDialog::clearcompleted()" << std::endl;
|
|
|
|
rsFiles->FileClearCompleted();
|
|
|
|
}
|
|
|
|
|
2009-11-17 07:45:06 -05:00
|
|
|
void TransfersDialog::showFileDetails()
|
2009-11-15 14:26:34 -05:00
|
|
|
{
|
2009-11-17 07:45:06 -05:00
|
|
|
std::string file_hash ;
|
|
|
|
int nb_select = 0 ;
|
2009-11-15 14:26:34 -05:00
|
|
|
|
2010-01-11 11:00:42 -05:00
|
|
|
std::cout << "new selection " << std::endl ;
|
|
|
|
|
2009-11-17 07:45:06 -05:00
|
|
|
for(int i = 0; i <= DLListModel->rowCount(); i++)
|
|
|
|
if(selection->isRowSelected(i, QModelIndex()))
|
|
|
|
{
|
|
|
|
file_hash = getID(i, DLListModel).toStdString();
|
|
|
|
++nb_select ;
|
|
|
|
}
|
|
|
|
if(nb_select != 1)
|
2010-01-11 11:00:42 -05:00
|
|
|
dynamic_cast<FileTransferInfoWidget*>(ui.fileTransferInfoWidget->widget())->setFileHash("") ;
|
|
|
|
else
|
|
|
|
dynamic_cast<FileTransferInfoWidget*>(ui.fileTransferInfoWidget->widget())->setFileHash(file_hash) ;
|
2009-11-17 07:45:06 -05:00
|
|
|
|
2010-01-11 11:00:42 -05:00
|
|
|
std::cout << "calling update " << std::endl ;
|
2009-11-17 07:45:06 -05:00
|
|
|
dynamic_cast<FileTransferInfoWidget*>(ui.fileTransferInfoWidget->widget())->updateDisplay() ;
|
2010-01-11 11:00:42 -05:00
|
|
|
std::cout << "done" << std::endl ;
|
2009-11-17 07:45:06 -05:00
|
|
|
}
|
2009-11-15 14:26:34 -05:00
|
|
|
|
2010-03-07 09:10:51 -05:00
|
|
|
double TransfersDialog::getProgress(int , QStandardItemModel *)
|
2008-12-12 16:42:44 -05:00
|
|
|
{
|
2010-01-11 11:00:42 -05:00
|
|
|
// return model->data(model->index(row, PROGRESS), Qt::DisplayRole).toDouble();
|
|
|
|
return 0.0 ;
|
2008-12-12 16:42:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
double TransfersDialog::getSpeed(int row, QStandardItemModel *model)
|
|
|
|
{
|
|
|
|
return model->data(model->index(row, DLSPEED), Qt::DisplayRole).toDouble();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString TransfersDialog::getFileName(int row, QStandardItemModel *model)
|
|
|
|
{
|
|
|
|
return model->data(model->index(row, NAME), Qt::DisplayRole).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString TransfersDialog::getStatus(int row, QStandardItemModel *model)
|
|
|
|
{
|
|
|
|
return model->data(model->index(row, STATUS), Qt::DisplayRole).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString TransfersDialog::getID(int row, QStandardItemModel *model)
|
|
|
|
{
|
|
|
|
return model->data(model->index(row, ID), Qt::DisplayRole).toString();
|
|
|
|
}
|
|
|
|
|
2009-08-14 16:48:53 -04:00
|
|
|
QString TransfersDialog::getPriority(int row, QStandardItemModel *model)
|
|
|
|
{
|
|
|
|
return model->data(model->index(row, PRIORITY), Qt::DisplayRole).toString();
|
|
|
|
}
|
|
|
|
|
2008-12-12 16:42:44 -05:00
|
|
|
qlonglong TransfersDialog::getFileSize(int row, QStandardItemModel *model)
|
|
|
|
{
|
|
|
|
bool ok = false;
|
|
|
|
return model->data(model->index(row, SIZE), Qt::DisplayRole).toULongLong(&ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
qlonglong TransfersDialog::getTransfered(int row, QStandardItemModel *model)
|
|
|
|
{
|
|
|
|
bool ok = false;
|
|
|
|
return model->data(model->index(row, COMPLETED), Qt::DisplayRole).toULongLong(&ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
qlonglong TransfersDialog::getRemainingTime(int row, QStandardItemModel *model)
|
|
|
|
{
|
|
|
|
bool ok = false;
|
|
|
|
return model->data(model->index(row, REMAINING), Qt::DisplayRole).toULongLong(&ok);
|
|
|
|
}
|