mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-06 05:14:21 -04:00
Merged branch that provide group-based file permissions.
Now users can sort peers into groups in the friend list, and attribute flags and parent groups to the directories in the share manager. Flags are B-B-N, meaning in order: - browsable for peers in the parent groups - browsable for everyone - network wide for everyone Backward compatibility makes previously BN flags been interpreted as -BN, meaning browsable/network wide for everyone. Be careful with this new feature. It has been tested, but it's a bit early to rely on it for highly sensitive data. The merge also includes a significant improvement of the naming of flags with incompatible types which should sort out some existing bugs as well, since inconsistencies in flag usage have been found during the process. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5787 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
6edb9eb4f8
64 changed files with 1389 additions and 824 deletions
|
@ -261,8 +261,8 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info
|
|||
y += text_height ; painter->drawText(20,y,tr("Chunk strategy") + ":") ; painter->drawText(tab_size,y,(info.strategy==FileChunksInfo::CHUNK_STRATEGY_RANDOM)?"Random":"Streaming") ;
|
||||
y += block_sep ;
|
||||
y += text_height ; painter->drawText(20,y,tr("Transfer type") + ":") ;
|
||||
if(info.flags & RS_FILE_HINTS_NETWORK_WIDE) painter->drawText(tab_size,y,tr("Anonymous F2F")) ;
|
||||
if(info.flags & RS_FILE_HINTS_ASSUME_AVAILABILITY) painter->drawText(tab_size,y,tr("Direct friend transfer / Availability assumed")) ;
|
||||
if(nfo.transfer_info_flags & RS_FILE_REQ_ANONYMOUS_ROUTING) painter->drawText(tab_size,y,tr("Anonymous F2F")) ;
|
||||
if(nfo.transfer_info_flags & RS_FILE_REQ_ASSUME_AVAILABILITY) painter->drawText(tab_size,y,tr("Direct friend transfer / Availability assumed")) ;
|
||||
y += text_height ;
|
||||
y += block_sep ;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
#include "settings/rsharesettings.h"
|
||||
|
||||
|
||||
|
@ -211,7 +212,7 @@ void QuickStartWizard::on_pushButtonSharesAdd_clicked()
|
|||
{
|
||||
SharedDirInfo sdi ;
|
||||
sdi.filename = dir ;
|
||||
sdi.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
|
||||
sdi.shareflags = DIR_FLAGS_BROWSABLE_OTHERS | DIR_FLAGS_NETWORK_WIDE_OTHERS ;
|
||||
|
||||
rsFiles->addSharedDirectory(sdi);
|
||||
|
||||
|
@ -307,8 +308,8 @@ void QuickStartWizard::loadShare()
|
|||
QCheckBox *cb1 = new QCheckBox ;
|
||||
QCheckBox *cb2 = new QCheckBox ;
|
||||
|
||||
cb1->setChecked( (*it).shareflags & RS_FILE_HINTS_NETWORK_WIDE ) ;
|
||||
cb2->setChecked( (*it).shareflags & RS_FILE_HINTS_BROWSABLE ) ;
|
||||
cb1->setChecked( (*it).shareflags & DIR_FLAGS_NETWORK_WIDE_OTHERS ) ;
|
||||
cb2->setChecked( (*it).shareflags & DIR_FLAGS_BROWSABLE_OTHERS ) ;
|
||||
|
||||
cb1->setToolTip(QString("If checked, the share is anonymously shared to anybody.")) ;
|
||||
cb2->setToolTip(QString("If checked, the share is browsable by your friends.")) ;
|
||||
|
@ -339,11 +340,11 @@ void QuickStartWizard::updateFlags(bool b)
|
|||
for(it = dirs.begin(); it != dirs.end(); it++,++row)
|
||||
{
|
||||
std::cerr << "Looking for row=" << row << ", file=" << (*it).filename << ", flags=" << (*it).shareflags << std::endl ;
|
||||
uint32_t current_flags = 0 ;
|
||||
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,1)))->isChecked()? RS_FILE_HINTS_NETWORK_WIDE:0 ;
|
||||
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,2)))->isChecked()? RS_FILE_HINTS_BROWSABLE:0 ;
|
||||
FileStorageFlags current_flags(0u) ;
|
||||
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,1)))->isChecked()? DIR_FLAGS_NETWORK_WIDE_OTHERS:(FileStorageFlags)0u ;
|
||||
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,2)))->isChecked()? DIR_FLAGS_BROWSABLE_OTHERS :(FileStorageFlags)0u ;
|
||||
|
||||
if( (*it).shareflags ^ current_flags )
|
||||
if( ((*it).shareflags ^ current_flags).toUInt32() )
|
||||
{
|
||||
(*it).shareflags = current_flags ;
|
||||
rsFiles->updateShareFlags(*it) ; // modifies the flags
|
||||
|
|
|
@ -91,11 +91,7 @@ bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const
|
|||
void *ref = parent.internalPointer();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_CHILDREN;
|
||||
if (RemoteMode)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
{
|
||||
|
@ -152,11 +148,7 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const
|
|||
void *ref = (parent.isValid())? parent.internalPointer() : NULL ;
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_CHILDREN;
|
||||
if (RemoteMode)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
{
|
||||
|
@ -202,16 +194,28 @@ int FlatStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
|
|||
{
|
||||
return 5;
|
||||
}
|
||||
QString RetroshareDirModel::getFlagsString(uint32_t flags)
|
||||
QString RetroshareDirModel::getFlagsString(FileStorageFlags flags)
|
||||
{
|
||||
switch(flags & (DIR_FLAGS_NETWORK_WIDE|DIR_FLAGS_BROWSABLE))
|
||||
char str[11] = "- - -" ;
|
||||
|
||||
if(flags & DIR_FLAGS_BROWSABLE_GROUPS) str[0] = 'B' ;
|
||||
//if(flags & DIR_FLAGS_NETWORK_WIDE_GROUPS) str[3] = 'N' ;
|
||||
if(flags & DIR_FLAGS_BROWSABLE_OTHERS) str[3] = 'B' ;
|
||||
if(flags & DIR_FLAGS_NETWORK_WIDE_OTHERS) str[6] = 'N' ;
|
||||
|
||||
return QString(str) ;
|
||||
}
|
||||
QString RetroshareDirModel::getGroupsString(const std::list<std::string>& groups)
|
||||
{
|
||||
QString groups_str ;
|
||||
|
||||
for(std::list<std::string>::const_iterator it(groups.begin());it!=groups.end();)
|
||||
{
|
||||
case DIR_FLAGS_NETWORK_WIDE: return tr("Anonymous") ;
|
||||
case DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE: return tr("Anonymous and browsable by friends") ;
|
||||
case DIR_FLAGS_BROWSABLE: return tr("Only browsable by friends") ;
|
||||
default:
|
||||
return QString() ;
|
||||
groups_str += QString::fromStdString(*it) ;
|
||||
if(++it != groups.end())
|
||||
groups_str += ", " ;
|
||||
}
|
||||
return groups_str ;
|
||||
}
|
||||
|
||||
QString RetroshareDirModel::getAgeIndicatorString(const DirDetails &details) const
|
||||
|
@ -320,13 +324,16 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
|||
return misc::userFriendlyDuration(details.age);
|
||||
case 3:
|
||||
return getFlagsString(details.flags);
|
||||
// case 4:
|
||||
// {
|
||||
// QString ind("");
|
||||
// if (ageIndicator != IND_ALWAYS)
|
||||
// ind = getAgeIndicatorString(details);
|
||||
// return ind;
|
||||
// }
|
||||
case 4:
|
||||
{
|
||||
QString ind("");
|
||||
if (ageIndicator != IND_ALWAYS)
|
||||
ind = getAgeIndicatorString(details);
|
||||
return ind;
|
||||
}
|
||||
return getGroupsString(details.parent_groups) ;
|
||||
|
||||
default:
|
||||
return tr("FILE");
|
||||
}
|
||||
|
@ -348,6 +355,9 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
|||
return misc::userFriendlyDuration(details.min_age);
|
||||
case 3:
|
||||
return getFlagsString(details.flags);
|
||||
case 4:
|
||||
return getGroupsString(details.parent_groups) ;
|
||||
|
||||
default:
|
||||
return tr("DIR");
|
||||
}
|
||||
|
@ -359,7 +369,7 @@ QString FlatStyle_RDM::computeDirectoryPath(const DirDetails& details) const
|
|||
{
|
||||
QString dir ;
|
||||
DirDetails det(details) ;
|
||||
uint32_t flags = (RemoteMode)?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if(!requestDirDetails(det.parent,det,flags))
|
||||
return QString();
|
||||
|
@ -500,11 +510,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
|
|||
int coln = index.column();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (RemoteMode)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
return QVariant();
|
||||
|
@ -564,12 +570,8 @@ void RetroshareDirModel::getAgeIndicatorRec(DirDetails &details, QString &ret) c
|
|||
for (it = details.children.begin(); it != details.children.end(); it++) {
|
||||
void *ref = it->ref;
|
||||
DirDetails childDetails;
|
||||
uint32_t flags;
|
||||
|
||||
if (RemoteMode)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (requestDirDetails(ref, childDetails, flags) && ret == tr(""))
|
||||
getAgeIndicatorRec(childDetails, ret);
|
||||
|
@ -612,7 +614,10 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
|||
else
|
||||
return tr("Share Type");
|
||||
case 4:
|
||||
return tr("What's new");
|
||||
if (RemoteMode)
|
||||
return tr("What's new");
|
||||
else
|
||||
return tr("Groups");
|
||||
}
|
||||
return QString("Column %1").arg(section);
|
||||
}
|
||||
|
@ -683,11 +688,7 @@ QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent
|
|||
********/
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_CHILDREN;
|
||||
if (RemoteMode)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
{
|
||||
|
@ -766,7 +767,7 @@ QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
|
|||
void *ref = index.internalPointer();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = (RemoteMode)?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
{
|
||||
|
@ -817,11 +818,7 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
|
|||
void *ref = index.internalPointer();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (RemoteMode)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
return Qt::ItemIsSelectable; // Error.
|
||||
|
@ -871,7 +868,7 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
|
|||
#endif
|
||||
}
|
||||
|
||||
bool RetroshareDirModel::requestDirDetails(void *ref,DirDetails& details,uint32_t flags) const
|
||||
bool RetroshareDirModel::requestDirDetails(void *ref,DirDetails& details,FileSearchFlags flags) const
|
||||
{
|
||||
// We should use a cache instead of calling RsFiles::RequestDirDetails(), which is very costly
|
||||
// due to some pointer checking crap.
|
||||
|
@ -929,7 +926,7 @@ void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
|
|||
std::list<std::string> srcIds;
|
||||
srcIds.push_back(details.id);
|
||||
rsFiles -> FileRequest(details.name, details.hash,
|
||||
details.count, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds);
|
||||
details.count, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
|
||||
}
|
||||
/* if it is a dir, copy all files included*/
|
||||
else if (details.type == DIR_TYPE_DIR)
|
||||
|
@ -950,7 +947,7 @@ void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int pr
|
|||
QString cleanPath = QDir::cleanPath(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()) + "/" + QString::fromUtf8(dirDetails.path.substr(prefixLen).c_str()));
|
||||
|
||||
srcIds.push_back(dirDetails.id);
|
||||
rsFiles->FileRequest(dirDetails.name, dirDetails.hash, dirDetails.count, cleanPath.toUtf8().constData(), RS_FILE_HINTS_NETWORK_WIDE, srcIds);
|
||||
rsFiles->FileRequest(dirDetails.name, dirDetails.hash, dirDetails.count, cleanPath.toUtf8().constData(), RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
|
||||
}
|
||||
else if (dirDetails.type & DIR_TYPE_DIR)
|
||||
{
|
||||
|
@ -965,7 +962,7 @@ void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int pr
|
|||
if (!it->ref) continue;
|
||||
|
||||
DirDetails subDirDetails;
|
||||
uint32_t flags = DIR_FLAGS_CHILDREN | DIR_FLAGS_REMOTE;
|
||||
FileSearchFlags flags = RS_FILE_HINTS_REMOTE ;
|
||||
|
||||
if (!requestDirDetails(it->ref, subDirDetails, flags)) continue;
|
||||
|
||||
|
@ -987,20 +984,10 @@ void RetroshareDirModel::getDirDetailsFromSelect (const QModelIndexList &list, s
|
|||
void *ref = it -> internalPointer();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (RemoteMode)
|
||||
{
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
}
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
dirVec.push_back(details);
|
||||
}
|
||||
|
@ -1035,12 +1022,7 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s
|
|||
void *ref = it -> internalPointer();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
|
||||
if (RemoteMode)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
continue;
|
||||
|
@ -1136,10 +1118,8 @@ void RetroshareDirModel::getFilePaths(const QModelIndexList &list, std::list<std
|
|||
void *ref = it -> internalPointer();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
if (!requestDirDetails(ref, details, RS_FILE_HINTS_LOCAL))
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "getFilePaths() Bad Request" << std::endl;
|
||||
|
@ -1193,15 +1173,7 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
|
|||
void *ref = it -> internalPointer();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (RemoteMode)
|
||||
{
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
}
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!requestDirDetails(ref, details, flags))
|
||||
{
|
||||
|
@ -1278,7 +1250,7 @@ int RetroshareDirModel::getType ( const QModelIndex & index ) const
|
|||
//if (RemoteMode) // only local files can be opened
|
||||
// return ;
|
||||
|
||||
uint32_t flags = RemoteMode?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
|
||||
return rsFiles->getType(index.internalPointer(),flags);
|
||||
}
|
||||
|
@ -1327,10 +1299,9 @@ void FlatStyle_RDM::updateRefs()
|
|||
std::cerr << "FlatStyle_RDM::postMods(): poped ref " << ref << std::endl;
|
||||
#endif
|
||||
_ref_stack.pop_back() ;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
DirDetails details ;
|
||||
|
||||
if (requestDirDetails(ref, details, flags))
|
||||
if (requestDirDetails(ref, details, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_REMOTE))
|
||||
{
|
||||
if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons.
|
||||
_ref_entries.push_back(std::pair<void*,QString>(ref,computeDirectoryPath(details)));
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <QIcon>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
class DirDetails;
|
||||
|
||||
|
@ -65,7 +66,7 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
|
||||
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
||||
|
||||
bool requestDirDetails(void *ref,DirDetails& details,uint32_t flags) const;
|
||||
bool requestDirDetails(void *ref,DirDetails& details,FileSearchFlags flags) const;
|
||||
void update() ;
|
||||
public:
|
||||
|
||||
|
@ -79,7 +80,8 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||
|
||||
void treeStyle();
|
||||
void downloadDirectory(const DirDetails & details, int prefixLen);
|
||||
static QString getFlagsString(uint32_t) ;
|
||||
static QString getFlagsString(FileStorageFlags f) ;
|
||||
static QString getGroupsString(const std::list<std::string>&) ;
|
||||
QString getAgeIndicatorString(const DirDetails &) const;
|
||||
void getAgeIndicatorRec(DirDetails &details, QString &ret) const;
|
||||
|
||||
|
|
|
@ -973,7 +973,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
|||
srcIds.push_back((*it).peerId) ;
|
||||
}
|
||||
|
||||
if (rsFiles->FileRequest(link.name().toUtf8().constData(), link.hash().toStdString(), link.size(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) {
|
||||
if (rsFiles->FileRequest(link.name().toUtf8().constData(), link.hash().toStdString(), link.size(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) {
|
||||
fileAdded.append(link.name());
|
||||
} else {
|
||||
fileExist.append(link.name());
|
||||
|
|
|
@ -353,7 +353,7 @@ void SearchDialog::download()
|
|||
std::string hash = item->text(SR_HASH_COL).toStdString();
|
||||
getSourceFriendsForHash(hash,srcIds) ;
|
||||
|
||||
if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toUtf8().constData(), hash, (item->text(SR_SIZE_COL)).toULongLong(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds))
|
||||
if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toUtf8().constData(), hash, (item->text(SR_SIZE_COL)).toULongLong(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds))
|
||||
attemptDownloadLocal = true ;
|
||||
else
|
||||
{
|
||||
|
@ -384,7 +384,7 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString
|
|||
rsFiles->FileRequest(item->text(SR_NAME_COL).toUtf8().constData(),
|
||||
hash,
|
||||
item->text(SR_SIZE_COL).toULongLong(),
|
||||
cleanPath.toUtf8().constData(),RS_FILE_HINTS_NETWORK_WIDE, srcIds);
|
||||
cleanPath.toUtf8().constData(),RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
|
||||
|
||||
std::cout << "SearchDialog::downloadDirectory(): "\
|
||||
"issuing file request from search dialog: -"
|
||||
|
@ -607,7 +607,7 @@ void SearchDialog::advancedSearch(Expression* expression)
|
|||
// The text "bool exp" should be replaced by an appropriate text describing the actual search.
|
||||
initSearchResult("bool exp",req_id, ui.FileTypeComboBox->currentIndex(), true) ;
|
||||
|
||||
rsFiles -> SearchBoolExp(expression, results, DIR_FLAGS_REMOTE | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE);
|
||||
rsFiles -> SearchBoolExp(expression, results, RS_FILE_HINTS_REMOTE);// | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE);
|
||||
|
||||
/* abstraction to allow reusee of tree rendering code */
|
||||
resultsToTree(advSearchDialog->getSearchAsString(),req_id, results);
|
||||
|
@ -689,7 +689,7 @@ void SearchDialog::searchKeywords(const QString& keywords)
|
|||
{
|
||||
std::list<DirDetails> initialResults;
|
||||
|
||||
rsFiles->SearchBoolExp(&exprs, initialResults, DIR_FLAGS_REMOTE) ;
|
||||
rsFiles->SearchBoolExp(&exprs, initialResults, RS_FILE_HINTS_REMOTE) ;
|
||||
|
||||
/* which extensions do we use? */
|
||||
DirDetails dd;
|
||||
|
@ -705,7 +705,7 @@ void SearchDialog::searchKeywords(const QString& keywords)
|
|||
{
|
||||
std::list<DirDetails> initialResults;
|
||||
|
||||
rsFiles->SearchBoolExp(&exprs, initialResults, DIR_FLAGS_LOCAL | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE) ;
|
||||
rsFiles->SearchBoolExp(&exprs, initialResults, RS_FILE_HINTS_LOCAL);// | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE) ;
|
||||
|
||||
/* which extensions do we use? */
|
||||
DirDetails dd;
|
||||
|
@ -859,7 +859,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
|
|||
/* go through all children directories/files for a recursive call */
|
||||
for (std::list<DirStub>::const_iterator it(dir.children.begin()); it != dir.children.end(); it ++) {
|
||||
DirDetails details;
|
||||
rsFiles->RequestDirDetails(it->ref, details, 0);
|
||||
rsFiles->RequestDirDetails(it->ref, details, FileSearchFlags(0u));
|
||||
insertDirectory(txt, searchId, details, child);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,19 @@
|
|||
#include "ShareDialog.h"
|
||||
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QLayout>
|
||||
#include <QTextEdit>
|
||||
#include <QComboBox>
|
||||
#include <QSizePolicy>
|
||||
#include <QGroupBox>
|
||||
|
||||
#include <gui/common/GroupSelectionBox.h>
|
||||
#include <gui/common/GroupFlagsWidget.h>
|
||||
|
||||
/** Default constructor */
|
||||
ShareDialog::ShareDialog(std::string filename, QWidget *parent, Qt::WFlags flags)
|
||||
|
@ -43,16 +51,43 @@ ShareDialog::ShareDialog(std::string filename, QWidget *parent, Qt::WFlags flags
|
|||
|
||||
ui.okButton->setEnabled(false);
|
||||
|
||||
if (filename.empty()) {
|
||||
ui.networkwideCheckBox->setChecked(true);
|
||||
} else {
|
||||
/* edit exisiting share */
|
||||
QVBoxLayout *vbox = new QVBoxLayout() ;
|
||||
|
||||
QHBoxLayout *hb2 = new QHBoxLayout() ;
|
||||
hb2->addWidget(new QLabel(tr("Share flags and groups: "))) ;
|
||||
|
||||
groupflagsbox = new GroupFlagsWidget(ui.shareflags_GB) ;
|
||||
groupflagsbox->setFlags(DIR_FLAGS_NETWORK_WIDE_OTHERS) ; // default value
|
||||
|
||||
messageBox = new QTextEdit(ui.shareflags_GB) ;
|
||||
messageBox->setReadOnly(true) ;
|
||||
messageBox->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred)) ;
|
||||
|
||||
hb2->addWidget(groupflagsbox) ;
|
||||
|
||||
vbox->addLayout(hb2) ;
|
||||
vbox->addWidget(messageBox) ;
|
||||
|
||||
QHBoxLayout *hbox = new QHBoxLayout() ;
|
||||
groupselectionbox = new GroupSelectionBox(ui.shareflags_GB);
|
||||
hbox->addLayout(vbox) ;
|
||||
hbox->addWidget(groupselectionbox) ;
|
||||
|
||||
ui.shareflags_GB->setLayout(hbox) ;
|
||||
updateInfoMessage() ;
|
||||
|
||||
connect(groupselectionbox,SIGNAL(itemSelectionChanged()),this,SLOT(updateInfoMessage())) ;
|
||||
connect(groupflagsbox,SIGNAL(flagsChanged(FileStorageFlags)),this,SLOT(updateInfoMessage())) ;
|
||||
|
||||
if (!filename.empty())
|
||||
{
|
||||
std::list<SharedDirInfo> dirs;
|
||||
rsFiles->getSharedDirectories(dirs);
|
||||
|
||||
std::list<SharedDirInfo>::const_iterator it;
|
||||
for (it = dirs.begin(); it != dirs.end(); it++) {
|
||||
if (it->filename == filename) {
|
||||
if (it->filename == filename)
|
||||
{
|
||||
/* fill dialog */
|
||||
ui.okButton->setEnabled(true);
|
||||
|
||||
|
@ -61,14 +96,20 @@ ShareDialog::ShareDialog(std::string filename, QWidget *parent, Qt::WFlags flags
|
|||
ui.browseButton->setDisabled(true);
|
||||
ui.virtualpath_lineEdit->setText(QString::fromUtf8(it->virtualname.c_str()));
|
||||
|
||||
ui.browsableCheckBox->setChecked(it->shareflags & RS_FILE_HINTS_BROWSABLE);
|
||||
ui.networkwideCheckBox->setChecked(it->shareflags & RS_FILE_HINTS_NETWORK_WIDE);
|
||||
groupflagsbox->setFlags(it->shareflags) ;
|
||||
groupselectionbox->setSelectedGroups(it->parent_groups) ;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::updateInfoMessage()
|
||||
{
|
||||
messageBox->setText(GroupFlagsWidget::groupInfoString(groupflagsbox->flags(),groupselectionbox->selectedGroups())) ;
|
||||
}
|
||||
|
||||
void ShareDialog::browseDirectory()
|
||||
{
|
||||
/* select a dir*/
|
||||
|
@ -88,20 +129,16 @@ void ShareDialog::addDirectory()
|
|||
SharedDirInfo sdi ;
|
||||
sdi.filename = ui.localpath_lineEdit->text().toUtf8().constData();
|
||||
sdi.virtualname = ui.virtualpath_lineEdit->text().toUtf8().constData();
|
||||
sdi.shareflags = groupflagsbox->flags() ;
|
||||
sdi.parent_groups = groupselectionbox->selectedGroups() ;
|
||||
|
||||
sdi.shareflags = 0;
|
||||
|
||||
if (ui.browsableCheckBox->isChecked()) {
|
||||
sdi.shareflags |= RS_FILE_HINTS_BROWSABLE ;
|
||||
}
|
||||
if (ui.networkwideCheckBox->isChecked()) {
|
||||
sdi.shareflags |= RS_FILE_HINTS_NETWORK_WIDE;
|
||||
}
|
||||
|
||||
if (ui.localpath_lineEdit->isEnabled()) {
|
||||
if (ui.localpath_lineEdit->isEnabled())
|
||||
{
|
||||
/* add new share */
|
||||
rsFiles->addSharedDirectory(sdi);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* edit exisiting share */
|
||||
bool found = false;
|
||||
|
||||
|
@ -115,13 +152,15 @@ void ShareDialog::addDirectory()
|
|||
|
||||
if (it->virtualname != sdi.virtualname) {
|
||||
/* virtual name changed, remove shared directory and add it again */
|
||||
|
||||
rsFiles->removeSharedDirectory(it->filename);
|
||||
rsFiles->addSharedDirectory(sdi);
|
||||
break;
|
||||
}
|
||||
if (it->shareflags ^ sdi.shareflags) {
|
||||
if (it->shareflags != sdi.shareflags || it->parent_groups != sdi.parent_groups) {
|
||||
/* modifies the flags */
|
||||
it->shareflags = sdi.shareflags;
|
||||
it->parent_groups = sdi.parent_groups;
|
||||
rsFiles->updateShareFlags(*it);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -26,22 +26,30 @@
|
|||
|
||||
#include "ui_ShareDialog.h"
|
||||
|
||||
class GroupFlagsWidget ;
|
||||
class GroupSelectionBox ;
|
||||
class QTextEdit ;
|
||||
|
||||
class ShareDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default constructor */
|
||||
ShareDialog( std::string filename, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default destructor */
|
||||
public:
|
||||
/** Default constructor */
|
||||
ShareDialog( std::string filename, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
|
||||
private slots:
|
||||
void browseDirectory();
|
||||
void addDirectory();
|
||||
private slots:
|
||||
void browseDirectory();
|
||||
void addDirectory();
|
||||
void updateInfoMessage() ;
|
||||
|
||||
private:
|
||||
/** Qt Designer generated object */
|
||||
Ui::ShareDialog ui;
|
||||
private:
|
||||
/** Qt Designer generated object */
|
||||
Ui::ShareDialog ui;
|
||||
|
||||
GroupSelectionBox *groupselectionbox ;
|
||||
GroupFlagsWidget *groupflagsbox ;
|
||||
QTextEdit *messageBox ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<property name="lineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<zorder>groupBox</zorder>
|
||||
<zorder>frame_2</zorder>
|
||||
<zorder>groupBox</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
@ -45,17 +48,14 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="6">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Share Folder</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
|
@ -108,101 +108,87 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Share Flags</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="browsableCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Browseable by Friends</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browsable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="networkwideCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Anonymous shared Network Wide</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Network Wide</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="okButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="shareflags_GB">
|
||||
<property name="title">
|
||||
<string>Share Flags</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="okButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -27,10 +27,12 @@
|
|||
#include <QUrl>
|
||||
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
#include "ShareManager.h"
|
||||
#include "ShareDialog.h"
|
||||
#include "settings/rsharesettings.h"
|
||||
#include <gui/common/GroupFlagsWidget.h>
|
||||
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_CANCEL ":/images/delete.png"
|
||||
|
@ -38,9 +40,8 @@
|
|||
|
||||
#define COLUMN_PATH 0
|
||||
#define COLUMN_VIRTUALNAME 1
|
||||
#define COLUMN_NETWORKWIDE 2
|
||||
#define COLUMN_BROWSABLE 3
|
||||
#define COLUMN_COUNT 3
|
||||
#define COLUMN_SHARE_FLAGS 2
|
||||
#define COLUMN_GROUPS 3
|
||||
|
||||
ShareManager *ShareManager::_instance = NULL ;
|
||||
|
||||
|
@ -73,15 +74,12 @@ ShareManager::ShareManager()
|
|||
QHeaderView* header = ui.shareddirList->horizontalHeader();
|
||||
header->setResizeMode( COLUMN_PATH, QHeaderView::Stretch);
|
||||
|
||||
header->setResizeMode(COLUMN_NETWORKWIDE, QHeaderView::Fixed);
|
||||
header->setResizeMode(COLUMN_BROWSABLE, QHeaderView::Fixed);
|
||||
//header->setResizeMode(COLUMN_NETWORKWIDE, QHeaderView::Fixed);
|
||||
//header->setResizeMode(COLUMN_BROWSABLE, QHeaderView::Fixed);
|
||||
|
||||
header->setHighlightSections(false);
|
||||
|
||||
ui.shareddirList->setRangeSelected(QTableWidgetSelectionRange(0, 0, 0, COLUMN_COUNT), true);
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
}
|
||||
|
||||
|
@ -124,79 +122,35 @@ void ShareManager::load()
|
|||
/* set new row count */
|
||||
listWidget->setRowCount(dirs.size());
|
||||
|
||||
connect(this,SIGNAL(itemClicked(QTableWidgetItem*)),this,SLOT(updateFlags(QTableWidgetItem*))) ;
|
||||
|
||||
#ifndef USE_COMBOBOX
|
||||
QString ToolTips [2] = { tr("If checked, the share is anonymously shared to anybody."),
|
||||
tr("If checked, the share is browsable by your friends.") };
|
||||
int Flags [2] = { RS_FILE_HINTS_NETWORK_WIDE, RS_FILE_HINTS_BROWSABLE };
|
||||
#endif
|
||||
|
||||
int row=0 ;
|
||||
for(it = dirs.begin(); it != dirs.end(); it++,++row)
|
||||
{
|
||||
listWidget->setItem(row, COLUMN_PATH, new QTableWidgetItem(QString::fromUtf8((*it).filename.c_str())));
|
||||
listWidget->setItem(row, COLUMN_VIRTUALNAME, new QTableWidgetItem(QString::fromUtf8((*it).virtualname.c_str())));
|
||||
|
||||
#ifdef USE_COMBOBOX
|
||||
QComboBox *cb = new QComboBox ;
|
||||
cb->addItem(QString("Network Wide")) ;
|
||||
cb->addItem(QString("Browsable")) ;
|
||||
cb->addItem(QString("Universal")) ;
|
||||
GroupFlagsWidget *widget = new GroupFlagsWidget(NULL,(*it).shareflags);
|
||||
|
||||
cb->setToolTip(QString("Decide here whether this directory is\n* Network Wide: \tanonymously shared over the network (including your friends)\n* Browsable: \tbrowsable by your friends\n* Universal: \t\tboth")) ;
|
||||
listWidget->setRowHeight(row, 32);
|
||||
listWidget->setCellWidget(row, COLUMN_SHARE_FLAGS, widget);
|
||||
|
||||
// TODO
|
||||
// - set combobox current value depending on what rsFiles reports.
|
||||
// - use a signal mapper to get the correct row that contains the combo box sending the signal:
|
||||
// mapper = new SignalMapper(this) ;
|
||||
//
|
||||
// for(all cb)
|
||||
// {
|
||||
// signalMapper->setMapping(cb,...)
|
||||
// }
|
||||
//
|
||||
int index = 0 ;
|
||||
index += ((*it).shareflags & RS_FILE_HINTS_NETWORK_WIDE) > 0 ;
|
||||
index += (((*it).shareflags & RS_FILE_HINTS_BROWSABLE) > 0) * 2 ;
|
||||
listWidget->setCellWidget(row,1,cb);
|
||||
QString group_string ;
|
||||
int n=0;
|
||||
for(std::list<std::string>::const_iterator it2((*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2,++n)
|
||||
{
|
||||
if(n>0)
|
||||
group_string += ", " ;
|
||||
|
||||
if(index < 1 || index > 3)
|
||||
std::cerr << "******* ERROR IN FILE SHARING FLAGS. Flags = " << (*it).shareflags << " ***********" << std::endl ;
|
||||
else
|
||||
index-- ;
|
||||
group_string += QString::fromStdString(*it2) ;
|
||||
}
|
||||
|
||||
cb->setCurrentIndex(index) ;
|
||||
#else
|
||||
int col;
|
||||
for (col = 0; col <= 1; col++) {
|
||||
QModelIndex index = listWidget->model()->index(row, col + COLUMN_NETWORKWIDE, QModelIndex());
|
||||
QWidget* widget = dynamic_cast<QWidget*>(listWidget->indexWidget(index));
|
||||
QCheckBox* cb = NULL;
|
||||
if (widget) {
|
||||
cb = dynamic_cast<QCheckBox*>(widget->children().front());
|
||||
}
|
||||
if (cb == NULL) {
|
||||
QWidget* widget = new QWidget;
|
||||
listWidget->setItem(row, COLUMN_GROUPS, new QTableWidgetItem(group_string)) ;
|
||||
listWidget->item(row,COLUMN_GROUPS)->setBackgroundColor(QColor(183,236,181)) ;
|
||||
|
||||
cb = new QCheckBox(widget);
|
||||
cb->setToolTip(ToolTips [col]);
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout(widget);
|
||||
layout->addWidget(cb, 0, Qt::AlignCenter);
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(10, 0, 0, 0); // to be centered
|
||||
widget->setLayout(layout);
|
||||
|
||||
listWidget->setCellWidget(row, col + COLUMN_NETWORKWIDE, widget);
|
||||
|
||||
QObject::connect(cb, SIGNAL(toggled(bool)), this, SLOT(updateFlags(bool))) ;
|
||||
}
|
||||
cb->setChecked((*it).shareflags & Flags [col]);
|
||||
}
|
||||
#endif
|
||||
connect(widget,SIGNAL(flagsChanged(FileStorageFlags)),this,SLOT(updateFlags())) ;
|
||||
}
|
||||
|
||||
listWidget->setColumnWidth(COLUMN_SHARE_FLAGS,132) ;
|
||||
|
||||
//ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));
|
||||
|
||||
listWidget->update(); /* update display */
|
||||
|
@ -225,12 +179,12 @@ void ShareManager::showYourself()
|
|||
}
|
||||
}
|
||||
|
||||
void ShareManager::updateFlags(bool b)
|
||||
void ShareManager::updateFlags()
|
||||
{
|
||||
if(isLoading)
|
||||
return ;
|
||||
|
||||
std::cerr << "Updating flags (b=" << b << ") !!!" << std::endl ;
|
||||
std::cerr << "Updating flags" << std::endl;
|
||||
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
std::list<SharedDirInfo> dirs;
|
||||
|
@ -239,17 +193,15 @@ void ShareManager::updateFlags(bool b)
|
|||
int row=0 ;
|
||||
for(it = dirs.begin(); it != dirs.end(); it++,++row)
|
||||
{
|
||||
std::cerr << "Looking for row=" << row << ", file=" << (*it).filename << ", flags=" << (*it).shareflags << std::endl ;
|
||||
uint32_t current_flags = 0 ;
|
||||
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,COLUMN_NETWORKWIDE)->children().front()))->isChecked()? RS_FILE_HINTS_NETWORK_WIDE:0 ;
|
||||
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,COLUMN_BROWSABLE)->children().front()))->isChecked()? RS_FILE_HINTS_BROWSABLE:0 ;
|
||||
//std::cerr << "Looking for row=" << row << ", file=" << (*it).filename << ", flags=" << (*it).shareflags << std::endl ;
|
||||
FileStorageFlags current_flags = (dynamic_cast<GroupFlagsWidget*>(ui.shareddirList->cellWidget(row,COLUMN_SHARE_FLAGS)))->flags() ;
|
||||
|
||||
if( (*it).shareflags ^ current_flags )
|
||||
if( (*it).shareflags != current_flags )
|
||||
{
|
||||
(*it).shareflags = current_flags ;
|
||||
rsFiles->updateShareFlags(*it) ; // modifies the flags
|
||||
|
||||
std::cout << "Updating share flags for directory " << (*it).filename << std::endl ;
|
||||
std::cout << "Updating share flags for directory " << (*it).filename << " to " << current_flags << std::endl ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +309,7 @@ void ShareManager::dropEvent(QDropEvent *event)
|
|||
sdi.filename = localpath.toUtf8().constData();
|
||||
sdi.virtualname.clear();
|
||||
|
||||
sdi.shareflags = 0;
|
||||
sdi.shareflags.clear() ;
|
||||
|
||||
/* add new share */
|
||||
rsFiles->addSharedDirectory(sdi);
|
||||
|
|
|
@ -59,7 +59,7 @@ private slots:
|
|||
void showShareDialog();
|
||||
void editShareDirectory();
|
||||
void removeShareDirectory();
|
||||
void updateFlags(bool);
|
||||
void updateFlags();
|
||||
|
||||
private:
|
||||
static ShareManager *_instance;
|
||||
|
|
|
@ -81,14 +81,23 @@ p, li { white-space: pre-wrap; }
|
|||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>100</number>
|
||||
<number>128</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
|
@ -108,7 +117,7 @@ p, li { white-space: pre-wrap; }
|
|||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Network Wide</string>
|
||||
<string>Share flags</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string comment="If activated, the share is anonymously accessible to anybody"/>
|
||||
|
@ -116,7 +125,7 @@ p, li { white-space: pre-wrap; }
|
|||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Browsable</string>
|
||||
<string>Parent groups</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string comment="If checked, the share is browsable by your friends"/>
|
||||
|
|
|
@ -157,17 +157,12 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
|||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * l_header = ui.localDirTreeView->header () ;
|
||||
// l_header->setResizeMode (0, QHeaderView::Interactive);
|
||||
// l_header->setResizeMode (1, QHeaderView::Fixed);
|
||||
// l_header->setResizeMode (2, QHeaderView::Interactive);
|
||||
// l_header->setResizeMode (3, QHeaderView::Interactive);
|
||||
// l_header->setResizeMode (4, QHeaderView::Interactive);
|
||||
|
||||
l_header->resizeSection ( 0, 490 );
|
||||
l_header->resizeSection ( 1, 70 );
|
||||
l_header->resizeSection ( 2, 100 );
|
||||
l_header->resizeSection ( 3, 100 );
|
||||
// l_header->resizeSection ( 4, 100 );
|
||||
l_header->resizeSection ( 4, 100 );
|
||||
|
||||
l_header->setStretchLastSection(false);
|
||||
// l_header->setHighlightSections(false);
|
||||
|
@ -210,7 +205,7 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
|||
// Hide columns after loading the settings
|
||||
ui.remoteDirTreeView->setColumnHidden(3,false) ;
|
||||
ui.remoteDirTreeView->setColumnHidden(4,true) ;
|
||||
ui.localDirTreeView->setColumnHidden(4,true) ;
|
||||
ui.localDirTreeView->setColumnHidden(4,false) ;
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
@ -468,11 +463,7 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
|||
const DirStub& dirStub = *cit;
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (remote)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = remote?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
|
||||
|
||||
// do not recursive copy sub dirs.
|
||||
if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE)
|
||||
|
|
|
@ -945,7 +945,7 @@ void TransfersDialog::insertTransfers()
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((fileInfo.flags & RS_FILE_HINTS_CACHE) && !showCacheTransfers) {
|
||||
if ((fileInfo.transfer_info_flags & RS_FILE_REQ_CACHE) && !showCacheTransfers) {
|
||||
// if file transfer is a cache file index file, don't show it
|
||||
DLListModel->removeRow(row);
|
||||
rowCount = DLListModel->rowCount();
|
||||
|
@ -971,7 +971,7 @@ void TransfersDialog::insertTransfers()
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((fileInfo.flags & RS_FILE_HINTS_CACHE) && !showCacheTransfers) {
|
||||
if ((fileInfo.transfer_info_flags & RS_FILE_REQ_CACHE) && !showCacheTransfers) {
|
||||
//if file transfer is a cache file index file, don't show it
|
||||
continue;
|
||||
}
|
||||
|
@ -998,7 +998,7 @@ void TransfersDialog::insertTransfers()
|
|||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info))
|
||||
continue;
|
||||
|
||||
if((info.flags & RS_FILE_HINTS_CACHE) && showCacheTransfers)
|
||||
if((info.transfer_info_flags & RS_FILE_REQ_CACHE) && showCacheTransfers)
|
||||
continue ;
|
||||
|
||||
std::list<TransferInfo>::iterator pit;
|
||||
|
|
174
retroshare-gui/src/gui/common/GroupFlagsWidget.cpp
Normal file
174
retroshare-gui/src/gui/common/GroupFlagsWidget.cpp
Normal file
|
@ -0,0 +1,174 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QSizePolicy>
|
||||
#include "GroupFlagsWidget.h"
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
#define FLAGS_GROUP_NETWORK_WIDE_ICON ":images/anonymous_128_green.png"
|
||||
#define FLAGS_GROUP_BROWSABLE_ICON ":images/browsable_128_green.png"
|
||||
#define FLAGS_GROUP_UNCHECKED ":images/blank_128_green.png"
|
||||
#define FLAGS_OTHER_NETWORK_WIDE_ICON ":images/anonymous_128_blue.png"
|
||||
#define FLAGS_OTHER_BROWSABLE_ICON ":images/browsable_128_blue.png"
|
||||
#define FLAGS_OTHER_UNCHECKED ":images/blank_128_blue.png"
|
||||
|
||||
#define INDEX_GROUP_BROWSABLE 0
|
||||
#define INDEX_GROUP_NETWORK_W 1
|
||||
#define INDEX_OTHER_BROWSABLE 2
|
||||
#define INDEX_OTHER_NETWORK_W 3
|
||||
#define INDEX_GROUP_UNCHECKED 4
|
||||
#define INDEX_OTHER_UNCHECKED 5
|
||||
|
||||
QString GroupFlagsWidget::_tooltips_on[4] = {
|
||||
QObject::tr("Directory is browsable for friends from parent groups"),
|
||||
QObject::tr("Directory is accessible by anonymous tunnels from friends from parent groups"),
|
||||
QObject::tr("Directory is browsable for any friend"),
|
||||
QObject::tr("Directory is accessible by anonymous tunnels from any friend")
|
||||
};
|
||||
QString GroupFlagsWidget::_tooltips_off[4] = {
|
||||
QObject::tr(""),
|
||||
QObject::tr(""),
|
||||
QObject::tr(""),
|
||||
QObject::tr("")
|
||||
};
|
||||
|
||||
GroupFlagsWidget::GroupFlagsWidget(QWidget *parent,FileStorageFlags flags)
|
||||
: QWidget(parent)
|
||||
{
|
||||
_layout = new QHBoxLayout(this) ;
|
||||
|
||||
setMinimumSize(128,32) ;
|
||||
setMaximumSize(128,32) ;
|
||||
setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
||||
|
||||
_icons[INDEX_GROUP_BROWSABLE] = new QIcon(FLAGS_GROUP_BROWSABLE_ICON) ;
|
||||
_icons[INDEX_GROUP_NETWORK_W] = new QIcon(FLAGS_GROUP_NETWORK_WIDE_ICON) ;
|
||||
_icons[INDEX_OTHER_BROWSABLE] = new QIcon(FLAGS_OTHER_BROWSABLE_ICON) ;
|
||||
_icons[INDEX_OTHER_NETWORK_W] = new QIcon(FLAGS_OTHER_NETWORK_WIDE_ICON) ;
|
||||
_icons[INDEX_GROUP_UNCHECKED] = new QIcon(FLAGS_GROUP_UNCHECKED) ;
|
||||
_icons[INDEX_OTHER_UNCHECKED] = new QIcon(FLAGS_OTHER_UNCHECKED) ;
|
||||
|
||||
setLayout(_layout) ;
|
||||
|
||||
_flags[0] = DIR_FLAGS_BROWSABLE_GROUPS ;
|
||||
_flags[1] = DIR_FLAGS_NETWORK_WIDE_GROUPS ;
|
||||
_flags[2] = DIR_FLAGS_BROWSABLE_OTHERS ;
|
||||
_flags[3] = DIR_FLAGS_NETWORK_WIDE_OTHERS ;
|
||||
|
||||
for(int i=0;i<4;++i)
|
||||
{
|
||||
_buttons[i] = new QPushButton(this) ;
|
||||
_buttons[i]->setCheckable(true) ;
|
||||
_buttons[i]->setChecked(flags & _flags[i]) ;
|
||||
_buttons[i]->setIconSize(QSize(32,32));
|
||||
update_button_state(_buttons[i]->isChecked(),i) ;
|
||||
_layout->addWidget(_buttons[i]) ;
|
||||
}
|
||||
_buttons[INDEX_GROUP_NETWORK_W]->setHidden(true);
|
||||
|
||||
connect(_buttons[INDEX_GROUP_NETWORK_W],SIGNAL(toggled(bool)),this,SLOT(update_GN_button(bool))) ;
|
||||
connect(_buttons[INDEX_OTHER_NETWORK_W],SIGNAL(toggled(bool)),this,SLOT(update_ON_button(bool))) ;
|
||||
connect(_buttons[INDEX_GROUP_BROWSABLE],SIGNAL(toggled(bool)),this,SLOT(update_GB_button(bool))) ;
|
||||
connect(_buttons[INDEX_OTHER_BROWSABLE],SIGNAL(toggled(bool)),this,SLOT(update_OB_button(bool))) ;
|
||||
|
||||
_layout->setSpacing(0);
|
||||
_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
_layout->update() ;
|
||||
}
|
||||
|
||||
void GroupFlagsWidget::updated()
|
||||
{
|
||||
emit flagsChanged(flags()) ;
|
||||
}
|
||||
|
||||
FileStorageFlags GroupFlagsWidget::flags() const
|
||||
{
|
||||
FileStorageFlags flags ;
|
||||
|
||||
for(int i=0;i<4;++i)
|
||||
if(_buttons[i]->isChecked()) flags |= _flags[i] ;
|
||||
|
||||
flags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ;
|
||||
return flags ;
|
||||
}
|
||||
|
||||
void GroupFlagsWidget::setFlags(FileStorageFlags flags)
|
||||
{
|
||||
for(int i=0;i<4;++i)
|
||||
{
|
||||
_buttons[i]->setChecked(flags & _flags[i]) ;
|
||||
update_button_state(_buttons[i]->isChecked(),i) ;
|
||||
}
|
||||
}
|
||||
|
||||
void GroupFlagsWidget::update_button_state(bool b,int button_id)
|
||||
{
|
||||
if(b)
|
||||
{
|
||||
_buttons[button_id]->setIcon(*_icons[button_id]) ;
|
||||
_buttons[button_id]->setToolTip(_tooltips_on[button_id]) ;
|
||||
}
|
||||
else if(button_id == INDEX_GROUP_NETWORK_W || button_id == INDEX_GROUP_BROWSABLE)
|
||||
{
|
||||
_buttons[button_id]->setIcon(*_icons[INDEX_GROUP_UNCHECKED]) ;
|
||||
_buttons[button_id]->setToolTip(_tooltips_off[button_id]) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
_buttons[button_id]->setIcon(*_icons[INDEX_OTHER_UNCHECKED]) ;
|
||||
_buttons[button_id]->setToolTip(_tooltips_off[button_id]) ;
|
||||
}
|
||||
}
|
||||
|
||||
QString GroupFlagsWidget::groupInfoString(FileStorageFlags flags,const std::list<std::string>& groups)
|
||||
{
|
||||
// makes a string that explains how files are shared / visible.
|
||||
|
||||
QString res ;
|
||||
QString groups_string ;
|
||||
|
||||
for(std::list<std::string>::const_iterator it(groups.begin());it!=groups.end();++it)
|
||||
{
|
||||
if(it != groups.begin())
|
||||
groups_string += ", " ;
|
||||
groups_string += QString::fromStdString(*it) ;
|
||||
}
|
||||
|
||||
if(flags & DIR_FLAGS_BROWSABLE_OTHERS)
|
||||
res += tr("All your friends can browse this directory\n") ;
|
||||
else if(flags & DIR_FLAGS_BROWSABLE_GROUPS)
|
||||
if(!groups.empty())
|
||||
res += tr("Only friends in groups ") + groups_string + tr(" can browse this directory\n") ;
|
||||
else
|
||||
res += tr("No one can browse this directory\n") ;
|
||||
else
|
||||
res += tr("No one can browse this directory\n") ;
|
||||
|
||||
if(flags & DIR_FLAGS_NETWORK_WIDE_OTHERS)
|
||||
res += tr("All your friends can relay anonymous tunnels to this directory") ;
|
||||
else if(flags & DIR_FLAGS_NETWORK_WIDE_GROUPS)
|
||||
res += tr("Only friends in groups ") + groups_string + tr(" can relay anonymous tunnels to this directory") ;
|
||||
else
|
||||
res += tr("No one can anonymously access this directory.") ;
|
||||
|
||||
//if(flags.toUInt32() == 0)
|
||||
// res += tr("No friends can access nor see this directory.") ;
|
||||
|
||||
return res ;
|
||||
}
|
||||
|
||||
void GroupFlagsWidget::update_GN_button(bool b) { update_button_state(b,INDEX_GROUP_NETWORK_W) ; updated() ; }
|
||||
void GroupFlagsWidget::update_GB_button(bool b) { update_button_state(b,INDEX_GROUP_BROWSABLE) ; updated() ; }
|
||||
void GroupFlagsWidget::update_ON_button(bool b) { update_button_state(b,INDEX_OTHER_NETWORK_W) ; updated() ; }
|
||||
void GroupFlagsWidget::update_OB_button(bool b) { update_button_state(b,INDEX_OTHER_BROWSABLE) ; updated() ; }
|
||||
|
||||
GroupFlagsWidget::~GroupFlagsWidget()
|
||||
{
|
||||
for(int i=0;i<4;++i)
|
||||
{
|
||||
delete _buttons[i] ;
|
||||
delete _icons[i] ;
|
||||
}
|
||||
delete _icons[INDEX_GROUP_UNCHECKED] ;
|
||||
delete _icons[INDEX_OTHER_UNCHECKED] ;
|
||||
}
|
||||
|
43
retroshare-gui/src/gui/common/GroupFlagsWidget.h
Normal file
43
retroshare-gui/src/gui/common/GroupFlagsWidget.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <QPushButton>
|
||||
#include <QFrame>
|
||||
#include <retroshare/rsflags.h>
|
||||
|
||||
class GroupFlagsWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GroupFlagsWidget(QWidget *parent,FileStorageFlags flags = FileStorageFlags(0u)) ;
|
||||
virtual ~GroupFlagsWidget() ;
|
||||
|
||||
FileStorageFlags flags() const ;
|
||||
void setFlags(FileStorageFlags flags) ;
|
||||
|
||||
static QString groupInfoString(FileStorageFlags flags,const std::list<std::string>& groups) ;
|
||||
public slots:
|
||||
void updated() ;
|
||||
|
||||
protected slots:
|
||||
void update_GN_button(bool) ;
|
||||
void update_GB_button(bool) ;
|
||||
void update_ON_button(bool) ;
|
||||
void update_OB_button(bool) ;
|
||||
|
||||
signals:
|
||||
void flagsChanged(FileStorageFlags) const ;
|
||||
|
||||
private:
|
||||
void update_button_state(bool b,int id) ;
|
||||
|
||||
QPushButton *_buttons[4] ;
|
||||
|
||||
QLayout *_layout ;
|
||||
QIcon *_icons[6] ;
|
||||
FileStorageFlags _flags[4] ;
|
||||
|
||||
static QString _tooltips_on[4] ;
|
||||
static QString _tooltips_off[4] ;
|
||||
};
|
43
retroshare-gui/src/gui/common/GroupSelectionBox.cpp
Normal file
43
retroshare-gui/src/gui/common/GroupSelectionBox.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include <retroshare/rspeers.h>
|
||||
#include "GroupSelectionBox.h"
|
||||
|
||||
GroupSelectionBox::GroupSelectionBox(QWidget *parent)
|
||||
: QListWidget(parent)
|
||||
{
|
||||
setSelectionMode(QAbstractItemView::ExtendedSelection) ;
|
||||
|
||||
// Fill with available groups
|
||||
|
||||
std::list<RsGroupInfo> lst ;
|
||||
rsPeers->getGroupInfoList(lst) ;
|
||||
|
||||
for(std::list<RsGroupInfo>::const_iterator it(lst.begin());it!=lst.end();++it)
|
||||
addItem(QString::fromStdString(it->id)) ;
|
||||
|
||||
for(int i=0;i<count();++i)
|
||||
item(i)->setBackgroundColor(QColor(183,236,181)) ;
|
||||
}
|
||||
|
||||
std::list<std::string> GroupSelectionBox::selectedGroups() const
|
||||
{
|
||||
QList<QListWidgetItem*> selected_items = selectedItems() ;
|
||||
std::list<std::string> out ;
|
||||
|
||||
for(QList<QListWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||
{
|
||||
out.push_back((*it)->text().toStdString()) ;
|
||||
std::cerr << "Addign selected item " << out.back() << std::endl;
|
||||
}
|
||||
|
||||
return out ;
|
||||
}
|
||||
|
||||
void GroupSelectionBox::setSelectedGroups(const std::list<std::string>& group_ids)
|
||||
{
|
||||
for(std::list<std::string>::const_iterator it(group_ids.begin());it!=group_ids.end();++it)
|
||||
{
|
||||
QList<QListWidgetItem*> lst = findItems(QString::fromStdString(*it),Qt::MatchExactly) ;
|
||||
|
||||
setCurrentItem(*lst.begin(),QItemSelectionModel::Select) ;
|
||||
}
|
||||
}
|
11
retroshare-gui/src/gui/common/GroupSelectionBox.h
Normal file
11
retroshare-gui/src/gui/common/GroupSelectionBox.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <QListWidget>
|
||||
|
||||
class GroupSelectionBox: public QListWidget
|
||||
{
|
||||
public:
|
||||
GroupSelectionBox(QWidget *parent) ;
|
||||
|
||||
std::list<std::string> selectedGroups() const ;
|
||||
|
||||
void setSelectedGroups(const std::list<std::string>& selected_group_ids) ;
|
||||
};
|
|
@ -217,7 +217,7 @@ void RsCollectionDialog::download()
|
|||
if(!QDir(QApplication::applicationDirPath()).mkpath(cleanPath))
|
||||
QMessageBox::warning(NULL,QObject::tr("Unable to make path"),QObject::tr("Unable to make path:")+"<br> "+cleanPath) ;
|
||||
|
||||
rsFiles->FileRequest(dlinfo.name.toUtf8().constData(), dlinfo.hash.toUtf8().constData(), dlinfo.size, cleanPath.toUtf8().constData(), RS_FILE_HINTS_NETWORK_WIDE, std::list<std::string>());
|
||||
rsFiles->FileRequest(dlinfo.name.toUtf8().constData(), dlinfo.hash.toUtf8().constData(), dlinfo.size, cleanPath.toUtf8().constData(), RS_FILE_REQ_ANONYMOUS_ROUTING, std::list<std::string>());
|
||||
}
|
||||
else
|
||||
std::cerr<<"Skipping file : " << dlinfo.name.toStdString() << std::endl;
|
||||
|
|
|
@ -110,7 +110,7 @@ void RsCollectionFile::recursAddElements(QDomDocument& doc,const DirDetails& det
|
|||
continue;
|
||||
|
||||
DirDetails subDirDetails;
|
||||
uint32_t flags = DIR_FLAGS_CHILDREN | DIR_FLAGS_LOCAL;
|
||||
FileSearchFlags flags = RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!rsFiles->RequestDirDetails(it->ref, subDirDetails, flags))
|
||||
continue;
|
||||
|
|
|
@ -100,7 +100,7 @@ AttachFileItem::AttachFileItem(const QString& path)
|
|||
mType = AFI_TYPE_ATTACH;
|
||||
|
||||
/* ask for Files to hash/prepare it for us */
|
||||
if ((!rsFiles) || (!rsFiles->ExtraFileHash(path.toUtf8().constData(), AFI_DEFAULT_PERIOD, 0)))
|
||||
if ((!rsFiles) || (!rsFiles->ExtraFileHash(path.toUtf8().constData(), AFI_DEFAULT_PERIOD, TransferRequestFlags(0u))))
|
||||
{
|
||||
mMode = AFI_STATE_ERROR;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ void AttachFileItem::Setup()
|
|||
if (mMode == AFI_STATE_REMOTE)
|
||||
{
|
||||
FileInfo fi;
|
||||
uint32_t hintflags = RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY;
|
||||
FileSearchFlags hintflags = RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY;
|
||||
|
||||
/* look up path */
|
||||
if (rsFiles->FileDetails(mFileHash, hintflags, fi))
|
||||
|
@ -194,7 +194,7 @@ void AttachFileItem::updateItemStatic()
|
|||
if (mPath == "")
|
||||
{
|
||||
FileInfo fi;
|
||||
uint32_t hintflags = RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_LOCAL
|
||||
FileSearchFlags hintflags = RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_LOCAL
|
||||
| RS_FILE_HINTS_SPEC_ONLY;
|
||||
|
||||
/* look up path */
|
||||
|
@ -350,7 +350,7 @@ void AttachFileItem::updateItem()
|
|||
}
|
||||
else
|
||||
{
|
||||
uint32_t hintflags = 0;
|
||||
FileSearchFlags hintflags(0u);
|
||||
switch(mMode)
|
||||
{
|
||||
case AFI_STATE_REMOTE:
|
||||
|
|
|
@ -182,7 +182,7 @@ void SubFileItem::updateItemStatic()
|
|||
if (mPath == "")
|
||||
{
|
||||
FileInfo fi;
|
||||
uint32_t hintflags = RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY | RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE;
|
||||
FileSearchFlags hintflags = RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY | RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE;
|
||||
|
||||
/* look up path */
|
||||
if (!rsFiles->FileDetails(mFileHash, hintflags, fi))
|
||||
|
@ -364,7 +364,7 @@ void SubFileItem::updateItem()
|
|||
}
|
||||
else
|
||||
{
|
||||
uint32_t hintflags = 0;
|
||||
FileSearchFlags hintflags(0u) ;
|
||||
switch(mMode)
|
||||
{
|
||||
case SFI_STATE_REMOTE:
|
||||
|
@ -544,7 +544,7 @@ void SubFileItem::cancel()
|
|||
if (((mType == SFI_TYPE_ATTACH) || (mType == SFI_TYPE_CHANNEL)) && (mFlag & SFI_FLAG_CREATE))
|
||||
{
|
||||
hide();
|
||||
rsFiles->ExtraFileRemove(FileHash(), RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_EXTRA);
|
||||
rsFiles->ExtraFileRemove(FileHash(), RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA);
|
||||
mPath = "";
|
||||
}
|
||||
else
|
||||
|
@ -559,7 +559,7 @@ void SubFileItem::cancel()
|
|||
void SubFileItem::play()
|
||||
{
|
||||
FileInfo info;
|
||||
uint32_t flags = RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE;
|
||||
FileSearchFlags flags = RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE;
|
||||
|
||||
|
||||
if (!rsFiles->FileDetails( mFileHash, flags, info))
|
||||
|
@ -612,7 +612,7 @@ void SubFileItem::download()
|
|||
if (mSrcId != "")
|
||||
sources.push_back(mSrcId);
|
||||
|
||||
rsFiles->FileRequest(mFileName, mFileHash, mFileSize, "", RS_FILE_HINTS_NETWORK_WIDE, sources);
|
||||
rsFiles->FileRequest(mFileName, mFileHash, mFileSize, "", RS_FILE_REQ_ANONYMOUS_ROUTING, sources);
|
||||
|
||||
downloadButton->setEnabled(false);
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>images/anonymous_128_green.png</file>
|
||||
<file>images/anonymous_128_blue.png</file>
|
||||
<file>images/browsable_128_green.png</file>
|
||||
<file>images/browsable_128_blue.png</file>
|
||||
<file>images/blank_128_green.png</file>
|
||||
<file>images/blank_128_blue.png</file>
|
||||
<file>images/splash.png</file>
|
||||
<file>images/help/addafriend.png</file>
|
||||
<file>images/help/addfriendkey.png</file>
|
||||
|
|
BIN
retroshare-gui/src/gui/images/anonymous_128_blue.png
Normal file
BIN
retroshare-gui/src/gui/images/anonymous_128_blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
retroshare-gui/src/gui/images/anonymous_128_green.png
Normal file
BIN
retroshare-gui/src/gui/images/anonymous_128_green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
retroshare-gui/src/gui/images/blank_128_blue.png
Normal file
BIN
retroshare-gui/src/gui/images/blank_128_blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
BIN
retroshare-gui/src/gui/images/blank_128_green.png
Normal file
BIN
retroshare-gui/src/gui/images/blank_128_green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
BIN
retroshare-gui/src/gui/images/browsable_128_blue.png
Normal file
BIN
retroshare-gui/src/gui/images/browsable_128_blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
retroshare-gui/src/gui/images/browsable_128_green.png
Normal file
BIN
retroshare-gui/src/gui/images/browsable_128_green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -323,7 +323,7 @@ void MessageWidget::getcurrentrecommended()
|
|||
const FileInfo& fi(it->second) ;
|
||||
std::cout << "Requesting file " << fi.fname << ", size=" << fi.size << ", hash=" << fi.hash << std::endl ;
|
||||
|
||||
if (rsFiles->FileRequest(fi.fname, fi.hash, fi.size, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds) == false) {
|
||||
if (rsFiles->FileRequest(fi.fname, fi.hash, fi.size, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds) == false) {
|
||||
QMessageBox mb(QObject::tr("File Request canceled"), QObject::tr("The following has not been added to your download list, because you already have it:\n ") + QString::fromUtf8(fi.fname.c_str()), QMessageBox::Critical, QMessageBox::Ok, 0, 0);
|
||||
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
|
||||
mb.exec();
|
||||
|
@ -347,7 +347,7 @@ void MessageWidget::getallrecommended()
|
|||
std::cerr << "MessageWidget::getallrecommended() Calling File Request" << std::endl;
|
||||
std::list<std::string> srcIds;
|
||||
srcIds.push_back(msgInfo.srcId);
|
||||
rsFiles->FileRequest(it->fname, it->hash, it->size, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds);
|
||||
rsFiles->FileRequest(it->fname, it->hash, it->size, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -357,6 +357,8 @@ HEADERS += rshare.h \
|
|||
gui/common/rwindow.h \
|
||||
gui/common/html.h \
|
||||
gui/common/AvatarDefs.h \
|
||||
gui/common/GroupFlagsWidget.h \
|
||||
gui/common/GroupSelectionBox.h \
|
||||
gui/common/StatusDefs.h \
|
||||
gui/common/TagDefs.h \
|
||||
gui/common/GroupDefs.h \
|
||||
|
@ -619,6 +621,8 @@ SOURCES += main.cpp \
|
|||
gui/common/rwindow.cpp \
|
||||
gui/common/html.cpp \
|
||||
gui/common/AvatarDefs.cpp \
|
||||
gui/common/GroupFlagsWidget.cpp \
|
||||
gui/common/GroupSelectionBox.cpp \
|
||||
gui/common/StatusDefs.cpp \
|
||||
gui/common/TagDefs.cpp \
|
||||
gui/common/GroupDefs.cpp \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue