removed misplaced auto-download from subscribe button, and enable/disable subscribe for distant search results

This commit is contained in:
csoler 2020-10-26 20:46:50 +01:00
parent 874e095ee8
commit b74e6dbe42
2 changed files with 38 additions and 18 deletions

View File

@ -455,16 +455,19 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
QIcon icon; QIcon icon;
icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/redled.png"), QIcon::Normal, QIcon::On); icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/redled.png"), QIcon::Normal, QIcon::On);
icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/start.png"), QIcon::Normal, QIcon::Off); icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/start.png"), QIcon::Normal, QIcon::Off);
#ifdef TO_REMOVE
mAutoDownloadAction = new QAction(icon, "", this); mAutoDownloadAction = new QAction(icon, "", this);
mAutoDownloadAction->setCheckable(true); mAutoDownloadAction->setCheckable(true);
connect(mAutoDownloadAction, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); connect(mAutoDownloadAction, SIGNAL(triggered()), this, SLOT(toggleAutoDownload()));
ui->subscribeToolButton->addSubscribedAction(mAutoDownloadAction); ui->subscribeToolButton->addSubscribedAction(mAutoDownloadAction);
setAutoDownload(false);
#endif
ui->commentsDialog->setTokenService(rsGxsChannels->getTokenService(),rsGxsChannels); ui->commentsDialog->setTokenService(rsGxsChannels->getTokenService(),rsGxsChannels);
/* Initialize GUI */ /* Initialize GUI */
setAutoDownload(false);
settingsChanged(); settingsChanged();
setGroupId(channelId); setGroupId(channelId);
@ -925,7 +928,7 @@ GxsChannelPostsWidgetWithModel::~GxsChannelPostsWidgetWithModel()
// save settings // save settings
processSettings(false); processSettings(false);
delete(mAutoDownloadAction); //delete(mAutoDownloadAction);
delete mFilesDelegate; delete mFilesDelegate;
delete ui; delete ui;
} }
@ -1039,18 +1042,16 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
ui->postButton->setEnabled(bool(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)); ui->postButton->setEnabled(bool(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH));
ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); #ifdef TO_REMOVE
ui->subscribeToolButton->setEnabled(true);
bool autoDownload ; bool autoDownload ;
rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload); rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload);
setAutoDownload(autoDownload); setAutoDownload(autoDownload);
#endif
if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) setSubscribeButtonText(group.mMeta.mGroupId,group.mMeta.mSubscribeFlags);
if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags))
{ {
ui->subscribeToolButton->setText(tr("Subscribed") + " " + QString::number(group.mMeta.mPop) );
//ui->feedToolButton->setEnabled(true);
//ui->fileToolButton->setEnabled(true);
ui->channel_TW->setTabEnabled(CHANNEL_TABS_POSTS,true); ui->channel_TW->setTabEnabled(CHANNEL_TABS_POSTS,true);
ui->channel_TW->setTabEnabled(CHANNEL_TABS_FILES,true); ui->channel_TW->setTabEnabled(CHANNEL_TABS_FILES,true);
ui->details_TW->setEnabled(true); ui->details_TW->setEnabled(true);
@ -1159,29 +1160,44 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
//ui->fileToolButton->setEnabled(false); //ui->fileToolButton->setEnabled(false);
#endif #endif
if(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) setSubscribeButtonText(group.mMeta.mGroupId,group.mMeta.mSubscribeFlags);
showPostDetails();
}
void GxsChannelPostsWidgetWithModel::setSubscribeButtonText(const RsGxsGroupId& group_id,uint32_t flags)
{
if(IS_GROUP_SUBSCRIBED(flags))
{
ui->subscribeToolButton->setText(tr("Unsubscribe")); ui->subscribeToolButton->setText(tr("Unsubscribe"));
ui->subscribeToolButton->setSubscribed(true);
ui->subscribeToolButton->setEnabled(true);
}
else else
{ {
switch(rsGxsChannels->getDistantSearchStatus(group.mMeta.mGroupId)) switch(rsGxsChannels->getDistantSearchStatus(group_id))
{ {
case DistantSearchGroupStatus::UNKNOWN: // means no search ongoing. This is not a distant search case DistantSearchGroupStatus::UNKNOWN: // means no search ongoing. This is not a distant search
case DistantSearchGroupStatus::HAVE_GROUP_DATA: // fallthrough case DistantSearchGroupStatus::HAVE_GROUP_DATA: // fallthrough
ui->subscribeToolButton->setText(tr("Subscribe")); ui->subscribeToolButton->setText(tr("Subscribe"));
ui->subscribeToolButton->setToolTip(""); ui->subscribeToolButton->setToolTip("");
ui->subscribeToolButton->setSubscribed(false);
ui->subscribeToolButton->setEnabled(true);
break; break;
case DistantSearchGroupStatus::CAN_BE_REQUESTED: // means no search ongoing. This is not a distant search case DistantSearchGroupStatus::CAN_BE_REQUESTED: // means no search ongoing. This is not a distant search
ui->subscribeToolButton->setText(tr("Request data")); ui->subscribeToolButton->setText(tr("Request data"));
ui->subscribeToolButton->setToolTip(tr("Hit this button to retrieve the data you need to subscribe to this channel") ); ui->subscribeToolButton->setToolTip(tr("Hit this button to retrieve the data you need to subscribe to this channel") );
ui->subscribeToolButton->setSubscribed(false);
ui->subscribeToolButton->setEnabled(false);
break; break;
case DistantSearchGroupStatus::ONGOING_REQUEST: case DistantSearchGroupStatus::ONGOING_REQUEST:
ui->subscribeToolButton->setText(tr("Ongoing request...")); ui->subscribeToolButton->setText(tr("Ongoing request..."));
ui->subscribeToolButton->setToolTip(""); ui->subscribeToolButton->setToolTip("");
ui->subscribeToolButton->setSubscribed(true);
ui->subscribeToolButton->setEnabled(false);
break; break;
} }
} }
showPostDetails();
} }
void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool) void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool)
@ -1254,10 +1270,11 @@ void GxsChannelPostsWidgetWithModel::subscribeGroup(bool subscribe)
} ); } );
} }
#ifdef TO_REMOVE
void GxsChannelPostsWidgetWithModel::setAutoDownload(bool autoDl) void GxsChannelPostsWidgetWithModel::setAutoDownload(bool autoDl)
{ {
mAutoDownloadAction->setChecked(autoDl); mAutoDownloadAction->setChecked(autoDl);
mAutoDownloadAction->setText(autoDl ? tr("Disable Auto-Download") : tr("Enable Auto-Download")); mAutoDownloadAction->setText(autoDl ? tr("Disable Auto-Download") : tr("Enable Auto-Download"));
} }
void GxsChannelPostsWidgetWithModel::toggleAutoDownload() void GxsChannelPostsWidgetWithModel::toggleAutoDownload()
@ -1285,6 +1302,7 @@ void GxsChannelPostsWidgetWithModel::toggleAutoDownload()
} }
}); });
} }
#endif
class GxsChannelPostsReadData class GxsChannelPostsReadData
{ {

View File

@ -144,7 +144,7 @@ private slots:
void updateGroupData(); void updateGroupData();
void download(); void download();
void createMsg(); void createMsg();
void toggleAutoDownload(); // void toggleAutoDownload();
void subscribeGroup(bool subscribe); void subscribeGroup(bool subscribe);
void filterChanged(QString); void filterChanged(QString);
void settingsChanged(); void settingsChanged();
@ -168,14 +168,16 @@ private:
RsGxsMessageId getCurrentItemId() const; RsGxsMessageId getCurrentItemId() const;
void selectItem(const RsGxsMessageId& msg_id); void selectItem(const RsGxsMessageId& msg_id);
void setAutoDownload(bool autoDl); // void setAutoDownload(bool autoDl);
static bool filterItem(FeedItem *feedItem, const QString &text, int filter); static bool filterItem(FeedItem *feedItem, const QString &text, int filter);
void insertChannelDetails(const RsGxsChannelGroup &group); void insertChannelDetails(const RsGxsChannelGroup &group);
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event); void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
private: private:
QAction *mAutoDownloadAction; void setSubscribeButtonText(const RsGxsGroupId& group_id,uint32_t flags);
// QAction *mAutoDownloadAction;
RsGxsChannelGroup mGroup; RsGxsChannelGroup mGroup;
bool mUseThread; bool mUseThread;