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