mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-18 04:14:28 -05:00
added paste multiple links
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2516 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
ff0b797248
commit
0705d9dfc7
@ -1636,7 +1636,7 @@ void PeersDialog::anchorClicked (const QUrl& link )
|
||||
|
||||
if (link.scheme() == "retroshare")
|
||||
{
|
||||
RetroShareLink rslnk(link.toString()) ;
|
||||
RetroShareLink rslnk(link) ;
|
||||
|
||||
if (rslnk.valid())
|
||||
{
|
||||
|
@ -25,35 +25,31 @@
|
||||
|
||||
const QString RetroShareLink::HEADER_NAME("retroshare://file");
|
||||
|
||||
RetroShareLink::RetroShareLink(const QString & url)
|
||||
RetroShareLink::RetroShareLink(const QUrl& url)
|
||||
{
|
||||
// parse
|
||||
#ifdef DEBUG_RSLINK
|
||||
std::cerr << "got new RS link \"" << url.toStdString() << "\"" << std::endl ;
|
||||
std::cerr << "got new RS link \"" << url.toString().toStdString() << "\"" << std::endl ;
|
||||
#endif
|
||||
QStringList urlList = url.split ("\n");
|
||||
QStringList list = url.toString().split ("|");
|
||||
|
||||
if(urlList.isEmpty ())
|
||||
if(list.size() < 4)
|
||||
goto bad_link ;
|
||||
|
||||
{
|
||||
QStringList list = urlList[0].split ("|");
|
||||
bool ok ;
|
||||
|
||||
bool ok ;
|
||||
_name = list[1] ;
|
||||
_size = list[2].toULongLong(&ok) ;
|
||||
_hash = list[3].left(40) ; // normally not necessary, but it's a security.
|
||||
|
||||
_name = list[1] ;
|
||||
_size = list[2].toULongLong(&ok) ;
|
||||
_hash = list[3].left(40) ; // normally not necessary, but it's a security.
|
||||
|
||||
if(!ok)
|
||||
goto bad_link ;
|
||||
if(!ok)
|
||||
goto bad_link ;
|
||||
#ifdef DEBUG_RSLINK
|
||||
std::cerr << "New RetroShareLink forged:" << std::endl ;
|
||||
std::cerr << " name = \"" << _name.toStdString() << "\"" << std::endl ;
|
||||
std::cerr << " hash = \"" << _hash.toStdString() << "\"" << std::endl ;
|
||||
std::cerr << " size = " << _size << std::endl ;
|
||||
std::cerr << "New RetroShareLink forged:" << std::endl ;
|
||||
std::cerr << " name = \"" << _name.toStdString() << "\"" << std::endl ;
|
||||
std::cerr << " hash = \"" << _hash.toStdString() << "\"" << std::endl ;
|
||||
std::cerr << " size = " << _size << std::endl ;
|
||||
#endif
|
||||
}
|
||||
|
||||
check() ;
|
||||
|
||||
@ -122,6 +118,11 @@ bool RetroShareLink::checkName(const QString& name)
|
||||
return true ;
|
||||
}
|
||||
|
||||
QUrl RetroShareLink::toUrl() const
|
||||
{
|
||||
return QUrl(toString()) ;
|
||||
}
|
||||
|
||||
bool RetroShareLink::checkHash(const QString& hash)
|
||||
{
|
||||
if(hash.length() != 40)
|
||||
@ -140,4 +141,3 @@ bool RetroShareLink::checkHash(const QString& hash)
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,11 +27,12 @@
|
||||
#include <stdint.h>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QUrl>
|
||||
|
||||
class RetroShareLink
|
||||
{
|
||||
public:
|
||||
RetroShareLink(const QString& url);
|
||||
RetroShareLink(const QUrl& url);
|
||||
RetroShareLink(const QString& name, uint64_t size, const QString& hash);
|
||||
|
||||
uint64_t size() const { return _size ; }
|
||||
@ -39,10 +40,9 @@ class RetroShareLink
|
||||
const QString& hash() const { return _hash ; }
|
||||
|
||||
QString toString() const ;
|
||||
QUrl toUrl() const ;
|
||||
|
||||
bool valid() const { return _size > 0 ; }
|
||||
|
||||
static void parseForLinks(const QString& text,QList<RetroShareLink>& link_list) ;
|
||||
private:
|
||||
void check() ;
|
||||
static bool checkHash(const QString& hash) ;
|
||||
|
@ -254,11 +254,8 @@ void SearchDialog::searchtableWidgetCostumPopupMenu( QPoint point )
|
||||
contextMnu->addAction( downloadAct);
|
||||
contextMnu->addSeparator();
|
||||
|
||||
if ((ui.searchResultWidget->selectedItems()).size() == 1)
|
||||
{
|
||||
contextMnu->addAction( copysearchlinkAct);
|
||||
contextMnu->addAction( sendrslinkAct);
|
||||
}
|
||||
contextMnu->addAction( copysearchlinkAct);
|
||||
contextMnu->addAction( sendrslinkAct);
|
||||
}
|
||||
|
||||
QMouseEvent *mevent = new QMouseEvent(QEvent::MouseButtonPress,point,Qt::RightButton, Qt::RightButton,Qt::NoModifier);
|
||||
@ -1195,26 +1192,31 @@ void SearchDialog::copysearchLink()
|
||||
int numdls = itemsForCopy.size();
|
||||
QTreeWidgetItem * item;
|
||||
|
||||
QList<QUrl> urls ;
|
||||
|
||||
for (int i = 0; i < numdls; ++i)
|
||||
{
|
||||
item = itemsForCopy.at(i);
|
||||
// call copy
|
||||
{
|
||||
item = itemsForCopy.at(i);
|
||||
// call copy
|
||||
|
||||
if (!item->childCount())
|
||||
{
|
||||
std::cerr << "SearchDialog::copysearchLink() Calling set retroshare link";
|
||||
std::cerr << std::endl;
|
||||
if (!item->childCount())
|
||||
{
|
||||
std::cerr << "SearchDialog::copysearchLink() Calling set retroshare link";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QString fhash = item->text(SR_HASH_COL);
|
||||
qulonglong fsize = item->text(SR_REALSIZE_COL).toULongLong();
|
||||
QString fname = item->text(SR_NAME_COL);
|
||||
QString fhash = item->text(SR_HASH_COL);
|
||||
qulonglong fsize = item->text(SR_REALSIZE_COL).toULongLong();
|
||||
QString fname = item->text(SR_NAME_COL);
|
||||
|
||||
RetroShareLink link(fname, fsize, fhash);
|
||||
RetroShareLink link(fname, fsize, fhash);
|
||||
|
||||
QApplication::clipboard()->setText(link.toString());
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if(link.valid())
|
||||
urls.push_back(link.toUrl()) ;
|
||||
}
|
||||
}
|
||||
QMimeData *dt = new QMimeData;
|
||||
dt->setUrls(urls) ;
|
||||
QApplication::clipboard()->setMimeData(dt) ;
|
||||
}
|
||||
|
||||
void SearchDialog::sendLinkTo( )
|
||||
|
@ -251,43 +251,43 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
||||
else
|
||||
localModel->getDirDetailsFromSelect(lst, dirVec);
|
||||
|
||||
QList<QUrl> urls ;
|
||||
|
||||
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
||||
{
|
||||
const DirDetails& details = dirVec[i];
|
||||
|
||||
RetroShareLink link(details.name.c_str(), details.count, details.hash.c_str());
|
||||
|
||||
QApplication::clipboard()->setText(link.toString());
|
||||
#ifdef TO_DO_LATER
|
||||
if (details.type == DIR_TYPE_DIR)
|
||||
{
|
||||
for (std::list<DirStub>::const_iterator cit = details.children.begin();
|
||||
cit != details.children.end(); ++cit)
|
||||
for (std::list<DirStub>::const_iterator cit = details.children.begin();cit != details.children.end(); ++cit)
|
||||
{
|
||||
const DirStub& dirStub = *cit;
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (remote)
|
||||
{
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
}
|
||||
|
||||
// do not recursive copy sub dirs.
|
||||
if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE)
|
||||
continue;
|
||||
|
||||
analyzer.setRetroShareLink (details.name.c_str(), QString::number(details.count), details.hash.c_str());
|
||||
RetroShareLink link(details.name.c_str(), details.count, details.hash.c_str());
|
||||
urls.push_back(link.toUrl()) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
analyzer.setRetroShareLink (details.name.c_str(), QString::number(details.count), details.hash.c_str());
|
||||
#endif
|
||||
{
|
||||
RetroShareLink link(details.name.c_str(), details.count, details.hash.c_str());
|
||||
|
||||
urls.push_back(link.toUrl()) ;
|
||||
}
|
||||
}
|
||||
QMimeData *dt = new QMimeData ;
|
||||
dt->setUrls(urls) ;
|
||||
QApplication::clipboard()->setMimeData(dt) ;
|
||||
}
|
||||
|
||||
void SharedFilesDialog::copyLinkRemote()
|
||||
|
@ -1072,12 +1072,15 @@ void TransfersDialog::showDetailsDialog()
|
||||
|
||||
void TransfersDialog::pasteLink()
|
||||
{
|
||||
RetroShareLink link(QApplication::clipboard()->text());
|
||||
QList<QUrl> urllist = QApplication::clipboard()->mimeData()->urls() ;
|
||||
|
||||
if (!link.valid())
|
||||
return;
|
||||
for(QList<QUrl>::const_iterator it(urllist.begin());it!=urllist.end();++it)
|
||||
{
|
||||
RetroShareLink link(*it) ;
|
||||
|
||||
rsFiles->FileRequest(link.name().toStdString(), link.hash().toStdString(),link.size(), "", RS_FILE_HINTS_NETWORK_WIDE, std::list<std::string>());
|
||||
if (link.valid())
|
||||
rsFiles->FileRequest(link.name().toStdString(), link.hash().toStdString(),link.size(), "", RS_FILE_HINTS_NETWORK_WIDE, std::list<std::string>());
|
||||
}
|
||||
}
|
||||
|
||||
void TransfersDialog::getIdOfSelectedItems(std::set<QStandardItem *>& items)
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <gui/settings/rsharesettings.h>
|
||||
|
||||
#include <gui/RetroShareLink.h>
|
||||
#include <QtGui>
|
||||
#include <QFileDialog>
|
||||
#include <QString>
|
||||
@ -414,21 +415,14 @@ void CreateForumMsg::fileHashingFinished(AttachFileItem* file) {
|
||||
|
||||
void CreateForumMsg::pasteLink()
|
||||
{
|
||||
|
||||
QString link = QApplication::clipboard()->text();
|
||||
|
||||
if (link.startsWith("retroshare://", Qt::CaseInsensitive))
|
||||
{
|
||||
ui.forumMessage->setHtml("<a href='" + link + "'> " + link + "</a>");
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Clipboard does not contains RetroShare link('s)"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QUrl> list = QApplication::clipboard()->mimeData()->urls();
|
||||
|
||||
for(QList<QUrl>::const_iterator it(list.begin());it!=list.end();++it)
|
||||
{
|
||||
RetroShareLink link(*it) ;
|
||||
|
||||
if(link.valid())
|
||||
ui.forumMessage->insertHtml("<a href='" + link.toString() + "'> " + link.toString() + "</a> <br>") ;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user