mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-02 11:16:34 -04:00
added possibility to remove extra shared file
This commit is contained in:
parent
1383846364
commit
7ab7c7db93
13 changed files with 125 additions and 69 deletions
|
@ -76,6 +76,7 @@
|
|||
#define IMAGE_COLLOPEN ":/images/library.png"
|
||||
#define IMAGE_EDITSHARE ":/images/edit_16.png"
|
||||
#define IMAGE_MYFILES ":/icons/svg/folders1.svg"
|
||||
#define IMAGE_REMOVE ":/images/deletemail24.png"
|
||||
|
||||
/*define viewType_CB value */
|
||||
#define VIEW_TYPE_TREE 0
|
||||
|
@ -229,6 +230,9 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
|||
sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links" ), this );
|
||||
connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( ) ) );
|
||||
|
||||
removeExtraFileAct = new QAction(QIcon(IMAGE_REMOVE), tr( "Stop sharing this file" ), this );
|
||||
connect( removeExtraFileAct , SIGNAL( triggered() ), this, SLOT( removeExtraFile() ) );
|
||||
|
||||
collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ;
|
||||
connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())) ;
|
||||
collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this) ;
|
||||
|
@ -1093,7 +1097,7 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
|||
|
||||
currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ;
|
||||
int type = model->getType(midx) ;
|
||||
if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE) return;
|
||||
if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE && type != DIR_TYPE_EXTRA_FILE) return;
|
||||
|
||||
QMenu contextMnu(this) ;
|
||||
|
||||
|
@ -1127,58 +1131,70 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
|||
contextMnu.addMenu(&collectionMenu) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ;
|
||||
break;
|
||||
|
||||
case DIR_TYPE_EXTRA_FILE:
|
||||
contextMnu.addAction(openfileAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction(copylinkAct) ;
|
||||
contextMnu.addAction(sendlinkAct) ;
|
||||
contextMnu.addAction(removeExtraFileAct) ;
|
||||
|
||||
break ;
|
||||
|
||||
default :
|
||||
return ;
|
||||
}
|
||||
|
||||
GxsChannelDialog *channelDialog = dynamic_cast<GxsChannelDialog*>(MainWindow::getPage(MainWindow::Channels));
|
||||
QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards
|
||||
|
||||
if(channelDialog != NULL)
|
||||
if(type != DIR_TYPE_EXTRA_FILE)
|
||||
{
|
||||
shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL));
|
||||
GxsChannelDialog *channelDialog = dynamic_cast<GxsChannelDialog*>(MainWindow::getPage(MainWindow::Channels));
|
||||
QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards
|
||||
|
||||
std::map<RsGxsGroupId,RsGroupMetaData> grp_metas ;
|
||||
channelDialog->getGroupList(grp_metas) ;
|
||||
if(channelDialog != NULL)
|
||||
{
|
||||
shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL));
|
||||
|
||||
std::vector<std::pair<std::string,RsGxsGroupId> > grplist ; // I dont use a std::map because two or more channels may have the same name.
|
||||
std::map<RsGxsGroupId,RsGroupMetaData> grp_metas ;
|
||||
channelDialog->getGroupList(grp_metas) ;
|
||||
|
||||
for(auto it(grp_metas.begin());it!=grp_metas.end();++it)
|
||||
if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags))
|
||||
grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId));
|
||||
std::vector<std::pair<std::string,RsGxsGroupId> > grplist ; // I dont use a std::map because two or more channels may have the same name.
|
||||
|
||||
std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ;
|
||||
for(auto it(grp_metas.begin());it!=grp_metas.end();++it)
|
||||
if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags))
|
||||
grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId));
|
||||
|
||||
for(auto it(grplist.begin());it!=grplist.end();++it)
|
||||
std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ;
|
||||
|
||||
for(auto it(grplist.begin());it!=grplist.end();++it)
|
||||
shareChannelMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).second.toStdString())) ;
|
||||
|
||||
contextMnu.addMenu(&shareChannelMenu) ;
|
||||
}
|
||||
contextMnu.addMenu(&shareChannelMenu) ;
|
||||
}
|
||||
|
||||
GxsForumsDialog *forumsDialog = dynamic_cast<GxsForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
|
||||
QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards
|
||||
GxsForumsDialog *forumsDialog = dynamic_cast<GxsForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
|
||||
QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards
|
||||
|
||||
if(forumsDialog != NULL)
|
||||
{
|
||||
shareForumMenu.setIcon(QIcon(IMAGE_FORUMS));
|
||||
if(forumsDialog != NULL)
|
||||
{
|
||||
shareForumMenu.setIcon(QIcon(IMAGE_FORUMS));
|
||||
|
||||
std::map<RsGxsGroupId,RsGroupMetaData> grp_metas ;
|
||||
forumsDialog->getGroupList(grp_metas) ;
|
||||
std::map<RsGxsGroupId,RsGroupMetaData> grp_metas ;
|
||||
forumsDialog->getGroupList(grp_metas) ;
|
||||
|
||||
std::vector<std::pair<std::string,RsGxsGroupId> > grplist ; // I dont use a std::map because two or more channels may have the same name.
|
||||
std::vector<std::pair<std::string,RsGxsGroupId> > grplist ; // I dont use a std::map because two or more channels may have the same name.
|
||||
|
||||
for(auto it(grp_metas.begin());it!=grp_metas.end();++it)
|
||||
if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags))
|
||||
grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId));
|
||||
for(auto it(grp_metas.begin());it!=grp_metas.end();++it)
|
||||
if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags))
|
||||
grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId));
|
||||
|
||||
std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ;
|
||||
std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ;
|
||||
|
||||
for(auto it(grplist.begin());it!=grplist.end();++it)
|
||||
shareForumMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareInForum()))->setData(QString::fromStdString((*it).second.toStdString())) ;
|
||||
for(auto it(grplist.begin());it!=grplist.end();++it)
|
||||
shareForumMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareInForum()))->setData(QString::fromStdString((*it).second.toStdString())) ;
|
||||
|
||||
contextMnu.addMenu(&shareForumMenu) ;
|
||||
contextMnu.addMenu(&shareForumMenu) ;
|
||||
}
|
||||
}
|
||||
|
||||
contextMnu.exec(QCursor::pos()) ;
|
||||
|
@ -1564,6 +1580,20 @@ void SharedFilesDialog::FilterItems()
|
|||
#endif
|
||||
}
|
||||
|
||||
void SharedFilesDialog::removeExtraFile()
|
||||
{
|
||||
std::list<DirDetails> files_info ;
|
||||
|
||||
model->getFileInfoFromIndexList(getSelected(),files_info);
|
||||
|
||||
for(auto it(files_info.begin());it!=files_info.end();++it)
|
||||
{
|
||||
std::cerr << "removing file " << (*it).name << ", hash = " << (*it).hash << std::endl;
|
||||
|
||||
rsFiles->ExtraFileRemove((*it).hash);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEPRECATED_CODE
|
||||
bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString &text, int /*level*/)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue