fixed copy file link in channel post files

This commit is contained in:
csoler 2023-06-28 21:48:07 +02:00
parent afba23882e
commit a782122742
2 changed files with 22 additions and 13 deletions

View File

@ -411,7 +411,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
connect(ui->channelPostFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnPostFiles(int,Qt::SortOrder)));
connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder)));
connect(ui->channelPostFiles_TV,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showChannelFilesContextMenu(QPoint)));
connect(ui->channelPostFiles_TV,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showChannelPostFilesContextMenu(QPoint)));
connect(ui->channelFiles_TV,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showChannelFilesContextMenu(QPoint)));
connect(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails()));
@ -1344,13 +1344,26 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
showPostDetails();
}
void GxsChannelPostsWidgetWithModel::showChannelFilesContextMenu(QPoint /*p*/)
void GxsChannelPostsWidgetWithModel::showChannelFilesContextMenu(QPoint p)
{
QMenu contextMnu(this) ;
QModelIndex index = ui->channelFiles_TV->indexAt(p);
QAction *action = contextMnu.addAction(QIcon(), tr("Copy Retroshare link"), this, SLOT(copyChannelFilesLink()));
action->setData(QVariant::fromValue(sender()));
if(!index.isValid())
return;
QMenu contextMnu(this) ;
contextMnu.addAction(QIcon(), tr("Copy Retroshare link"), this, SLOT(copyChannelFilesLink()))->setData(QVariant::fromValue(index));
contextMnu.exec(QCursor::pos());
}
void GxsChannelPostsWidgetWithModel::showChannelPostFilesContextMenu(QPoint p)
{
QModelIndex index = ui->channelPostFiles_TV->indexAt(p);
if(!index.isValid())
return;
QMenu contextMnu(this) ;
contextMnu.addAction(QIcon(), tr("Copy Retroshare link"), this, SLOT(copyChannelFilesLink()))->setData(QVariant::fromValue(index));
contextMnu.exec(QCursor::pos());
}
@ -1358,16 +1371,11 @@ void GxsChannelPostsWidgetWithModel::copyChannelFilesLink()
{
// Block the popup if no results available
QAction *action = dynamic_cast<QAction*>(sender());
RSTreeView *tree = dynamic_cast<RSTreeView*>(action->data().value<QWidget*>());
QModelIndexList sel = tree->selectionModel()->selection().indexes();
if(sel.empty())
return;
QModelIndex s = action->data().toModelIndex();
ChannelPostFileInfo file;
if(!static_cast<RsGxsChannelPostFilesModel*>(tree->model())->getFileData(sel.front(),file))
if(!static_cast<const RsGxsChannelPostFilesModel*>(s.model())->getFileData(s,file))
return;
RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(file.mName.c_str()), file.mSize, QString::fromStdString(file.mHash.toStdString()));

View File

@ -166,6 +166,7 @@ public slots:
void sortColumnPostFiles(int col,Qt::SortOrder so);
void updateCommentsCount(int n);
void showChannelFilesContextMenu(QPoint p);
void showChannelPostFilesContextMenu(QPoint p);
void copyChannelFilesLink();
private: