From 30fcab1bffe693b624470bf3605b716742a97414 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Tue, 22 Jul 2014 15:04:36 +0000 Subject: [PATCH] Posted: - Used GxsGroupFrameDialog - Added tabbed interface - Added user notify git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7464 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MainWindow.cpp | 5 +- retroshare-gui/src/gui/MainWindow.h | 5 +- .../src/gui/Posted/PostedCreatePostDialog.cpp | 2 + .../src/gui/Posted/PostedDialog.cpp | 135 +++ retroshare-gui/src/gui/Posted/PostedDialog.h | 65 +- .../src/gui/Posted/PostedListDialog.cpp | 1054 ----------------- .../src/gui/Posted/PostedListDialog.ui | 343 ------ .../src/gui/Posted/PostedListWidget.cpp | 971 +++++++++++++++ ...{PostedListDialog.h => PostedListWidget.h} | 118 +- .../src/gui/Posted/PostedListWidget.ui | 332 ++++++ .../src/gui/Posted/PostedUserNotify.cpp | 94 ++ .../src/gui/Posted/PostedUserNotify.h | 46 + .../src/gui/gxs/GxsGroupFrameDialog.cpp | 12 +- .../gui/gxschannels/GxsChannelPostsWidget.cpp | 34 +- .../gui/gxschannels/GxsChannelPostsWidget.h | 6 +- .../gui/gxsforums/GxsForumThreadWidget.cpp | 8 +- .../src/gui/gxsforums/GxsForumThreadWidget.h | 2 +- .../src/gui/settings/rsharesettings.cpp | 2 +- .../src/gui/settings/rsharesettings.h | 4 + retroshare-gui/src/retroshare-gui.pro | 11 +- 20 files changed, 1703 insertions(+), 1546 deletions(-) create mode 100644 retroshare-gui/src/gui/Posted/PostedDialog.cpp delete mode 100644 retroshare-gui/src/gui/Posted/PostedListDialog.cpp delete mode 100644 retroshare-gui/src/gui/Posted/PostedListDialog.ui create mode 100644 retroshare-gui/src/gui/Posted/PostedListWidget.cpp rename retroshare-gui/src/gui/Posted/{PostedListDialog.h => PostedListWidget.h} (50%) create mode 100644 retroshare-gui/src/gui/Posted/PostedListWidget.ui create mode 100644 retroshare-gui/src/gui/Posted/PostedUserNotify.cpp create mode 100644 retroshare-gui/src/gui/Posted/PostedUserNotify.h diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index edf315b68..742f4262c 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -412,9 +412,7 @@ void MainWindow::initStackedPage() //notify.push_back(QPair(gxsforumDialog, action)); addPage(gxsforumDialog = new GxsForumsDialog(ui->stackPages), grp, ¬ify); - PostedDialog *postedDialog = NULL; addPage(postedDialog = new PostedDialog(ui->stackPages), grp, ¬ify); - postedDialog->setup(); WikiDialog *wikiDialog = NULL; addPage(wikiDialog = new WikiDialog(ui->stackPages), grp, ¬ify); @@ -960,6 +958,9 @@ void SetForegroundWindowInternal(HWND hWnd) Page = _instance->blogsFeed; return true ; #endif + case Posted: + _instance->ui->stackPages->setCurrentPage( _instance->postedDialog ); + return true ; default: std::cerr << "Show page called on value that is not handled yet. Please code it! (value = " << page << ")" << std::endl; } diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index ea65da296..cdb4aeaf2 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -48,6 +48,7 @@ class ToasterDisable; //class ForumsDialog; class GxsChannelDialog ; class GxsForumsDialog ; +class PostedDialog; class FriendsDialog; class ChatLobbyWidget; class ChatDialog; @@ -98,7 +99,8 @@ public: #endif #ifdef RS_USE_LINKS Links = 10, /** Links page. */ -#endif +#endif + Posted = 11, /** Posted links */ }; /** Create main window */ @@ -137,6 +139,7 @@ public: SharedFilesDialog *sharedfilesDialog; GxsChannelDialog *gxschannelDialog ; GxsForumsDialog *gxsforumDialog ; + PostedDialog *postedDialog; // ForumsDialog *forumsDialog; // ChannelFeed *channelFeed; diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp index 0c2d6c31d..9bdc3f952 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp @@ -45,6 +45,8 @@ PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *pos ui->headerFrame->setHeaderImage(QPixmap(":/images/posted_64.png")); ui->headerFrame->setHeaderText(tr("Submit a new Post")); + setAttribute ( Qt::WA_DeleteOnClose, true ); + /* fill in the available OwnIds for signing */ ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId()); } diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.cpp b/retroshare-gui/src/gui/Posted/PostedDialog.cpp new file mode 100644 index 000000000..cdd70f2df --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedDialog.cpp @@ -0,0 +1,135 @@ +/* + * Retroshare Posted Dialog + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#include "PostedDialog.h" +#include "PostedItem.h" +#include "PostedGroupDialog.h" +#include "PostedListWidget.h" +#include "PostedUserNotify.h" +//#include "gui/channels/ShareKey.h" +//#include "gui/settings/rsharesettings.h" +//#include "gui/notifyqt.h" + +#include + +/** Constructor */ +PostedDialog::PostedDialog(QWidget *parent) + : GxsGroupFrameDialog(rsPosted, parent) +{ +// connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); + + settingsChanged(); +} + +PostedDialog::~PostedDialog() +{ +} + +UserNotify *PostedDialog::getUserNotify(QObject *parent) +{ + return new PostedUserNotify(rsPosted, parent); +} + +QString PostedDialog::text(TextType type) +{ + switch (type) { + case TEXT_NAME: + return tr("Posted Links"); + case TEXT_NEW: + return tr("Create Topic"); + case TEXT_TODO: + return "Open points:
    " + "
  • Subreddits/tag to posts support" + "
  • Picture Support" + "
