Added New Services to GUI.

- Added GxsChannels 
 - Added New Common Comments GUI elements.
 - Moved Posted over to use Comments.
 
Lots done, but lots to do!



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6212 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2013-03-11 20:53:15 +00:00
parent a05f04900c
commit da4c1e0f7f
38 changed files with 5725 additions and 550 deletions

View File

@ -246,6 +246,10 @@ void ChannelFeed::openChat(std::string /*peerId*/)
{
}
void ChannelFeed::openComments(uint32_t /*type*/ , const RsGxsGroupId & /*grpId */, const RsGxsMessageId & /*msgId*/)
{
}
void ChannelFeed::editChannelDetail(){
EditChanDetails editUi(this, mChannelId);

View File

@ -54,6 +54,7 @@ public:
virtual QScrollArea *getScrollArea();
virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(std::string peerId);
virtual void openComments(uint32_t /*type*/ , const RsGxsGroupId & /*grpId */, const RsGxsMessageId & /*msgId*/);
bool navigate(const std::string& channelId, const std::string& msgId);

View File

@ -810,6 +810,15 @@ void NewsFeed::openChat(std::string peerId)
ChatDialog::chatFriend(peerId);
}
void NewsFeed::openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId)
{
std::cerr << "NewsFeed::openComments() Not Handled Yet";
std::cerr << std::endl;
}
void NewsFeed::itemDestroyed(QObject *item)
{
widgets.remove(item);

View File

@ -47,6 +47,7 @@ public:
virtual QScrollArea *getScrollArea();
virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(std::string peerId);
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId);
static void testFeeds(uint notifyFlags);
static void testFeed(FeedNotify *feedNotify);

View File

@ -18,7 +18,7 @@ void PostedCreatePostDialog::createPost()
post.mMeta.mMsgName = ui->titleEdit->text().toStdString();
uint32_t token;
mPosted->submitPost(token, post);
mPosted->createPost(token, post);
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_POST);
close();
}

View File

@ -24,43 +24,43 @@
#ifndef MRK_POSTED_DIALOG_H
#define MRK_POSTED_DIALOG_H
#include "retroshare-gui/mainpage.h"
#include "ui_PostedDialog.h"
#include <retroshare/rsposted.h>
#include <map>
#include "gui/gxs/GxsCommentContainer.h"
#include "gui/Posted/PostedListDialog.h"
class CommentHolder
{
public:
/*!
* This should be used for loading comments of a message on a main comment viewing page
* @param msgId the message id for which comments will be requested
*/
virtual void commentLoad(const RsPostedPost&) = 0;
};
class PostedListDialog;
class PostedComments;
class PostedDialog : public MainPage, public CommentHolder
class PostedDialog : public GxsCommentContainer
{
Q_OBJECT
public:
PostedDialog(QWidget *parent = 0);
void commentLoad(const RsPostedPost &);
PostedDialog(QWidget *parent = 0)
:GxsCommentContainer(parent) { return; }
private:
virtual GxsServiceDialog *createServiceDialog()
{
return new PostedListDialog(this);
}
PostedListDialog *mPostedList;
PostedComments *mPostedComments;
virtual QString getServiceName()
{
return tr("Posted");
}
/* UI - from Designer */
Ui::PostedDialog ui;
virtual RsTokenService *getTokenService()
{
return rsPosted->getTokenService();
}
virtual RsGxsCommentService *getCommentService()
{
return rsPosted;
}
virtual GxsCommentHeader *createHeaderWidget()
{
return NULL;
}
};
#endif

View File

@ -20,35 +20,49 @@
****************************************************************/
#include "PostedGroupDialog.h"
#include "util/TokenQueue.h"
#include <retroshare/rsposted.h>
#include <retroshare/rswiki.h>
#include <iostream>
#define POSTED_ENABLE_FLAG ( GXS_GROUP_FLAGS_ICON | \
GXS_GROUP_FLAGS_DESCRIPTION | \
GXS_GROUP_FLAGS_DISTRIBUTION | \
GXS_GROUP_FLAGS_PUBLISHSIGN | \
GXS_GROUP_FLAGS_SHAREKEYS | \
GXS_GROUP_FLAGS_PERSONALSIGN | \
GXS_GROUP_FLAGS_COMMENTS | \
0)
const uint32_t PostedCreateEnabledFlags = ( // GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN |
GXS_GROUP_FLAGS_SHAREKEYS |
// GXS_GROUP_FLAGS_PERSONALSIGN |
// GXS_GROUP_FLAGS_COMMENTS |
0);
#define POSTED_CREATE_DEFAULT_FLAG ( GXS_GROUP_DEFAULTS_DISTRIB_LOCAL | \
GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED | \
GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB | \
GXS_GROUP_DEFAULTS_COMMENTS_NO | \
0)
uint32_t PostedCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP |
//GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
PostedGroupDialog::PostedGroupDialog(TokenQueue* tokenQueue, RsPosted* posted, QWidget *parent)
:GxsGroupDialog(tokenQueue, POSTED_ENABLE_FLAG, POSTED_CREATE_DEFAULT_FLAG, parent),
mPosted(posted)
GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
//GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
//GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
//GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED |
//GXS_GROUP_DEFAULTS_PERSONAL_GPG |
GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
//GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
//GXS_GROUP_DEFAULTS_COMMENTS_YES |
GXS_GROUP_DEFAULTS_COMMENTS_NO |
0);
PostedGroupDialog::PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
:GxsGroupDialog(tokenQueue, PostedCreateEnabledFlags, PostedCreateDefaultsFlags, parent)
{
}
PostedGroupDialog::PostedGroupDialog(const RsPostedGroup& grp, Mode mode, QWidget *parent)
:GxsGroupDialog(grp.mMeta, mode, parent), mGrp(grp)
PostedGroupDialog::PostedGroupDialog(const RsPostedGroup &group, QWidget *parent)
:GxsGroupDialog(group.mMeta, MODE_SHOW, parent)
{
}
void PostedGroupDialog::initUi()
@ -65,20 +79,26 @@ void PostedGroupDialog::initUi()
setUiText(UITYPE_SERVICE_HEADER, tr("Edit Posted Topic"));
break;
}
setUiText(UITYPE_KEY_SHARE_CHECKBOX, tr("Add Topic Admins"));
setUiText(UITYPE_CONTACTS_DOCK, tr("Select Topic Admins"));
}
QPixmap PostedGroupDialog::serviceImage()
{
return QPixmap(":/images/posted_add_64.png");
return QPixmap(":/images/resource-group_64.png");
}
bool PostedGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
{
// Specific Function.
RsPostedGroup grp;
grp.mDescription = getDescription().toStdString();
RsPostedGroup grp;
grp.mMeta = meta;
grp.mDescription = getDescription().toStdString();
std::cerr << "PostedGroupDialog::service_CreateGroup() storing to Queue";
std::cerr << std::endl;
rsPosted->createGroup(token, grp);
rsPosted->submitGroup(token, grp);
return true;
}

View File

@ -24,32 +24,26 @@
#define _POSTED_GROUP_DIALOG_H
#include "gui/gxs/GxsGroupDialog.h"
#include "retroshare/rsposted.h"
#include <retroshare/rsposted.h>
class PostedGroupDialog : public GxsGroupDialog
{
Q_OBJECT
public:
/*!
* This constructs a create dialog
*/
PostedGroupDialog(TokenQueue* tokenQueue, RsPosted* posted, QWidget *parent = NULL);
/*!
* This constructs a show dialog which displays an already existing group
*/
PostedGroupDialog(const RsPostedGroup& grp, Mode mode, QWidget *parent = NULL);
PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
PostedGroupDialog(const RsPostedGroup &topic, QWidget *parent);
protected:
virtual void initUi();
virtual QPixmap serviceImage();
bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
virtual void initUi();
virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
private:
RsPostedGroup mGrp;
RsPosted* mPosted;
RsPostedGroup mTopic;
};
#endif

View File

@ -69,6 +69,7 @@ void PostedItem::setContent(const RsPostedPost &post)
uint32_t up, down, nComments;
#if 0
bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments);
if(ok)
@ -82,6 +83,7 @@ void PostedItem::setContent(const RsPostedPost &post)
"style=\" font-size:8pt; font-weight:600;\"> Comments: "
+ QString::number(nComments) + "</span></p>");
}
#endif
}

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,8 @@
#include "retroshare-gui/RsAutoUpdatePage.h"
#include "PostedUserTypes.h"
#include "gui/gxs/GxsCommentContainer.h"
class CommentHolder;
/*********************** **** **** **** ***********************/
/** Request / Response of Data ********************************/
@ -53,12 +53,12 @@ class CommentHolder;
#define POSTEDDIALOG_INSERT_POST 5
#define POSTEDDIALOG_REPLY_MESSAGE 6
class PostedListDialog : public RsAutoUpdatePage, public PostedHolder, public TokenResponse
class PostedListDialog : public RsAutoUpdatePage, public PostedHolder, public TokenResponse, public GxsServiceDialog
{
Q_OBJECT
public:
PostedListDialog(CommentHolder* commentHolder, QWidget *parent = 0);
PostedListDialog(QWidget *parent = 0);
void showComments(const RsPostedPost& post);
@ -112,8 +112,8 @@ private:
// ranking
void loadRankings(const uint32_t& token);
void applyRanking(const PostedRanking& ranks);
//void loadRankings(const uint32_t& token);
//void applyRanking(const PostedRanking& ranks);
// update displayed item
@ -141,7 +141,7 @@ private:
QMap<RsGxsMessageId, PostedItem*> mPosts;
TokenQueue *mPostedQueue;
CommentHolder* mCommentHolder;
//CommentHolder* mCommentHolder;
/* UI - from Designer */
Ui::PostedListDialog ui;

View File

@ -25,6 +25,8 @@
#include <string>
#include <stdint.h>
#include <retroshare/rsgxschannels.h> // WRONG ONE - BUT IT'LL DO FOR NOW.
class QScrollArea;
class FeedHolder
@ -35,6 +37,7 @@ public:
virtual QScrollArea *getScrollArea() = 0;
virtual void deleteFeedItem(QWidget *item, uint32_t type) = 0;
virtual void openChat(std::string peerId) = 0;
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId) = 0;
// Workaround for QTBUG-3372
void lockLayout(QWidget *feedItem, bool lock);

