mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-01 02:46:20 -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.chunk_size = _chunk_size ;
|
||||
info.chunks = _map ;
|
||||
info.strategy = _strategy ;
|
||||
|
||||
info.active_chunks.clear() ;
|
||||
|
||||
|
@ -112,6 +112,7 @@ bool ftController::getFileDownloadChunksDetails(const std::string& hash,FileChun
|
||||
return false ;
|
||||
|
||||
it->second.mCreator->getChunkMap(info) ;
|
||||
info.flags = it->second.mFlags ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@ -481,8 +482,10 @@ bool ftController::completeFile(std::string hash)
|
||||
callbackCode = fc->mCallbackCode;
|
||||
|
||||
mDataplex->removeTransferModule(hash_to_suppress) ;
|
||||
uint32_t flgs = fc->mFlags ;
|
||||
mDownloads.erase(it);
|
||||
|
||||
if(flgs & RS_FILE_HINTS_NETWORK_WIDE)
|
||||
mTurtle->stopMonitoringFileTunnels(hash_to_suppress) ;
|
||||
|
||||
} /******* UNLOCKED ********/
|
||||
@ -773,7 +776,9 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
||||
else
|
||||
{
|
||||
/* 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 */
|
||||
#ifdef CONTROL_DEBUG
|
||||
@ -840,7 +845,10 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
||||
if(flags & RS_FILE_HINTS_NETWORK_WIDE)
|
||||
mTurtle->monitorFileTunnels(fname,hash,size) ;
|
||||
else
|
||||
{
|
||||
std::cerr << "Warning: no flags supplied. Assuming availability. This is probably a bug." << std::endl ;
|
||||
flags |= RS_FILE_HINTS_ASSUME_AVAILABILITY ;
|
||||
}
|
||||
|
||||
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.filesize = fit->second.mSize;
|
||||
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);
|
||||
|
||||
@ -1560,7 +1568,7 @@ bool ftController::loadList(std::list<RsItem *> load)
|
||||
/* This will get stored on a waiting list - until the
|
||||
* 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) ;
|
||||
|
@ -264,6 +264,8 @@ class FileChunksInfo
|
||||
|
||||
uint64_t file_size ; // real size of the file
|
||||
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
|
||||
std::vector<ChunkState> chunks ;
|
||||
|
@ -197,6 +197,7 @@ uint32_t RsFileConfigSerialiser::sizeTransfer(RsFileTransfer *item)
|
||||
s += 4; /* lrate */
|
||||
s += 4; /* ltransfer */
|
||||
s += 4; // chunk_strategy
|
||||
s += 4; // flags
|
||||
s += 4; // chunk map size
|
||||
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->ltransfer);
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->flags);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->chunk_strategy);
|
||||
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->ltransfer));
|
||||
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->flags));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->chunk_strategy));
|
||||
uint32_t map_size = 0 ;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &map_size);
|
||||
|
@ -207,6 +207,7 @@ class RsFileTransfer: public RsItem
|
||||
uint32_t ltransfer;
|
||||
|
||||
// chunk information
|
||||
uint32_t flags ;
|
||||
uint32_t chunk_strategy ; // strategy flags for chunks
|
||||
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 += 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 += 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 += block_sep ;
|
||||
|
||||
|
@ -258,7 +258,13 @@ void SearchDialog::download()
|
||||
std::cerr << "SearchDialog::download() Calling File Request";
|
||||
std::cerr << std::endl;
|
||||
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()) ;
|
||||
#endif
|
||||
|
||||
if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toStdString(),
|
||||
(item->text(SR_HASH_COL)).toStdString(),
|
||||
@ -283,7 +289,9 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString
|
||||
{
|
||||
if (!item->childCount()) {
|
||||
std::list<std::string> srcIds;
|
||||
#ifdef SUSPENDED
|
||||
srcIds.push_back(item->text(SR_UID_COL).toStdString());
|
||||
#endif
|
||||
|
||||
QString path = QString::fromStdString(rsFiles->getDownloadDirectory())
|
||||
+ tr("/") + base + tr("/");
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "rshare.h"
|
||||
#include "TransfersDialog.h"
|
||||
@ -241,10 +242,14 @@ void TransfersDialog::keyPressEvent(QKeyEvent *e)
|
||||
|
||||
void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
||||
{
|
||||
|
||||
QMenu contextMnu( this );
|
||||
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||
|
||||
std::set<QStandardItem *> items;
|
||||
std::set<QStandardItem *>::iterator it;
|
||||
getIdOfSelectedItems(items);
|
||||
|
||||
bool single = (items.size() == 1) ;
|
||||
|
||||
/* check which item is selected
|
||||
* - if it is completed - play should appear in menu
|
||||
@ -272,6 +277,7 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
||||
playAct = new QAction(QIcon(IMAGE_PLAY), tr( "Play" ), this );
|
||||
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()));
|
||||
@ -297,8 +303,10 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
||||
clearcompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this );
|
||||
connect( clearcompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) );
|
||||
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
|
||||
connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
|
||||
#endif
|
||||
|
||||
pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste retroshare Link" ), this );
|
||||
connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
||||
@ -350,20 +358,47 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
||||
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);
|
||||
@ -1201,7 +1236,7 @@ void TransfersDialog::pasteLink()
|
||||
}
|
||||
}
|
||||
|
||||
void TransfersDialog::getIdOfSelectedItems(QList<QStandardItem *>& items)
|
||||
void TransfersDialog::getIdOfSelectedItems(std::set<QStandardItem *>& items)
|
||||
{
|
||||
items.clear();
|
||||
|
||||
@ -1230,7 +1265,7 @@ void TransfersDialog::getIdOfSelectedItems(QList<QStandardItem *>& items)
|
||||
/* if transfered file or it's peers are selected control it*/
|
||||
if (isParentSelected || isChildSelected) {
|
||||
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;
|
||||
|
||||
QList<QStandardItem *> items;
|
||||
QList<QStandardItem *>::iterator it;
|
||||
std::set<QStandardItem *> items;
|
||||
std::set<QStandardItem *>::iterator it;
|
||||
getIdOfSelectedItems(items);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
result &= rsFiles->FileControl((*it)->data(Qt::DisplayRole).toString().toStdString(), flags);
|
||||
@ -1269,8 +1304,8 @@ void TransfersDialog::openFolderTransfer()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
QList<QStandardItem *> items;
|
||||
QList<QStandardItem *>::iterator it;
|
||||
std::set<QStandardItem *> items;
|
||||
std::set<QStandardItem *>::iterator it;
|
||||
getIdOfSelectedItems(items);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||
@ -1299,8 +1334,8 @@ void TransfersDialog::previewTransfer()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
QList<QStandardItem *> items;
|
||||
QList<QStandardItem *>::iterator it;
|
||||
std::set<QStandardItem *> items;
|
||||
std::set<QStandardItem *>::iterator it;
|
||||
getIdOfSelectedItems(items);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||
@ -1359,8 +1394,8 @@ void TransfersDialog::openTransfer()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
QList<QStandardItem *> items;
|
||||
QList<QStandardItem *>::iterator it;
|
||||
std::set<QStandardItem *> items;
|
||||
std::set<QStandardItem *>::iterator it;
|
||||
getIdOfSelectedItems(items);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||
@ -1390,8 +1425,8 @@ void TransfersDialog::openTransfer()
|
||||
/* clear download or all queue - for pending dwls */
|
||||
void TransfersDialog::clearQueuedDwl()
|
||||
{
|
||||
QList<QStandardItem *> items;
|
||||
QList<QStandardItem *>::iterator it;
|
||||
std::set<QStandardItem *> items;
|
||||
std::set<QStandardItem *>::iterator it;
|
||||
getIdOfSelectedItems(items);
|
||||
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
@ -1414,8 +1449,8 @@ void TransfersDialog::chunkRandom()
|
||||
}
|
||||
void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
||||
{
|
||||
QList<QStandardItem *> items;
|
||||
QList<QStandardItem *>::iterator it;
|
||||
std::set<QStandardItem *> items;
|
||||
std::set<QStandardItem *>::iterator it;
|
||||
getIdOfSelectedItems(items);
|
||||
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
@ -1443,8 +1478,8 @@ void TransfersDialog::priorityAuto()
|
||||
|
||||
void TransfersDialog::changePriority(int priority)
|
||||
{
|
||||
QList<QStandardItem *> items;
|
||||
QList<QStandardItem *>::iterator it;
|
||||
std::set<QStandardItem *> items;
|
||||
std::set<QStandardItem *>::iterator it;
|
||||
getIdOfSelectedItems(items);
|
||||
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
|
@ -22,6 +22,8 @@
|
||||
#ifndef _TRANSFERSDIALOG_H
|
||||
#define _TRANSFERSDIALOG_H
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QProgressBar>
|
||||
#include <QtGui>
|
||||
@ -152,7 +154,7 @@ class TransfersDialog : public RsAutoUpdatePage
|
||||
QAction *chunkStreamingAct;
|
||||
QAction *detailsfileAct;
|
||||
|
||||
void getIdOfSelectedItems(QList<QStandardItem *>& items);
|
||||
void getIdOfSelectedItems(std::set<QStandardItem *>& items);
|
||||
bool controlTransferFile(uint32_t flags);
|
||||
void changePriority(int priority);
|
||||
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
|
||||
|
Loading…
Reference in New Issue
Block a user