mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-06 05:08:09 -05:00
restaured priority queue methods, and made better context menues.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2135 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7b35b7dc6a
commit
7fd5c7ad4b
@ -63,7 +63,7 @@ static const uint32_t INACTIVE_CHUNKS_CHECK_DELAY = 60 ; // save transfer progre
|
|||||||
ftFileControl::ftFileControl()
|
ftFileControl::ftFileControl()
|
||||||
:mTransfer(NULL), mCreator(NULL),
|
:mTransfer(NULL), mCreator(NULL),
|
||||||
mState(0), mSize(0), mFlags(0),
|
mState(0), mSize(0), mFlags(0),
|
||||||
mPriority(PRIORITY_NORMAL)
|
mPriority(SPEED_NORMAL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ ftFileControl::ftFileControl(std::string fname,
|
|||||||
:mName(fname), mCurrentPath(tmppath), mDestination(dest),
|
:mName(fname), mCurrentPath(tmppath), mDestination(dest),
|
||||||
mTransfer(tm), mCreator(fc), mState(0), mHash(hash),
|
mTransfer(tm), mCreator(fc), mState(0), mHash(hash),
|
||||||
mSize(size), mFlags(flags), mDoCallback(false), mCallbackCode(cb),
|
mSize(size), mFlags(flags), mDoCallback(false), mCallbackCode(cb),
|
||||||
mPriority(PRIORITY_NORMAL) // default priority to normal
|
mPriority(SPEED_NORMAL) // default priority to normal
|
||||||
{
|
{
|
||||||
if (cb)
|
if (cb)
|
||||||
mDoCallback = true;
|
mDoCallback = true;
|
||||||
@ -253,39 +253,17 @@ void ftController::tickTransfers()
|
|||||||
|
|
||||||
// 2.1 - decide based on probability, which category of files we handle.
|
// 2.1 - decide based on probability, which category of files we handle.
|
||||||
|
|
||||||
static const float HIGH_PRIORITY_PROB = 0.60 ;
|
// static const float HIGH_PRIORITY_PROB = 0.60 ;
|
||||||
static const float NORMAL_PRIORITY_PROB = 0.25 ;
|
// static const float NORMAL_PRIORITY_PROB = 0.25 ;
|
||||||
static const float LOW_PRIORITY_PROB = 0.15 ;
|
// static const float LOW_PRIORITY_PROB = 0.15 ;
|
||||||
static const float SUSP_PRIORITY_PROB = 0.00 ;
|
// static const float SUSP_PRIORITY_PROB = 0.00 ;
|
||||||
|
|
||||||
std::cerr << "Priority tabs: " ;
|
std::cerr << "Priority tabs: " ;
|
||||||
std::cerr << "Low (" << mPriorityTab[PRIORITY_LOW ].size() << ") " ;
|
std::cerr << "Low (" << mPriorityTab[SPEED_LOW ].size() << ") " ;
|
||||||
std::cerr << "Normal (" << mPriorityTab[PRIORITY_NORMAL].size() << ") " ;
|
std::cerr << "Normal (" << mPriorityTab[SPEED_NORMAL].size() << ") " ;
|
||||||
std::cerr << "High (" << mPriorityTab[PRIORITY_HIGH ].size() << ") " ;
|
std::cerr << "High (" << mPriorityTab[SPEED_HIGH ].size() << ") " ;
|
||||||
std::cerr << std::endl ;
|
std::cerr << std::endl ;
|
||||||
|
|
||||||
// float probs[3] = { (!mPriorityTab[PRIORITY_LOW ].empty())* LOW_PRIORITY_PROB,
|
|
||||||
// (!mPriorityTab[PRIORITY_NORMAL].empty())*NORMAL_PRIORITY_PROB,
|
|
||||||
// (!mPriorityTab[PRIORITY_HIGH ].empty())* HIGH_PRIORITY_PROB } ;
|
|
||||||
//
|
|
||||||
// float total = probs[0]+probs[1]+probs[2] ;
|
|
||||||
// float cumul_probs[3] = { probs[0], probs[0]+probs[1], probs[0]+probs[1]+probs[2] } ;
|
|
||||||
//
|
|
||||||
// float r = rand()/(float)RAND_MAX * total;
|
|
||||||
// int chosen ;
|
|
||||||
//
|
|
||||||
// if(total == 0.0)
|
|
||||||
// return ;
|
|
||||||
//
|
|
||||||
// if(r < cumul_probs[0])
|
|
||||||
// chosen = 0 ;
|
|
||||||
// else if(r < cumul_probs[1])
|
|
||||||
// chosen = 1 ;
|
|
||||||
// else
|
|
||||||
// chosen = 2 ;
|
|
||||||
//
|
|
||||||
// std::cerr << "chosen: " << chosen << std::endl ;
|
|
||||||
|
|
||||||
/* tick the transferModules */
|
/* tick the transferModules */
|
||||||
|
|
||||||
// start anywhere in the chosen list of transfers, so that not to favor any special transfer
|
// start anywhere in the chosen list of transfers, so that not to favor any special transfer
|
||||||
@ -299,31 +277,9 @@ void ftController::tickTransfers()
|
|||||||
for(int i=0;i<(int)mPriorityTab[chosen].size();++i)
|
for(int i=0;i<(int)mPriorityTab[chosen].size();++i)
|
||||||
mPriorityTab[chosen][(i+start)%(int)mPriorityTab[chosen].size()]->tick() ;
|
mPriorityTab[chosen][(i+start)%(int)mPriorityTab[chosen].size()]->tick() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
//#ifdef CONTROL_DEBUG
|
|
||||||
// std::cerr << "\tTicking: " << it->first;
|
|
||||||
// std::cerr << std::endl;
|
|
||||||
//#endif
|
|
||||||
//
|
|
||||||
// if (it->second.mTransfer)
|
|
||||||
// {
|
|
||||||
//#ifdef CONTROL_DEBUG
|
|
||||||
// std::cerr << "\tTicking mTransfer: " << (void*)it->second.mTransfer;
|
|
||||||
// std::cerr << std::endl;
|
|
||||||
//#endif
|
|
||||||
// (it->second.mTransfer)->tick();
|
|
||||||
// }
|
|
||||||
//#ifdef CONTROL_DEBUG
|
|
||||||
// else
|
|
||||||
// std::cerr << "No mTransfer for this hash." << std::endl ;
|
|
||||||
//#endif
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftController::getPriority(const std::string& hash,DwlPriority& p)
|
bool ftController::getPriority(const std::string& hash,DwlSpeed& p)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
|
||||||
@ -337,7 +293,7 @@ bool ftController::getPriority(const std::string& hash,DwlPriority& p)
|
|||||||
else
|
else
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
void ftController::setPriority(const std::string& hash,DwlPriority p)
|
void ftController::setPriority(const std::string& hash,DwlSpeed p)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class ftFileControl
|
|||||||
bool mDoCallback;
|
bool mDoCallback;
|
||||||
uint32_t mCallbackCode;
|
uint32_t mCallbackCode;
|
||||||
time_t mCreateTime;
|
time_t mCreateTime;
|
||||||
DwlPriority mPriority ;
|
DwlSpeed mPriority ;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ftPendingRequest
|
class ftPendingRequest
|
||||||
@ -144,8 +144,8 @@ bool FileClearCompleted();
|
|||||||
bool FlagFileComplete(std::string hash);
|
bool FlagFileComplete(std::string hash);
|
||||||
bool getFileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info);
|
bool getFileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info);
|
||||||
|
|
||||||
bool getPriority(const std::string& hash,DwlPriority& p);
|
bool getPriority(const std::string& hash,DwlSpeed& p);
|
||||||
void setPriority(const std::string& hash,DwlPriority p);
|
void setPriority(const std::string& hash,DwlSpeed p);
|
||||||
|
|
||||||
/* get Details of File Transfers */
|
/* get Details of File Transfers */
|
||||||
bool FileDownloads(std::list<std::string> &hashs);
|
bool FileDownloads(std::list<std::string> &hashs);
|
||||||
|
@ -263,7 +263,12 @@ bool ftServer::setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStr
|
|||||||
|
|
||||||
bool ftServer::FileCancel(std::string hash)
|
bool ftServer::FileCancel(std::string hash)
|
||||||
{
|
{
|
||||||
return mFtController->FileCancel(hash);
|
// Remove from both queue and ftController, by default.
|
||||||
|
//
|
||||||
|
mFtDwlQueue->clearDownload(hash);
|
||||||
|
mFtController->FileCancel(hash);
|
||||||
|
|
||||||
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftServer::FileControl(std::string hash, uint32_t flags)
|
bool ftServer::FileControl(std::string hash, uint32_t flags)
|
||||||
@ -277,26 +282,35 @@ bool ftServer::FileClearCompleted()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Control of Downloads Priority. */
|
/* Control of Downloads Priority. */
|
||||||
bool ftServer::changePriority(const std::string hash, int priority)
|
bool ftServer::changeQueuePriority(const std::string hash, int priority)
|
||||||
{
|
{
|
||||||
mFtController->setPriority(hash, (DwlPriority) priority);
|
return mFtDwlQueue->changePriority(hash,(DwlPriority)priority) ;
|
||||||
|
}
|
||||||
|
bool ftServer::changeDownloadSpeed(const std::string hash, int speed)
|
||||||
|
{
|
||||||
|
mFtController->setPriority(hash, (DwlSpeed)speed);
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
bool ftServer::getDownloadSpeed(const std::string hash, int & speed)
|
||||||
bool ftServer::getPriority(const std::string hash, int & priority)
|
|
||||||
{
|
{
|
||||||
DwlPriority _priority;
|
DwlSpeed _speed;
|
||||||
int ret = mFtController->getPriority(hash, _priority);
|
int ret = mFtController->getPriority(hash, _speed);
|
||||||
if (ret) {
|
if (ret)
|
||||||
priority = _priority;
|
speed = _speed;
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
bool ftServer::getQueuePriority(const std::string hash, int & priority)
|
||||||
|
{
|
||||||
|
DwlPriority _priority;
|
||||||
|
int ret = mFtDwlQueue->getPriority(hash, _priority);
|
||||||
|
if (ret)
|
||||||
|
priority = _priority;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
bool ftServer::clearDownload(const std::string hash)
|
bool ftServer::clearDownload(const std::string hash)
|
||||||
{
|
{
|
||||||
return mFtDwlQueue->clearDownload(hash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftServer::clearQueue()
|
void ftServer::clearQueue()
|
||||||
|
@ -125,8 +125,10 @@ virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrat
|
|||||||
/***
|
/***
|
||||||
* Control of Downloads Priority.
|
* Control of Downloads Priority.
|
||||||
***/
|
***/
|
||||||
virtual bool changePriority(const std::string hash, int priority);
|
virtual bool changeQueuePriority(const std::string hash, int priority);
|
||||||
virtual bool getPriority(const std::string hash, int & priority);
|
virtual bool changeDownloadSpeed(const std::string hash, int speed);
|
||||||
|
virtual bool getQueuePriority(const std::string hash, int & priority);
|
||||||
|
virtual bool getDownloadSpeed(const std::string hash, int & speed);
|
||||||
virtual bool clearDownload(const std::string hash);
|
virtual bool clearDownload(const std::string hash);
|
||||||
virtual void clearQueue();
|
virtual void clearQueue();
|
||||||
virtual void getDwlDetails(std::list<DwlDetails> & details);
|
virtual void getDwlDetails(std::list<DwlDetails> & details);
|
||||||
|
@ -119,8 +119,10 @@ class RsFiles
|
|||||||
/***
|
/***
|
||||||
* Control of Downloads Priority.
|
* Control of Downloads Priority.
|
||||||
***/
|
***/
|
||||||
virtual bool changePriority(const std::string hash, int priority) = 0;
|
virtual bool changeQueuePriority(const std::string hash, int priority) = 0;
|
||||||
virtual bool getPriority(const std::string hash, int & priority) = 0;
|
virtual bool changeDownloadSpeed(const std::string hash, int speed) = 0;
|
||||||
|
virtual bool getQueuePriority(const std::string hash, int & priority) = 0;
|
||||||
|
virtual bool getDownloadSpeed(const std::string hash, int & speed) = 0;
|
||||||
virtual bool clearDownload(const std::string hash) = 0;
|
virtual bool clearDownload(const std::string hash) = 0;
|
||||||
virtual void clearQueue() = 0;
|
virtual void clearQueue() = 0;
|
||||||
virtual void getDwlDetails(std::list<DwlDetails> & details) = 0;
|
virtual void getDwlDetails(std::list<DwlDetails> & details) = 0;
|
||||||
|
@ -63,6 +63,12 @@ enum DwlPriority { PRIORITY_LOW = 0x00,
|
|||||||
PRIORITY_AUTO = 0x03
|
PRIORITY_AUTO = 0x03
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum DwlSpeed { SPEED_LOW = 0x00,
|
||||||
|
SPEED_NORMAL = 0x01,
|
||||||
|
SPEED_HIGH = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FileInfo
|
class FileInfo
|
||||||
{
|
{
|
||||||
@ -107,7 +113,7 @@ class FileInfo
|
|||||||
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
||||||
std::list<TransferInfo> peers;
|
std::list<TransferInfo> peers;
|
||||||
|
|
||||||
DwlPriority priority ;
|
DwlSpeed priority ;
|
||||||
time_t lastTS;
|
time_t lastTS;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -950,10 +950,7 @@ bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std
|
|||||||
/* try to load it, and get Id */
|
/* try to load it, and get Id */
|
||||||
|
|
||||||
std::string location;
|
std::string location;
|
||||||
if (LoadCheckX509andGetLocation(cert_name.c_str(), location, sslId) == 0) {
|
bool ret = LoadCheckX509andGetLocation(cert_name.c_str(), location, sslId) ;
|
||||||
std::cerr << "RsInit::GenerateSSLCertificate() Cannot check own signature, maybe the files are corrupted." << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "LoadCheckX509andGetLocation: returned " << ret << ", sslId=" << sslId << std::endl ;
|
std::cout << "LoadCheckX509andGetLocation: returned " << ret << ", sslId=" << sslId << std::endl ;
|
||||||
|
|
||||||
|
@ -151,8 +151,19 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
// create a xProgressBar
|
// create a xProgressBar
|
||||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||||
xProgressBar progressBar(pinfo.cmap,option.rect, painter); // the 3rd param is the color schema (0 is the default value)
|
xProgressBar progressBar(pinfo.cmap,option.rect, painter); // the 3rd param is the color schema (0 is the default value)
|
||||||
|
|
||||||
|
if(pinfo.type == FileProgressInfo::DOWNLOAD_LINE)
|
||||||
|
{
|
||||||
|
progressBar.setDisplayText(true); // should display % text?
|
||||||
|
progressBar.setValue(pinfo.progress); // set the progress value
|
||||||
|
progressBar.setColorSchema(0) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
progressBar.setDisplayText(false); // should display % text?
|
progressBar.setDisplayText(false); // should display % text?
|
||||||
progressBar.setValue(pinfo.progress); // set the progress value
|
progressBar.setValue(pinfo.progress); // set the progress value
|
||||||
|
progressBar.setColorSchema(1) ;
|
||||||
|
}
|
||||||
progressBar.setVerticalSpan(1);
|
progressBar.setVerticalSpan(1);
|
||||||
progressBar.paint(); // paint the progress bar
|
progressBar.paint(); // paint the progress bar
|
||||||
}
|
}
|
||||||
|
@ -115,10 +115,10 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
||||||
DLListModel->setHeaderData(COMPLETED, Qt::Horizontal, tr("Completed", ""));
|
DLListModel->setHeaderData(COMPLETED, Qt::Horizontal, tr("Completed", ""));
|
||||||
DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("Speed", "i.e: Download speed"));
|
DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("Speed", "i.e: Download speed"));
|
||||||
DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded"));
|
DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress / Availability", "i.e: % downloaded"));
|
||||||
DLListModel->setHeaderData(SOURCES, Qt::Horizontal, tr("Sources", "i.e: Sources"));
|
DLListModel->setHeaderData(SOURCES, Qt::Horizontal, tr("Sources", "i.e: Sources"));
|
||||||
DLListModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status"));
|
DLListModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status"));
|
||||||
DLListModel->setHeaderData(PRIORITY, Qt::Horizontal, tr("Priority"));
|
DLListModel->setHeaderData(PRIORITY, Qt::Horizontal, tr("Speed / Queue priority"));
|
||||||
DLListModel->setHeaderData(REMAINING, Qt::Horizontal, tr("Remaining", "i.e: Estimated Time of Arrival / Time left"));
|
DLListModel->setHeaderData(REMAINING, Qt::Horizontal, tr("Remaining", "i.e: Estimated Time of Arrival / Time left"));
|
||||||
DLListModel->setHeaderData(ID, Qt::Horizontal, tr("Core-ID"));
|
DLListModel->setHeaderData(ID, Qt::Horizontal, tr("Core-ID"));
|
||||||
ui.downloadList->setModel(DLListModel);
|
ui.downloadList->setModel(DLListModel);
|
||||||
@ -321,26 +321,37 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||||||
viewMenu->addAction(rootisnotdecoratedAct);
|
viewMenu->addAction(rootisnotdecoratedAct);
|
||||||
viewMenu->addAction(rootisdecoratedAct);
|
viewMenu->addAction(rootisdecoratedAct);
|
||||||
|
|
||||||
clearQueuedDwlAct = new QAction(QIcon(), tr("Clear from Queue"), this);
|
clearQueueAct = new QAction(QIcon(), tr("Remove all queued"), this);
|
||||||
connect(clearQueuedDwlAct, SIGNAL(triggered()), this, SLOT(clearQueuedDwl()));
|
|
||||||
clearQueueAct = new QAction(QIcon(), tr("Clear Queue"), this);
|
|
||||||
connect(clearQueueAct, SIGNAL(triggered()), this, SLOT(clearQueue()));
|
connect(clearQueueAct, SIGNAL(triggered()), this, SLOT(clearQueue()));
|
||||||
|
|
||||||
priorityLowAct = new QAction(QIcon(IMAGE_PRIORITYLOW), tr("Low"), this);
|
priorityLowAct = new QAction(QIcon(IMAGE_PRIORITYLOW), tr("Low"), this);
|
||||||
connect(priorityLowAct, SIGNAL(triggered()), this, SLOT(priorityLow()));
|
connect(priorityLowAct, SIGNAL(triggered()), this, SLOT(priorityQueueLow()));
|
||||||
priorityNormalAct = new QAction(QIcon(IMAGE_PRIORITYNORMAL), tr("Normal"), this);
|
priorityNormalAct = new QAction(QIcon(IMAGE_PRIORITYNORMAL), tr("Normal"), this);
|
||||||
connect(priorityNormalAct, SIGNAL(triggered()), this, SLOT(priorityNormal()));
|
connect(priorityNormalAct, SIGNAL(triggered()), this, SLOT(priorityQueueNormal()));
|
||||||
priorityHighAct = new QAction(QIcon(IMAGE_PRIORITYHIGH), tr("High"), this);
|
priorityHighAct = new QAction(QIcon(IMAGE_PRIORITYHIGH), tr("High"), this);
|
||||||
connect(priorityHighAct, SIGNAL(triggered()), this, SLOT(priorityHigh()));
|
connect(priorityHighAct, SIGNAL(triggered()), this, SLOT(priorityQueueHigh()));
|
||||||
priorityAutoAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Auto"), this);
|
priorityAutoAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Auto"), this);
|
||||||
connect(priorityAutoAct, SIGNAL(triggered()), this, SLOT(priorityAuto()));
|
connect(priorityAutoAct, SIGNAL(triggered()), this, SLOT(priorityQueueAuto()));
|
||||||
|
|
||||||
QMenu *priorityMenu = new QMenu(tr("Priority (Download)"), this);
|
prioritySlowAct = new QAction(QIcon(IMAGE_PRIORITYLOW), tr("Slower"), this);
|
||||||
priorityMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
connect(prioritySlowAct, SIGNAL(triggered()), this, SLOT(speedSlow()));
|
||||||
priorityMenu->addAction(priorityLowAct);
|
priorityMediumAct = new QAction(QIcon(IMAGE_PRIORITYNORMAL), tr("Average"), this);
|
||||||
priorityMenu->addAction(priorityNormalAct);
|
connect(priorityMediumAct, SIGNAL(triggered()), this, SLOT(speedAverage()));
|
||||||
priorityMenu->addAction(priorityHighAct);
|
priorityFastAct = new QAction(QIcon(IMAGE_PRIORITYHIGH), tr("Faster"), this);
|
||||||
priorityMenu->addAction(priorityAutoAct);
|
connect(priorityFastAct, SIGNAL(triggered()), this, SLOT(speedFast()));
|
||||||
|
|
||||||
|
QMenu *priorityQueueMenu = new QMenu(tr("Priority (Queue)"), this);
|
||||||
|
priorityQueueMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
||||||
|
priorityQueueMenu->addAction(priorityLowAct);
|
||||||
|
priorityQueueMenu->addAction(priorityNormalAct);
|
||||||
|
priorityQueueMenu->addAction(priorityHighAct);
|
||||||
|
priorityQueueMenu->addAction(priorityAutoAct);
|
||||||
|
|
||||||
|
QMenu *prioritySpeedMenu = new QMenu(tr("Priority (Speed)"), this);
|
||||||
|
prioritySpeedMenu->setIcon(QIcon(IMAGE_PRIORITY));
|
||||||
|
prioritySpeedMenu->addAction(prioritySlowAct);
|
||||||
|
prioritySpeedMenu->addAction(priorityMediumAct);
|
||||||
|
prioritySpeedMenu->addAction(priorityFastAct);
|
||||||
|
|
||||||
chunkStreamingAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Streaming"), this);
|
chunkStreamingAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Streaming"), this);
|
||||||
connect(chunkStreamingAct, SIGNAL(triggered()), this, SLOT(chunkStreaming()));
|
connect(chunkStreamingAct, SIGNAL(triggered()), this, SLOT(chunkStreaming()));
|
||||||
@ -353,16 +364,18 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||||||
chunkMenu->addAction(chunkRandomAct);
|
chunkMenu->addAction(chunkRandomAct);
|
||||||
|
|
||||||
contextMnu.clear();
|
contextMnu.clear();
|
||||||
|
|
||||||
if (addPlayOption)
|
if (addPlayOption)
|
||||||
{
|
|
||||||
contextMnu.addAction(playAct);
|
contextMnu.addAction(playAct);
|
||||||
}
|
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
if(!items.empty())
|
if(!items.empty())
|
||||||
{
|
{
|
||||||
bool all_paused = true ;
|
bool all_paused = true ;
|
||||||
bool all_downld = true ;
|
bool all_downld = true ;
|
||||||
|
bool all_downloading = true ;
|
||||||
|
bool all_queued = true ;
|
||||||
|
|
||||||
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
||||||
|
|
||||||
@ -372,9 +385,20 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||||||
all_downld = false ;
|
all_downld = false ;
|
||||||
if ( lst[i].column() == 0 && lst[i].model ()->data (lst[i].model ()->index (lst[i].row (), STATUS )).toString() == "Downloading")
|
if ( lst[i].column() == 0 && lst[i].model ()->data (lst[i].model ()->index (lst[i].row (), STATUS )).toString() == "Downloading")
|
||||||
all_paused = false ;
|
all_paused = false ;
|
||||||
|
|
||||||
|
if ( lst[i].column() == 0)
|
||||||
|
if(lst[i].model ()->data (lst[i].model ()->index (lst[i].row (), STATUS )).toString() == "Queued")
|
||||||
|
all_downloading = false ;
|
||||||
|
else
|
||||||
|
all_queued = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
contextMnu.addMenu( priorityMenu);
|
if(all_downloading)
|
||||||
|
contextMnu.addMenu(prioritySpeedMenu);
|
||||||
|
else if(all_queued)
|
||||||
|
contextMnu.addMenu(priorityQueueMenu) ;
|
||||||
|
|
||||||
|
if(all_downloading)
|
||||||
contextMnu.addMenu( chunkMenu);
|
contextMnu.addMenu( chunkMenu);
|
||||||
|
|
||||||
if(!all_paused)
|
if(!all_paused)
|
||||||
@ -403,7 +427,6 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||||||
#endif
|
#endif
|
||||||
contextMnu.addAction( pastelinkAct);
|
contextMnu.addAction( pastelinkAct);
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
contextMnu.addAction( clearQueuedDwlAct);
|
|
||||||
contextMnu.addAction( clearQueueAct);
|
contextMnu.addAction( clearQueueAct);
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
contextMnu.addMenu( viewMenu);
|
contextMnu.addMenu( viewMenu);
|
||||||
@ -776,17 +799,17 @@ void TransfersDialog::insertTransfers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (info.priority) {
|
switch (info.priority) {
|
||||||
case 0:
|
case SPEED_LOW:
|
||||||
priority = tr("Low");
|
priority = tr("Slower");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case SPEED_NORMAL:
|
||||||
priority = tr("Normal");
|
priority = tr("Average");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case SPEED_HIGH:
|
||||||
priority = tr("High");
|
priority = tr("Faster");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
priority = tr("Auto");
|
priority = tr("Average");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -799,6 +822,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
|
|
||||||
FileProgressInfo pinfo ;
|
FileProgressInfo pinfo ;
|
||||||
pinfo.cmap = fcinfo.chunks ;
|
pinfo.cmap = fcinfo.chunks ;
|
||||||
|
pinfo.type = FileProgressInfo::DOWNLOAD_LINE ;
|
||||||
pinfo.progress = completed*100.0/info.size ;
|
pinfo.progress = completed*100.0/info.size ;
|
||||||
|
|
||||||
// std::cerr << "Converting fcinfo to compressed chunk map. Chunks=" << fcinfo.chunks.size() << std::endl ;
|
// std::cerr << "Converting fcinfo to compressed chunk map. Chunks=" << fcinfo.chunks.size() << std::endl ;
|
||||||
@ -872,6 +896,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
remaining = (info.size - info.transfered) / (pit->tfRate * 1024.0);
|
remaining = (info.size - info.transfered) / (pit->tfRate * 1024.0);
|
||||||
|
|
||||||
FileProgressInfo pinfo ;
|
FileProgressInfo pinfo ;
|
||||||
|
pinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ;
|
||||||
pinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId] ;
|
pinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId] ;
|
||||||
pinfo.progress = 0.0 ; // we don't display completion for sources.
|
pinfo.progress = 0.0 ; // we don't display completion for sources.
|
||||||
|
|
||||||
@ -1061,6 +1086,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
FileProgressInfo pinfo ;
|
FileProgressInfo pinfo ;
|
||||||
pinfo.progress = progress ;
|
pinfo.progress = progress ;
|
||||||
pinfo.cmap = CompressedChunkMap() ;
|
pinfo.cmap = CompressedChunkMap() ;
|
||||||
|
pinfo.type = FileProgressInfo::DOWNLOAD_LINE ;
|
||||||
|
|
||||||
addUploadItem(symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, completed, remaining);
|
addUploadItem(symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, completed, remaining);
|
||||||
ulCount++;
|
ulCount++;
|
||||||
@ -1090,37 +1116,13 @@ void TransfersDialog::cancel()
|
|||||||
queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?"));
|
queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?"));
|
||||||
|
|
||||||
if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok)
|
if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok)
|
||||||
{
|
|
||||||
for(int i = 0; i <= DLListModel->rowCount(); i++)
|
for(int i = 0; i <= DLListModel->rowCount(); i++)
|
||||||
{
|
|
||||||
if(selection->isRowSelected(i, QModelIndex()))
|
if(selection->isRowSelected(i, QModelIndex()))
|
||||||
{
|
{
|
||||||
QVector<QString> pri;
|
|
||||||
pri << "Low" << "Normal" << "High" << "Auto";
|
|
||||||
QString priority = getPriority(i, DLListModel).trimmed();
|
|
||||||
std::string id = getID(i, DLListModel).toStdString();
|
std::string id = getID(i, DLListModel).toStdString();
|
||||||
|
|
||||||
if (pri.indexOf(priority) >= 0)
|
|
||||||
{
|
|
||||||
/* for file that is just in dwl queue */
|
|
||||||
rsFiles->clearDownload(id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef UNUSED
|
|
||||||
QString qname = getFileName(i, DLListModel);
|
|
||||||
/* XXX -> Should not have to 'trim' filename ... something wrong here..
|
|
||||||
* but otherwise, not exact filename .... BUG
|
|
||||||
*/
|
|
||||||
std::string name = (qname.trimmed()).toStdString();
|
|
||||||
#endif
|
|
||||||
rsFiles->FileCancel(id); /* hash */
|
rsFiles->FileCancel(id); /* hash */
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::handleDownloadRequest(const QString& url){
|
void TransfersDialog::handleDownloadRequest(const QString& url){
|
||||||
@ -1452,17 +1454,17 @@ 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()
|
||||||
{
|
//{
|
||||||
std::set<QStandardItem *> items;
|
// std::set<QStandardItem *> items;
|
||||||
std::set<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 ++) {
|
||||||
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
// std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
||||||
rsFiles->clearDownload(hash);
|
// rsFiles->clearDownload(hash);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
void TransfersDialog::clearQueue()
|
void TransfersDialog::clearQueue()
|
||||||
{
|
{
|
||||||
rsFiles->clearQueue();
|
rsFiles->clearQueue();
|
||||||
@ -1488,24 +1490,37 @@ void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* modify download priority actions */
|
/* modify download priority actions */
|
||||||
void TransfersDialog::priorityLow()
|
void TransfersDialog::speedSlow()
|
||||||
{
|
{
|
||||||
changePriority(0);
|
changeSpeed(0);
|
||||||
}
|
}
|
||||||
void TransfersDialog::priorityNormal()
|
void TransfersDialog::speedAverage()
|
||||||
{
|
{
|
||||||
changePriority(1);
|
changeSpeed(1);
|
||||||
}
|
}
|
||||||
void TransfersDialog::priorityHigh()
|
void TransfersDialog::speedFast()
|
||||||
{
|
{
|
||||||
changePriority(2);
|
changeSpeed(2);
|
||||||
}
|
|
||||||
void TransfersDialog::priorityAuto()
|
|
||||||
{
|
|
||||||
changePriority(3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::changePriority(int priority)
|
void TransfersDialog::priorityQueueLow()
|
||||||
|
{
|
||||||
|
changeQueuePriority(0);
|
||||||
|
}
|
||||||
|
void TransfersDialog::priorityQueueNormal()
|
||||||
|
{
|
||||||
|
changeQueuePriority(1);
|
||||||
|
}
|
||||||
|
void TransfersDialog::priorityQueueHigh()
|
||||||
|
{
|
||||||
|
changeQueuePriority(2);
|
||||||
|
}
|
||||||
|
void TransfersDialog::priorityQueueAuto()
|
||||||
|
{
|
||||||
|
changeQueuePriority(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransfersDialog::changeSpeed(int speed)
|
||||||
{
|
{
|
||||||
std::set<QStandardItem *> items;
|
std::set<QStandardItem *> items;
|
||||||
std::set<QStandardItem *>::iterator it;
|
std::set<QStandardItem *>::iterator it;
|
||||||
@ -1513,7 +1528,21 @@ void TransfersDialog::changePriority(int priority)
|
|||||||
|
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
||||||
rsFiles->changePriority(hash, priority);
|
rsFiles->changeDownloadSpeed(hash, speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TransfersDialog::changeQueuePriority(int priority)
|
||||||
|
{
|
||||||
|
std::set<QStandardItem *> items;
|
||||||
|
std::set<QStandardItem *>::iterator it;
|
||||||
|
getIdOfSelectedItems(items);
|
||||||
|
|
||||||
|
for (it = items.begin(); it != items.end(); it ++)
|
||||||
|
{
|
||||||
|
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
||||||
|
rsFiles->changeQueuePriority(hash, priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,14 +85,20 @@ class TransfersDialog : public RsAutoUpdatePage
|
|||||||
void previewTransfer();
|
void previewTransfer();
|
||||||
|
|
||||||
/** clear download or all queue - for pending dwls */
|
/** clear download or all queue - for pending dwls */
|
||||||
void clearQueuedDwl();
|
|
||||||
void clearQueue();
|
void clearQueue();
|
||||||
|
|
||||||
/** modify download priority actions */
|
/** modify download priority actions */
|
||||||
void priorityLow();
|
void priorityQueueLow();
|
||||||
void priorityNormal();
|
void priorityQueueNormal();
|
||||||
void priorityHigh();
|
void priorityQueueHigh();
|
||||||
void priorityAuto();
|
void priorityQueueAuto();
|
||||||
|
|
||||||
|
void speedSlow();
|
||||||
|
void speedAverage();
|
||||||
|
void speedFast();
|
||||||
|
|
||||||
|
void changeSpeed(int) ;
|
||||||
|
void changeQueuePriority(int) ;
|
||||||
|
|
||||||
void chunkRandom();
|
void chunkRandom();
|
||||||
void chunkStreaming();
|
void chunkStreaming();
|
||||||
@ -146,6 +152,9 @@ class TransfersDialog : public RsAutoUpdatePage
|
|||||||
QAction *clearQueuedDwlAct;
|
QAction *clearQueuedDwlAct;
|
||||||
QAction *clearQueueAct;
|
QAction *clearQueueAct;
|
||||||
QAction *changePriorityAct;
|
QAction *changePriorityAct;
|
||||||
|
QAction *prioritySlowAct;
|
||||||
|
QAction *priorityMediumAct;
|
||||||
|
QAction *priorityFastAct;
|
||||||
QAction *priorityLowAct;
|
QAction *priorityLowAct;
|
||||||
QAction *priorityNormalAct;
|
QAction *priorityNormalAct;
|
||||||
QAction *priorityHighAct;
|
QAction *priorityHighAct;
|
||||||
|
@ -66,8 +66,8 @@ void xProgressBar::setColor()
|
|||||||
/* green schema */
|
/* green schema */
|
||||||
case 1:
|
case 1:
|
||||||
// background
|
// background
|
||||||
backgroundBorderColor.setRgb(3, 194, 26);
|
backgroundBorderColor.setRgb(53, 194, 26);
|
||||||
backgroundColor.setRgb(76, 214, 93);
|
backgroundColor.setRgb(176, 214, 93);
|
||||||
// progress
|
// progress
|
||||||
gradBorderColor.setRgb(8, 77, 16);
|
gradBorderColor.setRgb(8, 77, 16);
|
||||||
gradColor1.setRgb(0, 137, 16);
|
gradColor1.setRgb(0, 137, 16);
|
||||||
|
@ -39,6 +39,9 @@
|
|||||||
class FileProgressInfo
|
class FileProgressInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef enum { DOWNLOAD_LINE,UPLOAD_LINE,DOWNLOAD_SOURCE } LineType ;
|
||||||
|
|
||||||
|
LineType type ;
|
||||||
CompressedChunkMap cmap ;
|
CompressedChunkMap cmap ;
|
||||||
float progress ;
|
float progress ;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user