View File

@ -0,0 +1,663 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QDateTime>
#include <QTimer>
#include <QFileInfo>
#include "rshare.h"
#include "GxsChannelPostItem.h"
#include "FeedHolder.h"
#include "SubFileItem.h"
#include "gui/notifyqt.h"
#include "util/misc.h"
#include "gui/RetroShareLink.h"
#include "util/HandleRichText.h"
#include "util/DateTime.h"
#include <retroshare/rschannels.h>
/****
* #define DEBUG_ITEM 1
****/
#define COLOR_NORMAL QColor(248, 248, 248)
#define COLOR_NEW QColor(220, 236, 253)
#define SELF_LOAD 1
#define DATA_PROVIDED 2
/** Constructor */
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const std::string &chanId, const std::string &msgId, bool isHome)
:QWidget(NULL), mParent(parent), mFeedId(feedId),
mChanId(chanId), mMsgId(msgId), mIsHome(isHome)
{
mMode = SELF_LOAD;
mSubscribeFlags = 0;
setup();
// THIS IS JUST SO WE REMEMBER TO DO IT.
updateItemStatic();
updateItem();
}
/** Constructor */
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subFlags, bool isHome)
:QWidget(NULL), mParent(parent), mFeedId(feedId),
mChanId(post.mMeta.mGroupId), mMsgId(post.mMeta.mMsgId), mIsHome(isHome)
{
mMode = DATA_PROVIDED;
mSubscribeFlags = subFlags;
setup();
loadPost(post);
updateItem();
}
void GxsChannelPostItem::setup()
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
m_inUpdateItemStatic = false;
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
/* specific */
connect(readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem()));
connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
//connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) );
// HACK FOR NOW.
connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( comments ( void ) ) );
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) );
connect( copyLinkButton, SIGNAL( clicked( void ) ), this, SLOT( copyLink ( void ) ) );
connect( readButton, SIGNAL( toggled(bool) ), this, SLOT( readToggled(bool) ) );
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
downloadButton->hide();
playButton->hide();
warn_image_label->hide();
warning_label->hide();
titleLabel->setMinimumWidth(100);
subjectLabel->setMinimumWidth(100);
warning_label->setMinimumWidth(100);
frame->setProperty("state", "");
QPalette palette = frame->palette();
palette.setColor(frame->backgroundRole(), COLOR_NORMAL);
frame->setPalette(palette);
expandFrame->hide();
}
void GxsChannelPostItem::updateItemStatic()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::updateItemStatic()";
std::cerr << std::endl;
#endif
ChannelMsgInfo cmi;
if (!rsChannels)
return;
if (!rsChannels->getChannelMessage(mChanId, mMsgId, cmi))
return;
m_inUpdateItemStatic = true;
QString title;
ChannelInfo ci;
rsChannels->getChannelInfo(mChanId, ci);
if (!mIsHome)
{
title = tr("Channel Feed") + ": ";
RetroShareLink link;
link.createChannel(ci.channelId, "");
title += link.toHtml();
titleLabel->setText(title);
RetroShareLink msgLink;
msgLink.createChannel(cmi.channelId, cmi.msgId);
subjectLabel->setText(msgLink.toHtml());
if ((ci.channelFlags & RS_DISTRIB_SUBSCRIBED) || (ci.channelFlags & RS_DISTRIB_ADMIN)) {
unsubscribeButton->setEnabled(true);
} else {
unsubscribeButton->setEnabled(false);
}
readButton->hide();
newLabel->hide();
copyLinkButton->hide();
}
else
{
/* subject */
titleLabel->setText(QString::fromStdWString(cmi.subject));
subjectLabel->setText(RsHtml().formatText(NULL, QString::fromStdWString(cmi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
/* disable buttons: deletion facility not enabled with cache services yet */
clearButton->setEnabled(false);
unsubscribeButton->setEnabled(false);
clearButton->hide();
readAndClearButton->hide();
unsubscribeButton->hide();
copyLinkButton->show();
if ((ci.channelFlags & RS_DISTRIB_SUBSCRIBED) || (ci.channelFlags & RS_DISTRIB_ADMIN)) {
readButton->setVisible(true);
uint32_t status = 0;
rsChannels->getMessageStatus(mChanId, mMsgId, status);
if ((status & CHANNEL_MSG_STATUS_READ) == 0 || (status & CHANNEL_MSG_STATUS_UNREAD_BY_USER)) {
readButton->setChecked(true);
readButton->setIcon(QIcon(":/images/message-state-unread.png"));
} else {
readButton->setChecked(false);
readButton->setIcon(QIcon(":/images/message-state-read.png"));
}
bool newState;
QColor color;
if (status & CHANNEL_MSG_STATUS_READ) {
newLabel->setVisible(false);
newState = false;
color = COLOR_NORMAL;
} else {
newLabel->setVisible(true);
newState = true;
color = COLOR_NEW;
}
/* unpolish widget to clear the stylesheet's palette cache */
frame->style()->unpolish(frame);
QPalette palette = frame->palette();
palette.setColor(frame->backgroundRole(), color);
frame->setPalette(palette);
frame->setProperty("new", newState);
Rshare::refreshStyleSheet(frame, false);
} else {
readButton->setVisible(false);
newLabel->setVisible(false);
}
}
msgLabel->setText(RsHtml().formatText(NULL, QString::fromStdWString(cmi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
msgFrame->setVisible(!cmi.msg.empty());
datetimelabel->setText(DateTime::formatLongDateTime(cmi.ts));
filelabel->setText(QString("(%1 %2) %3").arg(cmi.count).arg(tr("Files")).arg(misc::friendlyUnit(cmi.size)));
if (mFileItems.empty() == false) {
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
delete(*it);
}
mFileItems.clear();
}
std::list<FileInfo>::iterator it;
for(it = cmi.files.begin(); it != cmi.files.end(); it++)
{
/* add file */
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size,
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
mFileItems.push_back(fi);
/* check if the file is a media file */
if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->fname.c_str())).suffix()))
fi->mediatype();
QLayout *layout = expandFrame->layout();
layout->addWidget(fi);
}
if(cmi.thumbnail.image_thumbnail != NULL)
{
QPixmap thumbnail;
thumbnail.loadFromData(cmi.thumbnail.image_thumbnail, cmi.thumbnail.im_thumbnail_size, "PNG");
logoLabel->setPixmap(thumbnail);
}
m_inUpdateItemStatic = false;
}
void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::loadPost()";
std::cerr << std::endl;
#endif
QString title;
if (!mIsHome)
{
title = tr("Channel Feed") + ": ";
RetroShareLink link;
link.createChannel(post.mMeta.mGroupId, "");
title += link.toHtml();
titleLabel->setText(title);
RetroShareLink msgLink;
msgLink.createChannel(post.mMeta.mGroupId, post.mMeta.mMsgId);
subjectLabel->setText(msgLink.toHtml());
if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags))
{
unsubscribeButton->setEnabled(true);
}
else
{
unsubscribeButton->setEnabled(false);
}
readButton->hide();
newLabel->hide();
copyLinkButton->hide();
}
else
{
/* subject */
titleLabel->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
subjectLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
/* disable buttons: deletion facility not enabled with cache services yet */
clearButton->setEnabled(false);
unsubscribeButton->setEnabled(false);
clearButton->hide();
readAndClearButton->hide();
unsubscribeButton->hide();
copyLinkButton->show();
if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags))
{
readButton->setVisible(true);
uint32_t status = 0;
rsChannels->getMessageStatus(mChanId, mMsgId, status);
if (IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
{
readButton->setChecked(true);
readButton->setIcon(QIcon(":/images/message-state-unread.png"));
}
else
{
readButton->setChecked(false);
readButton->setIcon(QIcon(":/images/message-state-read.png"));
}
bool newState;
QColor color;
if (!IS_MSG_UNREAD(post.mMeta.mMsgStatus))
{
newLabel->setVisible(false);
newState = false;
color = COLOR_NORMAL;
}
else
{
newLabel->setVisible(true);
newState = true;
color = COLOR_NEW;
}
/* unpolish widget to clear the stylesheet's palette cache */
frame->style()->unpolish(frame);
QPalette palette = frame->palette();
palette.setColor(frame->backgroundRole(), color);
frame->setPalette(palette);
frame->setProperty("new", newState);
Rshare::refreshStyleSheet(frame, false);
}
else
{
readButton->setVisible(false);
newLabel->setVisible(false);
}
}
msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
msgFrame->setVisible(!post.mMsg.empty());
datetimelabel->setText(DateTime::formatLongDateTime(post.mMeta.mPublishTs));
filelabel->setText(QString("(%1 %2) %3").arg(post.mCount).arg(tr("Files")).arg(misc::friendlyUnit(post.mSize)));
if (mFileItems.empty() == false) {
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
delete(*it);
}
mFileItems.clear();
}
#if 0
std::list<FileInfo>::iterator it;
for(it = cmi.files.begin(); it != cmi.files.end(); it++)
{
/* add file */
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size,
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
mFileItems.push_back(fi);
/* check if the file is a media file */
if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->fname.c_str())).suffix()))
fi->mediatype();
QLayout *layout = expandFrame->layout();
layout->addWidget(fi);
}
if(cmi.thumbnail.image_thumbnail != NULL)
{
QPixmap thumbnail;
thumbnail.loadFromData(cmi.thumbnail.image_thumbnail, cmi.thumbnail.im_thumbnail_size, "PNG");
logoLabel->setPixmap(thumbnail);
}
#endif
}
void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left)
{
int hours = (int)time_left/3600;
int minutes = (time_left - hours*3600)%60;
warning_label->setText(tr("Warning! You have less than %1 hours and %2 minute before this file is deleted Consider saving it.").arg(
QString::number(hours)).arg(QString::number(minutes)));
QFont warnFont = warning_label->font();
warnFont.setBold(true);
warning_label->setFont(warnFont);
warn_image_label->setVisible(true);
warning_label->setVisible(true);
return;
}
void GxsChannelPostItem::updateItem()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::updateItem()";
std::cerr << std::endl;
#endif
int msec_rate = 10000;
int downloadCount = 0;
int downloadStartable = 0;
int playCount = 0;
int playStartable = 0;
bool startable;
bool loopAgain = false;
/* Very slow Tick to check when all files are downloaded */
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
SubFileItem *item = *it;
if (item->isDownloadable(startable)) {
downloadCount++;
if (startable) {
downloadStartable++;
}
}
if (item->isPlayable(startable)) {
playCount++;
if (startable) {
playStartable++;
}
}
if (!item->done())
{
/* loop again */
loopAgain = true;
}
}
if (downloadCount) {
downloadButton->show();
if (downloadStartable) {
downloadButton->setEnabled(true);
} else {
downloadButton->setEnabled(false);
}
} else {
downloadButton->hide();
}
if (playCount) {
/* one file is playable */
playButton->show();
if (playStartable == 1) {
playButton->setEnabled(true);
} else {
playButton->setEnabled(false);
}
} else {
playButton->hide();
}
if (loopAgain) {
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
}
// HACK TO DISPLAY COMMENT BUTTON FOR NOW.
downloadButton->show();
downloadButton->setEnabled(true);
}
void GxsChannelPostItem::toggle()
{
mParent->lockLayout(this, true);
if (expandFrame->isHidden())
{
expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
readToggled(false);
}
else
{
expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
}
mParent->lockLayout(this, false);
}
void GxsChannelPostItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::removeItem()";
std::cerr << std::endl;
#endif
mParent->lockLayout(this, true);
hide();
mParent->lockLayout(this, false);
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
void GxsChannelPostItem::comments()
{
#ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::comments()";
std::cerr << std::endl;
#endif
if (mParent)
{
mParent->openComments(mFeedId, mChanId, mMsgId);
}
}
/*********** SPECIFIC FUNCTIONS ***********************/
void GxsChannelPostItem::readAndClearItem()
{
#ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::readAndClearItem()";
std::cerr << std::endl;
#endif
readToggled(false);
removeItem();
}
void GxsChannelPostItem::unsubscribeChannel()
{
#ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::unsubscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
rsChannels->channelSubscribe(mChanId, false, false);
}
updateItemStatic();
}
void GxsChannelPostItem::download()
{
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
(*it)->download();
}
updateItem();
}
void GxsChannelPostItem::play()
{
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
bool startable;
if ((*it)->isPlayable(startable) && startable) {
(*it)->play();
}
}
}
void GxsChannelPostItem::readToggled(bool checked)
{
if (m_inUpdateItemStatic) {
return;
}
/* set always as read ... */
uint32_t statusNew = CHANNEL_MSG_STATUS_READ;
if (checked) {
/* ... and as unread by user */
statusNew |= CHANNEL_MSG_STATUS_UNREAD_BY_USER;
} else {
/* ... and as read by user */
statusNew &= ~CHANNEL_MSG_STATUS_UNREAD_BY_USER;
}
if (!mIsHome) {
disconnect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
}
rsChannels->setMessageStatus(mChanId, mMsgId, statusNew, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
if (!mIsHome) {
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
}
}
void GxsChannelPostItem::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)
{
if (channelId.toStdString() == mChanId && msgId.toStdString() == mMsgId) {
if (!mIsHome) {
if (status & CHANNEL_MSG_STATUS_READ) {
close();
return;
}
}
updateItemStatic();
}
}
void GxsChannelPostItem::copyLink()
{
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);
}
}
}

