mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-17 21:40:36 -04:00
fixed abstract item model for channels. Display still missing
This commit is contained in:
parent
198733a763
commit
5a6c8de005
5 changed files with 134 additions and 168 deletions
|
@ -80,15 +80,6 @@ GxsChannelFilesWidget::GxsChannelFilesWidget(QWidget *parent) :
|
||||||
ui->treeWidget->setColumnWidth(COLUMN_PUBLISHED, 150);
|
ui->treeWidget->setColumnWidth(COLUMN_PUBLISHED, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsChannelFilesWidget::paintEvent()
|
|
||||||
{
|
|
||||||
QWidget::paintEvent();
|
|
||||||
|
|
||||||
if(!mLoaded)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GxsChannelFilesWidget::~GxsChannelFilesWidget()
|
GxsChannelFilesWidget::~GxsChannelFilesWidget()
|
||||||
{
|
{
|
||||||
delete(mCompareRole);
|
delete(mCompareRole);
|
||||||
|
|
|
@ -98,7 +98,7 @@ private:
|
||||||
int viewMode();
|
int viewMode();
|
||||||
|
|
||||||
void insertChannelDetails(const RsGxsChannelGroup &group);
|
void insertChannelDetails(const RsGxsChannelGroup &group);
|
||||||
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts);
|
void insertChannelPosts(std::vector<RsGxsChannelPost>& posts, GxsMessageFramePostThread *thread, bool related);
|
||||||
|
|
||||||
void createPostItem(const RsGxsChannelPost &post, bool related);
|
void createPostItem(const RsGxsChannelPost &post, bool related);
|
||||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "retroshare/rsgxscircles.h"
|
#include "retroshare/rsgxscircles.h"
|
||||||
|
|
||||||
#include "GxsChannelPostsWidgetWithModel.h"
|
#include "GxsChannelPostsWidgetWithModel.h"
|
||||||
#include "ui_GxsChannelPostsWidget.h"
|
#include "GxsChannelPostsModel.h"
|
||||||
|
#include "ui_GxsChannelPostsWidgetWithModel.h"
|
||||||
#include "gui/feeds/GxsChannelPostItem.h"
|
#include "gui/feeds/GxsChannelPostItem.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
#include "gui/gxschannels/CreateGxsChannelMsg.h"
|
#include "gui/gxschannels/CreateGxsChannelMsg.h"
|
||||||
|
@ -53,27 +54,27 @@
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupId &channelId, QWidget *parent) :
|
GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupId &channelId, QWidget *parent) :
|
||||||
GxsMessageFramePostWidget(rsGxsChannels, parent),
|
GxsMessageFrameWidget(rsGxsChannels, parent),
|
||||||
ui(new Ui::GxsChannelPostsWidget)
|
ui(new Ui::GxsChannelPostsWidgetWithModel)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->postsTree->setModel(new RsGxsChannelPostsModel());
|
ui->postsTree->setModel(mThreadModel = new RsGxsChannelPostsModel());
|
||||||
|
|
||||||
/* Setup UI helper */
|
/* Setup UI helper */
|
||||||
|
|
||||||
mStateHelper->addWidget(mTokenTypeAllPosts, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
//mStateHelper->addWidget(mTokenTypeAllPosts, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
||||||
mStateHelper->addWidget(mTokenTypeAllPosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
//mStateHelper->addWidget(mTokenTypeAllPosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
||||||
mStateHelper->addWidget(mTokenTypeAllPosts, ui->filterLineEdit);
|
//mStateHelper->addWidget(mTokenTypeAllPosts, ui->filterLineEdit);
|
||||||
|
|
||||||
mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
//mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
||||||
|
|
||||||
mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel);
|
//mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel);
|
||||||
|
|
||||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton);
|
//mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton);
|
||||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel);
|
//mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel);
|
||||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
|
//mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
|
||||||
|
|
||||||
/* Connect signals */
|
/* Connect signals */
|
||||||
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
||||||
|
@ -111,8 +112,8 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
||||||
ui->nameLabel->setMinimumWidth(20);
|
ui->nameLabel->setMinimumWidth(20);
|
||||||
|
|
||||||
/* Initialize feed widget */
|
/* Initialize feed widget */
|
||||||
ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder);
|
//ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder);
|
||||||
ui->feedWidget->setFilterCallback(filterItem);
|
//ui->feedWidget->setFilterCallback(filterItem);
|
||||||
|
|
||||||
/* load settings */
|
/* load settings */
|
||||||
processSettings(true);
|
processSettings(true);
|
||||||
|
@ -141,7 +142,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
||||||
mEventHandlerId, RsEventType::GXS_CHANNELS );
|
mEventHandlerId, RsEventType::GXS_CHANNELS );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||||
{
|
{
|
||||||
const RsGxsChannelEvent *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
|
const RsGxsChannelEvent *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
|
||||||
|
|
||||||
|
@ -157,29 +158,90 @@ void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEven
|
||||||
if(e->mChannelGroupId == groupId())
|
if(e->mChannelGroupId == groupId())
|
||||||
updateDisplay(true);
|
updateDisplay(true);
|
||||||
break;
|
break;
|
||||||
case RsChannelEventCode::READ_STATUS_CHANGED:
|
// case RsChannelEventCode::READ_STATUS_CHANGED:
|
||||||
if (FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(e->mChannelMsgId)))
|
// if (FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(e->mChannelMsgId)))
|
||||||
if (GxsChannelPostItem *channelPostItem = dynamic_cast<GxsChannelPostItem*>(feedItem))
|
// if (GxsChannelPostItem *channelPostItem = dynamic_cast<GxsChannelPostItem*>(feedItem))
|
||||||
channelPostItem->setReadStatus(false,!channelPostItem->isUnread());
|
// channelPostItem->setReadStatus(false,!channelPostItem->isUnread());
|
||||||
//channelPostItem->setReadStatus(false,e->Don't get read status. Will be more easier and accurate);
|
// //channelPostItem->setReadStatus(false,e->Don't get read status. Will be more easier and accurate);
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
void GxsChannelPostsWidgetWithModel::updateGroupData()
|
||||||
|
{
|
||||||
|
if(groupId().isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
RsThread::async([this]()
|
||||||
|
{
|
||||||
|
std::vector<RsGxsChannelGroup> groups;
|
||||||
|
|
||||||
|
if(!rsGxsChannels->getChannelsInfo(std::list<RsGxsGroupId>{ groupId() }, groups))
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " failed to get autodownload value for channel: " << groupId() << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(groups.size() != 1)
|
||||||
|
{
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " cannot retrieve channel data for group ID " << groupId() << ": ERROR." << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [this,groups]()
|
||||||
|
{
|
||||||
|
mGroup = groups[0];
|
||||||
|
mThreadModel->updateChannel(groupId());
|
||||||
|
} );
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsChannelPostsWidgetWithModel::updateDisplay(bool complete)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
|
std::cerr << "udateDisplay: groupId()=" << groupId()<< std::endl;
|
||||||
|
#endif
|
||||||
|
if(groupId().isNull())
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
|
std::cerr << " group_id=0. Return!"<< std::endl;
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mGroup.mMeta.mGroupId.isNull() && !groupId().isNull())
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << " inconsistent group data. Reloading!"<< std::endl;
|
||||||
|
#endif
|
||||||
|
complete = true;
|
||||||
|
}
|
||||||
|
if(complete) // need to update the group data, reload the messages etc.
|
||||||
|
{
|
||||||
|
#warning todo
|
||||||
|
//saveExpandedItems(mSavedExpandedMessages);
|
||||||
|
|
||||||
|
//if(mGroupId != mThreadModel->currentGroupId())
|
||||||
|
// mThreadId.clear();
|
||||||
|
|
||||||
|
updateGroupData();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GxsChannelPostsWidgetWithModel::~GxsChannelPostsWidgetWithModel()
|
||||||
{
|
{
|
||||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||||
// save settings
|
// save settings
|
||||||
processSettings(false);
|
processSettings(false);
|
||||||
|
|
||||||
delete(mAutoDownloadAction);
|
delete(mAutoDownloadAction);
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::processSettings(bool load)
|
void GxsChannelPostsWidgetWithModel::processSettings(bool load)
|
||||||
{
|
{
|
||||||
Settings->beginGroup(QString("ChannelPostsWidget"));
|
Settings->beginGroup(QString("ChannelPostsWidget"));
|
||||||
|
|
||||||
|
@ -204,14 +266,19 @@ void GxsChannelPostsWidget::processSettings(bool load)
|
||||||
Settings->endGroup();
|
Settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::settingsChanged()
|
void GxsChannelPostsWidgetWithModel::settingsChanged()
|
||||||
{
|
{
|
||||||
mUseThread = Settings->getChannelLoadThread();
|
mUseThread = Settings->getChannelLoadThread();
|
||||||
|
|
||||||
mStateHelper->setWidgetVisible(ui->progressBar, mUseThread);
|
//mStateHelper->setWidgetVisible(ui->progressBar, mUseThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::groupNameChanged(const QString &name)
|
QString GxsChannelPostsWidgetWithModel::groupName(bool)
|
||||||
|
{
|
||||||
|
return "Group name" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsChannelPostsWidgetWithModel::groupNameChanged(const QString &name)
|
||||||
{
|
{
|
||||||
if (groupId().isNull()) {
|
if (groupId().isNull()) {
|
||||||
ui->nameLabel->setText(tr("No Channel Selected"));
|
ui->nameLabel->setText(tr("No Channel Selected"));
|
||||||
|
@ -221,11 +288,11 @@ void GxsChannelPostsWidget::groupNameChanged(const QString &name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon GxsChannelPostsWidget::groupIcon()
|
QIcon GxsChannelPostsWidgetWithModel::groupIcon()
|
||||||
{
|
{
|
||||||
if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypeAllPosts)) {
|
// if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypeAllPosts)) {
|
||||||
return QIcon(":/images/kalarm.png");
|
// return QIcon(":/images/kalarm.png");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// if (mNewCount) {
|
// if (mNewCount) {
|
||||||
// return QIcon(":/images/message-state-new.png");
|
// return QIcon(":/images/message-state-new.png");
|
||||||
|
@ -238,36 +305,19 @@ QIcon GxsChannelPostsWidget::groupIcon()
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
QScrollArea *GxsChannelPostsWidget::getScrollArea()
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GxsChannelPostsWidget::deleteFeedItem(FeedItem *feedItem, uint32_t /*type*/)
|
|
||||||
{
|
|
||||||
if (!feedItem)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ui->feedWidget->removeFeedItem(feedItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GxsChannelPostsWidget::openChat(const RsPeerId & /*peerId*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Callback from Widget->FeedHolder->ServiceDialog->CommentContainer->CommentDialog,
|
// Callback from Widget->FeedHolder->ServiceDialog->CommentContainer->CommentDialog,
|
||||||
void GxsChannelPostsWidget::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId>& msg_versions,const RsGxsMessageId &msgId, const QString &title)
|
void GxsChannelPostsWidgetWithModel::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId>& msg_versions,const RsGxsMessageId &msgId, const QString &title)
|
||||||
{
|
{
|
||||||
emit loadComment(groupId, msg_versions,msgId, title);
|
emit loadComment(groupId, msg_versions,msgId, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::createMsg()
|
void GxsChannelPostsWidgetWithModel::createMsg()
|
||||||
{
|
{
|
||||||
if (groupId().isNull()) {
|
if (groupId().isNull()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_GROUP_SUBSCRIBED(subscribeFlags())) {
|
if (!IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +327,7 @@ void GxsChannelPostsWidget::createMsg()
|
||||||
/* window will destroy itself! */
|
/* window will destroy itself! */
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group)
|
void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGroup &group)
|
||||||
{
|
{
|
||||||
/* IMAGE */
|
/* IMAGE */
|
||||||
QPixmap chanImage;
|
QPixmap chanImage;
|
||||||
|
@ -387,7 +437,7 @@ void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GxsChannelPostsWidget::viewMode()
|
int GxsChannelPostsWidgetWithModel::viewMode()
|
||||||
{
|
{
|
||||||
if (ui->feedToolButton->isChecked()) {
|
if (ui->feedToolButton->isChecked()) {
|
||||||
return VIEW_MODE_FEEDS;
|
return VIEW_MODE_FEEDS;
|
||||||
|
@ -399,7 +449,7 @@ int GxsChannelPostsWidget::viewMode()
|
||||||
return VIEW_MODE_FEEDS;
|
return VIEW_MODE_FEEDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::setViewMode(int viewMode)
|
void GxsChannelPostsWidgetWithModel::setViewMode(int viewMode)
|
||||||
{
|
{
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
switch (viewMode) {
|
switch (viewMode) {
|
||||||
|
@ -426,7 +476,7 @@ void GxsChannelPostsWidget::setViewMode(int viewMode)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::filterChanged(int filter)
|
void GxsChannelPostsWidgetWithModel::filterChanged(int filter)
|
||||||
{
|
{
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
ui->feedWidget->setFilterType(filter);
|
ui->feedWidget->setFilterType(filter);
|
||||||
|
@ -434,7 +484,8 @@ void GxsChannelPostsWidget::filterChanged(int filter)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ bool GxsChannelPostsWidget::filterItem(FeedItem *feedItem, const QString &text, int filter)
|
#ifdef TODO
|
||||||
|
/*static*/ bool GxsChannelPostsWidgetWithModel::filterItem(FeedItem *feedItem, const QString &text, int filter)
|
||||||
{
|
{
|
||||||
GxsChannelPostItem *item = dynamic_cast<GxsChannelPostItem*>(feedItem);
|
GxsChannelPostItem *item = dynamic_cast<GxsChannelPostItem*>(feedItem);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
|
@ -474,7 +525,6 @@ void GxsChannelPostsWidget::filterChanged(int filter)
|
||||||
return bVisible;
|
return bVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TODO
|
|
||||||
void GxsChannelPostsWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& meta,bool related)
|
void GxsChannelPostsWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& meta,bool related)
|
||||||
{
|
{
|
||||||
GxsChannelPostItem *item = NULL;
|
GxsChannelPostItem *item = NULL;
|
||||||
|
@ -518,14 +568,7 @@ void GxsChannelPostsWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& m
|
||||||
ui->fileWidget->addFiles(post, related);
|
ui->fileWidget->addFiles(post, related);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost>& posts)
|
|
||||||
{
|
|
||||||
mModel->setPosts(posts);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TODO
|
|
||||||
void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool related)
|
void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool related)
|
||||||
{
|
{
|
||||||
GxsChannelPostItem *item = NULL;
|
GxsChannelPostItem *item = NULL;
|
||||||
|
@ -734,31 +777,25 @@ void GxsChannelPostsWidget::clearPosts()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void GxsChannelPostsWidget::blank()
|
void GxsChannelPostsWidgetWithModel::blank()
|
||||||
{
|
{
|
||||||
mStateHelper->setWidgetEnabled(ui->postButton, false);
|
//mStateHelper->setWidgetEnabled(ui->postButton, false);
|
||||||
mStateHelper->setWidgetEnabled(ui->subscribeToolButton, false);
|
//mStateHelper->setWidgetEnabled(ui->subscribeToolButton, false);
|
||||||
|
|
||||||
clearPosts();
|
|
||||||
|
|
||||||
|
mThreadModel->clear();
|
||||||
groupNameChanged(QString());
|
groupNameChanged(QString());
|
||||||
|
|
||||||
ui->infoWidget->hide();
|
ui->infoWidget->hide();
|
||||||
ui->feedWidget->show();
|
|
||||||
ui->fileWidget->hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GxsChannelPostsWidget::navigatePostItem(const RsGxsMessageId &msgId)
|
bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId &msgId)
|
||||||
{
|
{
|
||||||
FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(msgId));
|
#warning TODO
|
||||||
if (!feedItem) {
|
//return ui->feedWidget->scrollTo(feedItem, true);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ui->feedWidget->scrollTo(feedItem, true);
|
void GxsChannelPostsWidgetWithModel::subscribeGroup(bool subscribe)
|
||||||
}
|
|
||||||
|
|
||||||
void GxsChannelPostsWidget::subscribeGroup(bool subscribe)
|
|
||||||
{
|
{
|
||||||
RsGxsGroupId grpId(groupId());
|
RsGxsGroupId grpId(groupId());
|
||||||
if (grpId.isNull()) return;
|
if (grpId.isNull()) return;
|
||||||
|
@ -769,13 +806,13 @@ void GxsChannelPostsWidget::subscribeGroup(bool subscribe)
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::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 GxsChannelPostsWidget::toggleAutoDownload()
|
void GxsChannelPostsWidgetWithModel::toggleAutoDownload()
|
||||||
{
|
{
|
||||||
RsGxsGroupId grpId = groupId();
|
RsGxsGroupId grpId = groupId();
|
||||||
if (grpId.isNull()) {
|
if (grpId.isNull()) {
|
||||||
|
@ -813,7 +850,8 @@ void GxsChannelPostsWidget::toggleAutoDownload()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GxsChannelPostsWidget::insertGroupData(const RsGxsGenericGroupData *data)
|
#ifdef TODO
|
||||||
|
bool GxsChannelPostsWidgetWithModel::insertGroupData(const RsGxsGenericGroupData *data)
|
||||||
{
|
{
|
||||||
const RsGxsChannelGroup *d = dynamic_cast<const RsGxsChannelGroup*>(data);
|
const RsGxsChannelGroup *d = dynamic_cast<const RsGxsChannelGroup*>(data);
|
||||||
|
|
||||||
|
@ -827,67 +865,6 @@ bool GxsChannelPostsWidget::insertGroupData(const RsGxsGenericGroupData *data)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::getMsgData(const std::set<RsGxsMessageId>& msgIds,std::vector<RsGxsGenericMsgData*>& psts)
|
|
||||||
{
|
|
||||||
std::vector<RsGxsChannelPost> posts;
|
|
||||||
std::vector<RsGxsComment> comments;
|
|
||||||
std::vector<RsGxsVote> votes;
|
|
||||||
|
|
||||||
rsGxsChannels->getChannelContent( groupId(),msgIds,posts,comments,votes );
|
|
||||||
|
|
||||||
psts.clear();
|
|
||||||
|
|
||||||
for(auto& post: posts)
|
|
||||||
psts.push_back(new RsGxsChannelPost(post));
|
|
||||||
}
|
|
||||||
|
|
||||||
void GxsChannelPostsWidget::getAllMsgData(std::vector<RsGxsGenericMsgData*>& psts)
|
|
||||||
{
|
|
||||||
std::vector<RsGxsChannelPost> posts;
|
|
||||||
std::vector<RsGxsComment> comments;
|
|
||||||
std::vector<RsGxsVote> votes;
|
|
||||||
|
|
||||||
rsGxsChannels->getChannelAllContent( groupId(),posts,comments,votes );
|
|
||||||
|
|
||||||
psts.clear();
|
|
||||||
|
|
||||||
for(auto& post: posts)
|
|
||||||
psts.push_back(new RsGxsChannelPost(post));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GxsChannelPostsWidget::getGroupData(RsGxsGenericGroupData *& data)
|
|
||||||
{
|
|
||||||
if(groupId().isNull())
|
|
||||||
{
|
|
||||||
RsErr() << __PRETTY_FUNCTION__ << " Trying to get data about null group!!" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
std::vector<RsGxsChannelGroup> groups;
|
|
||||||
|
|
||||||
if(rsGxsChannels->getChannelsInfo(std::list<RsGxsGroupId>({groupId()}),groups) && groups.size()==1)
|
|
||||||
{
|
|
||||||
data = new RsGxsChannelGroup(groups[0]);
|
|
||||||
|
|
||||||
mGroup = groups[0]; // make a local copy to pass on to items
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RsGxsChannelGroup distant_group;
|
|
||||||
|
|
||||||
if(rsGxsChannels->retrieveDistantGroup(groupId(),distant_group))
|
|
||||||
{
|
|
||||||
insertChannelDetails(distant_group);
|
|
||||||
data = new RsGxsChannelGroup(distant_group);
|
|
||||||
mGroup = distant_group; // make a local copy to pass on to items
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TODO
|
|
||||||
void GxsChannelPostsWidget::insertAllPosts(const std::vector<RsGxsGenericMsgData*>& posts, GxsMessageFramePostThread *thread)
|
void GxsChannelPostsWidget::insertAllPosts(const std::vector<RsGxsGenericMsgData*>& posts, GxsMessageFramePostThread *thread)
|
||||||
{
|
{
|
||||||
std::vector<RsGxsChannelPost> cposts;
|
std::vector<RsGxsChannelPost> cposts;
|
||||||
|
@ -897,7 +874,6 @@ void GxsChannelPostsWidget::insertAllPosts(const std::vector<RsGxsGenericMsgData
|
||||||
|
|
||||||
insertChannelPosts(cposts, thread, false);
|
insertChannelPosts(cposts, thread, false);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void GxsChannelPostsWidget::insertPosts(const std::vector<RsGxsGenericMsgData*>& posts)
|
void GxsChannelPostsWidget::insertPosts(const std::vector<RsGxsGenericMsgData*>& posts)
|
||||||
{
|
{
|
||||||
|
@ -908,6 +884,7 @@ void GxsChannelPostsWidget::insertPosts(const std::vector<RsGxsGenericMsgData*>&
|
||||||
|
|
||||||
insertChannelPosts(cposts);
|
insertChannelPosts(cposts);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
class GxsChannelPostsReadData
|
class GxsChannelPostsReadData
|
||||||
{
|
{
|
||||||
|
@ -940,14 +917,14 @@ static void setAllMessagesReadCallback(FeedItem *feedItem, void *data)
|
||||||
rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead);
|
rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::setAllMessagesReadDo(bool read, uint32_t &token)
|
void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token)
|
||||||
{
|
{
|
||||||
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(subscribeFlags())) {
|
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsChannelPostsReadData data(read);
|
GxsChannelPostsReadData data(read);
|
||||||
ui->feedWidget->withAll(setAllMessagesReadCallback, &data);
|
//ui->feedWidget->withAll(setAllMessagesReadCallback, &data);
|
||||||
|
|
||||||
token = data.mLastToken;
|
token = data.mLastToken;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "gui/feeds/FeedHolder.h"
|
#include "gui/feeds/FeedHolder.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class GxsChannelPostsWidget;
|
class GxsChannelPostsWidgetWithModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GxsChannelPostItem;
|
class GxsChannelPostItem;
|
||||||
|
@ -36,7 +36,7 @@ class QTreeWidgetItem;
|
||||||
class FeedItem;
|
class FeedItem;
|
||||||
class RsGxsChannelPostsModel;
|
class RsGxsChannelPostsModel;
|
||||||
|
|
||||||
class GxsChannelPostsWidgetWithModel: public QWidget, public GxsMessageFrameWidget
|
class GxsChannelPostsWidgetWithModel: public GxsMessageFrameWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -56,17 +56,19 @@ public:
|
||||||
|
|
||||||
/* GxsMessageFrameWidget */
|
/* GxsMessageFrameWidget */
|
||||||
virtual QIcon groupIcon();
|
virtual QIcon groupIcon();
|
||||||
virtual void groupIdChanged() override;
|
virtual void groupIdChanged() { updateDisplay(true); }
|
||||||
virtual QString groupName(bool) override;
|
virtual QString groupName(bool) override;
|
||||||
virtual bool navigate(const RsGxsMessageId&) override;
|
virtual bool navigate(const RsGxsMessageId&) override;
|
||||||
|
|
||||||
|
void updateDisplay(bool complete);
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
/* FeedHolder */
|
/* FeedHolder */
|
||||||
virtual QScrollArea *getScrollArea();
|
virtual QScrollArea *getScrollArea();
|
||||||
virtual void deleteFeedItem(FeedItem *feedItem, uint32_t type);
|
virtual void deleteFeedItem(FeedItem *feedItem, uint32_t type);
|
||||||
virtual void openChat(const RsPeerId& peerId);
|
virtual void openChat(const RsPeerId& peerId);
|
||||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId> &msg_versions, const RsGxsMessageId &msgId, const QString &title);
|
|
||||||
#endif
|
#endif
|
||||||
|
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector<RsGxsMessageId> &msg_versions, const RsGxsMessageId &msgId, const QString &title);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* GxsMessageFramePostWidget */
|
/* GxsMessageFramePostWidget */
|
||||||
|
@ -74,10 +76,7 @@ protected:
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
virtual bool insertGroupData(const RsGxsGenericGroupData *data) override;
|
virtual bool insertGroupData(const RsGxsGenericGroupData *data) override;
|
||||||
#endif
|
#endif
|
||||||
virtual void clearPosts();
|
|
||||||
virtual bool useThread() { return mUseThread; }
|
virtual bool useThread() { return mUseThread; }
|
||||||
virtual void fillThreadCreatePost(const QVariant &post, bool related, int current, int count);
|
|
||||||
virtual bool navigatePostItem(const RsGxsMessageId& msgId);
|
|
||||||
virtual void blank() ;
|
virtual void blank() ;
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
|
@ -92,6 +91,7 @@ protected:
|
||||||
virtual void setAllMessagesReadDo(bool read, uint32_t &token);
|
virtual void setAllMessagesReadDo(bool read, uint32_t &token);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void updateGroupData();
|
||||||
void createMsg();
|
void createMsg();
|
||||||
void toggleAutoDownload();
|
void toggleAutoDownload();
|
||||||
void subscribeGroup(bool subscribe);
|
void subscribeGroup(bool subscribe);
|
||||||
|
@ -108,9 +108,6 @@ private:
|
||||||
int viewMode();
|
int viewMode();
|
||||||
|
|
||||||
void insertChannelDetails(const RsGxsChannelGroup &group);
|
void insertChannelDetails(const RsGxsChannelGroup &group);
|
||||||
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts, GxsMessageFramePostThread *thread, bool related);
|
|
||||||
|
|
||||||
void createPostItem(const RsGxsChannelPost &post, bool related);
|
|
||||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -124,7 +121,7 @@ private:
|
||||||
UIStateHelper *mStateHelper;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
Ui::GxsChannelPostsWidget *ui;
|
Ui::GxsChannelPostsWidgetWithModel *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -498,6 +498,7 @@ void GxsForumThreadWidget::recursRestoreExpandedItems(const QModelIndex& /*index
|
||||||
ui->threadTreeWidget->setExpanded( mThreadProxyModel->mapFromSource(mThreadModel->getIndexOfMessage(*it)) ,true) ;
|
ui->threadTreeWidget->setExpanded( mThreadProxyModel->mapFromSource(mThreadModel->getIndexOfMessage(*it)) ,true) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GxsForumThreadWidget::updateDisplay(bool complete)
|
void GxsForumThreadWidget::updateDisplay(bool complete)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue