- Added a ChunkMap class responsible for allocating new chunks to be downloaded, according to

- a given chunk strategy
	- the availablility map of each source 
- Integrated this into ftFileCreator
- added gui menu in file transfer+right click to change the chunk strategy: streaming vs. random

Next step: 
	- loading/saving file downloading state and availability map
	- displaying chunk details in the selected transfer tab (e.g. list of currently worked chunks, and their current downloading completion)



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1863 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-12-08 22:29:52 +00:00
parent de0cbd50ce
commit 25a09900e9
16 changed files with 584 additions and 173 deletions

View file

@ -303,6 +303,16 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
priorityMenu->addAction(priorityHighAct);
priorityMenu->addAction(priorityAutoAct);
chunkStreamingAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Streaming"), this);
connect(chunkStreamingAct, SIGNAL(triggered()), this, SLOT(chunkStreaming()));
chunkRandomAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Random"), this);
connect(chunkRandomAct, SIGNAL(triggered()), this, SLOT(chunkRandom()));
QMenu *chunkMenu = new QMenu(tr("Chunk strategy"), this);
chunkMenu->setIcon(QIcon(IMAGE_PRIORITY));
chunkMenu->addAction(chunkStreamingAct);
chunkMenu->addAction(chunkRandomAct);
contextMnu.clear();
if (addPlayOption)
{
@ -310,6 +320,7 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
}
contextMnu.addSeparator();
contextMnu.addMenu( priorityMenu);
contextMnu.addMenu( chunkMenu);
contextMnu.addAction( pauseAct);
contextMnu.addAction( resumeAct);
contextMnu.addAction( cancelAct);
@ -1252,6 +1263,25 @@ void TransfersDialog::clearQueue()
rsFiles->clearQueue();
}
void TransfersDialog::chunkStreaming()
{
setChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_STREAMING) ;
}
void TransfersDialog::chunkRandom()
{
setChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_RANDOM) ;
}
void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
{
QList<QStandardItem *> items;
QList<QStandardItem *>::iterator it;
getIdOfSelectedItems(items);
for (it = items.begin(); it != items.end(); it ++) {
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
rsFiles->setChunkStrategy(hash, s);
}
}
/* modify download priority actions */
void TransfersDialog::priorityLow()
{

View file

@ -30,6 +30,7 @@
#include <QVariant>
#include <stdint.h>
#include <rsiface/rstypes.h>
#include "mainpage.h"
#include "RsAutoUpdatePage.h"
@ -90,6 +91,9 @@ class TransfersDialog : public RsAutoUpdatePage
void priorityHigh();
void priorityAuto();
void chunkRandom();
void chunkStreaming();
/** save sort indicators for next transfers display */
void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
@ -143,10 +147,13 @@ class TransfersDialog : public RsAutoUpdatePage
QAction *priorityNormalAct;
QAction *priorityHighAct;
QAction *priorityAutoAct;
QAction *chunkRandomAct;
QAction *chunkStreamingAct;
void getIdOfSelectedItems(QList<QStandardItem *>& items);
bool controlTransferFile(uint32_t flags);
void changePriority(int priority);
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
QTreeView *downloadList;