mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added new base class for group and tabbed message dialogs (forums, channels)
- GxsGroupFrameDialog, GxsMessageFrameWidget git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7329 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4c8eaeb421
commit
50bb541c4e
818
retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp
Normal file
818
retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp
Normal file
@ -0,0 +1,818 @@
|
||||
/****************************************************************
|
||||
* 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 <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QToolButton>
|
||||
|
||||
#include "GxsGroupFrameDialog.h"
|
||||
#include "ui_GxsGroupFrameDialog.h"
|
||||
#include "GxsMessageFrameWidget.h"
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/channels/ShareKey.h"
|
||||
#include "gui/common/RSTreeWidget.h"
|
||||
#include "gui/notifyqt.h"
|
||||
//#include "gui/common/UIStateHelper.h"
|
||||
|
||||
//#define DEBUG_GROUPFRAMEDIALOG
|
||||
|
||||
/* Images for TreeWidget */
|
||||
#define IMAGE_SUBSCRIBE ":/images/edit_add24.png"
|
||||
#define IMAGE_UNSUBSCRIBE ":/images/cancel.png"
|
||||
#define IMAGE_INFO ":/images/info16.png"
|
||||
//#define IMAGE_GROUPAUTHD ":/images/konv_message2.png"
|
||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||
|
||||
#define TOKEN_TYPE_LISTING 1
|
||||
#define TOKEN_TYPE_SUBSCRIBE_CHANGE 2
|
||||
//#define TOKEN_TYPE_CURRENTGROUP 3
|
||||
|
||||
/*
|
||||
* Transformation Notes:
|
||||
* there are still a couple of things that the new groups differ from Old version.
|
||||
* these will need to be addressed in the future.
|
||||
* -> Child TS (for sorting) is not handled by GXS, this will probably have to be done in the GUI.
|
||||
* -> Need to handle IDs properly.
|
||||
* -> Popularity not handled in GXS yet.
|
||||
* -> Much more to do.
|
||||
*/
|
||||
|
||||
/** Constructor */
|
||||
GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent)
|
||||
: RsGxsUpdateBroadcastPage(ifaceImpl, parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui = new Ui::GxsGroupFrameDialog();
|
||||
ui->setupUi(this);
|
||||
|
||||
mInitialized = false;
|
||||
mYourGroups = NULL;
|
||||
mSubscribedGroups = NULL;
|
||||
mPopularGroups = NULL;
|
||||
mOtherGroups = NULL;
|
||||
mMessageWidget = NULL;
|
||||
|
||||
/* Setup Queue */
|
||||
mInterface = ifaceImpl;
|
||||
mTokenQueue = new TokenQueue(mInterface->getTokenService(), this);
|
||||
|
||||
/* Setup UI helper */
|
||||
// mStateHelper = new UIStateHelper(this);
|
||||
// no widget to add yet
|
||||
|
||||
connect(ui->groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupTreeCustomPopupMenu(QPoint)));
|
||||
connect(ui->groupTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(changedGroup(QString)));
|
||||
connect(ui->groupTreeWidget->treeWidget(), SIGNAL(signalMouseMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(groupTreeMiddleButtonClicked(QTreeWidgetItem*)));
|
||||
connect(ui->messageTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(messageTabCloseRequested(int)));
|
||||
connect(ui->messageTabWidget, SIGNAL(currentChanged(int)), this, SLOT(messageTabChanged(int)));
|
||||
|
||||
connect(ui->todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
|
||||
|
||||
/* Set initial size the splitter */
|
||||
QList<int> sizes;
|
||||
sizes << 300 << width(); // Qt calculates the right sizes
|
||||
ui->splitter->setSizes(sizes);
|
||||
}
|
||||
|
||||
GxsGroupFrameDialog::~GxsGroupFrameDialog()
|
||||
{
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
||||
delete(mTokenQueue);
|
||||
delete(ui);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::initUi()
|
||||
{
|
||||
ui->titleBarPixmap->setPixmap(QPixmap(icon(ICON_NAME)));
|
||||
ui->titleBarLabel->setText(text(TEXT_NAME));
|
||||
|
||||
/* Initialize group tree */
|
||||
QToolButton *newGroupButton = new QToolButton(this);
|
||||
newGroupButton->setIcon(QIcon(icon(ICON_NEW)));
|
||||
newGroupButton->setToolTip(text(TEXT_NEW));
|
||||
connect(newGroupButton, SIGNAL(clicked()), this, SLOT(newGroup()));
|
||||
ui->groupTreeWidget->addToolButton(newGroupButton);
|
||||
|
||||
/* Create group tree */
|
||||
mYourGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_YOUR_GROUP), QIcon(icon(ICON_YOUR_GROUP)), true);
|
||||
mSubscribedGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_SUBSCRIBED_GROUP), QIcon(icon(ICON_SUBSCRIBED_GROUP)), true);
|
||||
mPopularGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_POPULAR_GROUP), QIcon(icon(ICON_POPULAR_GROUP)), false);
|
||||
mOtherGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_OTHER_GROUP), QIcon(icon(ICON_OTHER_GROUP)), false);
|
||||
|
||||
if (text(TEXT_TODO).isEmpty()) {
|
||||
ui->todoPushButton->hide();
|
||||
}
|
||||
|
||||
// load settings
|
||||
mSettingsName = settingsGroupName();
|
||||
processSettings(true);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::showEvent(QShowEvent *event)
|
||||
{
|
||||
if (!mInitialized) {
|
||||
/* Problem: virtual methods cannot be used in constructor */
|
||||
mInitialized = true;
|
||||
|
||||
initUi();
|
||||
}
|
||||
|
||||
RsGxsUpdateBroadcastPage::showEvent(event);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::processSettings(bool load)
|
||||
{
|
||||
if (mSettingsName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Settings->beginGroup(mSettingsName);
|
||||
|
||||
if (load) {
|
||||
// load settings
|
||||
|
||||
// state of splitter
|
||||
ui->splitter->restoreState(Settings->value("Splitter").toByteArray());
|
||||
} else {
|
||||
// save settings
|
||||
|
||||
// state of splitter
|
||||
Settings->setValue("Splitter", ui->splitter->saveState());
|
||||
}
|
||||
|
||||
ui->groupTreeWidget->processSettings(Settings, load);
|
||||
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::setSingleTab(bool singleTab)
|
||||
{
|
||||
if (singleTab) {
|
||||
if (!mMessageWidget) {
|
||||
mMessageWidget = createMessageWidget(RsGxsGroupId());
|
||||
// remove close button of the the first tab
|
||||
ui->messageTabWidget->hideCloseButton(ui->messageTabWidget->indexOf(mMessageWidget));
|
||||
}
|
||||
} else {
|
||||
if (mMessageWidget) {
|
||||
delete(mMessageWidget);
|
||||
mMessageWidget = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::updateDisplay(bool complete)
|
||||
{
|
||||
if (complete || !getGrpIds().empty()) {
|
||||
/* Update group list */
|
||||
requestGroupSummary();
|
||||
}
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::todo()
|
||||
{
|
||||
QMessageBox::information(this, "Todo", text(TEXT_TODO));
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint /*point*/)
|
||||
{
|
||||
int subscribeFlags = ui->groupTreeWidget->subscribeFlags(QString::fromStdString(mGroupId.toStdString()));
|
||||
|
||||
bool isAdmin = IS_GROUP_ADMIN(subscribeFlags);
|
||||
bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags);
|
||||
bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags);
|
||||
|
||||
QMenu contextMnu(this);
|
||||
|
||||
QAction *action;
|
||||
|
||||
if (isSubscribed) {
|
||||
action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeGroup()));
|
||||
action->setEnabled (!mGroupId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
||||
} else {
|
||||
action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeGroup()));
|
||||
action->setDisabled (mGroupId.isNull() || IS_GROUP_SUBSCRIBED(subscribeFlags));
|
||||
}
|
||||
|
||||
if (mMessageWidget) {
|
||||
action = contextMnu.addAction(QIcon(""), tr("Open in new tab"), this, SLOT(openInNewTab()));
|
||||
if (mGroupId.isNull() || messageWidget(mGroupId, true)) {
|
||||
action->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
contextMnu.addSeparator();
|
||||
|
||||
contextMnu.addAction(QIcon(icon(ICON_NEW)), text(TEXT_NEW), this, SLOT(newGroup()));
|
||||
|
||||
action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Details"), this, SLOT(showGroupDetails()));
|
||||
action->setEnabled (!mGroupId.isNull());
|
||||
|
||||
action = contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Edit Details"), this, SLOT(editGroupDetails()));
|
||||
action->setEnabled (!mGroupId.isNull() && isAdmin);
|
||||
|
||||
action = contextMnu.addAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share"), this, SLOT(shareKey()));
|
||||
action->setEnabled(!mGroupId.isNull() && isAdmin);
|
||||
|
||||
if (!mGroupId.isNull() && isPublisher && !isAdmin) {
|
||||
contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights" ), this, SLOT(restoreGroupKeys()));
|
||||
}
|
||||
|
||||
action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink()));
|
||||
action->setEnabled(!mGroupId.isNull());
|
||||
|
||||
contextMnu.addSeparator();
|
||||
|
||||
action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead()));
|
||||
action->setEnabled (!mGroupId.isNull() && isSubscribed);
|
||||
|
||||
action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread()));
|
||||
action->setEnabled (!mGroupId.isNull() && isSubscribed);
|
||||
|
||||
/* Add special actions */
|
||||
QList<QAction*> actions;
|
||||
groupTreeCustomActions(mGroupId, subscribeFlags, actions);
|
||||
if (!actions.isEmpty()) {
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addActions(actions);
|
||||
}
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::restoreGroupKeys(void)
|
||||
{
|
||||
QMessageBox::warning(this, "RetroShare", "ToDo");
|
||||
|
||||
#ifdef TOGXS
|
||||
mInterface->groupRestoreKeys(mGroupId);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::newGroup()
|
||||
{
|
||||
GxsGroupDialog *dialog = createNewGroupDialog(mTokenQueue);
|
||||
if (!dialog) {
|
||||
return;
|
||||
}
|
||||
|
||||
dialog->exec();
|
||||
delete(dialog);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::subscribeGroup()
|
||||
{
|
||||
groupSubscribe(true);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::unsubscribeGroup()
|
||||
{
|
||||
groupSubscribe(false);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::groupSubscribe(bool subscribe)
|
||||
{
|
||||
if (mGroupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t token;
|
||||
mInterface->subscribeToGroup(token, mGroupId, subscribe);
|
||||
mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_SUBSCRIBE_CHANGE);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::showGroupDetails()
|
||||
{
|
||||
if (mGroupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GxsGroupDialog *dialog = createGroupDialog(mTokenQueue, mInterface->getTokenService(), GxsGroupDialog::MODE_SHOW, mGroupId);
|
||||
if (!dialog) {
|
||||
return;
|
||||
}
|
||||
|
||||
dialog->exec();
|
||||
delete(dialog);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::editGroupDetails()
|
||||
{
|
||||
if (mGroupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GxsGroupDialog *dialog = createGroupDialog(mTokenQueue, mInterface->getTokenService(), GxsGroupDialog::MODE_EDIT, mGroupId);
|
||||
if (!dialog) {
|
||||
return;
|
||||
}
|
||||
|
||||
dialog->exec();
|
||||
delete(dialog);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::copyGroupLink()
|
||||
{
|
||||
if (mGroupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// THIS CODE CALLS getForumInfo() to verify that the Ids are valid.
|
||||
// As we are switching to Request/Response this is now harder to do...
|
||||
// So not bothering any more - shouldn't be necessary.
|
||||
// IF we get errors - fix them, rather than patching here.
|
||||
#if 0
|
||||
ForumInfo fi;
|
||||
if (rsGxsForums->getForumInfo(mCurrForumId, fi)) {
|
||||
RetroShareLink link;
|
||||
if (link.createForum(fi.forumId, "")) {
|
||||
QList<RetroShareLink> urls;
|
||||
urls.push_back(link);
|
||||
RSLinkClipboard::copyLinks(urls);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QMessageBox::warning(this, "RetroShare", "ToDo");
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::markMsgAsRead()
|
||||
{
|
||||
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, false);
|
||||
if (msgWidget) {
|
||||
msgWidget->setAllMessagesRead(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::markMsgAsUnread()
|
||||
{
|
||||
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, false);
|
||||
if (msgWidget) {
|
||||
msgWidget->setAllMessagesRead(false);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::shareKey()
|
||||
{
|
||||
if (mGroupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ShareKey shareUi(this, mGroupId.toStdString(), shareKeyType());
|
||||
shareUi.exec();
|
||||
}
|
||||
|
||||
bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const std::string& msgId)
|
||||
{
|
||||
if (groupId.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ui->groupTreeWidget->activateId(QString::fromStdString(groupId.toStdString()), msgId.empty()) == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mGroupId != groupId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (msgId.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//#TODO
|
||||
// if (mThreadLoading) {
|
||||
// mThreadLoad.FocusMsgId = msgId;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
/* Search exisiting item */
|
||||
// QTreeWidgetItemIterator itemIterator(ui->threadTreeWidget);
|
||||
// QTreeWidgetItem *item = NULL;
|
||||
// while ((item = *itemIterator) != NULL) {
|
||||
// itemIterator++;
|
||||
|
||||
// if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) {
|
||||
// ui->threadTreeWidget->setCurrentItem(item);
|
||||
// ui->threadTreeWidget->setFocus();
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
GxsMessageFrameWidget *GxsGroupFrameDialog::messageWidget(const RsGxsGroupId &groupId, bool ownTab)
|
||||
{
|
||||
int tabCount = ui->messageTabWidget->count();
|
||||
for (int index = 0; index < tabCount; ++index) {
|
||||
GxsMessageFrameWidget *childWidget = dynamic_cast<GxsMessageFrameWidget*>(ui->messageTabWidget->widget(index));
|
||||
if (ownTab && mMessageWidget && childWidget == mMessageWidget) {
|
||||
continue;
|
||||
}
|
||||
if (childWidget && childWidget->groupId() == groupId) {
|
||||
return childWidget;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GxsMessageFrameWidget *GxsGroupFrameDialog::createMessageWidget(const RsGxsGroupId &groupId)
|
||||
{
|
||||
GxsMessageFrameWidget *msgWidget = createMessageFrameWidget(groupId);
|
||||
if (!msgWidget) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int index = ui->messageTabWidget->addTab(msgWidget, msgWidget->groupName(true));
|
||||
ui->messageTabWidget->setTabIcon(index, msgWidget->groupIcon());
|
||||
connect(msgWidget, SIGNAL(groupChanged(QWidget*)), this, SLOT(messageTabInfoChanged(QWidget*)));
|
||||
|
||||
return msgWidget;
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::changedGroup(const QString &groupId)
|
||||
{
|
||||
mGroupId = RsGxsGroupId(groupId.toStdString());
|
||||
if (mGroupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* search exisiting tab */
|
||||
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, true);
|
||||
|
||||
if (!msgWidget) {
|
||||
if (mMessageWidget) {
|
||||
/* not found, use standard tab */
|
||||
msgWidget = mMessageWidget;
|
||||
msgWidget->setGroupId(mGroupId);
|
||||
} else {
|
||||
/* create new tab */
|
||||
msgWidget = createMessageWidget(mGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
ui->messageTabWidget->setCurrentWidget(msgWidget);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::groupTreeMiddleButtonClicked(QTreeWidgetItem *item)
|
||||
{
|
||||
openGroupInNewTab(RsGxsGroupId(ui->groupTreeWidget->itemId(item).toStdString()));
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::openInNewTab()
|
||||
{
|
||||
openGroupInNewTab(mGroupId);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::openGroupInNewTab(const RsGxsGroupId &groupId)
|
||||
{
|
||||
if (groupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* search exisiting tab */
|
||||
GxsMessageFrameWidget *msgWidget = messageWidget(groupId, true);
|
||||
if (!msgWidget) {
|
||||
/* not found, create new tab */
|
||||
msgWidget = createMessageWidget(groupId);
|
||||
}
|
||||
|
||||
ui->messageTabWidget->setCurrentWidget(msgWidget);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::messageTabCloseRequested(int index)
|
||||
{
|
||||
GxsMessageFrameWidget *msgWidget = dynamic_cast<GxsMessageFrameWidget*>(ui->messageTabWidget->widget(index));
|
||||
if (!msgWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgWidget == mMessageWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete(msgWidget);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::messageTabChanged(int index)
|
||||
{
|
||||
GxsMessageFrameWidget *msgWidget = dynamic_cast<GxsMessageFrameWidget*>(ui->messageTabWidget->widget(index));
|
||||
if (!msgWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui->groupTreeWidget->activateId(QString::fromStdString(msgWidget->groupId().toStdString()), false);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::messageTabInfoChanged(QWidget *widget)
|
||||
{
|
||||
int index = ui->messageTabWidget->indexOf(widget);
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
GxsMessageFrameWidget *msgWidget = dynamic_cast<GxsMessageFrameWidget*>(ui->messageTabWidget->widget(index));
|
||||
if (!msgWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui->messageTabWidget->setTabText(index, msgWidget->groupName(true));
|
||||
ui->messageTabWidget->setTabIcon(index, msgWidget->groupIcon());
|
||||
}
|
||||
|
||||
///***** INSERT GROUP LISTS *****/
|
||||
void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo)
|
||||
{
|
||||
groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId.toStdString());
|
||||
groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str());
|
||||
//groupItemInfo.description =
|
||||
groupItemInfo.popularity = groupInfo.mPop;
|
||||
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost);
|
||||
groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags;
|
||||
|
||||
#if TOGXS
|
||||
if (groupInfo.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) {
|
||||
groupItemInfo.name += " (" + tr("AUTHD") + ")";
|
||||
groupItemInfo.icon = QIcon(IMAGE_GROUPAUTHD);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
groupItemInfo.icon = QIcon(icon(ICON_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGroupMetaData> &groupList)
|
||||
{
|
||||
if (!mInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<RsGroupMetaData>::const_iterator it;
|
||||
|
||||
QList<GroupItemInfo> adminList;
|
||||
QList<GroupItemInfo> subList;
|
||||
QList<GroupItemInfo> popList;
|
||||
QList<GroupItemInfo> otherList;
|
||||
std::multimap<uint32_t, GroupItemInfo> popMap;
|
||||
|
||||
for (it = groupList.begin(); it != groupList.end(); it++) {
|
||||
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
||||
uint32_t flags = it->mSubscribeFlags;
|
||||
|
||||
GroupItemInfo groupItemInfo;
|
||||
groupInfoToGroupItemInfo(*it, groupItemInfo);
|
||||
|
||||
if (IS_GROUP_SUBSCRIBED(flags))
|
||||
{
|
||||
if (IS_GROUP_ADMIN(flags))
|
||||
{
|
||||
adminList.push_back(groupItemInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* subscribed group */
|
||||
subList.push_back(groupItemInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rate the others by popularity */
|
||||
popMap.insert(std::make_pair(it->mPop, groupItemInfo));
|
||||
}
|
||||
}
|
||||
|
||||
/* iterate backwards through popMap - take the top 5 or 10% of list */
|
||||
uint32_t popCount = 5;
|
||||
if (popCount < popMap.size() / 10)
|
||||
{
|
||||
popCount = popMap.size() / 10;
|
||||
}
|
||||
|
||||
uint32_t i = 0;
|
||||
uint32_t popLimit = 0;
|
||||
std::multimap<uint32_t, GroupItemInfo>::reverse_iterator rit;
|
||||
for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) ;
|
||||
if (rit != popMap.rend()) {
|
||||
popLimit = rit->first;
|
||||
}
|
||||
|
||||
for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) {
|
||||
if (rit->second.popularity < (int) popLimit) {
|
||||
otherList.append(rit->second);
|
||||
} else {
|
||||
popList.append(rit->second);
|
||||
}
|
||||
}
|
||||
|
||||
/* now we can add them in as a tree! */
|
||||
ui->groupTreeWidget->fillGroupItems(mYourGroups, adminList);
|
||||
ui->groupTreeWidget->fillGroupItems(mSubscribedGroups, subList);
|
||||
ui->groupTreeWidget->fillGroupItems(mPopularGroups, popList);
|
||||
ui->groupTreeWidget->fillGroupItems(mOtherGroups, otherList);
|
||||
|
||||
updateMessageSummaryList(RsGxsGroupId());
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
|
||||
{
|
||||
if (!mInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *items[2] = { mYourGroups, mSubscribedGroups };
|
||||
|
||||
for (int item = 0; item < 2; item++) {
|
||||
int child;
|
||||
int childCount = items[item]->childCount();
|
||||
for (child = 0; child < childCount; child++) {
|
||||
QTreeWidgetItem *childItem = items[item]->child(child);
|
||||
std::string childId = ui->groupTreeWidget->itemId(childItem).toStdString();
|
||||
if (childId.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (groupId.isNull() || childId == groupId.toStdString()) {
|
||||
/* calculate unread messages */
|
||||
unsigned int newMessageCount = 0;
|
||||
unsigned int unreadMessageCount = 0;
|
||||
|
||||
//#TODO mInterface->getMessageCount(childId, newMessageCount, unreadMessageCount);
|
||||
|
||||
std::cerr << "IMPLEMENT mInterface->getMessageCount()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
ui->groupTreeWidget->setUnreadCount(childItem, unreadMessageCount);
|
||||
|
||||
if (groupId.isNull() == false) {
|
||||
/* Calculate only this group */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/** Request / Response of Data ********************************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsGroupFrameDialog::requestGroupSummary()
|
||||
{
|
||||
// mStateHelper->setLoading(TOKEN_TYPE_LISTING, true);
|
||||
|
||||
#ifdef DEBUG_GROUPFRAMEDIALOG
|
||||
std::cerr << "GxsGroupFrameDialog::requestGroupSummary()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_LISTING);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
uint32_t token;
|
||||
mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_LISTING);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_GROUPFRAMEDIALOG
|
||||
std::cerr << "GxsGroupFrameDialog::loadGroupSummary()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::list<RsGroupMetaData> groupInfo;
|
||||
mInterface->getGroupSummary(token, groupInfo);
|
||||
|
||||
if (groupInfo.size() > 0)
|
||||
{
|
||||
// mStateHelper->setActive(TOKEN_TYPE_LISTING, true);
|
||||
|
||||
insertGroupsData(groupInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsGroupFrameDialog::loadGroupSummary() ERROR No Groups...";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// mStateHelper->setActive(TOKEN_TYPE_LISTING, false);
|
||||
}
|
||||
|
||||
// mStateHelper->setLoading(TOKEN_TYPE_LISTING, false);
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsGroupFrameDialog::acknowledgeSubscribeChange(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_GROUPFRAMEDIALOG
|
||||
std::cerr << "GxsGroupFrameDialog::acknowledgeSubscribeChange()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RsGxsGroupId groupId;
|
||||
mInterface->acknowledgeGrp(token, groupId);
|
||||
|
||||
requestGroupSummary();
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
//void GxsGroupFrameDialog::requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId)
|
||||
//{
|
||||
// RsTokReqOptions opts;
|
||||
// opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
// std::list<std::string> grpIds;
|
||||
// grpIds.push_back(groupId);
|
||||
|
||||
// std::cerr << "GxsGroupFrameDialog::requestGroupSummary_CurrentGroup(" << groupId << ")";
|
||||
// std::cerr << std::endl;
|
||||
|
||||
// uint32_t token;
|
||||
// mInteface->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, TOKEN_TYPE_CURRENTGROUP);
|
||||
//}
|
||||
|
||||
//void GxsGroupFrameDialog::loadGroupSummary_CurrentGroup(const uint32_t &token)
|
||||
//{
|
||||
// std::cerr << "GxsGroupFrameDialog::loadGroupSummary_CurrentGroup()";
|
||||
// std::cerr << std::endl;
|
||||
|
||||
// std::list<RsGroupMetaData> groupInfo;
|
||||
// rsGxsForums->getGroupSummary(token, groupInfo);
|
||||
|
||||
// if (groupInfo.size() == 1)
|
||||
// {
|
||||
// RsGroupMetaData fi = groupInfo.front();
|
||||
// mSubscribeFlags = fi.mSubscribeFlags;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// resetData();
|
||||
// std::cerr << "GxsGroupFrameDialog::loadGroupSummary_CurrentGroup() ERROR Invalid Number of Groups...";
|
||||
// std::cerr << std::endl;
|
||||
// }
|
||||
|
||||
// setValid(true);
|
||||
//}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsGroupFrameDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_GROUPFRAMEDIALOG
|
||||
std::cerr << "GxsGroupFrameDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (queue == mTokenQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
{
|
||||
case TOKEN_TYPE_LISTING:
|
||||
loadGroupSummary(req.mToken);
|
||||
break;
|
||||
|
||||
case TOKEN_TYPE_SUBSCRIBE_CHANGE:
|
||||
acknowledgeSubscribeChange(req.mToken);
|
||||
break;
|
||||
|
||||
// case TOKEN_TYPE_CURRENTGROUP:
|
||||
// loadGroupSummary_CurrentGroup(req.mToken);
|
||||
// break;
|
||||
|
||||
default:
|
||||
std::cerr << "GxsGroupFrameDialog::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
168
retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h
Normal file
168
retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h
Normal file
@ -0,0 +1,168 @@
|
||||
/****************************************************************
|
||||
* 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 _GXSGROUPFRAMEDIALOG_H
|
||||
#define _GXSGROUPFRAMEDIALOG_H
|
||||
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||
#include "RsAutoUpdatePage.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
#include "GxsIdTreeWidgetItem.h"
|
||||
#include "GxsGroupDialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class GxsGroupFrameDialog;
|
||||
}
|
||||
|
||||
class GroupTreeWidget;
|
||||
class GroupItemInfo;
|
||||
class GxsMessageFrameWidget;
|
||||
//class UIStateHelper;
|
||||
|
||||
class GxsGroupFrameDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum TextType {
|
||||
TEXT_NAME,
|
||||
TEXT_NEW,
|
||||
TEXT_TODO,
|
||||
TEXT_YOUR_GROUP,
|
||||
TEXT_SUBSCRIBED_GROUP,
|
||||
TEXT_POPULAR_GROUP,
|
||||
TEXT_OTHER_GROUP
|
||||
};
|
||||
|
||||
enum IconType {
|
||||
ICON_NAME,
|
||||
ICON_NEW,
|
||||
ICON_YOUR_GROUP,
|
||||
ICON_SUBSCRIBED_GROUP,
|
||||
ICON_POPULAR_GROUP,
|
||||
ICON_OTHER_GROUP,
|
||||
ICON_DEFAULT
|
||||
};
|
||||
|
||||
public:
|
||||
GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = 0);
|
||||
~GxsGroupFrameDialog();
|
||||
|
||||
bool navigate(const RsGxsGroupId groupId, const std::string& msgId);
|
||||
|
||||
// Callback for all Loads.
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
RsGxsGroupId groupId() { return mGroupId; }
|
||||
|
||||
void setSingleTab(bool singleTab);
|
||||
|
||||
private slots:
|
||||
void todo();
|
||||
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void groupTreeCustomPopupMenu(QPoint point);
|
||||
|
||||
void restoreGroupKeys();
|
||||
void newGroup();
|
||||
|
||||
void changedGroup(const QString &groupId);
|
||||
void groupTreeMiddleButtonClicked(QTreeWidgetItem *item);
|
||||
void openInNewTab();
|
||||
void messageTabCloseRequested(int index);
|
||||
void messageTabChanged(int index);
|
||||
void messageTabInfoChanged(QWidget *widget);
|
||||
|
||||
void copyGroupLink();
|
||||
|
||||
void subscribeGroup();
|
||||
void unsubscribeGroup();
|
||||
|
||||
void showGroupDetails();
|
||||
void editGroupDetails();
|
||||
|
||||
void markMsgAsRead();
|
||||
void markMsgAsUnread();
|
||||
|
||||
void shareKey();
|
||||
|
||||
private:
|
||||
virtual QString text(TextType type) = 0;
|
||||
virtual QString icon(IconType type) = 0;
|
||||
virtual QString settingsGroupName() = 0;
|
||||
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue) = 0;
|
||||
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0;
|
||||
virtual int shareKeyType() = 0;
|
||||
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId) = 0;
|
||||
virtual void groupTreeCustomActions(RsGxsGroupId /*grpId*/, int /*subscribeFlags*/, QList<QAction*> &/*actions*/) {}
|
||||
|
||||
void initUi();
|
||||
|
||||
void updateMessageSummaryList(RsGxsGroupId groupId);
|
||||
void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
||||
|
||||
void openGroupInNewTab(const RsGxsGroupId &groupId);
|
||||
void groupSubscribe(bool subscribe);
|
||||
|
||||
void processSettings(bool load);
|
||||
|
||||
// New Request/Response Loading Functions.
|
||||
void insertGroupsData(const std::list<RsGroupMetaData> &groupList);
|
||||
|
||||
void requestGroupSummary();
|
||||
void loadGroupSummary(const uint32_t &token);
|
||||
|
||||
// subscribe/unsubscribe ack.
|
||||
void acknowledgeSubscribeChange(const uint32_t &token);
|
||||
|
||||
GxsMessageFrameWidget *messageWidget(const RsGxsGroupId &groupId, bool ownTab);
|
||||
GxsMessageFrameWidget *createMessageWidget(const RsGxsGroupId &groupId);
|
||||
|
||||
// void requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId);
|
||||
// void loadGroupSummary_CurrentGroup(const uint32_t &token);
|
||||
|
||||
private:
|
||||
bool mInitialized;
|
||||
QString mSettingsName;
|
||||
RsGxsGroupId mGroupId;
|
||||
RsGxsIfaceHelper *mInterface;
|
||||
TokenQueue *mTokenQueue;
|
||||
GxsMessageFrameWidget *mMessageWidget;
|
||||
|
||||
QTreeWidgetItem *mYourGroups;
|
||||
QTreeWidgetItem *mSubscribedGroups;
|
||||
QTreeWidgetItem *mPopularGroups;
|
||||
QTreeWidgetItem *mOtherGroups;
|
||||
|
||||
// UIStateHelper *mStateHelper;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::GxsGroupFrameDialog *ui;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GxsForumsDialog</class>
|
||||
<widget class="QWidget" name="GxsForumsDialog">
|
||||
<class>GxsGroupFrameDialog</class>
|
||||
<widget class="QWidget" name="GxsGroupFrameDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -33,7 +33,16 @@
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
@ -48,7 +57,16 @@
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -80,7 +98,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Forums</string>
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -108,7 +126,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="GroupTreeWidget" name="forumTreeWidget" native="true">
|
||||
<widget class="GroupTreeWidget" name="groupTreeWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
@ -119,7 +137,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="RSTabWidget" name="threadTabWidget">
|
||||
<widget class="RSTabWidget" name="messageTabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
27
retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp
Normal file
27
retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 RetroShare Team
|
||||
*
|
||||
* 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 "GxsMessageFrameWidget.h"
|
||||
|
||||
GxsMessageFrameWidget::GxsMessageFrameWidget(RsGxsIfaceHelper *ifaceImpl, QWidget *parent)
|
||||
: RsGxsUpdateBroadcastWidget(ifaceImpl, parent)
|
||||
{
|
||||
}
|
46
retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.h
Normal file
46
retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.h
Normal file
@ -0,0 +1,46 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 RetroShare Team
|
||||
*
|
||||
* 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 GXSMESSAGEFRAMEWIDGET_H
|
||||
#define GXSMESSAGEFRAMEWIDGET_H
|
||||
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastWidget.h"
|
||||
|
||||
class RsGxsIfaceHelper;
|
||||
|
||||
class GxsMessageFrameWidget : public RsGxsUpdateBroadcastWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GxsMessageFrameWidget(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = NULL);
|
||||
|
||||
virtual RsGxsGroupId groupId() = 0;
|
||||
virtual void setGroupId(const RsGxsGroupId &groupId) = 0;
|
||||
virtual QString groupName(bool withUnreadCount) = 0;
|
||||
virtual QIcon groupIcon() = 0;
|
||||
virtual void setAllMessagesRead(bool read) = 0;
|
||||
|
||||
signals:
|
||||
void groupChanged(QWidget *widget);
|
||||
};
|
||||
|
||||
#endif // GXSMESSAGEFRAMEWIDGET_H
|
File diff suppressed because it is too large
Load Diff
@ -22,23 +22,10 @@
|
||||
#ifndef _GXS_CHANNEL_DIALOG_H
|
||||
#define _GXS_CHANNEL_DIALOG_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||
|
||||
#include "ui_GxsChannelDialog.h"
|
||||
|
||||
#include "gui/feeds/FeedHolder.h"
|
||||
#include "gui/gxs/GxsGroupFrameDialog.h"
|
||||
#include "gui/gxs/GxsCommentContainer.h"
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
//class ChanMsgItem;
|
||||
class GxsChannelPostItem;
|
||||
class QTreeWidgetItem;
|
||||
class UIStateHelper;
|
||||
|
||||
class GxsChannelDialog : public RsGxsUpdateBroadcastPage, public TokenResponse, public GxsServiceDialog, public FeedHolder
|
||||
class GxsChannelDialog : public GxsGroupFrameDialog, public GxsServiceDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -50,94 +37,20 @@ public:
|
||||
|
||||
// virtual UserNotify *getUserNotify(QObject *parent);
|
||||
|
||||
/* FeedHolder */
|
||||
virtual QScrollArea *getScrollArea();
|
||||
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
||||
virtual void openChat(const RsPeerId& peerId);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
bool navigate(const std::string& channelId, const std::string& msgId);
|
||||
|
||||
/* NEW GXS FNS */
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
protected:
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
private slots:
|
||||
void todo();
|
||||
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 fillThreadFinished();
|
||||
//void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
|
||||
void loadComment(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
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);
|
||||
|
||||
void acknowledgeGroupUpdate(const uint32_t &token);
|
||||
void acknowledgeMessageUpdate(const uint32_t &token);
|
||||
|
||||
RsGxsGroupId 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;
|
||||
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::GxsChannelDialog ui;
|
||||
/* GxsGroupFrameDialog */
|
||||
virtual QString text(TextType type);
|
||||
virtual QString icon(IconType type);
|
||||
virtual QString settingsGroupName() { return "GxsChannelDialog"; }
|
||||
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue);
|
||||
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId);
|
||||
virtual int shareKeyType();
|
||||
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
|
||||
virtual void groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList<QAction*> &actions);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,314 +0,0 @@
|
||||
<?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 resource="../images.qrc">:/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="todoPushButton">
|
||||
<property name="text">
|
||||
<string>Todo</string>
|
||||
</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 resource="../images.qrc">:/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>389</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 resource="../images.qrc">
|
||||
<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>
|
616
retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp
Normal file
616
retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp
Normal file
@ -0,0 +1,616 @@
|
||||
/****************************************************************
|
||||
* 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 "GxsChannelPostsWidget.h"
|
||||
#include "ui_GxsChannelPostsWidget.h"
|
||||
#include "gui/feeds/GxsChannelPostItem.h"
|
||||
#include "gui/gxschannels/CreateGxsChannelMsg.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
|
||||
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
|
||||
|
||||
#define WARNING_LIMIT 3600*24*2
|
||||
|
||||
/* Images for TreeWidget */
|
||||
#define IMAGE_CHANNELBLUE ":/images/channelsblue.png"
|
||||
#define IMAGE_CHANNELGREEN ":/images/channelsgreen.png"
|
||||
#define IMAGE_CHANNELRED ":/images/channelsred.png"
|
||||
#define IMAGE_CHANNELYELLOW ":/images/channelsyellow.png"
|
||||
|
||||
/****
|
||||
* #define DEBUG_CHANNEL
|
||||
***/
|
||||
|
||||
#define USE_THREAD
|
||||
|
||||
#define TOKEN_TYPE_MESSAGE_CHANGE 4
|
||||
#define TOKEN_TYPE_GROUP_DATA 6
|
||||
#define TOKEN_TYPE_POSTS 7
|
||||
|
||||
/** Constructor */
|
||||
GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent)
|
||||
: GxsMessageFrameWidget(rsGxsChannels, parent),
|
||||
ui(new Ui::GxsChannelPostsWidget)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui->setupUi(this);
|
||||
|
||||
/* Setup UI helper */
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
|
||||
mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
||||
mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressLabel, UISTATE_LOADING_VISIBLE);
|
||||
|
||||
mStateHelper->addLoadPlaceholder(TOKEN_TYPE_GROUP_DATA, ui->nameLabel);
|
||||
|
||||
mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui->postButton);
|
||||
mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui->logoLabel);
|
||||
|
||||
mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this);
|
||||
|
||||
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
||||
// connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
|
||||
|
||||
/*************** Setup Left Hand Side (List of Channels) ****************/
|
||||
|
||||
ui->progressLabel->hide();
|
||||
ui->progressBar->hide();
|
||||
|
||||
ui->nameLabel->setMinimumWidth(20);
|
||||
|
||||
/* load settings */
|
||||
processSettings(true);
|
||||
|
||||
/* Initialize GUI */
|
||||
setGroupId(channelId);
|
||||
}
|
||||
|
||||
GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
||||
{
|
||||
// save settings
|
||||
processSettings(false);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::updateDisplay(bool complete)
|
||||
{
|
||||
if (complete) {
|
||||
/* Not needed */
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<RsGxsGroupId> &grpIds = getGrpIds();
|
||||
if (!mChannelId.isNull() && std::find(grpIds.begin(), grpIds.end(), mChannelId) != grpIds.end()) {
|
||||
requestGroupData(mChannelId);
|
||||
} else {
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgs = getMsgIds();
|
||||
if (!msgs.empty())
|
||||
{
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit = msgs.find(mChannelId);
|
||||
if(mit != msgs.end())
|
||||
{
|
||||
requestPosts(mChannelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//UserNotify *GxsChannelPostsWidget::getUserNotify(QObject *parent)
|
||||
//{
|
||||
// return new ChannelUserNotify(parent);
|
||||
//}
|
||||
|
||||
void GxsChannelPostsWidget::processSettings(bool load)
|
||||
{
|
||||
// Settings->beginGroup(QString("GxsChannelDialog"));
|
||||
//
|
||||
// if (load) {
|
||||
// // load settings
|
||||
// } else {
|
||||
// // save settings
|
||||
// }
|
||||
//
|
||||
// Settings->endGroup();
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::setGroupId(const RsGxsGroupId &groupId)
|
||||
{
|
||||
if (mChannelId == groupId) {
|
||||
if (!groupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mChannelId = groupId;
|
||||
ui->nameLabel->setText(mChannelId.isNull () ? "" : tr("Loading"));
|
||||
|
||||
emit groupChanged(this);
|
||||
|
||||
requestGroupData(mChannelId);
|
||||
}
|
||||
|
||||
QString GxsChannelPostsWidget::groupName(bool withUnreadCount)
|
||||
{
|
||||
QString name = mChannelId.isNull () ? tr("No name") : ui->nameLabel->text();
|
||||
|
||||
// if (withUnreadCount && mUnreadCount) {
|
||||
// name += QString(" (%1)").arg(mUnreadCount);
|
||||
// }
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
QIcon GxsChannelPostsWidget::groupIcon()
|
||||
{
|
||||
if (mStateHelper->isLoading(TOKEN_TYPE_POSTS)) {
|
||||
return QIcon(":/images/kalarm.png");
|
||||
}
|
||||
|
||||
// if (mNewCount) {
|
||||
// return QIcon(":/images/message-state-new.png");
|
||||
// }
|
||||
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
/*************************************************************************************/
|
||||
/*************************************************************************************/
|
||||
/*************************************************************************************/
|
||||
|
||||
QScrollArea *GxsChannelPostsWidget::getScrollArea()
|
||||
{
|
||||
return ui->scrollArea;
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::deleteFeedItem(QWidget * /*item*/, uint32_t /*type*/)
|
||||
{
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::createMsg()
|
||||
{
|
||||
if (mChannelId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(mChannelId);
|
||||
msgDialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
//void GxsChannelPostsWidget::channelMsgReadSatusChanged(const QString& channelId, const QString& /*msgId*/, int /*status*/)
|
||||
//{
|
||||
// updateMessageSummaryList(channelId.toStdString());
|
||||
//}
|
||||
|
||||
void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group)
|
||||
{
|
||||
mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, true);
|
||||
|
||||
/* IMAGE */
|
||||
QPixmap chanImage;
|
||||
if (group.mImage.mData != NULL) {
|
||||
chanImage.loadFromData(group.mImage.mData, group.mImage.mSize, "PNG");
|
||||
} else {
|
||||
chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
|
||||
}
|
||||
ui->logoLabel->setPixmap(chanImage);
|
||||
|
||||
/* set Channel name */
|
||||
ui->nameLabel->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str()));
|
||||
|
||||
if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)
|
||||
{
|
||||
mStateHelper->setWidgetEnabled(ui->postButton, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mStateHelper->setWidgetEnabled(ui->postButton, false);
|
||||
}
|
||||
|
||||
setAutoDownloadButton(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED);
|
||||
|
||||
emit groupChanged(this);
|
||||
requestPosts(mChannelId);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::insertChannelPosts(const std::vector<RsGxsChannelPost> &posts)
|
||||
{
|
||||
std::vector<RsGxsChannelPost>::const_iterator it;
|
||||
|
||||
// Do these need sorting? probably.
|
||||
// can we add that into the request?
|
||||
//msgs.sort(sortChannelMsgSummary);
|
||||
|
||||
uint32_t subscribeFlags = 0xffffffff;
|
||||
|
||||
for (it = posts.begin(); it != posts.end(); it++)
|
||||
{
|
||||
GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, *it, subscribeFlags, true);
|
||||
mChannelPostItems.push_back(item);
|
||||
ui->verticalLayout->addWidget(item);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void GxsChannelPostsWidget::updateChannelMsgs()
|
||||
{
|
||||
if (fillThread) {
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::updateChannelMsgs() stop current fill thread" << std::endl;
|
||||
#endif
|
||||
// stop current fill thread
|
||||
GxsChannelFillThread *thread = fillThread;
|
||||
fillThread = NULL;
|
||||
thread->stop();
|
||||
delete(thread);
|
||||
|
||||
progressLabel->hide();
|
||||
progressBar->hide();
|
||||
}
|
||||
|
||||
if (!rsChannels) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* replace all the messages with new ones */
|
||||
QList<ChanMsgItem *>::iterator mit;
|
||||
for (mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++) {
|
||||
delete (*mit);
|
||||
}
|
||||
mChanMsgItems.clear();
|
||||
|
||||
ChannelInfo ci;
|
||||
if (!rsChannels->getChannelInfo(mChannelId, ci)) {
|
||||
postButton->setEnabled(false);
|
||||
nameLabel->setText(tr("No Channel Selected"));
|
||||
logoLabel->setPixmap(QPixmap(":/images/channels.png"));
|
||||
logoLabel->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
QPixmap chanImage;
|
||||
if (ci.pngImageLen != 0) {
|
||||
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
|
||||
} else {
|
||||
chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
|
||||
}
|
||||
logoLabel->setPixmap(chanImage);
|
||||
logoLabel->setEnabled(true);
|
||||
|
||||
/* set Channel name */
|
||||
nameLabel->setText(QString::fromStdWString(ci.channelName));
|
||||
|
||||
if (ci.channelFlags & RS_DISTRIB_PUBLISH) {
|
||||
postButton->setEnabled(true);
|
||||
} else {
|
||||
postButton->setEnabled(false);
|
||||
}
|
||||
|
||||
if (!(ci.channelFlags & RS_DISTRIB_ADMIN) &&
|
||||
(ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) {
|
||||
actionEnable_Auto_Download->setEnabled(true);
|
||||
} else {
|
||||
actionEnable_Auto_Download->setEnabled(false);
|
||||
}
|
||||
|
||||
#ifdef USE_THREAD
|
||||
progressLabel->show();
|
||||
progressBar->reset();
|
||||
progressBar->show();
|
||||
|
||||
// create fill thread
|
||||
fillThread = new GxsChannelFillThread(this, mChannelId);
|
||||
|
||||
// connect thread
|
||||
connect(fillThread, SIGNAL(finished()), this, SLOT(fillThreadFinished()), Qt::BlockingQueuedConnection);
|
||||
connect(fillThread, SIGNAL(addMsg(QString,QString,int,int)), this, SLOT(fillThreadAddMsg(QString,QString,int,int)), Qt::BlockingQueuedConnection);
|
||||
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::updateChannelMsgs() Start fill thread" << std::endl;
|
||||
#endif
|
||||
|
||||
// start thread
|
||||
fillThread->start();
|
||||
#else
|
||||
std::list<ChannelMsgSummary> msgs;
|
||||
std::list<ChannelMsgSummary>::iterator it;
|
||||
rsChannels->getChannelMsgList(mChannelId, msgs);
|
||||
|
||||
msgs.sort(sortChannelMsgSummary);
|
||||
|
||||
for (it = msgs.begin(); it != msgs.end(); it++) {
|
||||
ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true);
|
||||
mChanMsgItems.push_back(cmi);
|
||||
verticalLayout_2->addWidget(cmi);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::fillThreadFinished()
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::fillThreadFinished()" << std::endl;
|
||||
#endif
|
||||
|
||||
// thread has finished
|
||||
GxsChannelFillThread *thread = dynamic_cast<GxsChannelFillThread*>(sender());
|
||||
if (thread) {
|
||||
if (thread == fillThread) {
|
||||
// current thread has finished, hide progressbar and release thread
|
||||
progressBar->hide();
|
||||
progressLabel->hide();
|
||||
fillThread = NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CHANNEL
|
||||
if (thread->wasStopped()) {
|
||||
// thread was stopped
|
||||
std::cerr << "GxsChannelPostsWidget::fillThreadFinished() Thread was stopped" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::fillThreadFinished() Delete thread" << std::endl;
|
||||
#endif
|
||||
|
||||
thread->deleteLater();
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::fillThreadFinished done()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count)
|
||||
{
|
||||
if (sender() == fillThread) {
|
||||
// show fill progress
|
||||
if (count) {
|
||||
progressBar->setValue(current * progressBar->maximum() / count);
|
||||
}
|
||||
|
||||
lockLayout(NULL, true);
|
||||
|
||||
ChanMsgItem *cmi = new ChanMsgItem(this, 0, channelId.toStdString(), channelMsgId.toStdString(), true);
|
||||
mChanMsgItems.push_back(cmi);
|
||||
verticalLayout->addWidget(cmi);
|
||||
cmi->show();
|
||||
|
||||
lockLayout(cmi, false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GxsChannelPostsWidget::setAllMessagesRead(bool read)
|
||||
{
|
||||
#if 0
|
||||
if (mChannelId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rsChannels) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelInfo ci;
|
||||
if (rsChannels->getChannelInfo(mChannelId, ci) == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) {
|
||||
std::list<ChannelMsgSummary> msgs;
|
||||
std::list<ChannelMsgSummary>::iterator it;
|
||||
|
||||
rsChannels->getChannelMsgList(mChannelId, msgs);
|
||||
|
||||
for(it = msgs.begin(); it != msgs.end(); it++) {
|
||||
rsChannels->setMessageStatus(mChannelId, it->msgId, CHANNEL_MSG_STATUS_READ, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::setAutoDownloadButton(bool autoDl)
|
||||
{
|
||||
if (autoDl) {
|
||||
ui->actionEnable_Auto_Download->setText(tr("Disable Auto-Download"));
|
||||
}else{
|
||||
ui->actionEnable_Auto_Download->setText(tr("Enable Auto-Download"));
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************************************
|
||||
* New Stuff here.
|
||||
*************/
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/** Request / Response of Data ********************************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsChannelPostsWidget::requestGroupData(const RsGxsGroupId &grpId)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::requestGroupData()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_DATA);
|
||||
|
||||
if (grpId.isNull()) {
|
||||
mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, false);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_GROUP_DATA);
|
||||
|
||||
ui->nameLabel->setText(tr("No Channel Selected"));
|
||||
ui->logoLabel->setPixmap(QPixmap(":/images/channels.png"));
|
||||
|
||||
emit groupChanged(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(grpId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
mChannelQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_GROUP_DATA);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::loadGroupData(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::loadGroupData()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsChannelGroup> groups;
|
||||
rsGxsChannels->getGroupData(token, groups);
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, false);
|
||||
|
||||
if (groups.size() == 1)
|
||||
{
|
||||
insertChannelDetails(groups[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsChannelPostsWidget::loadGroupData() ERROR Not just one Group";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_GROUP_DATA);
|
||||
|
||||
emit groupChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::requestPosts(const RsGxsGroupId &grpId)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::requestPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* replace all the messages with new ones */
|
||||
QList<GxsChannelPostItem *>::iterator mit;
|
||||
for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); mit++) {
|
||||
delete (*mit);
|
||||
}
|
||||
mChannelPostItems.clear();
|
||||
|
||||
mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_POSTS);
|
||||
|
||||
if (grpId.isNull()) {
|
||||
mStateHelper->setActive(TOKEN_TYPE_POSTS, false);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_POSTS);
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_POSTS, true);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(grpId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
uint32_t token;
|
||||
mChannelQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_POSTS);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::loadPosts(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::loadPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
rsGxsChannels->getPostData(token, posts);
|
||||
|
||||
mStateHelper->setActive(TOKEN_TYPE_POSTS, true);
|
||||
|
||||
insertChannelPosts(posts);
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::acknowledgeMessageUpdate(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::acknowledgeMessageUpdate() TODO";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::pair<RsGxsGroupId, RsGxsMessageId> msgId;
|
||||
rsGxsChannels->acknowledgeMsg(token, msgId);
|
||||
if (msgId.first == mChannelId)
|
||||
{
|
||||
requestPosts(mChannelId);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (queue == mChannelQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
{
|
||||
case TOKEN_TYPE_MESSAGE_CHANGE:
|
||||
acknowledgeMessageUpdate(req.mToken);
|
||||
break;
|
||||
case TOKEN_TYPE_GROUP_DATA:
|
||||
loadGroupData(req.mToken);
|
||||
break;
|
||||
case TOKEN_TYPE_POSTS:
|
||||
loadPosts(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "GxsChannelPostsWidget::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
115
retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h
Normal file
115
retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h
Normal file
@ -0,0 +1,115 @@
|
||||
/****************************************************************
|
||||
* 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_CHANNELPOSTSWIDGET_H
|
||||
#define _GXS_CHANNELPOSTSWIDGET_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "gui/gxs/GxsMessageFrameWidget.h"
|
||||
|
||||
#include "gui/feeds/FeedHolder.h"
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
namespace Ui {
|
||||
class GxsChannelPostsWidget;
|
||||
}
|
||||
|
||||
//class ChanMsgItem;
|
||||
class GxsChannelPostItem;
|
||||
class QTreeWidgetItem;
|
||||
class UIStateHelper;
|
||||
class QBoxLayout;
|
||||
|
||||
class GxsChannelPostsWidget : public GxsMessageFrameWidget, public TokenResponse, public FeedHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent = 0);
|
||||
/** Default Destructor */
|
||||
~GxsChannelPostsWidget();
|
||||
|
||||
/* GxsMessageFrameWidget */
|
||||
virtual RsGxsGroupId groupId() { return mChannelId; }
|
||||
virtual void setGroupId(const RsGxsGroupId &channelId);
|
||||
virtual QString groupName(bool withUnreadCount);
|
||||
virtual QIcon groupIcon();
|
||||
virtual void setAllMessagesRead(bool read);
|
||||
|
||||
/* FeedHolder */
|
||||
virtual QScrollArea *getScrollArea();
|
||||
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
||||
virtual void openChat(const RsPeerId& peerId);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
/* 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);
|
||||
|
||||
private slots:
|
||||
void createMsg();
|
||||
|
||||
//void fillThreadFinished();
|
||||
//void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
|
||||
|
||||
private:
|
||||
void processSettings(bool load);
|
||||
|
||||
void setAutoDownloadButton(bool autoDl);
|
||||
|
||||
/* NEW GXS FNS */
|
||||
void requestGroupData(const RsGxsGroupId &grpId);
|
||||
void loadGroupData(const uint32_t &token);
|
||||
|
||||
void requestPosts(const RsGxsGroupId &grpId);
|
||||
void loadPosts(const uint32_t &token);
|
||||
|
||||
void insertChannelDetails(const RsGxsChannelGroup &group);
|
||||
void insertChannelPosts(const std::vector<RsGxsChannelPost> &posts);
|
||||
|
||||
void acknowledgeMessageUpdate(const uint32_t &token);
|
||||
|
||||
RsGxsGroupId mChannelId; /* current Channel */
|
||||
TokenQueue *mChannelQueue;
|
||||
|
||||
/* Layout Pointers */
|
||||
QBoxLayout *mMsgLayout;
|
||||
|
||||
//QList<ChanMsgItem *> mChanMsgItems;
|
||||
QList<GxsChannelPostItem *> mChannelPostItems;
|
||||
|
||||
std::map<std::string, uint32_t> mChanSearchScore; //chanId, score
|
||||
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::GxsChannelPostsWidget *ui;
|
||||
};
|
||||
|
||||
#endif
|
248
retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui
Normal file
248
retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui
Normal file
@ -0,0 +1,248 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GxsChannelPostsWidget</class>
|
||||
<widget class="QWidget" name="GxsChannelPostsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>681</width>
|
||||
<height>476</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<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="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<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 resource="../images.qrc">:/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>
|
||||
<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="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<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 resource="../images.qrc">
|
||||
<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>
|
||||
<item>
|
||||
<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>
|
||||
<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>679</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="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</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>
|
||||
<zorder>toolBarFrame</zorder>
|
||||
<zorder>scrollArea</zorder>
|
||||
<zorder></zorder>
|
||||
<zorder>headFrame</zorder>
|
||||
<zorder>toolBarFrame</zorder>
|
||||
<zorder>scrollArea</zorder>
|
||||
<zorder></zorder>
|
||||
<zorder>headFrame</zorder>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -87,7 +87,7 @@
|
||||
#define TOKEN_TYPE_REPLY_MESSAGE 3
|
||||
|
||||
GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget *parent) :
|
||||
RsGxsUpdateBroadcastWidget(rsGxsForums, parent),
|
||||
GxsMessageFrameWidget(rsGxsForums, parent),
|
||||
ui(new Ui::GxsForumThreadWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -195,7 +195,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
||||
mFillThread = NULL;
|
||||
ui->threadTreeWidget->setGxsIdColumn(COLUMN_THREAD_AUTHOR);
|
||||
|
||||
setForumId(forumId);
|
||||
setGroupId(forumId);
|
||||
|
||||
ui->threadTreeWidget->installEventFilter(this);
|
||||
}
|
||||
@ -256,7 +256,7 @@ void GxsForumThreadWidget::processSettings(bool load)
|
||||
mInProcessSettings = false;
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::setForumId(const RsGxsGroupId &forumId)
|
||||
void GxsForumThreadWidget::setGroupId(const RsGxsGroupId &forumId)
|
||||
{
|
||||
if (mForumId == forumId) {
|
||||
if (!forumId.isNull()) {
|
||||
@ -269,12 +269,12 @@ void GxsForumThreadWidget::setForumId(const RsGxsGroupId &forumId)
|
||||
mNewCount = 0;
|
||||
mUnreadCount = 0;
|
||||
|
||||
emit forumChanged(this);
|
||||
emit groupChanged(this);
|
||||
|
||||
insertThreads();
|
||||
}
|
||||
|
||||
QString GxsForumThreadWidget::forumName(bool withUnreadCount)
|
||||
QString GxsForumThreadWidget::groupName(bool withUnreadCount)
|
||||
{
|
||||
QString name = mForumId.isNull () ? tr("No name") : ui->forumName->text();
|
||||
|
||||
@ -285,7 +285,7 @@ QString GxsForumThreadWidget::forumName(bool withUnreadCount)
|
||||
return name;
|
||||
}
|
||||
|
||||
QIcon GxsForumThreadWidget::forumIcon()
|
||||
QIcon GxsForumThreadWidget::groupIcon()
|
||||
{
|
||||
if (mStateHelper->isLoading(TOKEN_TYPE_CURRENTFORUM) || mFillThread) {
|
||||
return QIcon(":/images/kalarm.png");
|
||||
@ -632,7 +632,7 @@ void GxsForumThreadWidget::calculateUnreadCount()
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
emit forumChanged(this);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,7 +682,7 @@ void GxsForumThreadWidget::fillThreadFinished()
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, false);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, false);
|
||||
emit forumChanged(this);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
if (thread->wasStopped()) {
|
||||
@ -745,7 +745,7 @@ void GxsForumThreadWidget::fillThreadFinished()
|
||||
insertPost();
|
||||
calculateIconsAndFonts();
|
||||
calculateUnreadCount();
|
||||
emit forumChanged(this);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
@ -968,7 +968,7 @@ void GxsForumThreadWidget::insertForumThreads(const RsGxsForumGroup &group)
|
||||
|
||||
// start thread
|
||||
mFillThread->start();
|
||||
emit forumChanged(this);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::fillThreads(QList<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand)
|
||||
@ -1493,7 +1493,7 @@ void GxsForumThreadWidget::markMsgAsUnreadChildren()
|
||||
markMsgAsReadUnread(false, true, false);
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::setAllMsgReadStatus(bool read)
|
||||
void GxsForumThreadWidget::setAllMessagesRead(bool read)
|
||||
{
|
||||
markMsgAsReadUnread(read, true, true);
|
||||
}
|
||||
@ -1683,7 +1683,7 @@ void GxsForumThreadWidget::requestGroup_CurrentForum(const RsGxsGroupId &forumId
|
||||
ui->progressBar->reset();
|
||||
mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, true);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, true);
|
||||
emit forumChanged(this);
|
||||
emit groupChanged(this);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
@ -1723,7 +1723,7 @@ void GxsForumThreadWidget::loadGroup_CurrentForum(const uint32_t &token)
|
||||
mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_CURRENTFORUM);
|
||||
mStateHelper->clear(TOKEN_TYPE_INSERT_POST);
|
||||
emit forumChanged(this);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef GXSFORUMTHREADWIDGET_H
|
||||
#define GXSFORUMTHREADWIDGET_H
|
||||
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastWidget.h"
|
||||
#include "gui/gxs/GxsMessageFrameWidget.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
class QTreeWidgetItem;
|
||||
@ -15,7 +15,7 @@ namespace Ui {
|
||||
class GxsForumThreadWidget;
|
||||
}
|
||||
|
||||
class GxsForumThreadWidget : public RsGxsUpdateBroadcastWidget, public TokenResponse
|
||||
class GxsForumThreadWidget : public GxsMessageFrameWidget, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -41,24 +41,21 @@ public:
|
||||
void setTextColorNotSubscribed(QColor color) { mTextColorNotSubscribed = color; }
|
||||
void setTextColorMissing(QColor color) { mTextColorMissing = color; }
|
||||
|
||||
RsGxsGroupId forumId() { return mForumId; }
|
||||
void setForumId(const RsGxsGroupId &forumId);
|
||||
QString forumName(bool withUnreadCount);
|
||||
QIcon forumIcon();
|
||||
virtual RsGxsGroupId groupId() { return mForumId; }
|
||||
virtual void setGroupId(const RsGxsGroupId &forumId);
|
||||
virtual QString groupName(bool withUnreadCount);
|
||||
virtual QIcon groupIcon();
|
||||
unsigned int newCount() { return mNewCount; }
|
||||
unsigned int unreadCount() { return mUnreadCount; }
|
||||
|
||||
QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn);
|
||||
QTreeWidgetItem *generateMissingItem(const RsGxsMessageId &msgId);
|
||||
|
||||
void setAllMsgReadStatus(bool read);
|
||||
virtual void setAllMessagesRead(bool read);
|
||||
|
||||
// Callback for all Loads.
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
signals:
|
||||
void forumChanged(QWidget *widget);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
void changeEvent(QEvent *e);
|
||||
|
@ -1,791 +0,0 @@
|
||||
/****************************************************************
|
||||
* 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 <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QToolButton>
|
||||
|
||||
#include "GxsForumsDialog.h"
|
||||
#include "GxsForumGroupDialog.h"
|
||||
#include "GxsForumThreadWidget.h"
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/channels/ShareKey.h"
|
||||
#include "gui/common/RSTreeWidget.h"
|
||||
#include "gui/notifyqt.h"
|
||||
//#include "gui/common/UIStateHelper.h"
|
||||
|
||||
// These should be in retroshare/ folder.
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
|
||||
//#define DEBUG_FORUMS
|
||||
|
||||
/* Images for TreeWidget */
|
||||
#define IMAGE_FOLDER ":/images/folder16.png"
|
||||
#define IMAGE_FOLDERGREEN ":/images/folder_green.png"
|
||||
#define IMAGE_FOLDERRED ":/images/folder_red.png"
|
||||
#define IMAGE_FOLDERYELLOW ":/images/folder_yellow.png"
|
||||
#define IMAGE_FORUM ":/images/konversation.png"
|
||||
#define IMAGE_SUBSCRIBE ":/images/edit_add24.png"
|
||||
#define IMAGE_UNSUBSCRIBE ":/images/cancel.png"
|
||||
#define IMAGE_INFO ":/images/info16.png"
|
||||
#define IMAGE_NEWFORUM ":/images/new_forum16.png"
|
||||
#define IMAGE_FORUMAUTHD ":/images/konv_message2.png"
|
||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||
|
||||
#define TOKEN_TYPE_LISTING 1
|
||||
#define TOKEN_TYPE_SUBSCRIBE_CHANGE 2
|
||||
//#define TOKEN_TYPE_CURRENTFORUM 3
|
||||
|
||||
/*
|
||||
* Transformation Notes:
|
||||
* there are still a couple of things that the new forums differ from Old version.
|
||||
* these will need to be addressed in the future.
|
||||
* -> Child TS (for sorting) is not handled by GXS, this will probably have to be done in the GUI.
|
||||
* -> Need to handle IDs properly.
|
||||
* -> Popularity not handled in GXS yet.
|
||||
* -> Much more to do.
|
||||
*/
|
||||
|
||||
/** Constructor */
|
||||
GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
||||
: RsGxsUpdateBroadcastPage(rsGxsForums, parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
/* Setup Queue */
|
||||
mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
||||
mThreadWidget = NULL;
|
||||
|
||||
/* Setup UI helper */
|
||||
// mStateHelper = new UIStateHelper(this);
|
||||
// no widget to add yet
|
||||
|
||||
connect(ui.forumTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(forumListCustomPopupMenu(QPoint)));
|
||||
connect(ui.forumTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(changedForum(QString)));
|
||||
connect(ui.forumTreeWidget->treeWidget(), SIGNAL(signalMouseMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(forumTreeMiddleButtonClicked(QTreeWidgetItem*)));
|
||||
connect(ui.threadTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(threadTabCloseRequested(int)));
|
||||
connect(ui.threadTabWidget, SIGNAL(currentChanged(int)), this, SLOT(threadTabChanged(int)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
||||
|
||||
connect(ui.todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
|
||||
|
||||
/* Initialize group tree */
|
||||
QToolButton *newForumButton = new QToolButton(this);
|
||||
newForumButton->setIcon(QIcon(":/images/new_forum16.png"));
|
||||
newForumButton->setToolTip(tr("Create Forum"));
|
||||
connect(newForumButton, SIGNAL(clicked()), this, SLOT(newforum()));
|
||||
ui.forumTreeWidget->addToolButton(newForumButton);
|
||||
|
||||
/* Set initial size the splitter */
|
||||
QList<int> sizes;
|
||||
sizes << 300 << width(); // Qt calculates the right sizes
|
||||
ui.splitter->setSizes(sizes);
|
||||
|
||||
/* create forum tree */
|
||||
yourForums = ui.forumTreeWidget->addCategoryItem(tr("My Forums"), QIcon(IMAGE_FOLDER), true);
|
||||
subscribedForums = ui.forumTreeWidget->addCategoryItem(tr("Subscribed Forums"), QIcon(IMAGE_FOLDERRED), true);
|
||||
popularForums = ui.forumTreeWidget->addCategoryItem(tr("Popular Forums"), QIcon(IMAGE_FOLDERGREEN), false);
|
||||
otherForums = ui.forumTreeWidget->addCategoryItem(tr("Other Forums"), QIcon(IMAGE_FOLDERYELLOW), false);
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
settingsChanged();
|
||||
}
|
||||
|
||||
GxsForumsDialog::~GxsForumsDialog()
|
||||
{
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
||||
delete(mForumQueue);
|
||||
}
|
||||
|
||||
//UserNotify *GxsForumsDialog::getUserNotify(QObject *parent)
|
||||
//{
|
||||
// return new GxsForumUserNotify(parent);
|
||||
//}
|
||||
|
||||
void GxsForumsDialog::todo()
|
||||
{
|
||||
QMessageBox::information(this, "Todo",
|
||||
"<b>Open points:</b><ul>"
|
||||
"<li>Restore forum keys"
|
||||
"<li>Display AUTHD"
|
||||
"<li>Copy/navigate forum link"
|
||||
"<li>Display author of post"
|
||||
"<li>Display count of unread messages"
|
||||
"<li>Don't show own posts as unread"
|
||||
"<li>Remove messages"
|
||||
"</ul>");
|
||||
}
|
||||
|
||||
void GxsForumsDialog::processSettings(bool load)
|
||||
{
|
||||
Settings->beginGroup(QString("GxsForumsDialog"));
|
||||
|
||||
if (load) {
|
||||
// load settings
|
||||
|
||||
// state of splitter
|
||||
ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
|
||||
} else {
|
||||
// save settings
|
||||
|
||||
// state of splitter
|
||||
Settings->setValue("Splitter", ui.splitter->saveState());
|
||||
}
|
||||
|
||||
ui.forumTreeWidget->processSettings(Settings, load);
|
||||
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
void GxsForumsDialog::settingsChanged()
|
||||
{
|
||||
if (Settings->getForumOpenAllInNewTab()) {
|
||||
if (mThreadWidget) {
|
||||
delete(mThreadWidget);
|
||||
mThreadWidget = NULL;
|
||||
}
|
||||
} else {
|
||||
if (!mThreadWidget) {
|
||||
mThreadWidget = createThreadWidget(RsGxsGroupId());
|
||||
// remove close button of the the first tab
|
||||
ui.threadTabWidget->hideCloseButton(ui.threadTabWidget->indexOf(mThreadWidget));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/)
|
||||
{
|
||||
int subscribeFlags = ui.forumTreeWidget->subscribeFlags(QString::fromStdString(mForumId.toStdString()));
|
||||
|
||||
QMenu contextMnu(this);
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "GxsForumsDialog::forumListCustomPopupMenu()";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << " mForumId: " << mForumId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << " subscribeFlags: " << subscribeFlags;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << " IS_GROUP_SUBSCRIBED(): " << IS_GROUP_SUBSCRIBED(subscribeFlags);
|
||||
std::cerr << std::endl;
|
||||
std::cerr << " IS_GROUP_ADMIN(): " << IS_GROUP_ADMIN(subscribeFlags);
|
||||
std::cerr << std::endl;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe to Forum"), this, SLOT(subscribeToForum()));
|
||||
action->setDisabled (mForumId.isNull() || IS_GROUP_SUBSCRIBED(subscribeFlags));
|
||||
|
||||
action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Forum"), this, SLOT(unsubscribeToForum()));
|
||||
action->setEnabled (!mForumId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
||||
|
||||
if (!Settings->getForumOpenAllInNewTab()) {
|
||||
action = contextMnu.addAction(QIcon(""), tr("Open in new tab"), this, SLOT(openInNewTab()));
|
||||
if (mForumId.isNull() || forumThreadWidget(mForumId)) {
|
||||
action->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
contextMnu.addSeparator();
|
||||
|
||||
contextMnu.addAction(QIcon(IMAGE_NEWFORUM), tr("New Forum"), this, SLOT(newforum()));
|
||||
|
||||
action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Forum Details"), this, SLOT(showForumDetails()));
|
||||
action->setEnabled (!mForumId.isNull());
|
||||
|
||||
action = contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Edit Forum Details"), this, SLOT(editForumDetails()));
|
||||
action->setEnabled (!mForumId.isNull() && IS_GROUP_ADMIN(subscribeFlags));
|
||||
|
||||
QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Forum"), &contextMnu);
|
||||
connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );
|
||||
shareKeyAct->setEnabled(!mForumId.isNull() && IS_GROUP_ADMIN(subscribeFlags));
|
||||
contextMnu.addAction( shareKeyAct);
|
||||
|
||||
QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Forum" ), &contextMnu);
|
||||
connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreForumKeys() ) );
|
||||
restoreKeysAct->setEnabled(!mForumId.isNull() && !IS_GROUP_ADMIN(subscribeFlags));
|
||||
contextMnu.addAction( restoreKeysAct);
|
||||
|
||||
action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyForumLink()));
|
||||
action->setEnabled(!mForumId.isNull());
|
||||
|
||||
contextMnu.addSeparator();
|
||||
|
||||
action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead()));
|
||||
action->setEnabled (!mForumId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
||||
|
||||
action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread()));
|
||||
action->setEnabled (!mForumId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void GxsForumsDialog::restoreForumKeys(void)
|
||||
{
|
||||
QMessageBox::warning(this, "RetroShare", "ToDo");
|
||||
|
||||
#ifdef TOGXS
|
||||
rsGxsForums->groupRestoreKeys(mCurrForumId);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsForumsDialog::updateDisplay(bool complete)
|
||||
{
|
||||
if (complete || !getGrpIds().empty()) {
|
||||
/* Update forums list */
|
||||
insertForums();
|
||||
}
|
||||
}
|
||||
|
||||
void GxsForumsDialog::forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo)
|
||||
{
|
||||
groupItemInfo.id = QString::fromStdString(forumInfo.mGroupId.toStdString());
|
||||
groupItemInfo.name = QString::fromUtf8(forumInfo.mGroupName.c_str());
|
||||
//groupItemInfo.description = QString::fromUtf8(forumInfo.forumDesc);
|
||||
groupItemInfo.popularity = forumInfo.mPop;
|
||||
groupItemInfo.lastpost = QDateTime::fromTime_t(forumInfo.mLastPost);
|
||||
groupItemInfo.subscribeFlags = forumInfo.mSubscribeFlags;
|
||||
|
||||
#if TOGXS
|
||||
if (forumInfo.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) {
|
||||
groupItemInfo.name += " (" + tr("AUTHD") + ")";
|
||||
groupItemInfo.icon = QIcon(IMAGE_FORUMAUTHD);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
groupItemInfo.icon = QIcon(IMAGE_FORUM);
|
||||
}
|
||||
}
|
||||
|
||||
/***** INSERT FORUM LISTS *****/
|
||||
void GxsForumsDialog::insertForumsData(const std::list<RsGroupMetaData> &forumList)
|
||||
{
|
||||
std::list<RsGroupMetaData>::const_iterator it;
|
||||
|
||||
QList<GroupItemInfo> adminList;
|
||||
QList<GroupItemInfo> subList;
|
||||
QList<GroupItemInfo> popList;
|
||||
QList<GroupItemInfo> otherList;
|
||||
std::multimap<uint32_t, GroupItemInfo> popMap;
|
||||
|
||||
for (it = forumList.begin(); it != forumList.end(); it++) {
|
||||
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
||||
uint32_t flags = it->mSubscribeFlags;
|
||||
|
||||
GroupItemInfo groupItemInfo;
|
||||
forumInfoToGroupItemInfo(*it, groupItemInfo);
|
||||
|
||||
if (IS_GROUP_SUBSCRIBED(flags))
|
||||
{
|
||||
if (IS_GROUP_ADMIN(flags))
|
||||
{
|
||||
adminList.push_back(groupItemInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* subscribed forum */
|
||||
subList.push_back(groupItemInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rate the others by popularity */
|
||||
popMap.insert(std::make_pair(it->mPop, groupItemInfo));
|
||||
}
|
||||
}
|
||||
|
||||
/* iterate backwards through popMap - take the top 5 or 10% of list */
|
||||
uint32_t popCount = 5;
|
||||
if (popCount < popMap.size() / 10)
|
||||
{
|
||||
popCount = popMap.size() / 10;
|
||||
}
|
||||
|
||||
uint32_t i = 0;
|
||||
uint32_t popLimit = 0;
|
||||
std::multimap<uint32_t, GroupItemInfo>::reverse_iterator rit;
|
||||
for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) ;
|
||||
if (rit != popMap.rend()) {
|
||||
popLimit = rit->first;
|
||||
}
|
||||
|
||||
for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) {
|
||||
if (rit->second.popularity < (int) popLimit) {
|
||||
otherList.append(rit->second);
|
||||
} else {
|
||||
popList.append(rit->second);
|
||||
}
|
||||
}
|
||||
|
||||
/* now we can add them in as a tree! */
|
||||
ui.forumTreeWidget->fillGroupItems(yourForums, adminList);
|
||||
ui.forumTreeWidget->fillGroupItems(subscribedForums, subList);
|
||||
ui.forumTreeWidget->fillGroupItems(popularForums, popList);
|
||||
ui.forumTreeWidget->fillGroupItems(otherForums, otherList);
|
||||
|
||||
updateMessageSummaryList(RsGxsGroupId());
|
||||
}
|
||||
|
||||
GxsForumThreadWidget *GxsForumsDialog::forumThreadWidget(const RsGxsGroupId &forumId)
|
||||
{
|
||||
int tabCount = ui.threadTabWidget->count();
|
||||
for (int index = 0; index < tabCount; ++index) {
|
||||
GxsForumThreadWidget *childWidget = dynamic_cast<GxsForumThreadWidget*>(ui.threadTabWidget->widget(index));
|
||||
if (mThreadWidget && childWidget == mThreadWidget) {
|
||||
continue;
|
||||
}
|
||||
if (childWidget && childWidget->forumId() == forumId) {
|
||||
return childWidget;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GxsForumThreadWidget *GxsForumsDialog::createThreadWidget(const RsGxsGroupId &forumId)
|
||||
{
|
||||
GxsForumThreadWidget *threadWidget = new GxsForumThreadWidget(forumId);
|
||||
int index = ui.threadTabWidget->addTab(threadWidget, threadWidget->forumName(true));
|
||||
ui.threadTabWidget->setTabIcon(index, threadWidget->forumIcon());
|
||||
connect(threadWidget, SIGNAL(forumChanged(QWidget*)), this, SLOT(threadTabInfoChanged(QWidget*)));
|
||||
|
||||
return threadWidget;
|
||||
}
|
||||
|
||||
void GxsForumsDialog::changedForum(const QString &forumId)
|
||||
{
|
||||
mForumId = RsGxsGroupId(forumId.toStdString());
|
||||
if (mForumId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// requestGroupSummary_CurrentForum(mForumId);
|
||||
|
||||
/* search exisiting tab */
|
||||
GxsForumThreadWidget *threadWidget = forumThreadWidget(mForumId);
|
||||
|
||||
if (!threadWidget) {
|
||||
if (mThreadWidget) {
|
||||
/* not found, use standard tab */
|
||||
threadWidget = mThreadWidget;
|
||||
threadWidget->setForumId(mForumId);
|
||||
} else {
|
||||
/* create new tab */
|
||||
threadWidget = createThreadWidget(mForumId);
|
||||
}
|
||||
}
|
||||
|
||||
ui.threadTabWidget->setCurrentWidget(threadWidget);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::forumTreeMiddleButtonClicked(QTreeWidgetItem *item)
|
||||
{
|
||||
openForumInNewTab(RsGxsGroupId(ui.forumTreeWidget->itemId(item).toStdString()));
|
||||
}
|
||||
|
||||
void GxsForumsDialog::openInNewTab()
|
||||
{
|
||||
openForumInNewTab(mForumId);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::openForumInNewTab(const RsGxsGroupId &forumId)
|
||||
{
|
||||
if (forumId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* search exisiting tab */
|
||||
GxsForumThreadWidget *threadWidget = forumThreadWidget(forumId);
|
||||
if (!threadWidget) {
|
||||
/* not found, create new tab */
|
||||
threadWidget = createThreadWidget(forumId);
|
||||
}
|
||||
|
||||
ui.threadTabWidget->setCurrentWidget(threadWidget);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::threadTabCloseRequested(int index)
|
||||
{
|
||||
GxsForumThreadWidget *threadWidget = dynamic_cast<GxsForumThreadWidget*>(ui.threadTabWidget->widget(index));
|
||||
if (!threadWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (threadWidget == mThreadWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete(threadWidget);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::threadTabChanged(int index)
|
||||
{
|
||||
GxsForumThreadWidget *threadWidget = dynamic_cast<GxsForumThreadWidget*>(ui.threadTabWidget->widget(index));
|
||||
if (!threadWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui.forumTreeWidget->activateId(QString::fromStdString(threadWidget->forumId().toStdString()), false);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::threadTabInfoChanged(QWidget *widget)
|
||||
{
|
||||
int index = ui.threadTabWidget->indexOf(widget);
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
GxsForumThreadWidget *threadWidget = dynamic_cast<GxsForumThreadWidget*>(ui.threadTabWidget->widget(index));
|
||||
if (!threadWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui.threadTabWidget->setTabText(index, threadWidget->forumName(true));
|
||||
ui.threadTabWidget->setTabIcon(index, threadWidget->forumIcon());
|
||||
}
|
||||
|
||||
void GxsForumsDialog::copyForumLink()
|
||||
{
|
||||
if (mForumId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// THIS CODE CALLS getForumInfo() to verify that the Ids are valid.
|
||||
// As we are switching to Request/Response this is now harder to do...
|
||||
// So not bothering any more - shouldn't be necessary.
|
||||
// IF we get errors - fix them, rather than patching here.
|
||||
#if 0
|
||||
ForumInfo fi;
|
||||
if (rsGxsForums->getForumInfo(mCurrForumId, fi)) {
|
||||
RetroShareLink link;
|
||||
if (link.createForum(fi.forumId, "")) {
|
||||
QList<RetroShareLink> urls;
|
||||
urls.push_back(link);
|
||||
RSLinkClipboard::copyLinks(urls);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QMessageBox::warning(this, "RetroShare", "ToDo");
|
||||
}
|
||||
|
||||
void GxsForumsDialog::markMsgAsRead()
|
||||
{
|
||||
GxsForumThreadWidget *threadWidget = forumThreadWidget(mForumId);
|
||||
if (threadWidget) {
|
||||
threadWidget->setAllMsgReadStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsForumsDialog::markMsgAsUnread()
|
||||
{
|
||||
GxsForumThreadWidget *threadWidget = forumThreadWidget(mForumId);
|
||||
if (threadWidget) {
|
||||
threadWidget->setAllMsgReadStatus(false);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsForumsDialog::newforum()
|
||||
{
|
||||
GxsForumGroupDialog cf(mForumQueue, this);
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
void GxsForumsDialog::subscribeToForum()
|
||||
{
|
||||
forumSubscribe(true);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::unsubscribeToForum()
|
||||
{
|
||||
forumSubscribe(false);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::forumSubscribe(bool subscribe)
|
||||
{
|
||||
if (mForumId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t token;
|
||||
rsGxsForums->subscribeToGroup(token, mForumId, subscribe);
|
||||
mForumQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_SUBSCRIBE_CHANGE);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::showForumDetails()
|
||||
{
|
||||
if (mForumId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GxsForumGroupDialog cf(mForumQueue, rsGxsForums->getTokenService(), GxsGroupDialog::MODE_SHOW, mForumId, this);
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
void GxsForumsDialog::editForumDetails()
|
||||
{
|
||||
if (mForumId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RsGxsForumGroup grp;
|
||||
grp.mMeta.mGroupId = mForumId;
|
||||
|
||||
GxsForumGroupDialog cf(mForumQueue, rsGxsForums->getTokenService(), GxsGroupDialog::MODE_EDIT, mForumId, this);
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
void GxsForumsDialog::shareKey()
|
||||
{
|
||||
ShareKey shareUi(this, mForumId.toStdString(), FORUM_KEY_SHARE);
|
||||
shareUi.exec();
|
||||
}
|
||||
|
||||
void GxsForumsDialog::updateMessageSummaryList( RsGxsGroupId forumId)
|
||||
{
|
||||
QTreeWidgetItem *items[2] = { yourForums, subscribedForums };
|
||||
|
||||
for (int item = 0; item < 2; item++) {
|
||||
int child;
|
||||
int childCount = items[item]->childCount();
|
||||
for (child = 0; child < childCount; child++) {
|
||||
QTreeWidgetItem *childItem = items[item]->child(child);
|
||||
std::string childId = ui.forumTreeWidget->itemId(childItem).toStdString();
|
||||
if (childId.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (forumId.isNull() || childId == forumId.toStdString()) {
|
||||
/* calculate unread messages */
|
||||
unsigned int newMessageCount = 0;
|
||||
unsigned int unreadMessageCount = 0;
|
||||
|
||||
//#TODO rsGxsForums->getMessageCount(childId, newMessageCount, unreadMessageCount);
|
||||
|
||||
std::cerr << "IMPLEMENT rsGxsForums->getMessageCount()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
ui.forumTreeWidget->setUnreadCount(childItem, unreadMessageCount);
|
||||
|
||||
if (forumId.isNull() == false) {
|
||||
/* Calculate only this forum */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GxsForumsDialog::navigate(const RsGxsGroupId forumId, const std::string& msgId)
|
||||
{
|
||||
if (forumId.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ui.forumTreeWidget->activateId(QString::fromStdString(forumId.toStdString()), msgId.empty()) == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Threads are filled in changedForum */
|
||||
if (mForumId != forumId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (msgId.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//#TODO
|
||||
// if (mThreadLoading) {
|
||||
// mThreadLoad.FocusMsgId = msgId;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
/* Search exisiting item */
|
||||
// QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget);
|
||||
// QTreeWidgetItem *item = NULL;
|
||||
// while ((item = *itemIterator) != NULL) {
|
||||
// itemIterator++;
|
||||
|
||||
// if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) {
|
||||
// ui.threadTreeWidget->setCurrentItem(item);
|
||||
// ui.threadTreeWidget->setFocus();
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/** Request / Response of Data ********************************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsForumsDialog::insertForums()
|
||||
{
|
||||
requestGroupSummary();
|
||||
}
|
||||
|
||||
void GxsForumsDialog::requestGroupSummary()
|
||||
{
|
||||
// mStateHelper->setLoading(TOKEN_TYPE_LISTING, true);
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "GxsForumsDialog::requestGroupSummary()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mForumQueue->cancelActiveRequestTokens(TOKEN_TYPE_LISTING);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_LISTING);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::loadGroupSummary(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "GxsForumsDialog::loadGroupSummary()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::list<RsGroupMetaData> groupInfo;
|
||||
rsGxsForums->getGroupSummary(token, groupInfo);
|
||||
|
||||
if (groupInfo.size() > 0)
|
||||
{
|
||||
// mStateHelper->setActive(TOKEN_TYPE_LISTING, true);
|
||||
|
||||
insertForumsData(groupInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsForumsDialog::loadGroupSummary() ERROR No Groups...";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// mStateHelper->setActive(TOKEN_TYPE_LISTING, false);
|
||||
}
|
||||
|
||||
// mStateHelper->setLoading(TOKEN_TYPE_LISTING, false);
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsForumsDialog::acknowledgeSubscribeChange(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "GxsForumsDialog::acknowledgeSubscribeChange()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RsGxsGroupId groupId;
|
||||
rsGxsForums->acknowledgeGrp(token, groupId);
|
||||
|
||||
insertForums();
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
//void GxsForumsDialog::requestGroupSummary_CurrentForum(const RsGxsGroupId &forumId)
|
||||
//{
|
||||
// RsTokReqOptions opts;
|
||||
// opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
// std::list<std::string> grpIds;
|
||||
// grpIds.push_back(forumId);
|
||||
|
||||
// std::cerr << "GxsForumsDialog::requestGroupSummary_CurrentForum(" << forumId << ")";
|
||||
// std::cerr << std::endl;
|
||||
|
||||
// uint32_t token;
|
||||
// mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, TOKEN_TYPE_CURRENTFORUM);
|
||||
//}
|
||||
|
||||
//void GxsForumsDialog::loadGroupSummary_CurrentForum(const uint32_t &token)
|
||||
//{
|
||||
// std::cerr << "GxsForumsDialog::loadGroupSummary_CurrentForum()";
|
||||
// std::cerr << std::endl;
|
||||
|
||||
// std::list<RsGroupMetaData> groupInfo;
|
||||
// rsGxsForums->getGroupSummary(token, groupInfo);
|
||||
|
||||
// if (groupInfo.size() == 1)
|
||||
// {
|
||||
// RsGroupMetaData fi = groupInfo.front();
|
||||
// mSubscribeFlags = fi.mSubscribeFlags;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// resetData();
|
||||
// std::cerr << "GxsForumsDialog::loadGroupSummary_CurrentForum() ERROR Invalid Number of Groups...";
|
||||
// std::cerr << std::endl;
|
||||
// }
|
||||
|
||||
// setValid(true);
|
||||
//}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsForumsDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "GxsForumsDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (queue == mForumQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
{
|
||||
case TOKEN_TYPE_LISTING:
|
||||
loadGroupSummary(req.mToken);
|
||||
break;
|
||||
|
||||
case TOKEN_TYPE_SUBSCRIBE_CHANGE:
|
||||
acknowledgeSubscribeChange(req.mToken);
|
||||
break;
|
||||
|
||||
// case TOKEN_TYPE_CURRENTFORUM:
|
||||
// loadGroupSummary_CurrentForum(req.mToken);
|
||||
// break;
|
||||
|
||||
default:
|
||||
std::cerr << "GxsForumsDialog::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
/****************************************************************
|
||||
* 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 _GXSFORUMSDIALOG_H
|
||||
#define _GXSFORUMSDIALOG_H
|
||||
|
||||
#include <QThread>
|
||||
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "ui_GxsForumsDialog.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
||||
|
||||
class ForumInfo;
|
||||
class RsGxsForumMsg;
|
||||
class GxsForumThreadWidget;
|
||||
class UIStateHelper;
|
||||
|
||||
class GxsForumsDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GxsForumsDialog(QWidget *parent = 0);
|
||||
~GxsForumsDialog();
|
||||
|
||||
// virtual UserNotify *getUserNotify(QObject *parent);
|
||||
|
||||
bool navigate(const RsGxsGroupId forumId, const std::string& msgId);
|
||||
|
||||
// Callback for all Loads.
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
protected:
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
private slots:
|
||||
void settingsChanged();
|
||||
void todo();
|
||||
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void forumListCustomPopupMenu( QPoint point );
|
||||
|
||||
void restoreForumKeys();
|
||||
void newforum();
|
||||
|
||||
void changedForum(const QString &forumId);
|
||||
void forumTreeMiddleButtonClicked(QTreeWidgetItem *item);
|
||||
void openInNewTab();
|
||||
void threadTabCloseRequested(int index);
|
||||
void threadTabChanged(int index);
|
||||
void threadTabInfoChanged(QWidget *widget);
|
||||
|
||||
void copyForumLink();
|
||||
|
||||
void subscribeToForum();
|
||||
void unsubscribeToForum();
|
||||
|
||||
void showForumDetails();
|
||||
void editForumDetails();
|
||||
|
||||
void markMsgAsRead();
|
||||
void markMsgAsUnread();
|
||||
|
||||
void shareKey();
|
||||
|
||||
private:
|
||||
void insertForums();
|
||||
|
||||
void updateMessageSummaryList( RsGxsGroupId forumId);
|
||||
// void forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo);
|
||||
void forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo);
|
||||
|
||||
void openForumInNewTab(const RsGxsGroupId &forumId);
|
||||
void forumSubscribe(bool subscribe);
|
||||
|
||||
void processSettings(bool load);
|
||||
|
||||
// New Request/Response Loading Functions.
|
||||
void insertForumsData(const std::list<RsGroupMetaData> &forumList);
|
||||
|
||||
void requestGroupSummary();
|
||||
void loadGroupSummary(const uint32_t &token);
|
||||
|
||||
// subscribe/unsubscribe ack.
|
||||
void acknowledgeSubscribeChange(const uint32_t &token);
|
||||
|
||||
GxsForumThreadWidget *forumThreadWidget(const RsGxsGroupId &forumId);
|
||||
GxsForumThreadWidget *createThreadWidget(const RsGxsGroupId &forumId);
|
||||
|
||||
// void requestGroupSummary_CurrentForum(const RsGxsGroupId &forumId);
|
||||
// void loadGroupSummary_CurrentForum(const uint32_t &token);
|
||||
|
||||
RsGxsGroupId mForumId;
|
||||
TokenQueue *mForumQueue;
|
||||
GxsForumThreadWidget *mThreadWidget;
|
||||
|
||||
QTreeWidgetItem *yourForums;
|
||||
QTreeWidgetItem *subscribedForums;
|
||||
QTreeWidgetItem *popularForums;
|
||||
QTreeWidgetItem *otherForums;
|
||||
|
||||
// UIStateHelper *mStateHelper;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::GxsForumsDialog ui;
|
||||
};
|
||||
|
||||
#endif
|
@ -1121,8 +1121,7 @@ gxsforums {
|
||||
gui/gxsforums/GxsForumThreadWidget.h \
|
||||
gui/gxsforums/GxsForumsFillThread.h
|
||||
|
||||
FORMS += gui/gxsforums/GxsForumsDialog.ui \
|
||||
gui/gxsforums/CreateGxsForumMsg.ui \
|
||||
FORMS += gui/gxsforums/CreateGxsForumMsg.ui \
|
||||
gui/gxsforums/GxsForumThreadWidget.ui
|
||||
|
||||
SOURCES += gui/gxsforums/GxsForumsDialog.cpp \
|
||||
@ -1139,16 +1138,18 @@ gxschannels {
|
||||
gui/gxschannels/GxsChannelGroupDialog.h \
|
||||
gui/gxschannels/CreateGxsChannelMsg.h \
|
||||
gui/gxschannels/ChannelDialog.h \
|
||||
gui/feeds/GxsChannelPostItem.h \
|
||||
gui/gxschannels/GxsChannelPostsWidget.h \
|
||||
gui/feeds/GxsChannelPostItem.h
|
||||
|
||||
FORMS += gui/gxschannels/GxsChannelDialog.ui \
|
||||
FORMS += gui/gxschannels/GxsChannelPostsWidget.ui \
|
||||
gui/gxschannels/CreateGxsChannelMsg.ui \
|
||||
gui/feeds/GxsChannelPostItem.ui \
|
||||
gui/feeds/GxsChannelPostItem.ui
|
||||
|
||||
SOURCES += gui/gxschannels/GxsChannelDialog.cpp \
|
||||
gui/gxschannels/GxsChannelPostsWidget.cpp \
|
||||
gui/gxschannels/GxsChannelGroupDialog.cpp \
|
||||
gui/gxschannels/CreateGxsChannelMsg.cpp \
|
||||
gui/feeds/GxsChannelPostItem.cpp \
|
||||
gui/feeds/GxsChannelPostItem.cpp
|
||||
}
|
||||
|
||||
|
||||
@ -1199,6 +1200,8 @@ gxsgui {
|
||||
gui/gxs/GxsCommentContainer.h \
|
||||
gui/gxs/GxsCommentDialog.h \
|
||||
gui/gxs/GxsCreateCommentDialog.h \
|
||||
gui/gxs/GxsGroupFrameDialog.h \
|
||||
gui/gxs/GxsMessageFrameWidget.h \
|
||||
gui/gxs/GxsFeedItem.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.h \
|
||||
@ -1212,6 +1215,7 @@ gxsgui {
|
||||
gui/gxs/GxsCommentContainer.ui \
|
||||
gui/gxs/GxsCommentDialog.ui \
|
||||
gui/gxs/GxsCreateCommentDialog.ui \
|
||||
gui/gxs/GxsGroupFrameDialog.ui
|
||||
|
||||
# gui/gxs/GxsMsgDialog.ui \
|
||||
# gui/gxs/GxsCommentTreeWidget.ui \
|
||||
@ -1229,6 +1233,8 @@ gxsgui {
|
||||
gui/gxs/GxsCommentContainer.cpp \
|
||||
gui/gxs/GxsCommentDialog.cpp \
|
||||
gui/gxs/GxsCreateCommentDialog.cpp \
|
||||
gui/gxs/GxsGroupFrameDialog.cpp \
|
||||
gui/gxs/GxsMessageFrameWidget.cpp \
|
||||
gui/gxs/GxsFeedItem.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user