mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
GxsForums:
- optimized steps of the progressbar when loading - added UIStateHelper - removed debug output - added Todo button git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6500 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
06b68e4e31
commit
9eeacf7f83
@ -31,6 +31,7 @@
|
||||
#include "channels/ShareKey.h"
|
||||
#include "common/RSTreeWidget.h"
|
||||
#include "notifyqt.h"
|
||||
//#include "gui/common/UIStateHelper.h"
|
||||
|
||||
// These should be in retroshare/ folder.
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
@ -50,6 +51,9 @@
|
||||
#define IMAGE_FORUMAUTHD ":/images/konv_message2.png"
|
||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||
|
||||
#define TOKEN_TYPE_LISTING 1
|
||||
//#define TOKEN_TYPE_CURRENTFORUM 2
|
||||
|
||||
/*
|
||||
* Transformation Notes:
|
||||
* there are still a couple of things that the new forums differ from Old version.
|
||||
@ -68,10 +72,14 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
/* Setup Queue */
|
||||
/* Setup Queue */
|
||||
mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
||||
mThreadWidget = NULL;
|
||||
|
||||
/* Setup UI helper */
|
||||
// mStateHelper = new UIStateHelper(this);
|
||||
// no widget to add yet
|
||||
|
||||
connect(ui.forumTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(forumListCustomPopupMenu(QPoint)));
|
||||
connect(ui.newForumButton, SIGNAL(clicked()), this, SLOT(newforum()));
|
||||
connect(ui.forumTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(changedForum(QString)));
|
||||
@ -83,6 +91,7 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
||||
|
||||
// HACK - TEMPORARY HIJACKING THIS BUTTON FOR REFRESH.
|
||||
connect(ui.refreshButton, SIGNAL(clicked()), this, SLOT(forceUpdateDisplay()));
|
||||
connect(ui.todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
|
||||
|
||||
/* Initialize group tree */
|
||||
ui.forumTreeWidget->initDisplayMenu(ui.displayButton);
|
||||
@ -122,6 +131,22 @@ GxsForumsDialog::~GxsForumsDialog()
|
||||
// return new GxsForumUserNotify(parent);
|
||||
//}
|
||||
|
||||
void GxsForumsDialog::todo()
|
||||
{
|
||||
QMessageBox::information(this, "Todo",
|
||||
"<b>Open points:</b><ul>"
|
||||
"<li>Automatic update"
|
||||
"<li>Restore forum keys"
|
||||
"<li>Display AUTHD"
|
||||
"<li>Copy/navigate forum link"
|
||||
"<li>Display count of unread messages"
|
||||
"<li>Show missing messages"
|
||||
"<li>Show/Edit forum details"
|
||||
"<li>Don't show own posts as unread"
|
||||
"<li>Remove messages"
|
||||
"</ul>");
|
||||
}
|
||||
|
||||
void GxsForumsDialog::processSettings(bool load)
|
||||
{
|
||||
Settings->beginGroup(QString("GxsForumsDialog"));
|
||||
@ -707,9 +732,6 @@ void GxsForumsDialog::generateMassData()
|
||||
/** Request / Response of Data ********************************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
#define TOKEN_TYPE_LISTING 1
|
||||
//#define TOKEN_TYPE_CURRENTFORUM 2
|
||||
|
||||
void GxsForumsDialog::insertForums()
|
||||
{
|
||||
requestGroupSummary();
|
||||
@ -717,6 +739,8 @@ void GxsForumsDialog::insertForums()
|
||||
|
||||
void GxsForumsDialog::requestGroupSummary()
|
||||
{
|
||||
// mStateHelper->setLoading(TOKEN_TYPE_LISTING, true);
|
||||
|
||||
std::cerr << "GxsForumsDialog::requestGroupSummary()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
@ -749,13 +773,19 @@ void GxsForumsDialog::loadGroupSummary(const uint32_t &token)
|
||||
|
||||
if (groupInfo.size() > 0)
|
||||
{
|
||||
// mStateHelper->setActive(TOKEN_TYPE_LISTING, true);
|
||||
|
||||
insertForumsData(groupInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsForumsDialog::loadGroupSummary() ERROR No Groups...";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// mStateHelper->setActive(TOKEN_TYPE_LISTING, false);
|
||||
}
|
||||
|
||||
// mStateHelper->setLoading(TOKEN_TYPE_LISTING, false);
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
@ -823,7 +853,6 @@ void GxsForumsDialog::loadRequest(const TokenQueue *queue, const TokenRequest &r
|
||||
default:
|
||||
std::cerr << "GxsForumsDialog::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
class ForumInfo;
|
||||
class RsGxsForumMsg;
|
||||
class GxsForumThreadWidget;
|
||||
class UIStateHelper;
|
||||
|
||||
class GxsForumsDialog : public RsAutoUpdatePage, public TokenResponse
|
||||
{
|
||||
@ -59,6 +60,7 @@ public:
|
||||
private slots:
|
||||
void settingsChanged();
|
||||
void forceUpdateDisplay(); // TEMP HACK FN.
|
||||
void todo();
|
||||
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void forumListCustomPopupMenu( QPoint point );
|
||||
@ -121,6 +123,8 @@ private:
|
||||
QTreeWidgetItem *popularForums;
|
||||
QTreeWidgetItem *otherForums;
|
||||
|
||||
// UIStateHelper *mStateHelper;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::GxsForumsDialog ui;
|
||||
};
|
||||
|
@ -104,6 +104,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="todoPushButton">
|
||||
<property name="text">
|
||||
<string>Todo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="displayButton">
|
||||
<property name="focusPolicy">
|
||||
|
@ -105,6 +105,48 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *widget() const
|
||||
{
|
||||
if (mLabel) {
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
if (mLineEdit) {
|
||||
return mLineEdit;
|
||||
}
|
||||
|
||||
if (mTreeWidget) {
|
||||
return mTreeWidget;
|
||||
}
|
||||
|
||||
if (mLinkTextBrowser) {
|
||||
return mLinkTextBrowser;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool isWidget(QWidget *widget) const
|
||||
{
|
||||
if (mLabel == widget) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mLineEdit == widget) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mTreeWidget == widget) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mLinkTextBrowser == widget) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator ==(const UIStateHelperObject &data) const
|
||||
{
|
||||
if (mLabel == data.mLabel &&
|
||||
@ -364,6 +406,33 @@ bool UIStateHelper::isWidgetEnabled(QWidget *widget)
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool UIStateHelper::isWidgetLoading(QWidget *widget, QString &text)
|
||||
{
|
||||
bool loading = false;
|
||||
text.clear();
|
||||
|
||||
QMap<long, UIStateHelperData*>::iterator dataIt;
|
||||
for (dataIt = mData.begin(); dataIt != mData.end(); ++dataIt) {
|
||||
UIStateHelperData *data = dataIt.value();
|
||||
QMap<UIStateHelperObject, QPair<QString, bool> >::iterator it;
|
||||
for (it = data->mLoad.begin(); it != data->mLoad.end(); ++it) {
|
||||
if (it.key().isWidget(widget)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (it != data->mLoad.end()) {
|
||||
if (dataIt.value()->mLoading) {
|
||||
loading = true;
|
||||
text = it.value().first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return loading;
|
||||
}
|
||||
|
||||
void UIStateHelper::updateData(UIStateHelperData *data)
|
||||
{
|
||||
QMap<QWidget*, UIStates>::iterator it;
|
||||
@ -393,10 +462,17 @@ void UIStateHelper::setLoading(int index, bool loading)
|
||||
|
||||
QMap<UIStateHelperObject, QPair<QString, bool> >::iterator it;
|
||||
for (it = data->mLoad.begin(); it != data->mLoad.end(); ++it) {
|
||||
const UIStateHelperObject &object = it.key();
|
||||
|
||||
if (loading) {
|
||||
it.key().setPlaceholder(loading, it.value().first, it.value().second);
|
||||
object.setPlaceholder(loading, it.value().first, it.value().second);
|
||||
} else {
|
||||
it.key().setPlaceholder(loading, "", it.value().second);
|
||||
QString text;
|
||||
if (isWidgetLoading(object.widget(), text)) {
|
||||
object.setPlaceholder(true, text, it.value().second);
|
||||
} else {
|
||||
object.setPlaceholder(loading, "", it.value().second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ private:
|
||||
void updateData(UIStateHelperData *data);
|
||||
bool isWidgetVisible(QWidget *widget);
|
||||
bool isWidgetEnabled(QWidget *widget);
|
||||
bool isWidgetLoading(QWidget *widget, QString &text);
|
||||
|
||||
private:
|
||||
QMap<long, UIStateHelperData*> mData;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/common/Emoticons.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/misc.h"
|
||||
@ -50,11 +51,26 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
/* Setup Queue */
|
||||
mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
||||
|
||||
/* Setup UI helper */
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui.buttonBox->button(QDialogButtonBox::Ok));
|
||||
mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui.innerFrame);
|
||||
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui.forumName);
|
||||
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui.forumSubject);
|
||||
mStateHelper->addClear(CREATEGXSFORUMMSG_FORUMINFO, ui.forumName);
|
||||
|
||||
mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui.buttonBox->button(QDialogButtonBox::Ok));
|
||||
mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui.innerFrame);
|
||||
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui.forumName);
|
||||
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui.forumSubject);
|
||||
mStateHelper->addClear(CREATEGXSFORUMMSG_PARENTMSG, ui.forumName);
|
||||
|
||||
QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message");
|
||||
setWindowTitle(text);
|
||||
|
||||
@ -117,18 +133,19 @@ void CreateGxsForumMsg::newMsg()
|
||||
/* fill in the available OwnIds for signing */
|
||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, "");
|
||||
|
||||
/* lock gui */
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
ui.innerFrame->setEnabled(false);
|
||||
|
||||
if (mForumId.empty()) {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
mStateHelper->clear(CREATEGXSFORUMMSG_FORUMINFO);
|
||||
mStateHelper->clear(CREATEGXSFORUMMSG_PARENTMSG);
|
||||
ui.forumName->setText(tr("No Forum"));
|
||||
return;
|
||||
}
|
||||
ui.forumName->setText(tr("Loading"));
|
||||
|
||||
/* request Data */
|
||||
{
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
@ -144,10 +161,13 @@ void CreateGxsForumMsg::newMsg()
|
||||
|
||||
if (mParentId.empty())
|
||||
{
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
mParentMsgLoaded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
@ -163,41 +183,37 @@ void CreateGxsForumMsg::newMsg()
|
||||
}
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::saveForumInfo(const RsGroupMetaData &meta)
|
||||
{
|
||||
mForumMeta = meta;
|
||||
mForumMetaLoaded = true;
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::saveParentMsg(const RsGxsForumMsg &msg)
|
||||
{
|
||||
mParentMsg = msg;
|
||||
mParentMsgLoaded = true;
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::loadFormInformation()
|
||||
{
|
||||
if ((!mParentMsgLoaded) && (!mParentId.empty()))
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ParentMsg not Loaded Yet";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
if (!mParentId.empty()) {
|
||||
if (mParentMsgLoaded) {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
} else {
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ParentMsg not Loaded Yet";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
}
|
||||
|
||||
if (!mForumMetaLoaded)
|
||||
{
|
||||
if (mForumMetaLoaded) {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, true);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
} else {
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ForumMeta not Loaded Yet";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
ui.innerFrame->setEnabled(true);
|
||||
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() Data Available!";
|
||||
std::cerr << std::endl;
|
||||
|
||||
@ -356,10 +372,6 @@ void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "CreateGxsForumMsg::anchorClicked mesgString : " << mesgString.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
if (!mesgString.isEmpty()) {
|
||||
ui.forumMessage->textCursor().insertHtml(mesgString);
|
||||
}
|
||||
@ -397,12 +409,19 @@ void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
|
||||
if (groupInfo.size() == 1)
|
||||
{
|
||||
RsGroupMetaData fi = groupInfo.front();
|
||||
saveForumInfo(fi);
|
||||
|
||||
mForumMeta = fi;
|
||||
mForumMetaLoaded = true;
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadForumInfo() ERROR INVALID Number of Forums";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,8 +439,17 @@ void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
|
||||
/* error */
|
||||
std::cerr << "CreateGxsForumMsg::loadParentMsg() ERROR wrong number of msgs";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
|
||||
return;
|
||||
}
|
||||
saveParentMsg(msgs[0]);
|
||||
|
||||
mParentMsg = msgs[0];
|
||||
mParentMsgLoaded = true;
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,7 +472,6 @@ void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest
|
||||
default:
|
||||
std::cerr << "CreateGxsForum::loadRequest() UNKNOWN UserType ";
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#include <retroshare/rsgxsforums.h>
|
||||
|
||||
class UIStateHelper;
|
||||
|
||||
class CreateGxsForumMsg : public QDialog, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -58,8 +60,6 @@ protected:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
private:
|
||||
void saveForumInfo(const RsGroupMetaData &meta);
|
||||
void saveParentMsg(const RsGxsForumMsg &msg);
|
||||
void loadFormInformation();
|
||||
|
||||
void loadForumInfo(const uint32_t &token);
|
||||
@ -74,6 +74,7 @@ private:
|
||||
RsGroupMetaData mForumMeta;
|
||||
|
||||
TokenQueue *mForumQueue;
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::CreateGxsForumMsg ui;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "CreateGxsForumMsg.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "util/DateTime.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
|
||||
#include <retroshare/rsgxsforums.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
@ -45,7 +46,7 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#define DEBUG_FORUMS
|
||||
//#define DEBUG_FORUMS
|
||||
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_MESSAGE ":/images/folder-draft.png"
|
||||
@ -90,6 +91,29 @@ GxsForumThreadWidget::GxsForumThreadWidget(const std::string &forumId, QWidget *
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
/* 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->newthreadButton);
|
||||
mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->threadTreeWidget, UISTATE_ACTIVE_ENABLED);
|
||||
|
||||
mStateHelper->addLoadPlaceholder(TOKEN_TYPE_CURRENTFORUM, ui->progressText);
|
||||
|
||||
mStateHelper->addClear(TOKEN_TYPE_CURRENTFORUM, ui->threadTreeWidget);
|
||||
mStateHelper->addClear(TOKEN_TYPE_CURRENTFORUM, ui->forumName);
|
||||
|
||||
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->nextUnreadButton);
|
||||
mStateHelper->addWidget(TOKEN_TYPE_INSERT_POST, ui->downloadButton);
|
||||
|
||||
mStateHelper->addLoadPlaceholder(TOKEN_TYPE_INSERT_POST, ui->postText);
|
||||
mStateHelper->addLoadPlaceholder(TOKEN_TYPE_INSERT_POST, ui->threadTitle);
|
||||
|
||||
mSubscribeFlags = 0;
|
||||
mInProcessSettings = false;
|
||||
mUnreadCount = 0;
|
||||
@ -159,7 +183,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const std::string &forumId, QWidget *
|
||||
|
||||
ui->progressBar->hide();
|
||||
ui->progressText->hide();
|
||||
ui->progressBarLayout->setEnabled(false);
|
||||
|
||||
// mTimer = new QTimer;
|
||||
// mTimer->setInterval(1000);
|
||||
@ -263,7 +286,7 @@ QString GxsForumThreadWidget::forumName(bool withUnreadCount)
|
||||
|
||||
QIcon GxsForumThreadWidget::forumIcon()
|
||||
{
|
||||
if (mThreadQueue->activeRequestExist(TOKEN_TYPE_CURRENTFORUM) || mFillThread) {
|
||||
if (mStateHelper->isLoading(TOKEN_TYPE_CURRENTFORUM) || mFillThread) {
|
||||
return QIcon(":/images/kalarm.png");
|
||||
}
|
||||
|
||||
@ -274,21 +297,6 @@ QIcon GxsForumThreadWidget::forumIcon()
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::updateInterface()
|
||||
{
|
||||
if (mFillThread) {
|
||||
ui->newthreadButton->setEnabled(false);
|
||||
} else {
|
||||
if (mThreadQueue->activeRequestExist(TOKEN_TYPE_CURRENTFORUM)) {
|
||||
ui->newthreadButton->setEnabled(false);
|
||||
} else {
|
||||
ui->newthreadButton->setEnabled (IS_GROUP_SUBSCRIBED(mSubscribeFlags));
|
||||
}
|
||||
}
|
||||
|
||||
emit forumChanged(this);
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
@ -636,7 +644,7 @@ void GxsForumThreadWidget::calculateUnreadCount()
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
updateInterface();
|
||||
emit forumChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,13 +690,11 @@ void GxsForumThreadWidget::fillThreadFinished()
|
||||
if (thread) {
|
||||
if (thread == mFillThread) {
|
||||
// current thread has finished, hide progressbar and release thread
|
||||
ui->progressBar->hide();
|
||||
ui->progressText->hide();
|
||||
ui->progressBarLayout->setEnabled(false);
|
||||
mFillThread = NULL;
|
||||
updateInterface();
|
||||
|
||||
ui->threadTreeWidget->setPlaceholderText("");
|
||||
mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, false);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, false);
|
||||
emit forumChanged(this);
|
||||
}
|
||||
|
||||
if (thread->wasStopped()) {
|
||||
@ -701,6 +707,7 @@ void GxsForumThreadWidget::fillThreadFinished()
|
||||
std::cerr << "GxsForumThreadWidget::fillThreadFinished Add messages" << std::endl;
|
||||
#endif
|
||||
|
||||
mStateHelper->setActive(TOKEN_TYPE_CURRENTFORUM, true);
|
||||
ui->threadTreeWidget->setSortingEnabled(false);
|
||||
|
||||
/* add all messages in! */
|
||||
@ -747,10 +754,10 @@ void GxsForumThreadWidget::fillThreadFinished()
|
||||
if (ui->filterLineEdit->text().isEmpty() == false) {
|
||||
filterItems(ui->filterLineEdit->text());
|
||||
}
|
||||
insertPost ();
|
||||
insertPost();
|
||||
calculateIconsAndFonts();
|
||||
calculateUnreadCount();
|
||||
updateInterface();
|
||||
emit forumChanged(this);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
@ -898,25 +905,20 @@ void GxsForumThreadWidget::insertThreads()
|
||||
thread->stop();
|
||||
delete(thread);
|
||||
|
||||
ui->progressBar->hide();
|
||||
ui->progressText->hide();
|
||||
mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, false);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, false);
|
||||
}
|
||||
|
||||
mSubscribeFlags = 0;
|
||||
mForumDescription.clear();
|
||||
|
||||
ui->newmessageButton->setEnabled(false);
|
||||
ui->newthreadButton->setEnabled(false);
|
||||
|
||||
ui->postText->clear();
|
||||
ui->threadTitle->clear();
|
||||
|
||||
if (mForumId.empty())
|
||||
{
|
||||
/* not an actual forum - clear */
|
||||
ui->threadTreeWidget->clear();
|
||||
/* when no Thread selected - clear */
|
||||
ui->forumName->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);
|
||||
/* clear last stored forumID */
|
||||
mForumId.erase();
|
||||
mLastForumID.erase();
|
||||
@ -928,9 +930,6 @@ void GxsForumThreadWidget::insertThreads()
|
||||
return;
|
||||
}
|
||||
|
||||
//#TODO
|
||||
// ui->threadTitle->setText(tr("Loading"));
|
||||
|
||||
// Get Current Forum Info... then complete insertForumThreads().
|
||||
requestGroupSummary_CurrentForum(mForumId);
|
||||
}
|
||||
@ -941,13 +940,8 @@ void GxsForumThreadWidget::insertForumThreads(const RsGroupMetaData &fi)
|
||||
ui->forumName->setText(QString::fromUtf8(fi.mGroupName.c_str()));
|
||||
// mForumDescription = QString::fromUtf8(fi.mDescription); // not available
|
||||
|
||||
ui->progressBarLayout->setEnabled(true);
|
||||
|
||||
ui->progressText->show();
|
||||
ui->progressBar->reset();
|
||||
ui->progressBar->show();
|
||||
|
||||
ui->threadTreeWidget->setPlaceholderText(tr("Loading"));
|
||||
mStateHelper->setActive(TOKEN_TYPE_CURRENTFORUM, true);
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "GxsForumsDialog::insertThreads() Start filling Forum threads" << std::endl;
|
||||
@ -995,7 +989,7 @@ void GxsForumThreadWidget::insertForumThreads(const RsGroupMetaData &fi)
|
||||
|
||||
// start thread
|
||||
mFillThread->start();
|
||||
updateInterface();
|
||||
emit forumChanged(this);
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::fillThreads(QList<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand)
|
||||
@ -1160,46 +1154,46 @@ void GxsForumThreadWidget::insertPost()
|
||||
{
|
||||
if (mForumId.empty())
|
||||
{
|
||||
ui->postText->setText("");
|
||||
ui->threadTitle->setText("");
|
||||
ui->previousButton->setEnabled(false);
|
||||
ui->nextButton->setEnabled(false);
|
||||
ui->newmessageButton->setEnabled (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);
|
||||
|
||||
ui->postText->clear();
|
||||
ui->threadTitle->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mThreadId.empty())
|
||||
{
|
||||
ui->previousButton->setEnabled(false);
|
||||
ui->nextButton->setEnabled(false);
|
||||
ui->newmessageButton->setEnabled (false);
|
||||
mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_INSERT_POST);
|
||||
|
||||
ui->threadTitle->setText(tr("Forum Description"));
|
||||
ui->postText->setText(mForumDescription);
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, true);
|
||||
|
||||
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
|
||||
if (item) {
|
||||
QTreeWidgetItem *parentItem = item->parent();
|
||||
int index = parentItem ? parentItem->indexOfChild(item) : ui->threadTreeWidget->indexOfTopLevelItem(item);
|
||||
int count = parentItem ? parentItem->childCount() : ui->threadTreeWidget->topLevelItemCount();
|
||||
ui->previousButton->setEnabled(index > 0);
|
||||
ui->nextButton->setEnabled(index < count - 1);
|
||||
mStateHelper->setWidgetEnabled(ui->previousButton, (index > 0));
|
||||
mStateHelper->setWidgetEnabled(ui->nextButton, (index < count - 1));
|
||||
} else {
|
||||
// there is something wrong
|
||||
ui->previousButton->setEnabled(false);
|
||||
ui->nextButton->setEnabled(false);
|
||||
mStateHelper->setWidgetEnabled(ui->previousButton, false);
|
||||
mStateHelper->setWidgetEnabled(ui->nextButton, false);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->postText->setPlaceholderText(tr("Loading"));
|
||||
ui->threadTitle->setText(tr("Loading"));
|
||||
|
||||
ui->newmessageButton->setEnabled(IS_GROUP_SUBSCRIBED(mSubscribeFlags) && mThreadId.empty() == false);
|
||||
mStateHelper->setWidgetEnabled(ui->newmessageButton, (IS_GROUP_SUBSCRIBED(mSubscribeFlags) && mThreadId.empty() == false));
|
||||
|
||||
/* blank text, incase we get nothing */
|
||||
ui->postText->setText("");
|
||||
ui->postText->clear();
|
||||
/* request Post */
|
||||
|
||||
// Get Forum Post ... then complete insertPostData().
|
||||
@ -1213,9 +1207,6 @@ void GxsForumThreadWidget::insertPostData(const RsGxsForumMsg &msg)
|
||||
* otherwise, another request will fill the data
|
||||
*/
|
||||
|
||||
ui->postText->setPlaceholderText("");
|
||||
ui->threadTitle->setText("");
|
||||
|
||||
if ((msg.mMeta.mGroupId != mForumId) || (msg.mMeta.mMsgId != mThreadId))
|
||||
{
|
||||
std::cerr << "GxsForumsDialog::insertPostData() Ignoring Invalid Data....";
|
||||
@ -1225,9 +1216,13 @@ 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);
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, true);
|
||||
|
||||
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
|
||||
|
||||
bool setToReadOnActive = Settings->getForumMsgSetToReadOnActivate();
|
||||
@ -1706,20 +1701,15 @@ bool GxsForumThreadWidget::filterItem(QTreeWidgetItem *item, const QString &text
|
||||
|
||||
void GxsForumThreadWidget::requestGroupSummary_CurrentForum(const std::string &forumId)
|
||||
{
|
||||
ui->progressBar->reset();
|
||||
mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, true);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, true);
|
||||
emit forumChanged(this);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
std::list<uint32_t> tokens;
|
||||
mThreadQueue->activeRequestTokens(TOKEN_TYPE_CURRENTFORUM, tokens);
|
||||
if (!tokens.empty()) {
|
||||
std::list<uint32_t>::iterator tokenIt;
|
||||
for (tokenIt = tokens.begin(); tokenIt != tokens.end(); ++tokenIt) {
|
||||
std::cerr << "GxsForumThreadWidget::requestGroupSummary() Canceling Request: " << *tokenIt;
|
||||
std::cerr << std::endl;
|
||||
|
||||
mThreadQueue->cancelRequest(*tokenIt);
|
||||
}
|
||||
}
|
||||
mThreadQueue->cancelActiveRequestTokens(TOKEN_TYPE_CURRENTFORUM);
|
||||
|
||||
std::list<std::string> grpIds;
|
||||
grpIds.push_back(forumId);
|
||||
@ -1749,7 +1739,13 @@ void GxsForumThreadWidget::loadGroupSummary_CurrentForum(const uint32_t &token)
|
||||
std::cerr << "GxsForumsDialog::loadGroupSummary_CurrentForum() ERROR Invalid Number of Groups...";
|
||||
std::cerr << std::endl;
|
||||
|
||||
updateInterface();
|
||||
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 forumChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1758,6 +1754,8 @@ void GxsForumThreadWidget::loadGroupSummary_CurrentForum(const uint32_t &token)
|
||||
|
||||
void GxsForumThreadWidget::requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId)
|
||||
{
|
||||
mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, true);
|
||||
|
||||
#if 0
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
@ -1771,18 +1769,7 @@ void GxsForumThreadWidget::requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &ms
|
||||
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_INSERT_POST);
|
||||
#else
|
||||
|
||||
std::list<uint32_t> tokens;
|
||||
mThreadQueue->activeRequestTokens(TOKEN_TYPE_INSERT_POST, tokens);
|
||||
if (!tokens.empty()) {
|
||||
std::list<uint32_t>::iterator tokenIt;
|
||||
for (tokenIt = tokens.begin(); tokenIt != tokens.end(); ++tokenIt) {
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "GxsForumThreadWidget::requestMsgData_InsertPost() Canceling Request: " << *tokenIt;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mThreadQueue->cancelRequest(*tokenIt);
|
||||
}
|
||||
}
|
||||
mThreadQueue->cancelActiveRequestTokens(TOKEN_TYPE_INSERT_POST);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
@ -1801,6 +1788,8 @@ void GxsForumThreadWidget::requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &ms
|
||||
|
||||
void GxsForumThreadWidget::loadMsgData_InsertPost(const uint32_t &token)
|
||||
{
|
||||
mStateHelper->setLoading(TOKEN_TYPE_INSERT_POST, false);
|
||||
|
||||
std::cerr << "GxsForumsDialog::loadMsgData_InsertPost()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
@ -1809,12 +1798,17 @@ void GxsForumThreadWidget::loadMsgData_InsertPost(const uint32_t &token)
|
||||
if (msgs.size() != 1) {
|
||||
std::cerr << "GxsForumsDialog::loadMsgData_InsertPost() ERROR Wrong number of answers";
|
||||
std::cerr << std::endl;
|
||||
mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_INSERT_POST);
|
||||
return;
|
||||
}
|
||||
insertPostData(msgs[0]);
|
||||
} else {
|
||||
std::cerr << "GxsForumsDialog::loadMsgData_InsertPost() ERROR Missing Message Data...";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_INSERT_POST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ class QTreeWidgetItem;
|
||||
class RSTreeWidgetItemCompareRole;
|
||||
class RsGxsForumMsg;
|
||||
class GxsForumsFillThread;
|
||||
class UIStateHelper;
|
||||
|
||||
namespace Ui {
|
||||
class GxsForumThreadWidget;
|
||||
@ -132,8 +133,6 @@ private:
|
||||
|
||||
void processSettings(bool bLoad);
|
||||
|
||||
void updateInterface();
|
||||
|
||||
std::string mForumId;
|
||||
std::string mLastForumID;
|
||||
std::string mThreadId;
|
||||
@ -164,6 +163,8 @@ private:
|
||||
QColor mTextColorNotSubscribed;
|
||||
QColor mTextColorMissing;
|
||||
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
Ui::GxsForumThreadWidget *ui;
|
||||
};
|
||||
|
||||
|
@ -96,6 +96,13 @@
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="forumLabel">
|
||||
<property name="text">
|
||||
<string>Forum:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="forumName">
|
||||
<property name="sizePolicy">
|
||||
@ -234,8 +241,21 @@
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="threadLabel">
|
||||
<property name="text">
|
||||
<string>Thread:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="threadTitle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -31,7 +31,9 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#define DEBUG_FORUMS
|
||||
//#define DEBUG_FORUMS
|
||||
|
||||
#define PROGRESSBAR_MAX 100
|
||||
|
||||
GxsForumsFillThread::GxsForumsFillThread(GxsForumThreadWidget *parent)
|
||||
: QThread(parent), mParent(parent)
|
||||
@ -153,6 +155,8 @@ void GxsForumsFillThread::run()
|
||||
|
||||
int count = msgs.size();
|
||||
int pos = 0;
|
||||
int steps = count / PROGRESSBAR_MAX;
|
||||
int step = 0;
|
||||
QList<QPair<std::string, QTreeWidgetItem*> > threadList;
|
||||
QPair<std::string, QTreeWidgetItem*> threadPair;
|
||||
|
||||
@ -179,7 +183,11 @@ void GxsForumsFillThread::run()
|
||||
calculateExpand(msg, item);
|
||||
|
||||
mItems.append(item);
|
||||
emit progress(++pos, count);
|
||||
|
||||
if (++step >= steps) {
|
||||
step = 0;
|
||||
emit progress(++pos, PROGRESSBAR_MAX);
|
||||
}
|
||||
|
||||
msgIt = msgs.erase(msgIt);
|
||||
}
|
||||
@ -222,7 +230,11 @@ void GxsForumsFillThread::run()
|
||||
/* add item to process list */
|
||||
threadList.push_back(QPair<std::string, QTreeWidgetItem*>(msg.mMeta.mMsgId, item));
|
||||
|
||||
emit progress(++pos, count);
|
||||
if (++step >= steps) {
|
||||
step = 0;
|
||||
emit progress(++pos, PROGRESSBAR_MAX);
|
||||
}
|
||||
|
||||
msgIt = msgs.erase(msgIt);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user