added up-to-date info about sync period in group data details (channels, boards, forums) and warning when the sync period is too small w.r.t. the date of last post

This commit is contained in:
csoler 2020-10-24 21:17:34 +02:00
parent 709b323b03
commit c30107c248
20 changed files with 331 additions and 183 deletions

View file

@ -36,15 +36,15 @@ public:
/** Default Destructor */
~PostedDialog();
virtual QIcon iconPixmap() const { return QIcon(IMAGE_POSTED) ; } //MainPage
virtual QString pageName() const { return tr("Boards") ; } //MainPage
virtual QString helpText() const { return ""; } //MainPage
virtual QIcon iconPixmap() const override { return QIcon(IMAGE_POSTED) ; } //MainPage
virtual QString pageName() const override { return tr("Boards") ; } //MainPage
virtual QString helpText() const override { return ""; } //MainPage
protected:
virtual UserNotify *createUserNotify(QObject *parent) override;
virtual QString getHelpString() const ;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_POSTED; }
virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Posted; }
virtual QString getHelpString() const override;
virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_POSTED; }
virtual GroupFrameSettings::Type groupFrameSettingsType() override { return GroupFrameSettings::Posted; }
void groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo) override;
bool getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo) override;
@ -52,16 +52,16 @@ protected:
private:
/* GxsGroupFrameDialog */
virtual QString text(TextType type);
virtual QString icon(IconType type);
virtual QString settingsGroupName() { return "PostedDialog"; }
virtual GxsGroupDialog *createNewGroupDialog();
virtual GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId);
virtual int shareKeyType();
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
virtual RsGxsCommentService *getCommentService();
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
virtual QString text(TextType type) override;
virtual QString icon(IconType type) override;
virtual QString settingsGroupName() override{ return "PostedDialog"; }
virtual GxsGroupDialog *createNewGroupDialog() override;
virtual GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId) override;
virtual int shareKeyType() override;
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId) override;
virtual RsGxsCommentService *getCommentService() override;
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId) override;
virtual uint32_t requestGroupSummaryType() override { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
RsEventsHandlerId_t mEventHandlerId;

View file

@ -29,6 +29,7 @@
#include "ui_PostedListWidgetWithModel.h"
#include "gui/feeds/GxsChannelPostItem.h"
#include "gui/gxs/GxsIdDetails.h"
#include "gui/gxs/GxsGroupFrameDialog.h"
#include "gui/gxs/GxsCommentDialog.h"
#include "util/misc.h"
#include "gui/Posted/PostedCreatePostDialog.h"
@ -277,7 +278,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()),this, SLOT(settingsChanged()));
/* add filter actions */
ui->postsTree->setPlaceholderText(tr("Thumbnails"));
ui->postsTree->setPlaceholderText(tr("No posts available in this board"));
//ui->postsTree->setMinimumWidth(COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font()).height()+1);
connect(ui->postsTree,SIGNAL(sizeChanged(QSize)),this,SLOT(handlePostsTreeSizeChange(QSize)));
@ -488,7 +489,8 @@ void PostedListWidgetWithModel::handleEvent_main_thread(std::shared_ptr<const Rs
case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]];
case RsPostedEventCode::UPDATED_POSTED_GROUP: // [[fallthrough]];
case RsPostedEventCode::UPDATED_MESSAGE:
{
case RsPostedEventCode::SYNC_PARAMETERS_UPDATED:
{
if(e->mPostedGroupId == groupId())
updateDisplay(true);
}
@ -851,11 +853,33 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group)
ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount));
if(group.mMeta.mLastPost==0)
ui->infoLastPost->setText(tr("Never"));
else
ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost));
QString formatDescription = QString::fromUtf8(group.mDescription.c_str());
if(group.mMeta.mLastPost==0)
ui->infoLastPost->setText(tr("Never"));
else
ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost));
uint32_t current_sync_time = GxsGroupFrameDialog::checkDelay(rsPosted->getSyncPeriod(group.mMeta.mGroupId))/86400 ;
QString sync_string;
switch(current_sync_time)
{
case 5: sync_string = tr("5 days"); break;
case 15: sync_string = tr("2 weeks"); break;
case 30: sync_string = tr("1 month"); break;
case 90: sync_string = tr("3 months"); break;
case 180: sync_string = tr("6 months"); break;
case 365: sync_string = tr("1 year"); break;
case 0: sync_string = tr("indefinitly"); break;
default:
sync_string = tr("Unknown");
}
if(group.mMeta.mLastPost + rsPosted->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags))
sync_string += " (Warning: will not allow latest posts to sync)";
ui->syncPeriodLabel->setText(sync_string);
QString formatDescription = QString::fromUtf8(group.mDescription.c_str());
unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS;

View file

@ -47,18 +47,6 @@
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="namelabel">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="3">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
@ -127,26 +115,6 @@
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QLabel" name="infoPosts">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="5">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
@ -169,16 +137,23 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="createdlabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1" colspan="5">
<widget class="QLabel" name="infoLastPost">
<property name="text">
<string>Created</string>
<string notr="true">unknown</string>
</property>
</widget>
</item>
@ -195,33 +170,7 @@
</property>
</widget>
</item>
<item row="4" column="1" colspan="5">
<widget class="QLabel" name="createdinfolabel">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Posts</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
@ -234,18 +183,15 @@
</property>
</widget>
</item>
<item row="5" column="1" colspan="5">
<widget class="GxsIdLabel" name="infoAdministrator">
<item row="7" column="1" colspan="5">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<item row="7" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
@ -253,7 +199,7 @@
</font>
</property>
<property name="text">
<string>Popularity</string>
<string>Distribution:</string>
</property>
</widget>
</item>
@ -276,8 +222,8 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<item row="2" column="1">
<widget class="QLabel" name="infoPosts">
<property name="font">
<font>
<weight>75</weight>
@ -285,29 +231,103 @@
</font>
</property>
<property name="text">
<string>Distribution:</string>
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="5">
<widget class="QLabel" name="infoLastPost">
<item row="6" column="0">
<widget class="QLabel" name="createdlabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">unknown</string>
<string>Created</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="0" column="1">
<widget class="QLabel" name="namelabel">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="text">
<string>TextLabel</string>
</property>
</spacer>
</widget>
</item>
<item row="5" column="1" colspan="5">
<widget class="QLabel" name="createdinfolabel">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Popularity</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Posts</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="5">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Sync period:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="syncPeriodLabel">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
</layout>
</item>
@ -320,7 +340,7 @@
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">

View file

@ -388,7 +388,7 @@ void GxsGroupFrameDialog::removeAllSearches()
// Same function than the one in rsgxsnetservice.cc, so that all times are automatically consistent
static uint32_t checkDelay(uint32_t time_in_secs)
uint32_t GxsGroupFrameDialog::checkDelay(uint32_t time_in_secs)
{
if(time_in_secs < 1 * 86400)
return 0 ;

View file

@ -82,6 +82,8 @@ public:
void getServiceStatistics(GxsServiceStatistic& stats) const ;
static uint32_t checkDelay(uint32_t time_in_secs);
protected:
virtual void showEvent(QShowEvent *event) override;
virtual void paintEvent(QPaintEvent *pe) override;

View file

@ -29,6 +29,7 @@
#include "ui_GxsChannelPostsWidgetWithModel.h"
#include "gui/feeds/GxsChannelPostItem.h"
#include "gui/gxs/GxsIdDetails.h"
#include "gui/gxs/GxsGroupFrameDialog.h"
#include "util/misc.h"
#include "gui/gxschannels/CreateGxsChannelMsg.h"
#include "gui/common/UIStateHelper.h"
@ -429,7 +430,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
ui->filterLineEdit->setPlaceholderText(tr("Search..."));
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
ui->postsTree->setPlaceholderText(tr("Thumbnails"));
ui->postsTree->setPlaceholderText(tr("No posts available in this channel"));
ui->postsTree->setMinimumWidth(COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font()).height()+1);
connect(ui->postsTree,SIGNAL(sizeChanged(QSize)),this,SLOT(handlePostsTreeSizeChange(QSize)));
@ -702,7 +703,8 @@ void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptr<con
case RsChannelEventCode::UPDATED_CHANNEL: // [[fallthrough]];
case RsChannelEventCode::NEW_MESSAGE: // [[fallthrough]];
case RsChannelEventCode::UPDATED_MESSAGE:
{
case RsChannelEventCode::SYNC_PARAMETERS_UPDATED:
{
if(e->mChannelGroupId == groupId())
updateDisplay(true);
}
@ -1067,6 +1069,29 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
ui->infoLastPost->setText(tr("Never"));
else
ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost));
uint32_t current_sync_time = GxsGroupFrameDialog::checkDelay(rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId))/86400 ;
QString sync_string;
switch(current_sync_time)
{
case 5: sync_string = tr("5 days"); break;
case 15: sync_string = tr("2 weeks"); break;
case 30: sync_string = tr("1 month"); break;
case 90: sync_string = tr("3 months"); break;
case 180: sync_string = tr("6 months"); break;
case 365: sync_string = tr("1 year"); break;
case 0: sync_string = tr("indefinitly"); break;
default:
sync_string = tr("Unknown");
}
if(group.mMeta.mLastPost + rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags))
sync_string += " (Warning: will not allow latest posts to sync)";
ui->infoSyncTimeLabel->setText(sync_string);
QString formatDescription = QString::fromUtf8(group.mDescription.c_str());
unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS;

View file

@ -181,7 +181,7 @@
<item>
<widget class="QTabWidget" name="channel_TW">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
@ -219,7 +219,27 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="3">
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distribution:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="infoPosts">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
@ -229,6 +249,20 @@
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="infoLastPost">
<property name="text">
<string notr="true">unknown</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="infoLastPostLabel">
<property name="sizePolicy">
@ -248,14 +282,7 @@
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="infoCreated">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<item row="3" column="1" colspan="2">
<widget class="QLabel" name="label">
<property name="font">
<font>
@ -268,53 +295,6 @@
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="infoLastPost">
<property name="text">
<string notr="true">unknown</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distribution:</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Created:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="infoPosts">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
@ -337,6 +317,46 @@
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QLabel" name="infoCreated">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Created:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Sync period:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="infoSyncTimeLabel">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
</layout>
</item>
<item>

View file

@ -383,7 +383,8 @@ void GxsForumThreadWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent
case RsForumEventCode::NEW_FORUM: // [[fallthrough]];
case RsForumEventCode::UPDATED_MESSAGE: // [[fallthrough]];
case RsForumEventCode::NEW_MESSAGE:
if(e->mForumGroupId == mForumGroup.mMeta.mGroupId)
case RsForumEventCode::SYNC_PARAMETERS_UPDATED:
if(e->mForumGroupId == mForumGroup.mMeta.mGroupId)
updateDisplay(true);
break;
default: break;