mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 23:40:26 -04:00
added Copy/Paste/Send retroshare//: file urls/links
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1257 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b7290c67ed
commit
30e4d8d078
12 changed files with 438 additions and 35 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "rshare.h"
|
||||
#include "TransfersDialog.h"
|
||||
#include "RetroShareLinkAnalyzer.h"
|
||||
#include "DLListDelegate.h"
|
||||
#include "ULListDelegate.h"
|
||||
|
||||
|
@ -43,7 +44,9 @@
|
|||
#define IMAGE_INFO ":/images/fileinfo.png"
|
||||
#define IMAGE_CANCEL ":/images/delete.png"
|
||||
#define IMAGE_CLEARCOMPLETED ":/images/deleteall.png"
|
||||
#define IMAGE_PLAY ":/images/player_play.png"
|
||||
#define IMAGE_PLAY ":/images/player_play.png"
|
||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||
#define IMAGE_PASTELINK ":/images/pasterslink.png"
|
||||
|
||||
/** Constructor */
|
||||
TransfersDialog::TransfersDialog(QWidget *parent)
|
||||
|
@ -188,9 +191,15 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||
connect( playAct , SIGNAL( triggered() ), this, SLOT( playSelectedTransfer() ) );
|
||||
}
|
||||
|
||||
cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this );
|
||||
cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this );
|
||||
connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) );
|
||||
|
||||
copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
|
||||
connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
|
||||
|
||||
pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste retroshare Link" ), this );
|
||||
connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
||||
|
||||
clearcompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this );
|
||||
connect( clearcompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) );
|
||||
|
||||
|
@ -203,6 +212,9 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||
|
||||
contextMnu.addAction( cancelAct);
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction( copylinkAct);
|
||||
contextMnu.addAction( pastelinkAct);
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction( clearcompletedAct);
|
||||
contextMnu.exec( mevent->globalPos() );
|
||||
}
|
||||
|
@ -627,6 +639,72 @@ void TransfersDialog::cancel()
|
|||
return;
|
||||
}
|
||||
|
||||
void TransfersDialog::handleDownloadRequest(const QString& url){
|
||||
|
||||
RetroShareLinkAnalyzer analyzer (url);
|
||||
|
||||
if (!analyzer.isValid ())
|
||||
return;
|
||||
|
||||
QVector<RetroShareLinkData> linkList;
|
||||
analyzer.getFileInformation (linkList);
|
||||
|
||||
std::list<std::string> srcIds;
|
||||
|
||||
for (int i = 0, n = linkList.size (); i < n; ++i)
|
||||
{
|
||||
const RetroShareLinkData& linkData = linkList[i];
|
||||
|
||||
rsFiles->FileRequest (linkData.getName ().toStdString (), linkData.getHash ().toStdString (),
|
||||
linkData.getSize ().toInt (), "", 0, srcIds);
|
||||
}
|
||||
}
|
||||
|
||||
void TransfersDialog::copyLink ()
|
||||
{
|
||||
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
||||
RetroShareLinkAnalyzer analyzer;
|
||||
|
||||
for (int i = 0; i < lst.count (); i++)
|
||||
{
|
||||
if ( lst[i].column() == 0 )
|
||||
{
|
||||
QModelIndex & ind = lst[i];
|
||||
QString fhash= ind.model ()->data (ind.model ()->index (ind.row (), ID )).toString() ;
|
||||
QString fsize= ind.model ()->data (ind.model ()->index (ind.row (), SIZE)).toString() ;
|
||||
QString fname= ind.model ()->data (ind.model ()->index (ind.row (), NAME)).toString() ;
|
||||
|
||||
analyzer.setRetroShareLink (fname, fsize, fhash);
|
||||
}
|
||||
}
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(analyzer.getRetroShareLink ());
|
||||
}
|
||||
|
||||
void TransfersDialog::pasteLink()
|
||||
{
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
RetroShareLinkAnalyzer analyzer (clipboard->text ());
|
||||
|
||||
if (!analyzer.isValid ())
|
||||
return;
|
||||
|
||||
QVector<RetroShareLinkData> linkList;
|
||||
analyzer.getFileInformation (linkList);
|
||||
|
||||
std::list<std::string> srcIds;
|
||||
|
||||
for (int i = 0, n = linkList.size (); i < n; ++i)
|
||||
{
|
||||
const RetroShareLinkData& linkData = linkList[i];
|
||||
//downloadFileRequested(linkData.getName (), linkData.getSize ().toInt (),
|
||||
// linkData.getHash (), "", -1, -1, -1, -1);
|
||||
rsFiles->FileRequest (linkData.getName ().toStdString (), linkData.getHash ().toStdString (),
|
||||
linkData.getSize ().toInt (), "", 0, srcIds);
|
||||
}
|
||||
}
|
||||
|
||||
void TransfersDialog::clearcompleted()
|
||||
{
|
||||
std::cerr << "TransfersDialog::clearcompleted()" << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue