attempt to sort out the mess in item deletion in FeedHolder widgets

This commit is contained in:
csoler 2020-01-14 21:43:29 +01:00
parent a0b6f50b60
commit c552890459
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
35 changed files with 149 additions and 283 deletions

View file

@ -233,8 +233,12 @@ QScrollArea *GxsChannelPostsWidget::getScrollArea()
return NULL;
}
void GxsChannelPostsWidget::deleteFeedItem(QWidget * /*item*/, uint32_t /*type*/)
void GxsChannelPostsWidget::deleteFeedItem(FeedItem *feedItem, uint32_t /*type*/)
{
if (!feedItem)
return;
ui->feedWidget->removeFeedItem(feedItem);
}
void GxsChannelPostsWidget::openChat(const RsPeerId & /*peerId*/)
@ -460,7 +464,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool re
if(!post.mMeta.mOrigMsgId.isNull())
{
FeedItem *feedItem = ui->feedWidget->findGxsFeedItem(post.mMeta.mGroupId, post.mMeta.mOrigMsgId);
FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(post.mMeta.mOrigMsgId)) ;
item = dynamic_cast<GxsChannelPostItem*>(feedItem);
if(item)
@ -476,7 +480,7 @@ void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool re
if (related)
{
FeedItem *feedItem = ui->feedWidget->findGxsFeedItem(post.mMeta.mGroupId, post.mMeta.mMsgId);
FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(post.mMeta.mMsgId)) ;
item = dynamic_cast<GxsChannelPostItem*>(feedItem);
}
if (item) {
@ -669,7 +673,7 @@ void GxsChannelPostsWidget::blank()
bool GxsChannelPostsWidget::navigatePostItem(const RsGxsMessageId &msgId)
{
FeedItem *feedItem = ui->feedWidget->findGxsFeedItem(groupId(), msgId);
FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(msgId));
if (!feedItem) {
return false;
}
@ -718,17 +722,17 @@ void GxsChannelPostsWidget::toggleAutoDownload()
return;
}
RsQThreadUtils::postToObject( [=]()
{
/* 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
* after a blocking call to RetroShare API complete, note that
* Qt::QueuedConnection is important!
*/
std::cerr << __PRETTY_FUNCTION__ << " Has been executed on GUI "
<< "thread but was scheduled by async thread" << std::endl;
}, this );
// RsQThreadUtils::postToObject( [=]()
// {
// /* 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
// * after a blocking call to RetroShare API complete, note that
// * Qt::QueuedConnection is important!
// */
//
// std::cerr << __PRETTY_FUNCTION__ << " Has been executed on GUI "
// << "thread but was scheduled by async thread" << std::endl;
// }, this );
});
}

View file

@ -58,7 +58,7 @@ public:
/* FeedHolder */
virtual QScrollArea *getScrollArea();
virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void deleteFeedItem(FeedItem *feedItem, uint32_t type);
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);

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>880</width>
<height>557</height>
<width>977</width>
<height>628</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -369,7 +369,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:'Sans'; font-size:9pt; 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">
@ -525,7 +525,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="GxsFeedWidget" name="feedWidget" native="true">
<widget class="RSFeedWidget" name="feedWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -572,22 +572,22 @@ p, li { white-space: pre-wrap; }
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
<customwidget>
<class>GxsFeedWidget</class>
<extends>QWidget</extends>
<header>gui/gxs/GxsFeedWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GxsChannelFilesWidget</class>
<extends>QWidget</extends>
<header>gui/gxschannels/GxsChannelFilesWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>RSFeedWidget</class>
<extends>QWidget</extends>
<header>gui/common/RSFeedWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
<include location="../icons.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>