View File

@ -0,0 +1,83 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _GXS_CHANNEL_POST_ITEM_H
#define _GXS_CHANNEL_POST_ITEM_H
#include <retroshare/rsgxschannels.h>
#include "ui_GxsChannelPostItem.h"
#include <stdint.h>
class FeedHolder;
class SubFileItem;
class GxsChannelPostItem : public QWidget, private Ui::GxsChannelPostItem
{
Q_OBJECT
public:
/** Default Constructor */
GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const std::string &chanId, const std::string &msgId, bool isHome);
GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subscribeFlags, bool isHome);
void updateItemStatic();
void setFileCleanUpWarning(uint32_t time_left);
const std::string &msgId() { return mMsgId; }
private slots:
/* default stuff */
void removeItem();
void toggle();
void readAndClearItem();
void unsubscribeChannel();
void download();
void play();
void copyLink();
void comments();
void readToggled(bool checked);
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
void updateItem();
private:
void setup();
void loadPost(const RsGxsChannelPost &post);
FeedHolder *mParent;
uint32_t mFeedId;
std::string mChanId;
std::string mMsgId;
bool mIsHome;
bool m_inUpdateItemStatic;
uint32_t mMode;
uint32_t mSubscribeFlags;
std::list<SubFileItem *> mFileItems;
};
#endif

View File

@ -0,0 +1,481 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GxsChannelPostItem</class>
<widget class="QWidget" name="GxsChannelPostItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>629</width>
<height>172</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<property name="margin">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="logoLabel">
<property name="maximumSize">
<size>
<width>156</width>
<height>107</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/thumb-default-video.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:11pt; font-weight:600; font-style:italic;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:normal; color:#656565;&quot;&gt;Channel Subject&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="datetimelabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; color:#666666;&quot;&gt;DateTime&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="subjectLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; color:#666666;&quot;&gt;Short Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="filelabel">
<property name="font">
<font>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string notr="true">fileLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="warn_image_label">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/status_unknown.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="warning_label">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>8</number>
</property>
<item>
<widget class="QPushButton" name="readButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Toggle Message Read Status</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/message-state-unread.png</normaloff>:/images/message-state-unread.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="newLabel">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>21</height>
</size>
</property>
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="downloadButton">
<property name="font">
<font/>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Download</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/download16.png</normaloff>:/images/download16.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="playButton">
<property name="font">
<font/>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Play</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/player_play.png</normaloff>:/images/player_play.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="copyLinkButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Copy RetroShare Link</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/copyrslink.png</normaloff>:/images/copyrslink.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="unsubscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Unsubscribe From Channel</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_delete.png</normaloff>:/images/mail_delete.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="readAndClearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Set as read and remove item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/cancel.png</normaloff>:/images/cancel.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="expandFrame">
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="msgFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="msgLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>6</number>
</property>
<property name="indent">
<number>-1</number>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,91 @@
/*
* Retroshare Posted List
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "gui/gxs/GxsCommentContainer.h"
#include "gui/gxs/GxsCommentDialog.h"
#include <iostream>
#include <sstream>
#include <QTimer>
#include <QMessageBox>
/******
* #define PHOTO_DEBUG 1
*****/
/****************************************************************
* Posted Dialog
*
*/
GxsCommentContainer::GxsCommentContainer(QWidget *parent)
: MainPage(parent)
{
ui.setupUi(this);
}
void GxsCommentContainer::setup()
{
mServiceDialog = createServiceDialog();
QString name = getServiceName();
QString list(name);
QWidget *widget = dynamic_cast<QWidget *>(mServiceDialog);
ui.tabWidget->addTab(widget, name);
}
void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
{
QString comments(tr("Comments"));
GxsCommentDialog *commentDialog = new GxsCommentDialog(this, getTokenService(), getCommentService());
GxsCommentHeader *commentHeader = createHeaderWidget();
commentDialog->setCommentHeader(commentHeader);
commentDialog->commentLoad(grpId, msgId);
//commentHeader->commentLoad(grpId, msgId);
ui.tabWidget->addTab(commentDialog, comments);
}

View File

