mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-03 20:01:07 -05:00
made contextual menus in FT more contextual, added info about transfer type and chunking strategy, load/save of transfer flags
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2114 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9182091917
commit
0e7f9df638
@ -359,6 +359,7 @@ void ChunkMap::getChunksInfo(FileChunksInfo& info) const
|
|||||||
info.file_size = _file_size ;
|
info.file_size = _file_size ;
|
||||||
info.chunk_size = _chunk_size ;
|
info.chunk_size = _chunk_size ;
|
||||||
info.chunks = _map ;
|
info.chunks = _map ;
|
||||||
|
info.strategy = _strategy ;
|
||||||
|
|
||||||
info.active_chunks.clear() ;
|
info.active_chunks.clear() ;
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ bool ftController::getFileDownloadChunksDetails(const std::string& hash,FileChun
|
|||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
it->second.mCreator->getChunkMap(info) ;
|
it->second.mCreator->getChunkMap(info) ;
|
||||||
|
info.flags = it->second.mFlags ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@ -481,9 +482,11 @@ bool ftController::completeFile(std::string hash)
|
|||||||
callbackCode = fc->mCallbackCode;
|
callbackCode = fc->mCallbackCode;
|
||||||
|
|
||||||
mDataplex->removeTransferModule(hash_to_suppress) ;
|
mDataplex->removeTransferModule(hash_to_suppress) ;
|
||||||
|
uint32_t flgs = fc->mFlags ;
|
||||||
mDownloads.erase(it);
|
mDownloads.erase(it);
|
||||||
|
|
||||||
mTurtle->stopMonitoringFileTunnels(hash_to_suppress) ;
|
if(flgs & RS_FILE_HINTS_NETWORK_WIDE)
|
||||||
|
mTurtle->stopMonitoringFileTunnels(hash_to_suppress) ;
|
||||||
|
|
||||||
} /******* UNLOCKED ********/
|
} /******* UNLOCKED ********/
|
||||||
|
|
||||||
@ -773,7 +776,9 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* do a source search - for any extra sources */
|
/* do a source search - for any extra sources */
|
||||||
if (mSearch->search(hash, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info))
|
// add sources only in direct mode
|
||||||
|
//
|
||||||
|
if ((!(flags & RS_FILE_HINTS_NETWORK_WIDE)) && mSearch->search(hash, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info))
|
||||||
{
|
{
|
||||||
/* do something with results */
|
/* do something with results */
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
@ -840,7 +845,10 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
|||||||
if(flags & RS_FILE_HINTS_NETWORK_WIDE)
|
if(flags & RS_FILE_HINTS_NETWORK_WIDE)
|
||||||
mTurtle->monitorFileTunnels(fname,hash,size) ;
|
mTurtle->monitorFileTunnels(fname,hash,size) ;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Warning: no flags supplied. Assuming availability. This is probably a bug." << std::endl ;
|
||||||
flags |= RS_FILE_HINTS_ASSUME_AVAILABILITY ;
|
flags |= RS_FILE_HINTS_ASSUME_AVAILABILITY ;
|
||||||
|
}
|
||||||
|
|
||||||
bool assume_source_availability = (flags & RS_FILE_HINTS_ASSUME_AVAILABILITY) > 0 ;
|
bool assume_source_availability = (flags & RS_FILE_HINTS_ASSUME_AVAILABILITY) > 0 ;
|
||||||
|
|
||||||
@ -1498,7 +1506,7 @@ std::list<RsItem *> ftController::saveList(bool &cleanup)
|
|||||||
rft->file.hash = fit->second.mHash;
|
rft->file.hash = fit->second.mHash;
|
||||||
rft->file.filesize = fit->second.mSize;
|
rft->file.filesize = fit->second.mSize;
|
||||||
rft->file.path = RsDirUtil::removeTopDir(fit->second.mDestination); /* remove fname */
|
rft->file.path = RsDirUtil::removeTopDir(fit->second.mDestination); /* remove fname */
|
||||||
//rft->flags = fit->second.mFlags;
|
rft->flags = fit->second.mFlags;
|
||||||
|
|
||||||
fit->second.mTransfer->getFileSources(rft->allPeerIds.ids);
|
fit->second.mTransfer->getFileSources(rft->allPeerIds.ids);
|
||||||
|
|
||||||
@ -1560,7 +1568,7 @@ bool ftController::loadList(std::list<RsItem *> load)
|
|||||||
/* This will get stored on a waiting list - until the
|
/* This will get stored on a waiting list - until the
|
||||||
* config files are fully loaded
|
* config files are fully loaded
|
||||||
*/
|
*/
|
||||||
FileRequest(rsft->file.name, rsft->file.hash, rsft->file.filesize, rsft->file.path, 0, rsft->allPeerIds.ids);
|
FileRequest(rsft->file.name, rsft->file.hash, rsft->file.filesize, rsft->file.path, rsft->flags, rsft->allPeerIds.ids);
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(ctrlMutex) ;
|
RsStackMutex mtx(ctrlMutex) ;
|
||||||
|
@ -264,6 +264,8 @@ class FileChunksInfo
|
|||||||
|
|
||||||
uint64_t file_size ; // real size of the file
|
uint64_t file_size ; // real size of the file
|
||||||
uint32_t chunk_size ; // size of chunks
|
uint32_t chunk_size ; // size of chunks
|
||||||
|
uint32_t flags ;
|
||||||
|
uint32_t strategy ;
|
||||||
|
|
||||||
// dl state of chunks. Only the last chunk may have size < chunk_size
|
// dl state of chunks. Only the last chunk may have size < chunk_size
|
||||||
std::vector<ChunkState> chunks ;
|
std::vector<ChunkState> chunks ;
|
||||||
|
@ -197,6 +197,7 @@ uint32_t RsFileConfigSerialiser::sizeTransfer(RsFileTransfer *item)
|
|||||||
s += 4; /* lrate */
|
s += 4; /* lrate */
|
||||||
s += 4; /* ltransfer */
|
s += 4; /* ltransfer */
|
||||||
s += 4; // chunk_strategy
|
s += 4; // chunk_strategy
|
||||||
|
s += 4; // flags
|
||||||
s += 4; // chunk map size
|
s += 4; // chunk map size
|
||||||
s += 4*item->compressed_chunk_map._map.size(); // compressed_chunk_map
|
s += 4*item->compressed_chunk_map._map.size(); // compressed_chunk_map
|
||||||
|
|
||||||
@ -241,6 +242,7 @@ bool RsFileConfigSerialiser::serialiseTransfer(RsFileTransfer *item, void *d
|
|||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->lrate);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->lrate);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->ltransfer);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->ltransfer);
|
||||||
|
|
||||||
|
ok &= setRawUInt32(data, tlvsize, &offset, item->flags);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->chunk_strategy);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->chunk_strategy);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->compressed_chunk_map._map.size());
|
ok &= setRawUInt32(data, tlvsize, &offset, item->compressed_chunk_map._map.size());
|
||||||
|
|
||||||
@ -306,6 +308,7 @@ RsFileTransfer *RsFileConfigSerialiser::deserialiseTransfer(void *data, uint32_t
|
|||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->lrate));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->lrate));
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->ltransfer));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->ltransfer));
|
||||||
|
|
||||||
|
ok &= getRawUInt32(data, rssize, &offset, &(item->flags));
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->chunk_strategy));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->chunk_strategy));
|
||||||
uint32_t map_size = 0 ;
|
uint32_t map_size = 0 ;
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &map_size);
|
ok &= getRawUInt32(data, rssize, &offset, &map_size);
|
||||||
|
@ -207,6 +207,7 @@ class RsFileTransfer: public RsItem
|
|||||||
uint32_t ltransfer;
|
uint32_t ltransfer;
|
||||||
|
|
||||||
// chunk information
|
// chunk information
|
||||||
|
uint32_t flags ;
|
||||||
uint32_t chunk_strategy ; // strategy flags for chunks
|
uint32_t chunk_strategy ; // strategy flags for chunks
|
||||||
CompressedChunkMap compressed_chunk_map ; // chunk availability (bitwise)
|
CompressedChunkMap compressed_chunk_map ; // chunk availability (bitwise)
|
||||||
};
|
};
|
||||||
|
@ -221,6 +221,12 @@ void FileTransferInfoWidget::draw(const FileChunksInfo& info,QPainter *painter)
|
|||||||
y += text_height ; painter->drawText(20,y,tr("Number of chunks: ")) ; painter->drawText(tab_size,y,QString::number(info.chunks.size())) ;
|
y += text_height ; painter->drawText(20,y,tr("Number of chunks: ")) ; painter->drawText(tab_size,y,QString::number(info.chunks.size())) ;
|
||||||
y += block_sep ;
|
y += block_sep ;
|
||||||
y += text_height ; painter->drawText(20,y,tr("Number of sources: ")) ; painter->drawText(tab_size,y,QString::number(info.compressed_peer_availability_maps.size())) ;
|
y += text_height ; painter->drawText(20,y,tr("Number of sources: ")) ; painter->drawText(tab_size,y,QString::number(info.compressed_peer_availability_maps.size())) ;
|
||||||
|
y += block_sep ;
|
||||||
|
y += text_height ; painter->drawText(20,y,tr("Chunk strategy: ")) ; painter->drawText(tab_size,y,(info.strategy==FileChunksInfo::CHUNK_STRATEGY_RANDOM)?"Random":"Streaming") ;
|
||||||
|
y += block_sep ;
|
||||||
|
y += text_height ; painter->drawText(20,y,tr("Transfer type: ")) ;
|
||||||
|
if(info.flags & RS_FILE_HINTS_NETWORK_WIDE) painter->drawText(tab_size,y,"Anonymous F2F") ;
|
||||||
|
if(info.flags & RS_FILE_HINTS_ASSUME_AVAILABILITY) painter->drawText(tab_size,y,"Direct friend transfer / Availability assumed") ;
|
||||||
y += text_height ;
|
y += text_height ;
|
||||||
y += block_sep ;
|
y += block_sep ;
|
||||||
|
|
||||||
|
@ -258,7 +258,13 @@ void SearchDialog::download()
|
|||||||
std::cerr << "SearchDialog::download() Calling File Request";
|
std::cerr << "SearchDialog::download() Calling File Request";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::list<std::string> srcIds;
|
std::list<std::string> srcIds;
|
||||||
|
#ifdef SUSPENDED
|
||||||
|
// I suspend this. For turtle F2F download, we dont' need sources:
|
||||||
|
// - if we put sources, they make double with some tunnels.
|
||||||
|
// - they won't transfer because ASSUME_AVAILABILITY can't be used,
|
||||||
|
// and no chunk maps are transfered except in tunnels.
|
||||||
srcIds.push_back(item->text(SR_UID_COL).toStdString()) ;
|
srcIds.push_back(item->text(SR_UID_COL).toStdString()) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toStdString(),
|
if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toStdString(),
|
||||||
(item->text(SR_HASH_COL)).toStdString(),
|
(item->text(SR_HASH_COL)).toStdString(),
|
||||||
@ -283,7 +289,9 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString
|
|||||||
{
|
{
|
||||||
if (!item->childCount()) {
|
if (!item->childCount()) {
|
||||||
std::list<std::string> srcIds;
|
std::list<std::string> srcIds;
|
||||||
|
#ifdef SUSPENDED
|
||||||
srcIds.push_back(item->text(SR_UID_COL).toStdString());
|
srcIds.push_back(item->text(SR_UID_COL).toStdString());
|
||||||
|
#endif
|
||||||
|
|
||||||
QString path = QString::fromStdString(rsFiles->getDownloadDirectory())
|
QString path = QString::fromStdString(rsFiles->getDownloadDirectory())
|
||||||
+ tr("/") + base + tr("/");
|
+ tr("/") + base + tr("/");
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "rshare.h"
|
#include "rshare.h"
|
||||||
#include "TransfersDialog.h"
|
#include "TransfersDialog.h"
|
||||||
@ -241,14 +242,18 @@ void TransfersDialog::keyPressEvent(QKeyEvent *e)
|
|||||||
|
|
||||||
void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
||||||
{
|
{
|
||||||
|
QMenu contextMnu( this );
|
||||||
|
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||||
|
|
||||||
QMenu contextMnu( this );
|
std::set<QStandardItem *> items;
|
||||||
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
std::set<QStandardItem *>::iterator it;
|
||||||
|
getIdOfSelectedItems(items);
|
||||||
|
|
||||||
|
bool single = (items.size() == 1) ;
|
||||||
|
|
||||||
/* check which item is selected
|
/* check which item is selected
|
||||||
* - if it is completed - play should appear in menu
|
* - if it is completed - play should appear in menu
|
||||||
*/
|
*/
|
||||||
std::cerr << "TransfersDialog::downloadListCostumPopupMenu()" << std::endl;
|
std::cerr << "TransfersDialog::downloadListCostumPopupMenu()" << std::endl;
|
||||||
|
|
||||||
bool addPlayOption = false;
|
bool addPlayOption = false;
|
||||||
@ -266,112 +271,142 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QAction *playAct = NULL;
|
QAction *playAct = NULL;
|
||||||
if (addPlayOption)
|
if (addPlayOption)
|
||||||
{
|
{
|
||||||
playAct = new QAction(QIcon(IMAGE_PLAY), tr( "Play" ), this );
|
playAct = new QAction(QIcon(IMAGE_PLAY), tr( "Play" ), this );
|
||||||
connect( playAct , SIGNAL( triggered() ), this, SLOT( playSelectedTransfer() ) );
|
connect( playAct , SIGNAL( triggered() ), this, SLOT( playSelectedTransfer() ) );
|
||||||
}
|
}
|
||||||
QAction *detailsAct = NULL;
|
|
||||||
pauseAct = new QAction(QIcon(IMAGE_PAUSE), tr("Pause"), this);
|
|
||||||
connect(pauseAct, SIGNAL(triggered()), this, SLOT(pauseFileTransfer()));
|
|
||||||
|
|
||||||
resumeAct = new QAction(QIcon(IMAGE_RESUME), tr("Resume"), this);
|
QAction *detailsAct = NULL;
|
||||||
connect(resumeAct, SIGNAL(triggered()), this, SLOT(resumeFileTransfer()));
|
pauseAct = new QAction(QIcon(IMAGE_PAUSE), tr("Pause"), this);
|
||||||
|
connect(pauseAct, SIGNAL(triggered()), this, SLOT(pauseFileTransfer()));
|
||||||
|
|
||||||
cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this );
|
resumeAct = new QAction(QIcon(IMAGE_RESUME), tr("Resume"), this);
|
||||||
connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) );
|
connect(resumeAct, SIGNAL(triggered()), this, SLOT(resumeFileTransfer()));
|
||||||
|
|
||||||
openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
|
cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this );
|
||||||
connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openFolderTransfer()));
|
connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) );
|
||||||
|
|
||||||
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
|
openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
|
||||||
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openTransfer()));
|
connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openFolderTransfer()));
|
||||||
|
|
||||||
previewfileAct = new QAction(QIcon(IMAGE_PREVIEW), tr("Preview File"), this);
|
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
|
||||||
connect(previewfileAct, SIGNAL(triggered()), this, SLOT(previewTransfer()));
|
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openTransfer()));
|
||||||
|
|
||||||
detailsfileAct = new QAction(QIcon(IMAGE_INFO), tr("Details..."), this);
|
previewfileAct = new QAction(QIcon(IMAGE_PREVIEW), tr("Preview File"), this);
|
||||||
connect(detailsfileAct, SIGNAL(triggered()), this, SLOT(showDetailsDialog()));
|
connect(previewfileAct, SIGNAL(triggered()), this, SLOT(previewTransfer()));
|
||||||
|
|
||||||
clearcompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this );
|
detailsfileAct = new QAction(QIcon(IMAGE_INFO), tr("Details..."), this);
|
||||||
connect( clearcompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) );
|
connect(detailsfileAct, SIGNAL(triggered()), this, SLOT(showDetailsDialog()));
|
||||||
|
|
||||||
copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
|
clearcompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this );
|
||||||
connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
|
connect( clearcompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) );
|
||||||
|
|
||||||
pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste retroshare Link" ), this );
|
#ifndef RS_RELEASE_VERSION
|
||||||
connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
|
||||||
|
connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
rootisnotdecoratedAct = new QAction(QIcon(), tr( "Set Root is not Decorated" ), this );
|
pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste retroshare Link" ), this );
|
||||||
connect( rootisnotdecoratedAct , SIGNAL( triggered() ), this, SLOT( rootisnotdecorated() ) );
|
connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
||||||
|
|
||||||
rootisdecoratedAct = new QAction(QIcon(), tr( "Set Root is Decorated" ), this );
|
rootisnotdecoratedAct = new QAction(QIcon(), tr( "Set Root is not Decorated" ), this );
|
||||||
connect( rootisdecoratedAct , SIGNAL( triggered() ), this, SLOT( rootdecorated() ) );
|
connect( rootisnotdecoratedAct , SIGNAL( triggered() ), this, SLOT( rootisnotdecorated() ) );
|
||||||
|
|
||||||
QMenu *viewMenu = new QMenu( tr("View"), this );
|
rootisdecoratedAct = new QAction(QIcon(), tr( "Set Root is Decorated" ), this );
|
||||||
viewMenu->addAction(rootisnotdecoratedAct);
|
connect( rootisdecoratedAct , SIGNAL( triggered() ), this, SLOT( rootdecorated() ) );
|
||||||
viewMenu->addAction(rootisdecoratedAct);
|
|
||||||
|
|
||||||
clearQueuedDwlAct = new QAction(QIcon(), tr("Clear from Queue"), this);
|
QMenu *viewMenu = new QMenu( tr("View"), this );
|
||||||
connect(clearQueuedDwlAct, SIGNAL(triggered()), this, SLOT(clearQueuedDwl()));
|
viewMenu->addAction(rootisnotdecoratedAct);
|
||||||
clearQueueAct = new QAction(QIcon(), tr("Clear Queue"), this);
|
viewMenu->addAction(rootisdecoratedAct);
|
||||||
connect(clearQueueAct, SIGNAL(triggered()), this, SLOT(clearQueue()));
|
|
||||||
|
|
||||||
priorityLowAct = new QAction(QIcon(IMAGE_PRIORITYLOW), tr("Low"), this);
|
clearQueuedDwlAct = new QAction(QIcon(), tr("Clear from Queue"), this);
|
||||||
connect(priorityLowAct, SIGNAL(triggered()), this, SLOT(priorityLow()));
|
connect(clearQueuedDwlAct, SIGNAL(triggered()), this, SLOT(clearQueuedDwl()));
|
||||||
priorityNormalAct = new QAction(QIcon(IMAGE_PRIORITYNORMAL), tr("Normal"), this);
|
clearQueueAct = new QAction(QIcon(), tr("Clear Queue"), this);
|
||||||
connect(priorityNormalAct, SIGNAL(triggered()), this, SLOT(priorityNormal()));
|
connect(clearQueueAct, SIGNAL(triggered()), this, SLOT(clearQueue()));
|
||||||
priorityHighAct = new QAction(QIcon(IMAGE_PRIORITYHIGH), tr("High"), this);
|
|
||||||
connect(priorityHighAct, SIGNAL(triggered()), this, SLOT(priorityHigh()));
|
|
||||||
priorityAutoAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Auto"), this);
|
|
||||||
connect(priorityAutoAct, SIGNAL(triggered()), this, SLOT(priorityAuto()));
|
|
||||||
|
|
||||||
QMenu *priorityMenu = new QMenu(tr("Priority (Download)"), this);
|
priorityLowAct = new QAction(QIcon(IMAGE_PRIORITYLOW), tr("Low"), this);
|
||||||
priorityMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
connect(priorityLowAct, SIGNAL(triggered()), this, SLOT(priorityLow()));
|
||||||
priorityMenu->addAction(priorityLowAct);
|
priorityNormalAct = new QAction(QIcon(IMAGE_PRIORITYNORMAL), tr("Normal"), this);
|
||||||
priorityMenu->addAction(priorityNormalAct);
|
connect(priorityNormalAct, SIGNAL(triggered()), this, SLOT(priorityNormal()));
|
||||||
priorityMenu->addAction(priorityHighAct);
|
priorityHighAct = new QAction(QIcon(IMAGE_PRIORITYHIGH), tr("High"), this);
|
||||||
priorityMenu->addAction(priorityAutoAct);
|
connect(priorityHighAct, SIGNAL(triggered()), this, SLOT(priorityHigh()));
|
||||||
|
priorityAutoAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Auto"), this);
|
||||||
|
connect(priorityAutoAct, SIGNAL(triggered()), this, SLOT(priorityAuto()));
|
||||||
|
|
||||||
chunkStreamingAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Streaming"), this);
|
QMenu *priorityMenu = new QMenu(tr("Priority (Download)"), this);
|
||||||
connect(chunkStreamingAct, SIGNAL(triggered()), this, SLOT(chunkStreaming()));
|
priorityMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
||||||
chunkRandomAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Random"), this);
|
priorityMenu->addAction(priorityLowAct);
|
||||||
connect(chunkRandomAct, SIGNAL(triggered()), this, SLOT(chunkRandom()));
|
priorityMenu->addAction(priorityNormalAct);
|
||||||
|
priorityMenu->addAction(priorityHighAct);
|
||||||
|
priorityMenu->addAction(priorityAutoAct);
|
||||||
|
|
||||||
QMenu *chunkMenu = new QMenu(tr("Chunk strategy"), this);
|
chunkStreamingAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Streaming"), this);
|
||||||
chunkMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
connect(chunkStreamingAct, SIGNAL(triggered()), this, SLOT(chunkStreaming()));
|
||||||
chunkMenu->addAction(chunkStreamingAct);
|
chunkRandomAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Random"), this);
|
||||||
chunkMenu->addAction(chunkRandomAct);
|
connect(chunkRandomAct, SIGNAL(triggered()), this, SLOT(chunkRandom()));
|
||||||
|
|
||||||
contextMnu.clear();
|
QMenu *chunkMenu = new QMenu(tr("Chunk strategy"), this);
|
||||||
if (addPlayOption)
|
chunkMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
||||||
{
|
chunkMenu->addAction(chunkStreamingAct);
|
||||||
contextMnu.addAction(playAct);
|
chunkMenu->addAction(chunkRandomAct);
|
||||||
}
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
contextMnu.addMenu( priorityMenu);
|
|
||||||
contextMnu.addMenu( chunkMenu);
|
|
||||||
contextMnu.addAction( pauseAct);
|
|
||||||
contextMnu.addAction( resumeAct);
|
|
||||||
contextMnu.addAction( cancelAct);
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
contextMnu.addAction( openfileAct);
|
|
||||||
contextMnu.addAction( previewfileAct);
|
|
||||||
contextMnu.addAction( openfolderAct);
|
|
||||||
contextMnu.addAction( detailsfileAct);
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
contextMnu.addAction( clearcompletedAct);
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
contextMnu.addAction( copylinkAct);
|
|
||||||
contextMnu.addAction( pastelinkAct);
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
contextMnu.addAction( clearQueuedDwlAct);
|
|
||||||
contextMnu.addAction( clearQueueAct);
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
contextMnu.addMenu( viewMenu);
|
|
||||||
|
|
||||||
contextMnu.exec( mevent->globalPos() );
|
contextMnu.clear();
|
||||||
|
if (addPlayOption)
|
||||||
|
{
|
||||||
|
contextMnu.addAction(playAct);
|
||||||
|
}
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
|
if(!items.empty())
|
||||||
|
{
|
||||||
|
bool all_paused = true ;
|
||||||
|
bool all_downld = true ;
|
||||||
|
|
||||||
|
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
||||||
|
|
||||||
|
for (int i = 0; i < lst.count (); i++)
|
||||||
|
{
|
||||||
|
if ( lst[i].column() == 0 && lst[i].model ()->data (lst[i].model ()->index (lst[i].row (), STATUS )).toString() == "Waiting")
|
||||||
|
all_downld = false ;
|
||||||
|
if ( lst[i].column() == 0 && lst[i].model ()->data (lst[i].model ()->index (lst[i].row (), STATUS )).toString() == "Downloading")
|
||||||
|
all_paused = false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMnu.addMenu( priorityMenu);
|
||||||
|
contextMnu.addMenu( chunkMenu);
|
||||||
|
|
||||||
|
if(!all_paused)
|
||||||
|
contextMnu.addAction( pauseAct);
|
||||||
|
if(!all_downld)
|
||||||
|
contextMnu.addAction( resumeAct);
|
||||||
|
contextMnu.addAction( cancelAct);
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
}
|
||||||
|
#ifndef RS_RELEASE_VERSION
|
||||||
|
if(single)
|
||||||
|
{
|
||||||
|
contextMnu.addAction( openfileAct);
|
||||||
|
contextMnu.addAction( previewfileAct);
|
||||||
|
contextMnu.addAction( openfolderAct);
|
||||||
|
contextMnu.addAction( detailsfileAct);
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
contextMnu.addAction( clearcompletedAct);
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
#ifndef RS_RELEASE_VERSION
|
||||||
|
contextMnu.addAction( copylinkAct);
|
||||||
|
#endif
|
||||||
|
contextMnu.addAction( pastelinkAct);
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
contextMnu.addAction( clearQueuedDwlAct);
|
||||||
|
contextMnu.addAction( clearQueueAct);
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
contextMnu.addMenu( viewMenu);
|
||||||
|
|
||||||
|
contextMnu.exec( mevent->globalPos() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::playSelectedTransfer()
|
void TransfersDialog::playSelectedTransfer()
|
||||||
@ -1201,7 +1236,7 @@ void TransfersDialog::pasteLink()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::getIdOfSelectedItems(QList<QStandardItem *>& items)
|
void TransfersDialog::getIdOfSelectedItems(std::set<QStandardItem *>& items)
|
||||||
{
|
{
|
||||||
items.clear();
|
items.clear();
|
||||||
|
|
||||||
@ -1230,7 +1265,7 @@ void TransfersDialog::getIdOfSelectedItems(QList<QStandardItem *>& items)
|
|||||||
/* if transfered file or it's peers are selected control it*/
|
/* if transfered file or it's peers are selected control it*/
|
||||||
if (isParentSelected || isChildSelected) {
|
if (isParentSelected || isChildSelected) {
|
||||||
QStandardItem *id = DLListModel->item(i, ID);
|
QStandardItem *id = DLListModel->item(i, ID);
|
||||||
items.append(id);
|
items.insert(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1239,8 +1274,8 @@ bool TransfersDialog::controlTransferFile(uint32_t flags)
|
|||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
QList<QStandardItem *> items;
|
std::set<QStandardItem *> items;
|
||||||
QList<QStandardItem *>::iterator it;
|
std::set<QStandardItem *>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getIdOfSelectedItems(items);
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
result &= rsFiles->FileControl((*it)->data(Qt::DisplayRole).toString().toStdString(), flags);
|
result &= rsFiles->FileControl((*it)->data(Qt::DisplayRole).toString().toStdString(), flags);
|
||||||
@ -1269,8 +1304,8 @@ void TransfersDialog::openFolderTransfer()
|
|||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
QList<QStandardItem *> items;
|
std::set<QStandardItem *> items;
|
||||||
QList<QStandardItem *>::iterator it;
|
std::set<QStandardItem *>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getIdOfSelectedItems(items);
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
@ -1299,8 +1334,8 @@ void TransfersDialog::previewTransfer()
|
|||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
QList<QStandardItem *> items;
|
std::set<QStandardItem *> items;
|
||||||
QList<QStandardItem *>::iterator it;
|
std::set<QStandardItem *>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getIdOfSelectedItems(items);
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
@ -1359,8 +1394,8 @@ void TransfersDialog::openTransfer()
|
|||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
QList<QStandardItem *> items;
|
std::set<QStandardItem *> items;
|
||||||
QList<QStandardItem *>::iterator it;
|
std::set<QStandardItem *>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getIdOfSelectedItems(items);
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
@ -1390,8 +1425,8 @@ void TransfersDialog::openTransfer()
|
|||||||
/* clear download or all queue - for pending dwls */
|
/* clear download or all queue - for pending dwls */
|
||||||
void TransfersDialog::clearQueuedDwl()
|
void TransfersDialog::clearQueuedDwl()
|
||||||
{
|
{
|
||||||
QList<QStandardItem *> items;
|
std::set<QStandardItem *> items;
|
||||||
QList<QStandardItem *>::iterator it;
|
std::set<QStandardItem *>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getIdOfSelectedItems(items);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
@ -1414,8 +1449,8 @@ void TransfersDialog::chunkRandom()
|
|||||||
}
|
}
|
||||||
void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
||||||
{
|
{
|
||||||
QList<QStandardItem *> items;
|
std::set<QStandardItem *> items;
|
||||||
QList<QStandardItem *>::iterator it;
|
std::set<QStandardItem *>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getIdOfSelectedItems(items);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
@ -1443,8 +1478,8 @@ void TransfersDialog::priorityAuto()
|
|||||||
|
|
||||||
void TransfersDialog::changePriority(int priority)
|
void TransfersDialog::changePriority(int priority)
|
||||||
{
|
{
|
||||||
QList<QStandardItem *> items;
|
std::set<QStandardItem *> items;
|
||||||
QList<QStandardItem *>::iterator it;
|
std::set<QStandardItem *>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getIdOfSelectedItems(items);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#ifndef _TRANSFERSDIALOG_H
|
#ifndef _TRANSFERSDIALOG_H
|
||||||
#define _TRANSFERSDIALOG_H
|
#define _TRANSFERSDIALOG_H
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
@ -152,7 +154,7 @@ class TransfersDialog : public RsAutoUpdatePage
|
|||||||
QAction *chunkStreamingAct;
|
QAction *chunkStreamingAct;
|
||||||
QAction *detailsfileAct;
|
QAction *detailsfileAct;
|
||||||
|
|
||||||
void getIdOfSelectedItems(QList<QStandardItem *>& items);
|
void getIdOfSelectedItems(std::set<QStandardItem *>& items);
|
||||||
bool controlTransferFile(uint32_t flags);
|
bool controlTransferFile(uint32_t flags);
|
||||||
void changePriority(int priority);
|
void changePriority(int priority);
|
||||||
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
|
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user