mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
improved display of shared directories for friends with no update info
This commit is contained in:
parent
1d977dd0cb
commit
6e4ba76bbb
@ -242,6 +242,7 @@ bool DirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
|
|||||||
d.hash.clear() ;
|
d.hash.clear() ;
|
||||||
d.count = dir_entry->subdirs.size() + dir_entry->subfiles.size();
|
d.count = dir_entry->subdirs.size() + dir_entry->subfiles.size();
|
||||||
d.min_age = now - dir_entry->dir_most_recent_time ;
|
d.min_age = now - dir_entry->dir_most_recent_time ;
|
||||||
|
d.age = now - dir_entry->dir_modtime ;
|
||||||
d.name = dir_entry->dir_name;
|
d.name = dir_entry->dir_name;
|
||||||
d.path = dir_entry->dir_parent_path + "/" + dir_entry->dir_name ;
|
d.path = dir_entry->dir_parent_path + "/" + dir_entry->dir_name ;
|
||||||
d.parent = (void*)(intptr_t)dir_entry->parent_index ;
|
d.parent = (void*)(intptr_t)dir_entry->parent_index ;
|
||||||
|
@ -63,6 +63,11 @@ Qt::DropActions RetroshareDirModel::supportedDragActions() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool isNewerThanEpoque(uint32_t age)
|
||||||
|
{
|
||||||
|
return age < time(NULL) - 1000 ; // this should be conservative enough
|
||||||
|
}
|
||||||
|
|
||||||
void FlatStyle_RDM::update()
|
void FlatStyle_RDM::update()
|
||||||
{
|
{
|
||||||
if(_needs_update)
|
if(_needs_update)
|
||||||
@ -241,7 +246,7 @@ QString RetroshareDirModel::getAgeIndicatorString(const DirDetails &details) con
|
|||||||
QString ret("");
|
QString ret("");
|
||||||
QString nind = tr("NEW");
|
QString nind = tr("NEW");
|
||||||
// QString oind = tr("OLD");
|
// QString oind = tr("OLD");
|
||||||
uint32_t age = details.age;
|
uint32_t age = details.min_age;
|
||||||
|
|
||||||
switch (ageIndicator) {
|
switch (ageIndicator) {
|
||||||
case IND_LAST_DAY:
|
case IND_LAST_DAY:
|
||||||
@ -271,7 +276,7 @@ QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln)
|
|||||||
return QVariant() ;
|
return QVariant() ;
|
||||||
|
|
||||||
if (details.type == DIR_TYPE_PERSON)
|
if (details.type == DIR_TYPE_PERSON)
|
||||||
{
|
{
|
||||||
if(details.min_age > ageIndicator)
|
if(details.min_age > ageIndicator)
|
||||||
return QIcon(":/images/folder_grey.png");
|
return QIcon(":/images/folder_grey.png");
|
||||||
else if (ageIndicator == IND_LAST_DAY )
|
else if (ageIndicator == IND_LAST_DAY )
|
||||||
@ -321,14 +326,16 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
|||||||
|
|
||||||
if (details.type == DIR_TYPE_PERSON) /* Person */
|
if (details.type == DIR_TYPE_PERSON) /* Person */
|
||||||
{
|
{
|
||||||
switch(coln)
|
switch(coln)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return (RemoteMode)?(QString::fromUtf8(rsPeers->getPeerName(details.id).c_str())):tr("My files");
|
return (RemoteMode)?(QString::fromUtf8(rsPeers->getPeerName(details.id).c_str())):tr("My files");
|
||||||
case 1:
|
case 1:
|
||||||
return QString() ;
|
return QString() ;
|
||||||
case 2:
|
case 2: if(!isNewerThanEpoque(details.min_age))
|
||||||
return misc::userFriendlyDuration(details.min_age);
|
return QString();
|
||||||
|
else
|
||||||
|
return misc::userFriendlyDuration(details.min_age);
|
||||||
default:
|
default:
|
||||||
return QString() ;
|
return QString() ;
|
||||||
}
|
}
|
||||||
@ -342,7 +349,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
|||||||
case 1:
|
case 1:
|
||||||
return misc::friendlyUnit(details.count);
|
return misc::friendlyUnit(details.count);
|
||||||
case 2:
|
case 2:
|
||||||
return misc::userFriendlyDuration(details.age);
|
return misc::userFriendlyDuration(details.min_age);
|
||||||
case 3:
|
case 3:
|
||||||
return getFlagsString(details.flags);
|
return getFlagsString(details.flags);
|
||||||
// case 4:
|
// case 4:
|
||||||
@ -417,7 +424,7 @@ QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
|||||||
{
|
{
|
||||||
case 0: return QString::fromUtf8(details.name.c_str());
|
case 0: return QString::fromUtf8(details.name.c_str());
|
||||||
case 1: return misc::friendlyUnit(details.count);
|
case 1: return misc::friendlyUnit(details.count);
|
||||||
case 2: return misc::userFriendlyDuration(details.age);
|
case 2: return misc::userFriendlyDuration(details.min_age);
|
||||||
case 3: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
case 3: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||||
case 4: return computeDirectoryPath(details);
|
case 4: return computeDirectoryPath(details);
|
||||||
default:
|
default:
|
||||||
@ -457,7 +464,7 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
|||||||
case 1:
|
case 1:
|
||||||
return (qulonglong) details.count;
|
return (qulonglong) details.count;
|
||||||
case 2:
|
case 2:
|
||||||
return details.age;
|
return details.min_age;
|
||||||
case 3:
|
case 3:
|
||||||
return getFlagsString(details.flags);
|
return getFlagsString(details.flags);
|
||||||
case 4:
|
case 4:
|
||||||
@ -503,7 +510,7 @@ QVariant FlatStyle_RDM::sortRole(const QModelIndex& index,const DirDetails& deta
|
|||||||
{
|
{
|
||||||
case 0: return QString::fromUtf8(details.name.c_str());
|
case 0: return QString::fromUtf8(details.name.c_str());
|
||||||
case 1: return (qulonglong) details.count;
|
case 1: return (qulonglong) details.count;
|
||||||
case 2: return details.age;
|
case 2: return details.min_age;
|
||||||
case 3: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
case 3: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||||
|
|
||||||
case 4: {
|
case 4: {
|
||||||
@ -570,7 +577,11 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
|
|||||||
if(role == Qt::DecorationRole)
|
if(role == Qt::DecorationRole)
|
||||||
return decorationRole(details,coln) ;
|
return decorationRole(details,coln) ;
|
||||||
|
|
||||||
/*****************
|
if(role == Qt::ToolTipRole)
|
||||||
|
if(!isNewerThanEpoque(details.min_age))
|
||||||
|
return tr("This node hasn't sent any directory information yet.") ;
|
||||||
|
|
||||||
|
/*****************
|
||||||
Qt::EditRole
|
Qt::EditRole
|
||||||
Qt::ToolTipRole
|
Qt::ToolTipRole
|
||||||
Qt::StatusTipRole
|
Qt::StatusTipRole
|
||||||
@ -842,7 +853,8 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
|
|||||||
|
|
||||||
switch(details.type)
|
switch(details.type)
|
||||||
{
|
{
|
||||||
case DIR_TYPE_PERSON: return Qt::ItemIsEnabled;
|
// we grey out a person that has never been updated. It's easy to spot these, since the min age of the directory is approx equal to time(NULL), which exceeds 40 years.
|
||||||
|
case DIR_TYPE_PERSON:return isNewerThanEpoque(details.min_age)? (Qt::ItemIsEnabled):(Qt::NoItemFlags) ;
|
||||||
case DIR_TYPE_DIR: return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
case DIR_TYPE_DIR: return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||||
case DIR_TYPE_FILE: return Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled;
|
case DIR_TYPE_FILE: return Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user