diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 90860ff2c..9692d96ff 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -37,6 +37,7 @@ #include "util/RsAction.h" #include "util/misc.h" #include "util/rstime.h" +#include "util/rsdir.h" #include #include @@ -74,6 +75,7 @@ #define IMAGE_COLLOPEN ":/icons/collections.png" #define IMAGE_EDITSHARE ":/images/edit_16.png" #define IMAGE_MYFILES ":/icons/svg/folders1.svg" +#define IMAGE_UNSHAREEXTRA ":/images/button_cancel.png" /*define viewType_CB value */ #define VIEW_TYPE_TREE 0 @@ -232,7 +234,7 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links" ), this ); connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( ) ) ); - removeExtraFileAct = new QAction(QIcon(), tr( "Stop sharing this file" ), this ); + removeExtraFileAct = new QAction(QIcon(IMAGE_UNSHAREEXTRA), tr( "Stop sharing this file" ), this ); connect( removeExtraFileAct , SIGNAL( triggered() ), this, SLOT( removeExtraFile() ) ); collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ; @@ -634,22 +636,31 @@ void SharedFilesDialog::copyLinks(const QModelIndexList& lst, bool remote,QList< RetroShareLink link = RetroShareLink::createFileTree(dir_name,ft->mTotalSize,ft->mTotalFiles,QString::fromStdString(ft->toRadix64())) ; - if(link.valid()) - urls.push_back(link) ; - } - else - { - if(details.hash.isNull()) - { - has_unhashed_files = true; - continue; - } - RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str()); - if (link.valid()) { - urls.push_back(link) ; - } - } - } + if(link.valid()) + urls.push_back(link) ; + } + else + { + if(details.hash.isNull()) + { + has_unhashed_files = true; + continue; + } + QString name; + if(details.type == DIR_TYPE_EXTRA_FILE) + { + std::string dir,file; + RsDirUtil::splitDirFromFile(details.name,dir,file) ; + name = QString::fromStdString(file); + } + else + name = QString::fromUtf8(details.name.c_str()); + RetroShareLink link = RetroShareLink::createFile(name, details.count, details.hash.toStdString().c_str()); + if (link.valid()) { + urls.push_back(link) ; + } + } + } } void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote) @@ -875,8 +886,8 @@ void LocalSharedFilesDialog::openfolder() { std::cerr << "SharedFilesDialog::openfolder" << std::endl; - QModelIndexList qmil = getSelected(); - model->openSelected(qmil); + QModelIndexList qmil = getSelected(); + model->openSelected(qmil, true); } void SharedFilesDialog::preModDirectories(bool local) @@ -1143,11 +1154,12 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) break; case DIR_TYPE_EXTRA_FILE: - contextMnu.addAction(openfileAct) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addAction(copylinkAct) ; - contextMnu.addAction(sendlinkAct) ; - contextMnu.addAction(removeExtraFileAct) ; + contextMnu.addAction(openfileAct) ; + contextMnu.addAction(openfolderAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addAction(copylinkAct) ; + contextMnu.addAction(sendlinkAct) ; + contextMnu.addAction(removeExtraFileAct) ; break ; diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index ed61cf4f5..49d9b2d6e 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -521,7 +521,19 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const case COLUMN_SIZE: return misc::friendlyUnit(details.count); case COLUMN_AGE: - return (details.type == DIR_TYPE_FILE)?(misc::timeRelativeToNow(details.max_mtime)):QString(); + { + if(details.type == DIR_TYPE_FILE) + return misc::timeRelativeToNow(details.max_mtime); + else if(details.type == DIR_TYPE_EXTRA_FILE) + { + FileInfo fi; + if (rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA , fi)) + return misc::timeRelativeToNow((rstime_t)fi.age-(30 * 3600 * 24)); // AFI_DEFAULT_PERIOD + return QString(); + } + else + return QString(); + } case COLUMN_FRIEND_ACCESS: return QVariant(); case COLUMN_WN_VISU_DIR: @@ -1370,7 +1382,7 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s * OLD RECOMMEND SYSTEM - DISABLED ******/ -void RetroshareDirModel::openSelected(const QModelIndexList &qmil) +void RetroshareDirModel::openSelected(const QModelIndexList &qmil, bool openDir) { #ifdef RDM_DEBUG std::cerr << "RetroshareDirModel::openSelected()" << std::endl; @@ -1393,12 +1405,15 @@ void RetroshareDirModel::openSelected(const QModelIndexList &qmil) QDir dir(QString::fromUtf8((*it).path.c_str())); QString dest; - if ((*it).type & DIR_TYPE_FILE || (*it).type & DIR_TYPE_EXTRA_FILE) { + if ((*it).type & DIR_TYPE_FILE || (!openDir && (*it).type & DIR_TYPE_EXTRA_FILE)) { dest = dir.absoluteFilePath(QString::fromUtf8(it->name.c_str())); } else if ((*it).type & DIR_TYPE_DIR) { dest = dir.absolutePath(); + } else if (openDir) // extra + { + QDir d = QFileInfo(it->name.c_str()).absoluteDir(); + dest = d.absolutePath(); } - std::cerr << "Opening this file: " << dest.toStdString() << std::endl ; RsUrlHandler::openUrl(QUrl::fromLocalFile(dest)); diff --git a/retroshare-gui/src/gui/RemoteDirModel.h b/retroshare-gui/src/gui/RemoteDirModel.h index 7184ae8d2..115ba5b20 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.h +++ b/retroshare-gui/src/gui/RemoteDirModel.h @@ -82,7 +82,7 @@ class RetroshareDirModel : public QAbstractItemModel int getType ( const QModelIndex & index ) const ; void getFileInfoFromIndexList(const QModelIndexList& list, std::list& files_info) ; - void openSelected(const QModelIndexList &list); + void openSelected(const QModelIndexList &list, bool openDir = false); void getFilePaths(const QModelIndexList &list, std::list &fullpaths); void getFilePath(const QModelIndex& index, std::string& fullpath); void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }