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
This commit is contained in:
csoler 2012-10-21 19:39:56 +00:00
parent 56e26ba00a
commit 03d4936b12
8 changed files with 95 additions and 33 deletions

View File

@ -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<DirStub> children;
std::list<std::string> 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 ;

View File

@ -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<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 +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);
}

View File

@ -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<std::string>&) ;
QString getAgeIndicatorString(const DirDetails &) const;
void getAgeIndicatorRec(DirDetails &details, QString &ret) const;

View File

@ -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 */

View File

@ -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>

View File

@ -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

View File

@ -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() ; }

View File

@ -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] ;
};