diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index fc1ea2ec5..dabd4e1b3 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -19,14 +19,16 @@ #include #include +#include +#include +#include +#include #include "RetroShareLink.h" #define DEBUG_RSLINK 1 const QString RetroShareLink::HEADER_NAME("retroshare://file"); -std::vector RSLinkClipboard::_links ; - RetroShareLink::RetroShareLink(const QUrl& url) { // parse @@ -97,6 +99,10 @@ QString RetroShareLink::toString() const return HEADER_NAME + "|" + _name + "|" + QString::number(_size) + "|" + _hash ; } QString RetroShareLink::toHtml() const +{ + return QString("" + name() + "" ; +} +QString RetroShareLink::toHtmlFull() const { return QString("" + toString() + "" ; } @@ -147,3 +153,105 @@ bool RetroShareLink::checkHash(const QString& hash) return true ; } + +void RSLinkClipboard::copyLinks(const std::vector& links) +{ + QString res ; + for(uint32_t i=0;isetText(res) ; +} + +std::vector RSLinkClipboard::pasteLinks() +{ + return parseClipboard() ; +} + +std::vector RSLinkClipboard::parseClipboard() +{ + // parse clipboard for links. + // + std::vector links ; + QString text = QApplication::clipboard()->text() ; + + std::cerr << "Parsing clipboard:" << text.toStdString() << std::endl ; + + QRegExp rx("retroshare://file") ; + rx.setPatternSyntax(QRegExp::Wildcard) ; + + int pos = 0; + + while((pos = rx.indexIn(text, pos)) != -1) + { + QString txt = text.right(text.length()-pos) ; + QStringList lst = txt.split('|') ; + + if(lst.size() < 4) + break ; + + bool ok = false ; + RetroShareLink link(lst[1],lst[2].toULongLong(&ok),lst[3].left(40)) ; + + if(link.valid()) + { + // check that the link is not already in the list: + bool already = false ; + for(uint32_t i=0;i links(parseClipboard()) ; + + QString res ; + for(uint32_t i=0;i links(parseClipboard()) ; + + QString res ; + for(uint32_t i=0;i" ; + + return res ; +} +QString RSLinkClipboard::toHtmlFull() +{ + std::vector links(parseClipboard()) ; + + QString res ; + for(uint32_t i=0;i" ; + + return res ; +} +bool RSLinkClipboard::empty() +{ + return parseClipboard().empty() ; +} +