From 8cf78b072be282768d2e626c1b30f1c80c1b9d40 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 26 Mar 2020 17:10:29 +0100 Subject: [PATCH] added more info when loading forums --- .../src/gui/feeds/GxsChannelPostItem.cpp | 2 +- .../src/gui/feeds/GxsForumGroupItem.cpp | 2 +- .../src/gui/feeds/GxsForumMsgItem.cpp | 2 +- .../src/gui/feeds/PostedGroupItem.cpp | 2 +- retroshare-gui/src/gui/gxs/GxsIdDetails.cpp | 2 +- .../src/gui/gxs/GxsMessageFramePostWidget.cpp | 2 +- .../gui/gxsforums/GxsForumThreadWidget.cpp | 39 +++++++++++++------ .../src/gui/gxsforums/GxsForumThreadWidget.h | 5 ++- 8 files changed, 38 insertions(+), 18 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index c7cc02a11..1e0fc57b9 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -116,7 +116,7 @@ void GxsChannelPostItem::setup() mCloseOnRead = false; /* clear ui */ - ui->titleLabel->setText(tr("Loading")); + ui->titleLabel->setText(tr("Loading...")); ui->datetimelabel->clear(); ui->filelabel->clear(); ui->newCommentLabel->hide(); diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp index 57cf259ab..ee96c068e 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp @@ -59,7 +59,7 @@ void GxsForumGroupItem::setup() setAttribute(Qt::WA_DeleteOnClose, true); /* clear ui */ - ui->nameLabel->setText(tr("Loading")); + ui->nameLabel->setText(tr("Loading...")); ui->titleLabel->clear(); ui->descLabel->clear(); diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index 50decda82..f6afc8cdd 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -97,7 +97,7 @@ void GxsForumMsgItem::setup() mCloseOnRead = false; /* clear ui */ - ui->titleLabel->setText(tr("Loading")); + ui->titleLabel->setText(tr("Loading...")); ui->subjectLabel->clear(); ui->timestamplabel->clear(); ui->parentNameLabel->clear(); diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp index d512a0b7a..6b39566aa 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp @@ -60,7 +60,7 @@ void PostedGroupItem::setup() setAttribute(Qt::WA_DeleteOnClose, true); /* clear ui */ - ui->nameLabel->setText(tr("Loading")); + ui->nameLabel->setText(tr("Loading...")); ui->titleLabel->clear(); ui->descLabel->clear(); diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index aa2210bee..22469575f 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -935,7 +935,7 @@ QPixmap GxsIdDetails::drawIdentIcon( QString hash, quint16 width, bool rotate) QString GxsIdDetails::getLoadingText(const RsGxsId &id) { - return QString("%1... %2").arg(QApplication::translate("GxsIdDetails", "Loading"), QString::fromStdString(id.toStdString().substr(0, 5))); + return QString("%1... %2").arg(QApplication::translate("GxsIdDetails", "Loading..."), QString::fromStdString(id.toStdString().substr(0, 5))); } QString GxsIdDetails::getFailedText(const RsGxsId &id) diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp index 906c0d8de..4be7db243 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp @@ -50,7 +50,7 @@ GxsMessageFramePostWidget::~GxsMessageFramePostWidget() void GxsMessageFramePostWidget::groupIdChanged() { - mGroupName = groupId().isNull () ? "" : tr("Loading"); + mGroupName = groupId().isNull () ? "" : tr("Loading..."); groupNameChanged(mGroupName); emit groupChanged(this); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 1314c1b1d..b0908ce18 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -869,8 +869,27 @@ static QString getDurationString(uint32_t days) } } -void GxsForumThreadWidget::updateForumDescription() +void GxsForumThreadWidget::setForumDescriptionLoading() { + ui->postText->setText(tr("Loading...")); +} + +void GxsForumThreadWidget::clearForumDescription() +{ + ui->postText->clear(); +} + +void GxsForumThreadWidget::updateForumDescription(bool success) +{ + if(!success) + { + QString forum_description = QString("ERROR: Forum could not be loaded. Database might be in heavy use. Please try later."); + ui->postText->setText(forum_description); + mStateHelper->setWidgetEnabled(ui->newthreadButton, false); + + return; + } + std::cerr << "Updating forum description" << std::endl; if (!mThreadId.isNull()) return; @@ -1697,6 +1716,8 @@ void GxsForumThreadWidget::updateGroupData() // ui->threadTreeWidget->selectionModel()->reset(); // mThreadProxyModel->clear(); + setForumDescriptionLoading(); + RsThread::async([this]() { // 1 - get message data from p3GxsForums @@ -1705,18 +1726,14 @@ void GxsForumThreadWidget::updateGroupData() std::vector groups; forumIds.push_back(groupId()); + bool success = false; if(!rsGxsForums->getForumsInfo(forumIds,groups)) - { std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum group info for forum " << groupId() << std::endl; - return; - } - - if(groups.size() != 1) - { + else if(groups.size() != 1) std::cerr << __PRETTY_FUNCTION__ << " obtained more than one group info for forum " << groupId() << std::endl; - return; - } + else + success = true; // 2 - sort the messages into a proper hierarchy @@ -1724,7 +1741,7 @@ void GxsForumThreadWidget::updateGroupData() // 3 - update the model in the UI thread. - RsQThreadUtils::postToObject( [group,this]() + RsQThreadUtils::postToObject( [group,success,this]() { /* Here it goes any code you want to be executed on the Qt Gui * thread, for example to update the data model with new information @@ -1736,7 +1753,7 @@ void GxsForumThreadWidget::updateGroupData() ui->threadTreeWidget->setColumnHidden(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION, !IS_GROUP_PGP_KNOWN_AUTHED(mForumGroup.mMeta.mSignFlags) && !(IS_GROUP_PGP_AUTHED(mForumGroup.mMeta.mSignFlags))); ui->subscribeToolButton->setHidden(IS_GROUP_SUBSCRIBED(mForumGroup.mMeta.mSubscribeFlags)) ; - updateForumDescription(); + updateForumDescription(success); }, this ); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index a548cda07..2dc7f4b78 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -170,11 +170,14 @@ private: static void loadAuthorIdCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &/*data*/); void updateMessageData(const RsGxsMessageId& msgId); - void updateForumDescription(); + void updateForumDescription(bool success); void handleEvent_main_thread(std::shared_ptr event); private: + void setForumDescriptionLoading(); + void clearForumDescription(); + RsGxsGroupId mLastForumID; RsGxsMessageId mThreadId; RsGxsMessageId mOrigThreadId;