From 03d4936b126bb3814cea10f40940aa6d97988920 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 21 Oct 2012 19:39:56 +0000 Subject: [PATCH] improved display in share manager. Updated RemoteDirModel to show groups. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-FileSharingPermissions@5706 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/retroshare/rstypes.h | 21 +++++---- retroshare-gui/src/gui/RemoteDirModel.cpp | 47 ++++++++++++++----- retroshare-gui/src/gui/RemoteDirModel.h | 1 + retroshare-gui/src/gui/ShareManager.cpp | 7 ++- retroshare-gui/src/gui/ShareManager.ui | 11 ++++- retroshare-gui/src/gui/SharedFilesDialog.cpp | 9 +--- .../src/gui/common/GroupFlagsWidget.cpp | 29 +++++++++++- .../src/gui/common/GroupFlagsWidget.h | 3 ++ 8 files changed, 95 insertions(+), 33 deletions(-) diff --git a/libretroshare/src/retroshare/rstypes.h b/libretroshare/src/retroshare/rstypes.h index f038ede89..d03f29d9f 100644 --- a/libretroshare/src/retroshare/rstypes.h +++ b/libretroshare/src/retroshare/rstypes.h @@ -254,8 +254,10 @@ class SearchRequest #define DIR_FLAGS_PARENT 0x0001 #define DIR_FLAGS_DETAILS 0x0002 #define DIR_FLAGS_CHILDREN 0x0004 -#define DIR_FLAGS_NETWORK_WIDE 0x0008 -#define DIR_FLAGS_BROWSABLE 0x0010 +#define DIR_FLAGS_NETWORK_WIDE_OTHERS 0x0008 +#define DIR_FLAGS_BROWSABLE_OTHERS 0x0010 +#define DIR_FLAGS_NETWORK_WIDE_GROUPS 0x0020 +#define DIR_FLAGS_BROWSABLE_GROUPS 0x0040 class DirStub { @@ -283,18 +285,19 @@ class DirDetails uint32_t min_age ; // minimum age of files in this subtree std::list children; + std::list groups; // parent groups for the shared directory }; class FileDetail { public: - std::string id; - std::string name; - std::string hash; - std::string path; - uint64_t size; - uint32_t age; - uint32_t rank; + std::string id; + std::string name; + std::string hash; + std::string path; + uint64_t size; + uint32_t age; + uint32_t rank; }; class CompressedChunkMap ; diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 201c16f5f..db4e22997 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -204,14 +204,26 @@ int FlatStyle_RDM::columnCount(const QModelIndex &/*parent*/) const } QString RetroshareDirModel::getFlagsString(uint32_t flags) { - switch(flags & (DIR_FLAGS_NETWORK_WIDE|DIR_FLAGS_BROWSABLE)) + char str[5] = "----" ; + + if(flags & DIR_FLAGS_BROWSABLE_GROUPS) str[0] = 'B' ; + if(flags & DIR_FLAGS_NETWORK_WIDE_GROUPS) str[1] = 'N' ; + if(flags & DIR_FLAGS_BROWSABLE_OTHERS) str[2] = 'B' ; + if(flags & DIR_FLAGS_NETWORK_WIDE_OTHERS) str[3] = 'N' ; + + return QString(str) ; +} +QString RetroshareDirModel::getGroupsString(const std::list& groups) +{ + QString groups_str ; + + for(std::list::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 +332,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.groups) ; + default: return tr("FILE"); } @@ -348,6 +363,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.groups) ; + default: return tr("DIR"); } @@ -612,7 +630,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); } diff --git a/retroshare-gui/src/gui/RemoteDirModel.h b/retroshare-gui/src/gui/RemoteDirModel.h index 80f66448d..229240c9c 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.h +++ b/retroshare-gui/src/gui/RemoteDirModel.h @@ -80,6 +80,7 @@ class RetroshareDirModel : public QAbstractItemModel void treeStyle(); void downloadDirectory(const DirDetails & details, int prefixLen); static QString getFlagsString(uint32_t) ; + static QString getGroupsString(const std::list&) ; QString getAgeIndicatorString(const DirDetails &) const; void getAgeIndicatorRec(DirDetails &details, QString &ret) const; diff --git a/retroshare-gui/src/gui/ShareManager.cpp b/retroshare-gui/src/gui/ShareManager.cpp index 387079f03..fd449662d 100644 --- a/retroshare-gui/src/gui/ShareManager.cpp +++ b/retroshare-gui/src/gui/ShareManager.cpp @@ -131,10 +131,15 @@ void ShareManager::load() QWidget* widget = new GroupFlagsWidget(NULL,(*it).shareflags); - //listWidget->setRowHeight(row, 32); + listWidget->setRowHeight(row, 32); listWidget->setCellWidget(row, COLUMN_SHARE_FLAGS, widget); + + listWidget->setItem(row, COLUMN_GROUPS, new QTableWidgetItem(QString(" - "))) ; // no groups! + listWidget->item(row,COLUMN_GROUPS)->setBackgroundColor(QColor(183,236,181)) ; } + listWidget->setColumnWidth(COLUMN_SHARE_FLAGS,132) ; + //ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory())); listWidget->update(); /* update display */ diff --git a/retroshare-gui/src/gui/ShareManager.ui b/retroshare-gui/src/gui/ShareManager.ui index 57b92ac1e..bb9b948ab 100644 --- a/retroshare-gui/src/gui/ShareManager.ui +++ b/retroshare-gui/src/gui/ShareManager.ui @@ -81,14 +81,23 @@ p, li { white-space: pre-wrap; } QAbstractItemView::NoEditTriggers + + true + QAbstractItemView::SingleSelection QAbstractItemView::SelectRows + + false + + + true + - 100 + 128 false diff --git a/retroshare-gui/src/gui/SharedFilesDialog.cpp b/retroshare-gui/src/gui/SharedFilesDialog.cpp index 87d1b7f6e..210ff7035 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/SharedFilesDialog.cpp @@ -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 diff --git a/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp b/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp index d8717ce37..8a0ce7932 100644 --- a/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp @@ -17,11 +17,28 @@ #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,uint32_t 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) ; @@ -41,8 +58,7 @@ GroupFlagsWidget::GroupFlagsWidget(QWidget *parent,uint32_t flags) _buttons[i] = new QPushButton(this) ; _buttons[i]->setCheckable(true) ; _buttons[i]->setChecked(flags & _flags[i]) ; - //_buttons[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - //_buttons[i]->setMinimumSize(32,32); + _buttons[i]->setIconSize(QSize(32,32)); update_button_state(_buttons[i]->isChecked(),i) ; _layout->addWidget(_buttons[i]) ; } @@ -76,11 +92,20 @@ uint32_t GroupFlagsWidget::flags() const 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]) ; + } } void GroupFlagsWidget::update_GN_button(bool b) { update_button_state(b,INDEX_GROUP_NETWORK_W) ; updated() ; } diff --git a/retroshare-gui/src/gui/common/GroupFlagsWidget.h b/retroshare-gui/src/gui/common/GroupFlagsWidget.h index c0d323d35..89f2b78fa 100644 --- a/retroshare-gui/src/gui/common/GroupFlagsWidget.h +++ b/retroshare-gui/src/gui/common/GroupFlagsWidget.h @@ -34,4 +34,7 @@ class GroupFlagsWidget: public QWidget QLayout *_layout ; QIcon *_icons[6] ; uint32_t _flags[4] ; + + static QString _tooltips_on[4] ; + static QString _tooltips_off[4] ; };