"; + + case TEXT_YOUR_GROUP: + return tr("My Topics"); + case TEXT_SUBSCRIBED_GROUP: + return tr("Subscribed Topics"); + case TEXT_POPULAR_GROUP: + return tr("Popular Topics"); + case TEXT_OTHER_GROUP: + return tr("Other Topics"); + } + + return ""; +} + +QString PostedDialog::icon(IconType type) +{ + switch (type) { + case ICON_NAME: + return ":/images/posted_24.png"; + case ICON_NEW: + return ":/images/posted_add_24.png"; + case ICON_YOUR_GROUP: + return ":/images/folder16.png"; + case ICON_SUBSCRIBED_GROUP: + return ":/images/folder_red.png"; + case ICON_POPULAR_GROUP: + return ":/images/folder_green.png"; + case ICON_OTHER_GROUP: + return ":/images/folder_yellow.png"; + case ICON_DEFAULT: + return ""; + } + + return ""; +} + +void PostedDialog::settingsChanged() +{ + setSingleTab(true /*!Settings->getPostedOpenAllInNewTab()*/); + setHideTabBarWithOneTab(true /*Settings->getPostedHideTabBarWithOneTab()*/); +} + +GxsGroupDialog *PostedDialog::createNewGroupDialog(TokenQueue *tokenQueue) +{ + return new PostedGroupDialog(tokenQueue, this); +} + +GxsGroupDialog *PostedDialog::createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) +{ + return new PostedGroupDialog(tokenQueue, tokenService, mode, groupId, this); +} + +int PostedDialog::shareKeyType() +{ + return 0; //POSTED_KEY_SHARE; +} + +GxsMessageFrameWidget *PostedDialog::createMessageFrameWidget(const RsGxsGroupId &groupId) +{ + return new PostedListWidget(groupId); +} + +RsGxsCommentService *PostedDialog::getCommentService() +{ + return rsPosted; +} + +QWidget *PostedDialog::createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId) +{ + return new PostedItem(NULL, 0, grpId, msgId, true); +} diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.h b/retroshare-gui/src/gui/Posted/PostedDialog.h index 1403ccfa7..4dff0b944 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedDialog.h @@ -24,56 +24,43 @@ #ifndef MRK_POSTED_DIALOG_H #define MRK_POSTED_DIALOG_H -#include +#include "gui/gxs/GxsGroupFrameDialog.h" -#include "gui/gxs/GxsCommentContainer.h" -#include "gui/Posted/PostedListDialog.h" -#include "gui/Posted/PostedItem.h" +#define IMAGE_POSTED ":/images/wikibook_32.png" -#define IMAGE_POSTED ":/images/wikibook_32.png" - -class PostedDialog : public GxsCommentContainer +class PostedDialog : public GxsGroupFrameDialog { Q_OBJECT public: - PostedDialog(QWidget *parent = 0) - :GxsCommentContainer(parent) { return; } + /** Default Constructor */ + PostedDialog(QWidget *parent = 0); + /** Default Destructor */ + ~PostedDialog(); - virtual QIcon iconPixmap() const { return QIcon(IMAGE_POSTED) ; } //MainPage - virtual QString pageName() const { return tr("Posted") ; } //MainPage - virtual QString helpText() const { return ""; } //MainPage + virtual QIcon iconPixmap() const { return QIcon(IMAGE_POSTED) ; } //MainPage + virtual QString pageName() const { return tr("Posted") ; } //MainPage + virtual QString helpText() const { return ""; } //MainPage + virtual UserNotify *getUserNotify(QObject *parent); - virtual GxsServiceDialog *createServiceDialog() - { - return new PostedListDialog(this); - } +protected: + virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; } - virtual QString getServiceName() - { - return tr("Posted Links"); - } +private slots: + void settingsChanged(); - virtual RsTokenService *getTokenService() - { - return rsPosted->getTokenService(); - } - - virtual RsGxsCommentService *getCommentService() - { - return rsPosted; - } - - virtual QWidget *createHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId) - { - return new PostedItem(NULL, 0, grpId, msgId, true); - } - - virtual QPixmap getServicePixmap() - { - return QPixmap(":/images/posted_24.png"); - } +private: + /* GxsGroupFrameDialog */ + virtual QString text(TextType type); + virtual QString icon(IconType type); + virtual QString settingsGroupName() { return "PostedDialog"; } + 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 RsGxsCommentService *getCommentService(); + virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId); }; #endif diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.cpp b/retroshare-gui/src/gui/Posted/PostedListDialog.cpp deleted file mode 100644 index edc362c1a..000000000 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.cpp +++ /dev/null @@ -1,1054 +0,0 @@ -/* - * Retroshare Posted List - * - * Copyright 2012-2012 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - -#include "PostedListDialog.h" - -#include "PostedGroupDialog.h" -#include "PostedCreatePostDialog.h" -#include "PostedDialog.h" -#include "PostedItem.h" -#include "PostedUserTypes.h" -#include "gui/Identity/IdDialog.h" - -#include - -#include -#include - -/**************************************************************** - */ - -/* Images for context menu icons */ -#define IMAGE_MESSAGE ":/images/folder-draft.png" -#define IMAGE_SUBSCRIBE ":/images/edit_add24.png" -#define IMAGE_UNSUBSCRIBE ":/images/cancel.png" -#define IMAGE_SHOW ":/images/info16.png" -#define IMAGE_EDIT ":/images/settings16.png" - -/* 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" - -// token types to deal with - -#define POSTED_DEFAULT_LISTING_LENGTH 10 -#define POSTED_MAX_INDEX 10000 - -/** Constructor */ -PostedListDialog::PostedListDialog(QWidget *parent) -: RsGxsUpdateBroadcastPage(rsPosted, parent), GxsServiceDialog(dynamic_cast(parent)) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - /* Setup Queue */ - mPostedQueue = new TokenQueue(rsPosted->getTokenService(), this); - - connect( ui.groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupListCustomPopupMenu(QPoint))); - connect( ui.groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedTopic(QString))); - - connect(ui.hotSortButton, SIGNAL(clicked()), this, SLOT(getRankings())); - connect(ui.newSortButton, SIGNAL(clicked()), this, SLOT(getRankings())); - connect(ui.topSortButton, SIGNAL(clicked()), this, SLOT(getRankings())); - connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(showNext())); - connect(ui.prevButton, SIGNAL(clicked()), this, SLOT(showPrev())); - - connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(todo())); - - connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId())); - - // default sort method. - mSortMethod = RsPosted::HotRankType; - mLastSortMethod = RsPosted::TopRankType; // to be different. - mPostIndex = 0; - mPostShow = POSTED_DEFAULT_LISTING_LENGTH; - - /* Initialize group tree */ - QToolButton *newTopicButton = new QToolButton(this); - newTopicButton->setIcon(QIcon(":/images/posted_add_24.png")); - newTopicButton->setToolTip(tr("Create New Topic")); - connect(newTopicButton, SIGNAL(clicked()), this, SLOT(newTopic())); - ui.groupTreeWidget->addToolButton(newTopicButton); - - /* create posted tree */ - yourTopics = ui.groupTreeWidget->addCategoryItem(tr("My Topics"), QIcon(IMAGE_FOLDER), true); - subscribedTopics = ui.groupTreeWidget->addCategoryItem(tr("Subscribed Topics"), QIcon(IMAGE_FOLDERRED), true); - popularTopics = ui.groupTreeWidget->addCategoryItem(tr("Popular Topics"), QIcon(IMAGE_FOLDERGREEN), false); - otherTopics = ui.groupTreeWidget->addCategoryItem(tr("Other Topics"), QIcon(IMAGE_FOLDERYELLOW), false); - - ui.hotSortButton->setChecked(true); - - /* fill in the available OwnIds for signing */ - ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId()); - - connect(ui.submitPostButton, SIGNAL(clicked()), this, SLOT(newPost())); -} - -void PostedListDialog::showNext() -{ - mPostIndex += mPostShow; - if (mPostIndex > POSTED_MAX_INDEX) - mPostIndex = POSTED_MAX_INDEX; - applyRanking(); - updateShowText(); -} - -void PostedListDialog::showPrev() -{ - mPostIndex -= mPostShow; - if (mPostIndex < 0) - mPostIndex = 0; - applyRanking(); - updateShowText(); -} - -void PostedListDialog::updateShowText() -{ - QString showText = tr("Showing"); - showText += " "; - showText += QString::number(mPostIndex + 1); - showText += "-"; - showText += QString::number(mPostIndex + mPostShow); - ui.showLabel->setText(showText); -} - -void PostedListDialog::getRankings() -{ - if(mCurrTopicId.isNull()) - return; - - std::cerr << "PostedListDialog::getRankings()"; - std::cerr << std::endl; - - int oldSortMethod = mSortMethod; - - QObject* button = sender(); - if(button == ui.hotSortButton) - { - mSortMethod = RsPosted::HotRankType; - } - else if(button == ui.topSortButton) - { - mSortMethod = RsPosted::TopRankType; - } - else if(button == ui.newSortButton) - { - mSortMethod = RsPosted::NewRankType; - } - else - { - return; - } - - if (oldSortMethod != mSortMethod) - { - /* Reset Counter */ - mPostIndex = 0; - updateShowText(); - } - - applyRanking(); -} - -void PostedListDialog::groupListCustomPopupMenu(QPoint /*point*/) -{ - if (mCurrTopicId.isNull()) - { - return; - } - - uint32_t subscribeFlags = ui.groupTreeWidget->subscribeFlags(QString::fromStdString(mCurrTopicId.toStdString())); - - QMenu contextMnu(this); - - //bool isAdmin = IS_GROUP_ADMIN(subscribeFlags); - //bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags); - bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags); - - QAction *action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit a new Post"), this, SLOT(newPost())); - action->setEnabled(isSubscribed); - action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeTopic())); - action->setEnabled(!isSubscribed); - action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeTopic())); - action->setEnabled(isSubscribed); - - contextMnu.addSeparator(); - - action = contextMnu.addAction(QIcon(IMAGE_SHOW), tr("Show Topic Details"), this, SLOT(showTopic())); - action->setEnabled (!mCurrTopicId.isNull()); - - action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Topic Details"), this, SLOT(editTopic())); - action->setEnabled (!mCurrTopicId.isNull() && IS_GROUP_ADMIN(subscribeFlags)); - - contextMnu.exec(QCursor::pos()); -} - -void PostedListDialog::newPost() -{ - if(mCurrTopicId.isNull()) - return; - - uint32_t subscribeFlags = ui.groupTreeWidget->subscribeFlags(QString::fromStdString(mCurrTopicId.toStdString())); - bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags); - - if (isSubscribed) - { - PostedCreatePostDialog cp(mPostedQueue, rsPosted, mCurrTopicId, this); - cp.exec(); - } -} - -void PostedListDialog::unsubscribeTopic() -{ - std::cerr << "PostedListDialog::unsubscribeTopic()"; - std::cerr << std::endl; - - if(mCurrTopicId.isNull()) - return; - - uint32_t token; - rsPosted->subscribeToGroup(token, mCurrTopicId, false); - mPostedQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_SUBSCRIBE_CHANGE); -} - -void PostedListDialog::subscribeTopic() -{ - std::cerr << "PostedListDialog::subscribeTopic()"; - std::cerr << std::endl; - - if(mCurrTopicId.isNull()) - return; - - uint32_t token; - rsPosted->subscribeToGroup(token, mCurrTopicId, true); - mPostedQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_SUBSCRIBE_CHANGE); -} - -void PostedListDialog::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up) -{ - /* must grab AuthorId from Layout */ - RsGxsId authorId; - switch (ui.idChooser->getChosenId(authorId)) { - case GxsIdChooser::KnowId: - case GxsIdChooser::UnKnowId: - break; - case GxsIdChooser::NoId: - case GxsIdChooser::None: - default: - std::cerr << "PostedListDialog::createPost() ERROR GETTING AuthorId!, Vote Failed"; - std::cerr << std::endl; - - QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id before Voting"), QMessageBox::Ok, QMessageBox::Ok); - - return; - }//switch (ui.idChooser->getChosenId(authorId)) - - RsGxsVote vote; - - vote.mMeta.mGroupId = msgId.first; - vote.mMeta.mThreadId = msgId.second; - vote.mMeta.mParentId = msgId.second; - vote.mMeta.mAuthorId = authorId; - - if (up) { - vote.mVoteType = GXS_VOTE_UP; - } else { //if (up) - vote.mVoteType = GXS_VOTE_DOWN; - }//if (up) - - std::cerr << "PostedListDialog::submitVote()"; - std::cerr << std::endl; - - std::cerr << "GroupId : " << vote.mMeta.mGroupId << std::endl; - std::cerr << "ThreadId : " << vote.mMeta.mThreadId << std::endl; - std::cerr << "ParentId : " << vote.mMeta.mParentId << std::endl; - std::cerr << "AuthorId : " << vote.mMeta.mAuthorId << std::endl; - - uint32_t token; - rsPosted->createVote(token, vote); - mPostedQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_VOTE); -} - -/*****************************************************************************************/ -// Overloaded from FeedHolder. -QScrollArea *PostedListDialog::getScrollArea() -{ - return ui.scrollArea; -} - -void PostedListDialog::deleteFeedItem(QWidget */*item*/, uint32_t /*type*/) -{ - std::cerr << "PostedListDialog::deleteFeedItem() Nah"; - std::cerr << std::endl; - return; -} - -void PostedListDialog::openChat(const RsPeerId & /*peerId*/) -{ - std::cerr << "PostedListDialog::openChat() Nah"; - std::cerr << std::endl; - return; -} - -void PostedListDialog::openComments(uint32_t /*feed_type*/, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title) -{ - commentLoad(groupId, msgId, title); -} - -/*****************************************************************************************/ - -void PostedListDialog::updateDisplay(bool /*complete*/) -{ - std::cerr << "rsPosted->updateDisplay()"; - std::cerr << std::endl; - - /* update List */ - insertGroups(); - - const std::map > &msgs = getMsgIds(); - if(!msgs.empty()) - { - std::cerr << "rsPosted->msgsChanged():"; - std::cerr << std::endl; - - std::map >::const_iterator mit; - mit = msgs.find(mCurrTopicId); - if(mit != msgs.end()) - { - std::cerr << "current Group -> updating Displayed Items"; - std::cerr << std::endl; - updateDisplayedItems(mit->second); - } - } -} - -void PostedListDialog::updateDisplayedItems(const std::vector &msgIds) -{ - RsTokReqOptions opts; - - opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; - opts.mOptions = RS_TOKREQOPT_MSG_LATEST; - - GxsMsgReq msgs; - msgs[mCurrTopicId] = msgIds; - - std::cerr << "PostedListDialog::updateDisplayedItems(" << mCurrTopicId << ")"; - std::cerr << std::endl; - - std::vector::const_iterator it; - for(it = msgIds.begin(); it != msgIds.end(); it++) - { - std::cerr << "\t\tMsgId: " << *it; - std::cerr << std::endl; - } - - uint32_t token; - mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgs, TOKEN_USER_TYPE_POST_MOD); -} - -void PostedListDialog::changedTopic(const QString &id) -{ - mCurrTopicId = RsGxsGroupId(id.toStdString()); - insertThreads(); -} - -/*********************** **** **** **** ***********************/ -/** New / Edit Groups ********************************/ -/*********************** **** **** **** ***********************/ - -void PostedListDialog::newTopic() -{ - PostedGroupDialog cf (mPostedQueue, this); - cf.exec (); -} - -void PostedListDialog::showTopic() -{ - if (mCurrTopicId.isNull()) { - return; - } - - PostedGroupDialog cf(mPostedQueue, rsPosted->getTokenService(), GxsGroupDialog::MODE_SHOW, mCurrTopicId, this); - cf.exec (); -} - -void PostedListDialog::editTopic() -{ - if (mCurrTopicId.isNull()) { - return; - } - - PostedGroupDialog cf(mPostedQueue, rsPosted->getTokenService(), GxsGroupDialog::MODE_EDIT, mCurrTopicId, this); - cf.exec (); -} - -void PostedListDialog::createNewGxsId() -{ - IdEditDialog dlg(this); - dlg.setupNewId(false); - dlg.exec(); - ui.idChooser->setDefaultId(dlg.getLastIdName()); -} - -void PostedListDialog::showGroupDetails() -{ - if (mCurrTopicId.isNull()) - { - return; - } - - PostedGroupDialog cf(mPostedQueue, rsPosted->getTokenService(), GxsGroupDialog::MODE_SHOW, mCurrTopicId, this); - cf.exec (); -} - -void PostedListDialog::insertGroups() -{ - requestGroupSummary(); -} - -void PostedListDialog::requestGroupSummary() -{ - std::cerr << "PostedListDialog::requestGroupSummary()"; - std::cerr << std::endl; - - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; - uint32_t token; - mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_USER_TYPE_TOPIC); - - // /* refresh Id Chooser Too */ - //RsGxsId currentId ; - //ui.idChooser->getChosenId(currentId); - //ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, currentId); -} - -void PostedListDialog::acknowledgeGroup(const uint32_t &token) -{ - RsGxsGroupId grpId; - rsPosted->acknowledgeGrp(token, grpId); - - if(!grpId.isNull()) - { - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; - uint32_t reqToken; - mPostedQueue->requestGroupInfo(reqToken, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_USER_TYPE_TOPIC); - } -} - -void PostedListDialog::acknowledgePostMsg(const uint32_t &token) -{ - RsGxsGrpMsgIdPair msgId; - - // just acknowledge, don't load anything - rsPosted->acknowledgeMsg(token, msgId); -} - -void PostedListDialog::loadGroupSummary(const uint32_t &token) -{ - std::cerr << "PostedListDialog::loadGroupSummary()"; - std::cerr << std::endl; - - std::list groupInfo; - rsPosted->getGroupSummary(token, groupInfo); - - if (groupInfo.size() > 0) - { - insertGroupData(groupInfo); - } - else - { - std::cerr << "PostedListDialog::loadGroupSummary() ERROR No Groups..."; - std::cerr << std::endl; - } -} - -void PostedListDialog::loadPostData(const uint32_t &token) -{ - loadGroupThreadData_InsertThreads(token); -} - -void PostedListDialog::acknowledgeVoteMsg(const uint32_t &token) -{ - RsGxsGrpMsgIdPair msgId; - - rsPosted->acknowledgeVote(token, msgId); -} - -void PostedListDialog::loadVoteData(const uint32_t &/*token*/) -{ - return; -} - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - -void PostedListDialog::requestGroupSummary_CurrentForum(const RsGxsGroupId &forumId) -{ - RsTokReqOptions opts; - - std::list grpIds; - grpIds.push_back(forumId); - - std::cerr << "PostedListDialog::requestGroupSummary_CurrentForum(" << forumId << ")"; - std::cerr << std::endl; - - uint32_t token; - mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, POSTEDDIALOG_CURRENTFORUM); -} - -void PostedListDialog::loadGroupSummary_CurrentForum(const uint32_t &token) -{ - std::cerr << "PostedListDialog::loadGroupSummary_CurrentForum()"; - std::cerr << std::endl; - - std::list groupInfo; - rsPosted->getGroupSummary(token, groupInfo); - - if (groupInfo.size() == 1) - { - RsGroupMetaData fi = groupInfo.front(); - //insertForumThreads(fi); - } - else - { - std::cerr << "PostedListDialog::loadGroupSummary_CurrentForum() ERROR Invalid Number of Groups..."; - std::cerr << std::endl; - } -} - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - -void PostedListDialog::insertThreads() -{ - loadCurrentTopicThreads(mCurrTopicId); -} - -void PostedListDialog::loadCurrentTopicThreads(const RsGxsGroupId &topicId) -{ - std::cerr << "PostedListDialog::loadCurrentForumThreads(" << topicId << ")"; - std::cerr << std::endl; - - if (topicId.isNull()) - { - std::cerr << "PostedListDialog::loadCurrentForumThreads() Empty GroupId .. ignoring Req"; - std::cerr << std::endl; - return; - } - - clearPosts(); - - /* initiate loading */ - requestGroupThreadData_InsertThreads(topicId); -} - -void PostedListDialog::requestGroupThreadData_InsertThreads(const RsGxsGroupId &groupId) -{ - RsTokReqOptions opts; - - opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; - opts.mOptions = RS_TOKREQOPT_MSG_LATEST; - - std::list grpIds; - grpIds.push_back(groupId); - - std::cerr << "PostedListDialog::requestGroupThreadData_InsertThreads(" << groupId << ")"; - std::cerr << std::endl; - - uint32_t token; - mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, TOKEN_USER_TYPE_POST); -} - -void PostedListDialog::loadGroupThreadData_InsertThreads(const uint32_t &token) -{ - std::cerr << "PostedListDialog::loadGroupThreadData_InsertThreads()"; - std::cerr << std::endl; - - clearPosts(); - - std::vector posts; - rsPosted->getPostData(token, posts); - std::vector::iterator vit; - - for(vit = posts.begin(); vit != posts.end(); vit++) - { - RsPostedPost& p = *vit; - loadPost(p); - } - - applyRanking(); -} - -void PostedListDialog::loadPost(const RsPostedPost &post) -{ - PostedItem *item = new PostedItem(this, 0, post, true); - connect(item, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool))); - mPosts.insert(post.mMeta.mMsgId, item); - //QLayout *alayout = ui.scrollAreaWidgetContents->layout(); - //alayout->addWidget(item); - mPostList.push_back(item); -} - -bool CmpPIHot(const PostedItem *a, const PostedItem *b) -{ - const RsPostedPost &postA = a->getPost(); - const RsPostedPost &postB = b->getPost(); - - if (postA.mHotScore == postB.mHotScore) - { - return (postA.mNewScore > postB.mNewScore); - } - - return (postA.mHotScore > postB.mHotScore); -} - -bool CmpPITop(const PostedItem *a, const PostedItem *b) -{ - const RsPostedPost &postA = a->getPost(); - const RsPostedPost &postB = b->getPost(); - - if (postA.mTopScore == postB.mTopScore) - { - return (postA.mNewScore > postB.mNewScore); - } - - return (postA.mTopScore > postB.mTopScore); -} - -bool CmpPINew(const PostedItem *a, const PostedItem *b) -{ - return (a->getPost().mNewScore > b->getPost().mNewScore); -} - -void PostedListDialog::applyRanking() -{ - /* uses current settings to sort posts, then add to layout */ - std::cerr << "PostedListDialog::applyRanking()"; - std::cerr << std::endl; - - shallowClearPosts(); - - /* sort */ - switch(mSortMethod) - { - default: - case RsPosted::HotRankType: - std::cerr << "PostedListDialog::applyRanking() HOT"; - std::cerr << std::endl; - mPostList.sort(CmpPIHot); - break; - case RsPosted::NewRankType: - std::cerr << "PostedListDialog::applyRanking() NEW"; - std::cerr << std::endl; - mPostList.sort(CmpPINew); - break; - case RsPosted::TopRankType: - std::cerr << "PostedListDialog::applyRanking() TOP"; - std::cerr << std::endl; - mPostList.sort(CmpPITop); - break; - } - mLastSortMethod = mSortMethod; - - std::cerr << "PostedListDialog::applyRanking() Sorted mPostList"; - std::cerr << std::endl; - - /* go through list (skipping out-of-date items) to get */ - QLayout *alayout = ui.scrollAreaWidgetContents->layout(); - int counter = 0; - time_t min_ts = 0; - std::list::iterator it; - for(it = mPostList.begin(); it != mPostList.end(); it++) - { - PostedItem *item = (*it); - std::cerr << "PostedListDialog::applyRanking() Item: " << item; - std::cerr << std::endl; - - if (item->getPost().mMeta.mPublishTs < min_ts) - { - std::cerr << "\t Skipping OLD"; - std::cerr << std::endl; - item->hide(); - continue; - } - - if (counter >= mPostIndex + mPostShow) - { - std::cerr << "\t END - Counter too high"; - std::cerr << std::endl; - item->hide(); - } - else if (counter >= mPostIndex) - { - std::cerr << "\t Adding to Layout"; - std::cerr << std::endl; - /* add it in! */ - alayout->addWidget(item); - item->show(); - } - else - { - std::cerr << "\t Skipping to Low"; - std::cerr << std::endl; - item->hide(); - } - counter++; - } - - std::cerr << "PostedListDialog::applyRanking() Loaded New Order"; - std::cerr << std::endl; - - // trigger a redraw. - ui.scrollAreaWidgetContents->update(); -} - -void PostedListDialog::clearPosts() -{ - std::cerr << "PostedListDialog::clearPosts()" << std::endl; - - std::list postedItems; - std::list::iterator pit; - - QLayout *alayout = ui.scrollAreaWidgetContents->layout(); - int count = alayout->count(); - for(int i = 0; i < count; i++) - { - QLayoutItem *litem = alayout->itemAt(i); - if (!litem) - { - std::cerr << "PostedListDialog::clearPosts() missing litem"; - std::cerr << std::endl; - continue; - } - - PostedItem *item = dynamic_cast(litem->widget()); - if (item) - { - std::cerr << "PostedListDialog::clearPosts() item: " << item; - std::cerr << std::endl; - - postedItems.push_back(item); - } - else - { - std::cerr << "PostedListDialog::clearPosts() Found Child, which is not a PostedItem???"; - std::cerr << std::endl; - } - } - - for(pit = postedItems.begin(); pit != postedItems.end(); pit++) - { - PostedItem *item = *pit; - alayout->removeWidget(item); - delete item; - } - - mPosts.clear(); - mPostList.clear(); -} - -void PostedListDialog::shallowClearPosts() -{ - std::cerr << "PostedListDialog::shallowClearPosts()" << std::endl; - - std::list postedItems; - std::list::iterator pit; - - QLayout *alayout = ui.scrollAreaWidgetContents->layout(); - int count = alayout->count(); - for(int i = 0; i < count; i++) - { - QLayoutItem *litem = alayout->itemAt(i); - if (!litem) - { - std::cerr << "PostedListDialog::shallowClearPosts() missing litem"; - std::cerr << std::endl; - continue; - } - - PostedItem *item = dynamic_cast(litem->widget()); - if (item) - { - std::cerr << "PostedListDialog::shallowClearPosts() item: " << item; - std::cerr << std::endl; - - postedItems.push_back(item); - } - else - { - std::cerr << "PostedListDialog::shallowClearPosts() Found Child, which is not a PostedItem???"; - std::cerr << std::endl; - } - } - - for(pit = postedItems.begin(); pit != postedItems.end(); pit++) - { - PostedItem *item = *pit; - alayout->removeWidget(item); - } -} - -void PostedListDialog::updateCurrentDisplayComplete(const uint32_t &token) -{ - std::cerr << "PostedListDialog::updateCurrentDisplayComplete()"; - std::cerr << std::endl; - - std::vector posts; - rsPosted->getPostData(token, posts); - - std::vector::iterator vit; - for(vit = posts.begin(); vit != posts.end(); vit++) - { - RsPostedPost& p = *vit; - - // modify post content - if(mPosts.find(p.mMeta.mMsgId) != mPosts.end()) - { - std::cerr << "PostedListDialog::updateCurrentDisplayComplete() updating MsgId: " << p.mMeta.mMsgId; - std::cerr << std::endl; - - mPosts[p.mMeta.mMsgId]->setContent(p); - } - else - { - std::cerr << "PostedListDialog::updateCurrentDisplayComplete() loading New MsgId: " << p.mMeta.mMsgId; - std::cerr << std::endl; - /* insert new entry */ - loadPost(p); - } - } - - time_t now = time(NULL); - QMap::iterator pit; - for(pit = mPosts.begin(); pit != mPosts.end(); pit++) - { - (*pit)->post().calculateScores(now); - } - - applyRanking(); -} - -void PostedListDialog::acknowledgeSubscribeChange(const uint32_t &token) -{ - std::cerr << "PostedListDialog::acknowledgeSubscribeChange()"; - std::cerr << std::endl; - - std::vector posts; - RsGxsGroupId groupId; - rsPosted->acknowledgeGrp(token, groupId); - - insertGroups(); -} - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - -void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) -{ - std::cerr << "PostedListDialog::loadRequest() UserType: " << req.mUserType; - std::cerr << std::endl; - - if (queue == mPostedQueue) - { - /* now switch on req */ - switch(req.mUserType) - { - case TOKEN_USER_TYPE_TOPIC: - switch(req.mAnsType) - { - case RS_TOKREQ_ANSTYPE_SUMMARY: - loadGroupSummary(req.mToken); - break; - default: - std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; - break; - } - break; - case TOKEN_USER_TYPE_POST: - switch(req.mAnsType) - { - case RS_TOKREQ_ANSTYPE_ACK: - acknowledgePostMsg(req.mToken); - break; - case RS_TOKREQ_ANSTYPE_DATA: - loadPostData(req.mToken); - break; - default: - std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; - break; - } - break; - case TOKEN_USER_TYPE_VOTE: - switch(req.mAnsType) - { - case RS_TOKREQ_ANSTYPE_ACK: - acknowledgeVoteMsg(req.mToken); - break; - default: - std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; - break; - } - break; - case TOKEN_USER_TYPE_POST_MOD: - switch(req.mAnsType) - { - case RS_TOKREQ_ANSTYPE_DATA: - updateCurrentDisplayComplete(req.mToken); - break; - default: - std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; - break; - } - break; - case TOKEN_USER_TYPE_POST_RANKINGS: - switch(req.mAnsType) - { - case RS_TOKREQ_ANSTYPE_DATA: - //loadRankings(req.mToken); - break; - default: - std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; - break; - } - case TOKEN_USER_TYPE_SUBSCRIBE_CHANGE: - acknowledgeSubscribeChange(req.mToken); - break; - default: - std::cerr << "PostedListDialog::loadRequest() ERROR: INVALID TYPE"; - std::cerr << std::endl; - break; - } - } - - /* now switch on req */ - switch(req.mType) - { - case TOKENREQ_GROUPINFO: - switch(req.mAnsType) - { - case RS_TOKREQ_ANSTYPE_ACK: - acknowledgeGroup(req.mToken); - break; - } - break; - } -} - -/**************************************************************************************/ -/**************************************************************************************/ -/**************************************************************************************/ -/**************************** Groups **********************/ - -void PostedListDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo) -{ - groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId.toStdString()); - groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str()); - //groupItemInfo.description = QString::fromUtf8(groupInfo.forumDesc); - groupItemInfo.popularity = groupInfo.mPop; - groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost); - groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags; -} - -void PostedListDialog::insertGroupData(const std::list &groupList) -{ - std::list::const_iterator it; - - QList adminList; - QList subList; - QList popList; - QList otherList; - std::multimap 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) || IS_GROUP_PUBLISHER(flags)) - { - adminList.push_back(groupItemInfo); - } - else - { - subList.push_back(groupItemInfo); - } - } - else - { - 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::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(yourTopics, adminList); - ui.groupTreeWidget->fillGroupItems(subscribedTopics, subList); - ui.groupTreeWidget->fillGroupItems(popularTopics, popList); - ui.groupTreeWidget->fillGroupItems(otherTopics, otherList); -} - -/**************************************************************************************/ -/**************************************************************************************/ -/**************************************************************************************/ - -void PostedListDialog::todo() -{ - QMessageBox::information(this, "Todo", - "Open points:
    " - "
  • Subreddits/tag to posts support" - "
  • Picture Support" - "
