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:
thunder2 2014-10-25 23:52:33 +00:00
parent 6c2cc75f2b
commit cfd6a7b8b5
15 changed files with 129 additions and 45 deletions

View File

@ -67,9 +67,10 @@ QString PostedDialog::text(TextType type)
return tr("Create Topic"); return tr("Create Topic");
case TEXT_TODO: case TEXT_TODO:
return "<b>Open points:</b><ul>" return "<b>Open points:</b><ul>"
"<li>Subreddits/tag to posts support" "<li>Subreddits/tag to posts support"
"<li>Picture Support" "<li>Picture Support"
"</ul>"; "<li>Navigate channel link"
"</ul>";
case TEXT_YOUR_GROUP: case TEXT_YOUR_GROUP:
return tr("My Topics"); return tr("My Topics");

View File

@ -480,6 +480,12 @@ void PostedListWidget::clearPosts()
mPosts.clear(); mPosts.clear();
} }
bool PostedListWidget::navigatePostItem(const RsGxsMessageId &msgId)
{
//TODO
return false;
}
void PostedListWidget::shallowClearPosts() void PostedListWidget::shallowClearPosts()
{ {
std::cerr << "PostedListWidget::shallowClearPosts()" << std::endl; std::cerr << "PostedListWidget::shallowClearPosts()" << std::endl;

View File

@ -64,6 +64,7 @@ protected:
virtual void insertPosts(const uint32_t &token, GxsMessageFramePostThread *thread); virtual void insertPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
virtual void insertRelatedPosts(const uint32_t &token); virtual void insertRelatedPosts(const uint32_t &token);
virtual void clearPosts(); virtual void clearPosts();
virtual bool navigatePostItem(const RsGxsMessageId& msgId);
private slots: private slots:
void createNewGxsId(); void createNewGxsId();

View File

@ -316,6 +316,23 @@ QTreeWidgetItem *RSFeedWidget::findTreeWidgetItem(FeedItem *feedItem)
return NULL; 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 class RSFeedWidgetCallback
{ {
public: public:

View File

@ -67,6 +67,8 @@ public:
void enableRemove(bool enable); void enableRemove(bool enable);
void setSelectionMode(QAbstractItemView::SelectionMode mode); void setSelectionMode(QAbstractItemView::SelectionMode mode);
bool scrollTo(FeedItem *feedItem, bool focus);
void withAll(RSFeedWidgetCallbackFunction callback, const QVariant &data); void withAll(RSFeedWidgetCallbackFunction callback, const QVariant &data);
FeedItem *findFeedItem(RSFeedWidgetFindCallbackFunction callback, const QVariant &data1, const QVariant &data2); FeedItem *findFeedItem(RSFeedWidgetFindCallbackFunction callback, const QVariant &data1, const QVariant &data2);

View File

@ -502,26 +502,7 @@ bool GxsGroupFrameDialog::navigate(const RsGxsGroupId &groupId, const RsGxsMessa
return true; return true;
} }
//#TODO return msgWidget->navigate(msgId);
// 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;
} }
GxsMessageFrameWidget *GxsGroupFrameDialog::messageWidget(const RsGxsGroupId &groupId, bool ownTab) GxsMessageFrameWidget *GxsGroupFrameDialog::messageWidget(const RsGxsGroupId &groupId, bool ownTab)

View File

@ -22,7 +22,6 @@
#include <QApplication> #include <QApplication>
#include "GxsMessageFramePostWidget.h" #include "GxsMessageFramePostWidget.h"
#include "GxsFeedItem.h"
#include "gui/common/UIStateHelper.h" #include "gui/common/UIStateHelper.h"
#include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxsifacehelper.h"
@ -89,6 +88,22 @@ QString GxsMessageFramePostWidget::groupName(bool withUnreadCount)
return name; 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) void GxsMessageFramePostWidget::updateDisplay(bool complete)
{ {
if (complete) { if (complete) {
@ -151,6 +166,12 @@ void GxsMessageFramePostWidget::fillThreadFinished()
mStateHelper->setLoading(mTokenTypePosts, false); mStateHelper->setLoading(mTokenTypePosts, false);
emit groupChanged(this); emit groupChanged(this);
if (!mNavigatePendingMsgId.isNull()) {
navigate(mNavigatePendingMsgId);
mNavigatePendingMsgId.clear();
}
} }
#ifdef ENABLE_DEBUG #ifdef ENABLE_DEBUG
@ -253,6 +274,8 @@ void GxsMessageFramePostWidget::requestPosts()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
mNavigatePendingMsgId.clear();
/* Request all posts */ /* Request all posts */
mTokenQueue->cancelActiveRequestTokens(mTokenTypePosts); mTokenQueue->cancelActiveRequestTokens(mTokenTypePosts);
@ -316,6 +339,12 @@ void GxsMessageFramePostWidget::loadPosts(const uint32_t &token)
insertPosts(token, NULL); insertPosts(token, NULL);
mStateHelper->setLoading(mTokenTypePosts, false); mStateHelper->setLoading(mTokenTypePosts, false);
if (!mNavigatePendingMsgId.isNull()) {
navigate(mNavigatePendingMsgId);
mNavigatePendingMsgId.clear();
}
} }
emit groupChanged(this); emit groupChanged(this);
@ -328,6 +357,8 @@ void GxsMessageFramePostWidget::requestRelatedPosts(const std::vector<RsGxsMessa
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
mNavigatePendingMsgId.clear();
mTokenQueue->cancelActiveRequestTokens(mTokenTypeRelatedPosts); mTokenQueue->cancelActiveRequestTokens(mTokenTypeRelatedPosts);
if (mGroupId.isNull()) { if (mGroupId.isNull()) {
@ -370,6 +401,12 @@ void GxsMessageFramePostWidget::loadRelatedPosts(const uint32_t &token)
mStateHelper->setLoading(mTokenTypeRelatedPosts, false); mStateHelper->setLoading(mTokenTypeRelatedPosts, false);
emit groupChanged(this); emit groupChanged(this);
if (!mNavigatePendingMsgId.isNull()) {
navigate(mNavigatePendingMsgId);
mNavigatePendingMsgId.clear();
}
} }
void GxsMessageFramePostWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req) void GxsMessageFramePostWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)

