fixed pasting of FileTree links in download queue

This commit is contained in:
csoler 2017-10-21 16:16:23 +02:00
parent 6581fa0429
commit fe516c6b7a
5 changed files with 21 additions and 17 deletions

View File

@ -517,7 +517,7 @@ void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
contextMnu.addAction( copylinkAct) ; contextMnu.addAction( copylinkAct) ;
contextMnu.addAction( sendlinkAct) ; contextMnu.addAction( sendlinkAct) ;
contextMnu.addSeparator() ;//------------------------------------ contextMnu.addSeparator() ;//------------------------------------
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg())) ; contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ;
} }
contextMnu.addSeparator() ;//------------------------------------ contextMnu.addSeparator() ;//------------------------------------
@ -578,7 +578,9 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
std::cerr << "Created collection file tree:" << std::endl; std::cerr << "Created collection file tree:" << std::endl;
ft->print(); ft->print();
RetroShareLink link = RetroShareLink::createCollection(QString::fromUtf8(details.name.c_str()),ft->mTotalSize,ft->mTotalFiles,QString::fromStdString(ft->toRadix64())) ; QString dir_name = QDir(QString::fromUtf8(details.name.c_str())).dirName();
RetroShareLink link = RetroShareLink::createCollection(dir_name,ft->mTotalSize,ft->mTotalFiles,QString::fromStdString(ft->toRadix64())) ;
if(link.valid()) if(link.valid())
urls.push_back(link) ; urls.push_back(link) ;
@ -1027,12 +1029,12 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
contextMnu.addSeparator() ;//------------------------------------ contextMnu.addSeparator() ;//------------------------------------
contextMnu.addMenu(&collectionMenu) ; contextMnu.addMenu(&collectionMenu) ;
contextMnu.addSeparator() ;//------------------------------------ contextMnu.addSeparator() ;//------------------------------------
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg())) ; contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ;
break ; break ;
default : default :
return ; return ;
}//switch (type) }
contextMnu.exec(QCursor::pos()) ; contextMnu.exec(QCursor::pos()) ;
} }

View File

@ -652,7 +652,8 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
QMenu contextMnu( this ); QMenu contextMnu( this );
if(!RSLinkClipboard::empty(RetroShareLink::TYPE_FILE)) add_PasteLink=true; if(!RSLinkClipboard::empty(RetroShareLink::TYPE_FILE)) add_PasteLink=true;
if(!RSLinkClipboard::empty(RetroShareLink::TYPE_FILE_TREE)) add_PasteLink=true;
if(!items.empty()) if(!items.empty())
{ {
@ -1640,6 +1641,7 @@ void TransfersDialog::updateDetailsDialog()
void TransfersDialog::pasteLink() void TransfersDialog::pasteLink()
{ {
RSLinkClipboard::process(RetroShareLink::TYPE_FILE); RSLinkClipboard::process(RetroShareLink::TYPE_FILE);
RSLinkClipboard::process(RetroShareLink::TYPE_FILE_TREE);
} }
void TransfersDialog::getDLSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows) void TransfersDialog::getDLSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows)

View File

