mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-23 08:19:57 -05:00
extrafiles - fix links, add age, open folder, unshare icon
This commit is contained in:
parent
82ba488574
commit
6cbabd27c2
@ -37,6 +37,7 @@
|
|||||||
#include "util/RsAction.h"
|
#include "util/RsAction.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
#include "util/rstime.h"
|
#include "util/rstime.h"
|
||||||
|
#include "util/rsdir.h"
|
||||||
|
|
||||||
#include <retroshare/rsexpr.h>
|
#include <retroshare/rsexpr.h>
|
||||||
#include <retroshare/rsfiles.h>
|
#include <retroshare/rsfiles.h>
|
||||||
@ -74,6 +75,7 @@
|
|||||||
#define IMAGE_COLLOPEN ":/icons/collections.png"
|
#define IMAGE_COLLOPEN ":/icons/collections.png"
|
||||||
#define IMAGE_EDITSHARE ":/images/edit_16.png"
|
#define IMAGE_EDITSHARE ":/images/edit_16.png"
|
||||||
#define IMAGE_MYFILES ":/icons/svg/folders1.svg"
|
#define IMAGE_MYFILES ":/icons/svg/folders1.svg"
|
||||||
|
#define IMAGE_UNSHAREEXTRA ":/images/button_cancel.png"
|
||||||
|
|
||||||
/*define viewType_CB value */
|
/*define viewType_CB value */
|
||||||
#define VIEW_TYPE_TREE 0
|
#define VIEW_TYPE_TREE 0
|
||||||
@ -227,7 +229,7 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
|||||||
sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links" ), this );
|
sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links" ), this );
|
||||||
connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( ) ) );
|
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() ) );
|
connect( removeExtraFileAct , SIGNAL( triggered() ), this, SLOT( removeExtraFile() ) );
|
||||||
|
|
||||||
collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ;
|
collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ;
|
||||||
@ -639,7 +641,16 @@ void SharedFilesDialog::copyLinks(const QModelIndexList& lst, bool remote,QList<
|
|||||||
has_unhashed_files = true;
|
has_unhashed_files = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str());
|
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()) {
|
if (link.valid()) {
|
||||||
urls.push_back(link) ;
|
urls.push_back(link) ;
|
||||||
}
|
}
|
||||||
@ -871,7 +882,7 @@ void LocalSharedFilesDialog::openfolder()
|
|||||||
std::cerr << "SharedFilesDialog::openfolder" << std::endl;
|
std::cerr << "SharedFilesDialog::openfolder" << std::endl;
|
||||||
|
|
||||||
QModelIndexList qmil = getSelected();
|
QModelIndexList qmil = getSelected();
|
||||||
model->openSelected(qmil);
|
model->openSelected(qmil, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedFilesDialog::preModDirectories(bool local)
|
void SharedFilesDialog::preModDirectories(bool local)
|
||||||
@ -1139,6 +1150,7 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
|||||||
|
|
||||||
case DIR_TYPE_EXTRA_FILE:
|
case DIR_TYPE_EXTRA_FILE:
|
||||||
contextMnu.addAction(openfileAct) ;
|
contextMnu.addAction(openfileAct) ;
|
||||||
|
contextMnu.addAction(openfolderAct) ;
|
||||||
contextMnu.addSeparator() ;//------------------------------------
|
contextMnu.addSeparator() ;//------------------------------------
|
||||||
contextMnu.addAction(copylinkAct) ;
|
contextMnu.addAction(copylinkAct) ;
|
||||||
contextMnu.addAction(sendlinkAct) ;
|
contextMnu.addAction(sendlinkAct) ;
|
||||||
|
@ -520,7 +520,19 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
|||||||
case COLUMN_SIZE:
|
case COLUMN_SIZE:
|
||||||
return misc::friendlyUnit(details.count);
|
return misc::friendlyUnit(details.count);
|
||||||
case COLUMN_AGE:
|
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:
|
case COLUMN_FRIEND_ACCESS:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
case COLUMN_WN_VISU_DIR:
|
case COLUMN_WN_VISU_DIR:
|
||||||
@ -1381,7 +1393,7 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s
|
|||||||
* OLD RECOMMEND SYSTEM - DISABLED
|
* OLD RECOMMEND SYSTEM - DISABLED
|
||||||
******/
|
******/
|
||||||
|
|
||||||
void RetroshareDirModel::openSelected(const QModelIndexList &qmil)
|
void RetroshareDirModel::openSelected(const QModelIndexList &qmil, bool openDir)
|
||||||
{
|
{
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
std::cerr << "RetroshareDirModel::openSelected()" << std::endl;
|
std::cerr << "RetroshareDirModel::openSelected()" << std::endl;
|
||||||
@ -1404,12 +1416,15 @@ void RetroshareDirModel::openSelected(const QModelIndexList &qmil)
|
|||||||
|
|
||||||
QDir dir(QString::fromUtf8((*it).path.c_str()));
|
QDir dir(QString::fromUtf8((*it).path.c_str()));
|
||||||
QString dest;
|
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()));
|
dest = dir.absoluteFilePath(QString::fromUtf8(it->name.c_str()));
|
||||||
} else if ((*it).type & DIR_TYPE_DIR) {
|
} else if ((*it).type & DIR_TYPE_DIR) {
|
||||||
dest = dir.absolutePath();
|
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 ;
|
std::cerr << "Opening this file: " << dest.toStdString() << std::endl ;
|
||||||
|
|
||||||
RsUrlHandler::openUrl(QUrl::fromLocalFile(dest));
|
RsUrlHandler::openUrl(QUrl::fromLocalFile(dest));
|
||||||
|
@ -82,7 +82,7 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||||||
|
|
||||||
int getType ( const QModelIndex & index ) const ;
|
int getType ( const QModelIndex & index ) const ;
|
||||||
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
||||||
void openSelected(const QModelIndexList &list);
|
void openSelected(const QModelIndexList &list, bool openDir = false);
|
||||||
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
|
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
|
||||||
void getFilePath(const QModelIndex& index, std::string& fullpath);
|
void getFilePath(const QModelIndex& index, std::string& fullpath);
|
||||||
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user