mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed up collection link display
This commit is contained in:
parent
e1d5014288
commit
9206daca37
@ -55,6 +55,9 @@ void FileTreeImpl::recurs_buildFileTree(FileTreeImpl& ft,uint32_t index,const Di
|
||||
|
||||
ft.mDirs[index].subfiles.push_back(ft.mFiles.size()) ;
|
||||
ft.mFiles.push_back(f) ;
|
||||
|
||||
ft.mTotalFiles++ ;
|
||||
ft.mTotalSize += f.size ;
|
||||
}
|
||||
else if(dd.children[i].type == DIR_TYPE_DIR)
|
||||
{
|
||||
@ -264,7 +267,8 @@ bool FileTreeImpl::serialise(unsigned char *& buffer,uint32_t& buffer_size) cons
|
||||
|
||||
void FileTreeImpl::print() const
|
||||
{
|
||||
recurs_print(0,"") ;
|
||||
std::cerr << "File hierarchy: name=" << mDirs[0].name << " size=" << mTotalSize << std::endl;
|
||||
recurs_print(0," ") ;
|
||||
}
|
||||
|
||||
void FileTreeImpl::recurs_print(uint32_t index,const std::string& indent) const
|
||||
|
@ -3,7 +3,11 @@
|
||||
class FileTreeImpl: public FileTree
|
||||
{
|
||||
public:
|
||||
FileTreeImpl() {}
|
||||
FileTreeImpl()
|
||||
{
|
||||
mTotalFiles = 0 ;
|
||||
mTotalSize = 0 ;
|
||||
}
|
||||
|
||||
virtual std::string toRadix64() const ;
|
||||
virtual bool getDirectoryContent(uint32_t index,std::vector<uint32_t>& subdirs,std::vector<FileData>& subfiles) const ;
|
||||
|
@ -578,7 +578,7 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
||||
std::cerr << "Created collection file tree:" << std::endl;
|
||||
ft->print();
|
||||
|
||||
RetroShareLink link = RetroShareLink::createCollection(QString::fromUtf8(details.name.c_str()), details.count,QString::fromStdString(ft->toRadix64())) ;
|
||||
RetroShareLink link = RetroShareLink::createCollection(QString::fromUtf8(details.name.c_str()),ft->mTotalSize,ft->mTotalFiles,QString::fromStdString(ft->toRadix64())) ;
|
||||
|
||||
if(link.valid())
|
||||
urls.push_back(link) ;
|
||||
|
@ -69,7 +69,7 @@
|
||||
#define HOST_CERTIFICATE "certificate"
|
||||
#define HOST_PUBLIC_MSG "public_msg"
|
||||
#define HOST_IDENTITY "identity"
|
||||
#define HOST_REGEXP "file|extra|person|forum|channel|posted|search|message|certificate|private_chat|public_msg|identity"
|
||||
#define HOST_REGEXP "file|collection|extra|person|forum|channel|posted|search|message|certificate|private_chat|public_msg|identity"
|
||||
|
||||
#define FILE_NAME "name"
|
||||
#define FILE_SIZE "size"
|
||||
@ -79,6 +79,7 @@
|
||||
#define COLLECTION_NAME "name"
|
||||
#define COLLECTION_SIZE "size"
|
||||
#define COLLECTION_DATA "radix"
|
||||
#define COLLECTION_COUNT "files"
|
||||
|
||||
#define PERSON_NAME "name"
|
||||
#define PERSON_HASH "hash"
|
||||
@ -337,8 +338,9 @@ void RetroShareLink::fromUrl(const QUrl& url)
|
||||
bool ok;
|
||||
_type = TYPE_COLLECTION;
|
||||
_radix = decodedQueryItemValue(urlQuery, COLLECTION_DATA);
|
||||
_name = decodedQueryItemValue(urlQuery, COLLECTION_NAME);
|
||||
_size = urlQuery.queryItemValue(COLLECTION_SIZE).toULongLong(&ok);
|
||||
_name = urlQuery.queryItemValue(COLLECTION_NAME).toULongLong(&ok);
|
||||
_count = urlQuery.queryItemValue(COLLECTION_COUNT).toULongLong(&ok);
|
||||
|
||||
#ifdef DEBUG_RSLINK
|
||||
std::cerr << "Got a certificate link!!" << std::endl;
|
||||
@ -418,12 +420,13 @@ RetroShareLink RetroShareLink::createFile(const QString& name, uint64_t size, co
|
||||
return link;
|
||||
}
|
||||
|
||||
RetroShareLink RetroShareLink::createCollection(const QString& name, const uint64_t size,const QString& radix_data)
|
||||
RetroShareLink RetroShareLink::createCollection(const QString& name, uint64_t size, uint32_t count, const QString& radix_data)
|
||||
{
|
||||
RetroShareLink link;
|
||||
link.clear();
|
||||
|
||||
link._name = name;
|
||||
link._count = count;
|
||||
link._size = size;
|
||||
link._radix = radix_data ;
|
||||
link._type = TYPE_COLLECTION;
|
||||
@ -899,8 +902,10 @@ QString RetroShareLink::toString() const
|
||||
case TYPE_COLLECTION:
|
||||
url.setScheme(RSLINK_SCHEME);
|
||||
url.setHost(HOST_COLLECTION) ;
|
||||
urlQuery.addQueryItem(CERTIFICATE_RADIX, encodeItem(_radix));
|
||||
urlQuery.addQueryItem(CERTIFICATE_NAME, encodeItem(_name));
|
||||
urlQuery.addQueryItem(COLLECTION_NAME, encodeItem(_name));
|
||||
urlQuery.addQueryItem(COLLECTION_SIZE, QString::number(_size));
|
||||
urlQuery.addQueryItem(COLLECTION_DATA, encodeItem(_radix));
|
||||
urlQuery.addQueryItem(COLLECTION_COUNT, QString::number(_count));
|
||||
break;
|
||||
|
||||
case TYPE_CERTIFICATE:
|
||||
@ -925,11 +930,14 @@ QString RetroShareLink::niceName() const
|
||||
if (type() == TYPE_PERSON)
|
||||
return PeerDefs::rsid(name().toUtf8().constData(), RsPgpId(hash().toStdString()));
|
||||
|
||||
if(type() == TYPE_COLLECTION)
|
||||
return QObject::tr("%1 (%2 files, %3)").arg(_name).arg(_count).arg(misc::friendlyUnit(_size));
|
||||
|
||||
if(type() == TYPE_IDENTITY)
|
||||
return QObject::tr("Identity link (name=%1, ID=%2)").arg(_name).arg(_hash) ;
|
||||
|
||||
if(type() == TYPE_COLLECTION)
|
||||
return QObject::tr("Click to browse/download this file collection");
|
||||
return QObject::tr("File directory (Total %s) Click to browse/download this file collection").arg(misc::friendlyUnit(_size));
|
||||
|
||||
if(type() == TYPE_PUBLIC_MSG) {
|
||||
RsPeerDetails detail;
|
||||
|
@ -81,7 +81,7 @@ class RetroShareLink
|
||||
static RetroShareLink createIdentity(const RsGxsId& gxs_id,const QString& name,const QString& radix_data) ;
|
||||
static RetroShareLink createExtraFile(const QString& name, uint64_t size, const QString& hash, const QString& ssl_id);
|
||||
static RetroShareLink createFile(const QString& name, uint64_t size, const QString& hash);
|
||||
static RetroShareLink createCollection(const QString& name, const uint64_t size,const QString& radix_data);
|
||||
static RetroShareLink createCollection(const QString& name, uint64_t size,uint32_t count,const QString& radix_data);
|
||||
static RetroShareLink createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ;
|
||||
static RetroShareLink createPerson(const RsPgpId &id);
|
||||
static RetroShareLink createCertificate(const RsPeerId &ssl_id) ;
|
||||
@ -169,6 +169,7 @@ class RetroShareLink
|
||||
QString _encrypted_chat_info ; // encrypted data string for the recipient of a chat invite
|
||||
time_t _time_stamp ; // time stamp at which the link will expire.
|
||||
QString _radix_group_data;
|
||||
uint32_t _count ;
|
||||
|
||||
unsigned int _subType; // for general use as sub type for _type (RSLINK_SUBTYPE_...)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user