mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 21:34:10 -05:00
Merge pull request #1019 from PhenomRetroShare/Add_GroupedUpLoadItem
Regroup Upload Items by file in TransfersDialog.
This commit is contained in:
commit
1dc6bef985
@ -229,6 +229,8 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, temp);
|
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, temp);
|
||||||
break;
|
break;
|
||||||
case COLUMN_LASTDL:
|
case COLUMN_LASTDL:
|
||||||
|
if (index.data().value<QString>().isEmpty())
|
||||||
|
break;
|
||||||
qi64Value = index.data().value<qint64>();
|
qi64Value = index.data().value<qint64>();
|
||||||
if (qi64Value < std::numeric_limits<qint64>::max()){
|
if (qi64Value < std::numeric_limits<qint64>::max()){
|
||||||
QDateTime qdtLastDL = QDateTime::fromTime_t(qi64Value);
|
QDateTime qdtLastDL = QDateTime::fromTime_t(qi64Value);
|
||||||
|
@ -212,7 +212,6 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
DLLFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
DLLFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
ui.downloadList->setModel(DLLFilterModel);
|
ui.downloadList->setModel(DLLFilterModel);
|
||||||
|
|
||||||
//ui.downloadList->hideColumn(ID);
|
|
||||||
DLDelegate = new DLListDelegate();
|
DLDelegate = new DLListDelegate();
|
||||||
ui.downloadList->setItemDelegate(DLDelegate);
|
ui.downloadList->setItemDelegate(DLDelegate);
|
||||||
|
|
||||||
@ -238,34 +237,34 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
|
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes Downloads TreeView*/
|
/* Set header resize modes and initial section sizes Downloads TreeView*/
|
||||||
QHeaderView * _header = ui.downloadList->header () ;
|
QHeaderView * dlheader = ui.downloadList->header () ;
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_NAME, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_NAME, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_SIZE, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_SIZE, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_COMPLETED, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_COMPLETED, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_DLSPEED, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_DLSPEED, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PROGRESS, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PROGRESS, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_SOURCES, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_SOURCES, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_STATUS, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_STATUS, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PRIORITY, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PRIORITY, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_REMAINING, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_REMAINING, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_DOWNLOADTIME, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_DOWNLOADTIME, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_ID, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_ID, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_LASTDL, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_LASTDL, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PATH, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PATH, QHeaderView::Interactive);
|
||||||
|
|
||||||
_header->resizeSection ( COLUMN_NAME, 170 );
|
dlheader->resizeSection ( COLUMN_NAME, 170 );
|
||||||
_header->resizeSection ( COLUMN_SIZE, 70 );
|
dlheader->resizeSection ( COLUMN_SIZE, 70 );
|
||||||
_header->resizeSection ( COLUMN_COMPLETED, 75 );
|
dlheader->resizeSection ( COLUMN_COMPLETED, 75 );
|
||||||
_header->resizeSection ( COLUMN_DLSPEED, 75 );
|
dlheader->resizeSection ( COLUMN_DLSPEED, 75 );
|
||||||
_header->resizeSection ( COLUMN_PROGRESS, 170 );
|
dlheader->resizeSection ( COLUMN_PROGRESS, 170 );
|
||||||
_header->resizeSection ( COLUMN_SOURCES, 90 );
|
dlheader->resizeSection ( COLUMN_SOURCES, 90 );
|
||||||
_header->resizeSection ( COLUMN_STATUS, 100 );
|
dlheader->resizeSection ( COLUMN_STATUS, 100 );
|
||||||
_header->resizeSection ( COLUMN_PRIORITY, 100 );
|
dlheader->resizeSection ( COLUMN_PRIORITY, 100 );
|
||||||
_header->resizeSection ( COLUMN_REMAINING, 100 );
|
dlheader->resizeSection ( COLUMN_REMAINING, 100 );
|
||||||
_header->resizeSection ( COLUMN_DOWNLOADTIME, 100 );
|
dlheader->resizeSection ( COLUMN_DOWNLOADTIME, 100 );
|
||||||
_header->resizeSection ( COLUMN_ID, 100 );
|
dlheader->resizeSection ( COLUMN_ID, 100 );
|
||||||
_header->resizeSection ( COLUMN_LASTDL, 100 );
|
dlheader->resizeSection ( COLUMN_LASTDL, 100 );
|
||||||
_header->resizeSection ( COLUMN_PATH, 100 );
|
dlheader->resizeSection ( COLUMN_PATH, 100 );
|
||||||
|
|
||||||
// set default column and sort order for download
|
// set default column and sort order for download
|
||||||
ui.downloadList->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
|
ui.downloadList->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
|
||||||
@ -283,16 +282,13 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
ULListModel = new QStandardItemModel(0,COLUMN_UCOUNT);
|
ULListModel = new QStandardItemModel(0,COLUMN_UCOUNT);
|
||||||
ULListModel->setHeaderData(COLUMN_UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
ULListModel->setHeaderData(COLUMN_UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
||||||
ULListModel->setHeaderData(COLUMN_USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
ULListModel->setHeaderData(COLUMN_USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
||||||
ULListModel->setHeaderData(COLUMN_USERNAME, Qt::Horizontal, tr("Peer", "i.e: user name"));
|
|
||||||
ULListModel->setHeaderData(COLUMN_UPROGRESS, Qt::Horizontal, tr("Progress", "i.e: % uploaded"));
|
|
||||||
ULListModel->setHeaderData(COLUMN_ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed"));
|
|
||||||
ULListModel->setHeaderData(COLUMN_USTATUS, Qt::Horizontal, tr("Status"));
|
|
||||||
ULListModel->setHeaderData(COLUMN_UTRANSFERRED, Qt::Horizontal, tr("Transferred", ""));
|
ULListModel->setHeaderData(COLUMN_UTRANSFERRED, Qt::Horizontal, tr("Transferred", ""));
|
||||||
|
ULListModel->setHeaderData(COLUMN_ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed"));
|
||||||
|
ULListModel->setHeaderData(COLUMN_UPROGRESS, Qt::Horizontal, tr("Progress", "i.e: % uploaded"));
|
||||||
ULListModel->setHeaderData(COLUMN_UHASH, Qt::Horizontal, tr("Hash", ""));
|
ULListModel->setHeaderData(COLUMN_UHASH, Qt::Horizontal, tr("Hash", ""));
|
||||||
ULListModel->setHeaderData(COLUMN_UUSERID, Qt::Horizontal, tr("UserID", ""));
|
|
||||||
ui.uploadsList->setModel(ULListModel);
|
ui.uploadsList->setModel(ULListModel);
|
||||||
//ULListModel->insertColumn(COLUMN_UUSERID);
|
|
||||||
//ui.uploadsList->hideColumn(COLUMN_UUSERID);
|
|
||||||
ULDelegate = new ULListDelegate();
|
ULDelegate = new ULListDelegate();
|
||||||
ui.uploadsList->setItemDelegate(ULDelegate);
|
ui.uploadsList->setItemDelegate(ULDelegate);
|
||||||
|
|
||||||
@ -300,13 +296,13 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
// With disabled autoscroll, the treeview doesn't scroll with cursor move
|
// With disabled autoscroll, the treeview doesn't scroll with cursor move
|
||||||
// ui.uploadsList->setAutoScroll(false) ;
|
// ui.uploadsList->setAutoScroll(false) ;
|
||||||
|
|
||||||
ui.uploadsList->setRootIsDecorated(false);
|
|
||||||
|
|
||||||
|
|
||||||
//Selection Setup
|
//Selection Setup
|
||||||
selectionUp = ui.uploadsList->selectionModel();
|
selectionUp = ui.uploadsList->selectionModel();
|
||||||
|
|
||||||
ui.uploadsList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
ui.uploadsList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
|
||||||
|
ui.uploadsList->setRootIsDecorated(true);
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes Uploads TreeView*/
|
/* Set header resize modes and initial section sizes Uploads TreeView*/
|
||||||
QHeaderView * upheader = ui.uploadsList->header () ;
|
QHeaderView * upheader = ui.uploadsList->header () ;
|
||||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UNAME, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UNAME, QHeaderView::Interactive);
|
||||||
@ -314,29 +310,16 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UTRANSFERRED, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UTRANSFERRED, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_ULSPEED, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_ULSPEED, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UPROGRESS, QHeaderView::Interactive);
|
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UPROGRESS, QHeaderView::Interactive);
|
||||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_USTATUS, QHeaderView::Interactive);
|
|
||||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_USERNAME, QHeaderView::Interactive);
|
|
||||||
|
|
||||||
upheader->resizeSection ( COLUMN_UNAME, 260 );
|
upheader->resizeSection ( COLUMN_UNAME, 260 );
|
||||||
upheader->resizeSection ( COLUMN_USIZE, 70 );
|
upheader->resizeSection ( COLUMN_USIZE, 70 );
|
||||||
upheader->resizeSection ( COLUMN_UTRANSFERRED, 75 );
|
upheader->resizeSection ( COLUMN_UTRANSFERRED, 75 );
|
||||||
upheader->resizeSection ( COLUMN_ULSPEED, 75 );
|
upheader->resizeSection ( COLUMN_ULSPEED, 75 );
|
||||||
upheader->resizeSection ( COLUMN_UPROGRESS, 170 );
|
upheader->resizeSection ( COLUMN_UPROGRESS, 170 );
|
||||||
upheader->resizeSection ( COLUMN_USTATUS, 100 );
|
|
||||||
upheader->resizeSection ( COLUMN_USERNAME, 120 );
|
|
||||||
|
|
||||||
// set default column and sort order for upload
|
// set default column and sort order for upload
|
||||||
ui.uploadsList->sortByColumn(COLUMN_UNAME, Qt::AscendingOrder);
|
ui.uploadsList->sortByColumn(COLUMN_UNAME, Qt::AscendingOrder);
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ;
|
QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ;
|
||||||
|
|
||||||
ui.tabWidget->insertTab(2,searchDialog = new SearchDialog(), QIcon(IMAGE_SEARCH), tr("Search")) ;
|
ui.tabWidget->insertTab(2,searchDialog = new SearchDialog(), QIcon(IMAGE_SEARCH), tr("Search")) ;
|
||||||
@ -384,13 +367,13 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) );
|
connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) );
|
||||||
|
|
||||||
openFolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
|
openFolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
|
||||||
connect(openFolderAct, SIGNAL(triggered()), this, SLOT(openFolderTransfer()));
|
connect(openFolderAct, SIGNAL(triggered()), this, SLOT(dlOpenFolder()));
|
||||||
|
|
||||||
openFileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
|
openFileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
|
||||||
connect(openFileAct, SIGNAL(triggered()), this, SLOT(openTransfer()));
|
connect(openFileAct, SIGNAL(triggered()), this, SLOT(dlOpenFile()));
|
||||||
|
|
||||||
previewFileAct = new QAction(QIcon(IMAGE_PREVIEW), tr("Preview File"), this);
|
previewFileAct = new QAction(QIcon(IMAGE_PREVIEW), tr("Preview File"), this);
|
||||||
connect(previewFileAct, SIGNAL(triggered()), this, SLOT(previewTransfer()));
|
connect(previewFileAct, SIGNAL(triggered()), this, SLOT(dlPreviewFile()));
|
||||||
|
|
||||||
detailsFileAct = new QAction(QIcon(IMAGE_INFO), tr("Details..."), this);
|
detailsFileAct = new QAction(QIcon(IMAGE_INFO), tr("Details..."), this);
|
||||||
connect(detailsFileAct, SIGNAL(triggered()), this, SLOT(showDetailsDialog()));
|
connect(detailsFileAct, SIGNAL(triggered()), this, SLOT(showDetailsDialog()));
|
||||||
@ -400,7 +383,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
|
|
||||||
|
|
||||||
copyLinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link" ), this );
|
copyLinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link" ), this );
|
||||||
connect( copyLinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
|
connect( copyLinkAct , SIGNAL( triggered() ), this, SLOT( dlCopyLink() ) );
|
||||||
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() ) );
|
||||||
queueDownAct = new QAction(QIcon(":/images/go-down.png"), tr("Down"), this);
|
queueDownAct = new QAction(QIcon(":/images/go-down.png"), tr("Down"), this);
|
||||||
@ -424,7 +407,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
chunkProgressiveAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Progressive"), this);
|
chunkProgressiveAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Progressive"), this);
|
||||||
connect(chunkProgressiveAct, SIGNAL(triggered()), this, SLOT(chunkProgressive()));
|
connect(chunkProgressiveAct, SIGNAL(triggered()), this, SLOT(chunkProgressive()));
|
||||||
playAct = new QAction(QIcon(IMAGE_PLAY), tr( "Play" ), this );
|
playAct = new QAction(QIcon(IMAGE_PLAY), tr( "Play" ), this );
|
||||||
connect( playAct , SIGNAL( triggered() ), this, SLOT( openTransfer() ) );
|
connect( playAct , SIGNAL( triggered() ), this, SLOT( dlOpenFile() ) );
|
||||||
renameFileAct = new QAction(QIcon(IMAGE_RENAMEFILE), tr("Rename file..."), this);
|
renameFileAct = new QAction(QIcon(IMAGE_RENAMEFILE), tr("Rename file..."), this);
|
||||||
connect(renameFileAct, SIGNAL(triggered()), this, SLOT(renameFile()));
|
connect(renameFileAct, SIGNAL(triggered()), this, SLOT(renameFile()));
|
||||||
specifyDestinationDirectoryAct = new QAction(QIcon(IMAGE_SEARCH),tr("Specify..."),this) ;
|
specifyDestinationDirectoryAct = new QAction(QIcon(IMAGE_SEARCH),tr("Specify..."),this) ;
|
||||||
@ -610,7 +593,7 @@ void TransfersDialog::processSettings(bool bLoad)
|
|||||||
void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
|
void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
|
||||||
{
|
{
|
||||||
std::set<RsFileHash> items ;
|
std::set<RsFileHash> items ;
|
||||||
getSelectedItems(&items, NULL) ;
|
getDLSelectedItems(&items, NULL) ;
|
||||||
|
|
||||||
bool single = (items.size() == 1) ;
|
bool single = (items.size() == 1) ;
|
||||||
|
|
||||||
@ -847,27 +830,16 @@ void TransfersDialog::downloadListHeaderCustomPopupMenu( QPoint /*point*/ )
|
|||||||
|
|
||||||
void TransfersDialog::uploadsListCustomPopupMenu( QPoint /*point*/ )
|
void TransfersDialog::uploadsListCustomPopupMenu( QPoint /*point*/ )
|
||||||
{
|
{
|
||||||
std::cerr << "TransfersDialog::uploadsListCustomPopupMenu()" << std::endl;
|
|
||||||
|
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
getULSelectedItems(&items, NULL);
|
getULSelectedItems(&items, NULL);
|
||||||
|
|
||||||
bool single = (items.size() == 1);
|
bool single = (items.size() == 1);
|
||||||
|
|
||||||
bool add_CopyLink = false;
|
bool add_CopyLink = !items.empty();
|
||||||
|
|
||||||
QMenu contextMnu( this );
|
QMenu contextMnu( this );
|
||||||
|
|
||||||
if(!items.empty())
|
|
||||||
{
|
|
||||||
add_CopyLink = true;
|
|
||||||
|
|
||||||
}//if(!items.empty())
|
|
||||||
|
|
||||||
if(single)
|
if(single)
|
||||||
{
|
|
||||||
contextMnu.addAction( ulOpenFolderAct);
|
contextMnu.addAction( ulOpenFolderAct);
|
||||||
}
|
|
||||||
|
|
||||||
if (add_CopyLink)
|
if (add_CopyLink)
|
||||||
contextMnu.addAction( ulCopyLinkAct);
|
contextMnu.addAction( ulCopyLinkAct);
|
||||||
@ -883,7 +855,7 @@ void TransfersDialog::chooseDestinationDirectory()
|
|||||||
return ;
|
return ;
|
||||||
|
|
||||||
std::set<RsFileHash> items ;
|
std::set<RsFileHash> items ;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for(std::set<RsFileHash>::const_iterator it(items.begin());it!=items.end();++it)
|
for(std::set<RsFileHash>::const_iterator it(items.begin());it!=items.end();++it)
|
||||||
{
|
{
|
||||||
@ -896,7 +868,7 @@ void TransfersDialog::setDestinationDirectory()
|
|||||||
std::string dest_dir(qobject_cast<QAction*>(sender())->data().toString().toUtf8().data()) ;
|
std::string dest_dir(qobject_cast<QAction*>(sender())->data().toString().toUtf8().data()) ;
|
||||||
|
|
||||||
std::set<RsFileHash> items ;
|
std::set<RsFileHash> items ;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for(std::set<RsFileHash>::const_iterator it(items.begin());it!=items.end();++it)
|
for(std::set<RsFileHash>::const_iterator it(items.begin());it!=items.end();++it)
|
||||||
{
|
{
|
||||||
@ -905,7 +877,7 @@ void TransfersDialog::setDestinationDirectory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TransfersDialog::addItem(int row, const FileInfo &fileInfo)
|
int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
|
||||||
{
|
{
|
||||||
QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
|
QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
|
||||||
double fileDlspeed = (fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0;
|
double fileDlspeed = (fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0;
|
||||||
@ -958,7 +930,6 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo)
|
|||||||
QString strPath = QString::fromUtf8(fileInfo.path.c_str());
|
QString strPath = QString::fromUtf8(fileInfo.path.c_str());
|
||||||
QString strPathAfterDL = strPath;
|
QString strPathAfterDL = strPath;
|
||||||
strPathAfterDL.replace(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()),"");
|
strPathAfterDL.replace(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()),"");
|
||||||
QStringList qslPath = strPathAfterDL.split("/");
|
|
||||||
|
|
||||||
FileChunksInfo fcinfo;
|
FileChunksInfo fcinfo;
|
||||||
if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo)) {
|
if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo)) {
|
||||||
@ -1020,25 +991,18 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo)
|
|||||||
|
|
||||||
QStandardItem *dlItem = DLListModel->item(row);
|
QStandardItem *dlItem = DLListModel->item(row);
|
||||||
|
|
||||||
std::map<std::string, std::string>::const_iterator vit;
|
|
||||||
|
|
||||||
std::set<int> used_rows ;
|
std::set<int> used_rows ;
|
||||||
int active = 0;
|
int active = 0;
|
||||||
|
|
||||||
if (fileInfo.downloadStatus != FT_STATE_COMPLETE) {
|
if (fileInfo.downloadStatus != FT_STATE_COMPLETE) {
|
||||||
std::list<TransferInfo>::const_iterator pit;
|
for (std::list<TransferInfo>::const_iterator pit = fileInfo.peers.begin()
|
||||||
for (pit = fileInfo.peers.begin(); pit != fileInfo.peers.end(); ++pit) {
|
; pit != fileInfo.peers.end(); ++pit)
|
||||||
|
{
|
||||||
const TransferInfo &transferInfo = *pit;
|
const TransferInfo &transferInfo = *pit;
|
||||||
|
|
||||||
QString peerName = getPeerName(transferInfo.peerId);
|
QString peerName = getPeerName(transferInfo.peerId);
|
||||||
//unique combination: fileHash + peerId, variant: hash + peerName (too long)
|
//unique combination: fileHash + peerId, variant: hash + peerName (too long)
|
||||||
QString hashFileAndPeerId = fileHash + QString::fromStdString(transferInfo.peerId.toStdString());
|
QString hashFileAndPeerId = fileHash + QString::fromStdString(transferInfo.peerId.toStdString());
|
||||||
QString version;
|
|
||||||
std::string rsversion;
|
|
||||||
if (rsDisc->getPeerVersion(transferInfo.peerId, rsversion))
|
|
||||||
{
|
|
||||||
version = tr("version:")+" " + QString::fromStdString(rsversion);
|
|
||||||
}
|
|
||||||
|
|
||||||
double peerDlspeed = 0;
|
double peerDlspeed = 0;
|
||||||
if ((uint32_t)transferInfo.status == FT_STATE_DOWNLOADING && fileInfo.downloadStatus != FT_STATE_PAUSED && fileInfo.downloadStatus != FT_STATE_COMPLETE)
|
if ((uint32_t)transferInfo.status == FT_STATE_DOWNLOADING && fileInfo.downloadStatus != FT_STATE_PAUSED && fileInfo.downloadStatus != FT_STATE_COMPLETE)
|
||||||
@ -1050,7 +1014,7 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo)
|
|||||||
peerpinfo.progress = 0.0; // we don't display completion for sources.
|
peerpinfo.progress = 0.0; // we don't display completion for sources.
|
||||||
peerpinfo.nb_chunks = peerpinfo.cmap._map.empty() ? 0 : fcinfo.chunks.size();
|
peerpinfo.nb_chunks = peerpinfo.cmap._map.empty() ? 0 : fcinfo.chunks.size();
|
||||||
|
|
||||||
int row_id = addPeerToItem(dlItem, peerName, hashFileAndPeerId, peerDlspeed, transferInfo.status, peerpinfo);
|
int row_id = addPeerToDLItem(dlItem, peerName, hashFileAndPeerId, peerDlspeed, transferInfo.status, peerpinfo);
|
||||||
|
|
||||||
used_rows.insert(row_id);
|
used_rows.insert(row_id);
|
||||||
|
|
||||||
@ -1073,17 +1037,15 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TransfersDialog::addPeerToItem(QStandardItem *dlItem, const QString& name, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo)
|
int TransfersDialog::addPeerToDLItem(QStandardItem *dlItem, const QString& name, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo)
|
||||||
{
|
{
|
||||||
// try to find the item
|
// try to find the item
|
||||||
int childRow = -1;
|
int childRow = -1;
|
||||||
int count = 0;
|
|
||||||
QStandardItem *childId = NULL;
|
|
||||||
|
|
||||||
for (count = 0; (childId = dlItem->child(count, COLUMN_ID)) != NULL; ++count) {
|
QStandardItem *childId = NULL;
|
||||||
|
for (int count = 0; (childId = dlItem->child(count, COLUMN_ID)) != NULL; ++count) {
|
||||||
if (childId->data(Qt::UserRole).toString() == coreID) {
|
if (childId->data(Qt::UserRole).toString() == coreID) {
|
||||||
childRow = count;
|
childRow = count;
|
||||||
break;
|
break;
|
||||||
@ -1099,17 +1061,19 @@ int TransfersDialog::addPeerToItem(QStandardItem *dlItem, const QString& name, c
|
|||||||
|
|
||||||
QHeaderView *header = ui.downloadList->header();
|
QHeaderView *header = ui.downloadList->header();
|
||||||
|
|
||||||
QStandardItem *iName = new QStandardItem();
|
QStandardItem *iName = new QStandardItem(); //COLUMN_NAME
|
||||||
QStandardItem *iSize = new SortByNameItem(header);
|
QStandardItem *iSize = new SortByNameItem(header); //COLUMN_SIZE
|
||||||
QStandardItem *iCompleted = new SortByNameItem(header);
|
QStandardItem *iCompleted = new SortByNameItem(header); //COLUMN_COMPLETED
|
||||||
QStandardItem *iDlSpeed = new SortByNameItem(header);
|
QStandardItem *iDlSpeed = new SortByNameItem(header); //COLUMN_DLSPEED
|
||||||
QStandardItem *iProgress = new ProgressItem(header);
|
QStandardItem *iProgress = new ProgressItem(header); //COLUMN_PROGRESS
|
||||||
QStandardItem *iSource = new SortByNameItem(header);
|
QStandardItem *iSource = new SortByNameItem(header); //COLUMN_SOURCES
|
||||||
QStandardItem *iStatus = new SortByNameItem(header);
|
QStandardItem *iStatus = new SortByNameItem(header); //COLUMN_STATUS
|
||||||
QStandardItem *iPriority = new SortByNameItem(header);
|
QStandardItem *iPriority = new SortByNameItem(header); //COLUMN_PRIORITY
|
||||||
QStandardItem *iRemaining = new SortByNameItem(header);
|
QStandardItem *iRemaining = new SortByNameItem(header); //COLUMN_REMAINING
|
||||||
QStandardItem *iDownloadTime = new SortByNameItem(header);
|
QStandardItem *iDownloadTime = new SortByNameItem(header); //COLUMN_DOWNLOADTIME
|
||||||
QStandardItem *iID = new SortByNameItem(header);
|
QStandardItem *iID = new SortByNameItem(header); //COLUMN_ID
|
||||||
|
QStandardItem *iLastDL = new SortByNameItem(header); //COLUMN_LASTDL
|
||||||
|
QStandardItem *iPath = new SortByNameItem(header); //COLUMN_PATH
|
||||||
|
|
||||||
siName = iName;
|
siName = iName;
|
||||||
siStatus = iStatus;
|
siStatus = iStatus;
|
||||||
@ -1127,6 +1091,8 @@ int TransfersDialog::addPeerToItem(QStandardItem *dlItem, const QString& name, c
|
|||||||
iDownloadTime->setData(QVariant(QString()), Qt::DisplayRole);
|
iDownloadTime->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
iID->setData(QVariant() , Qt::DisplayRole);
|
iID->setData(QVariant() , Qt::DisplayRole);
|
||||||
iID->setData(QVariant(coreID), Qt::UserRole);
|
iID->setData(QVariant(coreID), Qt::UserRole);
|
||||||
|
iLastDL->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
|
iPath->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
|
|
||||||
items.append(iName);
|
items.append(iName);
|
||||||
items.append(iSize);
|
items.append(iSize);
|
||||||
@ -1139,6 +1105,8 @@ int TransfersDialog::addPeerToItem(QStandardItem *dlItem, const QString& name, c
|
|||||||
items.append(iRemaining);
|
items.append(iRemaining);
|
||||||
items.append(iDownloadTime);
|
items.append(iDownloadTime);
|
||||||
items.append(iID);
|
items.append(iID);
|
||||||
|
items.append(iLastDL);
|
||||||
|
items.append(iPath);
|
||||||
dlItem->appendRow(items);
|
dlItem->appendRow(items);
|
||||||
|
|
||||||
childRow = dlItem->rowCount() - 1;
|
childRow = dlItem->rowCount() - 1;
|
||||||
@ -1180,43 +1148,150 @@ int TransfersDialog::addPeerToItem(QStandardItem *dlItem, const QString& name, c
|
|||||||
return childRow;
|
return childRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TransfersDialog::addUploadItem( const QString&, const QString& name, const QString& coreID,
|
int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
|
||||||
qlonglong fileSize, const FileProgressInfo& pinfo, double dlspeed,
|
|
||||||
const QString& source, const QString& peer_id, const QString& status, qlonglong completed, qlonglong)
|
|
||||||
{
|
{
|
||||||
// Find items does not work reliably, because it (apparently) needs Qt to flush pending events to work, so we can't call it
|
QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
|
||||||
// on a table that was just filled in.
|
|
||||||
//
|
|
||||||
int row ;
|
|
||||||
for(row=0;row<ULListModel->rowCount();++row)
|
|
||||||
if(ULListModel->item(row,COLUMN_UUSERID)->data(Qt::EditRole).toString() == peer_id && ULListModel->item(row,COLUMN_UHASH)->data(Qt::EditRole).toString() == coreID)
|
|
||||||
break ;
|
|
||||||
|
|
||||||
if(row >= ULListModel->rowCount() )
|
RsPeerId ownId = rsPeers->getOwnId();
|
||||||
|
|
||||||
|
QString fileName = QString::fromUtf8(fileInfo.fname.c_str());
|
||||||
|
qlonglong fileSize = fileInfo.size;
|
||||||
|
|
||||||
|
if(row < 0 )
|
||||||
{
|
{
|
||||||
row = ULListModel->rowCount();
|
row = ULListModel->rowCount();
|
||||||
ULListModel->insertRow(row);
|
ULListModel->insertRow(row);
|
||||||
|
|
||||||
// change progress column to own class for sorting
|
// change progress column to own class for sorting
|
||||||
ULListModel->setItem(row, COLUMN_UPROGRESS, new ProgressItem(NULL));
|
//ULListModel->setItem(row, COLUMN_UPROGRESS, new ProgressItem(NULL));
|
||||||
|
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), QVariant((QString)" "+name), Qt::DisplayRole);
|
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), fileName);
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_USERNAME), QVariant((QString)source));
|
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), FilesDefs::getIconFromFilename(fileName), Qt::DecorationRole);
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), QVariant((QString)coreID));
|
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash);
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UUSERID), QVariant((QString)peer_id));
|
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash, Qt::UserRole);
|
||||||
|
|
||||||
ULListModel->setData(ULListModel->index(row,COLUMN_UNAME), FilesDefs::getIconFromFilename(name), Qt::DecorationRole);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_USIZE), QVariant((qlonglong)fileSize));
|
ULListModel->setData(ULListModel->index(row, COLUMN_USIZE), QVariant((qlonglong)fileSize));
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant((qlonglong)completed));
|
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_ULSPEED), QVariant((double)dlspeed));
|
QStandardItem *ulItem = ULListModel->item(row);
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant::fromValue(pinfo));
|
std::set<int> used_rows ;
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_USTATUS), QVariant((QString)status));
|
double peerULSpeedTotal = 0;
|
||||||
|
|
||||||
|
for(std::list<TransferInfo>::const_iterator pit = fileInfo.peers.begin()
|
||||||
|
; pit != fileInfo.peers.end(); ++pit)
|
||||||
|
{
|
||||||
|
const TransferInfo &transferInfo = *pit;
|
||||||
|
|
||||||
|
if (transferInfo.peerId == ownId) //don't display transfer to ourselves
|
||||||
|
continue ;
|
||||||
|
|
||||||
|
//unique combination: fileHash + peerId, variant: hash + peerName (too long)
|
||||||
|
QString hashFileAndPeerId = fileHash + QString::fromStdString(transferInfo.peerId.toStdString());
|
||||||
|
qlonglong completed = transferInfo.transfered;
|
||||||
|
|
||||||
|
double peerULSpeed = transferInfo.tfRate * 1024.0;
|
||||||
|
|
||||||
|
FileProgressInfo peerpinfo ;
|
||||||
|
if(!rsFiles->FileUploadChunksDetails(fileInfo.hash, transferInfo.peerId, peerpinfo.cmap) )
|
||||||
|
continue ;
|
||||||
|
|
||||||
|
// 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)((fileInfo.size + (uint64_t)chunk_size - 1) / (uint64_t)(chunk_size)) ;
|
||||||
|
|
||||||
|
uint32_t filled_chunks = peerpinfo.cmap.filledChunks(nb_chunks) ;
|
||||||
|
peerpinfo.type = FileProgressInfo::UPLOAD_LINE ;
|
||||||
|
peerpinfo.nb_chunks = peerpinfo.cmap._map.empty()?0:nb_chunks ;
|
||||||
|
|
||||||
|
if(filled_chunks > 0 && nb_chunks > 0)
|
||||||
|
{
|
||||||
|
completed = peerpinfo.cmap.computeProgress(fileInfo.size,chunk_size) ;
|
||||||
|
peerpinfo.progress = completed / (float)fileInfo.size * 100.0f ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
completed = transferInfo.transfered % chunk_size ; // use the position with respect to last request.
|
||||||
|
peerpinfo.progress = (fileInfo.size>0)?((transferInfo.transfered % chunk_size)*100.0/fileInfo.size):0 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int row_id = addPeerToULItem(ulItem, transferInfo.peerId, hashFileAndPeerId, completed, peerULSpeed, peerpinfo);
|
||||||
|
|
||||||
|
used_rows.insert(row_id);
|
||||||
|
peerULSpeedTotal += peerULSpeed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Parent UpLoad Speed
|
||||||
|
ULListModel->setData(ULListModel->index(row, COLUMN_ULSPEED), QVariant((double)peerULSpeedTotal));
|
||||||
|
|
||||||
|
|
||||||
|
// 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 = ulItem->rowCount() - 1; r >= 0; --r) {
|
||||||
|
if (used_rows.find(r) == used_rows.end()) {
|
||||||
|
ulItem->removeRow(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TransfersDialog::addPeerToULItem(QStandardItem *ulItem, const RsPeerId& peer_ID, const QString& coreID, qlonglong completed, double ulspeed, const FileProgressInfo& peerInfo)
|
||||||
|
{
|
||||||
|
// try to find the item
|
||||||
|
int childRow = -1;
|
||||||
|
|
||||||
|
QStandardItem *childId = NULL;
|
||||||
|
for (int count = 0; (childId = ulItem->child(count, COLUMN_UHASH)) != NULL; ++count) {
|
||||||
|
if (childId->data(Qt::UserRole).toString() == coreID) {
|
||||||
|
childRow = count;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (childRow == -1) {
|
||||||
|
// set this false if you want to expand on double click
|
||||||
|
ulItem->setEditable(false);
|
||||||
|
|
||||||
|
QHeaderView *header = ui.uploadsList->header();
|
||||||
|
|
||||||
|
QStandardItem *iName = new QStandardItem(); //COLUMN_UNAME
|
||||||
|
QStandardItem *iSize = new SortByNameItem(header); //COLUMN_USIZE
|
||||||
|
QStandardItem *iTransferred = new SortByNameItem(header); //COLUMN_UTRANSFERRED
|
||||||
|
QStandardItem *iULSpeed = new SortByNameItem(header); //COLUMN_ULSPEED
|
||||||
|
QStandardItem *iProgress = new ProgressItem(header); //COLUMN_UPROGRESS
|
||||||
|
QStandardItem *iHash = new SortByNameItem(header); //COLUMN_UHASH
|
||||||
|
|
||||||
|
QList<QStandardItem*> items;
|
||||||
|
iName->setData( QVariant(getPeerName(peer_ID)), Qt::DisplayRole);
|
||||||
|
iSize->setData( QVariant(QString()), Qt::DisplayRole);
|
||||||
|
iTransferred->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
|
||||||
|
iULSpeed->setData( QVariant((double)ulspeed), Qt::DisplayRole);
|
||||||
|
iProgress->setData( QVariant::fromValue(peerInfo), Qt::DisplayRole);
|
||||||
|
iHash->setData( QVariant(), Qt::DisplayRole);
|
||||||
|
iHash->setData( QVariant(coreID), Qt::UserRole);
|
||||||
|
|
||||||
|
items.append(iName);
|
||||||
|
items.append(iSize);
|
||||||
|
items.append(iTransferred);
|
||||||
|
items.append(iULSpeed);
|
||||||
|
items.append(iProgress);
|
||||||
|
items.append(iHash);
|
||||||
|
ulItem->appendRow(items);
|
||||||
|
|
||||||
|
childRow = ulItem->rowCount() - 1;
|
||||||
|
} else {
|
||||||
|
// just update the child (peer)
|
||||||
|
ulItem->child(childRow, COLUMN_ULSPEED)->setData(QVariant((double)ulspeed), Qt::DisplayRole);
|
||||||
|
ulItem->child(childRow, COLUMN_UTRANSFERRED)->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
|
||||||
|
ulItem->child(childRow, COLUMN_UPROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
return childRow;
|
||||||
|
}
|
||||||
|
|
||||||
/* get the list of Transfers from the RsIface. **/
|
/* get the list of Transfers from the RsIface. **/
|
||||||
void TransfersDialog::updateDisplay()
|
void TransfersDialog::updateDisplay()
|
||||||
@ -1236,21 +1311,19 @@ void TransfersDialog::insertTransfers()
|
|||||||
|
|
||||||
/* build set for quick search */
|
/* build set for quick search */
|
||||||
std::set<RsFileHash> hashs;
|
std::set<RsFileHash> hashs;
|
||||||
std::list<RsFileHash>::iterator it;
|
|
||||||
for (it = downHashes.begin(); it != downHashes.end(); ++it) {
|
for (std::list<RsFileHash>::iterator it = downHashes.begin(); it != downHashes.end(); ++it) {
|
||||||
hashs.insert(*it);
|
hashs.insert(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add downloads, first iterate all rows in list */
|
/* add downloads, first iterate all rows in list */
|
||||||
|
|
||||||
int rowCount = DLListModel->rowCount();
|
int rowCount = DLListModel->rowCount();
|
||||||
int row ;
|
|
||||||
std::set<RsFileHash>::iterator hashIt;
|
|
||||||
|
|
||||||
for (row = 0; row < rowCount; ) {
|
for (int row = 0; row < rowCount; ) {
|
||||||
RsFileHash hash ( DLListModel->item(row, COLUMN_ID)->data(Qt::UserRole).toString().toStdString());
|
RsFileHash hash ( DLListModel->item(row, COLUMN_ID)->data(Qt::UserRole).toString().toStdString());
|
||||||
|
|
||||||
hashIt = hashs.find(hash);
|
std::set<RsFileHash>::iterator hashIt = hashs.find(hash);
|
||||||
if (hashIt == hashs.end()) {
|
if (hashIt == hashs.end()) {
|
||||||
// remove not existing downloads
|
// remove not existing downloads
|
||||||
DLListModel->removeRow(row);
|
DLListModel->removeRow(row);
|
||||||
@ -1267,7 +1340,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
|
|
||||||
hashs.erase(hashIt);
|
hashs.erase(hashIt);
|
||||||
|
|
||||||
if (addItem(row, fileInfo) < 0) {
|
if (addDLItem(row, fileInfo) < 0) {
|
||||||
DLListModel->removeRow(row);
|
DLListModel->removeRow(row);
|
||||||
rowCount = DLListModel->rowCount();
|
rowCount = DLListModel->rowCount();
|
||||||
continue;
|
continue;
|
||||||
@ -1278,109 +1351,80 @@ void TransfersDialog::insertTransfers()
|
|||||||
|
|
||||||
/* then add new downloads to the list */
|
/* then add new downloads to the list */
|
||||||
|
|
||||||
for (hashIt = hashs.begin(); hashIt != hashs.end(); ++hashIt) {
|
for (std::set<RsFileHash>::iterator hashIt = hashs.begin()
|
||||||
|
; hashIt != hashs.end(); ++hashIt)
|
||||||
|
{
|
||||||
FileInfo fileInfo;
|
FileInfo fileInfo;
|
||||||
if (!rsFiles->FileDetails(*hashIt, RS_FILE_HINTS_DOWNLOAD, fileInfo)) {
|
if (!rsFiles->FileDetails(*hashIt, RS_FILE_HINTS_DOWNLOAD, fileInfo)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
addItem(-1, fileInfo);
|
addDLItem(-1, fileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.downloadList->setSortingEnabled(true);
|
ui.downloadList->setSortingEnabled(true);
|
||||||
|
|
||||||
ui.uploadsList->setSortingEnabled(false);
|
|
||||||
|
|
||||||
// Now show upload hashes
|
// Now show upload hashes
|
||||||
//
|
//
|
||||||
|
|
||||||
|
/* disable for performance issues, enable after insert all transfers */
|
||||||
|
ui.uploadsList->setSortingEnabled(false);
|
||||||
|
|
||||||
|
/* get the upload lists */
|
||||||
std::list<RsFileHash> upHashes;
|
std::list<RsFileHash> upHashes;
|
||||||
rsFiles->FileUploads(upHashes);
|
rsFiles->FileUploads(upHashes);
|
||||||
|
|
||||||
RsPeerId ownId = rsPeers->getOwnId();
|
/* build set for quick search */
|
||||||
|
hashs.clear();
|
||||||
|
|
||||||
std::set<std::string> used_hashes ;
|
for(std::list<RsFileHash>::iterator it = upHashes.begin(); it != upHashes.end(); ++it) {
|
||||||
|
hashs.insert(*it);
|
||||||
|
}
|
||||||
|
|
||||||
for(it = upHashes.begin(); it != upHashes.end(); ++it)
|
/* add uploads, first iterate all rows in list */
|
||||||
{
|
|
||||||
FileInfo info;
|
rowCount = ULListModel->rowCount();
|
||||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info))
|
|
||||||
|
for (int row = 0; row < rowCount; ) {
|
||||||
|
RsFileHash hash ( ULListModel->item(row, COLUMN_UHASH)->data(Qt::UserRole).toString().toStdString());
|
||||||
|
|
||||||
|
std::set<RsFileHash>::iterator hashIt = hashs.find(hash);
|
||||||
|
if (hashIt == hashs.end()) {
|
||||||
|
// remove not existing uploads
|
||||||
|
ULListModel->removeRow(row);
|
||||||
|
rowCount = ULListModel->rowCount();
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::list<TransferInfo>::iterator pit;
|
|
||||||
for(pit = info.peers.begin(); pit != info.peers.end(); ++pit)
|
|
||||||
{
|
|
||||||
if (pit->peerId == ownId) //don't display transfer to ourselves
|
|
||||||
continue ;
|
|
||||||
|
|
||||||
QString fileHash = QString::fromStdString(info.hash.toStdString());
|
|
||||||
QString fileName = QString::fromUtf8(info.fname.c_str());
|
|
||||||
QString source = 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 ;
|
FileInfo fileInfo;
|
||||||
|
if (!rsFiles->FileDetails(hash, RS_FILE_HINTS_UPLOAD, fileInfo)) {
|
||||||
if(!rsFiles->FileUploadChunksDetails(*it,pit->peerId,pinfo.cmap) )
|
ULListModel->removeRow(row);
|
||||||
continue ;
|
|
||||||
|
|
||||||
double dlspeed = pit->tfRate * 1024.0;
|
|
||||||
qlonglong fileSize = info.size;
|
|
||||||
qlonglong completed = pit->transfered;
|
|
||||||
// double progress = (info.size > 0)?(pit->transfered * 100.0 / info.size):0.0;
|
|
||||||
qlonglong remaining = (pit->tfRate>0)?((info.size - pit->transfered) / (pit->tfRate * 1024.0)):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 - 1) / (uint64_t)(chunk_size)) ;
|
|
||||||
|
|
||||||
uint32_t filled_chunks = pinfo.cmap.filledChunks(nb_chunks) ;
|
|
||||||
pinfo.type = FileProgressInfo::UPLOAD_LINE ;
|
|
||||||
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:nb_chunks ;
|
|
||||||
|
|
||||||
if(filled_chunks > 0 && nb_chunks > 0)
|
|
||||||
{
|
|
||||||
completed = pinfo.cmap.computeProgress(info.size,chunk_size) ;
|
|
||||||
pinfo.progress = completed / (float)info.size * 100.0f ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
completed = pit->transfered % chunk_size ; // use the position with respect to last request.
|
|
||||||
pinfo.progress = (info.size>0)?((pit->transfered % chunk_size)*100.0/info.size):0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
addUploadItem("", fileName, fileHash, fileSize, pinfo, dlspeed, source,QString::fromStdString(pit->peerId.toStdString()), status, completed, remaining);
|
|
||||||
|
|
||||||
used_hashes.insert(fileHash.toStdString() + pit->peerId.toStdString()) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove hashes that where not shown
|
|
||||||
//first clean the model in case some files are not download anymore
|
|
||||||
//remove items that are not fiends anymore
|
|
||||||
int removeIndex = 0;
|
|
||||||
rowCount = ULListModel->rowCount();
|
rowCount = ULListModel->rowCount();
|
||||||
while (removeIndex < rowCount)
|
continue;
|
||||||
{
|
}
|
||||||
std::string hash = ULListModel->item(removeIndex, COLUMN_UHASH)->data(Qt::EditRole).toString().toStdString();
|
|
||||||
std::string peer = ULListModel->item(removeIndex, COLUMN_UUSERID)->data(Qt::EditRole).toString().toStdString();
|
|
||||||
|
|
||||||
if(used_hashes.find(hash + peer) == used_hashes.end()) {
|
hashs.erase(hashIt);
|
||||||
ULListModel->removeRow(removeIndex);
|
|
||||||
|
if (addULItem(row, fileInfo) < 0) {
|
||||||
|
ULListModel->removeRow(row);
|
||||||
rowCount = ULListModel->rowCount();
|
rowCount = ULListModel->rowCount();
|
||||||
} else
|
continue;
|
||||||
++removeIndex;
|
}
|
||||||
|
|
||||||
|
++row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* then add new uploads to the list */
|
||||||
|
|
||||||
|
for (std::set<RsFileHash>::iterator hashIt = hashs.begin()
|
||||||
|
; hashIt != hashs.end(); ++hashIt)
|
||||||
|
{
|
||||||
|
FileInfo fileInfo;
|
||||||
|
if (!rsFiles->FileDetails(*hashIt, RS_FILE_HINTS_UPLOAD, fileInfo)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
addULItem(-1, fileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.uploadsList->setSortingEnabled(true);
|
ui.uploadsList->setSortingEnabled(true);
|
||||||
@ -1423,7 +1467,7 @@ void TransfersDialog::cancel()
|
|||||||
|
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
for (it = items.begin(); it != items.end(); ++it) {
|
for (it = items.begin(); it != items.end(); ++it) {
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
@ -1464,13 +1508,13 @@ void TransfersDialog::cancel()
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void TransfersDialog::copyLink ()
|
void TransfersDialog::dlCopyLink ()
|
||||||
{
|
{
|
||||||
QList<RetroShareLink> links ;
|
QList<RetroShareLink> links ;
|
||||||
|
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); ++it) {
|
for (it = items.begin(); it != items.end(); ++it) {
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
@ -1527,7 +1571,7 @@ void TransfersDialog::showDetailsDialog()
|
|||||||
void TransfersDialog::updateDetailsDialog()
|
void TransfersDialog::updateDetailsDialog()
|
||||||
{
|
{
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
if (!items.empty())
|
if (!items.empty())
|
||||||
detailsDialog()->setFileHash(*items.begin());
|
detailsDialog()->setFileHash(*items.begin());
|
||||||
@ -1538,7 +1582,7 @@ void TransfersDialog::pasteLink()
|
|||||||
RSLinkClipboard::process(RetroShareLink::TYPE_FILE);
|
RSLinkClipboard::process(RetroShareLink::TYPE_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::getSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows)
|
void TransfersDialog::getDLSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows)
|
||||||
{
|
{
|
||||||
if (ids == NULL && rows == NULL) {
|
if (ids == NULL && rows == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -1598,7 +1642,7 @@ bool TransfersDialog::controlTransferFile(uint32_t flags)
|
|||||||
|
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
for (it = items.begin(); it != items.end(); ++it) {
|
for (it = items.begin(); it != items.end(); ++it) {
|
||||||
result &= rsFiles->FileControl(*it, flags);
|
result &= rsFiles->FileControl(*it, flags);
|
||||||
}
|
}
|
||||||
@ -1622,13 +1666,13 @@ void TransfersDialog::resumeFileTransfer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::openFolderTransfer()
|
void TransfersDialog::dlOpenFolder()
|
||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
for (it = items.begin(); it != items.end(); ++it) {
|
for (it = items.begin(); it != items.end(); ++it) {
|
||||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
break;
|
break;
|
||||||
@ -1647,7 +1691,7 @@ void TransfersDialog::openFolderTransfer()
|
|||||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||||
if (qinfo.exists() && qinfo.isDir()) {
|
if (qinfo.exists() && qinfo.isDir()) {
|
||||||
if (!RsUrlHandler::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
if (!RsUrlHandler::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
||||||
std::cerr << "openFolderTransfer(): can't open folder " << path << std::endl;
|
std::cerr << "dlOpenFolder(): can't open folder " << path << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1679,13 +1723,13 @@ void TransfersDialog::ulOpenFolder()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::previewTransfer()
|
void TransfersDialog::dlPreviewFile()
|
||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
for (it = items.begin(); it != items.end(); ++it) {
|
for (it = items.begin(); it != items.end(); ++it) {
|
||||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
break;
|
break;
|
||||||
@ -1749,13 +1793,13 @@ void TransfersDialog::previewTransfer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::openTransfer()
|
void TransfersDialog::dlOpenFile()
|
||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
std::set<RsFileHash> items ;
|
std::set<RsFileHash> items ;
|
||||||
std::set<RsFileHash>::iterator it ;
|
std::set<RsFileHash>::iterator it ;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
for (it = items.begin(); it != items.end(); ++it) {
|
for (it = items.begin(); it != items.end(); ++it) {
|
||||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
break;
|
break;
|
||||||
@ -1814,7 +1858,7 @@ void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
|||||||
{
|
{
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); ++it) {
|
for (it = items.begin(); it != items.end(); ++it) {
|
||||||
rsFiles->setChunkStrategy(*it, s);
|
rsFiles->setChunkStrategy(*it, s);
|
||||||
@ -1855,7 +1899,7 @@ void TransfersDialog::changeSpeed(int speed)
|
|||||||
{
|
{
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); ++it)
|
for (it = items.begin(); it != items.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -1884,7 +1928,7 @@ static bool checkFileName(const QString& name)
|
|||||||
void TransfersDialog::renameFile()
|
void TransfersDialog::renameFile()
|
||||||
{
|
{
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
if(items.size() != 1)
|
if(items.size() != 1)
|
||||||
{
|
{
|
||||||
@ -1920,7 +1964,7 @@ void TransfersDialog::changeQueuePosition(QueueMove mv)
|
|||||||
// std::cerr << "In changeQueuePosition (gui)"<< std::endl ;
|
// std::cerr << "In changeQueuePosition (gui)"<< std::endl ;
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); ++it)
|
for (it = items.begin(); it != items.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -1937,7 +1981,7 @@ void TransfersDialog::clearcompleted()
|
|||||||
void TransfersDialog::showFileDetails()
|
void TransfersDialog::showFileDetails()
|
||||||
{
|
{
|
||||||
std::set<RsFileHash> items ;
|
std::set<RsFileHash> items ;
|
||||||
getSelectedItems(&items, NULL) ;
|
getDLSelectedItems(&items, NULL) ;
|
||||||
if(items.size() != 1)
|
if(items.size() != 1)
|
||||||
detailsDialog()->setFileHash(RsFileHash());
|
detailsDialog()->setFileHash(RsFileHash());
|
||||||
else
|
else
|
||||||
@ -2031,7 +2075,7 @@ void TransfersDialog::collCreate()
|
|||||||
|
|
||||||
std::set<RsFileHash> items ;
|
std::set<RsFileHash> items ;
|
||||||
std::set<RsFileHash>::iterator it ;
|
std::set<RsFileHash>::iterator it ;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); ++it) {
|
for (it = items.begin(); it != items.end(); ++it) {
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
@ -2055,7 +2099,7 @@ void TransfersDialog::collModif()
|
|||||||
|
|
||||||
std::set<RsFileHash> items ;
|
std::set<RsFileHash> items ;
|
||||||
std::set<RsFileHash>::iterator it ;
|
std::set<RsFileHash>::iterator it ;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
if (items.size() != 1) return;
|
if (items.size() != 1) return;
|
||||||
it = items.begin();
|
it = items.begin();
|
||||||
@ -2085,7 +2129,7 @@ void TransfersDialog::collView()
|
|||||||
|
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
if (items.size() != 1) return;
|
if (items.size() != 1) return;
|
||||||
it = items.begin();
|
it = items.begin();
|
||||||
@ -2115,7 +2159,7 @@ void TransfersDialog::collOpen()
|
|||||||
|
|
||||||
std::set<RsFileHash> items;
|
std::set<RsFileHash> items;
|
||||||
std::set<RsFileHash>::iterator it;
|
std::set<RsFileHash>::iterator it;
|
||||||
getSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
if (items.size() == 1) {
|
if (items.size() == 1) {
|
||||||
it = items.begin();
|
it = items.begin();
|
||||||
|
@ -95,7 +95,7 @@ private slots:
|
|||||||
/** removes finished Downloads**/
|
/** removes finished Downloads**/
|
||||||
void clearcompleted();
|
void clearcompleted();
|
||||||
|
|
||||||
void copyLink();
|
void dlCopyLink();
|
||||||
void pasteLink();
|
void pasteLink();
|
||||||
void renameFile();
|
void renameFile();
|
||||||
void setDestinationDirectory();
|
void setDestinationDirectory();
|
||||||
@ -109,9 +109,9 @@ private slots:
|
|||||||
|
|
||||||
void pauseFileTransfer();
|
void pauseFileTransfer();
|
||||||
void resumeFileTransfer();
|
void resumeFileTransfer();
|
||||||
void openFolderTransfer();
|
void dlOpenFolder();
|
||||||
void openTransfer();
|
void dlOpenFile();
|
||||||
void previewTransfer();
|
void dlPreviewFile();
|
||||||
|
|
||||||
void ulOpenFolder();
|
void ulOpenFolder();
|
||||||
void ulCopyLink();
|
void ulCopyLink();
|
||||||
@ -235,7 +235,7 @@ private:
|
|||||||
bool m_bProcessSettings;
|
bool m_bProcessSettings;
|
||||||
void processSettings(bool bLoad);
|
void processSettings(bool bLoad);
|
||||||
|
|
||||||
void getSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows);
|
void getDLSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows);
|
||||||
void getULSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows);
|
void getULSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows);
|
||||||
bool controlTransferFile(uint32_t flags);
|
bool controlTransferFile(uint32_t flags);
|
||||||
void changePriority(int priority);
|
void changePriority(int priority);
|
||||||
@ -255,12 +255,11 @@ private:
|
|||||||
Ui::TransfersDialog ui;
|
Ui::TransfersDialog ui;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// these two functions add entries to the transfers dialog, and return the row id of the entry modified/added
|
// these four functions add entries to the transfers dialog, and return the row id of the entry modified/added
|
||||||
//
|
int addDLItem(int row, const FileInfo &fileInfo);
|
||||||
int addItem(int row, const FileInfo &fileInfo);
|
int addPeerToDLItem(QStandardItem *dlItem, const QString& name, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo);
|
||||||
int addPeerToItem(QStandardItem *dlItem, const QString& name, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo);
|
int addULItem(int row, const FileInfo &fileInfo);
|
||||||
|
int addPeerToULItem(QStandardItem *ulItem, const RsPeerId& peer_ID, const QString &coreID, qlonglong completed, double ulspeed, const FileProgressInfo& peerInfo);
|
||||||
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources,const QString& source_id, const QString& status, qlonglong completed, qlonglong remaining);
|
|
||||||
|
|
||||||
void showFileDetails() ;
|
void showFileDetails() ;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
qlonglong fileSize;
|
qlonglong fileSize;
|
||||||
double ulspeed, multi;
|
double ulspeed, multi;
|
||||||
QString temp , status;
|
QString temp;
|
||||||
qlonglong transferred;
|
qlonglong transferred;
|
||||||
|
|
||||||
// prepare
|
// prepare
|
||||||
@ -65,7 +65,12 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
}
|
}
|
||||||
|
|
||||||
// draw the background color
|
// draw the background color
|
||||||
if(index.column() != COLUMN_UPROGRESS) {
|
bool bDrawBackground = true;
|
||||||
|
if(index.column() == COLUMN_UPROGRESS) {
|
||||||
|
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||||
|
bDrawBackground = (pinfo.type == FileProgressInfo::UNINIT);
|
||||||
|
}
|
||||||
|
if( bDrawBackground ) {
|
||||||
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;
|
||||||
@ -78,6 +83,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case COLUMN_USIZE:
|
case COLUMN_USIZE:
|
||||||
fileSize = index.data().toLongLong();
|
fileSize = index.data().toLongLong();
|
||||||
@ -131,6 +137,8 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
case COLUMN_UPROGRESS:
|
case COLUMN_UPROGRESS:
|
||||||
{
|
{
|
||||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||||
|
if (pinfo.type == FileProgressInfo::UNINIT)
|
||||||
|
break;
|
||||||
|
|
||||||
// create a xProgressBar
|
// create a xProgressBar
|
||||||
painter->save() ;
|
painter->save() ;
|
||||||
@ -161,9 +169,6 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
}
|
}
|
||||||
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, index.data().toString());
|
||||||
break;
|
break;
|
||||||
case COLUMN_USTATUS:
|
|
||||||
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignCenter, index.data().toString());
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,8 @@
|
|||||||
#define COLUMN_UTRANSFERRED 2
|
#define COLUMN_UTRANSFERRED 2
|
||||||
#define COLUMN_ULSPEED 3
|
#define COLUMN_ULSPEED 3
|
||||||
#define COLUMN_UPROGRESS 4
|
#define COLUMN_UPROGRESS 4
|
||||||
#define COLUMN_USTATUS 5
|
#define COLUMN_UHASH 5
|
||||||
#define COLUMN_USERNAME 6
|
#define COLUMN_UCOUNT 6
|
||||||
#define COLUMN_UHASH 7
|
|
||||||
#define COLUMN_UUSERID 8
|
|
||||||
#define COLUMN_UCOUNT 9
|
|
||||||
|
|
||||||
|
|
||||||
#define MAX_CHAR_TMP 128
|
#define MAX_CHAR_TMP 128
|
||||||
|
@ -39,7 +39,9 @@
|
|||||||
class FileProgressInfo
|
class FileProgressInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef enum { DOWNLOAD_LINE,UPLOAD_LINE,DOWNLOAD_SOURCE } LineType ;
|
typedef enum { UNINIT, DOWNLOAD_LINE, UPLOAD_LINE, DOWNLOAD_SOURCE } LineType ;
|
||||||
|
|
||||||
|
FileProgressInfo() : type(UNINIT), progress(0.0) {}
|
||||||
|
|
||||||
LineType type ;
|
LineType type ;
|
||||||
CompressedChunkMap cmap ;
|
CompressedChunkMap cmap ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user