mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-09 07:02:41 -04:00
download recommended files from inside links cloud dialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1539 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b4ac276ce6
commit
44efa071f4
2 changed files with 91 additions and 39 deletions
|
@ -30,8 +30,10 @@
|
||||||
|
|
||||||
//#include "rshare.h"
|
//#include "rshare.h"
|
||||||
#include "LinksDialog.h"
|
#include "LinksDialog.h"
|
||||||
|
#include "RetroShareLinkAnalyzer.h"
|
||||||
#include "rsiface/rspeers.h"
|
#include "rsiface/rspeers.h"
|
||||||
#include "rsiface/rsrank.h"
|
#include "rsiface/rsrank.h"
|
||||||
|
#include "rsiface/rsfiles.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -53,6 +55,7 @@
|
||||||
#define IMAGE_OK ":/images/filerating3.png"
|
#define IMAGE_OK ":/images/filerating3.png"
|
||||||
#define IMAGE_SUX ":/images/filerating2.png"
|
#define IMAGE_SUX ":/images/filerating2.png"
|
||||||
#define IMAGE_BADLINK ":/images/filerating1.png"
|
#define IMAGE_BADLINK ":/images/filerating1.png"
|
||||||
|
#define IMAGE_DOWNLOAD ":/images/download16.png"
|
||||||
|
|
||||||
/******
|
/******
|
||||||
* #define LINKS_DEBUG 1
|
* #define LINKS_DEBUG 1
|
||||||
|
@ -166,10 +169,15 @@ void LinksDialog::linkTreeWidgetCostumPopupMenu( QPoint point )
|
||||||
connect( vote_m2 , SIGNAL( triggered() ), this, SLOT( voteup_m2() ) );
|
connect( vote_m2 , SIGNAL( triggered() ), this, SLOT( voteup_m2() ) );
|
||||||
voteMenu->addAction(vote_m2);
|
voteMenu->addAction(vote_m2);
|
||||||
|
|
||||||
|
downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr("Download"), this);
|
||||||
|
connect(downloadAct, SIGNAL(triggered()), this, SLOT(downloadSelected()));
|
||||||
|
|
||||||
contextMnu.clear();
|
contextMnu.clear();
|
||||||
contextMnu.addAction(voteupAct);
|
contextMnu.addAction(voteupAct);
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
contextMnu.addMenu(voteMenu);
|
contextMnu.addMenu(voteMenu);
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
contextMnu.addAction(downloadAct);
|
||||||
|
|
||||||
contextMnu.exec( mevent->globalPos() );
|
contextMnu.exec( mevent->globalPos() );
|
||||||
}
|
}
|
||||||
|
@ -942,3 +950,45 @@ void LinksDialog::voteup_m2()
|
||||||
voteup_score(-2);
|
voteup_score(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinksDialog::downloadSelected()
|
||||||
|
{
|
||||||
|
if (mLinkId == "")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsRankDetails detail;
|
||||||
|
if (!rsRanks->getRankDetails(mLinkId, detail))
|
||||||
|
{
|
||||||
|
/* not there! */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString link = QString::fromStdWString(detail.link);
|
||||||
|
std::wstring comment;
|
||||||
|
#ifdef LINKS_DEBUG
|
||||||
|
std::cerr << "LinksDialog::downloadSelected() : " << link.toStdString() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RetroShareLinkAnalyzer analyzer(QString::fromStdWString(detail.link));
|
||||||
|
QVector<RetroShareLinkData> linkList;
|
||||||
|
analyzer.getFileInformation(linkList);
|
||||||
|
if (!linkList.isEmpty())
|
||||||
|
{
|
||||||
|
/* regularly one link and choose it */
|
||||||
|
RetroShareLinkData item = linkList.first();
|
||||||
|
|
||||||
|
/* retrieve all peers id for this file */
|
||||||
|
FileInfo info;
|
||||||
|
rsFiles->FileDetails(item.getHash().toStdString(), 0, info);
|
||||||
|
|
||||||
|
std::list<std::string> srcIds;
|
||||||
|
std::list<TransferInfo>::iterator pit;
|
||||||
|
for (pit = info.peers.begin(); pit != info.peers.end(); pit ++)
|
||||||
|
{
|
||||||
|
srcIds.push_back(pit->peerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
rsFiles->FileRequest(item.getName().toStdString(), item.getHash().toStdString(), item.getSize().toULong(), "", 0, srcIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ private slots:
|
||||||
void voteup_p0();
|
void voteup_p0();
|
||||||
void voteup_m1();
|
void voteup_m1();
|
||||||
void voteup_m2();
|
void voteup_m2();
|
||||||
|
void downloadSelected();
|
||||||
|
|
||||||
void changedSortRank( int index );
|
void changedSortRank( int index );
|
||||||
void changedSortPeriod( int index );
|
void changedSortPeriod( int index );
|
||||||
|
@ -84,6 +85,7 @@ void updateComments(std::string rid, std::string pid);
|
||||||
/** Defines the actions for the context menu */
|
/** Defines the actions for the context menu */
|
||||||
QAction* voteupAct;
|
QAction* voteupAct;
|
||||||
QAction* votedownAct;
|
QAction* votedownAct;
|
||||||
|
QAction* downloadAct;
|
||||||
|
|
||||||
QTreeWidget *exampletreeWidget;
|
QTreeWidget *exampletreeWidget;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue