diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 9147dac42..0d02ce44c 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -364,6 +364,27 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const return QVariant(); } /* 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 { 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 2: return misc::userFriendlyDuration(details.age); case 3: return QString::fromStdString(rsPeers->getPeerName(details.id)); + case 4: return computeDirectoryPath(details); default: return QVariant() ; } return QVariant(); } /* 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; @@ -440,7 +462,7 @@ QVariant TreeStyle_RDM::sortRole(const DirDetails& details,int coln) const } 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; @@ -456,10 +478,10 @@ QVariant FlatStyle_RDM::sortRole(const DirDetails& details,int coln) const case 1: return (qulonglong) details.count; case 2: return details.age; 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 */ @@ -531,7 +553,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const return displayRole(details,coln) ; if (role == SortRole) - return sortRole(details,coln) ; + return sortRole(index,details,coln) ; return QVariant(); } @@ -636,7 +658,7 @@ QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int else return tr("Share Type"); case 4: - return tr("What's new"); + return tr("Directory"); } 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()) { - void *ref = _ref_entries[row] ; + void *ref = _ref_entries[row].first ; return createIndex(row, column, ref); } @@ -1286,7 +1308,7 @@ void FlatStyle_RDM::postMods() if (requestDirDetails(ref, details, flags)) { if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons. - _ref_entries.push_back(ref); + _ref_entries.push_back(std::pair(ref,computeDirectoryPath(details))); #ifdef RDM_DEBUG std::cerr << "FlatStyle_RDM::postMods(): addign ref " << ref << std::endl; #endif diff --git a/retroshare-gui/src/gui/RemoteDirModel.h b/retroshare-gui/src/gui/RemoteDirModel.h index 3dc37bfbf..3e21027eb 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.h +++ b/retroshare-gui/src/gui/RemoteDirModel.h @@ -76,7 +76,7 @@ class RetroshareDirModel : public QAbstractItemModel void getAgeIndicatorRec(DirDetails &details, QString &ret) const; 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 ; @@ -149,7 +149,7 @@ class TreeStyle_RDM: public RetroshareDirModel virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) 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 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 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 parent ( const QModelIndex & index ) const; virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const; - std::vector _ref_entries ; + QString computeDirectoryPath(const DirDetails& details) const ; + + std::vector > _ref_entries ; }; diff --git a/retroshare-gui/src/gui/SharedFilesDialog.cpp b/retroshare-gui/src/gui/SharedFilesDialog.cpp index 1caf751b1..c5cf2de97 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/SharedFilesDialog.cpp @@ -284,6 +284,7 @@ void SharedFilesDialog::changeCurrentViewModel(int c) model = tree_model ; proxyModel = tree_proxyModel ; ui.remoteDirTreeView->setColumnHidden(3,true) ; + ui.remoteDirTreeView->setColumnHidden(4,true) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW ui.filterLabel->hide(); ui.filterPatternLineEdit->hide(); @@ -296,6 +297,7 @@ void SharedFilesDialog::changeCurrentViewModel(int c) model = flat_model ; proxyModel = flat_proxyModel ; ui.remoteDirTreeView->setColumnHidden(3,false) ; + ui.remoteDirTreeView->setColumnHidden(4,false) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW ui.filterLabel->show(); ui.filterPatternLineEdit->show();