Optimized fill of forums

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7716 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-11-27 22:45:34 +00:00
parent 959c0ebf5b
commit 1fff74656e
7 changed files with 289 additions and 291 deletions

View File

@ -113,11 +113,11 @@ void GxsMessageFramePostWidget::updateDisplay(bool complete)
return;
}
bool updateGroup = false;
if (mGroupId.isNull()) {
return;
}
bool updateGroup = false;
const std::list<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), mGroupId) != grpIdsMeta.end()) {
updateGroup = true;

View File

@ -162,10 +162,13 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>314</width>
<height>10</height>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
@ -179,6 +182,12 @@
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>

View File

@ -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<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds, const QList<RsGxsMessageId> &removeMsgId)
{
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator grpIt;
for (grpIt = msgIds.begin(); grpIt != msgIds.end(); ) {
std::vector<RsGxsMessageId> &msgs = grpIt->second;
QList<RsGxsMessageId>::const_iterator removeMsgIt;
for (removeMsgIt = removeMsgId.begin(); removeMsgIt != removeMsgId.end(); ++removeMsgIt) {
std::vector<RsGxsMessageId>::iterator msgIt = std::find(msgs.begin(), msgs.end(), *removeMsgIt);
if (msgIt != msgs.end()) {
msgs.erase(msgIt);
}
}
if (msgs.empty()) {
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::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<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), mForumId) != grpIdsMeta.end()) {
updateGroup = true;
}
const std::list<RsGxsGroupId> &grpIds = getGrpIds();
if (std::find(grpIds.begin(), grpIds.end(), mForumId) != grpIds.end()) {
updateGroup = true;
/* Update threads */
insertThreads();
} else {
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > 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<QTreeWidgetItem*> 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<QTreeWidgetItem *> &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<QTreeWidgetItem*> *rows, QList<QTreeWidgetItem*> *rowsRead, QList<QTreeWidgetItem*> *rowsUnread)
@ -1414,6 +1409,9 @@ void GxsForumThreadWidget::setMsgReadStatus(QList<QTreeWidgetItem*> &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<QTreeWidgetItem*> &rows, bool
for (std::list<QTreeWidgetItem*>::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<RsGxsGroupId> 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<RsGxsForumGroup> 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<RsGxsGrpMsgIdPair> 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<RsGxsMessageId> &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<RsGxsForumMsg> 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:

View File

@ -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<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
void fillChildren(QTreeWidgetItem *parentItem, QTreeWidgetItem *newParentItem, bool expandNewMessages, QList<QTreeWidgetItem*> &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<RsGxsMessageId> mIgnoredMsgId;
Ui::GxsForumThreadWidget *ui;
};

View File

@ -87,7 +87,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -97,6 +97,35 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="progressText">
<property name="text">
<string>Loading</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="LineEditClear" name="filterLineEdit">
<property name="minimumSize">
@ -227,43 +256,6 @@
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="progressBarLayout">
<property name="leftMargin">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="progressText">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Loading</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="threadLayout">
<property name="leftMargin">
@ -344,47 +336,6 @@
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="nextButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Next Thread</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/forward.png</normaloff>:/images/forward.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="13">
<widget class="QPushButton" name="expandButton">
<property name="maximumSize">
@ -474,10 +425,7 @@
</spacer>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="previousButton">
<property name="enabled">
<bool>false</bool>
</property>
<widget class="QToolButton" name="previousButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -509,7 +457,48 @@
<iconset resource="../images.qrc">
<normaloff>:/images/back.png</normaloff>:/images/back.png</iconset>
</property>
<property name="flat">
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="nextButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Next Thread</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/forward.png</normaloff>:/images/forward.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>

View File

@ -45,7 +45,6 @@ GxsForumsFillThread::GxsForumsFillThread(GxsForumThreadWidget *parent)
mFillComplete = false;
mFilterColumn = 0;
mSubscribeFlags = 0;
mViewType = 0;
mFlatView = false;

View File

@ -28,7 +28,6 @@ signals:
public:
RsGxsGroupId mForumId;
int mFilterColumn;
int mSubscribeFlags;
bool mFillComplete;
int mViewType;
bool mFlatView;