@ -0,0 +1,97 @@
/*
* Retroshare Comment Container Dialog
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef MRK_COMMENT_CONTAINER_DIALOG_H
#define MRK_COMMENT_CONTAINER_DIALOG_H
#include "retroshare-gui/mainpage.h"
#include "ui_GxsCommentContainer.h"
#include <retroshare/rsgxscommon.h>
#include <retroshare/rstokenservice.h>
#include <map>
class GxsCommentHeader
{
public:
/*!
* This should be used for loading comments of a message on a main comment viewing page
* @param msgId the message id for which comments will be requested
*/
virtual void commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId) = 0;
};
class GxsServiceDialog;
class GxsCommentContainer : public MainPage
{
Q_OBJECT
public:
GxsCommentContainer(QWidget *parent = 0);
void setup();
void commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
virtual GxsServiceDialog *createServiceDialog() = 0;
virtual QString getServiceName() = 0;
virtual RsTokenService *getTokenService() = 0;
virtual RsGxsCommentService *getCommentService() = 0;
virtual GxsCommentHeader *createHeaderWidget() = 0;
private:
GxsServiceDialog *mServiceDialog;
/* UI - from Designer */
Ui::GxsCommentContainer ui;
};
class GxsServiceDialog
{
public:
GxsServiceDialog(GxsCommentContainer *container)
:mContainer(container) { return; }
virtual ~GxsServiceDialog() { return; }
void commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
{
mContainer->commentLoad(grpId, msgId);
}
private:
GxsCommentContainer *mContainer;
};
#endif

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GxsCommentContainer</class>
<widget class="QWidget" name="GxsCommentContainer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>726</width>
<height>557</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>1</number>
</property>
<item>
<widget class="QFrame" name="titleBarFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/posted_24.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Comment Container</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>573</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="Posted_images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,90 @@
/*
* Retroshare Comment Dialog
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "gui/gxs/GxsCommentDialog.h"
//#include "gxs/GxsCreateComment.h"
//#include <retroshare/rsposted.h>
#include <iostream>
#include <sstream>
#include <QTimer>
#include <QMessageBox>
#include <QDateTime>
/** Constructor */
GxsCommentDialog::GxsCommentDialog(QWidget *parent, RsTokenService *token_service, RsGxsCommentService *comment_service)
:QWidget(parent)
{
ui.setupUi(this);
//ui.postFrame->setVisible(false);
ui.treeWidget->setup(token_service, comment_service);
}
void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
{
std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", " << msgId << ")";
std::cerr << std::endl;
mGrpId = grpId;
mMsgId = msgId;
RsGxsGrpMsgIdPair threadId;
threadId.first = grpId;
threadId.second = msgId;
ui.treeWidget->requestComments(threadId);
}
void GxsCommentDialog::setCommentHeader(GxsCommentHeader *header)
{
#if 0
ui.postFrame->setVisible(true);
QDateTime qtime;
qtime.setTime_t(mCurrentPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
ui.dateLabel->setText(timestamp);
ui.fromLabel->setText(QString::fromUtf8(mCurrentPost.mMeta.mAuthorId.c_str()));
ui.titleLabel->setText("<a href=" + QString::fromStdString(mCurrentPost.mLink) +
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
QString::fromStdString(mCurrentPost.mMeta.mMsgName) + "</span></a>");
ui.siteLabel->setText("<a href=" + QString::fromStdString(mCurrentPost.mLink) +
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
QString::fromStdString(mCurrentPost.mLink) + "</span></a>");
ui.scoreLabel->setText(QString("0"));
ui.notesBrowser->setPlainText(QString::fromStdString(mCurrentPost.mNotes));
#endif
}

View File

@ -0,0 +1,51 @@
/*
* Retroshare Comment Dialog
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef MRK_GXS_COMMENT_DIALOG_H
#define MRK_GXS_COMMENT_DIALOG_H
#include "ui_GxsCommentDialog.h"
#include "gui/gxs/GxsCommentContainer.h"
class GxsCommentDialog: public QWidget
{
Q_OBJECT
public:
GxsCommentDialog(QWidget *parent, RsTokenService *token_service, RsGxsCommentService *comment_service);
void setCommentHeader(GxsCommentHeader *header);
void commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
private:
RsGxsGroupId mGrpId;
RsGxsMessageId mMsgId;
/* UI - from Designer */
Ui::GxsCommentDialog ui;
};
#endif

View File