@ -336,7 +336,7 @@ void RetroShareLink::fromUrl(const QUrl& url)
if (url.host() == HOST_COLLECTION) { if (url.host() == HOST_COLLECTION) {
bool ok; bool ok;
_type = TYPE_COLLECTION; _type = TYPE_FILE_TREE;
_radix = decodedQueryItemValue(urlQuery, COLLECTION_DATA); _radix = decodedQueryItemValue(urlQuery, COLLECTION_DATA);
_name = decodedQueryItemValue(urlQuery, COLLECTION_NAME); _name = decodedQueryItemValue(urlQuery, COLLECTION_NAME);
_size = urlQuery.queryItemValue(COLLECTION_SIZE).toULongLong(&ok); _size = urlQuery.queryItemValue(COLLECTION_SIZE).toULongLong(&ok);
@ -429,7 +429,7 @@ RetroShareLink RetroShareLink::createCollection(const QString& name, uint64_t si
link._count = count; link._count = count;
link._size = size; link._size = size;
link._radix = radix_data ; link._radix = radix_data ;
link._type = TYPE_COLLECTION; link._type = TYPE_FILE_TREE;
link.check(); link.check();
@ -643,7 +643,7 @@ void RetroShareLink::check()
if(!checkSSLId(_SSLid)) if(!checkSSLId(_SSLid))
_valid = false; // no break! We also test file stuff below. _valid = false; // no break! We also test file stuff below.
/* fallthrough */ /* fallthrough */
case TYPE_COLLECTION: case TYPE_FILE_TREE:
case TYPE_FILE: case TYPE_FILE:
if(_size > (((uint64_t)1)<<40)) // 1TB. Who has such large files? if(_size > (((uint64_t)1)<<40)) // 1TB. Who has such large files?
@ -754,7 +754,7 @@ QString RetroShareLink::title() const
rsPeers->getGPGDetails(RsPgpId(_GPGid.toStdString()), detail) ; rsPeers->getGPGDetails(RsPgpId(_GPGid.toStdString()), detail) ;
return QObject::tr("Click to send a private message to %1 (%2).").arg(QString::fromUtf8(detail.name.c_str())).arg(_GPGid) ; return QObject::tr("Click to send a private message to %1 (%2).").arg(QString::fromUtf8(detail.name.c_str())).arg(_GPGid) ;
} }
case TYPE_COLLECTION: case TYPE_FILE_TREE:
return QObject::tr("Click to browse/download this file collection"); return QObject::tr("Click to browse/download this file collection");
case TYPE_EXTRAFILE: case TYPE_EXTRAFILE:
return QObject::tr("%1 (%2, Extra - Source included)").arg(hash()).arg(misc::friendlyUnit(size())); return QObject::tr("%1 (%2, Extra - Source included)").arg(hash()).arg(misc::friendlyUnit(size()));
@ -899,7 +899,7 @@ QString RetroShareLink::toString() const
break; break;
case TYPE_COLLECTION: case TYPE_FILE_TREE:
url.setScheme(RSLINK_SCHEME); url.setScheme(RSLINK_SCHEME);
url.setHost(HOST_COLLECTION) ; url.setHost(HOST_COLLECTION) ;
urlQuery.addQueryItem(COLLECTION_NAME, encodeItem(_name)); urlQuery.addQueryItem(COLLECTION_NAME, encodeItem(_name));
@ -930,13 +930,13 @@ QString RetroShareLink::niceName() const
if (type() == TYPE_PERSON) if (type() == TYPE_PERSON)
return PeerDefs::rsid(name().toUtf8().constData(), RsPgpId(hash().toStdString())); return PeerDefs::rsid(name().toUtf8().constData(), RsPgpId(hash().toStdString()));
if(type() == TYPE_COLLECTION) if(type() == TYPE_FILE_TREE)
return QObject::tr("%1 (%2 files, %3)").arg(_name).arg(_count).arg(misc::friendlyUnit(_size)); return QObject::tr("%1 (%2 files, %3)").arg(_name).arg(_count).arg(misc::friendlyUnit(_size));
if(type() == TYPE_IDENTITY) if(type() == TYPE_IDENTITY)
return QObject::tr("Identity link (name=%1, ID=%2)").arg(_name).arg(_hash) ; return QObject::tr("Identity link (name=%1, ID=%2)").arg(_name).arg(_hash) ;
if(type() == TYPE_COLLECTION) if(type() == TYPE_FILE_TREE)
return QObject::tr("File directory (Total %s) Click to browse/download this file collection").arg(misc::friendlyUnit(_size)); return QObject::tr("File directory (Total %s) Click to browse/download this file collection").arg(misc::friendlyUnit(_size));
if(type() == TYPE_PUBLIC_MSG) { if(type() == TYPE_PUBLIC_MSG) {
@ -1149,7 +1149,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
case TYPE_SEARCH: case TYPE_SEARCH:
case TYPE_MESSAGE: case TYPE_MESSAGE:
case TYPE_IDENTITY: case TYPE_IDENTITY:
case TYPE_COLLECTION: case TYPE_FILE_TREE:
case TYPE_CERTIFICATE: case TYPE_CERTIFICATE:
case TYPE_PUBLIC_MSG: case TYPE_PUBLIC_MSG:
case TYPE_PRIVATE_CHAT: case TYPE_PRIVATE_CHAT:
@ -1391,7 +1391,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
} }
break; break;
case TYPE_COLLECTION: case TYPE_FILE_TREE:
{ {
FileTree *ft = FileTree::create(link.radix().toStdString()) ; FileTree *ft = FileTree::create(link.radix().toStdString()) ;

View File

@ -70,7 +70,7 @@ class RetroShareLink
TYPE_PUBLIC_MSG = 0x0a, TYPE_PUBLIC_MSG = 0x0a,
TYPE_POSTED = 0x0b, TYPE_POSTED = 0x0b,
TYPE_IDENTITY = 0x0c, TYPE_IDENTITY = 0x0c,
TYPE_COLLECTION = 0x0d TYPE_FILE_TREE = 0x0d
}; };
public: public:

View File

@ -227,7 +227,7 @@ bool RsHtml::canReplaceAnchor(QDomDocument &/*doc*/, QDomElement &/*element*/, c
switch (link.type()) { switch (link.type()) {
case RetroShareLink::TYPE_UNKNOWN: case RetroShareLink::TYPE_UNKNOWN:
case RetroShareLink::TYPE_FILE: case RetroShareLink::TYPE_FILE:
case RetroShareLink::TYPE_COLLECTION: case RetroShareLink::TYPE_FILE_TREE:
case RetroShareLink::TYPE_PERSON: case RetroShareLink::TYPE_PERSON:
case RetroShareLink::TYPE_FORUM: case RetroShareLink::TYPE_FORUM:
case RetroShareLink::TYPE_CHANNEL: case RetroShareLink::TYPE_CHANNEL:
@ -258,7 +258,7 @@ void RsHtml::anchorStylesheetForImg(QDomDocument &/*doc*/, QDomElement &/*elemen
switch (link.type()) { switch (link.type()) {
case RetroShareLink::TYPE_UNKNOWN: case RetroShareLink::TYPE_UNKNOWN:
case RetroShareLink::TYPE_FILE: case RetroShareLink::TYPE_FILE:
case RetroShareLink::TYPE_COLLECTION: case RetroShareLink::TYPE_FILE_TREE:
case RetroShareLink::TYPE_PERSON: case RetroShareLink::TYPE_PERSON:
case RetroShareLink::TYPE_FORUM: case RetroShareLink::TYPE_FORUM:
case RetroShareLink::TYPE_CHANNEL: case RetroShareLink::TYPE_CHANNEL: