- Added copy link to GxsFeedItem (GxsChannelPostItem)

- Fixed copy link of GxsGroupFrameDialog
  - utf8 issue
  - removed unread message count from group name

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7476 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-07-26 23:52:45 +00:00
parent 8427c92486
commit 3458cdc8fc
12 changed files with 112 additions and 182 deletions

View file

@ -175,6 +175,11 @@ RsPostedPost &PostedItem::post()
return mPost; return mPost;
} }
QString PostedItem::messageName()
{
return QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
}
void PostedItem::makeDownVote() void PostedItem::makeDownVote()
{ {
RsGxsGrpMsgIdPair msgId; RsGxsGrpMsgIdPair msgId;

View file

@ -53,6 +53,8 @@ signals:
protected: protected:
virtual void loadMessage(const uint32_t &token); virtual void loadMessage(const uint32_t &token);
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
virtual QString messageName();
private: private:
void setup(); void setup();

View file

@ -408,85 +408,14 @@ bool RetroShareLink::createUnknwonSslCertificate(const RsPeerId& sslId, const Rs
return false; return false;
} }
bool RetroShareLink::createForum(const std::string& id, const std::string& msgId) bool RetroShareLink::createGxsGroupLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const QString &groupName)
{ {
clear(); clear();
#if 0 if (!groupId.isNull()) {
if (!id.empty()) { _hash = QString::fromStdString(groupId.toStdString());
_hash = QString::fromStdString(id);
_msgId = QString::fromStdString(msgId);
_type = TYPE_FORUM;
if (msgId.empty()) {
ForumInfo fi;
if (rsForums->getForumInfo(id, fi)) {
_name = QString::fromStdWString(fi.forumName);
}
} else {
ForumMsgInfo mi;
if (rsForums->getForumMessage(id, msgId, mi)) {
_name = ForumsDialog::titleFromInfo(mi);
}
}
}
#endif
check();
return valid();
}
bool RetroShareLink::createChannel(const std::string &id, const std::string &msgId)
{
clear();
#if 0
if (!id.empty()) {
_hash = QString::fromStdString(id);
_msgId = QString::fromStdString(msgId);
_type = TYPE_CHANNEL;
if (msgId.empty()) {
ChannelInfo ci;
if (rsChannels->getChannelInfo(id, ci)) {
_name = QString::fromStdWString(ci.channelName);
}
} else {
ChannelMsgInfo mi;
if (rsChannels->getChannelMessage(id, msgId, mi)) {
_name = QString::fromStdWString(mi.subject);
}
}
}
#endif
check();
return valid();
}
bool RetroShareLink::createGxsLink(const RsGxsGroupId &id, const RsGxsMessageId &msgId,
const std::string& groupName, const std::string& msgSubject,
const RetroShareLink::enumType &linkType)
{
clear();
if (!id.isNull()) {
_hash = QString::fromStdString(id.toStdString());
if(!msgId.isNull())
_msgId = QString::fromStdString(msgId.toStdString());
_type = linkType; _type = linkType;
_name = groupName;
if (msgId.isNull()) {
_name = QString::fromStdString(groupName);
} else {
_name = QString::fromStdString(msgSubject);
}
} }
check(); check();
@ -494,6 +423,21 @@ bool RetroShareLink::createGxsLink(const RsGxsGroupId &id, const RsGxsMessageId
return valid(); return valid();
} }
bool RetroShareLink::createGxsMessageLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &msgName)
{
clear();
if (!groupId.isNull() && !msgId.isNull()) {
_hash = QString::fromStdString(groupId.toStdString());
_msgId = QString::fromStdString(msgId.toStdString());
_type = linkType;
_name = msgName;
}
check();
return valid();
}
bool RetroShareLink::createSearch(const QString& keywords) bool RetroShareLink::createSearch(const QString& keywords)
{ {

View file

@ -56,7 +56,8 @@
class RetroShareLink class RetroShareLink
{ {
public: public:
enum enumType { TYPE_UNKNOWN = 0x00, enum enumType {
TYPE_UNKNOWN = 0x00,
TYPE_FILE = 0x01, TYPE_FILE = 0x01,
TYPE_PERSON = 0x02, TYPE_PERSON = 0x02,
TYPE_FORUM = 0x03, TYPE_FORUM = 0x03,
@ -77,11 +78,8 @@ class RetroShareLink
bool createFile(const QString& name, uint64_t size, const QString& hash); bool createFile(const QString& name, uint64_t size, const QString& hash);
bool createExtraFile(const QString& name, uint64_t size, const QString& hash, const QString& ssl_id); bool createExtraFile(const QString& name, uint64_t size, const QString& hash, const QString& ssl_id);
bool createPerson(const RsPgpId &id); bool createPerson(const RsPgpId &id);
bool createForum(const std::string& id, const std::string& msgId); bool createGxsGroupLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const QString &groupName);
bool createChannel(const std::string& id, const std::string& msgId); bool createGxsMessageLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &msgName);
bool createGxsLink(const RsGxsGroupId &id, const RsGxsMessageId &msgId,
const std::string& groupName, const std::string& msgSubject,
const RetroShareLink::enumType &linkType);
bool createSearch(const QString& keywords); bool createSearch(const QString& keywords);
bool createMessage(const RsPeerId &peerId, const QString& subject); bool createMessage(const RsPeerId &peerId, const QString& subject);
bool createMessage(const RsGxsId &peerId, const QString& subject); bool createMessage(const RsGxsId &peerId, const QString& subject);

View file

@ -423,7 +423,6 @@ void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
item->setText(COLUMN_NAME, name); item->setText(COLUMN_NAME, name);
item->setFont(COLUMN_NAME, font); item->setFont(COLUMN_NAME, font);
} }
QTreeWidgetItem *GroupTreeWidget::getItemFromId(const QString &id) QTreeWidgetItem *GroupTreeWidget::getItemFromId(const QString &id)
@ -467,21 +466,18 @@ RSTreeWidget *GroupTreeWidget::treeWidget()
return ui->treeWidget; return ui->treeWidget;
} }
bool GroupTreeWidget::getGroupName(QString id, QTreeWidgetItem* categoryItem, QString& name) bool GroupTreeWidget::getGroupName(QString id, QString& name)
{ {
int childCount = categoryItem->childCount(); QTreeWidgetItem *item = getItemFromId(id);
for (int child = 0; child < childCount; child++) { if (item == NULL) {
QTreeWidgetItem *childItem = categoryItem->child(child);
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == id) {
/* Found child */
name = childItem->text(COLUMN_NAME);
return true;
}
}
return false; return false;
} }
name = item->data(COLUMN_DATA, ROLE_NAME).toString();
return true;
}
int GroupTreeWidget::subscribeFlags(const QString &id) int GroupTreeWidget::subscribeFlags(const QString &id)
{ {
QTreeWidgetItem *item = getItemFromId(id); QTreeWidgetItem *item = getItemFromId(id);

View file

@ -99,7 +99,7 @@ public:
void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; } void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; }
void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; } void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; }
bool getGroupName(QString id, QTreeWidgetItem* item, QString& name); bool getGroupName(QString id, QString& name);
int subscribeFlags(const QString &id); int subscribeFlags(const QString &id);

View file

@ -189,11 +189,11 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
{ {
title = tr("Channel Feed") + ": "; title = tr("Channel Feed") + ": ";
RetroShareLink link; RetroShareLink link;
link.createChannel(post.mMeta.mGroupId.toStdString(), ""); link.createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, post.mMeta.mGroupId, "");
title += link.toHtml(); title += link.toHtml();
ui->titleLabel->setText(title); ui->titleLabel->setText(title);
RetroShareLink msgLink; RetroShareLink msgLink;
msgLink.createChannel(post.mMeta.mGroupId.toStdString(), post.mMeta.mMsgId.toStdString()); msgLink.createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, post.mMeta.mGroupId, post.mMeta.mMsgId, QString::fromUtf8(post.mMeta.mMsgName.c_str()));
ui->subjectLabel->setText(msgLink.toHtml()); ui->subjectLabel->setText(msgLink.toHtml());
if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags)) if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags))
@ -314,6 +314,11 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
mInUpdateItemStatic = false; mInUpdateItemStatic = false;
} }
QString GxsChannelPostItem::messageName()
{
return QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
}
void GxsChannelPostItem::setReadStatus(bool isNew, bool isUnread) void GxsChannelPostItem::setReadStatus(bool isNew, bool isUnread)
{ {
if (isUnread) if (isUnread)
@ -536,25 +541,6 @@ void GxsChannelPostItem::channelMsgReadSatusChanged(const QString& channelId, co
#endif #endif
} }
void GxsChannelPostItem::copyLink()
{
#if 0
if (mChanId.empty() || mMsgId.empty()) {
return;
}
ChannelMsgInfo cmi;
if (rsChannels->getChannelMessage(mChanId, mMsgId, cmi)) {
RetroShareLink link;
if (link.createChannel(cmi.channelId, cmi.msgId)) {
QList<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);
}
}
#endif
}
void GxsChannelPostItem::makeDownVote() void GxsChannelPostItem::makeDownVote()
{ {
RsGxsGrpMsgIdPair msgId; RsGxsGrpMsgIdPair msgId;

View file

@ -55,6 +55,8 @@ public:
protected: protected:
virtual void loadMessage(const uint32_t &token); virtual void loadMessage(const uint32_t &token);
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
virtual QString messageName();
private slots: private slots:
/* default stuff */ /* default stuff */
@ -62,7 +64,6 @@ private slots:
void readAndClearItem(); void readAndClearItem();
void download(); void download();
void play(); void play();
void copyLink();
void loadComments(); void loadComments();
void readToggled(bool checked); void readToggled(bool checked);

View file

@ -97,6 +97,24 @@ void GxsFeedItem::subscribe()
} }
} }
void GxsFeedItem::copyLink()
{
if (mGroupId.isNull() || mMessageId.isNull()) {
return;
}
if (getLinkType() == RetroShareLink::TYPE_UNKNOWN) {
return;
}
RetroShareLink link;
if (link.createGxsMessageLink(getLinkType(), mGroupId, mMessageId, messageName())) {
QList<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);
}
}
void GxsFeedItem::updateItemStatic() void GxsFeedItem::updateItemStatic()
{ {
std::cerr << "GxsFeedItem::updateItemStatic()"; std::cerr << "GxsFeedItem::updateItemStatic()";

View file

@ -26,6 +26,8 @@
#include <retroshare/rsgxsifacehelper.h> #include <retroshare/rsgxsifacehelper.h>
#include "util/TokenQueue.h" #include "util/TokenQueue.h"
#include "gui/RetroShareLink.h"
#include <stdint.h> #include <stdint.h>
class FeedHolder; class FeedHolder;
@ -54,6 +56,9 @@ protected:
virtual void loadGroupMeta(const uint32_t &token); virtual void loadGroupMeta(const uint32_t &token);
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
virtual RetroShareLink::enumType getLinkType() = 0;
virtual QString messageName() = 0;
// general fns that can be implemented here. // general fns that can be implemented here.
protected slots: protected slots:
@ -61,6 +66,7 @@ protected slots:
void subscribe(); void subscribe();
void unsubscribe(); void unsubscribe();
void removeItem(); void removeItem();
void copyLink();
private slots: private slots:
/* RsGxsUpdateBroadcastBase */ /* RsGxsUpdateBroadcastBase */
@ -85,4 +91,3 @@ private:
}; };
#endif #endif

View file

@ -391,42 +391,17 @@ void GxsGroupFrameDialog::copyGroupLink()
QString name; QString name;
if(!getCurrentGroupName(name)) return; if(!getCurrentGroupName(name)) return;
if (link.createGxsLink(mGroupId, RsGxsMessageId(), name.toStdString(), "", getLinkType())) { if (link.createGxsGroupLink(getLinkType(), mGroupId, name)) {
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
urls.push_back(link); urls.push_back(link);
RSLinkClipboard::copyLinks(urls); RSLinkClipboard::copyLinks(urls);
} }
} }
bool GxsGroupFrameDialog::getCurrentGroupName(QString& name) bool GxsGroupFrameDialog::getCurrentGroupName(QString& name)
{ {
GroupTreeWidget* gtw = ui->groupTreeWidget; return ui->groupTreeWidget->getGroupName(QString::fromStdString(mGroupId.toStdString()), name);
QString id = QString::fromStdString(mGroupId.toStdString());
if(gtw->getGroupName(id, mYourGroups, name))
{
return true;
} }
else if(gtw->getGroupName(id, mSubscribedGroups, name))
{
return true;
}
else if(gtw->getGroupName(id, mYourGroups, name))
{
return true;
}
else if(gtw->getGroupName(id, mOtherGroups, name))
{
return true;
}
return false;
}
void GxsGroupFrameDialog::markMsgAsRead() void GxsGroupFrameDialog::markMsgAsRead()
{ {