@ -0,0 +1,367 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GxsCommentDialog</class>
<widget class="QWidget" name="GxsCommentDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>632</width>
<height>398</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="postFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(203, 203, 203);</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1">
<item>
<widget class="QLabel" name="scoreLabel">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="voteUpButton">
<property name="text">
<string>/\</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>score</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="voteDownButton">
<property name="text">
<string>\/</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Title this is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title dont you think? yes it is and should wrap around I hope</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QHBoxLayout" name="_4">
<item>
<widget class="QLabel" name="dateBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Date</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">You eyes only</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_3">
<item>
<widget class="QLabel" name="fromBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fromLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_5">
<item>
<widget class="QLabel" name="fromBoldLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Site</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="siteLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="notesBrowser">
<property name="styleSheet">
<string notr="true">background-color: rgb(203, 203, 203);</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="sortGroup">
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="hotSortButton">
<property name="text">
<string>Hot</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newSortButton">
<property name="text">
<string>New</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="topSortButton">
<property name="text">
<string>Top</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="GxsCommentTreeWidget" name="treeWidget">
<column>
<property name="text">
<string>Comment</string>
</property>
</column>
<column>
<property name="text">
<string>Author</string>
</property>
</column>
<column>
<property name="text">
<string>Date</string>
</property>
</column>
<column>
<property name="text">
<string>Points</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GxsCommentTreeWidget</class>
<extends>QTreeWidget</extends>
<header>gui/gxs/GxsCommentTreeWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -24,7 +24,7 @@
#include <QMenu>
#include "gui/gxs/GxsCommentTreeWidget.h"
#include "gui/Posted/PostedCreateCommentDialog.h"
#include "gui/gxs/GxsCreateCommentDialog.h"
#include <iostream>
@ -37,14 +37,12 @@
#define GXSCOMMENTS_LOADTHREAD 1
// Temporarily make this specific.
#include "retroshare/rsposted.h"
/* Images for context menu icons */
#define IMAGE_MESSAGE ":/images/folder-draft.png"
GxsCommentTreeWidget::GxsCommentTreeWidget(QWidget *parent)
:QTreeWidget(parent), mRsService(NULL), mTokenQueue(NULL)
:QTreeWidget(parent), mRsTokenService(NULL), mCommentService(NULL), mTokenQueue(NULL)
{
// QTreeWidget* widget = this;
@ -88,7 +86,7 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& point)
void GxsCommentTreeWidget::makeComment()
{
PostedCreateCommentDialog pcc(mTokenQueue, mThreadId, mThreadId.second, this);
GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, mThreadId, mThreadId.second, this);
pcc.exec();
}
@ -97,14 +95,15 @@ void GxsCommentTreeWidget::replyToComment()
RsGxsGrpMsgIdPair msgId;
msgId.first = mThreadId.first;
msgId.second = mCurrentMsgId;
PostedCreateCommentDialog pcc(mTokenQueue, msgId, mThreadId.second, this);
GxsCreateCommentDialog pcc(mTokenQueue, mCommentService, msgId, mThreadId.second, this);
pcc.exec();
}
void GxsCommentTreeWidget::setup(RsTokenService *service)
void GxsCommentTreeWidget::setup(RsTokenService *token_service, RsGxsCommentService *comment_service)
{
mRsService = service;
mTokenQueue = new TokenQueue(service, this);
mRsTokenService = token_service;
mCommentService = comment_service;
mTokenQueue = new TokenQueue(token_service, this);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customPopUpMenu(QPoint)));
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(setCurrentMsgId(QTreeWidgetItem*, QTreeWidgetItem*)));
@ -259,7 +258,7 @@ void GxsCommentTreeWidget::loadThread(const uint32_t &token)
void GxsCommentTreeWidget::acknowledgeComment(const uint32_t &token)
{
RsGxsGrpMsgIdPair msgId;
rsPosted->acknowledgeMsg(token, msgId);
mCommentService->acknowledgeComment(token, msgId);
// simply reload data
service_requestComments(mThreadId);
@ -271,15 +270,14 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
std::cerr << "GxsCommentTreeWidget::service_loadThread() ERROR must be overloaded!";
std::cerr << std::endl;
PostedRelatedCommentResult commentResult;
rsPosted->getRelatedComment(token, commentResult);
std::vector<RsGxsComment> comments;
mCommentService->getRelatedComments(token, comments);
std::vector<RsPostedComment>& commentV = commentResult[mThreadId];
std::vector<RsPostedComment>::iterator vit = commentV.begin();
std::vector<RsGxsComment>::iterator vit;
for(; vit != commentV.end(); vit++)
for(vit = comments.begin(); vit != comments.end(); vit++)
{
RsPostedComment& comment = *vit;
RsGxsComment &comment = *vit;
/* convert to a QTreeWidgetItem */
std::cerr << "GxsCommentTreeWidget::service_loadThread() Got Comment: " << comment.mMeta.mMsgId;
std::cerr << std::endl;

View File

@ -25,6 +25,7 @@
#include <QTreeWidget>
#include "util/TokenQueue.h"
#include <retroshare/rsgxscommon.h>
class GxsCommentTreeWidget : public QTreeWidget, public TokenResponse
{
@ -32,7 +33,7 @@ class GxsCommentTreeWidget : public QTreeWidget, public TokenResponse
public:
GxsCommentTreeWidget(QWidget *parent = 0);
void setup(RsTokenService *service);
void setup(RsTokenService *token_service, RsGxsCommentService *comment_service);
void requestComments(const RsGxsGrpMsgIdPair& threadId);
void getCurrentMsgId(RsGxsMessageId& parentId);
@ -73,7 +74,8 @@ protected:
std::multimap<std::string, QTreeWidgetItem *> mPendingInsertMap;
TokenQueue *mTokenQueue;
RsTokenService *mRsService;
RsTokenService *mRsTokenService;
RsGxsCommentService *mCommentService;
};

View File

@ -0,0 +1,32 @@
#include "GxsCreateCommentDialog.h"
#include "ui_GxsCreateCommentDialog.h"
GxsCreateCommentDialog::GxsCreateCommentDialog(TokenQueue *tokQ, RsGxsCommentService *service,
const RsGxsGrpMsgIdPair &parentId, const RsGxsMessageId& threadId, QWidget *parent) :
QDialog(parent),
ui(new Ui::GxsCreateCommentDialog), mTokenQueue(tokQ), mCommentService(service), mParentId(parentId), mThreadId(threadId)
{
ui->setupUi(this);
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(createComment()));
}
void GxsCreateCommentDialog::createComment()
{
RsGxsComment comment;
comment.mComment = ui->commentTextEdit->document()->toPlainText().toStdString();
comment.mMeta.mParentId = mParentId.second;
comment.mMeta.mGroupId = mParentId.first;
comment.mMeta.mThreadId = mThreadId;
uint32_t token;
mCommentService->createComment(token, comment);
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
close();
}
GxsCreateCommentDialog::~GxsCreateCommentDialog()
{
delete ui;
}

View File

@ -0,0 +1,34 @@
#ifndef _MRK_GXS_CREATE_COMMENT_DIALOG_H
#define _MRK_GXS_CREATE_COMMENT_DIALOG_H
#include <QDialog>
#include "retroshare/rsgxscommon.h"
#include "util/TokenQueue.h"
namespace Ui {
class GxsCreateCommentDialog;
}
class GxsCreateCommentDialog : public QDialog
{
Q_OBJECT
public:
explicit GxsCreateCommentDialog(TokenQueue* tokQ, RsGxsCommentService *service,
const RsGxsGrpMsgIdPair& parentId, const RsGxsMessageId& threadId, QWidget *parent = 0);
~GxsCreateCommentDialog();
private slots:
void createComment();
private:
Ui::GxsCreateCommentDialog *ui;
TokenQueue *mTokenQueue;
RsGxsCommentService *mCommentService;
RsGxsGrpMsgIdPair mParentId;
RsGxsMessageId mThreadId;
};
#endif // _MRK_GXS_CREATE_COMMENT_DIALOG_H

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GxsCreateCommentDialog</class>
<widget class="QDialog" name="GxsCreateCommentDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>372</width>
<height>145</height>
</rect>
</property>
<property name="windowTitle">
<string>Make Comment</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;Comment&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="commentTextEdit"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PostedCreateCommentDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>PostedCreateCommentDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,69 @@
/*
* Retroshare Channel Dialog
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef MRK_CHANNEL_DIALOG_H
#define MRK_CHANNEL_DIALOG_H
#include <retroshare/rsgxschannels.h>
#include "gui/gxs/GxsCommentContainer.h"
#include "gui/gxschannels/GxsChannelDialog.h"
class ChannelDialog : public GxsCommentContainer
{
//Q_OBJECT
public:
ChannelDialog(QWidget *parent = 0)
:GxsCommentContainer(parent) { return; }
virtual GxsServiceDialog *createServiceDialog()
{
return new GxsChannelDialog(this);
}
virtual QString getServiceName()
{
return tr("GxsChannels");
}
virtual RsTokenService *getTokenService()
{
return rsGxsChannels->getTokenService();
}
virtual RsGxsCommentService *getCommentService()
{
return rsGxsChannels;
}
virtual GxsCommentHeader *createHeaderWidget()
{
return NULL;
}
};
#endif

View File

@ -0,0 +1,656 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QDragEnterEvent>
#include <QUrl>
#include <QTimer>
#include <QMessageBox>
#include <QBuffer>
#include <QMenu>
#include <QDir>
#include <gui/RetroShareLink.h>
#include "CreateGxsChannelMsg.h"
#include "gui/feeds/SubFileItem.h"
#include "util/misc.h"
#include <retroshare/rsgxschannels.h>
#include <retroshare/rsfiles.h>
#include <iostream>
/** Constructor */
CreateGxsChannelMsg::CreateGxsChannelMsg(std::string cId)
: QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mChannelId(cId) ,mCheckAttachment(true), mAutoMediaThumbNail(false)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
headerFrame->setHeaderImage(QPixmap(":/images/channels.png"));
headerFrame->setHeaderText(tr("New GxsChannel Post"));
setAttribute ( Qt::WA_DeleteOnClose, true );
connect(buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancelMsg()));
connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail()));
connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool)));
connect(tabWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
thumbNailCb->setVisible(false);
thumbNailCb->setEnabled(false);
#ifdef CHANNELS_FRAME_CATCHER
fCatcher = new framecatcher();
thumbNailCb->setVisible(true);
thumbNailCb->setEnabled(true);
#endif
//buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
setAcceptDrops(true);
newChannelMsg();
}
void CreateGxsChannelMsg::contextMenu(QPoint /*point*/)
{
QList<RetroShareLink> links ;
RSLinkClipboard::pasteLinks(links) ;
int n_file = 0 ;
for(QList<RetroShareLink>::const_iterator it(links.begin());it!=links.end();++it)
if((*it).type() == RetroShareLink::TYPE_FILE)
n_file++ ;
QMenu contextMnu(this) ;
QAction *action ;
if(n_file > 1)
action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Links"), this, SLOT(pasteLink()));
else
action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
action->setDisabled(n_file < 1) ;
contextMnu.exec(QCursor::pos());
}
void CreateGxsChannelMsg::pasteLink()
{
std::cerr << "Pasting links: " << std::endl;
QList<RetroShareLink> links,not_have ;
RSLinkClipboard::pasteLinks(links) ;
for(QList<RetroShareLink>::const_iterator it(links.begin());it!=links.end();++it)
if((*it).type() == RetroShareLink::TYPE_FILE)
{
// 0 - check that we actually have the file!
//
std::cerr << "Pasting " << (*it).toString().toStdString() << std::endl;
FileInfo info ;
if(rsFiles->alreadyHaveFile( (*it).hash().toStdString(),info ) )
addAttachment((*it).hash().toStdString(), (*it).name().toUtf8().constData(), (*it).size(), true, "") ;
else
not_have.push_back( *it ) ;
}
if(!not_have.empty())
{
QString msg = tr("GxsChannel security policy prevents you from posting files that you don't have. If you have these files, you need to share them before, or attach them explicitly:")+"<br><br>" ;
for(QList<RetroShareLink>::const_iterator it(not_have.begin());it!=not_have.end();++it)
msg += (*it).toString() + "<br>" ;
QMessageBox::warning(NULL,tr("You can only post files that you do have"),msg) ;
}
}
CreateGxsChannelMsg::~CreateGxsChannelMsg(){
#ifdef CHANNELS_FRAME_CATCHER
delete fCatcher;
#endif
}
/* Dropping */
void CreateGxsChannelMsg::dragEnterEvent(QDragEnterEvent *event)
{
/* print out mimeType */
std::cerr << "CreateGxsChannelMsg::dragEnterEvent() Formats";
std::cerr << std::endl;
QStringList formats = event->mimeData()->formats();
QStringList::iterator it;
for(it = formats.begin(); it != formats.end(); it++)
{
std::cerr << "Format: " << (*it).toStdString();
std::cerr << std::endl;
}
if (event->mimeData()->hasFormat("text/plain"))
{
std::cerr << "CreateGxsChannelMsg::dragEnterEvent() Accepting PlainText";
std::cerr << std::endl;
event->acceptProposedAction();
}
else if (event->mimeData()->hasUrls())
{
std::cerr << "CreateGxsChannelMsg::dragEnterEvent() Accepting Urls";
std::cerr << std::endl;
event->acceptProposedAction();
}
else if (event->mimeData()->hasFormat("application/x-rsfilelist"))
{
std::cerr << "CreateGxsChannelMsg::dragEnterEvent() accepting Application/x-qabs...";
std::cerr << std::endl;
event->acceptProposedAction();
}
else
{
std::cerr << "CreateGxsChannelMsg::dragEnterEvent() No PlainText/Urls";
std::cerr << std::endl;
}
}
void CreateGxsChannelMsg::dropEvent(QDropEvent *event)
{
if (!(Qt::CopyAction & event->possibleActions()))
{
std::cerr << "CreateGxsChannelMsg::dropEvent() Rejecting uncopyable DropAction";
std::cerr << std::endl;
/* can't do it */
return;
}
std::cerr << "CreateGxsChannelMsg::dropEvent() Formats" << std::endl;
QStringList formats = event->mimeData()->formats();
QStringList::iterator it;
for(it = formats.begin(); it != formats.end(); it++)
{
std::cerr << "Format: " << (*it).toStdString();
std::cerr << std::endl;
}
if (event->mimeData()->hasText())
{
std::cerr << "CreateGxsChannelMsg::dropEvent() Plain Text:";
std::cerr << std::endl;
std::cerr << event->mimeData()->text().toStdString();
std::cerr << std::endl;
}
if (event->mimeData()->hasUrls())
{
std::cerr << "CreateGxsChannelMsg::dropEvent() Urls:" << std::endl;
QList<QUrl> urls = event->mimeData()->urls();
QList<QUrl>::iterator uit;
for(uit = urls.begin(); uit != urls.end(); uit++)
{
QString localpath = uit->toLocalFile();
std::cerr << "Whole URL: " << uit->toString().toStdString() << std::endl;
std::cerr << "or As Local File: " << localpath.toStdString() << std::endl;
if (localpath.isEmpty() == false)
{
// Check that the file does exist and is not a directory
QDir dir(localpath);
if (dir.exists()) {
std::cerr << "CreateGxsChannelMsg::dropEvent() directory not accepted."<< std::endl;
QMessageBox mb(tr("Drop file error."), tr("Directory can't be dropped, only files are accepted."),QMessageBox::Information,QMessageBox::Ok,0,0,this);
mb.exec();
} else if (QFile::exists(localpath)) {
addAttachment(localpath.toUtf8().constData());
} else {
std::cerr << "CreateGxsChannelMsg::dropEvent() file does not exists."<< std::endl;
QMessageBox mb(tr("Drop file error."), tr("File not found or file name not accepted."),QMessageBox::Information,QMessageBox::Ok,0,0,this);
mb.exec();
}
}
}
}
else if (event->mimeData()->hasFormat("application/x-rsfilelist"))
{
std::cerr << "CreateGxsChannelMsg::dropEvent() Application/x-rsfilelist";
std::cerr << std::endl;
QByteArray data = event->mimeData()->data("application/x-rsfilelist");
std::cerr << "Data Len:" << data.length();
std::cerr << std::endl;
std::cerr << "Data is:" << data.data();
std::cerr << std::endl;
std::string newattachments(data.data());
parseRsFileListAttachments(newattachments);
}
event->setDropAction(Qt::CopyAction);
event->accept();
}
void CreateGxsChannelMsg::parseRsFileListAttachments(const std::string &attachList)
{
/* split into lines */
QString input = QString::fromStdString(attachList);
QStringList attachItems = input.split("\n");
QStringList::iterator it;
QStringList::iterator it2;
for(it = attachItems.begin(); it != attachItems.end(); it++)
{
std::cerr << "CreateGxsChannelMsg::parseRsFileListAttachments() Entry: ";
QStringList parts = (*it).split("/");
bool ok = false;
quint64 qsize = 0;
std::string fname;
std::string hash;
uint64_t size = 0;
std::string source;
int i = 0;
for(it2 = parts.begin(); it2 != parts.end(); it2++, i++)
{
std::cerr << "\"" << it2->toStdString() << "\" ";
switch(i)
{
case 0:
fname = it2->toStdString();
break;
case 1:
hash = it2->toStdString();
break;
case 2:
qsize = it2->toULongLong(&ok, 10);
size = qsize;
break;
case 3:
source = it2->toStdString();
break;
}
}
std::cerr << std::endl;
std::cerr << "\tfname: " << fname << std::endl;
std::cerr << "\thash: " << hash << std::endl;
std::cerr << "\tsize: " << size << std::endl;
std::cerr << "\tsource: " << source << std::endl;
/* basic error checking */
if ((ok) && (hash.size() == 40))
{
std::cerr << "Item Ok" << std::endl;
if (source == "Local")
{
addAttachment(hash, fname, size, true, "");
}
else
{
// TEMP NOT ALLOWED UNTIL FT WORKING.
addAttachment(hash, fname, size, false, source);
}
}
else
{
std::cerr << "Error Decode: Hash size: " << hash.size() << std::endl;
}
}
}
void CreateGxsChannelMsg::addAttachment(const std::string &hash, const std::string &fname, uint64_t size, bool local, const std::string &srcId)
{
/* add a SubFileItem to the attachment section */
std::cerr << "CreateGxsChannelMsg::addAttachment()";
std::cerr << std::endl;
/* add widget in for new destination */
uint32_t flags = SFI_TYPE_CHANNEL;
if (local)
{
flags |= SFI_STATE_LOCAL;
}
else
{
flags |= SFI_STATE_REMOTE;
}
SubFileItem *file = new SubFileItem(hash, fname, "", size, flags, srcId); // destroyed when fileFrame (this subfileitem) is destroyed
mAttachments.push_back(file);
QLayout *layout = fileFrame->layout();
layout->addWidget(file);
if (mCheckAttachment)
{
checkAttachmentReady();
}
return;
}
void CreateGxsChannelMsg::addExtraFile()
{
/* add a SubFileItem to the attachment section */
std::cerr << "CreateGxsChannelMsg::addExtraFile() opening file dialog";
std::cerr << std::endl;
QStringList files;
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
for (QStringList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) {
addAttachment((*fileIt).toUtf8().constData());
}
}
}
void CreateGxsChannelMsg::addAttachment(const std::string &path)
{
/* add a SubFileItem to the attachment section */
std::cerr << "CreateGxsChannelMsg::addAttachment()";
std::cerr << std::endl;
if(mAutoMediaThumbNail)
setThumbNail(path, 2000);
/* add widget in for new destination */
uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA | SFI_FLAG_CREATE;
// check attachment if hash exists already
std::list<SubFileItem* >::iterator it;
for(it= mAttachments.begin(); it != mAttachments.end(); it++){
if((*it)->FilePath() == path){
QMessageBox::warning(this, tr("RetroShare"),
tr("File already Added and Hashed"),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
// channels creates copy of file into channels directory and shares this
FileInfo fInfo;
#if 0
rsGxsChannels->channelExtraFileHash(path, mChannelId, fInfo);
#endif
// file is not innitial
SubFileItem *file = new SubFileItem(fInfo.hash, fInfo.fname, fInfo.path, fInfo.size,
flags, mChannelId); // destroyed when fileFrame (this subfileitem) is destroyed
mAttachments.push_back(file);
QLayout *layout = fileFrame->layout();
layout->addWidget(file);
if (mCheckAttachment)
{
checkAttachmentReady();
}
return;
}
bool CreateGxsChannelMsg::setThumbNail(const std::string& path, int frame){
#ifdef CHANNELS_FRAME_CATCHER
unsigned char* imageBuffer = NULL;
int width = 0, height = 0, errCode = 0;
int length;
std::string errString;
if(1 != (errCode = fCatcher->open(path))){
fCatcher->getError(errCode, errString);
std::cerr << errString << std::endl;
return false;
}
length = fCatcher->getLength();
// make sure frame chosen is at lease a quarter length of video length if not choose quarter length
if(frame < (int) (0.25 * length))
frame = 0.25 * length;
if(1 != (errCode = fCatcher->getRGBImage(frame, imageBuffer, width, height))){
fCatcher->getError(errCode, errString);
std::cerr << errString << std::endl;
return false;
}
if(imageBuffer == NULL)
return false;
QImage tNail(imageBuffer, width, height, QImage::Format_RGB32);
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
tNail.save(&buffer, "PNG");
QPixmap img;
img.loadFromData(ba, "PNG");
img = img.scaled(thumbnail_label->width(), thumbnail_label->height(), Qt::KeepAspectRatio);
thumbnail_label->setPixmap(img);
delete[] imageBuffer;
#else
Q_UNUSED(path);
Q_UNUSED(frame);
#endif
return true;
}
void CreateGxsChannelMsg::allowAutoMediaThumbNail(bool allowThumbNail){
mAutoMediaThumbNail = allowThumbNail;
}
void CreateGxsChannelMsg::checkAttachmentReady()
{
std::list<SubFileItem *>::iterator fit;
mCheckAttachment = false;
for(fit = mAttachments.begin(); fit != mAttachments.end(); fit++)
{
if (!(*fit)->isHidden())
{
if (!(*fit)->ready())
{
/* ensure file is hashed or file will be hashed, thus
* recognized by librs but not correctly by gui (can't
* formally remove it)
*/
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
break;
}
}
}
if (fit == mAttachments.end())
{
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(true);
}
/* repeat... */
int msec_rate = 1000;
QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void)));
}
void CreateGxsChannelMsg::cancelMsg()
{
std::cerr << "CreateGxsChannelMsg::cancelMsg() :"
<< "Deleting EXTRA attachments" << std::endl;
std::cerr << std::endl;
std::list<SubFileItem* >::const_iterator it;
#if 0
for(it = mAttachments.begin(); it != mAttachments.end(); it++)
rsGxsChannels->channelExtraFileRemove((*it)->FileHash(), mChannelId);
#endif
close();
return;
}
void CreateGxsChannelMsg::newChannelMsg()
{
if (!rsGxsChannels)
return;
#if 0
GxsChannelInfo ci;
if (!rsGxsChannels->getGxsChannelInfo(mChannelId, ci))
{
return;
}
channelName->setText(QString::fromStdWString(ci.channelName));
#endif
subjectEdit->setFocus();
}
void CreateGxsChannelMsg::sendMsg()
{
std::cerr << "CreateGxsChannelMsg::sendMsg()";
std::cerr << std::endl;
/* construct message bits */
std::wstring subject = misc::removeNewLine(subjectEdit->text()).toStdWString();
std::wstring msg = msgEdit->toPlainText().toStdWString();
std::list<FileInfo> files;
std::list<SubFileItem *>::iterator fit;
for(fit = mAttachments.begin(); fit != mAttachments.end(); fit++)
{
if (!(*fit)->isHidden())
{
FileInfo fi;
fi.hash = (*fit)->FileHash();
fi.fname = (*fit)->FileName();
fi.size = (*fit)->FileSize();
files.push_back(fi);
/* commence downloads - if we don't have the file */
if (!(*fit)->done())
{
if ((*fit)->ready())
{
(*fit)->download();
}
// Skips unhashed files.
}
}
}
sendMessage(subject, msg, files);
}
void CreateGxsChannelMsg::sendMessage(std::wstring subject, std::wstring msg, std::list<FileInfo> &files)
{
QString name = misc::removeNewLine(subjectEdit->text());
if(name.isEmpty())
{ /* error message */
QMessageBox::warning(this, tr("RetroShare"),
tr("Please add a Subject"),
QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add an empty Subject!!
}
else
/* rsGxsChannels */
if (rsGxsChannels)
{
#if 0
GxsChannelMsgInfo msgInfo;
msgInfo.channelId = mChannelId;
msgInfo.msgId = "";
msgInfo.subject = subject;
msgInfo.msg = msg;
msgInfo.files = files;
QByteArray ba;
QBuffer buffer(&ba);
if(!picture.isNull()){
// send chan image
buffer.open(QIODevice::WriteOnly);
picture.save(&buffer, "PNG"); // writes image into ba in PNG format
msgInfo.thumbnail.image_thumbnail = (unsigned char*) ba.data();
msgInfo.thumbnail.im_thumbnail_size = ba.size();
}
rsGxsChannels->GxsChannelMessageSend(msgInfo);
#endif
}
close();
return;
}
void CreateGxsChannelMsg::addThumbnail()
{
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load thumbnail picture"), 156, 107);
if (img.isNull())
return;
picture = img;
// to show the selected
thumbnail_label->setPixmap(picture);
}

View File

@ -0,0 +1,91 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2013 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _CREATE_GXSCHANNEL_MSG_H
#define _CREATE_GXSCHANNEL_MSG_H
#include "ui_CreateGxsChannelMsg.h"
#include <stdint.h>
#ifdef CHANNELS_FRAME_CATCHER
#include "util/framecatcher.h"
#endif
class SubFileItem;
class FileInfo;
class CreateGxsChannelMsg : public QDialog, private Ui::CreateGxsChannelMsg
{
Q_OBJECT
public:
/** Default Constructor */
CreateGxsChannelMsg(std::string cId);
/** Default Destructor */
~CreateGxsChannelMsg();
void addAttachment(const std::string &path);
void addAttachment(const std::string &hash, const std::string &fname, uint64_t size, bool local, const std::string &srcId);
void newChannelMsg();
QPixmap picture;
protected:
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event);
private slots:
void addExtraFile();
void checkAttachmentReady();
void cancelMsg();
void sendMsg();
void pasteLink() ;
void contextMenu(QPoint) ;
void addThumbnail();
void allowAutoMediaThumbNail(bool);
private:
void parseRsFileListAttachments(const std::string &attachList);
void sendMessage(std::wstring subject, std::wstring msg, std::list<FileInfo> &files);
bool setThumbNail(const std::string& path, int frame);
std::string mChannelId;
std::list<SubFileItem *> mAttachments;
bool mCheckAttachment;
bool mAutoMediaThumbNail;
#ifdef CHANNELS_FRAME_CATCHER
framecatcher* fCatcher;
#endif
};
#endif

