diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 35f8df044..a6ce946f5 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -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(sender()); - RSTreeView *tree = dynamic_cast(action->data().value()); - - QModelIndexList sel = tree->selectionModel()->selection().indexes(); - - if(sel.empty()) - return; + QModelIndex s = action->data().toModelIndex(); ChannelPostFileInfo file; - if(!static_cast(tree->model())->getFileData(sel.front(),file)) + if(!static_cast(s.model())->getFileData(s,file)) return; RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(file.mName.c_str()), file.mSize, QString::fromStdString(file.mHash.toStdString())); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index c325c722b..9cfcaae21 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -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: