- Added comment tabs to GxsGroupFrameDialog

- Switched channels from GxsCommentContainer to new tabbed GxsGroupFrameDialog

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7350 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-05-08 00:00:21 +00:00
parent dacc60d28f
commit 2da8acd967
14 changed files with 134 additions and 145 deletions

View File

@ -91,7 +91,7 @@
#include <retroshare/rsfiles.h>
#include <retroshare/rsnotify.h>
#include "gui/gxschannels/ChannelDialog.h"
#include "gui/gxschannels/GxsChannelDialog.h"
#include "gui/gxsforums/GxsForumsDialog.h"
#include "gui/Identity/IdDialog.h"
#include "gui/Circles/CirclesDialog.h"
@ -272,9 +272,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
action = createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
notify.push_back(QPair<MainPage*, QAction*>(messagesDialog, action));
ui->stackPages->add(gxschannelDialog = new ChannelDialog(ui->stackPages),
ui->stackPages->add(gxschannelDialog = new GxsChannelDialog(ui->stackPages),
action = createPageAction(QIcon(IMAGE_GXSCHANNELS), tr("Channels"), grp));
gxschannelDialog->setup();
notify.push_back(QPair<MainPage*, QAction*>(gxschannelDialog, action));
ui->stackPages->add(gxsforumDialog = new GxsForumsDialog(ui->stackPages),
@ -436,6 +435,8 @@ MainWindow::~MainWindow()
#ifdef UNFINISHED
delete applicationWindow;
#endif
delete(ui);
}
void MainWindow::displayDiskSpaceWarning(int loc,int size_limit_mb)

View File

@ -36,8 +36,8 @@ class QLabel;
class QActionGroup;
class Idle;
class PeerStatus;
class ChannelDialog ;
class GxsForumsDialog ;
class GxsChannelDialog ;
class GxsForumsDialog ;
class NATStatus;
class RatesStatus;
class DiscStatus;
@ -131,7 +131,7 @@ public:
ChatLobbyWidget *chatLobbyDialog;
MessagesDialog *messagesDialog;
SharedFilesDialog *sharedfilesDialog;
ChannelDialog *gxschannelDialog ;
GxsChannelDialog *gxschannelDialog ;
GxsForumsDialog *gxsforumDialog ;
// ForumsDialog *forumsDialog;

View File

@ -22,10 +22,7 @@
*/
#include "gui/gxs/GxsCommentDialog.h"
//#include "gxs/GxsCreateComment.h"
//#include <retroshare/rsposted.h>
#include "ui_GxsCommentDialog.h"
#include <iostream>
#include <sstream>
@ -34,27 +31,32 @@
#include <QMessageBox>
#include <QDateTime>
/** Constructor */
GxsCommentDialog::GxsCommentDialog(QWidget *parent, RsTokenService *token_service, RsGxsCommentService *comment_service)
:QWidget(parent)
: QWidget(parent), ui(new Ui::GxsCommentDialog)
{
ui.setupUi(this);
//ui.postFrame->setVisible(false);
/* Invoke the Qt Designer generated QObject setup routine */
ui->setupUi(this);
ui.treeWidget->setup(token_service, comment_service);
//ui->postFrame->setVisible(false);
ui->treeWidget->setup(token_service, comment_service);
/* fill in the available OwnIds for signing */
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
connect(ui.refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
connect(ui.idChooser, SIGNAL(currentIndexChanged( int )), this, SLOT(voterSelectionChanged( int )));
connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
connect(ui->idChooser, SIGNAL(currentIndexChanged( int )), this, SLOT(voterSelectionChanged( int )));
/* force voterId through - first time */
voterSelectionChanged( 0 );
}
GxsCommentDialog::~GxsCommentDialog()
{
delete(ui);
}
void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
{
std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", " << msgId << ")";
@ -68,10 +70,9 @@ void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const RsGxsMessage
threadId.first = grpId;
threadId.second = msgId;
ui.treeWidget->requestComments(threadId);
ui->treeWidget->requestComments(threadId);
}
void GxsCommentDialog::refresh()
{
std::cerr << "GxsCommentDialog::refresh()";
@ -80,18 +81,17 @@ void GxsCommentDialog::refresh()
commentLoad(mGrpId, mMsgId);
}
void GxsCommentDialog::voterSelectionChanged( int index )
{
std::cerr << "GxsCommentDialog::voterSelectionChanged(" << index << ")";
std::cerr << std::endl;
RsGxsId voterId;
if (ui.idChooser->getChosenId(voterId))
if (ui->idChooser->getChosenId(voterId))
{
std::cerr << "GxsCommentDialog::voterSelectionChanged() => " << voterId;
std::cerr << std::endl;
ui.treeWidget->setVoteId(voterId);
ui->treeWidget->setVoteId(voterId);
}
else
{
@ -100,8 +100,6 @@ void GxsCommentDialog::voterSelectionChanged( int index )
}
}
void GxsCommentDialog::setCommentHeader(QWidget *header)
{
if (!header)
@ -114,31 +112,29 @@ void GxsCommentDialog::setCommentHeader(QWidget *header)
std::cerr << "GxsCommentDialog::setCommentHeader() Adding header to ui,postFrame";
std::cerr << std::endl;
//header->setParent(ui.postFrame);
//ui.postFrame->setVisible(true);
//header->setParent(ui->postFrame);
//ui->postFrame->setVisible(true);
QLayout *alayout = ui.postFrame->layout();
QLayout *alayout = ui->postFrame->layout();
alayout->addWidget(header);
#if 0
ui.postFrame->setVisible(true);
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) +
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) +
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->scoreLabel->setText(QString("0"));
ui.notesBrowser->setPlainText(QString::fromStdString(mCurrentPost.mNotes));
ui->notesBrowser->setPlainText(QString::fromStdString(mCurrentPost.mNotes));
#endif
}

View File

@ -24,31 +24,36 @@
#ifndef MRK_GXS_COMMENT_DIALOG_H
#define MRK_GXS_COMMENT_DIALOG_H
#include "ui_GxsCommentDialog.h"
#include "gui/gxs/GxsCommentContainer.h"
namespace Ui {
class GxsCommentDialog;
}
class GxsCommentDialog: public QWidget
{
Q_OBJECT
Q_OBJECT
public:
GxsCommentDialog(QWidget *parent, RsTokenService *token_service, RsGxsCommentService *comment_service);
virtual ~GxsCommentDialog();
void setCommentHeader(QWidget *header);
void commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
void setCommentHeader(QWidget *header);
void commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
RsGxsGroupId groupId() { return mGrpId; }
RsGxsMessageId messageId() { return mMsgId; }
private slots:
void refresh();
void voterSelectionChanged( int index );
private:
RsGxsGroupId mGrpId;
RsGxsMessageId mMsgId;
RsGxsGroupId mGrpId;
RsGxsMessageId mMsgId;
/* UI - from Designer */
Ui::GxsCommentDialog ui;
Ui::GxsCommentDialog *ui;
};
#endif

View File

@ -33,6 +33,7 @@
#include "gui/common/RSTreeWidget.h"
#include "gui/notifyqt.h"
#include "gui/common/UIStateHelper.h"
#include "GxsCommentDialog.h"
//#define DEBUG_GROUPFRAMEDIALOG
@ -43,13 +44,16 @@
//#define IMAGE_GROUPAUTHD ":/images/konv_message2.png"
#define IMAGE_COPYLINK ":/images/copyrslink.png"
#define IMAGE_EDIT ":/images/edit_16.png"
#define IMAGE_SHARE ":/images/share-icon-16.png"
#define IMAGE_TABNEW ":/images/tab-new.png"
#define IMAGE_SHARE ":/images/share-icon-16.png"
#define IMAGE_TABNEW ":/images/tab-new.png"
#define IMAGE_COMMENT ""
#define TOKEN_TYPE_GROUP_SUMMARY 1
#define TOKEN_TYPE_SUBSCRIBE_CHANGE 2
//#define TOKEN_TYPE_CURRENTGROUP 3
#define MAX_COMMENT_TITLE 32
/*
* Transformation Notes:
* there are still a couple of things that the new groups differ from Old version.
@ -388,6 +392,39 @@ void GxsGroupFrameDialog::shareKey()
shareUi.exec();
}
void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title)
{
RsGxsCommentService *commentService = getCommentService();
if (!commentService) {
/* No comment service available */
return;
}
GxsCommentDialog *commentDialog = commentWidget(msgId);
if (!commentDialog) {
QString comments = title;
if (title.length() > MAX_COMMENT_TITLE)
{
comments.truncate(MAX_COMMENT_TITLE - 3);
comments += "...";
}
commentDialog = new GxsCommentDialog(this, mInterface->getTokenService(), commentService);
QWidget *commentHeader = createCommentHeaderWidget(grpId, msgId);
if (commentHeader) {
commentDialog->setCommentHeader(commentHeader);
}
commentDialog->commentLoad(grpId, msgId);
int index = ui->messageTabWidget->addTab(commentDialog, comments);
ui->messageTabWidget->setTabIcon(index, QIcon(IMAGE_COMMENT));
}
ui->messageTabWidget->setCurrentWidget(commentDialog);
}
bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const std::string& msgId)
{
if (groupId.isNull()) {
@ -453,11 +490,26 @@ GxsMessageFrameWidget *GxsGroupFrameDialog::createMessageWidget(const RsGxsGroup
int index = ui->messageTabWidget->addTab(msgWidget, msgWidget->groupName(true));
ui->messageTabWidget->setTabIcon(index, msgWidget->groupIcon());
connect(msgWidget, SIGNAL(groupChanged(QWidget*)), this, SLOT(messageTabInfoChanged(QWidget*)));
connect(msgWidget, SIGNAL(loadComment(RsGxsGroupId,RsGxsMessageId,QString)), this, SLOT(loadComment(RsGxsGroupId,RsGxsMessageId,QString)));
return msgWidget;
}
GxsCommentDialog *GxsGroupFrameDialog::commentWidget(const RsGxsMessageId &msgId)
{
int tabCount = ui->messageTabWidget->count();
for (int index = 0; index < tabCount; ++index) {
GxsCommentDialog *childWidget = dynamic_cast<GxsCommentDialog*>(ui->messageTabWidget->widget(index));
if (childWidget && childWidget->messageId() == msgId) {
return childWidget;
}
}
return NULL;
}
void GxsGroupFrameDialog::changedGroup(const QString &groupId)
{
mGroupId = RsGxsGroupId(groupId.toStdString());
@ -510,16 +562,18 @@ void GxsGroupFrameDialog::openGroupInNewTab(const RsGxsGroupId &groupId)
void GxsGroupFrameDialog::messageTabCloseRequested(int index)
{
GxsMessageFrameWidget *msgWidget = dynamic_cast<GxsMessageFrameWidget*>(ui->messageTabWidget->widget(index));
if (!msgWidget) {
QWidget *widget = ui->messageTabWidget->widget(index);
if (!widget) {
return;
}
if (msgWidget == mMessageWidget) {
GxsMessageFrameWidget *msgWidget = dynamic_cast<GxsMessageFrameWidget*>(widget);
if (msgWidget && msgWidget == mMessageWidget) {
/* Don't close single tab */
return;
}
delete(msgWidget);
delete(widget);
}
void GxsGroupFrameDialog::messageTabChanged(int index)

View File

@ -39,6 +39,8 @@ class GroupTreeWidget;
class GroupItemInfo;
class GxsMessageFrameWidget;
class UIStateHelper;
class RsGxsCommentService;
class GxsCommentDialog;
class GxsGroupFrameDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
{
@ -111,6 +113,8 @@ private slots:
void shareKey();
void loadComment(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title);
private:
virtual QString text(TextType type) = 0;
virtual QString icon(IconType type) = 0;
@ -120,6 +124,8 @@ private:
virtual int shareKeyType() = 0;
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId) = 0;
virtual void groupTreeCustomActions(RsGxsGroupId /*grpId*/, int /*subscribeFlags*/, QList<QAction*> &/*actions*/) {}
virtual RsGxsCommentService *getCommentService() { return NULL; }
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &/*grpId*/, const RsGxsMessageId &/*msgId*/) { return NULL; }
void initUi();
@ -143,6 +149,8 @@ private:
GxsMessageFrameWidget *messageWidget(const RsGxsGroupId &groupId, bool ownTab);
GxsMessageFrameWidget *createMessageWidget(const RsGxsGroupId &groupId);
GxsCommentDialog *commentWidget(const RsGxsMessageId &msgId);
// void requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId);
// void loadGroupSummary_CurrentGroup(const uint32_t &token);

View File

@ -41,6 +41,7 @@ public:
signals:
void groupChanged(QWidget *widget);
void loadComment(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
};
#endif // GXSMESSAGEFRAMEWIDGET_H

View File

@ -1,72 +0,0 @@
/*
* 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"
#include "gui/feeds/GxsChannelPostItem.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 QWidget *createHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
{
return new GxsChannelPostItem(NULL, 0, grpId, msgId, true, true);
}
virtual QPixmap getServicePixmap()
{
return QPixmap(":/images/channels24.png");
}
};
#endif

View File

@ -23,6 +23,7 @@
#include "GxsChannelGroupDialog.h"
#include "GxsChannelPostsWidget.h"
#include "gui/channels/ShareKey.h"
#include "gui/feeds/GxsChannelPostItem.h"
/****
* #define DEBUG_CHANNEL
@ -30,7 +31,7 @@
/** Constructor */
GxsChannelDialog::GxsChannelDialog(QWidget *parent)
: GxsGroupFrameDialog(rsGxsChannels, parent), GxsServiceDialog(dynamic_cast<GxsCommentContainer *>(parent))
: GxsGroupFrameDialog(rsGxsChannels, parent)
{
//#TODO: add settings like forums
setSingleTab(true);
@ -115,17 +116,7 @@ int GxsChannelDialog::shareKeyType()
GxsMessageFrameWidget *GxsChannelDialog::createMessageFrameWidget(const RsGxsGroupId &groupId)
{
GxsChannelPostsWidget *widget = new GxsChannelPostsWidget(groupId);
//#TODO: find better solution
connect(widget, SIGNAL(commentLoad(RsGxsGroupId,RsGxsMessageId,QString)), this, SLOT(loadComment(RsGxsGroupId,RsGxsMessageId,QString)));
return widget;
}
void GxsChannelDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title)
{
commentLoad(grpId, msgId, title);
return new GxsChannelPostsWidget(groupId);
}
void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList<QAction*> &actions)
@ -143,6 +134,16 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF
}
}
RsGxsCommentService *GxsChannelDialog::getCommentService()
{
return rsGxsChannels;
}
QWidget *GxsChannelDialog::createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
{
return new GxsChannelPostItem(NULL, 0, grpId, msgId, true, true);
}
void GxsChannelDialog::toggleAutoDownload()
{
RsGxsGroupId grpId = groupId();

View File

@ -23,9 +23,8 @@
#define _GXS_CHANNEL_DIALOG_H
#include "gui/gxs/GxsGroupFrameDialog.h"
#include "gui/gxs/GxsCommentContainer.h"
class GxsChannelDialog : public GxsGroupFrameDialog, public GxsServiceDialog
class GxsChannelDialog : public GxsGroupFrameDialog
{
Q_OBJECT
@ -39,7 +38,6 @@ public:
private slots:
void toggleAutoDownload();
void loadComment(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title);
private:
/* GxsGroupFrameDialog */
@ -51,6 +49,8 @@ private:
virtual int shareKeyType();
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
virtual void groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList<QAction*> &actions);
virtual RsGxsCommentService *getCommentService();
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
};
#endif

View File

@ -192,7 +192,7 @@ void GxsChannelPostsWidget::openChat(const RsPeerId & /*peerId*/)
// Callback from Widget->FeedHolder->ServiceDialog->CommentContainer->CommentDialog,
void GxsChannelPostsWidget::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title)
{
emit commentLoad(groupId, msgId, title);
emit loadComment(groupId, msgId, title);
}
void GxsChannelPostsWidget::createMsg()

View File

@ -66,9 +66,6 @@ public:
/* NEW GXS FNS */
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
signals:
void commentLoad(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
protected:
virtual void updateDisplay(bool complete);

View File

@ -36,7 +36,6 @@
#include "gui/WikiPoos/WikiDialog.h"
#include "gui/Posted/PostedDialog.h"
#include "gui/gxsforums/GxsForumsDialog.h"
#include "gui/gxschannels/ChannelDialog.h"
// THESE HAVE TO BE CONVERTED TO VEG FORMAT
#if USE_VEG_SERVICE

View File

@ -1139,7 +1139,6 @@ gxschannels {
HEADERS += gui/gxschannels/GxsChannelDialog.h \
gui/gxschannels/GxsChannelGroupDialog.h \
gui/gxschannels/CreateGxsChannelMsg.h \
gui/gxschannels/ChannelDialog.h \
gui/gxschannels/GxsChannelPostsWidget.h \
gui/feeds/GxsChannelPostItem.h