View File

@ -0,0 +1,365 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateGxsChannelMsg</class>
<widget class="QDialog" name="CreateGxsChannelMsg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>581</width>
<height>479</height>
</rect>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>New Channel Post</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="HeaderFrame" name="headerFrame"/>
</item>
<item row="1" column="0">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Channel Post</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Channel Post to:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="channelName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;&quot;&gt;Attachments:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/images/feedback_arrow.png&quot; /&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt; Use Drag and Drop / Add Files button, to Hash new files.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/images/feedback_arrow.png&quot; /&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt; Copy/Paste RetroShare links from your shares&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="addfilepushButton">
<property name="text">
<string>Add File to Attach</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="addThumbnailButton">
<property name="text">
<string>Add Channel Thumbnail</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QLabel" name="thumbnail_label">
<property name="maximumSize">
<size>
<width>156</width>
<height>107</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/thumb-default-video.png</pixmap>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>12</width>
<height>98</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Message</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Subject :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="subjectEdit"/>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QTextEdit" name="msgEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/attachment.png</normaloff>:/images/attachment.png</iconset>
</attribute>
<attribute name="title">
<string>Attachments</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/attachment.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Attachments</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>334</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="addFileButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>34</width>
<height>34</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="thumbNailCb">
<property name="toolTip">
<string>Allow channels to get frame for message thumbnail from movie media attachments or not</string>
</property>
<property name="text">
<string>Auto Thumbnail</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="5">
<widget class="QScrollArea" name="scrollArea">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>24</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<number>3</number>
</property>
<item>
<widget class="QFrame" name="fileFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Drag and Drop Files from Search Results</string>
</property>
<layout class="QGridLayout" name="gridLayout_3"/>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,182 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _GXS_CHANNEL_DIALOG_H
#define _GXS_CHANNEL_DIALOG_H
#include <retroshare/rschannels.h>
#include <retroshare/rsgxschannels.h>
#include <QStandardItemModel>
#include <QThread>
#include <map>
#include "mainpage.h"
#include "RsAutoUpdatePage.h"
#include "ui_GxsChannelDialog.h"
#include "gui/feeds/FeedHolder.h"
#include "gui/gxs/GxsCommentContainer.h"
#include "util/TokenQueue.h"
//class ChanMsgItem;
class GxsChannelPostItem;
class QTreeWidgetItem;
class GxsChannelFillThread;
class GxsChannelDialog : public RsAutoUpdatePage, public TokenResponse, public GxsServiceDialog,
public FeedHolder
{
Q_OBJECT
public:
/** Default Constructor */
GxsChannelDialog(QWidget *parent = 0);
/** Default Destructor */
~GxsChannelDialog();
virtual UserNotify *getUserNotify(QObject *parent);
/* FeedHolder */
virtual QScrollArea *getScrollArea();
virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(std::string peerId);
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId);
bool navigate(const std::string& channelId, const std::string& msgId);
/* overloaded from RsAuthUpdatePage */
virtual void updateDisplay();
/* NEW GXS FNS */
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private slots:
void channelListCustomPopupMenu( QPoint point );
void selectChannel(const QString &id);
void createChannel();
void subscribeChannel();
void unsubscribeChannel();
void setAllAsReadClicked();
void toggleAutoDownload();
void createMsg();
void showChannelDetails();
void restoreChannelKeys();
void editChannelDetail();
void shareKey();
void copyChannelLink();
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
//void generateMassData();
//void fillThreadFinished();
//void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
/* NEW GXS FNS */
void forceUpdateDisplay();
private:
//void updateChannelList();
//void updateChannelMsgs();
void updateMessageSummaryList(const std::string &channelId);
void processSettings(bool load);
void setAutoDownloadButton(bool autoDl);
/* NEW GXS FNS */
void insertChannels();
void requestGroupSummary();
void loadGroupSummary(const uint32_t &token);
void requestGroupData(const RsGxsGroupId &grpId);
void loadGroupData(const uint32_t &token);
void requestPosts(const RsGxsGroupId &grpId);
void loadPosts(const uint32_t &token);
void insertChannelData(const std::list<RsGroupMetaData> &channelList);
void insertChannelDetails(const RsGxsChannelGroup &group);
void insertChannelPosts(const std::vector<RsGxsChannelPost> &posts);
std::string mChannelId; /* current Channel */
TokenQueue *mChannelQueue;
/* Layout Pointers */
QBoxLayout *mMsgLayout;
//QList<ChanMsgItem *> mChanMsgItems;
QList<GxsChannelPostItem *> mChannelPostItems;
std::map<std::string, uint32_t> mChanSearchScore; //chanId, score
QTreeWidgetItem *ownChannels;
QTreeWidgetItem *subcribedChannels;
QTreeWidgetItem *popularChannels;
QTreeWidgetItem *otherChannels;
GxsChannelFillThread *fillThread;
/* UI - from Designer */
Ui::GxsChannelDialog ui;
};
class GxsChannelFillThread : public QThread
{
Q_OBJECT
public:
GxsChannelFillThread(GxsChannelDialog *parent, const std::string &channelId);
~GxsChannelFillThread();
void run();
void stop();
bool wasStopped() { return stopped; }
signals:
void addMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
public:
std::string channelId;
private:
volatile bool stopped;
};
#endif