"); -} diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.ui b/retroshare-gui/src/gui/Posted/PostedListDialog.ui deleted file mode 100644 index 6d6166886..000000000 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.ui +++ /dev/null @@ -1,343 +0,0 @@ - - - PostedListDialog - - - - 0 - 0 - 756 - 428 - - - - Form - - - - - - Qt::Horizontal - - - 5 - - - - - - - - 0 - 0 - - - - - - - - - - - - - 6 - - - 6 - - - 0 - - - 6 - - - 0 - - - - - Submit a new Post - - - - :/images/posted_24.png:/images/posted_24.png - - - - - - - Todo - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Showing 1-100 - - - - - - - Prev - - - - - - - Next - - - - - - - - - - 6 - - - 6 - - - - - false - - - - 6 - - - 0 - - - - - Hot - - - - :/images/hot_24.png:/images/hot_24.png - - - - 24 - 24 - - - - true - - - true - - - - - - - New - - - - :/images/new_24.png:/images/new_24.png - - - - 24 - 24 - - - - true - - - true - - - - - - - Top - - - - :/images/vote_up.png:/images/vote_up.png - - - - 24 - 24 - - - - true - - - false - - - true - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - Today - - - - - Yesterday - - - - - This Week - - - - - This Month - - - - - This Year - - - - - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Create new Identity - - - New ID - - - - :/images/identity/identity_create_32.png:/images/identity/identity_create_32.png - - - - 24 - 24 - - - - true - - - - - - - - - true - - - - - 0 - 0 - 714 - 16 - - - - - 0 - 0 - - - - - 0 - - - 0 - - - - - - - - - - - - - - GxsIdChooser - QComboBox -
gui/gxs/GxsIdChooser.h
-
- - GroupTreeWidget - QWidget -
gui/common/GroupTreeWidget.h
- 1 -
-
- - - - - -
diff --git a/retroshare-gui/src/gui/Posted/PostedListWidget.cpp b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp new file mode 100644 index 000000000..82c7c9ffa --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp @@ -0,0 +1,971 @@ +/* + * Retroshare Posted List + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#include + +#include "PostedListWidget.h" +#include "ui_PostedListWidget.h" + +#include "PostedCreatePostDialog.h" +#include "PostedItem.h" +#include "PostedUserTypes.h" +#include "gui/Identity/IdDialog.h" +#include "gui/common/UIStateHelper.h" + +#include + +/*********************** **** **** **** ***********************/ +/** Request / Response of Data ********************************/ +/*********************** **** **** **** ***********************/ + +//#define POSTEDDIALOG_LISTING 1 +//#define POSTEDDIALOG_CURRENTFORUM 2 +#define POSTEDDIALOG_INSERTTHREADS 3 +//#define POSTEDDIALOG_INSERTCHILD 4 +//#define POSTEDDIALOG_INSERT_POST 5 +//#define POSTEDDIALOG_REPLY_MESSAGE 6 + +/**************************************************************** + */ + +// token types to deal with + +#define POSTED_DEFAULT_LISTING_LENGTH 10 +#define POSTED_MAX_INDEX 10000 + +/** Constructor */ +PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent) + : GxsMessageFrameWidget(rsPosted, parent), + ui(new Ui::PostedListWidget) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui->setupUi(this); + + /* Setup UI helper */ + mStateHelper = new UIStateHelper(this); + + // No progress yet +// mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->loadingLabel, UISTATE_LOADING_VISIBLE); +// 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); +// mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui->subscribeToolButton); + + /* Setup Queue */ + mPostedQueue = new TokenQueue(rsPosted->getTokenService(), this); + + mSubscribeFlags = 0; + + connect(ui->hotSortButton, SIGNAL(clicked()), this, SLOT(getRankings())); + connect(ui->newSortButton, SIGNAL(clicked()), this, SLOT(getRankings())); + connect(ui->topSortButton, SIGNAL(clicked()), this, SLOT(getRankings())); + connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(showNext())); + connect(ui->prevButton, SIGNAL(clicked()), this, SLOT(showPrev())); + + connect(ui->toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId())); + + // default sort method. + mSortMethod = RsPosted::HotRankType; + mLastSortMethod = RsPosted::TopRankType; // to be different. + mPostIndex = 0; + mPostShow = POSTED_DEFAULT_LISTING_LENGTH; + + ui->hotSortButton->setChecked(true); + + /* fill in the available OwnIds for signing */ + ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId()); + + connect(ui->submitPostButton, SIGNAL(clicked()), this, SLOT(newPost())); + + /* load settings */ + processSettings(true); + + /* Initialize GUI */ + setGroupId(postedId); +} + +PostedListWidget::~PostedListWidget() +{ + // save settings + processSettings(false); +} + +void PostedListWidget::updateDisplay(bool complete) +{ + std::cerr << "rsPosted->updateDisplay()"; + std::cerr << std::endl; + + if (complete) { + /* Fill complete */ + requestGroupData(); + requestPosts(); + return; + } + + if (mPostedId.isNull()) { + return; + } + + bool updateGroup = false; + + const std::list &grpIdsMeta = getGrpIdsMeta(); + if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), mPostedId) != grpIdsMeta.end()) { + updateGroup = true; + } + + const std::list &grpIds = getGrpIds(); + if (!mPostedId.isNull() && std::find(grpIds.begin(), grpIds.end(), mPostedId) != grpIds.end()) { + updateGroup = true; + /* Do we need to fill all posts? */ + requestPosts(); + } else { + std::map > msgs; + getAllMsgIds(msgs); + if (!msgs.empty()) + { + std::cerr << "rsPosted->msgsChanged():"; + std::cerr << std::endl; + + std::map >::const_iterator mit; + mit = msgs.find(mPostedId); + if(mit != msgs.end()) + { + std::cerr << "current Group -> updating Displayed Items"; + std::cerr << std::endl; + updateDisplayedItems(mit->second); + } + } + } + + if (updateGroup) { + requestGroupData(); + } +} + +void PostedListWidget::processSettings(bool load) +{ +// Settings->beginGroup(QString("PostedListWidget")); +// +// if (load) { +// // load settings +// } else { +// // save settings +// } +// +// Settings->endGroup(); +} + +void PostedListWidget::setGroupId(const RsGxsGroupId &groupId) +{ + if (mPostedId == groupId) { + if (!groupId.isNull()) { + return; + } + } + + mPostedId = groupId; + mName = mPostedId.isNull () ? "" : tr("Loading"); + + emit groupChanged(this); + + fillComplete(); +} + +QString PostedListWidget::groupName(bool withUnreadCount) +{ + QString name = mPostedId.isNull () ? tr("No name") : mName; + +// if (withUnreadCount && mUnreadCount) { +// name += QString(" (%1)").arg(mUnreadCount); +// } + + return name; +} + +QIcon PostedListWidget::groupIcon() +{ +// if (mStateHelper->isLoading(TOKEN_TYPE_GROUP_DATA) || mStateHelper->isLoading(TOKEN_TYPE_POSTS)) { +// return QIcon(":/images/kalarm.png"); +// } + +// if (mNewCount) { +// return QIcon(":/images/message-state-new.png"); +// } + + return QIcon(); +} + +/*****************************************************************************************/ +// Overloaded from FeedHolder. +QScrollArea *PostedListWidget::getScrollArea() +{ + return ui->scrollArea; +} + +void PostedListWidget::deleteFeedItem(QWidget */*item*/, uint32_t /*type*/) +{ + std::cerr << "PostedListWidget::deleteFeedItem() Nah"; + std::cerr << std::endl; + return; +} + +void PostedListWidget::openChat(const RsPeerId & /*peerId*/) +{ + std::cerr << "PostedListWidget::openChat() Nah"; + std::cerr << std::endl; + return; +} + +void PostedListWidget::openComments(uint32_t /*feed_type*/, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title) +{ + emit loadComment(groupId, msgId, title); +} + +void PostedListWidget::newPost() +{ + if (mPostedId.isNull()) + return; + + if (!IS_GROUP_SUBSCRIBED(mSubscribeFlags)) { + return; + } + + PostedCreatePostDialog *cp = new PostedCreatePostDialog(mPostedQueue, rsPosted, mPostedId, this); + cp->show(); + + /* window will destroy itself! */ +} + +void PostedListWidget::showNext() +{ + mPostIndex += mPostShow; + if (mPostIndex > POSTED_MAX_INDEX) + mPostIndex = POSTED_MAX_INDEX; + applyRanking(); + updateShowText(); +} + +void PostedListWidget::showPrev() +{ + mPostIndex -= mPostShow; + if (mPostIndex < 0) + mPostIndex = 0; + applyRanking(); + updateShowText(); +} + +void PostedListWidget::updateShowText() +{ + QString showText = tr("Showing"); + showText += " "; + showText += QString::number(mPostIndex + 1); + showText += "-"; + showText += QString::number(mPostIndex + mPostShow); + ui->showLabel->setText(showText); +} + +void PostedListWidget::getRankings() +{ + if (mPostedId.isNull()) + return; + + std::cerr << "PostedListWidget::getRankings()"; + std::cerr << std::endl; + + int oldSortMethod = mSortMethod; + + QObject* button = sender(); + if(button == ui->hotSortButton) + { + mSortMethod = RsPosted::HotRankType; + } + else if(button == ui->topSortButton) + { + mSortMethod = RsPosted::TopRankType; + } + else if(button == ui->newSortButton) + { + mSortMethod = RsPosted::NewRankType; + } + else + { + return; + } + + if (oldSortMethod != mSortMethod) + { + /* Reset Counter */ + mPostIndex = 0; + updateShowText(); + } + + applyRanking(); +} + +void PostedListWidget::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up) +{ + /* must grab AuthorId from Layout */ + RsGxsId authorId; + switch (ui->idChooser->getChosenId(authorId)) { + case GxsIdChooser::KnowId: + case GxsIdChooser::UnKnowId: + break; + case GxsIdChooser::NoId: + case GxsIdChooser::None: + default: + std::cerr << "PostedListWidget::createPost() ERROR GETTING AuthorId!, Vote Failed"; + std::cerr << std::endl; + + QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id before Voting"), QMessageBox::Ok, QMessageBox::Ok); + + return; + }//switch (ui.idChooser->getChosenId(authorId)) + + RsGxsVote vote; + + vote.mMeta.mGroupId = msgId.first; + vote.mMeta.mThreadId = msgId.second; + vote.mMeta.mParentId = msgId.second; + vote.mMeta.mAuthorId = authorId; + + if (up) { + vote.mVoteType = GXS_VOTE_UP; + } else { //if (up) + vote.mVoteType = GXS_VOTE_DOWN; + }//if (up) + + std::cerr << "PostedListWidget::submitVote()"; + std::cerr << std::endl; + + std::cerr << "GroupId : " << vote.mMeta.mGroupId << std::endl; + std::cerr << "ThreadId : " << vote.mMeta.mThreadId << std::endl; + std::cerr << "ParentId : " << vote.mMeta.mParentId << std::endl; + std::cerr << "AuthorId : " << vote.mMeta.mAuthorId << std::endl; + + uint32_t token; + rsPosted->createVote(token, vote); + mPostedQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_VOTE); +} + +/*****************************************************************************************/ + +void PostedListWidget::updateDisplayedItems(const std::vector &msgIds) +{ + mPostedQueue->cancelActiveRequestTokens(TOKEN_USER_TYPE_POST_MOD); + + if (mPostedId.isNull()) { + mStateHelper->setActive(TOKEN_USER_TYPE_POST, false); + mStateHelper->setLoading(TOKEN_USER_TYPE_POST, false); + mStateHelper->clear(TOKEN_USER_TYPE_POST); + emit groupChanged(this); + return; + } + + if (msgIds.empty()) { + return; + } + + mStateHelper->setLoading(TOKEN_USER_TYPE_POST, true); + emit groupChanged(this); + + RsTokReqOptions opts; + + opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; + opts.mOptions = RS_TOKREQOPT_MSG_LATEST; + + GxsMsgReq msgs; + msgs[mPostedId] = msgIds; + + std::cerr << "PostedListWidget::updateDisplayedItems(" << mPostedId << ")"; + std::cerr << std::endl; + + std::vector::const_iterator it; + for(it = msgIds.begin(); it != msgIds.end(); it++) + { + std::cerr << "\t\tMsgId: " << *it; + std::cerr << std::endl; + } + + uint32_t token; + mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgs, TOKEN_USER_TYPE_POST_MOD); +} + +void PostedListWidget::createNewGxsId() +{ + IdEditDialog dlg(this); + dlg.setupNewId(false); + dlg.exec(); + ui->idChooser->setDefaultId(dlg.getLastIdName()); +} + +void PostedListWidget::acknowledgeVoteMsg(const uint32_t &token) +{ + RsGxsGrpMsgIdPair msgId; + + rsPosted->acknowledgeVote(token, msgId); +} + +void PostedListWidget::loadVoteData(const uint32_t &/*token*/) +{ + return; +} + +/*********************** **** **** **** ***********************/ +/*********************** **** **** **** ***********************/ + +void PostedListWidget::requestGroupData() +{ +#ifdef DEBUG_POSTED + std::cerr << "PostedListWidget::requestGroupData()"; + std::cerr << std::endl; +#endif + + mSubscribeFlags = 0; + + mPostedQueue->cancelActiveRequestTokens(TOKEN_USER_TYPE_TOPIC); + + if (mPostedId.isNull()) { + mStateHelper->setActive(TOKEN_USER_TYPE_TOPIC, false); + mStateHelper->setLoading(TOKEN_USER_TYPE_TOPIC, false); + mStateHelper->clear(TOKEN_USER_TYPE_TOPIC); + + emit groupChanged(this); + + return; + } + + mStateHelper->setLoading(TOKEN_USER_TYPE_TOPIC, true); + emit groupChanged(this); + + std::list groupIds; + groupIds.push_back(mPostedId); + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; + + uint32_t token; + mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_USER_TYPE_TOPIC); +} + +void PostedListWidget::loadGroupData(const uint32_t &token) +{ + std::cerr << "PostedListWidget::loadGroupData()"; + std::cerr << std::endl; + + std::vector groups; + rsPosted->getGroupData(token, groups); + + mStateHelper->setLoading(TOKEN_USER_TYPE_TOPIC, false); + + if (groups.size() == 1) + { + insertPostedDetails(groups[0]); + } + else + { + std::cerr << "PostedListWidget::loadGroupData() ERROR Invalid Number of Groups..."; + std::cerr << std::endl; + + mStateHelper->setActive(TOKEN_USER_TYPE_TOPIC, false); + mStateHelper->clear(TOKEN_USER_TYPE_TOPIC); + } + + emit groupChanged(this); +} + +void PostedListWidget::insertPostedDetails(const RsPostedGroup &group) +{ + mStateHelper->setActive(TOKEN_USER_TYPE_TOPIC, true); + + mSubscribeFlags = group.mMeta.mSubscribeFlags; + + /* set name */ + mName = QString::fromUtf8(group.mMeta.mGroupName.c_str()); + + if (mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) + { + mStateHelper->setWidgetEnabled(ui->submitPostButton, true); + } + else + { + mStateHelper->setWidgetEnabled(ui->submitPostButton, false); + } + +// ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(mSubscribeFlags)); +} + +/*********************** **** **** **** ***********************/ +/*********************** **** **** **** ***********************/ +/*********************** **** **** **** ***********************/ +/*********************** **** **** **** ***********************/ + +void PostedListWidget::requestPosts() +{ + std::cerr << "PostedListWidget::loadCurrentForumThreads(" << mPostedId << ")"; + std::cerr << std::endl; + + clearPosts(); + + mPostedQueue->cancelActiveRequestTokens(TOKEN_USER_TYPE_POST); + + if (mPostedId.isNull()) + { + std::cerr << "PostedListWidget::loadCurrentForumThreads() Empty GroupId .. ignoring Req"; + std::cerr << std::endl; + + mStateHelper->setActive(TOKEN_USER_TYPE_POST, false); + mStateHelper->setLoading(TOKEN_USER_TYPE_POST, false); + mStateHelper->clear(TOKEN_USER_TYPE_POST); + emit groupChanged(this); + return; + } + + mStateHelper->setLoading(TOKEN_USER_TYPE_POST, true); + emit groupChanged(this); + + /* initiate loading */ + RsTokReqOptions opts; + + opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; + opts.mOptions = RS_TOKREQOPT_MSG_LATEST; + + std::list grpIds; + grpIds.push_back(mPostedId); + + std::cerr << "PostedListWidget::requestGroupThreadData_InsertThreads(" << mPostedId << ")"; + std::cerr << std::endl; + + uint32_t token; + mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, TOKEN_USER_TYPE_POST); +} + +void PostedListWidget::acknowledgePostMsg(const uint32_t &token) +{ + RsGxsGrpMsgIdPair msgId; + + // just acknowledge, don't load anything + rsPosted->acknowledgeMsg(token, msgId); +} + +void PostedListWidget::loadPostData(const uint32_t &token) +{ + std::cerr << "PostedListWidget::loadGroupThreadData_InsertThreads()"; + std::cerr << std::endl; + + mStateHelper->setActive(TOKEN_USER_TYPE_POST, true); + clearPosts(); + + std::vector posts; + rsPosted->getPostData(token, posts); + std::vector::iterator vit; + + for(vit = posts.begin(); vit != posts.end(); vit++) + { + RsPostedPost& p = *vit; + loadPost(p); + } + + applyRanking(); + + mStateHelper->setLoading(TOKEN_USER_TYPE_POST, false); + emit groupChanged(this); +} + +void PostedListWidget::loadPost(const RsPostedPost &post) +{ + PostedItem *item = new PostedItem(this, 0, post, true); + connect(item, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool))); + mPosts.insert(post.mMeta.mMsgId, item); + //QLayout *alayout = ui.scrollAreaWidgetContents->layout(); + //alayout->addWidget(item); + mPostList.push_back(item); +} + +static bool CmpPIHot(const PostedItem *a, const PostedItem *b) +{ + const RsPostedPost &postA = a->getPost(); + const RsPostedPost &postB = b->getPost(); + + if (postA.mHotScore == postB.mHotScore) + { + return (postA.mNewScore > postB.mNewScore); + } + + return (postA.mHotScore > postB.mHotScore); +} + +static bool CmpPITop(const PostedItem *a, const PostedItem *b) +{ + const RsPostedPost &postA = a->getPost(); + const RsPostedPost &postB = b->getPost(); + + if (postA.mTopScore == postB.mTopScore) + { + return (postA.mNewScore > postB.mNewScore); + } + + return (postA.mTopScore > postB.mTopScore); +} + +static bool CmpPINew(const PostedItem *a, const PostedItem *b) +{ + return (a->getPost().mNewScore > b->getPost().mNewScore); +} + +void PostedListWidget::applyRanking() +{ + /* uses current settings to sort posts, then add to layout */ + std::cerr << "PostedListWidget::applyRanking()"; + std::cerr << std::endl; + + shallowClearPosts(); + + /* sort */ + switch(mSortMethod) + { + default: + case RsPosted::HotRankType: + std::cerr << "PostedListWidget::applyRanking() HOT"; + std::cerr << std::endl; + mPostList.sort(CmpPIHot); + break; + case RsPosted::NewRankType: + std::cerr << "PostedListWidget::applyRanking() NEW"; + std::cerr << std::endl; + mPostList.sort(CmpPINew); + break; + case RsPosted::TopRankType: + std::cerr << "PostedListWidget::applyRanking() TOP"; + std::cerr << std::endl; + mPostList.sort(CmpPITop); + break; + } + mLastSortMethod = mSortMethod; + + std::cerr << "PostedListWidget::applyRanking() Sorted mPostList"; + std::cerr << std::endl; + + /* go through list (skipping out-of-date items) to get */ + QLayout *alayout = ui->scrollAreaWidgetContents->layout(); + int counter = 0; + time_t min_ts = 0; + std::list::iterator it; + for(it = mPostList.begin(); it != mPostList.end(); it++) + { + PostedItem *item = (*it); + std::cerr << "PostedListWidget::applyRanking() Item: " << item; + std::cerr << std::endl; + + if (item->getPost().mMeta.mPublishTs < min_ts) + { + std::cerr << "\t Skipping OLD"; + std::cerr << std::endl; + item->hide(); + continue; + } + + if (counter >= mPostIndex + mPostShow) + { + std::cerr << "\t END - Counter too high"; + std::cerr << std::endl; + item->hide(); + } + else if (counter >= mPostIndex) + { + std::cerr << "\t Adding to Layout"; + std::cerr << std::endl; + /* add it in! */ + alayout->addWidget(item); + item->show(); + } + else + { + std::cerr << "\t Skipping to Low"; + std::cerr << std::endl; + item->hide(); + } + counter++; + } + + std::cerr << "PostedListWidget::applyRanking() Loaded New Order"; + std::cerr << std::endl; + + // trigger a redraw. + ui->scrollAreaWidgetContents->update(); +} + +void PostedListWidget::clearPosts() +{ + std::cerr << "PostedListWidget::clearPosts()" << std::endl; + + std::list postedItems; + std::list::iterator pit; + + QLayout *alayout = ui->scrollAreaWidgetContents->layout(); + int count = alayout->count(); + for(int i = 0; i < count; i++) + { + QLayoutItem *litem = alayout->itemAt(i); + if (!litem) + { + std::cerr << "PostedListWidget::clearPosts() missing litem"; + std::cerr << std::endl; + continue; + } + + PostedItem *item = dynamic_cast(litem->widget()); + if (item) + { + std::cerr << "PostedListWidget::clearPosts() item: " << item; + std::cerr << std::endl; + + postedItems.push_back(item); + } + else + { + std::cerr << "PostedListWidget::clearPosts() Found Child, which is not a PostedItem???"; + std::cerr << std::endl; + } + } + + for(pit = postedItems.begin(); pit != postedItems.end(); pit++) + { + PostedItem *item = *pit; + alayout->removeWidget(item); + delete item; + } + + mPosts.clear(); + mPostList.clear(); +} + +void PostedListWidget::shallowClearPosts() +{ + std::cerr << "PostedListWidget::shallowClearPosts()" << std::endl; + + std::list postedItems; + std::list::iterator pit; + + QLayout *alayout = ui->scrollAreaWidgetContents->layout(); + int count = alayout->count(); + for(int i = 0; i < count; i++) + { + QLayoutItem *litem = alayout->itemAt(i); + if (!litem) + { + std::cerr << "PostedListWidget::shallowClearPosts() missing litem"; + std::cerr << std::endl; + continue; + } + + PostedItem *item = dynamic_cast(litem->widget()); + if (item) + { + std::cerr << "PostedListWidget::shallowClearPosts() item: " << item; + std::cerr << std::endl; + + postedItems.push_back(item); + } + else + { + std::cerr << "PostedListWidget::shallowClearPosts() Found Child, which is not a PostedItem???"; + std::cerr << std::endl; + } + } + + for(pit = postedItems.begin(); pit != postedItems.end(); pit++) + { + PostedItem *item = *pit; + alayout->removeWidget(item); + } +} + +void PostedListWidget::setAllMessagesRead(bool read) +{ +// if (mPostedId.isNull() || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) { +// return; +// } + +// QList::iterator mit; +// for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); ++mit) { +// GxsChannelPostItem *item = *mit; +// RsGxsGrpMsgIdPair msgPair = std::make_pair(item->groupId(), item->messageId()); + +// uint32_t token; +// rsGxsChannels->setMessageReadStatus(token, msgPair, read); +// } +} + +//void PostedListWidget::subscribeGroup(bool subscribe) +//{ +// if (mChannelId.isNull()) { +// return; +// } + +// uint32_t token; +// rsGxsChannels->subscribeToGroup(token, mChannelId, subscribe); +//// mChannelQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_SUBSCRIBE_CHANGE); +//} + +void PostedListWidget::updateCurrentDisplayComplete(const uint32_t &token) +{ + std::cerr << "PostedListWidget::updateCurrentDisplayComplete()"; + std::cerr << std::endl; + + std::vector posts; + rsPosted->getPostData(token, posts); + + mStateHelper->setActive(TOKEN_USER_TYPE_POST, true); + + std::vector::iterator vit; + for(vit = posts.begin(); vit != posts.end(); vit++) + { + RsPostedPost& p = *vit; + + // modify post content + if(mPosts.find(p.mMeta.mMsgId) != mPosts.end()) + { + std::cerr << "PostedListWidget::updateCurrentDisplayComplete() updating MsgId: " << p.mMeta.mMsgId; + std::cerr << std::endl; + + mPosts[p.mMeta.mMsgId]->setContent(p); + } + else + { + std::cerr << "PostedListWidget::updateCurrentDisplayComplete() loading New MsgId: " << p.mMeta.mMsgId; + std::cerr << std::endl; + /* insert new entry */ + loadPost(p); + } + } + + time_t now = time(NULL); + QMap::iterator pit; + for(pit = mPosts.begin(); pit != mPosts.end(); pit++) + { + (*pit)->post().calculateScores(now); + } + + applyRanking(); + + mStateHelper->setLoading(TOKEN_USER_TYPE_POST, false); + emit groupChanged(this); +} + +//void PostedListWidget::acknowledgeSubscribeChange(const uint32_t &token) +//{ +// std::cerr << "PostedListWidget::acknowledgeSubscribeChange()"; +// std::cerr << std::endl; + +// std::vector posts; +// RsGxsGroupId groupId; +// rsPosted->acknowledgeGrp(token, groupId); + +// insertGroups(); +//} + +/*********************** **** **** **** ***********************/ +/*********************** **** **** **** ***********************/ +/*********************** **** **** **** ***********************/ + +void PostedListWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req) +{ + std::cerr << "PostedListWidget::loadRequest() UserType: " << req.mUserType; + std::cerr << std::endl; + + if (queue == mPostedQueue) + { + /* now switch on req */ + switch(req.mUserType) + { + case TOKEN_USER_TYPE_TOPIC: + switch(req.mAnsType) + { + case RS_TOKREQ_ANSTYPE_DATA: + loadGroupData(req.mToken); + break; + default: + std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; + break; + } + break; + case TOKEN_USER_TYPE_POST: + switch(req.mAnsType) + { + case RS_TOKREQ_ANSTYPE_ACK: + acknowledgePostMsg(req.mToken); + break; + case RS_TOKREQ_ANSTYPE_DATA: + loadPostData(req.mToken); + break; + default: + std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; + break; + } + break; + case TOKEN_USER_TYPE_VOTE: + switch(req.mAnsType) + { + case RS_TOKREQ_ANSTYPE_ACK: + acknowledgeVoteMsg(req.mToken); + break; + default: + std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; + break; + } + break; + case TOKEN_USER_TYPE_POST_MOD: + switch(req.mAnsType) + { + case RS_TOKREQ_ANSTYPE_DATA: + updateCurrentDisplayComplete(req.mToken); + break; + default: + std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; + break; + } + break; +// case TOKEN_USER_TYPE_POST_RANKINGS: +// switch(req.mAnsType) +// { +// case RS_TOKREQ_ANSTYPE_DATA: +// //loadRankings(req.mToken); +// break; +// default: +// std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl; +// break; +// } +// case TOKEN_USER_TYPE_SUBSCRIBE_CHANGE: +// acknowledgeSubscribeChange(req.mToken); +// break; + default: + std::cerr << "PostedListWidget::loadRequest() ERROR: INVALID TYPE"; + std::cerr << std::endl; + break; + } + } +} diff --git a/retroshare-gui/src/gui/Posted/PostedListDialog.h b/retroshare-gui/src/gui/Posted/PostedListWidget.h similarity index 50% rename from retroshare-gui/src/gui/Posted/PostedListDialog.h rename to retroshare-gui/src/gui/Posted/PostedListWidget.h index c652e8005..3c884b112 100644 --- a/retroshare-gui/src/gui/Posted/PostedListDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidget.h @@ -21,82 +21,67 @@ * */ -#ifndef MRK_POSTED_LIST_DIALOG_H -#define MRK_POSTED_LIST_DIALOG_H +#ifndef POSTED_LIST_WIDGET_H +#define POSTED_LIST_WIDGET_H -#include "retroshare-gui/mainpage.h" -#include "ui_PostedListDialog.h" +#include -#include - -#include "util/TokenQueue.h" -#include "gui/gxs/RsGxsUpdateBroadcastPage.h" - -#include "gui/gxs/GxsCommentContainer.h" +#include "gui/gxs/GxsMessageFrameWidget.h" #include "gui/feeds/FeedHolder.h" +#include "util/TokenQueue.h" -#define IMAGE_POSTED ":/images/posted_32.png" - +class RsPostedGroup; +class RsPostedPost; class PostedItem; +class UIStateHelper; -/*********************** **** **** **** ***********************/ -/** Request / Response of Data ********************************/ -/*********************** **** **** **** ***********************/ +namespace Ui { +class PostedListWidget; +} -#define POSTEDDIALOG_LISTING 1 -#define POSTEDDIALOG_CURRENTFORUM 2 -#define POSTEDDIALOG_INSERTTHREADS 3 -#define POSTEDDIALOG_INSERTCHILD 4 -#define POSTEDDIALOG_INSERT_POST 5 -#define POSTEDDIALOG_REPLY_MESSAGE 6 - -class PostedListDialog : public RsGxsUpdateBroadcastPage, public FeedHolder, public TokenResponse, public GxsServiceDialog +class PostedListWidget : public GxsMessageFrameWidget, public FeedHolder, public TokenResponse { Q_OBJECT public: - PostedListDialog(QWidget *parent = 0); - - virtual QIcon iconPixmap() const { return QIcon(IMAGE_POSTED) ; } //MainPage - virtual QString pageName() const { return tr("Posted Links") ; } //MainPage - virtual QString helpText() const { return ""; } //MainPage - + PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent = 0); + ~PostedListWidget(); - // Overloaded from FeedHolder. + /* GxsMessageFrameWidget */ + virtual RsGxsGroupId groupId() { return mPostedId; } + virtual void setGroupId(const RsGxsGroupId &postedId); + 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 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); + +protected: + virtual void updateDisplay(bool complete); + private slots: - void groupListCustomPopupMenu(QPoint point); - void changedTopic(const QString &id); - - void newTopic(); - void showTopic(); - void editTopic(); - void createNewGxsId(); - - void showGroupDetails(); void newPost(); void submitVote(const RsGxsGrpMsgIdPair& msgId, bool up); void getRankings(); - void subscribeTopic(); - void unsubscribeTopic(); +// void subscribeTopic(); +// void unsubscribeTopic(); void showNext(); void showPrev(); - - void todo(); - -protected: - virtual void updateDisplay(bool complete); private: + void processSettings(bool load); void updateShowText(); void clearPosts(); @@ -108,24 +93,17 @@ private: void loadPost(const RsPostedPost &post); - void insertGroups(); - void requestGroupSummary(); - void acknowledgeGroup(const uint32_t &token); - void loadGroupSummary(const uint32_t &token); - - void requestGroupSummary_CurrentForum(const RsGxsGroupId &forumId); - void loadGroupSummary_CurrentForum(const uint32_t &token); + void requestGroupData(); + void loadGroupData(const uint32_t &token); + void insertPostedDetails(const RsPostedGroup &group); // subscribe/unsubscribe ack. - void acknowledgeSubscribeChange(const uint32_t &token); +// void acknowledgeSubscribeChange(const uint32_t &token); // posts void acknowledgePostMsg(const uint32_t &token); void loadPostData(const uint32_t &token); - void insertThreads(); - void loadCurrentTopicThreads(const RsGxsGroupId &forumId); - void requestGroupThreadData_InsertThreads(const RsGxsGroupId &forumId); - void loadGroupThreadData_InsertThreads(const uint32_t &token); + void requestPosts(); // votes void acknowledgeVoteMsg(const uint32_t& token); @@ -140,27 +118,16 @@ private: void updateDisplayedItems(const std::vector& msgIds); void updateCurrentDisplayComplete(const uint32_t& token); - void insertGroupData(const std::list &groupList); - void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo); - - void loadRequest(const TokenQueue *queue, const TokenRequest &req); - - private: - QTreeWidgetItem *yourTopics; - QTreeWidgetItem *subscribedTopics; - QTreeWidgetItem *popularTopics; - QTreeWidgetItem *otherTopics; - int mSortMethod; int mLastSortMethod; int mPostIndex; int mPostShow; - bool mThreadLoading; - RsGxsGroupId mCurrTopicId; + int mSubscribeFlags; + RsGxsGroupId mPostedId; + QString mName; - QMap mGroups; QMap mPosts; std::list mPostList; @@ -168,9 +135,10 @@ private: //CommentHolder* mCommentHolder; + UIStateHelper *mStateHelper; + /* UI - from Designer */ - Ui::PostedListDialog ui; + Ui::PostedListWidget *ui; }; #endif - diff --git a/retroshare-gui/src/gui/Posted/PostedListWidget.ui b/retroshare-gui/src/gui/Posted/PostedListWidget.ui new file mode 100644 index 000000000..60ab3f23b --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedListWidget.ui @@ -0,0 +1,332 @@ + + + PostedListWidget + + + + 0 + 0 + 756 + 428 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 6 + + + 6 + + + + + false + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Hot + + + + :/images/hot_24.png:/images/hot_24.png + + + + 24 + 24 + + + + true + + + true + + + + + + + New + + + + :/images/new_24.png:/images/new_24.png + + + + 24 + 24 + + + + true + + + true + + + + + + + Top + + + + :/images/vote_up.png:/images/vote_up.png + + + + 24 + 24 + + + + true + + + false + + + true + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + Today + + + + + Yesterday + + + + + This Week + + + + + This Month + + + + + This Year + + + + + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Create new Identity + + + New ID + + + + :/images/identity/identity_create_32.png:/images/identity/identity_create_32.png + + + + 24 + 24 + + + + true + + + + + + + + + + 6 + + + 6 + + + 0 + + + 6 + + + 0 + + + + + Submit a new Post + + + + :/images/posted_24.png:/images/posted_24.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Showing 1-100 + + + + + + + Prev + + + + + + + Next + + + + + + + + + + true + + + + + 0 + 0 + 754 + 16 + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + GxsIdChooser + QComboBox +
gui/gxs/GxsIdChooser.h
+
+
+ + + + + +
diff --git a/retroshare-gui/src/gui/Posted/PostedUserNotify.cpp b/retroshare-gui/src/gui/Posted/PostedUserNotify.cpp new file mode 100644 index 000000000..071567bd9 --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedUserNotify.cpp @@ -0,0 +1,94 @@ +/**************************************************************** + * 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 "PostedUserNotify.h" +#include "gui/settings/rsharesettings.h" +#include "gui/MainWindow.h" + +PostedUserNotify::PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) : + GxsUserNotify(ifaceImpl, parent) +{ +} + +bool PostedUserNotify::hasSetting(QString &name) +{ + name = tr("Posted"); + + return true; +} + +bool PostedUserNotify::notifyEnabled() +{ + return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_POSTED); +} + +bool PostedUserNotify::notifyCombined() +{ + return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_POSTED_COMBINED); +} + +bool PostedUserNotify::notifyBlink() +{ + return (Settings->getTrayNotifyBlinkFlags() & TRAYNOTIFY_BLINK_POSTED); +} + +void PostedUserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink) +{ + uint notifyFlags = Settings->getTrayNotifyFlags(); + uint blinkFlags = Settings->getTrayNotifyBlinkFlags(); + + if (enabled) { + notifyFlags |= TRAYNOTIFY_POSTED; + } else { + notifyFlags &= ~TRAYNOTIFY_POSTED; + } + + if (combined) { + notifyFlags |= TRAYNOTIFY_POSTED_COMBINED; + } else { + notifyFlags &= ~TRAYNOTIFY_POSTED_COMBINED; + } + + if (blink) { + blinkFlags |= TRAYNOTIFY_BLINK_POSTED; + } else { + blinkFlags &= ~TRAYNOTIFY_BLINK_POSTED; + } + + Settings->setTrayNotifyFlags(notifyFlags); + Settings->setTrayNotifyBlinkFlags(blinkFlags); +} + +QIcon PostedUserNotify::getIcon() +{ + return QIcon(":/images/wikibook_32.png"); +} + +QIcon PostedUserNotify::getMainIcon(bool hasNew) +{ + //TODO: add new icon + return hasNew ? QIcon(":/images/wikibook_32.png") : QIcon(":/images/wikibook_32.png"); +} + +void PostedUserNotify::iconClicked() +{ + MainWindow::showWindow(MainWindow::Posted); +} diff --git a/retroshare-gui/src/gui/Posted/PostedUserNotify.h b/retroshare-gui/src/gui/Posted/PostedUserNotify.h new file mode 100644 index 000000000..5ec96e8fc --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedUserNotify.h @@ -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 POSTEDUSERNOTIFY_H +#define POSTEDUSERNOTIFY_H + +#include "gui/gxs/GxsUserNotify.h" + +class PostedUserNotify : public GxsUserNotify +{ + Q_OBJECT + +public: + PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0); + + virtual bool hasSetting(QString &name); + virtual bool notifyEnabled(); + virtual bool notifyCombined(); + virtual bool notifyBlink(); + virtual void setNotifyEnabled(bool enabled, bool combined, bool blink); + +private: + virtual QIcon getIcon(); + virtual QIcon getMainIcon(bool hasNew); + virtual void iconClicked(); +}; + +#endif // POSTEDUSERNOTIFY_H diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 6ba47e9f4..f7fb8bf96 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -261,15 +261,19 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails())); action->setEnabled (!mGroupId.isNull() && isAdmin); - action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share"), this, SLOT(shareKey())); - action->setEnabled(!mGroupId.isNull() && isAdmin); + if (shareKeyType()) { + action = contextMnu.addAction(QIcon(IMAGE_SHARE), 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()); + if (getLinkType() != RetroShareLink::TYPE_UNKNOWN) { + action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink())); + action->setEnabled(!mGroupId.isNull()); + } contextMnu.addSeparator(); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index f1c410e2c..d03a7f24c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -125,8 +125,8 @@ void GxsChannelPostsWidget::updateDisplay(bool complete) { if (complete) { /* Fill complete */ - requestGroupData(mChannelId); - requestPosts(mChannelId); + requestGroupData(); + requestPosts(); return; } @@ -144,7 +144,7 @@ void GxsChannelPostsWidget::updateDisplay(bool complete) if (!mChannelId.isNull() && std::find(grpIds.begin(), grpIds.end(), mChannelId) != grpIds.end()) { updateGroup = true; /* Do we need to fill all posts? */ - requestPosts(mChannelId); + requestPosts(); } else { std::map > msgs; getAllMsgIds(msgs); @@ -153,13 +153,13 @@ void GxsChannelPostsWidget::updateDisplay(bool complete) std::map >::const_iterator mit = msgs.find(mChannelId); if(mit != msgs.end()) { - requestRelatedPosts(mChannelId, mit->second); + requestRelatedPosts(mit->second); } } } if (updateGroup) { - requestGroupData(mChannelId); + requestGroupData(); } } @@ -247,6 +247,10 @@ void GxsChannelPostsWidget::createMsg() return; } + if (!IS_GROUP_SUBSCRIBED(mSubscribeFlags)) { + return; + } + CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(mChannelId); msgDialog->show(); @@ -619,7 +623,7 @@ void GxsChannelPostsWidget::clearPosts() /** Request / Response of Data ********************************/ /*********************** **** **** **** ***********************/ -void GxsChannelPostsWidget::requestGroupData(const RsGxsGroupId &grpId) +void GxsChannelPostsWidget::requestGroupData() { #ifdef DEBUG_CHANNEL std::cerr << "GxsChannelPostsWidget::requestGroupData()"; @@ -630,7 +634,7 @@ void GxsChannelPostsWidget::requestGroupData(const RsGxsGroupId &grpId) mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_DATA); - if (grpId.isNull()) { + if (mChannelId.isNull()) { mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, false); mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, false); mStateHelper->clear(TOKEN_TYPE_GROUP_DATA); @@ -647,7 +651,7 @@ void GxsChannelPostsWidget::requestGroupData(const RsGxsGroupId &grpId) emit groupChanged(this); std::list groupIds; - groupIds.push_back(grpId); + groupIds.push_back(mChannelId); RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; @@ -684,7 +688,7 @@ void GxsChannelPostsWidget::loadGroupData(const uint32_t &token) emit groupChanged(this); } -void GxsChannelPostsWidget::requestPosts(const RsGxsGroupId &grpId) +void GxsChannelPostsWidget::requestPosts() { #ifdef DEBUG_CHANNEL std::cerr << "GxsChannelPostsWidget::requestPosts()"; @@ -696,7 +700,7 @@ void GxsChannelPostsWidget::requestPosts(const RsGxsGroupId &grpId) mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_POSTS); - if (grpId.isNull()) { + if (mChannelId.isNull()) { mStateHelper->setActive(TOKEN_TYPE_POSTS, false); mStateHelper->setLoading(TOKEN_TYPE_POSTS, false); mStateHelper->clear(TOKEN_TYPE_POSTS); @@ -708,7 +712,7 @@ void GxsChannelPostsWidget::requestPosts(const RsGxsGroupId &grpId) emit groupChanged(this); std::list groupIds; - groupIds.push_back(grpId); + groupIds.push_back(mChannelId); RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; @@ -735,7 +739,7 @@ void GxsChannelPostsWidget::loadPosts(const uint32_t &token) emit groupChanged(this); } -void GxsChannelPostsWidget::requestRelatedPosts(const RsGxsGroupId &grpId, const std::vector &msgIds) +void GxsChannelPostsWidget::requestRelatedPosts(const std::vector &msgIds) { #ifdef DEBUG_CHANNEL std::cerr << "GxsChannelPostsWidget::requestRelatedPosts()"; @@ -744,7 +748,7 @@ void GxsChannelPostsWidget::requestRelatedPosts(const RsGxsGroupId &grpId, const mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_RELATEDPOSTS); - if (grpId.isNull()) { + if (mChannelId.isNull()) { mStateHelper->setActive(TOKEN_TYPE_POSTS, false); mStateHelper->setLoading(TOKEN_TYPE_POSTS, false); mStateHelper->clear(TOKEN_TYPE_POSTS); @@ -766,7 +770,7 @@ void GxsChannelPostsWidget::requestRelatedPosts(const RsGxsGroupId &grpId, const uint32_t token; std::vector relatedMsgIds; for (std::vector::const_iterator msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) { - relatedMsgIds.push_back(RsGxsGrpMsgIdPair(grpId, *msgIt)); + relatedMsgIds.push_back(RsGxsGrpMsgIdPair(mChannelId, *msgIt)); } mChannelQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, relatedMsgIds, TOKEN_TYPE_RELATEDPOSTS); } @@ -800,7 +804,7 @@ void GxsChannelPostsWidget::acknowledgeMessageUpdate(const uint32_t &token) rsGxsChannels->acknowledgeMsg(token, msgId); if (msgId.first == mChannelId) { - requestPosts(mChannelId); + requestPosts(); } } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h index 2ec800ee8..d7ca4e460 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h @@ -86,13 +86,13 @@ private: void clearPosts(); /* NEW GXS FNS */ - void requestGroupData(const RsGxsGroupId &grpId); + void requestGroupData(); void loadGroupData(const uint32_t &token); - void requestPosts(const RsGxsGroupId &grpId); + void requestPosts(); void loadPosts(const uint32_t &token); - void requestRelatedPosts(const RsGxsGroupId &grpId, const std::vector &msgIds); + void requestRelatedPosts(const std::vector &msgIds); void loadRelatedPosts(const uint32_t &token); void insertChannelDetails(const RsGxsChannelGroup &group); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 8120e9873..fc250938c 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -912,7 +912,7 @@ void GxsForumThreadWidget::insertThreads() } // Get Current Forum Info... then complete insertForumThreads(). - requestGroup_CurrentForum(mForumId); + requestGroup_CurrentForum(); } void GxsForumThreadWidget::insertForumThreads(const RsGxsForumGroup &group) @@ -1693,7 +1693,7 @@ bool GxsForumThreadWidget::filterItem(QTreeWidgetItem *item, const QString &text /** Request / Response of Data ********************************/ /*********************** **** **** **** ***********************/ -void GxsForumThreadWidget::requestGroup_CurrentForum(const RsGxsGroupId &forumId) +void GxsForumThreadWidget::requestGroup_CurrentForum() { ui->progressBar->reset(); mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, true); @@ -1706,9 +1706,9 @@ void GxsForumThreadWidget::requestGroup_CurrentForum(const RsGxsGroupId &forumId mThreadQueue->cancelActiveRequestTokens(TOKEN_TYPE_CURRENTFORUM); std::list grpIds; - grpIds.push_back(forumId); + grpIds.push_back(mForumId); - std::cerr << "GxsForumsDialog::requestGroup_CurrentForum(" << forumId << ")"; + std::cerr << "GxsForumsDialog::requestGroup_CurrentForum(" << mForumId << ")"; std::cerr << std::endl; uint32_t token; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index 4e402d4ba..8e961a853 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -142,7 +142,7 @@ private: unsigned int mUnreadCount; unsigned int mNewCount; - void requestGroup_CurrentForum(const RsGxsGroupId &forumId); + void requestGroup_CurrentForum(); void loadGroup_CurrentForum(const uint32_t &token); void requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId); diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 1c3f0251b..31eca6505 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -463,7 +463,7 @@ void RshareSettings::setNotifyFlags(uint flags) uint RshareSettings::getTrayNotifyFlags() { - return value(SETTING_TRAYNOTIFY_FLAGS, TRAYNOTIFY_PRIVATECHAT | TRAYNOTIFY_MESSAGES | TRAYNOTIFY_CHANNELS | TRAYNOTIFY_FORUMS ).toUInt(); + return value(SETTING_TRAYNOTIFY_FLAGS, TRAYNOTIFY_PRIVATECHAT | TRAYNOTIFY_MESSAGES | TRAYNOTIFY_CHANNELS | TRAYNOTIFY_FORUMS | TRAYNOTIFY_POSTED ).toUInt(); } void RshareSettings::setTrayNotifyFlags(uint flags) diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 0498c7afa..3a1b88059 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -44,11 +44,15 @@ #define TRAYNOTIFY_FORUMS_COMBINED 0x00000100 #define TRAYNOTIFY_TRANSFERS_COMBINED 0x00000200 +#define TRAYNOTIFY_POSTED 0x00000400 +#define TRAYNOTIFY_POSTED_COMBINED 0x00000800 + #define TRAYNOTIFY_BLINK_PRIVATECHAT 0x00000001 #define TRAYNOTIFY_BLINK_MESSAGES 0x00000002 #define TRAYNOTIFY_BLINK_CHANNELS 0x00000004 #define TRAYNOTIFY_BLINK_FORUMS 0x00000008 #define TRAYNOTIFY_BLINK_TRANSFERS 0x00000010 +#define TRAYNOTIFY_BLINK_POSTED 0x00000020 #define RS_CHATLOBBY_BLINK 0x00000001 diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 1ee5be20d..29b291018 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1176,16 +1176,17 @@ gxschannels { posted { HEADERS += gui/Posted/PostedDialog.h \ - gui/Posted/PostedListDialog.h \ + gui/Posted/PostedListWidget.h \ gui/Posted/PostedItem.h \ gui/Posted/PostedGroupDialog.h \ gui/Posted/PostedCreatePostDialog.h \ - gui/Posted/PostedUserTypes.h + gui/Posted/PostedUserTypes.h \ + gui/Posted/PostedUserNotify.h #gui/Posted/PostedCreateCommentDialog.h \ #gui/Posted/PostedComments.h \ - FORMS += gui/Posted/PostedListDialog.ui \ + FORMS += gui/Posted/PostedListWidget.ui \ gui/Posted/PostedItem.ui \ gui/Posted/PostedCreatePostDialog.ui \ @@ -1193,10 +1194,12 @@ posted { #gui/Posted/PostedComments.ui \ #gui/Posted/PostedCreateCommentDialog.ui - SOURCES += gui/Posted/PostedListDialog.cpp \ + SOURCES += gui/Posted/PostedDialog.cpp \ + gui/Posted/PostedListWidget.cpp \ gui/Posted/PostedItem.cpp \ gui/Posted/PostedGroupDialog.cpp \ gui/Posted/PostedCreatePostDialog.cpp \ + gui/Posted/PostedUserNotify.cpp #gui/Posted/PostedDialog.cpp \ #gui/Posted/PostedComments.cpp \