View File

@ -27,7 +27,6 @@
#include "GxsMessageFrameWidget.h" #include "GxsMessageFrameWidget.h"
#include "util/TokenQueue.h" #include "util/TokenQueue.h"
class GxsFeedItem;
class UIStateHelper; class UIStateHelper;
class GxsMessageFramePostThread; class GxsMessageFramePostThread;
@ -46,6 +45,7 @@ public:
virtual void setGroupId(const RsGxsGroupId &groupId); virtual void setGroupId(const RsGxsGroupId &groupId);
virtual QString groupName(bool withUnreadCount); virtual QString groupName(bool withUnreadCount);
// virtual QIcon groupIcon() = 0; // virtual QIcon groupIcon() = 0;
virtual bool navigate(const RsGxsMessageId& msgId);
/* GXS functions */ /* GXS functions */
uint32_t nextTokenType() { return ++mNextTokenType; } uint32_t nextTokenType() { return ++mNextTokenType; }
@ -58,6 +58,7 @@ protected:
virtual void groupNameChanged(const QString &/*name*/) {} virtual void groupNameChanged(const QString &/*name*/) {}
virtual void clearPosts() = 0; virtual void clearPosts() = 0;
virtual bool navigatePostItem(const RsGxsMessageId& msgId) = 0;
/* Thread functions */ /* Thread functions */
virtual bool useThread() { return false; } virtual bool useThread() { return false; }
@ -86,6 +87,7 @@ protected:
uint32_t mTokenTypePosts; uint32_t mTokenTypePosts;
uint32_t mTokenTypeRelatedPosts; uint32_t mTokenTypeRelatedPosts;
UIStateHelper *mStateHelper; UIStateHelper *mStateHelper;
RsGxsMessageId mNavigatePendingMsgId;
private: private:
RsGxsGroupId mGroupId; /* current group */ RsGxsGroupId mGroupId; /* current group */

View File

@ -38,6 +38,7 @@ public:
virtual QString groupName(bool withUnreadCount) = 0; virtual QString groupName(bool withUnreadCount) = 0;
virtual QIcon groupIcon() = 0; virtual QIcon groupIcon() = 0;
virtual void setAllMessagesRead(bool read) = 0; virtual void setAllMessagesRead(bool read) = 0;
virtual bool navigate(const RsGxsMessageId& msgId) = 0;
signals: signals:
void groupChanged(QWidget *widget); void groupChanged(QWidget *widget);

View File

@ -79,7 +79,6 @@ QString GxsChannelDialog::text(TextType type)
case TEXT_TODO: case TEXT_TODO:
return "<b>Open points:</b><ul>" return "<b>Open points:</b><ul>"
"<li>Restore channel keys" "<li>Restore channel keys"
"<li>Navigate channel link"
"</ul>"; "</ul>";
case TEXT_YOUR_GROUP: case TEXT_YOUR_GROUP:

View File