View File

@ -0,0 +1,366 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GxsChannelDialog</class>
<widget class="QWidget" name="GxsChannelDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>476</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QFrame" name="channelTreeFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<property name="verticalSpacing">
<number>1</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="titleBarFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="titleBarPixmap">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/channels32.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titleBarLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Channels</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="refreshButton">
<property name="text">
<string>refresh</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="displayButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Display</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/looknfeel.png</normaloff>:/images/looknfeel.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="newChannelButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Create Channel</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/add_channel24.png</normaloff>:/images/add_channel24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="GroupTreeWidget" name="treeWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="channelLayout">
<item row="0" column="0">
<widget class="QFrame" name="headFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="margin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/channels.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nameLabel">
<property name="palette">
<palette>
<active/>
<inactive/>
<disabled/>
</palette>
</property>
<property name="font">
<font>
<pointsize>21</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Channel Name</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="progressLayout">
<item>
<widget class="QLabel" name="progressLabel">
<property name="text">
<string>Loading</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QFrame" name="toolBarFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QToolButton" name="postButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Post to Channel</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/mail_send.png</normaloff>:/images/mail_send.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>314</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
<action name="actionsetAllAsRead">
<property name="text">
<string>Set all as read</string>
</property>
<property name="toolTip">
<string>Set all as read</string>
</property>
</action>
<action name="actionEnable_Auto_Download">
<property name="text">
<string>Enable Auto-Download</string>
</property>
<property name="toolTip">
<string>Enable Auto-Download</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>GroupTreeWidget</class>
<extends>QWidget</extends>
<header>gui/common/GroupTreeWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,95 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2013 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "GxsChannelGroupDialog.h"
#include <retroshare/rsgxschannels.h>
#include <iostream>
// To start with we only have open forums - with distribution controls.
const uint32_t ChannelCreateEnabledFlags = ( GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN |
GXS_GROUP_FLAGS_SHAREKEYS |
// GXS_GROUP_FLAGS_PERSONALSIGN |
GXS_GROUP_FLAGS_COMMENTS |
0);
const uint32_t ChannelCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP |
//GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
//GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
//GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
//GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED |
//GXS_GROUP_DEFAULTS_PERSONAL_GPG |
GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
//GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
GXS_GROUP_DEFAULTS_COMMENTS_YES |
//GXS_GROUP_DEFAULTS_COMMENTS_NO |
0);
GxsChannelGroupDialog::GxsChannelGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
:GxsGroupDialog(tokenQueue, ChannelCreateEnabledFlags, ChannelCreateDefaultsFlags, parent)
{
}
GxsChannelGroupDialog::GxsChannelGroupDialog(const RsGxsChannelGroup &group, Mode mode, QWidget *parent)
:GxsGroupDialog(group.mMeta, mode, parent)
{
}
void GxsChannelGroupDialog::initUi()
{
switch (mode())
{
case MODE_CREATE:
setUiText(UITYPE_SERVICE_HEADER, tr("Create New Channel"));
break;
case MODE_SHOW:
setUiText(UITYPE_SERVICE_HEADER, tr("Channel"));
break;
case MODE_EDIT:
setUiText(UITYPE_SERVICE_HEADER, tr("Edit Channel"));
break;
}
}
QPixmap GxsChannelGroupDialog::serviceImage()
{
return QPixmap(":/images/konversation64.png");
}
bool GxsChannelGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
{
// Specific Function.
RsGxsChannelGroup grp;
grp.mMeta = meta;
//grp.mDescription = std::string(desc.toUtf8());
rsGxsChannels->createGroup(token, grp);
return true;
}

