added a column for directory in flat view of shared files

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4129 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-04-07 20:09:32 +00:00
parent 075efd6503
commit bcdf536c98
3 changed files with 38 additions and 12 deletions

View File

@ -364,6 +364,27 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
return QVariant(); return QVariant();
} /* end of DisplayRole */ } /* end of DisplayRole */
QString FlatStyle_RDM::computeDirectoryPath(const DirDetails& details) const
{
QString dir ;
DirDetails det(details) ;
uint32_t flags = (RemoteMode)?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
if(!requestDirDetails(det.parent,det,flags))
return QString();
do
{
dir = QString::fromStdString(det.name)+"/"+dir ;
if(!requestDirDetails(det.parent,det,flags))
break ;
}
while(det.parent != NULL);
return dir ;
}
QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const
{ {
if (details.type == DIR_TYPE_FILE) /* File */ if (details.type == DIR_TYPE_FILE) /* File */
@ -373,13 +394,14 @@ QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const
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.age);
case 3: return QString::fromStdString(rsPeers->getPeerName(details.id)); case 3: return QString::fromStdString(rsPeers->getPeerName(details.id));
case 4: return computeDirectoryPath(details);
default: default:
return QVariant() ; return QVariant() ;
} }
return QVariant(); return QVariant();
} /* end of DisplayRole */ } /* end of DisplayRole */
QVariant TreeStyle_RDM::sortRole(const DirDetails& details,int coln) const QVariant TreeStyle_RDM::sortRole(const QModelIndex& index,const DirDetails& details,int coln) const
{ {
/* /*
* Person: name, id, 0, 0; * Person: name, id, 0, 0;
@ -440,7 +462,7 @@ QVariant TreeStyle_RDM::sortRole(const DirDetails& details,int coln) const
} }
return QVariant(); return QVariant();
} }
QVariant FlatStyle_RDM::sortRole(const DirDetails& details,int coln) const QVariant FlatStyle_RDM::sortRole(const QModelIndex& index,const DirDetails& details,int coln) const
{ {
/* /*
* Person: name, id, 0, 0; * Person: name, id, 0, 0;
@ -456,10 +478,10 @@ QVariant FlatStyle_RDM::sortRole(const DirDetails& details,int coln) const
case 1: return (qulonglong) details.count; case 1: return (qulonglong) details.count;
case 2: return details.age; case 2: return details.age;
case 3: return QString::fromStdString(rsPeers->getPeerName(details.id)); case 3: return QString::fromStdString(rsPeers->getPeerName(details.id));
case 4: return _ref_entries[index.row()].second ;
} }
} }
else return QVariant();
return QVariant();
} /* end of SortRole */ } /* end of SortRole */
@ -531,7 +553,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
return displayRole(details,coln) ; return displayRole(details,coln) ;
if (role == SortRole) if (role == SortRole)
return sortRole(details,coln) ; return sortRole(index,details,coln) ;
return QVariant(); return QVariant();
} }
@ -636,7 +658,7 @@ QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int
else else
return tr("Share Type"); return tr("Share Type");
case 4: case 4:
return tr("What's new"); return tr("Directory");
} }
return QString("Column %1").arg(section); return QString("Column %1").arg(section);
} }
@ -718,7 +740,7 @@ QModelIndex FlatStyle_RDM::index(int row, int column, const QModelIndex & parent
if(row < _ref_entries.size()) if(row < _ref_entries.size())
{ {
void *ref = _ref_entries[row] ; void *ref = _ref_entries[row].first ;
return createIndex(row, column, ref); return createIndex(row, column, ref);
} }
@ -1286,7 +1308,7 @@ void FlatStyle_RDM::postMods()
if (requestDirDetails(ref, details, flags)) if (requestDirDetails(ref, details, flags))
{ {
if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons. if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons.
_ref_entries.push_back(ref); _ref_entries.push_back(std::pair<void*,QString>(ref,computeDirectoryPath(details)));
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "FlatStyle_RDM::postMods(): addign ref " << ref << std::endl; std::cerr << "FlatStyle_RDM::postMods(): addign ref " << ref << std::endl;
#endif #endif

View File

@ -76,7 +76,7 @@ class RetroshareDirModel : public QAbstractItemModel
void getAgeIndicatorRec(DirDetails &details, QString &ret) const; void getAgeIndicatorRec(DirDetails &details, QString &ret) const;
virtual QVariant displayRole(const DirDetails&,int) const = 0 ; virtual QVariant displayRole(const DirDetails&,int) const = 0 ;
virtual QVariant sortRole(const DirDetails&,int) const =0; virtual QVariant sortRole(const QModelIndex&,const DirDetails&,int) const =0;
QVariant decorationRole(const DirDetails&,int) const ; QVariant decorationRole(const DirDetails&,int) const ;
@ -149,7 +149,7 @@ class TreeStyle_RDM: public RetroshareDirModel
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual QVariant displayRole(const DirDetails&,int) const ; virtual QVariant displayRole(const DirDetails&,int) const ;
virtual QVariant sortRole(const DirDetails&,int) const ; virtual QVariant sortRole(const QModelIndex&,const DirDetails&,int) const ;
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const; virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
virtual QModelIndex parent ( const QModelIndex & index ) const; virtual QModelIndex parent ( const QModelIndex & index ) const;
@ -178,13 +178,15 @@ class FlatStyle_RDM: public RetroshareDirModel
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual QVariant displayRole(const DirDetails&,int) const ; virtual QVariant displayRole(const DirDetails&,int) const ;
virtual QVariant sortRole(const DirDetails&,int) const ; virtual QVariant sortRole(const QModelIndex&,const DirDetails&,int) const ;
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const; virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
virtual QModelIndex parent ( const QModelIndex & index ) const; virtual QModelIndex parent ( const QModelIndex & index ) const;
virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const; virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
std::vector<void *> _ref_entries ; QString computeDirectoryPath(const DirDetails& details) const ;
std::vector<std::pair<void *,QString> > _ref_entries ;
}; };

View File

@ -284,6 +284,7 @@ void SharedFilesDialog::changeCurrentViewModel(int c)
model = tree_model ; model = tree_model ;
proxyModel = tree_proxyModel ; proxyModel = tree_proxyModel ;
ui.remoteDirTreeView->setColumnHidden(3,true) ; ui.remoteDirTreeView->setColumnHidden(3,true) ;
ui.remoteDirTreeView->setColumnHidden(4,true) ;
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW #ifdef DONT_USE_SEARCH_IN_TREE_VIEW
ui.filterLabel->hide(); ui.filterLabel->hide();
ui.filterPatternLineEdit->hide(); ui.filterPatternLineEdit->hide();
@ -296,6 +297,7 @@ void SharedFilesDialog::changeCurrentViewModel(int c)
model = flat_model ; model = flat_model ;
proxyModel = flat_proxyModel ; proxyModel = flat_proxyModel ;
ui.remoteDirTreeView->setColumnHidden(3,false) ; ui.remoteDirTreeView->setColumnHidden(3,false) ;
ui.remoteDirTreeView->setColumnHidden(4,false) ;
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW #ifdef DONT_USE_SEARCH_IN_TREE_VIEW
ui.filterLabel->show(); ui.filterLabel->show();
ui.filterPatternLineEdit->show(); ui.filterPatternLineEdit->show();