diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.h index d2d4fabf8..1aaa60fcb 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.h @@ -98,6 +98,7 @@ public: // Helper functions void clear() ; + bool getFileData(const QModelIndex& i, ChannelPostFileInfo &fmpe) const; // AbstractItemModel functions. @@ -156,7 +157,6 @@ private: quintptr getParentRow(quintptr ref,int& row) const; quintptr getChildRef(quintptr ref, int index) const; int getChildrenCount(quintptr ref) const; - bool getFileData(const QModelIndex& i, ChannelPostFileInfo &fmpe) const; static bool convertTabEntryToRefPointer(uint32_t entry, quintptr& ref); static bool convertRefPointerToTabEntry(quintptr ref,uint32_t& entry); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index b6123864a..f1aa38f68 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -406,6 +406,9 @@ 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->channelFiles_TV,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showChannelFilesContextMenu(QPoint))); + ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel()); ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate(this)); ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected")); @@ -1243,6 +1246,35 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou showPostDetails(); } +void GxsChannelPostsWidgetWithModel::showChannelFilesContextMenu(QPoint p) +{ + QMenu contextMnu(this) ; + + QAction *action = contextMnu.addAction(QIcon(), tr("Copy Retroshare link"), this, SLOT(copyChannelFilesLink())); + action->setData(QVariant::fromValue(sender())); + contextMnu.exec(QCursor::pos()); +} + +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; + + ChannelPostFileInfo file; + + if(!static_cast(tree->model())->getFileData(sel.front(),file)) + return; + + RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(file.mName.c_str()), file.mSize, QString::fromStdString(file.mHash.toStdString())); + RSLinkClipboard::copyLinks(QList{ link }); +} + void GxsChannelPostsWidgetWithModel::setSubscribeButtonText(const RsGxsGroupId& group_id,uint32_t flags, uint32_t mPop) { if(IS_GROUP_SUBSCRIBED(flags)) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 4e74d2f00..eaac53c0f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -163,6 +163,8 @@ public slots: void sortColumnFiles(int col,Qt::SortOrder so); void sortColumnPostFiles(int col,Qt::SortOrder so); void updateCommentsCount(int n); + void showChannelFilesContextMenu(QPoint p); + void copyChannelFilesLink(); private: void processSettings(bool load); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index be78f618e..4bdae007a 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -181,7 +181,7 @@ - 0 + 1 @@ -552,6 +552,9 @@ p, li { white-space: pre-wrap; } + + Qt::CustomContextMenu + QAbstractItemView::CurrentChanged|QAbstractItemView::SelectedClicked @@ -602,6 +605,9 @@ p, li { white-space: pre-wrap; } + + Qt::CustomContextMenu + QAbstractItemView::CurrentChanged|QAbstractItemView::SelectedClicked