View File

@ -0,0 +1,42 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2013 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _GXSCHANNEL_GROUP_DIALOG_H
#define _GXSCHANNEL_GROUP_DIALOG_H
#include "gui/gxs/GxsGroupDialog.h"
#include <retroshare/rsgxschannels.h>
class GxsChannelGroupDialog : public GxsGroupDialog
{
Q_OBJECT
public:
GxsChannelGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
GxsChannelGroupDialog(const RsGxsChannelGroup &group, Mode mode, QWidget *parent);
protected:
virtual void initUi();
virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
};
#endif

View File

@ -1808,19 +1808,6 @@ void GxsForumThreadWidget::loadMsgData_InsertPost(const uint32_t &token)
void GxsForumThreadWidget::requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId)
{
#if 0
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
std::cerr << "GxsForumsDialog::requestMsgData_ReplyMessage(" << msgId.first << "," << msgId.second << ")";
std::cerr << std::endl;
std::vector<RsGxsGrpMsgIdPair> msgIds;
msgIds.push_back(msgId);
uint32_t token;
mThreadQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_REPLY_MESSAGE);
#else
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
@ -1833,7 +1820,7 @@ void GxsForumThreadWidget::requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &
uint32_t token;
mThreadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_REPLY_MESSAGE);
#endif
}
void GxsForumThreadWidget::loadMsgData_ReplyMessage(const uint32_t &token)
@ -1842,11 +1829,7 @@ void GxsForumThreadWidget::loadMsgData_ReplyMessage(const uint32_t &token)
std::cerr << std::endl;
std::vector<RsGxsForumMsg> msgs;
#if 0
if (rsGxsForums->getRelatedMessages(token, msgs))
#else
if (rsGxsForums->getMsgData(token, msgs))
#endif
{
if (msgs.size() != 1)
{

View File

@ -32,6 +32,7 @@
#include "gui/WikiPoos/WikiDialog.h"
#include "gui/Posted/PostedDialog.h"
#include "gui/GxsForumsDialog.h"
#include "gui/gxschannels/ChannelDialog.h"
// THESE HAVE TO BE CONVERTED TO VEG FORMAT
#if USE_VEG_SERVICE
@ -57,7 +58,7 @@
#define IMAGE_GXSFORUMS ":/images/konversation.png"
#define IMAGE_WIKI ":/images/wikibook_32.png"
#define IMAGE_POSTED ":/images/posted_32.png"
#define IMAGE_GXSCHANNELS ":/images/channels.png"
/** Constructor */
ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
@ -103,6 +104,7 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
PostedDialog *postedDialog = NULL;
ui.stackPages->add(postedDialog = new PostedDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_POSTED), tr("Posted Links"), grp));
postedDialog->setup();
WikiDialog *wikiDialog = NULL;
ui.stackPages->add(wikiDialog = new WikiDialog(ui.stackPages),
@ -112,6 +114,11 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
ui.stackPages->add(gxsforumsDialog = new GxsForumsDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_GXSFORUMS), tr("GxsForums"), grp));
ChannelDialog *gxschannelDialog = NULL;
ui.stackPages->add(gxschannelDialog = new ChannelDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_GXSCHANNELS), tr("GxsChannels"), grp));
gxschannelDialog->setup();
// THESE HAVE TO BE CONVERTED TO VEG FORMAT
#if USE_VEG_SERVICE
WireDialog *wireDialog = NULL;

View File

@ -2,7 +2,7 @@ CONFIG += qt gui uic qrc resources uitools idle bitdht
# Below is for GXS services.
# Should be disabled for releases.
#CONFIG += gxs
#CONFIG += gxs debug
gxs {
CONFIG += photoshare
@ -10,6 +10,7 @@ gxs {
CONFIG += identities
CONFIG += circles
CONFIG += gxsforums
CONFIG += gxschannels
CONFIG += posted
CONFIG += unfinished
CONFIG += gxsgui
@ -1047,31 +1048,53 @@ gxsforums {
}
gxschannels {
HEADERS += gui/gxschannels/GxsChannelDialog.h \
gui/gxschannels/GxsChannelGroupDialog.h \
gui/gxschannels/CreateGxsChannelMsg.h \
gui/gxschannels/ChannelDialog.h \
gui/feeds/GxsChannelPostItem.h \
FORMS += gui/gxschannels/GxsChannelDialog.ui \
gui/gxschannels/CreateGxsChannelMsg.ui \
gui/feeds/GxsChannelPostItem.ui \
SOURCES += gui/gxschannels/GxsChannelDialog.cpp \
gui/gxschannels/GxsChannelGroupDialog.cpp \
gui/gxschannels/CreateGxsChannelMsg.cpp \
gui/feeds/GxsChannelPostItem.cpp \
}
posted {
HEADERS += gui/Posted/PostedDialog.h \
gui/Posted/PostedListDialog.h \
gui/Posted/PostedItem.h \
gui/Posted/PostedComments.h \
gui/Posted/PostedGroupDialog.h \
gui/Posted/PostedCreatePostDialog.h \
gui/Posted/PostedCreateCommentDialog.h \
gui/Posted/PostedUserTypes.h
#gui/Posted/PostedCreateCommentDialog.h \
#gui/Posted/PostedComments.h \
FORMS += gui/Posted/PostedDialog.ui \
gui/Posted/PostedListDialog.ui \
FORMS += gui/Posted/PostedListDialog.ui \
gui/Posted/PostedItem.ui \
gui/Posted/PostedComments.ui \
gui/Posted/PostedCreatePostDialog.ui \
gui/Posted/PostedCreateCommentDialog.ui
#gui/Posted/PostedDialog.ui \
#gui/Posted/PostedComments.ui \
#gui/Posted/PostedCreateCommentDialog.ui
SOURCES += gui/Posted/PostedDialog.cpp \
gui/Posted/PostedListDialog.cpp \
SOURCES += gui/Posted/PostedListDialog.cpp \
gui/Posted/PostedItem.cpp \
gui/Posted/PostedComments.cpp \
gui/Posted/PostedGroupDialog.cpp \
gui/Posted/PostedCreatePostDialog.cpp \
gui/Posted/PostedCreateCommentDialog.cpp
#gui/Posted/PostedDialog.cpp \
#gui/Posted/PostedComments.cpp \
#gui/Posted/PostedCreateCommentDialog.cpp
RESOURCES += gui/Posted/Posted_images.qrc
}
@ -1079,30 +1102,39 @@ posted {
gxsgui {
HEADERS += gui/gxs/GxsGroupDialog.h \
gui/gxs/GxsCommentTreeWidget.h \
gui/gxs/WikiGroupDialog.h \
gui/gxs/GxsIdChooser.h \
gui/gxs/GxsIdLabel.h \
gui/gxs/GxsCircleChooser.h \
gui/gxs/GxsCircleLabel.h \
gui/gxs/GxsIdTreeWidgetItem.h \
gui/gxs/GxsCommentTreeWidget.h \
gui/gxs/GxsCommentContainer.h \
gui/gxs/GxsCommentDialog.h \
gui/gxs/GxsCreateCommentDialog.h \
util/TokenQueue.h \
# gui/gxs/GxsMsgDialog.h \
FORMS += gui/gxs/GxsGroupDialog.ui \
gui/gxs/GxsCommentContainer.ui \
gui/gxs/GxsCommentDialog.ui \
gui/gxs/GxsCreateCommentDialog.ui \
# gui/gxs/GxsMsgDialog.ui \
# gui/gxs/GxsCommentTreeWidget.ui \
SOURCES += gui/gxs/GxsGroupDialog.cpp \
gui/gxs/GxsCommentTreeWidget.cpp \
gui/gxs/WikiGroupDialog.cpp \
gui/gxs/GxsIdChooser.cpp \
gui/gxs/GxsIdLabel.cpp \
gui/gxs/GxsCircleChooser.cpp \
gui/gxs/GxsCircleLabel.cpp \
gui/gxs/GxsIdTreeWidgetItem.cpp \
gui/gxs/GxsCommentTreeWidget.cpp \
gui/gxs/GxsCommentContainer.cpp \
gui/gxs/GxsCommentDialog.cpp \
gui/gxs/GxsCreateCommentDialog.cpp \
util/TokenQueue.cpp \
# gui/gxs/GxsMsgDialog.cpp \