@ -394,6 +394,16 @@ void GxsChannelPostsWidget::clearPosts()
ui->fileWidget->clear(); 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) void GxsChannelPostsWidget::subscribeGroup(bool subscribe)
{ {
if (groupId().isNull()) { if (groupId().isNull()) {

View File

@ -73,6 +73,7 @@ protected:
virtual void clearPosts(); virtual void clearPosts();
virtual bool useThread() { return mUseThread; } virtual bool useThread() { return mUseThread; }
virtual void fillThreadCreatePost(const QVariant &post, bool related, int current, int count); virtual void fillThreadCreatePost(const QVariant &post, bool related, int current, int count);
virtual bool navigatePostItem(const RsGxsMessageId& msgId);
private slots: private slots:
void createMsg(); void createMsg();

View File

@ -752,6 +752,11 @@ void GxsForumThreadWidget::fillThreadFinished()
calculateIconsAndFonts(); calculateIconsAndFonts();
calculateUnreadCount(); calculateUnreadCount();
emit groupChanged(this); emit groupChanged(this);
if (!mNavigatePendingMsgId.isNull()) {
navigate(mNavigatePendingMsgId);
mNavigatePendingMsgId.clear();
}
} }
#ifdef DEBUG_FORUMS #ifdef DEBUG_FORUMS
@ -1506,29 +1511,45 @@ void GxsForumThreadWidget::setAllMessagesRead(bool read)
markMsgAsReadUnread(read, true, true); 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() void GxsForumThreadWidget::copyMessageLink()
{ {
if (mForumId.isNull() || mThreadId.isNull()) { if (mForumId.isNull() || mThreadId.isNull()) {
return; return;
} }
// THIS CODE CALLS getForumInfo() to verify that the Ids are valid. RetroShareLink link;
// As we are switching to Request/Response this is now harder to do... if (link.createGxsMessageLink(RetroShareLink::TYPE_FORUM, mForumId, mThreadId, ui->threadTitle->text())) {
// So not bothering any more - shouldn't be necessary. QList<RetroShareLink> urls;
// IF we get errors - fix them, rather than patching here. urls.push_back(link);
#if 0 RSLinkClipboard::copyLinks(urls);
ForumInfo fi;
if (rsGxsForums->getForumInfo(mForumId, fi)) {
RetroShareLink link;
if (link.createForum(mForumId, mThreadId)) {
QList<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);
}
} }
#endif
QMessageBox::warning(this, "RetroShare", "ToDo");
} }
void GxsForumThreadWidget::subscribeGroup(bool subscribe) void GxsForumThreadWidget::subscribeGroup(bool subscribe)
@ -1704,6 +1725,8 @@ void GxsForumThreadWidget::requestGroup_CurrentForum()
mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, true); mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, true);
emit groupChanged(this); emit groupChanged(this);
mNavigatePendingMsgId.clear();
RsTokReqOptions opts; RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;

View File

@ -41,18 +41,20 @@ public:
void setTextColorNotSubscribed(QColor color) { mTextColorNotSubscribed = color; } void setTextColorNotSubscribed(QColor color) { mTextColorNotSubscribed = color; }
void setTextColorMissing(QColor color) { mTextColorMissing = color; } void setTextColorMissing(QColor color) { mTextColorMissing = color; }
/* GxsMessageFrameWidget */
virtual RsGxsGroupId groupId() { return mForumId; } virtual RsGxsGroupId groupId() { return mForumId; }
virtual void setGroupId(const RsGxsGroupId &forumId); virtual void setGroupId(const RsGxsGroupId &forumId);
virtual QString groupName(bool withUnreadCount); virtual QString groupName(bool withUnreadCount);
virtual QIcon groupIcon(); virtual QIcon groupIcon();
virtual void setAllMessagesRead(bool read);
virtual bool navigate(const RsGxsMessageId& msgId);
unsigned int newCount() { return mNewCount; } unsigned int newCount() { return mNewCount; }
unsigned int unreadCount() { return mUnreadCount; } unsigned int unreadCount() { return mUnreadCount; }
QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn); QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn);
QTreeWidgetItem *generateMissingItem(const RsGxsMessageId &msgId); QTreeWidgetItem *generateMissingItem(const RsGxsMessageId &msgId);
virtual void setAllMessagesRead(bool read);
// Callback for all Loads. // Callback for all Loads.
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
@ -159,6 +161,8 @@ private:
UIStateHelper *mStateHelper; UIStateHelper *mStateHelper;
RsGxsMessageId mNavigatePendingMsgId;
Ui::GxsForumThreadWidget *ui; Ui::GxsForumThreadWidget *ui;
}; };

View File

@ -68,7 +68,6 @@ QString GxsForumsDialog::text(TextType type)
return "<b>Open points:</b><ul>" return "<b>Open points:</b><ul>"
"<li>Restore forum keys" "<li>Restore forum keys"
"<li>Display AUTHD" "<li>Display AUTHD"
"<li>Navigate forum link"
"<li>Remove messages" "<li>Remove messages"
"</ul>"; "</ul>";