ported branch v0.5.0 commits 2529 and 2544 to trunk

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2545 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-03-15 12:57:08 +00:00
parent a4d1e61aa2
commit cc17744ee3
13 changed files with 123 additions and 105 deletions

View file

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2009 *
* Copyright (C) 2009 Cyril Soler *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -24,6 +24,14 @@
//
// The link is done in a way that if valid()==true, then the link can be used.
//
// The following combinations have been tested:
// copy paste-> Transfers (DL) | Message compose (forums) | Private msg | Public chat | private Chat
// -------------+----------------+--------------------------+------------------+-------------+-------------
// search | Y | Y | Y (send RS link) | Paste menu? | Paste menu?
// -------------+----------------+--------------------------+------------------+-------------+-------------
// shared | Y | Y | Y (send RS link) | Paste menu? | Paste menu?
// -------------+----------------+--------------------------+------------------+-------------+-------------
//
#include <stdint.h>
#include <QString>
#include <QVector>
@ -39,7 +47,10 @@ class RetroShareLink
const QString& name() const { return _name ; }
const QString& hash() const { return _hash ; }
/// returns the string retroshare://file|name|size|hash
QString toString() const ;
/// returns the string <a href="retroshare://file|name|size|hash">retroshare://file|name|size|hash</a>
QString toHtml() const ;
QUrl toUrl() const ;
bool valid() const { return _size > 0 ; }
@ -55,5 +66,37 @@ class RetroShareLink
QString _hash;
};
/// This class handles the copy/paste of links. Every member is static to ensure unicity.
/// I put no mutex, because all calls supposely com from the GUI thread.
//
class RSLinkClipboard
{
public:
static void copyLinks(const std::vector<RetroShareLink>& links)
{
_links = links ;
}
static const std::vector<RetroShareLink>& pasteLinks()
{
return _links ;
}
static QString toHtml()
{
QString res ;
for(uint32_t i=0;i<_links.size();++i)
res += _links[i].toHtml() + "<br/>" ;
return res ;
}
static bool empty()
{
return _links.empty();
}
private:
static std::vector<RetroShareLink> _links ;
};
#endif