diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp index 55fc767f9..d7b54e87b 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp @@ -113,11 +113,11 @@ void GxsMessageFramePostWidget::updateDisplay(bool complete) return; } - bool updateGroup = false; if (mGroupId.isNull()) { return; } + bool updateGroup = false; const std::list &grpIdsMeta = getGrpIdsMeta(); if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), mGroupId) != grpIdsMeta.end()) { updateGroup = true; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui index 5d16f17bc..d15e299b7 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui @@ -162,10 +162,13 @@ Qt::Horizontal + + QSizePolicy::MinimumExpanding + - 314 - 10 + 0 + 0 @@ -179,6 +182,12 @@ + + + 0 + 0 + + 16777215 diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index a133d0448..796d6c4bf 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -82,9 +82,10 @@ #define ROLE_THREAD_COUNT 3 -#define TOKEN_TYPE_CURRENTFORUM 1 -#define TOKEN_TYPE_INSERT_POST 2 -#define TOKEN_TYPE_REPLY_MESSAGE 3 +#define TOKEN_TYPE_GROUPDATA 1 +#define TOKEN_TYPE_INSERT_THREADS 2 +#define TOKEN_TYPE_MESSAGEDATA 3 +#define TOKEN_TYPE_REPLY_MESSAGE 4 GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget *parent) : GxsMessageFrameWidget(rsGxsForums, parent), @@ -97,33 +98,34 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget /* Setup UI helper */ mStateHelper = new UIStateHelper(this); - mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->progressBar, UISTATE_LOADING_VISIBLE); - mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->progressText, UISTATE_LOADING_VISIBLE); - mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->subscribeToolButton); - mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->newthreadButton); - mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->threadTreeWidget, UISTATE_ACTIVE_ENABLED); + mStateHelper->addWidget(TOKEN_TYPE_GROUPDATA, ui->subscribeToolButton); + mStateHelper->addWidget(TOKEN_TYPE_GROUPDATA, ui->newthreadButton); - mStateHelper->addLoadPlaceholder(TOKEN_TYPE_CURRENTFORUM, ui->progressText); + mStateHelper->addClear(TOKEN_TYPE_GROUPDATA, ui->forumName); - mStateHelper->addClear(TOKEN_TYPE_CURRENTFORUM, ui->threadTreeWidget); - mStateHelper->addClear(TOKEN_TYPE_CURRENTFORUM, ui->forumName); - mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->nextUnreadButton); + mStateHelper->addWidget(TOKEN_TYPE_INSERT_THREADS, ui->progressBar, UISTATE_LOADING_VISIBLE); + mStateHelper->addWidget(TOKEN_TYPE_INSERT_THREADS, ui->progressText, UISTATE_LOADING_VISIBLE); + mStateHelper->addWidget(TOKEN_TYPE_INSERT_THREADS, ui->threadTreeWidget, UISTATE_ACTIVE_ENABLED); + mStateHelper->addLoadPlaceholder(TOKEN_TYPE_INSERT_THREADS, ui->progressText); + mStateHelper->addWidget(TOKEN_TYPE_INSERT_THREADS, ui->nextUnreadButton); + mStateHelper->addWidget(TOKEN_TYPE_INSERT_THREADS, ui->previousButton); + mStateHelper->addWidget(TOKEN_TYPE_INSERT_THREADS, ui->nextButton); - mStateHelper->addWidget(TOKEN_TYPE_INSERT_POST, ui->previousButton); - mStateHelper->addWidget(TOKEN_TYPE_INSERT_POST, ui->nextButton); - mStateHelper->addWidget(TOKEN_TYPE_INSERT_POST, ui->newmessageButton); - mStateHelper->addWidget(TOKEN_TYPE_INSERT_POST, ui->postText); - mStateHelper->addWidget(TOKEN_TYPE_INSERT_POST, ui->downloadButton); + mStateHelper->addClear(TOKEN_TYPE_INSERT_THREADS, ui->threadTreeWidget); - mStateHelper->addLoadPlaceholder(TOKEN_TYPE_INSERT_POST, ui->postText); - mStateHelper->addLoadPlaceholder(TOKEN_TYPE_INSERT_POST, ui->threadTitle); + mStateHelper->addWidget(TOKEN_TYPE_MESSAGEDATA, ui->newmessageButton); +// mStateHelper->addWidget(TOKEN_TYPE_MESSAGEDATA, ui->postText); + mStateHelper->addWidget(TOKEN_TYPE_MESSAGEDATA, ui->downloadButton); + + mStateHelper->addLoadPlaceholder(TOKEN_TYPE_MESSAGEDATA, ui->postText); + mStateHelper->addLoadPlaceholder(TOKEN_TYPE_MESSAGEDATA, ui->threadTitle); mSubscribeFlags = 0; mInProcessSettings = false; mUnreadCount = 0; mNewCount = 0; - mThreadQueue = new TokenQueue(rsGxsForums->getTokenService(), this); + mTokenQueue = new TokenQueue(rsGxsForums->getTokenService(), this); mInMsgAsReadUnread = false; @@ -187,14 +189,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget ui->progressBar->hide(); ui->progressText->hide(); -// mTimer = new QTimer; -// mTimer->setInterval(1000); -// mTimer->setSingleShot(true); - -// QObject::connect(mTimer, SIGNAL(timeout()), this, SLOT(updateDisplay())); - -// mTimer->start(); - mFillThread = NULL; ui->threadTreeWidget->setGxsIdColumn(COLUMN_THREAD_AUTHOR); @@ -216,8 +210,7 @@ GxsForumThreadWidget::~GxsForumThreadWidget() delete ui; -// delete(mTimer); - delete(mThreadQueue); + delete(mTokenQueue); delete(mThreadCompareRole); } @@ -277,7 +270,7 @@ void GxsForumThreadWidget::setGroupId(const RsGxsGroupId &forumId) emit groupChanged(this); - insertThreads(); + fillComplete(); } QString GxsForumThreadWidget::groupName(bool withUnreadCount) @@ -293,7 +286,7 @@ QString GxsForumThreadWidget::groupName(bool withUnreadCount) QIcon GxsForumThreadWidget::groupIcon() { - if (mStateHelper->isLoading(TOKEN_TYPE_CURRENTFORUM) || mFillThread) { + if (mStateHelper->isLoading(TOKEN_TYPE_GROUPDATA) || mFillThread) { return QIcon(":/images/kalarm.png"); } @@ -317,25 +310,72 @@ void GxsForumThreadWidget::changeEvent(QEvent *e) } } +static void removeMessages(std::map > &msgIds, const QList &removeMsgId) +{ + std::map >::iterator grpIt; + for (grpIt = msgIds.begin(); grpIt != msgIds.end(); ) { + std::vector &msgs = grpIt->second; + + QList::const_iterator removeMsgIt; + for (removeMsgIt = removeMsgId.begin(); removeMsgIt != removeMsgId.end(); ++removeMsgIt) { + std::vector::iterator msgIt = std::find(msgs.begin(), msgs.end(), *removeMsgIt); + if (msgIt != msgs.end()) { + msgs.erase(msgIt); + } + } + + if (msgs.empty()) { + std::map >::iterator grpItErase = grpIt++; + msgIds.erase(grpItErase); + } else { + ++grpIt; + } + } +} + void GxsForumThreadWidget::updateDisplay(bool complete) { if (complete) { - /* Not needed */ + /* Fill complete */ + requestGroupData(); + insertThreads(); + insertMessage(); + + mIgnoredMsgId.clear(); + return; } + bool updateGroup = false; + const std::list &grpIdsMeta = getGrpIdsMeta(); + if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), mForumId) != grpIdsMeta.end()) { + updateGroup = true; + } + const std::list &grpIds = getGrpIds(); if (std::find(grpIds.begin(), grpIds.end(), mForumId) != grpIds.end()) { + updateGroup = true; /* Update threads */ insertThreads(); } else { std::map > msgIds; getAllMsgIds(msgIds); + + if (!mIgnoredMsgId.empty()) { + /* Filter ignored messages */ + removeMessages(msgIds, mIgnoredMsgId); + mIgnoredMsgId.clear(); + } + if (msgIds.find(mForumId) != msgIds.end()) { /* Update threads */ insertThreads(); } } + + if (updateGroup) { + requestGroupData(); + } } void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) @@ -487,11 +527,15 @@ void GxsForumThreadWidget::changedThread() return; } - insertPost(); + insertMessage(); } void GxsForumThreadWidget::clickedThread(QTreeWidgetItem *item, int column) { + if (item == NULL) { + return; + } + if (mFillThread) { return; } @@ -500,10 +544,6 @@ void GxsForumThreadWidget::clickedThread(QTreeWidgetItem *item, int column) return; } - if (item == NULL) { - return; - } - if (column == COLUMN_THREAD_READ) { QList rows; rows.append(item); @@ -512,37 +552,6 @@ void GxsForumThreadWidget::clickedThread(QTreeWidgetItem *item, int column) } } -#ifdef TODO -void GxsForumThreadWidget::forumMsgReadStatusChanged(const QString &forumId, const QString &msgId, int status) -{ - if (mInMsgAsReadUnread) { - return; - } - - if (forumId.toStdString() == mCurrForumId) { - /* 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() == msgId) { - // update status - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, status); - - QTreeWidgetItem *parentItem = item; - while (parentItem->parent()) { - parentItem = parentItem->parent(); - } - calculateIconsAndFonts(parentItem); - break; - } - } - } - updateMessageSummaryList(forumId.toStdString()); -} -#endif - void GxsForumThreadWidget::calculateIconsAndFonts(QTreeWidgetItem *item, bool &hasReadChilddren, bool &hasUnreadChilddren) { uint32_t status = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); @@ -674,6 +683,28 @@ static void cleanupItems (QList &items) items.clear(); } +void GxsForumThreadWidget::insertGroupData(const RsGxsForumGroup &group) +{ +#ifdef DEBUG_FORUMS + std::cerr << "GxsForumThreadWidget::insertGroupData" << std::endl; +#endif + + mSubscribeFlags = group.mMeta.mSubscribeFlags; + ui->forumName->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str())); + mForumDescription = QString::fromUtf8(group.mDescription.c_str()); + + ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(mSubscribeFlags)); + mStateHelper->setWidgetEnabled(ui->newthreadButton, (IS_GROUP_SUBSCRIBED(mSubscribeFlags))); + + if (mThreadId.isNull() && !mStateHelper->isLoading(TOKEN_TYPE_MESSAGEDATA)) + { + ui->threadTitle->setText(tr("Forum Description")); + ui->postText->setText(mForumDescription); + } + + calculateIconsAndFonts(); +} + void GxsForumThreadWidget::fillThreadFinished() { #ifdef DEBUG_FORUMS @@ -687,8 +718,7 @@ void GxsForumThreadWidget::fillThreadFinished() // current thread has finished, hide progressbar and release thread mFillThread = NULL; - mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, false); - mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, false); + mStateHelper->setLoading(TOKEN_TYPE_INSERT_THREADS, false); emit groupChanged(this); } @@ -702,7 +732,7 @@ void GxsForumThreadWidget::fillThreadFinished() std::cerr << "GxsForumThreadWidget::fillThreadFinished Add messages" << std::endl; #endif - mStateHelper->setActive(TOKEN_TYPE_CURRENTFORUM, true); + mStateHelper->setActive(TOKEN_TYPE_INSERT_THREADS, true); ui->threadTreeWidget->setSortingEnabled(false); /* add all messages in! */ @@ -749,7 +779,6 @@ void GxsForumThreadWidget::fillThreadFinished() if (ui->filterLineEdit->text().isEmpty() == false) { filterItems(ui->filterLineEdit->text()); } - insertPost(); calculateIconsAndFonts(); calculateUnreadCount(); emit groupChanged(this); @@ -886,6 +915,9 @@ void GxsForumThreadWidget::insertThreads() std::cerr << "GxsForumThreadWidget::insertThreads()" << std::endl; #endif + mNavigatePendingMsgId.clear(); + ui->progressBar->reset(); + if (mFillThread) { #ifdef DEBUG_FORUMS std::cerr << "GxsForumThreadWidget::insertThreads() stop current fill thread" << std::endl; @@ -896,20 +928,15 @@ void GxsForumThreadWidget::insertThreads() thread->stop(); delete(thread); - mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, false); - mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, false); + mStateHelper->setLoading(TOKEN_TYPE_INSERT_THREADS, false); } - mSubscribeFlags = 0; - mForumDescription.clear(); - if (mForumId.isNull()) { /* not an actual forum - clear */ - mStateHelper->setActive(TOKEN_TYPE_CURRENTFORUM, false); - mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false); - mStateHelper->clear(TOKEN_TYPE_CURRENTFORUM); - mStateHelper->clear(TOKEN_TYPE_INSERT_POST); + mStateHelper->setActive(TOKEN_TYPE_INSERT_THREADS, false); + mStateHelper->clear(TOKEN_TYPE_INSERT_THREADS); + /* clear last stored forumID */ mForumId.clear(); mLastForumID.clear(); @@ -921,25 +948,12 @@ void GxsForumThreadWidget::insertThreads() return; } - // Get Current Forum Info... then complete insertForumThreads(). - requestGroup_CurrentForum(); -} - -void GxsForumThreadWidget::insertForumThreads(const RsGxsForumGroup &group) -{ - mSubscribeFlags = group.mMeta.mSubscribeFlags; - ui->forumName->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str())); - mForumDescription = QString::fromUtf8(group.mDescription.c_str()); - - ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(mSubscribeFlags)); - - ui->progressBar->reset(); - mStateHelper->setActive(TOKEN_TYPE_CURRENTFORUM, true); - #ifdef DEBUG_FORUMS std::cerr << "GxsForumThreadWidget::insertThreads() Start filling Forum threads" << std::endl; #endif + mStateHelper->setLoading(TOKEN_TYPE_INSERT_THREADS, true); + // create fill thread mFillThread = new GxsForumsFillThread(this); @@ -948,7 +962,6 @@ void GxsForumThreadWidget::insertForumThreads(const RsGxsForumGroup &group) mFillThread->mForumId = mForumId; mFillThread->mFilterColumn = ui->filterLineEdit->currentFilter(); mFillThread->mFilterColumn = COLUMN_THREAD_TITLE; - mFillThread->mSubscribeFlags = mSubscribeFlags; mFillThread->mExpandNewMessages = Settings->getForumExpandNewMessages(); mFillThread->mViewType = ui->viewBox->currentIndex(); if (mLastViewType != mFillThread->mViewType || mLastForumID != mForumId) { @@ -1143,14 +1156,12 @@ void GxsForumThreadWidget::fillChildren(QTreeWidgetItem *parentItem, QTreeWidget } } -void GxsForumThreadWidget::insertPost() +void GxsForumThreadWidget::insertMessage() { if (mForumId.isNull()) { - mStateHelper->setActive(TOKEN_TYPE_CURRENTFORUM, false); - mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false); - mStateHelper->clear(TOKEN_TYPE_CURRENTFORUM); - mStateHelper->clear(TOKEN_TYPE_INSERT_POST); + mStateHelper->setActive(TOKEN_TYPE_MESSAGEDATA, false); + mStateHelper->clear(TOKEN_TYPE_MESSAGEDATA); ui->postText->clear(); ui->threadTitle->clear(); @@ -1159,15 +1170,15 @@ void GxsForumThreadWidget::insertPost() if (mThreadId.isNull()) { - mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false); - mStateHelper->clear(TOKEN_TYPE_INSERT_POST); + mStateHelper->setActive(TOKEN_TYPE_MESSAGEDATA, false); + mStateHelper->clear(TOKEN_TYPE_MESSAGEDATA); ui->threadTitle->setText(tr("Forum Description")); ui->postText->setText(mForumDescription); return; } - mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, true); + mStateHelper->setActive(TOKEN_TYPE_MESSAGEDATA, true); QTreeWidgetItem *item = ui->threadTreeWidget->currentItem(); if (item) { @@ -1187,14 +1198,13 @@ void GxsForumThreadWidget::insertPost() /* blank text, incase we get nothing */ ui->postText->clear(); - /* request Post */ - // Get Forum Post ... then complete insertPostData(). - RsGxsGrpMsgIdPair postId = std::make_pair(mForumId, mThreadId); - requestMsgData_InsertPost(postId); + /* request Post */ + RsGxsGrpMsgIdPair msgId = std::make_pair(mForumId, mThreadId); + requestMessageData(msgId); } -void GxsForumThreadWidget::insertPostData(const RsGxsForumMsg &msg) +void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg) { /* As some time has elapsed since request - check that this is still the current msg. * otherwise, another request will fill the data @@ -1209,12 +1219,14 @@ void GxsForumThreadWidget::insertPostData(const RsGxsForumMsg &msg) std::cerr << "\t or CurrThdId: " << mThreadId << " != msg.MsgId: " << msg.mMeta.mMsgId; std::cerr << std::endl; std::cerr << std::endl; - mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false); - mStateHelper->clear(TOKEN_TYPE_INSERT_POST); + + mStateHelper->setActive(TOKEN_TYPE_MESSAGEDATA, false); + mStateHelper->clear(TOKEN_TYPE_MESSAGEDATA); + return; } - mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, true); + mStateHelper->setActive(TOKEN_TYPE_MESSAGEDATA, true); QTreeWidgetItem *item = ui->threadTreeWidget->currentItem(); @@ -1341,23 +1353,6 @@ void GxsForumThreadWidget::nextUnreadMessage() } } -// TODO -#if 0 -void GxsForumThreadWidget::removemessage() -{ - //std::cerr << "GxsForumThreadWidget::removemessage()" << std::endl; - std::string cid, mid; - if (!getCurrentMsg(cid, mid)) - { - //std::cerr << "GxsForumThreadWidget::removemessage()"; - //std::cerr << " No Message selected" << std::endl; - return; - } - - rsMsgs -> MessageDelete(mid); -} -#endif - /* get selected messages the messages tree is single selected, but who knows ... */ int GxsForumThreadWidget::getSelectedMsgCount(QList *rows, QList *rowsRead, QList *rowsUnread) @@ -1414,6 +1409,9 @@ void GxsForumThreadWidget::setMsgReadStatus(QList &rows, bool uint32_t token; rsGxsForums->setMessageReadStatus(token, msgPair, read); + /* Add message id to ignore list for the next updateDisplay */ + mIgnoredMsgId.push_back(RsGxsMessageId(msgId)); + (*row)->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, statusNew); QTreeWidgetItem *parentItem = *row; @@ -1432,7 +1430,6 @@ void GxsForumThreadWidget::setMsgReadStatus(QList &rows, bool for (std::list::iterator it = changedItems.begin(); it != changedItems.end(); ++it) { calculateIconsAndFonts(*it); } -//#TODO updateMessageSummaryList(mForumId); calculateUnreadCount(); } } @@ -1514,7 +1511,7 @@ void GxsForumThreadWidget::setAllMessagesRead(bool read) bool GxsForumThreadWidget::navigate(const RsGxsMessageId &msgId) { - if (mStateHelper->isLoading(TOKEN_TYPE_CURRENTFORUM)) { + if (mStateHelper->isLoading(TOKEN_TYPE_INSERT_THREADS)) { mNavigatePendingMsgId = msgId; /* No information if message is available */ @@ -1561,7 +1558,7 @@ void GxsForumThreadWidget::subscribeGroup(bool subscribe) uint32_t token; rsGxsForums->subscribeToGroup(token, mForumId, subscribe); -// mThreadQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_SUBSCRIBE_CHANGE); +// mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_SUBSCRIBE_CHANGE); } void GxsForumThreadWidget::createmessage() @@ -1719,117 +1716,122 @@ bool GxsForumThreadWidget::filterItem(QTreeWidgetItem *item, const QString &text /** Request / Response of Data ********************************/ /*********************** **** **** **** ***********************/ -void GxsForumThreadWidget::requestGroup_CurrentForum() +void GxsForumThreadWidget::requestGroupData() { - ui->progressBar->reset(); - mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, true); - mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, true); - emit groupChanged(this); + mSubscribeFlags = 0; + mForumDescription.clear(); - mNavigatePendingMsgId.clear(); + mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUPDATA); + + if (mForumId.isNull()) { + mStateHelper->setActive(TOKEN_TYPE_GROUPDATA, false); + mStateHelper->setLoading(TOKEN_TYPE_GROUPDATA, false); + mStateHelper->clear(TOKEN_TYPE_GROUPDATA); + + emit groupChanged(this); + + return; + } + + mStateHelper->setLoading(TOKEN_TYPE_GROUPDATA, true); + emit groupChanged(this); RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; - mThreadQueue->cancelActiveRequestTokens(TOKEN_TYPE_CURRENTFORUM); - std::list grpIds; grpIds.push_back(mForumId); - std::cerr << "GxsForumThreadWidget::requestGroup_CurrentForum(" << mForumId << ")"; +#ifdef DEBUG_FORUMS + std::cerr << "GxsForumThreadWidget::requestGroupData(" << mForumId << ")"; std::cerr << std::endl; +#endif uint32_t token; - mThreadQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, TOKEN_TYPE_CURRENTFORUM); + mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, TOKEN_TYPE_GROUPDATA); } -void GxsForumThreadWidget::loadGroup_CurrentForum(const uint32_t &token) +void GxsForumThreadWidget::loadGroupData(const uint32_t &token) { +#ifdef DEBUG_FORUMS std::cerr << "GxsForumThreadWidget::loadGroup_CurrentForum()"; std::cerr << std::endl; +#endif std::vector groups; rsGxsForums->getGroupData(token, groups); + mStateHelper->setLoading(TOKEN_TYPE_GROUPDATA, false); + if (groups.size() == 1) { - insertForumThreads(groups[0]); + insertGroupData(groups[0]); + + mStateHelper->setActive(TOKEN_TYPE_GROUPDATA, true); } else { std::cerr << "GxsForumThreadWidget::loadGroupSummary_CurrentForum() ERROR Invalid Number of Groups..."; std::cerr << std::endl; - mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, false); - mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, false); - mStateHelper->setActive(TOKEN_TYPE_CURRENTFORUM, false); - mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false); - mStateHelper->clear(TOKEN_TYPE_CURRENTFORUM); - mStateHelper->clear(TOKEN_TYPE_INSERT_POST); - emit groupChanged(this); + mStateHelper->setActive(TOKEN_TYPE_GROUPDATA, false); + mStateHelper->clear(TOKEN_TYPE_GROUPDATA); } + + emit groupChanged(this); } /*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ -void GxsForumThreadWidget::requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId) +void GxsForumThreadWidget::requestMessageData(const RsGxsGrpMsgIdPair &msgId) { - mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, true); + mStateHelper->setLoading(TOKEN_TYPE_MESSAGEDATA, true); -#if 0 - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; - - std::cerr << "GxsForumThreadWidget::requestMsgData_InsertPost(" << msgId.first << "," << msgId.second << ")"; - std::cerr << std::endl; - - std::vector msgIds; - msgIds.push_back(msgId); - uint32_t token; - mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_INSERT_POST); -#else - - mThreadQueue->cancelActiveRequestTokens(TOKEN_TYPE_INSERT_POST); + mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_MESSAGEDATA); RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; - std::cerr << "GxsForumThreadWidget::requestMsgData_InsertPost(" << msgId.first << "," << msgId.second << ")"; +#ifdef DEBUG_FORUMS + std::cerr << "GxsForumThreadWidget::requestMessage(" << msgId.first << "," << msgId.second << ")"; std::cerr << std::endl; +#endif GxsMsgReq msgIds; std::vector &vect = msgIds[msgId.first]; vect.push_back(msgId.second); uint32_t token; - mThreadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_INSERT_POST); -#endif + mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_MESSAGEDATA); } -void GxsForumThreadWidget::loadMsgData_InsertPost(const uint32_t &token) +void GxsForumThreadWidget::loadMessageData(const uint32_t &token) { - mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, false); + mStateHelper->setLoading(TOKEN_TYPE_MESSAGEDATA, false); - std::cerr << "GxsForumThreadWidget::loadMsgData_InsertPost()"; +#ifdef DEBUG_FORUMS + std::cerr << "GxsForumThreadWidget::loadMessage()"; std::cerr << std::endl; +#endif std::vector msgs; if (rsGxsForums->getMsgData(token, msgs)) { if (msgs.size() != 1) { - std::cerr << "GxsForumThreadWidget::loadMsgData_InsertPost() ERROR Wrong number of answers"; + std::cerr << "GxsForumThreadWidget::loadMessage() ERROR Wrong number of answers"; std::cerr << std::endl; - mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false); - mStateHelper->clear(TOKEN_TYPE_INSERT_POST); + + mStateHelper->setActive(TOKEN_TYPE_MESSAGEDATA, false); + mStateHelper->clear(TOKEN_TYPE_MESSAGEDATA); return; } - insertPostData(msgs[0]); + insertMessageData(msgs[0]); } else { - std::cerr << "GxsForumThreadWidget::loadMsgData_InsertPost() ERROR Missing Message Data..."; + std::cerr << "GxsForumThreadWidget::loadMessage() ERROR Missing Message Data..."; std::cerr << std::endl; - mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false); - mStateHelper->clear(TOKEN_TYPE_INSERT_POST); + mStateHelper->setActive(TOKEN_TYPE_MESSAGEDATA, false); + mStateHelper->clear(TOKEN_TYPE_MESSAGEDATA); } } @@ -1849,7 +1851,7 @@ void GxsForumThreadWidget::requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair & vect.push_back(msgId.second); uint32_t token; - mThreadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_REPLY_MESSAGE); + mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_REPLY_MESSAGE); } void GxsForumThreadWidget::loadMsgData_ReplyMessage(const uint32_t &token) @@ -1884,17 +1886,17 @@ void GxsForumThreadWidget::loadRequest(const TokenQueue *queue, const TokenReque std::cerr << "GxsForumThreadWidget::loadRequest() UserType: " << req.mUserType; std::cerr << std::endl; - if (queue == mThreadQueue) + if (queue == mTokenQueue) { /* now switch on req */ switch(req.mUserType) { - case TOKEN_TYPE_CURRENTFORUM: - loadGroup_CurrentForum(req.mToken); + case TOKEN_TYPE_GROUPDATA: + loadGroupData(req.mToken); break; - case TOKEN_TYPE_INSERT_POST: - loadMsgData_InsertPost(req.mToken); + case TOKEN_TYPE_MESSAGEDATA: + loadMessageData(req.mToken); break; case TOKEN_TYPE_REPLY_MESSAGE: diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index b2b2aa870..2bca33356 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -106,13 +106,10 @@ private slots: void fillThreadStatus(QString text); private: - void insertForumThreads(const RsGxsForumGroup &group); - void insertPostData(const RsGxsForumMsg &msg); // Second Half. + void insertMessageData(const RsGxsForumMsg &msg); void insertThreads(); - void insertPost(); - -// void forumMsgReadStatusChanged(const QString &forumId, const QString &msgId, int status); + void insertMessage(); void fillThreads(QList &threadList, bool expandNewMessages, QList &itemToExpand); void fillChildren(QTreeWidgetItem *parentItem, QTreeWidgetItem *newParentItem, bool expandNewMessages, QList &itemToExpand); @@ -130,6 +127,16 @@ private: void processSettings(bool bLoad); + void requestGroupData(); + void loadGroupData(const uint32_t &token); + void insertGroupData(const RsGxsForumGroup &group); + + void requestMessageData(const RsGxsGrpMsgIdPair &msgId); + void loadMessageData(const uint32_t &token); + void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId); + void loadMsgData_ReplyMessage(const uint32_t &token); + +private: RsGxsGroupId mForumId; RsGxsGroupId mLastForumID; RsGxsMessageId mThreadId; @@ -139,19 +146,11 @@ private: bool mInMsgAsReadUnread; int mLastViewType; RSTreeWidgetItemCompareRole *mThreadCompareRole; - TokenQueue *mThreadQueue; + TokenQueue *mTokenQueue; GxsForumsFillThread *mFillThread; unsigned int mUnreadCount; unsigned int mNewCount; - void requestGroup_CurrentForum(); - void loadGroup_CurrentForum(const uint32_t &token); - - void requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId); - void loadMsgData_InsertPost(const uint32_t &token); - void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId); - void loadMsgData_ReplyMessage(const uint32_t &token); - /* Color definitions (for standard see qss.default) */ QColor mTextColorRead; QColor mTextColorUnread; @@ -162,6 +161,7 @@ private: UIStateHelper *mStateHelper; RsGxsMessageId mNavigatePendingMsgId; + QList mIgnoredMsgId; Ui::GxsForumThreadWidget *ui; }; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui index 003b0c50c..97b72f97b 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui @@ -87,7 +87,7 @@ Qt::Horizontal - QSizePolicy::Expanding + QSizePolicy::MinimumExpanding @@ -97,6 +97,35 @@ + + + + Loading + + + + + + + + 0 + 0 + + + + + 16777215 + 10 + + + + 1000 + + + 0 + + + @@ -227,43 +256,6 @@ - - - - 3 - - - - - - 10 - 75 - true - - - - Loading - - - - - - - - 16777215 - 25 - - - - 1000 - - - 0 - - - - - @@ -344,47 +336,6 @@ - - - - false - - - - 0 - 0 - - - - - 24 - 24 - - - - - 24 - 24 - - - - Qt::NoFocus - - - Next Thread - - - - - - - :/images/forward.png:/images/forward.png - - - true - - - @@ -474,10 +425,7 @@ - - - false - + 0 @@ -509,7 +457,48 @@ :/images/back.png:/images/back.png - + + true + + + + + + + false + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + Qt::NoFocus + + + Next Thread + + + + + + + :/images/forward.png:/images/forward.png + + true diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp index e8394ab4a..f3690bd61 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp @@ -45,7 +45,6 @@ GxsForumsFillThread::GxsForumsFillThread(GxsForumThreadWidget *parent) mFillComplete = false; mFilterColumn = 0; - mSubscribeFlags = 0; mViewType = 0; mFlatView = false; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h index 7eb888851..58a461607 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h @@ -28,7 +28,6 @@ signals: public: RsGxsGroupId mForumId; int mFilterColumn; - int mSubscribeFlags; bool mFillComplete; int mViewType; bool mFlatView;