mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed navigate to channel post when clicking a channel post link.
Fixed navigate to forum message when clicking a forum message link. Fixed copy of forum message link to clipboard git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7640 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6c2cc75f2b
commit
cfd6a7b8b5
@ -67,9 +67,10 @@ QString PostedDialog::text(TextType type)
|
||||
return tr("Create Topic");
|
||||
case TEXT_TODO:
|
||||
return "<b>Open points:</b><ul>"
|
||||
"<li>Subreddits/tag to posts support"
|
||||
"<li>Picture Support"
|
||||
"</ul>";
|
||||
"<li>Subreddits/tag to posts support"
|
||||
"<li>Picture Support"
|
||||
"<li>Navigate channel link"
|
||||
"</ul>";
|
||||
|
||||
case TEXT_YOUR_GROUP:
|
||||
return tr("My Topics");
|
||||
|
@ -480,6 +480,12 @@ void PostedListWidget::clearPosts()
|
||||
mPosts.clear();
|
||||
}
|
||||
|
||||
bool PostedListWidget::navigatePostItem(const RsGxsMessageId &msgId)
|
||||
{
|
||||
//TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
void PostedListWidget::shallowClearPosts()
|
||||
{
|
||||
std::cerr << "PostedListWidget::shallowClearPosts()" << std::endl;
|
||||
|
@ -64,6 +64,7 @@ protected:
|
||||
virtual void insertPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
|
||||
virtual void insertRelatedPosts(const uint32_t &token);
|
||||
virtual void clearPosts();
|
||||
virtual bool navigatePostItem(const RsGxsMessageId& msgId);
|
||||
|
||||
private slots:
|
||||
void createNewGxsId();
|
||||
|
@ -316,6 +316,23 @@ QTreeWidgetItem *RSFeedWidget::findTreeWidgetItem(FeedItem *feedItem)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool RSFeedWidget::scrollTo(FeedItem *feedItem, bool focus)
|
||||
{
|
||||
QTreeWidgetItem *item = findTreeWidgetItem(feedItem);
|
||||
if (!feedItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ui->treeWidget->scrollToItem(item);
|
||||
ui->treeWidget->setCurrentItem(item);
|
||||
|
||||
if (focus) {
|
||||
ui->treeWidget->setFocus();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
class RSFeedWidgetCallback
|
||||
{
|
||||
public:
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
void enableRemove(bool enable);
|
||||
void setSelectionMode(QAbstractItemView::SelectionMode mode);
|
||||
|
||||
bool scrollTo(FeedItem *feedItem, bool focus);
|
||||
|
||||
void withAll(RSFeedWidgetCallbackFunction callback, const QVariant &data);
|
||||
FeedItem *findFeedItem(RSFeedWidgetFindCallbackFunction callback, const QVariant &data1, const QVariant &data2);
|
||||
|
||||
|
@ -502,26 +502,7 @@ bool GxsGroupFrameDialog::navigate(const RsGxsGroupId &groupId, const RsGxsMessa
|
||||
return true;
|
||||
}
|
||||
|
||||
//#TODO
|
||||
// if (mThreadLoading) {
|
||||
// mThreadLoad.FocusMsgId = msgId;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
/* Search exisiting item */
|
||||
// QTreeWidgetItemIterator itemIterator(ui->threadTreeWidget);
|
||||
// QTreeWidgetItem *item = NULL;
|
||||
// while ((item = *itemIterator) != NULL) {
|
||||
// ++itemIterator;
|
||||
//
|
||||
// if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) {
|
||||
// ui->threadTreeWidget->setCurrentItem(item);
|
||||
// ui->threadTreeWidget->setFocus();
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
return true;
|
||||
return msgWidget->navigate(msgId);
|
||||
}
|
||||
|
||||
GxsMessageFrameWidget *GxsGroupFrameDialog::messageWidget(const RsGxsGroupId &groupId, bool ownTab)
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <QApplication>
|
||||
|
||||
#include "GxsMessageFramePostWidget.h"
|
||||
#include "GxsFeedItem.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
|
||||
#include "retroshare/rsgxsifacehelper.h"
|
||||
@ -89,6 +88,22 @@ QString GxsMessageFramePostWidget::groupName(bool withUnreadCount)
|
||||
return name;
|
||||
}
|
||||
|
||||
bool GxsMessageFramePostWidget::navigate(const RsGxsMessageId &msgId)
|
||||
{
|
||||
if (msgId.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mStateHelper->isLoading(mTokenTypePosts) || mStateHelper->isLoading(mTokenTypeRelatedPosts)) {
|
||||
mNavigatePendingMsgId = msgId;
|
||||
|
||||
/* No information if group is available */
|
||||
return true;
|
||||
}
|
||||
|
||||
return navigatePostItem(msgId);
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::updateDisplay(bool complete)
|
||||
{
|
||||
if (complete) {
|
||||
@ -151,6 +166,12 @@ void GxsMessageFramePostWidget::fillThreadFinished()
|
||||
|
||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
||||
emit groupChanged(this);
|
||||
|
||||
if (!mNavigatePendingMsgId.isNull()) {
|
||||
navigate(mNavigatePendingMsgId);
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
@ -253,6 +274,8 @@ void GxsMessageFramePostWidget::requestPosts()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
|
||||
/* Request all posts */
|
||||
|
||||
mTokenQueue->cancelActiveRequestTokens(mTokenTypePosts);
|
||||
@ -316,6 +339,12 @@ void GxsMessageFramePostWidget::loadPosts(const uint32_t &token)
|
||||
insertPosts(token, NULL);
|
||||
|
||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
||||
|
||||
if (!mNavigatePendingMsgId.isNull()) {
|
||||
navigate(mNavigatePendingMsgId);
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
}
|
||||
}
|
||||
|
||||
emit groupChanged(this);
|
||||
@ -328,6 +357,8 @@ void GxsMessageFramePostWidget::requestRelatedPosts(const std::vector<RsGxsMessa
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
|
||||
mTokenQueue->cancelActiveRequestTokens(mTokenTypeRelatedPosts);
|
||||
|
||||
if (mGroupId.isNull()) {
|
||||
@ -370,6 +401,12 @@ void GxsMessageFramePostWidget::loadRelatedPosts(const uint32_t &token)
|
||||
|
||||
mStateHelper->setLoading(mTokenTypeRelatedPosts, false);
|
||||
emit groupChanged(this);
|
||||
|
||||
if (!mNavigatePendingMsgId.isNull()) {
|
||||
navigate(mNavigatePendingMsgId);
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "GxsMessageFrameWidget.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
class GxsFeedItem;
|
||||
class UIStateHelper;
|
||||
class GxsMessageFramePostThread;
|
||||
|
||||
@ -46,6 +45,7 @@ public:
|
||||
virtual void setGroupId(const RsGxsGroupId &groupId);
|
||||
virtual QString groupName(bool withUnreadCount);
|
||||
// virtual QIcon groupIcon() = 0;
|
||||
virtual bool navigate(const RsGxsMessageId& msgId);
|
||||
|
||||
/* GXS functions */
|
||||
uint32_t nextTokenType() { return ++mNextTokenType; }
|
||||
@ -58,6 +58,7 @@ protected:
|
||||
virtual void groupNameChanged(const QString &/*name*/) {}
|
||||
|
||||
virtual void clearPosts() = 0;
|
||||
virtual bool navigatePostItem(const RsGxsMessageId& msgId) = 0;
|
||||
|
||||
/* Thread functions */
|
||||
virtual bool useThread() { return false; }
|
||||
@ -86,6 +87,7 @@ protected:
|
||||
uint32_t mTokenTypePosts;
|
||||
uint32_t mTokenTypeRelatedPosts;
|
||||
UIStateHelper *mStateHelper;
|
||||
RsGxsMessageId mNavigatePendingMsgId;
|
||||
|
||||
private:
|
||||
RsGxsGroupId mGroupId; /* current group */
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
virtual QString groupName(bool withUnreadCount) = 0;
|
||||
virtual QIcon groupIcon() = 0;
|
||||
virtual void setAllMessagesRead(bool read) = 0;
|
||||
virtual bool navigate(const RsGxsMessageId& msgId) = 0;
|
||||
|
||||
signals:
|
||||
void groupChanged(QWidget *widget);
|
||||
|
@ -79,7 +79,6 @@ QString GxsChannelDialog::text(TextType type)
|
||||
case TEXT_TODO:
|
||||
return "<b>Open points:</b><ul>"
|
||||
"<li>Restore channel keys"
|
||||
"<li>Navigate channel link"
|
||||
"</ul>";
|
||||
|
||||
case TEXT_YOUR_GROUP:
|
||||
|
@ -394,6 +394,16 @@ void GxsChannelPostsWidget::clearPosts()
|
||||
ui->fileWidget->clear();
|
||||
}
|
||||
|
||||
bool GxsChannelPostsWidget::navigatePostItem(const RsGxsMessageId &msgId)
|
||||
{
|
||||
FeedItem *feedItem = ui->feedWidget->findGxsFeedItem(groupId(), msgId);
|
||||
if (!feedItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ui->feedWidget->scrollTo(feedItem, true);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::subscribeGroup(bool subscribe)
|
||||
{
|
||||
if (groupId().isNull()) {
|
||||
|
@ -73,6 +73,7 @@ protected:
|
||||
virtual void clearPosts();
|
||||
virtual bool useThread() { return mUseThread; }
|
||||
virtual void fillThreadCreatePost(const QVariant &post, bool related, int current, int count);
|
||||
virtual bool navigatePostItem(const RsGxsMessageId& msgId);
|
||||
|
||||
private slots:
|
||||
void createMsg();
|
||||
|
@ -752,6 +752,11 @@ void GxsForumThreadWidget::fillThreadFinished()
|
||||
calculateIconsAndFonts();
|
||||
calculateUnreadCount();
|
||||
emit groupChanged(this);
|
||||
|
||||
if (!mNavigatePendingMsgId.isNull()) {
|
||||
navigate(mNavigatePendingMsgId);
|
||||
mNavigatePendingMsgId.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
@ -1506,29 +1511,45 @@ void GxsForumThreadWidget::setAllMessagesRead(bool read)
|
||||
markMsgAsReadUnread(read, true, true);
|
||||
}
|
||||
|
||||
bool GxsForumThreadWidget::navigate(const RsGxsMessageId &msgId)
|
||||
{
|
||||
if (mStateHelper->isLoading(TOKEN_TYPE_CURRENTFORUM)) {
|
||||
mNavigatePendingMsgId = msgId;
|
||||
|
||||
/* No information if message is available */
|
||||
return true;
|
||||
}
|
||||
|
||||
QString msgIdString = QString::fromStdString(msgId.toStdString());
|
||||
|
||||
/* Search exisiting item */
|
||||
QTreeWidgetItemIterator itemIterator(ui->threadTreeWidget);
|
||||
QTreeWidgetItem *item = NULL;
|
||||
while ((item = *itemIterator) != NULL) {
|
||||
++itemIterator;
|
||||
|
||||
if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString() == msgIdString) {
|
||||
ui->threadTreeWidget->setCurrentItem(item);
|
||||
ui->threadTreeWidget->setFocus();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::copyMessageLink()
|
||||
{
|
||||
if (mForumId.isNull() || mThreadId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// THIS CODE CALLS getForumInfo() to verify that the Ids are valid.
|
||||
// As we are switching to Request/Response this is now harder to do...
|
||||
// So not bothering any more - shouldn't be necessary.
|
||||
// IF we get errors - fix them, rather than patching here.
|
||||
#if 0
|
||||
ForumInfo fi;
|
||||
if (rsGxsForums->getForumInfo(mForumId, fi)) {
|
||||
RetroShareLink link;
|
||||
if (link.createForum(mForumId, mThreadId)) {
|
||||
QList<RetroShareLink> urls;
|
||||
urls.push_back(link);
|
||||
RSLinkClipboard::copyLinks(urls);
|
||||
}
|
||||
RetroShareLink link;
|
||||
if (link.createGxsMessageLink(RetroShareLink::TYPE_FORUM, mForumId, mThreadId, ui->threadTitle->text())) {
|
||||
QList<RetroShareLink> urls;
|
||||
urls.push_back(link);
|
||||
RSLinkClipboard::copyLinks(urls);
|
||||
}
|
||||
#endif
|
||||
|
||||
QMessageBox::warning(this, "RetroShare", "ToDo");
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::subscribeGroup(bool subscribe)
|
||||
@ -1704,6 +1725,8 @@ void GxsForumThreadWidget::requestGroup_CurrentForum()
|
||||
mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
|
@ -41,18 +41,20 @@ public:
|
||||
void setTextColorNotSubscribed(QColor color) { mTextColorNotSubscribed = color; }
|
||||
void setTextColorMissing(QColor color) { mTextColorMissing = color; }
|
||||
|
||||
/* GxsMessageFrameWidget */
|
||||
virtual RsGxsGroupId groupId() { return mForumId; }
|
||||
virtual void setGroupId(const RsGxsGroupId &forumId);
|
||||
virtual QString groupName(bool withUnreadCount);
|
||||
virtual QIcon groupIcon();
|
||||
virtual void setAllMessagesRead(bool read);
|
||||
virtual bool navigate(const RsGxsMessageId& msgId);
|
||||
|
||||
unsigned int newCount() { return mNewCount; }
|
||||
unsigned int unreadCount() { return mUnreadCount; }
|
||||
|
||||
QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn);
|
||||
QTreeWidgetItem *generateMissingItem(const RsGxsMessageId &msgId);
|
||||
|
||||
virtual void setAllMessagesRead(bool read);
|
||||
|
||||
// Callback for all Loads.
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
@ -159,6 +161,8 @@ private:
|
||||
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
RsGxsMessageId mNavigatePendingMsgId;
|
||||
|
||||
Ui::GxsForumThreadWidget *ui;
|
||||
};
|
||||
|
||||
|
@ -68,7 +68,6 @@ QString GxsForumsDialog::text(TextType type)
|
||||
return "<b>Open points:</b><ul>"
|
||||
"<li>Restore forum keys"
|
||||
"<li>Display AUTHD"
|
||||
"<li>Navigate forum link"
|
||||
"<li>Remove messages"
|
||||
"</ul>";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user