From 4fc670695da887a94a1d9e88346dd02242568673 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 30 Jun 2020 19:51:14 +0200 Subject: [PATCH 01/78] removed unused files --- .../gui/gxschannels/GxsChannelFilesWidget.cpp | 251 ----- .../gui/gxschannels/GxsChannelFilesWidget.h | 76 -- .../gui/gxschannels/GxsChannelFilesWidget.ui | 78 -- .../gui/gxschannels/GxsChannelPostsWidget.cpp | 933 ------------------ .../gui/gxschannels/GxsChannelPostsWidget.h | 117 --- .../gui/gxschannels/GxsChannelPostsWidget.ui | 593 ----------- retroshare-gui/src/retroshare-gui.pro | 8 +- 7 files changed, 1 insertion(+), 2055 deletions(-) delete mode 100644 retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.cpp delete mode 100644 retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.h delete mode 100644 retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.ui delete mode 100644 retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp delete mode 100644 retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h delete mode 100644 retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.cpp deleted file mode 100644 index 6a975df64..000000000 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/******************************************************************************* - * retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.cpp * - * * - * Copyright 2014 by Retroshare Team * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - * * - *******************************************************************************/ - -#include - -#include "GxsChannelFilesWidget.h" -#include "ui_GxsChannelFilesWidget.h" -#include "GxsChannelFilesStatusWidget.h" -#include "GxsChannelPostsWidget.h" -#include "gui/feeds/GxsChannelPostItem.h" -#include "gui/common/RSTreeWidgetItem.h" -#include "util/misc.h" -#include "util/DateTime.h" -#include "gui/gxs/GxsFeedItem.h" - -#include "retroshare/rsgxschannels.h" - -#define COLUMN_FILENAME 0 -#define COLUMN_SIZE 1 -#define COLUMN_STATUS 2 -#define COLUMN_TITLE 3 -#define COLUMN_PUBLISHED 4 -#define COLUMN_COUNT 5 -#define COLUMN_DATA 0 - -#define ROLE_SORT Qt::UserRole -#define ROLE_GROUP_ID Qt::UserRole + 1 -#define ROLE_MESSAGE_ID Qt::UserRole + 2 -#define ROLE_FILE_HASH Qt::UserRole + 3 -#define ROLE_MSG Qt::UserRole + 4 - -Q_DECLARE_METATYPE(Sha1CheckSum) - -GxsChannelFilesWidget::GxsChannelFilesWidget(QWidget *parent) : - QWidget(parent), ui(new Ui::GxsChannelFilesWidget) -{ - ui->setupUi(this); - - mFeedItem = NULL; - - /* Connect signals */ - connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); - - /* Sort */ - mCompareRole = new RSTreeWidgetItemCompareRole; - mCompareRole->setRole(COLUMN_SIZE, ROLE_SORT); - mCompareRole->setRole(COLUMN_PUBLISHED, ROLE_SORT); - - /* Filter */ - mFilterType = 0; - - /* Initialize file tree */ - ui->treeWidget->setColumnCount(COLUMN_COUNT); - QTreeWidgetItem *headerItem = ui->treeWidget->headerItem(); - headerItem->setText(COLUMN_FILENAME, tr("Filename")); - headerItem->setText(COLUMN_SIZE, tr("Size")); - headerItem->setText(COLUMN_TITLE, tr("Title")); - headerItem->setText(COLUMN_PUBLISHED, tr("Published")); - headerItem->setText(COLUMN_STATUS, tr("Status")); - - ui->treeWidget->setColumnWidth(COLUMN_FILENAME, 400); - ui->treeWidget->setColumnWidth(COLUMN_SIZE, 80); - ui->treeWidget->setColumnWidth(COLUMN_PUBLISHED, 150); -} - -GxsChannelFilesWidget::~GxsChannelFilesWidget() -{ - delete(mCompareRole); - delete ui; -} - -void GxsChannelFilesWidget::addFiles(const RsGxsChannelPost& post, bool related) -{ - if (related) { - removeItems(post.mMeta.mGroupId, post.mMeta.mMsgId); - } - - std::list::const_iterator fileIt; - for (fileIt = post.mFiles.begin(); fileIt != post.mFiles.end(); ++fileIt) { - const RsGxsFile &file = *fileIt; - - QTreeWidgetItem *treeItem = new RSTreeWidgetItem(mCompareRole); - - treeItem->setText(COLUMN_FILENAME, QString::fromUtf8(file.mName.c_str())); - treeItem->setText(COLUMN_SIZE, misc::friendlyUnit(file.mSize)); - treeItem->setData(COLUMN_SIZE, ROLE_SORT, (qulonglong)file.mSize); - treeItem->setText(COLUMN_TITLE, QString::fromUtf8(post.mMeta.mMsgName.c_str())); - treeItem->setText(COLUMN_PUBLISHED, DateTime::formatDateTime(post.mMeta.mPublishTs)); - treeItem->setData(COLUMN_PUBLISHED, ROLE_SORT, QDateTime::fromTime_t(post.mMeta.mPublishTs)); - - treeItem->setData(COLUMN_DATA, ROLE_GROUP_ID, qVariantFromValue(post.mMeta.mGroupId)); - treeItem->setData(COLUMN_DATA, ROLE_MESSAGE_ID, qVariantFromValue(post.mMeta.mMsgId)); - treeItem->setData(COLUMN_DATA, ROLE_FILE_HASH, qVariantFromValue(file.mHash)); - treeItem->setData(COLUMN_DATA, ROLE_MSG, QString::fromUtf8(post.mMsg.c_str())); - treeItem->setTextAlignment(COLUMN_SIZE, Qt::AlignRight) ; - - ui->treeWidget->addTopLevelItem(treeItem); - - QWidget *statusWidget = new GxsChannelFilesStatusWidget(file); - ui->treeWidget->setItemWidget(treeItem, COLUMN_STATUS, statusWidget); - - filterItem(treeItem); - } -} - -void GxsChannelFilesWidget::clear() -{ - ui->treeWidget->clear(); - closeFeedItem(); -} - -void GxsChannelFilesWidget::setFilter(const QString &text, int type) -{ - if (mFilterText == text && mFilterType == type) { - return; - } - - mFilterText = text; - mFilterType = type; - - filterItems(); -} - -void GxsChannelFilesWidget::setFilterText(const QString &text) -{ - setFilter(text, mFilterType); -} - -void GxsChannelFilesWidget::setFilterType(int type) -{ - setFilter(mFilterText, type); -} - -void GxsChannelFilesWidget::filterItems() -{ - QTreeWidgetItemIterator it(ui->treeWidget); - QTreeWidgetItem *treeItem; - while ((treeItem = *it) != NULL) { - ++it; - filterItem(treeItem); - } -} - -void GxsChannelFilesWidget::filterItem(QTreeWidgetItem *treeItem) -{ - bool visible = mFilterText.isEmpty(); - - switch (mFilterType) { - case GxsChannelPostsWidget::FILTER_TITLE: - visible = treeItem->text(COLUMN_TITLE).contains(mFilterText, Qt::CaseInsensitive); - break; - case GxsChannelPostsWidget::FILTER_MSG: - visible = treeItem->data(COLUMN_DATA, ROLE_MSG).toString().contains(mFilterText, Qt::CaseInsensitive); - break; - case GxsChannelPostsWidget::FILTER_FILE_NAME: - visible = treeItem->text(COLUMN_FILENAME).contains(mFilterText, Qt::CaseInsensitive); - break; - } - - treeItem->setHidden(!visible); -} - -//QTreeWidgetItem *GxsChannelFilesWidget::findFile(const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, const RsFileHash &fileHash) -//{ -// QTreeWidgetItemIterator it(ui->treeWidget); -// QTreeWidgetItem *treeItem; -// while ((treeItem = *it) != NULL) { -// ++it; - -// if (fileHash != treeItem->data(COLUMN_DATA, ROLE_FILE_HASH).value()) { -// continue; -// } -// if (messageId != treeItem->data(COLUMN_DATA, ROLE_MESSAGE_ID).value()) { -// continue; -// } -// if (groupId != treeItem->data(COLUMN_DATA, ROLE_GROUP_ID).value()) { -// continue; -// } - -// return treeItem; -// } - -// return NULL; -//} - -void GxsChannelFilesWidget::removeItems(const RsGxsGroupId &groupId, const RsGxsMessageId &messageId) -{ - QTreeWidgetItemIterator it(ui->treeWidget); - QTreeWidgetItem *treeItem; - while ((treeItem = *it) != NULL) { - ++it; - - if (messageId != treeItem->data(COLUMN_DATA, ROLE_MESSAGE_ID).value()) { - continue; - } - if (groupId != treeItem->data(COLUMN_DATA, ROLE_GROUP_ID).value()) { - continue; - } - - delete(treeItem); - } -} - -void GxsChannelFilesWidget::closeFeedItem() -{ - if (mFeedItem) { - delete(mFeedItem); - mFeedItem = NULL; - } - - ui->feedItemFrame->hide(); -} - -void GxsChannelFilesWidget::currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem */*previous*/) -{ - if (!current) { - closeFeedItem(); - return; - } - - RsGxsGroupId groupId = current->data(COLUMN_DATA, ROLE_GROUP_ID).value(); - RsGxsMessageId messageId = current->data(COLUMN_DATA, ROLE_MESSAGE_ID).value(); - - if (mFeedItem) { - if (mFeedItem->groupId() == groupId && mFeedItem->messageId() == messageId) { - return; - } - closeFeedItem(); - } - - mFeedItem = new GxsChannelPostItem(NULL, 0, groupId, messageId, true, true); - ui->feedItemFrame->show(); - ui->feedItemFrame->layout()->addWidget(mFeedItem); -} diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.h b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.h deleted file mode 100644 index cb8bd8d14..000000000 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.h +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.h * - * * - * Copyright 2014 by Retroshare Team * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - * * - *******************************************************************************/ - -#ifndef GXSCHANNELFILESWIDGET_H -#define GXSCHANNELFILESWIDGET_H - -#include - -#include "retroshare/rsgxsifacetypes.h" - -struct RsGxsChannelPost; -class RSTreeWidgetItemCompareRole; -class QTreeWidgetItem; -class GxsFeedItem; - -namespace Ui { -class GxsChannelFilesWidget; -} - -class GxsChannelFilesWidget : public QWidget -{ - Q_OBJECT - -public: - explicit GxsChannelFilesWidget(QWidget *parent = 0); - ~GxsChannelFilesWidget(); - - void addFiles(const RsGxsChannelPost &post, bool related); - void clear(); - -public slots: - void setFilter(const QString &text, int type); - void setFilterText(const QString &text); - void setFilterType(int type); - -private: -// QTreeWidgetItem *findFile(const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, const RsFileHash &fileHash); - void removeItems(const RsGxsGroupId &groupId, const RsGxsMessageId &messageId); - void closeFeedItem(); - void filterItems(); - void filterItem(QTreeWidgetItem *treeItem); - -private slots: - void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); - -private: - /* Sort */ - RSTreeWidgetItemCompareRole *mCompareRole; - - /* Filter */ - QString mFilterText; - int mFilterType; - - GxsFeedItem *mFeedItem; - - Ui::GxsChannelFilesWidget *ui; -}; - -#endif // GXSCHANNELFILESWIDGET_H diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.ui deleted file mode 100644 index 4990b3259..000000000 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesWidget.ui +++ /dev/null @@ -1,78 +0,0 @@ - - - GxsChannelFilesWidget - - - - 0 - 0 - 400 - 300 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - false - - - false - - - true - - - true - - - - 1 - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp deleted file mode 100644 index 5d6974442..000000000 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ /dev/null @@ -1,933 +0,0 @@ -/******************************************************************************* - * retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp * - * * - * Copyright 2013 by Robert Fernie * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - * * - *******************************************************************************/ - -#include -#include - -#include "retroshare/rsgxscircles.h" - -#include "GxsChannelPostsWidget.h" -#include "ui_GxsChannelPostsWidget.h" -#include "gui/feeds/GxsChannelPostItem.h" -#include "gui/gxs/GxsIdDetails.h" -#include "gui/gxschannels/CreateGxsChannelMsg.h" -#include "gui/common/UIStateHelper.h" -#include "gui/settings/rsharesettings.h" -#include "gui/feeds/SubFileItem.h" -#include "gui/notifyqt.h" -#include "gui/RetroShareLink.h" -#include "util/HandleRichText.h" -#include "util/DateTime.h" -#include "util/qtthreadsutils.h" - -#include - -#define CHAN_DEFAULT_IMAGE ":/icons/png/channels.png" - -#define ROLE_PUBLISH FEED_TREEWIDGET_SORTROLE - -/**** - * #define DEBUG_CHANNEL - ***/ - -/* View mode */ -#define VIEW_MODE_FEEDS 1 -#define VIEW_MODE_FILES 2 - -/** Constructor */ -GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent) : - GxsMessageFramePostWidget(rsGxsChannels, parent), - ui(new Ui::GxsChannelPostsWidget) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui->setupUi(this); - - - /* Setup UI helper */ - - mStateHelper->addWidget(mTokenTypeAllPosts, ui->progressBar, UISTATE_LOADING_VISIBLE); - mStateHelper->addWidget(mTokenTypeAllPosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE); - mStateHelper->addWidget(mTokenTypeAllPosts, ui->filterLineEdit); - - mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE); - - mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel); - - mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton); - mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel); - mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton); - - /* Connect signals */ - connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg())); - connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool))); - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); - - ui->postButton->setText(tr("Add new post")); - - /* add filter actions */ - ui->filterLineEdit->addFilter(QIcon(), tr("Title"), FILTER_TITLE, tr("Search Title")); - ui->filterLineEdit->addFilter(QIcon(), tr("Message"), FILTER_MSG, tr("Search Message")); - ui->filterLineEdit->addFilter(QIcon(), tr("Filename"), FILTER_FILE_NAME, tr("Search Filename")); - connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), ui->feedWidget, SLOT(setFilterText(QString))); - connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), ui->fileWidget, SLOT(setFilterText(QString))); - connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterChanged(int))); - - /* Initialize view button */ - //setViewMode(VIEW_MODE_FEEDS); see processSettings - ui->infoWidget->hide(); - - QSignalMapper *signalMapper = new QSignalMapper(this); - connect(ui->feedToolButton, SIGNAL(clicked()), signalMapper, SLOT(map())); - connect(ui->fileToolButton, SIGNAL(clicked()), signalMapper, SLOT(map())); - signalMapper->setMapping(ui->feedToolButton, VIEW_MODE_FEEDS); - signalMapper->setMapping(ui->fileToolButton, VIEW_MODE_FILES); - connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(setViewMode(int))); - - /*************** Setup Left Hand Side (List of Channels) ****************/ - - ui->loadingLabel->hide(); - ui->progressBar->hide(); - - ui->nameLabel->setMinimumWidth(20); - - /* Initialize feed widget */ - ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder); - ui->feedWidget->setFilterCallback(filterItem); - - /* load settings */ - processSettings(true); - - /* Initialize subscribe button */ - QIcon icon; - icon.addPixmap(QPixmap(":/images/redled.png"), QIcon::Normal, QIcon::On); - icon.addPixmap(QPixmap(":/images/start.png"), QIcon::Normal, QIcon::Off); - mAutoDownloadAction = new QAction(icon, "", this); - mAutoDownloadAction->setCheckable(true); - connect(mAutoDownloadAction, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); - - ui->subscribeToolButton->addSubscribedAction(mAutoDownloadAction); - - /* Initialize GUI */ - setAutoDownload(false); - settingsChanged(); - setGroupId(channelId); - - mEventHandlerId = 0; - // Needs to be asynced because this function is called by another thread! - rsEvents->registerEventsHandler( - [this](std::shared_ptr event) - { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); }, - mEventHandlerId, RsEventType::GXS_CHANNELS ); -} - -void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr event) -{ - const RsGxsChannelEvent *e = dynamic_cast(event.get()); - - if(!e) - return; - - switch(e->mChannelEventCode) - { - case RsChannelEventCode::NEW_CHANNEL: // [[fallthrough]]; - case RsChannelEventCode::UPDATED_CHANNEL: // [[fallthrough]]; - case RsChannelEventCode::NEW_MESSAGE: // [[fallthrough]]; - case RsChannelEventCode::UPDATED_MESSAGE: - if(e->mChannelGroupId == groupId()) - updateDisplay(true); - break; - case RsChannelEventCode::READ_STATUS_CHANGED: - if (FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(e->mChannelMsgId))) - if (GxsChannelPostItem *channelPostItem = dynamic_cast(feedItem)) - channelPostItem->setReadStatus(false,!channelPostItem->isUnread()); - //channelPostItem->setReadStatus(false,e->Don't get read status. Will be more easier and accurate); - break; - default: - break; - } -} - -GxsChannelPostsWidget::~GxsChannelPostsWidget() -{ - rsEvents->unregisterEventsHandler(mEventHandlerId); - // save settings - processSettings(false); - - delete(mAutoDownloadAction); - - delete ui; -} - -void GxsChannelPostsWidget::processSettings(bool load) -{ - Settings->beginGroup(QString("ChannelPostsWidget")); - - if (load) { - // load settings - - /* Filter */ - ui->filterLineEdit->setCurrentFilter(Settings->value("filter", FILTER_TITLE).toInt()); - - /* View mode */ - setViewMode(Settings->value("viewMode", VIEW_MODE_FEEDS).toInt()); - } else { - // save settings - - /* Filter */ - Settings->setValue("filter", ui->filterLineEdit->currentFilter()); - - /* View mode */ - Settings->setValue("viewMode", viewMode()); - } - - Settings->endGroup(); -} - -void GxsChannelPostsWidget::settingsChanged() -{ - mUseThread = Settings->getChannelLoadThread(); - - mStateHelper->setWidgetVisible(ui->progressBar, mUseThread); -} - -void GxsChannelPostsWidget::groupNameChanged(const QString &name) -{ - if (groupId().isNull()) { - ui->nameLabel->setText(tr("No Channel Selected")); - ui->logoLabel->setPixmap(QPixmap(":/icons/png/channels.png")); - } else { - ui->nameLabel->setText(name); - } -} - -QIcon GxsChannelPostsWidget::groupIcon() -{ - if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypeAllPosts)) { - return QIcon(":/images/kalarm.png"); - } - -// if (mNewCount) { -// return QIcon(":/images/message-state-new.png"); -// } - - return QIcon(); -} - -/*************************************************************************************/ -/*************************************************************************************/ -/*************************************************************************************/ - -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, -void GxsChannelPostsWidget::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const QVector& msg_versions,const RsGxsMessageId &msgId, const QString &title) -{ - emit loadComment(groupId, msg_versions,msgId, title); -} - -void GxsChannelPostsWidget::createMsg() -{ - if (groupId().isNull()) { - return; - } - - if (!IS_GROUP_SUBSCRIBED(subscribeFlags())) { - return; - } - - CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(groupId()); - msgDialog->show(); - - /* window will destroy itself! */ -} - -void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group) -{ - /* IMAGE */ - QPixmap chanImage; - if (group.mImage.mData != NULL) { - GxsIdDetails::loadPixmapFromData(group.mImage.mData, group.mImage.mSize, chanImage,GxsIdDetails::ORIGINAL); - } else { - chanImage = QPixmap(CHAN_DEFAULT_IMAGE); - } - ui->logoLabel->setPixmap(chanImage); - - if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) - { - mStateHelper->setWidgetEnabled(ui->postButton, true); - } - else - { - mStateHelper->setWidgetEnabled(ui->postButton, false); - } - - ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); - mStateHelper->setWidgetEnabled(ui->subscribeToolButton, true); - - - bool autoDownload ; - rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload); - setAutoDownload(autoDownload); - - RetroShareLink link; - - if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) { - ui->feedToolButton->setEnabled(true); - - ui->fileToolButton->setEnabled(true); - ui->infoWidget->hide(); - setViewMode(viewMode()); - - ui->subscribeToolButton->setText(tr("Subscribed") + " " + QString::number(group.mMeta.mPop) ); - - - ui->infoPosts->clear(); - ui->infoDescription->clear(); - } else { - 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()); - - unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS; - - // embed smileys ? - if (Settings->valueFromGroup(QString("ChannelPostsWidget"), QString::fromUtf8("Emoteicons_ChannelDecription"), true).toBool()) { - formatFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS; - } - - formatDescription = RsHtml().formatText(NULL, formatDescription, formatFlag); - - ui->infoDescription->setText(formatDescription); - - ui->infoAdministrator->setId(group.mMeta.mAuthorId) ; - - link = RetroShareLink::createMessage(group.mMeta.mAuthorId, ""); - ui->infoAdministrator->setText(link.toHtml()); - - ui->infoCreated->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs)); - - QString distrib_string ( "[unknown]" ); - - switch(group.mMeta.mCircleType) - { - case GXS_CIRCLE_TYPE_PUBLIC: distrib_string = tr("Public") ; - break ; - case GXS_CIRCLE_TYPE_EXTERNAL: - { - RsGxsCircleDetails det ; - - // !! What we need here is some sort of CircleLabel, which loads the circle and updates the label when done. - - if(rsGxsCircles->getCircleDetails(group.mMeta.mCircleId,det)) - distrib_string = tr("Restricted to members of circle \"")+QString::fromUtf8(det.mCircleName.c_str()) +"\""; - else - distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ; - } - break ; - case GXS_CIRCLE_TYPE_YOUR_EYES_ONLY: distrib_string = tr("Your eyes only"); - break ; - case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes"); - break ; - default: - std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl; - } - - ui->infoDistribution->setText(distrib_string); - - ui->infoWidget->show(); - ui->feedWidget->hide(); - ui->fileWidget->hide(); - - ui->feedToolButton->setEnabled(false); - ui->fileToolButton->setEnabled(false); - - ui->subscribeToolButton->setText(tr("Subscribe ") + " " + QString::number(group.mMeta.mPop) ); - - } -} - -int GxsChannelPostsWidget::viewMode() -{ - if (ui->feedToolButton->isChecked()) { - return VIEW_MODE_FEEDS; - } else if (ui->fileToolButton->isChecked()) { - return VIEW_MODE_FILES; - } - - /* Default */ - return VIEW_MODE_FEEDS; -} - -void GxsChannelPostsWidget::setViewMode(int viewMode) -{ - switch (viewMode) { - case VIEW_MODE_FEEDS: - ui->feedWidget->show(); - ui->fileWidget->hide(); - - ui->feedToolButton->setChecked(true); - ui->fileToolButton->setChecked(false); - - break; - case VIEW_MODE_FILES: - ui->feedWidget->hide(); - ui->fileWidget->show(); - - ui->feedToolButton->setChecked(false); - ui->fileToolButton->setChecked(true); - - break; - default: - setViewMode(VIEW_MODE_FEEDS); - return; - } -} - -void GxsChannelPostsWidget::filterChanged(int filter) -{ - ui->feedWidget->setFilterType(filter); - ui->fileWidget->setFilterType(filter); -} - -/*static*/ bool GxsChannelPostsWidget::filterItem(FeedItem *feedItem, const QString &text, int filter) -{ - GxsChannelPostItem *item = dynamic_cast(feedItem); - if (!item) { - return true; - } - - bool bVisible = text.isEmpty(); - - if (!bVisible) - { - switch(filter) - { - case FILTER_TITLE: - bVisible = item->getTitleLabel().contains(text,Qt::CaseInsensitive); - break; - case FILTER_MSG: - bVisible = item->getMsgLabel().contains(text,Qt::CaseInsensitive); - break; - case FILTER_FILE_NAME: - { - std::list fileItems = item->getFileItems(); - std::list::iterator lit; - for(lit = fileItems.begin(); lit != fileItems.end(); ++lit) - { - SubFileItem *fi = *lit; - QString fileName = QString::fromUtf8(fi->FileName().c_str()); - bVisible = (bVisible || fileName.contains(text,Qt::CaseInsensitive)); - } - break; - } - default: - bVisible = true; - break; - } - } - - return bVisible; -} - -#ifdef TODO -void GxsChannelPostsWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& meta,bool related) -{ - GxsChannelPostItem *item = NULL; - RsGxsChannelPost post; - - if(!meta.mOrigMsgId.isNull()) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; - item = dynamic_cast(feedItem); - - if(item) - { - post = feedItem->post(); - ui->feedWidget->removeFeedItem(item) ; - - post.mOlderVersions.insert(post.mMeta.mMsgId); - - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); - - return ; - } - } - - if (related) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; - item = dynamic_cast(feedItem); - } - if (item) - { - item->setPost(post); - ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - } - else - { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, true); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); - } -#ifdef TODO - ui->fileWidget->addFiles(post, related); -#endif -} -#endif - -void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost& post, bool related) -{ - GxsChannelPostItem *item = NULL; - - const RsMsgMetaData& meta(post.mMeta); - - if(!meta.mOrigMsgId.isNull()) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; - item = dynamic_cast(feedItem); - - if(item) - { - std::set older_versions(item->olderVersions()); // we make a copy because the item will be deleted - ui->feedWidget->removeFeedItem(item) ; - - older_versions.insert(meta.mMsgId); - - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, false,older_versions); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - - return ; - } - } - - if (related) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; - item = dynamic_cast(feedItem); - } - if (item) - { - item->setPost(post); - ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - } - else - { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, true); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - } - - ui->fileWidget->addFiles(post, related); -} - -void GxsChannelPostsWidget::fillThreadCreatePost(const QVariant &post, bool related, int current, int count) -{ - /* show fill progress */ - if (count) { - ui->progressBar->setValue(current * ui->progressBar->maximum() / count); - } - - if (!post.canConvert()) { - return; - } - - createPostItem(post.value(), related); -} - -void GxsChannelPostsWidget::insertChannelPosts(std::vector& posts, GxsMessageFramePostThread *thread, bool related) -{ - if (related && thread) { - std::cerr << "GxsChannelPostsWidget::insertChannelPosts fill only related posts as thread is not possible" << std::endl; - return; - } - - int count = posts.size(); - int pos = 0; - - if (!thread) { - ui->feedWidget->setSortingEnabled(false); - } - - // collect new versions of posts if any - -#ifdef DEBUG_CHANNEL - std::cerr << "Inserting channel posts" << std::endl; -#endif - - std::vector new_versions ; - for (uint32_t i=0;i search_map ; - for (uint32_t i=0;i versions ; - std::map::const_iterator vit ; - - while(search_map.end() != (vit=search_map.find(posts[current_index].mMeta.mOrigMsgId))) - { -#ifdef DEBUG_CHANNEL - std::cerr << " post at index " << current_index << " replaces a post at position " << vit->second ; -#endif - - // Now replace the post only if the new versionis more recent. It may happen indeed that the same post has been corrected multiple - // times. In this case, we only need to replace the post with the newest version - - //uint32_t prev_index = current_index ; - current_index = vit->second ; - - if(posts[current_index].mMeta.mMsgId.isNull()) // This handles the branching situation where this post has been already erased. No need to go down further. - { -#ifdef DEBUG_CHANNEL - std::cerr << " already erased. Stopping." << std::endl; -#endif - break ; - } - - if(posts[current_index].mMeta.mPublishTs < posts[source_index].mMeta.mPublishTs) - { -#ifdef DEBUG_CHANNEL - std::cerr << " and is more recent => following" << std::endl; -#endif - for(std::set::const_iterator itt(posts[current_index].mOlderVersions.begin());itt!=posts[current_index].mOlderVersions.end();++itt) - posts[source_index].mOlderVersions.insert(*itt); - - posts[source_index].mOlderVersions.insert(posts[current_index].mMeta.mMsgId); - posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored - } -#ifdef DEBUG_CHANNEL - else - std::cerr << " but is older -> Stopping" << std::endl; -#endif - } - } - } - -#ifdef DEBUG_CHANNEL - std::cerr << "Now adding posts..." << std::endl; -#endif - - for (std::vector::const_reverse_iterator it = posts.rbegin(); it != posts.rend(); ++it) - { -#ifdef DEBUG_CHANNEL - std::cerr << " adding post: " << (*it).mMeta.mMsgId ; -#endif - - if(!(*it).mMeta.mMsgId.isNull()) - { -#ifdef DEBUG_CHANNEL - std::cerr << " added" << std::endl; -#endif - - if (thread && thread->stopped()) - break; - - if (thread) - thread->emitAddPost(QVariant::fromValue(*it), related, ++pos, count); - else - createPostItem(*it, related); - } -#ifdef DEBUG_CHANNEL - else - std::cerr << " skipped" << std::endl; -#endif - } - - if (!thread) { - ui->feedWidget->setSortingEnabled(true); - } -} - -void GxsChannelPostsWidget::clearPosts() -{ - ui->feedWidget->clear(); - ui->fileWidget->clear(); -} - -void GxsChannelPostsWidget::blank() -{ - mStateHelper->setWidgetEnabled(ui->postButton, false); - mStateHelper->setWidgetEnabled(ui->subscribeToolButton, false); - - clearPosts(); - - groupNameChanged(QString()); - - ui->infoWidget->hide(); - ui->feedWidget->show(); - ui->fileWidget->hide(); -} - -bool GxsChannelPostsWidget::navigatePostItem(const RsGxsMessageId &msgId) -{ - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(msgId)); - if (!feedItem) { - return false; - } - - return ui->feedWidget->scrollTo(feedItem, true); -} - -void GxsChannelPostsWidget::subscribeGroup(bool subscribe) -{ - RsGxsGroupId grpId(groupId()); - if (grpId.isNull()) return; - - RsThread::async([=]() - { - rsGxsChannels->subscribeToChannel(grpId, subscribe); - } ); -} - -void GxsChannelPostsWidget::setAutoDownload(bool autoDl) -{ - mAutoDownloadAction->setChecked(autoDl); - mAutoDownloadAction->setText(autoDl ? tr("Disable Auto-Download") : tr("Enable Auto-Download")); -} - -void GxsChannelPostsWidget::toggleAutoDownload() -{ - RsGxsGroupId grpId = groupId(); - if (grpId.isNull()) { - return; - } - - bool autoDownload; - if(!rsGxsChannels->getChannelAutoDownload(grpId, autoDownload)) - { - std::cerr << __PRETTY_FUNCTION__ << " failed to get autodownload value " - << "for channel: " << grpId.toStdString() << std::endl; - return; - } - - RsThread::async([this, grpId, autoDownload]() - { - if(!rsGxsChannels->setChannelAutoDownload(grpId, !autoDownload)) - { - std::cerr << __PRETTY_FUNCTION__ << " failed to set autodownload " - << "for channel: " << grpId.toStdString() << std::endl; - 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 ); - }); -} - -bool GxsChannelPostsWidget::insertGroupData(const RsGxsGenericGroupData *data) -{ - const RsGxsChannelGroup *d = dynamic_cast(data); - - if(!d) - { - RsErr() << __PRETTY_FUNCTION__ << " Cannot dynamic cast input data (" << (void*)data << " to RsGxsGenericGroupData. Something bad happenned." << std::endl; - return false; - } - - insertChannelDetails(*d); - return true; -} - -void GxsChannelPostsWidget::getMsgData(const std::set& msgIds,std::vector& psts) -{ - std::vector posts; - std::vector comments; - std::vector 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& psts) -{ - std::vector posts; - std::vector comments; - std::vector 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 groups; - - if(rsGxsChannels->getChannelsInfo(std::list({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; -} - -void GxsChannelPostsWidget::insertAllPosts(const std::vector& posts, GxsMessageFramePostThread *thread) -{ - std::vector cposts; - - for(auto post: posts) // This is not so nice but we have somehow to convert to RsGxsChannelPost at some time, and the cposts list is being modified in the insert method. - cposts.push_back(*static_cast(post)); - - insertChannelPosts(cposts, thread, false); -} -void GxsChannelPostsWidget::insertPosts(const std::vector& posts) -{ - std::vector cposts; - - for(auto post: posts) // This is not so nice but we have somehow to convert to RsGxsChannelPost at some timer, and the cposts list is being modified in the insert method. - cposts.push_back(*static_cast(post)); - - insertChannelPosts(cposts, NULL, true); -} - -class GxsChannelPostsReadData -{ -public: - GxsChannelPostsReadData(bool read) - { - mRead = read; - mLastToken = 0; - } - -public: - bool mRead; - uint32_t mLastToken; -}; - -static void setAllMessagesReadCallback(FeedItem *feedItem, void *data) -{ - GxsChannelPostItem *channelPostItem = dynamic_cast(feedItem); - if (!channelPostItem) { - return; - } - - GxsChannelPostsReadData *readData = (GxsChannelPostsReadData*) data; - bool isRead = !channelPostItem->isUnread() ; - - if(channelPostItem->isLoaded() && (isRead == readData->mRead)) - return ; - - RsGxsGrpMsgIdPair msgPair = std::make_pair(channelPostItem->groupId(), channelPostItem->messageId()); - rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead); -} - -void GxsChannelPostsWidget::setAllMessagesReadDo(bool read, uint32_t &token) -{ - if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(subscribeFlags())) { - return; - } - - GxsChannelPostsReadData data(read); - ui->feedWidget->withAll(setAllMessagesReadCallback, &data); - - token = data.mLastToken; -} diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h deleted file mode 100644 index dded41491..000000000 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h * - * * - * Copyright 2013 by Robert Fernie * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - * * - *******************************************************************************/ - -#ifndef _GXS_CHANNELPOSTSWIDGET_H -#define _GXS_CHANNELPOSTSWIDGET_H - -#include - -#include "gui/gxs/GxsMessageFramePostWidget.h" - -#include "gui/feeds/FeedHolder.h" - -namespace Ui { -class GxsChannelPostsWidget; -} - -class GxsChannelPostItem; -class QTreeWidgetItem; -class FeedItem; - -class GxsChannelPostsWidget : public GxsMessageFramePostWidget, public FeedHolder -{ - Q_OBJECT - -public: - /* Filters */ - enum Filter { - FILTER_TITLE = 1, - FILTER_MSG = 2, - FILTER_FILE_NAME = 3 - }; - -public: - /** Default Constructor */ - GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent = 0); - /** Default Destructor */ - ~GxsChannelPostsWidget(); - - /* GxsMessageFrameWidget */ - virtual QIcon groupIcon(); - - /* FeedHolder */ - virtual QScrollArea *getScrollArea(); - 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 &msg_versions, const RsGxsMessageId &msgId, const QString &title); - -protected: - /* GxsMessageFramePostWidget */ - virtual void groupNameChanged(const QString &name); - virtual bool insertGroupData(const RsGxsGenericGroupData *data) override; - virtual void clearPosts(); - 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 bool getGroupData(RsGxsGenericGroupData *& data) override; - virtual void getMsgData(const std::set& msgIds,std::vector& posts) override; - virtual void getAllMsgData(std::vector& posts) override; - virtual void insertPosts(const std::vector& posts) override; - virtual void insertAllPosts(const std::vector& posts, GxsMessageFramePostThread *thread) override; - - /* GxsMessageFrameWidget */ - virtual void setAllMessagesReadDo(bool read, uint32_t &token); - -private slots: - void createMsg(); - void toggleAutoDownload(); - void subscribeGroup(bool subscribe); - void filterChanged(int filter); - void setViewMode(int viewMode); - void settingsChanged(); - -private: - void processSettings(bool load); - - void setAutoDownload(bool autoDl); - static bool filterItem(FeedItem *feedItem, const QString &text, int filter); - - int viewMode(); - - void insertChannelDetails(const RsGxsChannelGroup &group); - void insertChannelPosts(std::vector& posts, GxsMessageFramePostThread *thread, bool related); - - void createPostItem(const RsGxsChannelPost &post, bool related); - void handleEvent_main_thread(std::shared_ptr event); - -private: - QAction *mAutoDownloadAction; - - RsGxsChannelGroup mGroup; - bool mUseThread; - RsEventsHandlerId_t mEventHandlerId ; - - /* UI - from Designer */ - Ui::GxsChannelPostsWidget *ui; -}; - -#endif diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui deleted file mode 100644 index fb6845f26..000000000 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.ui +++ /dev/null @@ -1,593 +0,0 @@ - - - GxsChannelPostsWidget - - - - 0 - 0 - 977 - 628 - - - - - 4 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::Box - - - QFrame::Sunken - - - - 4 - - - 4 - - - 4 - - - 4 - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/images/channels.png - - - true - - - - - - - - - - - - - - Channel Name - - - - - - - - - - QFrame::Box - - - QFrame::Sunken - - - - 4 - - - 2 - - - 6 - - - 2 - - - - - - 0 - 0 - - - - Subscribe - - - - 16 - 16 - - - - QToolButton::MenuButtonPopup - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Qt::NoFocus - - - Post to Channel - - - Add new post - - - - :/icons/png/add.png:/icons/png/add.png - - - - 32 - 16 - - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 0 - 0 - - - - - - - - Loading - - - - - - - - 0 - 0 - - - - - 16777215 - 10 - - - - 1000 - - - 0 - - - - - - - 0 - - - - - Show feeds - - - - :/images/view-feeds.png:/images/view-feeds.png - - - true - - - true - - - - - - - Show files - - - - :/images/view-files.png:/images/view-files.png - - - true - - - true - - - - - - - - - - 0 - 0 - - - - - 200 - 0 - - - - - 200 - 16777215 - - - - Search channels - - - true - - - - - - - - - - - - - - 3 - - - 0 - - - 3 - - - 3 - - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - Channel details - - - - 9 - - - 9 - - - 9 - - - 9 - - - - - - 0 - 0 - - - - - 75 - true - - - - Last Post: - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Description</span></p></body></html> - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - true - - - true - - - - - - - - 75 - true - - - - Description: - - - - - - - - 75 - true - - - - Created: - - - - - - - - 75 - true - - - - Administrator: - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Posts: - - - - - - - - 75 - true - - - - Distribution: - - - - - - - unknown - - - - - - - unknown - - - - - - - unknown - - - true - - - - - - - unknown - - - - - - - 0 - - - - - - - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - Feeds - - - - - Files - - - toolBarFrame - headFrame - feedWidget - fileWidget - infoWidget - - - - GxsIdLabel - QLabel -
gui/gxs/GxsIdLabel.h
-
- - SubscribeToolButton - QToolButton -
gui/common/SubscribeToolButton.h
-
- - StyledElidedLabel - QLabel -
gui/common/StyledElidedLabel.h
-
- - LineEditClear - QLineEdit -
gui/common/LineEditClear.h
-
- - GxsChannelFilesWidget - QWidget -
gui/gxschannels/GxsChannelFilesWidget.h
- 1 -
- - RSFeedWidget - QWidget -
gui/common/RSFeedWidget.h
- 1 -
-
- - - - - -
diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index bf76f36a2..616b3f835 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1336,11 +1336,9 @@ gxschannels { HEADERS += gui/gxschannels/GxsChannelDialog.h \ gui/gxschannels/GxsChannelGroupDialog.h \ gui/gxschannels/CreateGxsChannelMsg.h \ - gui/gxschannels/GxsChannelPostsWidget.h \ gui/gxschannels/GxsChannelPostsWidgetWithModel.h \ gui/gxschannels/GxsChannelPostsModel.h \ gui/gxschannels/GxsChannelPostFilesModel.h \ - gui/gxschannels/GxsChannelFilesWidget.h \ gui/gxschannels/GxsChannelPostThumbnail.h \ gui/gxschannels/GxsChannelFilesStatusWidget.h \ gui/feeds/GxsChannelGroupItem.h \ @@ -1349,19 +1347,15 @@ gxschannels { FORMS += \ gui/gxschannels/GxsChannelPostsWidgetWithModel.ui \ - gui/gxschannels/GxsChannelPostsWidget.ui \ - gui/gxschannels/GxsChannelFilesWidget.ui \ gui/gxschannels/GxsChannelFilesStatusWidget.ui \ gui/gxschannels/CreateGxsChannelMsg.ui \ gui/feeds/GxsChannelGroupItem.ui \ gui/feeds/GxsChannelPostItem.ui SOURCES += gui/gxschannels/GxsChannelDialog.cpp \ - gui/gxschannels/GxsChannelPostsWidget.cpp \ - gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp \ gui/gxschannels/GxsChannelPostsModel.cpp \ + gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp \ gui/gxschannels/GxsChannelPostFilesModel.cpp \ - gui/gxschannels/GxsChannelFilesWidget.cpp \ gui/gxschannels/GxsChannelFilesStatusWidget.cpp \ gui/gxschannels/GxsChannelGroupDialog.cpp \ gui/gxschannels/CreateGxsChannelMsg.cpp \ From 7db48990c32e8ca57cc9f1f00bbd416a6b83850d Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 1 Jul 2020 20:38:44 +0200 Subject: [PATCH 02/78] started creation of board model. Does not compile yet. --- .../src/gui/Posted/PostedDialog.cpp | 4 +- .../gui/Posted/PostedListWidgetWithModel.h | 146 ++++ .../gui/Posted/PostedListWidgetWithModel.ui | 566 ++++++++++++++ .../src/gui/Posted/PostedPostsModel.cpp | 688 ++++++++++++++++++ .../src/gui/Posted/PostedPostsModel.h | 197 +++++ retroshare-gui/src/retroshare-gui.pro | 8 +- 6 files changed, 1604 insertions(+), 5 deletions(-) create mode 100644 retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h create mode 100644 retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui create mode 100644 retroshare-gui/src/gui/Posted/PostedPostsModel.cpp create mode 100644 retroshare-gui/src/gui/Posted/PostedPostsModel.h diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.cpp b/retroshare-gui/src/gui/Posted/PostedDialog.cpp index 6c2772276..4cac07246 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedDialog.cpp @@ -21,7 +21,7 @@ #include "PostedDialog.h" #include "PostedItem.h" #include "PostedGroupDialog.h" -#include "PostedListWidget.h" +#include "PostedListWidgetWithModel.h" #include "PostedUserNotify.h" #include "gui/gxs/GxsGroupShareKey.h" #include "gui/settings/rsharesettings.h" @@ -195,7 +195,7 @@ int PostedDialog::shareKeyType() GxsMessageFrameWidget *PostedDialog::createMessageFrameWidget(const RsGxsGroupId &groupId) { - return new PostedListWidget(groupId); + return new PostedListWidgetWithModel(groupId); } RsGxsCommentService *PostedDialog::getCommentService() diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h new file mode 100644 index 000000000..8d4208db3 --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -0,0 +1,146 @@ +/******************************************************************************* + * retroshare-gui/src/gui/gxschannels/BoardPostsWidget.h * + * * + * Copyright 2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef _GXS_CHANNELPOSTSWIDGET_H +#define _GXS_CHANNELPOSTSWIDGET_H + +#include + +#include + +#include "retroshare/rsposted.h" + +#include "gui/gxs/GxsMessageFramePostWidget.h" +#include "gui/feeds/FeedHolder.h" + +namespace Ui { +class PostedListWidgetWithModel; +} + +class QTreeWidgetItem; +class QSortFilterProxyModel; +class RsPostedPostsModel; + +class PostedPostDelegate: public QAbstractItemDelegate +{ + Q_OBJECT + + public: + PostedPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){} + virtual ~PostedPostDelegate(){} + + void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + + int cellSize(const QFont& font) const; +}; + +class PostedListWidgetWithModel: public GxsMessageFrameWidget +{ + Q_OBJECT + +public: + /* Filters */ + enum Filter { + SORT_TITLE = 1, + SORT_MSG = 2, + SORT_FILE_NAME = 3 + }; + +public: + /** Default Constructor */ + PostedListWidgetWithModel(const RsGxsGroupId &postedId, QWidget *parent = 0); + /** Default Destructor */ + ~PostedListWidgetWithModel(); + + /* GxsMessageFrameWidget */ + virtual QIcon groupIcon() override; + virtual void groupIdChanged() override { updateDisplay(true); } + virtual QString groupName(bool) override ; + virtual bool navigate(const RsGxsMessageId&) override; + + void updateDisplay(bool complete) ; + +#ifdef TODO + /* FeedHolder */ + virtual QScrollArea *getScrollArea(); + virtual void deleteFeedItem(FeedItem *feedItem, uint32_t type); + virtual void openChat(const RsPeerId& peerId); +#endif + virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector &msg_versions, const RsGxsMessageId &msgId, const QString &title); + +protected: + /* GxsMessageFramePostWidget */ + virtual void groupNameChanged(const QString &name); + +#ifdef TODO + virtual bool insertGroupData(const RsGxsGenericGroupData *data) override; +#endif + virtual void blank() ; + +#ifdef TODO + virtual bool getGroupData(RsGxsGenericGroupData *& data) override; + virtual void getMsgData(const std::set& msgIds,std::vector& posts) override; + virtual void getAllMsgData(std::vector& posts) override; + virtual void insertPosts(const std::vector& posts) override; + virtual void insertAllPosts(const std::vector& posts, GxsMessageFramePostThread *thread) override; +#endif + + /* GxsMessageFrameWidget */ + virtual void setAllMessagesReadDo(bool read, uint32_t &token); + +private slots: + void updateGroupData(); + void createMsg(); + void subscribeGroup(bool subscribe); + void setViewMode(int viewMode); + void settingsChanged(); + void handlePostsTreeSizeChange(QSize s); + void postChannelPostLoad(); + void postContextMenu(const QPoint&); + void copyMessageLink(); + +public slots: + void sortColumnFiles(int col,Qt::SortOrder so); + void sortColumnPostFiles(int col,Qt::SortOrder so); + +private: + void processSettings(bool load); + int viewMode(); + + void insertBoardDetails(const RsPostedGroup &group); + void handleEvent_main_thread(std::shared_ptr event); + +private: + RsPostedGroup mGroup; + RsEventsHandlerId_t mEventHandlerId ; + + RsPostedPostsModel *mPostedPostsModel; + PostedPostDelegate *mPostedPostsDelegate; + + RsGxsMessageId mSelectedPost; + + /* UI - from Designer */ + Ui::PostedListWidgetWithModel *ui; +}; + +#endif diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui new file mode 100644 index 000000000..744ae6870 --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -0,0 +1,566 @@ + + + PostedListWidgetWithModel + + + + 0 + 0 + 950 + 771 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + false + + + + + + Board Details + + + false + + + false + + + + 6 + + + + + 0 + + + + + + 75 + true + + + + Popularity + + + + + + + + 75 + true + + + + 0 + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Posts + + + + + + + + 75 + true + + + + 0 + + + + + + + + 75 + true + + + + Created + + + + + + + unknown + + + + + + + + 75 + true + + + + Administrator: + + + + + + + unknown + + + true + + + + + + + + 75 + true + + + + Distribution: + + + + + + + unknown + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Last Post: + + + + + + + unknown + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + :/icons/png/postedlinks.png + + + true + + + + + + + + 14 + + + + TextLabel + + + + + + + + + Qt::Horizontal + + + + 421 + 114 + + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Description</span></p></body></html> + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + true + + + true + + + + + + + + + + + + + + + + QFrame::Box + + + QFrame::Sunken + + + + 6 + + + 2 + + + 6 + + + 2 + + + + + + 0 + 0 + + + + + 50 + false + false + + + + + + + Subscribe + + + false + + + + + + + + 0 + 0 + + + + Create Post + + + + :/images/write.png:/images/write.png + + + + 24 + 24 + + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + <html><head/><body><p><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol'; font-size:14px; color:#24292e; background-color:#ffffff;">Select sorting</span></p></body></html> + + + + + + + 24 + 24 + + + + + Hot + + + + :/icons/png/flame.png:/icons/png/flame.png + + + + + New + + + + :/icons/png/new.png:/icons/png/new.png + + + + + Top + + + + :/icons/png/top.png:/icons/png/top.png + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + + + Classic view + + + + :/images/classic.png:/images/classic.png + + + + 24 + 24 + + + + true + + + true + + + + + + + Card View + + + + :/images/card.png:/images/card.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + + Previous + + + + + + + :/icons/png/arrow-left.png:/icons/png/arrow-left.png + + + + + + + 1-10 + + + + + + + Next + + + + + + + :/icons/png/arrow-right.png:/icons/png/arrow-right.png + + + + + + + <html><head/><body><p>Default identity used when voting</p></body></html> + + + + + + + + + + + GxsIdLabel + QLabel +
gui/gxs/GxsIdLabel.h
+
+ + SubscribeToolButton + QToolButton +
gui/common/SubscribeToolButton.h
+
+ + RSTreeView + QTreeView +
gui/common/RSTreeView.h
+
+ + GxsIdChooser + QComboBox +
gui/gxs/GxsIdChooser.h
+
+
+ + + + + +
diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp new file mode 100644 index 000000000..7bb8094dd --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -0,0 +1,688 @@ +/******************************************************************************* + * retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp * + * * + * Copyright 2020 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include +#include + +#include "retroshare/rsgxsflags.h" +#include "retroshare/rsexpr.h" + +#include "gui/common/FilesDefs.h" +#include "util/qtthreadsutils.h" +#include "util/HandleRichText.h" +#include "util/DateTime.h" + +#include "PostedPostsModel.h" + +//#define DEBUG_CHANNEL_MODEL + +Q_DECLARE_METATYPE(RsMsgMetaData) +Q_DECLARE_METATYPE(RsPostedPost) + +std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere + +RsPostedPostsModel::RsPostedPostsModel(QObject *parent) + : QAbstractItemModel(parent), mTreeMode(TREE_MODE_PLAIN), mColumns(6) +{ + initEmptyHierarchy(); + + mEventHandlerId = 0; + // Needs to be asynced because this function is called by another thread! + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); + }, mEventHandlerId, RsEventType::GXS_CHANNELS ); +} + +RsPostedPostsModel::~RsPostedPostsModel() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} + +void RsPostedPostsModel::handleEvent_main_thread(std::shared_ptr event) +{ + const RsGxsPostedEvent *e = dynamic_cast(event.get()); + + if(!e) + return; + + switch(e->mPostedEventCode) + { + case RsPostedEventCode::UPDATED_MESSAGE: + case RsPostedEventCode::READ_STATUS_CHANGED: + { + // Normally we should just emit dataChanged() on the index of the data that has changed: + // + // We need to update the data! + + if(e->mPostedGroupId == mPostedGroup.mMeta.mGroupId) + RsThread::async([this, e]() + { + // 1 - get message data from p3GxsChannels + + std::vector posts; + std::vector comments; + std::vector votes; + + if(!rsPosted->getBoardContent(mPostedGroup.mMeta.mGroupId,std::set{ e->mPostedMsgId }, posts,comments,votes)) + { + std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel message data for channel/msg " << e->mChannelGroupId << "/" << e->mChannelMsgId << std::endl; + return; + } + + // 2 - update the model in the UI thread. + + RsQThreadUtils::postToObject( [posts,comments,votes,this]() + { + for(uint32_t i=0;i 0) + return 0; + + if(mFilteredPosts.empty()) // security. Should never happen. + return 0; + + if(!parent.isValid()) + return mFilteredPosts.size() ; + + RsErr() << __PRETTY_FUNCTION__ << " rowCount cannot figure out the porper number of rows." << std::endl; + return 0; +} + +int RsPostedPostsModel::columnCount(const QModelIndex &/*parent*/) const +{ + return 1; +} + +bool RsPostedPostsModel::getPostData(const QModelIndex& i,RsPostedPost& fmpe) const +{ + if(!i.isValid()) + return true; + + quintptr ref = i.internalId(); + uint32_t entry = 0; + + if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size()) + return false ; + + fmpe = mPosts[mFilteredPosts[entry]]; + + return true; + +} + +bool RsPostedPostsModel::hasChildren(const QModelIndex &parent) const +{ + if(!parent.isValid()) + return true; + + return false; // by default, no post has children +} + +bool RsPostedPostsModel::convertTabEntryToRefPointer(uint32_t entry,quintptr& ref) +{ + // the pointer is formed the following way: + // + // [ 32 bits ] + // + // This means that the whole software has the following build-in limitation: + // * 4 B simultaenous posts. Should be enough ! + + ref = (intptr_t)(entry+1); + + return true; +} + +bool RsPostedPostsModel::convertRefPointerToTabEntry(quintptr ref, uint32_t& entry) +{ + intptr_t val = (intptr_t)ref; + + if(val > (1<<30)) // make sure the pointer is an int that fits in 32bits and not too big which would look suspicious + { + RsErr() << "(EE) trying to make a ChannelPostsModelIndex out of a number that is larger than 2^32-1 !" << std::endl; + return false ; + } + if(val==0) + { + RsErr() << "(EE) trying to make a ChannelPostsModelIndex out of index 0." << std::endl; + return false; + } + + entry = val - 1; + + return true; +} + +QModelIndex RsPostedPostsModel::index(int row, int column, const QModelIndex & parent) const +{ + if(row < 0 || column < 0) + return QModelIndex(); + + quintptr ref = getChildRef(parent.internalId(),row); + +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << "index-3(" << row << "," << column << " parent=" << parent << ") : " << createIndex(row,column,ref) << std::endl; +#endif + return createIndex(row,column,ref) ; +} + +QModelIndex RsPostedPostsModel::parent(const QModelIndex& index) const +{ + if(!index.isValid()) + return QModelIndex(); + + return QModelIndex(); // there's no hierarchy here. So nothing to do! +} + +Qt::ItemFlags RsPostedPostsModel::flags(const QModelIndex& index) const +{ + if (!index.isValid()) + return 0; + + return QAbstractItemModel::flags(index); +} + +quintptr RsPostedPostsModel::getChildRef(quintptr ref,int index) const +{ + if (index < 0) + return 0; + + if(ref == quintptr(0)) + { + quintptr new_ref; + convertTabEntryToRefPointer(index,new_ref); + return new_ref; + } + else + return 0 ; +} + +quintptr RsPostedPostsModel::getParentRow(quintptr ref,int& row) const +{ + PostedPostsModelIndex ref_entry; + + if(!convertRefPointerToTabEntry(ref,ref_entry) || ref_entry >= mFilteredPosts.size()) + return 0 ; + + if(ref_entry == 0) + { + RsErr() << "getParentRow() shouldn't be asked for the parent of NULL" << std::endl; + row = 0; + } + else + row = ref_entry-1; + + return 0; +} + +int RsPostedPostsModel::getChildrenCount(quintptr ref) const +{ + uint32_t entry = 0 ; + + if(ref == quintptr(0)) + return rowCount()-1; + + return 0; +} + +QVariant RsPostedPostsModel::data(const QModelIndex& index, int role) const +{ +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << "calling data(" << index << ") role=" << role << std::endl; +#endif + + if(!index.isValid()) + return QVariant(); + + switch(role) + { + case Qt::SizeHintRole: return sizeHintRole(index.column()) ; + case Qt::StatusTipRole:return QVariant(); + default: break; + } + + quintptr ref = (index.isValid())?index.internalId():0 ; + uint32_t entry = 0; + +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << "data(" << index << ")" ; +#endif + + if(!ref) + { +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << " [empty]" << std::endl; +#endif + return QVariant() ; + } + + if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size()) + { +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << "Bad pointer: " << (void*)ref << std::endl; +#endif + return QVariant() ; + } + + const RsPostedPost& fmpe(mPosts[mFilteredPosts[entry]]); + + switch(role) + { + case Qt::DisplayRole: return displayRole (fmpe,index.column()) ; + case Qt::UserRole: return userRole (fmpe,index.column()) ; + default: + return QVariant(); + } +} + +QVariant RsPostedPostsModel::sizeHintRole(int col) const +{ + float factor = QFontMetricsF(QApplication::font()).height()/14.0f ; + + return QVariant( QSize(factor * 170, factor*14 )); +} + +QVariant RsPostedPostsModel::displayRole(const RsPostedPost& fmpe,int col) const +{ + switch(col) + { + default: + return QString::fromUtf8(fmpe.mMeta.mMsgName.c_str()); + } + + + return QVariant("[ERROR]"); +} + +QVariant RsPostedPostsModel::userRole(const RsPostedPost& fmpe,int col) const +{ + switch(col) + { + default: + return QVariant::fromValue(fmpe); + } +} + +const RsGxsGroupId& RsPostedPostsModel::currentGroupId() const +{ + return mPostedGroup.mMeta.mGroupId; +} + +void RsPostedPostsModel::updateBoard(const RsGxsGroupId& board_group_id) +{ + if(board_group_id.isNull()) + return; + + update_posts(board_group_id); +} + +void RsPostedPostsModel::clear() +{ + preMods(); + + mPosts.clear(); + initEmptyHierarchy(); + + postMods(); + emit boardPostsLoaded(); +} + +bool operator<(const RsPostedPost& p1,const RsPostedPost& p2) +{ + return p1.mMeta.mPublishTs > p2.mMeta.mPublishTs; +} + +void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector& posts) +{ + preMods(); + + beginRemoveRows(QModelIndex(),0,rowCount()-1); + endRemoveRows(); + + mPosts.clear(); + mPostedGroup = group; + + createPostsArray(posts); + + std::sort(mPosts.begin(),mPosts.end()); + + mFilteredPosts.clear(); + for(int i=0;i groupIds; + std::vector msg_metas; + std::vector groups; + + groupIds.push_back(group_id); + + if(!rsPosted->getBoardsInfo(groupIds,groups) || groups.size() != 1) + { + std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel group info for channel " << group_id << std::endl; + return; + } + + RsPostedGroup group = groups[0]; + + // We use the heap because the arrays need to be stored accross async + + std::vector *posts = new std::vector(); + std::vector *comments = new std::vector(); + std::vector *votes = new std::vector(); + + if(!rsPosted->getBoardContent(group_id, *posts,*comments,*votes)) + { + std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel messages for channel " << group_id << std::endl; + return; + } + + // 2 - update the model in the UI thread. + + RsQThreadUtils::postToObject( [group,posts,comments,votes,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 + * after a blocking call to RetroShare API complete, note that + * Qt::QueuedConnection is important! + */ + + setPosts(group,*posts) ; + + delete posts; + delete comments; + delete votes; + + }, this ); + + }); +} + +static bool decreasing_time_comp(const std::pair& e1,const std::pair& e2) { return e2.first < e1.first ; } + +void RsPostedPostsModel::createPostsArray(std::vector& posts) +{ + // Collect new versions of posts if any. For now Boards do not have versions, but if that ever happens, we'll be handlign it already. This code + // is a blind copy of the channel code. + +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << "Inserting channel posts" << std::endl; +#endif + + std::vector new_versions ; + for (uint32_t i=0;i search_map ; + for (uint32_t i=0;i versions ; + std::map::const_iterator vit ; + + while(search_map.end() != (vit=search_map.find(posts[current_index].mMeta.mOrigMsgId))) + { +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << " post at index " << current_index << " replaces a post at position " << vit->second ; +#endif + + // Now replace the post only if the new versionis more recent. It may happen indeed that the same post has been corrected multiple + // times. In this case, we only need to replace the post with the newest version + + //uint32_t prev_index = current_index ; + current_index = vit->second ; + + if(posts[current_index].mMeta.mMsgId.isNull()) // This handles the branching situation where this post has been already erased. No need to go down further. + { +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << " already erased. Stopping." << std::endl; +#endif + break ; + } + + if(posts[current_index].mMeta.mPublishTs < posts[source_index].mMeta.mPublishTs) + { +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << " and is more recent => following" << std::endl; +#endif + for(std::set::const_iterator itt(posts[current_index].mOlderVersions.begin());itt!=posts[current_index].mOlderVersions.end();++itt) + posts[source_index].mOlderVersions.insert(*itt); + + posts[source_index].mOlderVersions.insert(posts[current_index].mMeta.mMsgId); + posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored + } +#ifdef DEBUG_CHANNEL_MODEL + else + std::cerr << " but is older -> Stopping" << std::endl; +#endif + } + } + } + +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << "Now adding " << posts.size() << " posts into array structure..." << std::endl; +#endif + + mPosts.clear(); + + for (std::vector::const_reverse_iterator it = posts.rbegin(); it != posts.rend(); ++it) + { + if(!(*it).mMeta.mMsgId.isNull()) + { +#ifdef DEBUG_CHANNEL_MODEL + std::cerr << " adding post \"" << (*it).mMeta.mMsgName << "\"" << std::endl; +#endif + mPosts.push_back(*it); + } +#ifdef DEBUG_CHANNEL_MODEL + else + std::cerr << " skipped older version post \"" << (*it).mMeta.mMsgName << "\"" << std::endl; +#endif + } +} + +void RsPostedPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status,bool with_children) +{ + if(!i.isValid()) + return ; + + // no need to call preMods()/postMods() here because we'renot changing the model + + quintptr ref = i.internalId(); + uint32_t entry = 0; + + if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size()) + return ; + +#warning TODO +// bool has_unread_below, has_read_below; +// recursSetMsgReadStatus(entry,read_status,with_children) ; +// recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below); +} + +QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const +{ + // Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map. + + RsGxsMessageId postId = mid; + + for(uint32_t i=0;i * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include "retroshare/rsposted.h" +#include "retroshare/rsgxsifacetypes.h" +#include "retroshare/rsevents.h" + +#include +#include + +// This class holds the actual hierarchy of posts, represented by identifiers +// It is responsible for auto-updating when necessary and holds a mutex to allow the Model to +// safely access the data. + +// The model contains a post in place 0 that is the parent of all posts. + +typedef uint32_t PostedPostsModelIndex; + +// struct ChannelPostsModelPostEntry +// { +// ChannelPostsModelPostEntry() : mPublishTs(0),mPostFlags(0),mMsgStatus(0),prow(0) {} +// +// enum { // flags for display of posts. To be used in mPostFlags +// FLAG_POST_IS_PINNED = 0x0001, +// FLAG_POST_IS_MISSING = 0x0002, +// FLAG_POST_IS_REDACTED = 0x0004, +// FLAG_POST_HAS_UNREAD_CHILDREN = 0x0008, +// FLAG_POST_HAS_READ_CHILDREN = 0x0010, +// FLAG_POST_PASSES_FILTER = 0x0020, +// FLAG_POST_CHILDREN_PASSES_FILTER = 0x0040, +// }; +// +// std::string mTitle ; +// RsGxsMessageId mMsgId; +// uint32_t mPublishTs; +// uint32_t mPostFlags; +// int mMsgStatus; +// +// int prow ;// parent row, which basically means position in the array of posts +// }; + +// This class is the item model used by Qt to display the information + +class RsPostedPostsModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + explicit RsPostedPostsModel(QObject *parent = NULL); + virtual ~RsPostedPostsModel() override; + + static const int COLUMN_THREAD_NB_COLUMNS = 0x01; + + enum Columns { + COLUMN_POSTS =0x00, + COLUMN_THREAD_MSGID =0x01, + COLUMN_THREAD_DATA =0x02, + }; + + enum Roles{ SortRole = Qt::UserRole+1, + StatusRole = Qt::UserRole+2, + FilterRole = Qt::UserRole+3, + }; + + enum TreeMode{ TREE_MODE_UNKWN = 0x00, + TREE_MODE_PLAIN = 0x01, + TREE_MODE_FILES = 0x02, + }; + +#ifdef TODO + enum SortMode{ SORT_MODE_PUBLISH_TS = 0x00, + SORT_MODE_CHILDREN_PUBLISH_TS = 0x01, + }; +#endif + + QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;} + QModelIndex getIndexOfMessage(const RsGxsMessageId& mid) const; + + // This method will asynchroneously update the data + + void updateBoard(const RsGxsGroupId& posted_group_id); + const RsGxsGroupId& currentGroupId() const; + +#ifdef TODO + void setSortMode(SortMode mode) ; + + void setTextColorRead (QColor color) { mTextColorRead = color;} + void setTextColorUnread (QColor color) { mTextColorUnread = color;} + void setTextColorUnreadChildren(QColor color) { mTextColorUnreadChildren = color;} + void setTextColorNotSubscribed (QColor color) { mTextColorNotSubscribed = color;} + void setTextColorMissing (QColor color) { mTextColorMissing = color;} +#endif + + void setMsgReadStatus(const QModelIndex &i, bool read_status, bool with_children); + void setFilter(const QStringList &strings, uint32_t &count) ; + +#ifdef TODO + void setAuthorOpinion(const QModelIndex& indx,RsOpinion op); +#endif + + // Helper functions + + bool getPostData(const QModelIndex& i,RsPostedPost& fmpe) const ; + void clear() ; + + // AbstractItemModel functions. + + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; + + QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex& child) const override; + Qt::ItemFlags flags(const QModelIndex& index) const override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + // Custom item roles + + QVariant sizeHintRole (int col) const; + QVariant displayRole (const RsPostedPost& fmpe, int col) const; + QVariant toolTipRole (const RsPostedPost& fmpe, int col) const; + QVariant userRole (const RsPostedPost& fmpe, int col) const; +#ifdef TODO + QVariant decorationRole(const RsPostedPost& fmpe, int col) const; + QVariant pinnedRole (const RsPostedPost& fmpe, int col) const; + QVariant missingRole (const RsPostedPost& fmpe, int col) const; + QVariant statusRole (const RsPostedPost& fmpe, int col) const; + QVariant authorRole (const RsPostedPost& fmpe, int col) const; + QVariant sortRole (const RsPostedPost& fmpe, int col) const; + QVariant fontRole (const RsPostedPost& fmpe, int col) const; + QVariant filterRole (const RsPostedPost& fmpe, int col) const; + QVariant textColorRole (const RsPostedPost& fmpe, int col) const; + QVariant backgroundRole(const RsPostedPost& fmpe, int col) const; +#endif + + /*! + * \brief debug_dump + * Dumps the hierarchy of posts in the terminal, to allow checking whether the internal representation is correct. + */ + void debug_dump(); + +signals: + void boardlPostsLoaded(); // emitted after the posts have been loaded. + +private: + RsPostedGroup mPostedGroup; + + TreeMode mTreeMode; + + void preMods() ; + void postMods() ; + + quintptr getParentRow(quintptr ref,int& row) const; + quintptr getChildRef(quintptr ref, int index) const; + int getChildrenCount(quintptr ref) const; + + static bool convertTabEntryToRefPointer(uint32_t entry, quintptr &ref); + static bool convertRefPointerToTabEntry(quintptr ref,uint32_t& entry); + static void computeReputationLevel(uint32_t forum_sign_flags, RsPostedPost& entry); + + void update_posts(const RsGxsGroupId& group_id); + +#ifdef TODO + void setForumMessageSummary(const std::vector& messages); + void recursUpdateReadStatusAndTimes(ChannelPostsModelIndex i,bool& has_unread_below,bool& has_read_below); + uint32_t recursUpdateFilterStatus(ChannelPostsModelIndex i,int column,const QStringList& strings); + void recursSetMsgReadStatus(ChannelPostsModelIndex i,bool read_status,bool with_children); +#endif + + void createPostsArray(std::vector &posts); + void setPosts(const RsPostedGroup& group, std::vector &posts); + void initEmptyHierarchy(); + void handleEvent_main_thread(std::shared_ptr event); + + std::vector mFilteredPosts; // stores the list of displayes indices due to filtering. + std::vector mPosts ; // store the list of posts updated from rsForums. + + RsEventsHandlerId_t mEventHandlerId ; +}; diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 616b3f835..bd3aec4f8 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1368,7 +1368,8 @@ gxschannels { posted { HEADERS += gui/Posted/PostedDialog.h \ - gui/Posted/PostedListWidget.h \ + gui/Posted/PostedListWidgetWithModel.h \ + gui/Posted/PostedPostsModel.h \ gui/Posted/PostedItem.h \ gui/Posted/PostedCardView.h \ gui/Posted/PostedGroupDialog.h \ @@ -1380,7 +1381,7 @@ posted { #gui/Posted/PostedCreateCommentDialog.h \ #gui/Posted/PostedComments.h \ - FORMS += gui/Posted/PostedListWidget.ui \ + FORMS += gui/Posted/PostedListWidgetWithModel.ui \ gui/feeds/PostedGroupItem.ui \ gui/Posted/PostedItem.ui \ gui/Posted/PostedCardView.ui \ @@ -1391,7 +1392,8 @@ posted { #gui/Posted/PostedCreateCommentDialog.ui SOURCES += gui/Posted/PostedDialog.cpp \ - gui/Posted/PostedListWidget.cpp \ + gui/Posted/PostedListWidgetWithModel.cpp \ + gui/Posted/PostedPostsModel.cpp \ gui/feeds/PostedGroupItem.cpp \ gui/Posted/PostedItem.cpp \ gui/Posted/PostedCardView.cpp \ From e676f83ab36015f2dbbf905b12bff10dc62af3c6 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 2 Jul 2020 21:15:48 +0200 Subject: [PATCH 03/78] added new display widget for boards copying functionality from CardView --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 350 ++++++++++++ .../src/gui/Posted/BoardPostDisplayWidget.h | 65 +++ .../src/gui/Posted/BoardPostDisplayWidget.ui | 526 ++++++++++++++++++ .../gui/Posted/PostedListWidgetWithModel.h | 7 +- .../src/gui/Posted/PostedPostsModel.cpp | 18 +- .../src/gui/Posted/PostedPostsModel.h | 2 +- retroshare-gui/src/retroshare-gui.pro | 3 + 7 files changed, 957 insertions(+), 14 deletions(-) create mode 100644 retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp create mode 100644 retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h create mode 100644 retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp new file mode 100644 index 000000000..772b193a2 --- /dev/null +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -0,0 +1,350 @@ +/******************************************************************************* + * retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp * + * * + * Copyright (C) 2019 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include +#include + +#include "rshare.h" +#include "BoardPostDisplayWidget.h" +#include "gui/feeds/FeedHolder.h" +#include "gui/gxs/GxsIdDetails.h" +#include "util/misc.h" +#include "gui/common/FilesDefs.h" +#include "util/qtthreadsutils.h" +#include "util/HandleRichText.h" + +#include "ui_BoardPostDisplayWidget.h" + +#include +#include + +#define LINK_IMAGE ":/images/thumb-link.png" + +/** Constructor */ + +const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2.png"; + +BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,QWidget *parent) + : QWidget(parent),ui(new Ui::BoardPostDisplayWidget()),mPost(post) +{ + ui->setupUi(this); +} + +void BoardPostDisplayWidget::setCommentsSize(int comNb) +{ + QString sComButText = tr("Comment"); + if (comNb == 1) + sComButText = sComButText.append("(1)"); + else if(comNb > 1) + sComButText = tr("Comments ").append("(%1)").arg(comNb); + + ui->commentButton->setText(sComButText); +} + +void BoardPostDisplayWidget::makeDownVote() +{ + RsGxsGrpMsgIdPair msgId; + msgId.first = mPost.mMeta.mGroupId; + msgId.second = mPost.mMeta.mMsgId; + + ui->voteUpButton->setEnabled(false); + ui->voteDownButton->setEnabled(false); + + emit vote(msgId, false); +} + +void BoardPostDisplayWidget::makeUpVote() +{ + RsGxsGrpMsgIdPair msgId; + msgId.first = mPost.mMeta.mGroupId; + msgId.second = mPost.mMeta.mMsgId; + + ui->voteUpButton->setEnabled(false); + ui->voteDownButton->setEnabled(false); + + emit vote(msgId, true); +} + +void BoardPostDisplayWidget::setReadStatus(bool isNew, bool isUnread) +{ + if (isUnread) + { + ui->readButton->setChecked(true); + ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); + } + else + { + ui->readButton->setChecked(false); + ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png")); + } + + ui->newLabel->setVisible(isNew); + + ui->mainFrame->setProperty("new", isNew); + ui->mainFrame->style()->unpolish(ui->mainFrame); + ui->mainFrame->style()->polish( ui->mainFrame); +} + +void BoardPostDisplayWidget::setComment(const RsGxsComment& cmt) {} + +BoardPostDisplayWidget::~BoardPostDisplayWidget() +{ + delete(ui); +} + +void BoardPostDisplayWidget::setup() +{ + setAttribute(Qt::WA_DeleteOnClose, true); + + /* clear ui */ + ui->titleLabel->setText(tr("Loading")); + ui->dateLabel->clear(); + ui->fromLabel->clear(); + ui->siteLabel->clear(); + + connect(ui->commentButton, SIGNAL( clicked()), this, SLOT(loadComments())); + connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); + connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote())); + connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); + + QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); + connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink())); + + QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); + connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople())); + + int S = QFontMetricsF(font()).height() ; + + ui->voteUpButton->setIconSize(QSize(S*1.5,S*1.5)); + ui->voteDownButton->setIconSize(QSize(S*1.5,S*1.5)); + ui->commentButton->setIconSize(QSize(S*1.5,S*1.5)); + ui->readButton->setIconSize(QSize(S*1.5,S*1.5)); + ui->shareButton->setIconSize(QSize(S*1.5,S*1.5)); + + QMenu *menu = new QMenu(); + menu->addAction(CopyLinkAction); + menu->addSeparator(); + menu->addAction(showInPeopleAct); + ui->shareButton->setMenu(menu); + + ui->clearButton->hide(); + ui->readAndClearButton->hide(); +} + + + +void BoardPostDisplayWidget::fill() +{ + RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); + bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); + + if(redacted) { + ui->commentButton->setDisabled(true); + ui->voteUpButton->setDisabled(true); + ui->voteDownButton->setDisabled(true); + ui->picture_frame->hide(); + ui->fromLabel->setId(mPost.mMeta.mAuthorId); + ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; + QDateTime qtime; + qtime.setTime_t(mPost.mMeta.mPublishTs); + QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); + ui->dateLabel->setText(timestamp); + } else { + + QPixmap sqpixmap2 = FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png"); + + int desired_height = 1.5*(ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height()); + int desired_width = sqpixmap2.width()*desired_height/(float)sqpixmap2.height(); + + QDateTime qtime; + qtime.setTime_t(mPost.mMeta.mPublishTs); + QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); + QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); + ui->dateLabel->setText(timestamp2); + ui->dateLabel->setToolTip(timestamp); + + ui->fromLabel->setId(mPost.mMeta.mAuthorId); + + // Use QUrl to check/parse our URL + // The only combination that seems to work: load as EncodedUrl, extract toEncoded(). + QByteArray urlarray(mPost.mLink.c_str()); + QUrl url = QUrl::fromEncoded(urlarray.trimmed()); + QString urlstr = "Invalid Link"; + QString sitestr = "Invalid Link"; + + bool urlOkay = url.isValid(); + if (urlOkay) + { + QString scheme = url.scheme(); + if ((scheme != "https") + && (scheme != "http") + && (scheme != "ftp") + && (scheme != "retroshare")) + { + urlOkay = false; + sitestr = "Invalid Link Scheme"; + } + } + + if (urlOkay) + { + urlstr = QString(" "); + urlstr += QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); + urlstr += QString(" "); + + QString siteurl = url.toEncoded(); + sitestr = QString(" %2 ").arg(siteurl).arg(siteurl); + + ui->titleLabel->setText(urlstr); + } + else + ui->titleLabel->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) ); + + if (urlarray.isEmpty()) + { + ui->siteLabel->hide(); + } + + ui->siteLabel->setText(sitestr); + + if(mPost.mImage.mData != NULL) + { + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + // Wiping data - as its been passed to thumbnail. + + QPixmap scaledpixmap; + if(pixmap.width() > 800){ + QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); + ui->pictureLabel->setPixmap(scaledpixmap); + }else{ + ui->pictureLabel->setPixmap(pixmap); + } + } + else if (mPost.mImage.mData == NULL) + { + ui->picture_frame->hide(); + } + else + { + ui->picture_frame->show(); + } + } + + //QString score = "Hot" + QString::number(post.mHotScore); + //score += " Top" + QString::number(post.mTopScore); + //score += " New" + QString::number(post.mNewScore); + + QString score = QString::number(mPost.mTopScore); + + ui->scoreLabel->setText(score); + + // FIX THIS UP LATER. + ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + + QTextDocument doc; + doc.setHtml(ui->notes->text()); + + if(doc.toPlainText().trimmed().isEmpty()) + ui->notes->hide(); + +#ifdef TO_REMOVE + // differences between Feed or Top of Comment. + if (mFeedHolder) + { + // feed. + //frame_comment->show(); + ui->commentButton->show(); + + if (mPost.mComments) + { + QString commentText = QString::number(mPost.mComments); + commentText += " "; + commentText += tr("Comments"); + ui->commentButton->setText(commentText); + } + else + { + ui->commentButton->setText(tr("Comment")); + } + + setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); + } + else +#endif + { + // no feed. + //frame_comment->hide(); + ui->commentButton->hide(); + + ui->readButton->hide(); + ui->newLabel->hide(); + } + +#ifdef TO_REMOVE + if (mIsHome) + { + ui->clearButton->hide(); + ui->readAndClearButton->hide(); + } + else +#endif + { + ui->clearButton->show(); + ui->readAndClearButton->show(); + } + + // disable voting buttons - if they have already voted. + if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) + { + ui->voteUpButton->setEnabled(false); + ui->voteDownButton->setEnabled(false); + } + +#if 0 + uint32_t up, down, nComments; + + bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments); + + if(ok) + { + int32_t vote = up - down; + scoreLabel->setText(QString::number(vote)); + + numCommentsLabel->setText("

# Comments: " + + QString::number(nComments) + "

"); + } + + mInFill = false; +#endif + +#ifdef TODO + emit sizeChanged(this); +#endif +} + +void BoardPostDisplayWidget::toggleNotes() {} diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h new file mode 100644 index 000000000..8a165dc76 --- /dev/null +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -0,0 +1,65 @@ +/******************************************************************************* + * retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h * + * * + * Copyright (C) 2019 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#pragma once + +#include +#include + +#include + +namespace Ui { +class BoardPostDisplayWidget; +} + +class RsPostedPost; + +class BoardPostDisplayWidget : public QWidget +{ + Q_OBJECT + +public: + BoardPostDisplayWidget(const RsPostedPost& post,QWidget *parent=nullptr); + virtual ~BoardPostDisplayWidget(); + + static const char *DEFAULT_BOARD_IMAGE; +protected: + /* GxsGroupFeedItem */ + + void setup() ; + void fill() ; + void doExpand(bool open) {} + void setComment(const RsGxsComment&) ; + void setReadStatus(bool isNew, bool isUnread) ; + void toggle() {} + void setCommentsSize(int comNb) ; + void makeUpVote() ; + void makeDownVote() ; + void toggleNotes() ; + +signals: + void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); + +private: + /** Qt Designer generated object */ + Ui::BoardPostDisplayWidget *ui; + + RsPostedPost mPost; +}; diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui new file mode 100644 index 000000000..91b0d8ed4 --- /dev/null +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -0,0 +1,526 @@ + + + BoardPostDisplayWidget + + + + 0 + 0 + 614 + 182 + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + false + + + QFrame::Box + + + QFrame::Sunken + + + + 0 + + + 0 + + + 0 + + + 2 + + + 0 + + + 6 + + + + + + 0 + 0 + + + + + Arial + 10 + 75 + true + + + + This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + site + + + true + + + + + + + 5 + + + 0 + + + 6 + + + + + + 0 + 0 + + + + + 50 + false + + + + Posted by + + + + + + + + 0 + 0 + + + + Signed by + + + true + + + + + + + + 0 + 0 + + + + You eyes only + + + true + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + + :/images/message-state-unread.png:/images/message-state-unread.png + + + true + + + false + + + true + + + + + + + New + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 70 + 20 + + + + + + + + + + + 37 + 0 + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + + 0 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + 0 + 0 + + + + Vote up + + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true + + + + + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 5 + + + + + + + + + + + + + Comments + + + + :/images/comments.png:/images/comments.png + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + + + + + Qt::Horizontal + + + + 308 + 20 + + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Set as read and remove item + + + + :/icons/png/correct.png:/icons/png/correct.png + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Remove Item + + + + :/icons/png/exit2.png:/icons/png/exit2.png + + + + + + + + + + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + PictureLabel + + + true + + + + + + + Qt::Horizontal + + + + 268 + 17 + + + + + + + + + + + + + + + GxsIdLabel + QLabel +
gui/gxs/GxsIdLabel.h
+
+ + StyledLabel + QLabel +
gui/common/StyledLabel.h
+
+
+ + + + + + +
diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 8d4208db3..84a9a95c9 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -106,7 +106,7 @@ protected: #endif /* GxsMessageFrameWidget */ - virtual void setAllMessagesReadDo(bool read, uint32_t &token); + virtual void setAllMessagesReadDo(bool read, uint32_t &token) override; private slots: void updateGroupData(); @@ -114,15 +114,10 @@ private slots: void subscribeGroup(bool subscribe); void setViewMode(int viewMode); void settingsChanged(); - void handlePostsTreeSizeChange(QSize s); void postChannelPostLoad(); void postContextMenu(const QPoint&); void copyMessageLink(); -public slots: - void sortColumnFiles(int col,Qt::SortOrder so); - void sortColumnPostFiles(int col,Qt::SortOrder so); - private: void processSettings(bool load); int viewMode(); diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index 7bb8094dd..403ce50be 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -41,7 +41,7 @@ Q_DECLARE_METATYPE(RsPostedPost) std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere RsPostedPostsModel::RsPostedPostsModel(QObject *parent) - : QAbstractItemModel(parent), mTreeMode(TREE_MODE_PLAIN), mColumns(6) + : QAbstractItemModel(parent), mTreeMode(TREE_MODE_PLAIN) { initEmptyHierarchy(); @@ -86,7 +86,7 @@ void RsPostedPostsModel::handleEvent_main_thread(std::shared_ptr if(!rsPosted->getBoardContent(mPostedGroup.mMeta.mGroupId,std::set{ e->mPostedMsgId }, posts,comments,votes)) { - std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel message data for channel/msg " << e->mChannelGroupId << "/" << e->mChannelMsgId << std::endl; + std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel message data for channel/msg " << e->mPostedGroupId << "/" << e->mPostedMsgId << std::endl; return; } @@ -103,7 +103,7 @@ void RsPostedPostsModel::handleEvent_main_thread(std::shared_ptr { mPosts[j] = posts[i]; - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),mColumns-1,(void*)NULL)); + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL)); } } },this); @@ -133,7 +133,7 @@ void RsPostedPostsModel::postMods() { endResetModel(); - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),mColumns-1,(void*)NULL)); + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL)); } void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count) @@ -488,7 +488,7 @@ void RsPostedPostsModel::update_posts(const RsGxsGroupId& group_id) std::vector *comments = new std::vector(); std::vector *votes = new std::vector(); - if(!rsPosted->getBoardContent(group_id, *posts,*comments,*votes)) + if(!rsPosted->getBoardAllContent(group_id, *posts,*comments,*votes)) { std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel messages for channel " << group_id << std::endl; return; @@ -519,6 +519,7 @@ static bool decreasing_time_comp(const std::pair& e1,cons void RsPostedPostsModel::createPostsArray(std::vector& posts) { +#ifdef TODO // Collect new versions of posts if any. For now Boards do not have versions, but if that ever happens, we'll be handlign it already. This code // is a blind copy of the channel code. @@ -613,6 +614,7 @@ void RsPostedPostsModel::createPostsArray(std::vector& posts) } } } +#endif #ifdef DEBUG_CHANNEL_MODEL std::cerr << "Now adding " << posts.size() << " posts into array structure..." << std::endl; @@ -665,21 +667,23 @@ QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) con { // First look into msg versions, in case the msg is a version of an existing message +#ifdef TODO for(auto& msg_id:mPosts[mFilteredPosts[i]].mOlderVersions) if(msg_id == postId) { quintptr ref ; convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab - return createIndex(i/mColumns,i%mColumns, ref); + return createIndex(i,0, ref); } +#endif if(mPosts[mFilteredPosts[i]].mMeta.mMsgId == postId) { quintptr ref ; convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab - return createIndex(i/mColumns,i%mColumns, ref); + return createIndex(i,0, ref); } } diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.h b/retroshare-gui/src/gui/Posted/PostedPostsModel.h index f4ddc34f8..8491262fe 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.h +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.h @@ -158,7 +158,7 @@ public: void debug_dump(); signals: - void boardlPostsLoaded(); // emitted after the posts have been loaded. + void boardPostsLoaded(); // emitted after the posts have been loaded. private: RsPostedGroup mPostedGroup; diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index bd3aec4f8..cc2695781 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1370,6 +1370,7 @@ posted { HEADERS += gui/Posted/PostedDialog.h \ gui/Posted/PostedListWidgetWithModel.h \ gui/Posted/PostedPostsModel.h \ + gui/Posted/BoardPostDisplayWidget.h \ gui/Posted/PostedItem.h \ gui/Posted/PostedCardView.h \ gui/Posted/PostedGroupDialog.h \ @@ -1383,6 +1384,7 @@ posted { FORMS += gui/Posted/PostedListWidgetWithModel.ui \ gui/feeds/PostedGroupItem.ui \ + gui/Posted/BoardPostDisplayWidget.ui \ gui/Posted/PostedItem.ui \ gui/Posted/PostedCardView.ui \ gui/Posted/PostedCreatePostDialog.ui \ @@ -1393,6 +1395,7 @@ posted { SOURCES += gui/Posted/PostedDialog.cpp \ gui/Posted/PostedListWidgetWithModel.cpp \ + gui/Posted/BoardPostDisplayWidget.cpp \ gui/Posted/PostedPostsModel.cpp \ gui/feeds/PostedGroupItem.cpp \ gui/Posted/PostedItem.cpp \ From b453f80cbd31f313cb96f42c5fec2e713c393cbf Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 4 Jul 2020 15:58:16 +0200 Subject: [PATCH 04/78] display content in post widgets. Sizes still to fix up --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 25 +- .../src/gui/Posted/BoardPostDisplayWidget.ui | 839 ++++++-------- .../gui/Posted/PostedListWidgetWithModel.h | 10 +- .../gui/Posted/PostedListWidgetWithModel.ui | 1007 ++++++++--------- .../GxsChannelPostsWidgetWithModel.ui | 2 +- 5 files changed, 877 insertions(+), 1006 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 772b193a2..093459746 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -47,6 +47,9 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,QWidget : QWidget(parent),ui(new Ui::BoardPostDisplayWidget()),mPost(post) { ui->setupUi(this); + + setup(); + fill(); } void BoardPostDisplayWidget::setCommentsSize(int comNb) @@ -99,9 +102,9 @@ void BoardPostDisplayWidget::setReadStatus(bool isNew, bool isUnread) ui->newLabel->setVisible(isNew); - ui->mainFrame->setProperty("new", isNew); - ui->mainFrame->style()->unpolish(ui->mainFrame); - ui->mainFrame->style()->polish( ui->mainFrame); +// ui->mainFrame->setProperty("new", isNew); +// ui->mainFrame->style()->unpolish(ui->mainFrame); +// ui->mainFrame->style()->polish( ui->mainFrame); } void BoardPostDisplayWidget::setComment(const RsGxsComment& cmt) {} @@ -150,8 +153,6 @@ void BoardPostDisplayWidget::setup() ui->readAndClearButton->hide(); } - - void BoardPostDisplayWidget::fill() { RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); @@ -161,7 +162,7 @@ void BoardPostDisplayWidget::fill() ui->commentButton->setDisabled(true); ui->voteUpButton->setDisabled(true); ui->voteDownButton->setDisabled(true); - ui->picture_frame->hide(); +// ui->picture_frame->hide(); ui->fromLabel->setId(mPost.mMeta.mAuthorId); ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; QDateTime qtime; @@ -243,13 +244,9 @@ void BoardPostDisplayWidget::fill() } } else if (mPost.mImage.mData == NULL) - { - ui->picture_frame->hide(); - } + ui->pictureLabel->hide(); else - { - ui->picture_frame->show(); - } + ui->pictureLabel->show(); } //QString score = "Hot" + QString::number(post.mHotScore); @@ -263,10 +260,8 @@ void BoardPostDisplayWidget::fill() // FIX THIS UP LATER. ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); - QTextDocument doc; - doc.setHtml(ui->notes->text()); - if(doc.toPlainText().trimmed().isEmpty()) + if( ui->notes->document()==nullptr || ui->notes->document()->toPlainText().trimmed().isEmpty()) ui->notes->hide(); #ifdef TO_REMOVE diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index 91b0d8ed4..0d59d03f3 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -6,502 +6,383 @@ 0 0 - 614 - 182 + 747 + 366 + + + 0 + 0 + + - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - false - - - QFrame::Box - - - QFrame::Sunken - - - - 0 - - - 0 - - - 0 - - - 2 - - - 0 - - - 6 - - - - - - 0 - 0 - - - - - Arial - 10 - 75 - true - - - - This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 0 - 0 - - - - site - - - true - - - - - - - 5 - - - 0 - - - 6 - - - - - - 0 - 0 - - - - - 50 - false - - - - Posted by - - - - - - - - 0 - 0 - - - - Signed by - - - true - - - - - - - - 0 - 0 - - - - You eyes only - - - true - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Toggle Message Read Status - - - - :/images/message-state-unread.png:/images/message-state-unread.png - - - true - - - false - - - true - - - - - - - New - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 70 - 20 - - - - - - - - - - - 37 - 0 - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 + + + + + + + + 0 + 0 + + + + Vote up + + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true + + + + + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + + + + + + + + 5 + + + 0 + + + 6 + + + + + + 0 + 0 + - - 3 + + + 50 + false + - - 3 + + Posted by - - 3 + + + + + + + 0 + 0 + - - 3 + + Signed by - - - - - 0 - 0 - - - - Vote up - - - - - - - :/images/up-arrow.png:/images/up-arrow.png - - - true - - - - - - - - 9 - - - - 0 - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Vote down - - - - - - \/ - - - - :/images/down-arrow.png:/images/down-arrow.png - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 5 - - - - - - - - - - - - - Comments - - - - :/images/comments.png:/images/comments.png - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Share - - - - :/images/share.png:/images/share.png - - - true - - - - - - - Qt::Horizontal - - - - 308 - 20 - - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Set as read and remove item - - - - :/icons/png/correct.png:/icons/png/correct.png - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Remove Item - - - - :/icons/png/exit2.png:/icons/png/exit2.png - - - - - - - - - - - - true - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 0 + + true - - 0 + + + + + + + 0 + 0 + - - 0 + + You eyes only - - 0 + + true - - - - PictureLabel - - - true - - - - - - - Qt::Horizontal - - - - 268 - 17 - - - - - - - - - + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + + :/images/message-state-unread.png:/images/message-state-unread.png + + + true + + + false + + + true + + + + + + + New + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 70 + 20 + + + + + + + + + + + 0 + 0 + + + + + Arial + 10 + 75 + true + + + + This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + site + + + true + + + + + + + + + PictureLabel + + + true + + + + + + + Qt::Horizontal + + + + 268 + 17 + + + + + + + + + + + + + + + Comments + + + + :/images/comments.png:/images/comments.png + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + + + + + Qt::Horizontal + + + + 308 + 20 + + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Set as read and remove item + + + + :/icons/png/correct.png:/icons/png/correct.png + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Remove Item + + + + :/icons/png/exit2.png:/icons/png/exit2.png + + + + + + diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 84a9a95c9..f8b41bede 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -43,7 +43,7 @@ class PostedPostDelegate: public QAbstractItemDelegate Q_OBJECT public: - PostedPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){} + PostedPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100){} virtual ~PostedPostDelegate(){} void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; @@ -52,6 +52,11 @@ class PostedPostDelegate: public QAbstractItemDelegate QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; int cellSize(const QFont& font) const; + + void setCellWidth(int pix) { mCellWidthPix = pix; } + + private: + int mCellWidthPix; }; class PostedListWidgetWithModel: public GxsMessageFrameWidget @@ -118,6 +123,9 @@ private slots: void postContextMenu(const QPoint&); void copyMessageLink(); +public slots: + void handlePostsTreeSizeChange(QSize size); + private: void processSettings(bool load); int viewMode(); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 744ae6870..88cfc520b 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -6,532 +6,519 @@ 0 0 - 950 - 771 + 731 + 593 Form - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::StyledPanel + + + + + 1 - - QFrame::Raised - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - false - - - - - - Board Details - - - false - - - false - - - - 6 + + + Details + + + + + + false - - - - 0 - - - - - - 75 - true - - - - Popularity - - - - - - - - 75 - true - - - - 0 - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Posts - - - - - - - - 75 - true - - - - 0 - - - - - - - - 75 - true - - - - Created - - - - - - - unknown - - - - - - - - 75 - true - - - - Administrator: - - - - - - - unknown - - - true - - - - - - - - 75 - true - - - - Distribution: - - - - - - - unknown - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Last Post: - - - - - - - unknown - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - :/icons/png/postedlinks.png - - - true - - - - - - - - 14 - - - - TextLabel - - - - - - - - - Qt::Horizontal - - - - 421 - 114 - - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + + + + + Board Details + + + false + + + false + + + + 6 + + + + + 0 + + + + + + 75 + true + + + + Popularity + + + + + + + + 75 + true + + + + 0 + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Posts + + + + + + + + 75 + true + + + + 0 + + + + + + + + 75 + true + + + + Created + + + + + + + unknown + + + + + + + + 75 + true + + + + Administrator: + + + + + + + unknown + + + true + + + + + + + + 75 + true + + + + Distribution: + + + + + + + unknown + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Last Post: + + + + + + + unknown + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + :/icons/png/postedlinks.png + + + true + + + + + + + + 14 + + + + TextLabel + + + + + + + + + + 0 + 0 + + + + + 50 + false + false + + + + + + + Subscribe + + + false + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Description</span></p></body></html> - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - true - - - true - - - - - - - - - - - - - - - - QFrame::Box - - - QFrame::Sunken - - - - 6 - - - 2 - - - 6 - - - 2 - - - - - - 0 - 0 - - - - - 50 - false - false - - - - - - - Subscribe - - - false - - - - - - - - 0 - 0 - - - - Create Post - - - - :/images/write.png:/images/write.png - - - - 24 - 24 - - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - <html><head/><body><p><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol'; font-size:14px; color:#24292e; background-color:#ffffff;">Select sorting</span></p></body></html> - - - - - - - 24 - 24 - - - - - Hot + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + true + + + true + + + + + + + + + + + Posts + + + + + + QFrame::Box - - - :/icons/png/flame.png:/icons/png/flame.png + + QFrame::Sunken - - - - New + + + 6 + + + 2 + + + 6 + + + 2 + + + + + + 0 + 0 + + + + Create Post + + + + :/images/write.png:/images/write.png + + + + 24 + 24 + + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + <html><head/><body><p><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol'; font-size:14px; color:#24292e; background-color:#ffffff;">Select sorting</span></p></body></html> + + + + + + + 24 + 24 + + + + + Hot + + + + :/icons/png/flame.png:/icons/png/flame.png + + + + + New + + + + :/icons/png/new.png:/icons/png/new.png + + + + + Top + + + + :/icons/png/top.png:/icons/png/top.png + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + + + + true + + + + Classic view + + + + :/images/classic.png:/images/classic.png + + + + 24 + 24 + + + + true + + + true + + + + + + + Card View + + + + :/images/card.png:/images/card.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + + Previous + + + + + + + :/icons/png/arrow-left.png:/icons/png/arrow-left.png + + + + + + + 1-10 + + + + + + + Next + + + + + + + :/icons/png/arrow-right.png:/icons/png/arrow-right.png + + + + + + + <html><head/><body><p>Default identity used when voting</p></body></html> + + + + + + + + + + QAbstractItemView::CurrentChanged|QAbstractItemView::SelectedClicked - - - :/icons/png/new.png:/icons/png/new.png + + QAbstractItemView::ScrollPerPixel - - - - Top + + false - - - :/icons/png/top.png:/icons/png/top.png - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 0 - - - - - Classic view - - - - :/images/classic.png:/images/classic.png - - - - 24 - 24 - - - - true - - - true - - - - - - - Card View - - - - :/images/card.png:/images/card.png - - - - 24 - 24 - - - - true - - - true - - - - - - - - - Previous - - - - - - - :/icons/png/arrow-left.png:/icons/png/arrow-left.png - - - - - - - 1-10 - - - - - - - Next - - - - - - - :/icons/png/arrow-right.png:/icons/png/arrow-right.png - - - - - - - <html><head/><body><p>Default identity used when voting</p></body></html> - - - - + + false + + + + + diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index 1f51702a2..c14a1657b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -405,7 +405,7 @@ p, li { white-space: pre-wrap; } - 0 + 1 From 75cf9d6c86a7a2f570cafde87e2ac4d0eead4b57 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 4 Jul 2020 22:51:10 +0200 Subject: [PATCH 05/78] fixed scaling of items. --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 6 +- .../src/gui/Posted/BoardPostDisplayWidget.ui | 161 ++++++++++-------- 2 files changed, 98 insertions(+), 69 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 093459746..ac512a57d 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -260,8 +260,10 @@ void BoardPostDisplayWidget::fill() // FIX THIS UP LATER. ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); - - if( ui->notes->document()==nullptr || ui->notes->document()->toPlainText().trimmed().isEmpty()) + QTextDocument doc; + doc.setHtml(ui->notes->text()); + + if(doc.toPlainText().trimmed().isEmpty()) ui->notes->hide(); #ifdef TO_REMOVE diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index 0d59d03f3..900877531 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -7,7 +7,7 @@ 0 0 747 - 366 + 199 @@ -24,76 +24,93 @@ - + - - - - 0 - 0 - - - - Vote up - - - - - - - :/images/up-arrow.png:/images/up-arrow.png - - - true - - + + + + + + 0 + 0 + + + + Vote up + + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true + + + + + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + - - - - 9 - + + + Qt::Vertical - - 0 - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - + - 0 - 0 + 20 + 40 - - Vote down - - - - - - \/ - - - - :/images/down-arrow.png:/images/down-arrow.png - - - true - - + @@ -248,6 +265,19 @@ + + + + TextLabel + + + true + + + true + + + @@ -291,9 +321,6 @@ - - - From 7cec536904ded950087509cde579a8d24f08d415 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 4 Jul 2020 23:00:48 +0200 Subject: [PATCH 06/78] added edit mode --- .../src/gui/Posted/PostedPostsModel.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index 403ce50be..ad960b8ef 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -275,14 +275,6 @@ QModelIndex RsPostedPostsModel::parent(const QModelIndex& index) const return QModelIndex(); // there's no hierarchy here. So nothing to do! } -Qt::ItemFlags RsPostedPostsModel::flags(const QModelIndex& index) const -{ - if (!index.isValid()) - return 0; - - return QAbstractItemModel::flags(index); -} - quintptr RsPostedPostsModel::getChildRef(quintptr ref,int index) const { if (index < 0) @@ -433,6 +425,14 @@ bool operator<(const RsPostedPost& p1,const RsPostedPost& p2) return p1.mMeta.mPublishTs > p2.mMeta.mPublishTs; } +Qt::ItemFlags RsPostedPostsModel::flags(const QModelIndex& index) const +{ + if (!index.isValid()) + return 0; + + return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; +} + void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector& posts) { preMods(); From 6e3405d9819fb0aad7caec9250c33a3fe181b078 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 6 Jul 2020 22:29:36 +0200 Subject: [PATCH 07/78] improved display in boards --- retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h | 2 ++ retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui | 3 +++ 2 files changed, 5 insertions(+) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index f8b41bede..5d23708e4 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -56,6 +56,8 @@ class PostedPostDelegate: public QAbstractItemDelegate void setCellWidth(int pix) { mCellWidthPix = pix; } private: + QSize cellSize(const QSize& w) const; + int mCellWidthPix; }; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 88cfc520b..62faa796c 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -509,6 +509,9 @@ p, li { white-space: pre-wrap; } QAbstractItemView::ScrollPerPixel + + 0 + false From 1fced473d8c043c52268a25668fa2a7997e19168 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 12 Jul 2020 15:22:31 +0200 Subject: [PATCH 08/78] fixed sorting --- .../gui/Posted/PostedListWidgetWithModel.h | 1 + .../gui/Posted/PostedListWidgetWithModel.ui | 2 +- .../src/gui/Posted/PostedPostsModel.cpp | 33 ++++++++++++++++--- .../src/gui/Posted/PostedPostsModel.h | 8 +++++ 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 5d23708e4..245fd2812 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -116,6 +116,7 @@ protected: virtual void setAllMessagesReadDo(bool read, uint32_t &token) override; private slots: + void updateSorting(int); void updateGroupData(); void createMsg(); void subscribeGroup(bool subscribe); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 62faa796c..5ae0ea3d2 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -343,7 +343,7 @@ p, li { white-space: pre-wrap; } - + <html><head/><body><p><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol'; font-size:14px; color:#24292e; background-color:#ffffff;">Select sorting</span></p></body></html> diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index ad960b8ef..b7e4226a6 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -420,10 +420,26 @@ void RsPostedPostsModel::clear() emit boardPostsLoaded(); } -bool operator<(const RsPostedPost& p1,const RsPostedPost& p2) +class PostSorter { - return p1.mMeta.mPublishTs > p2.mMeta.mPublishTs; -} +public: + + PostSorter(RsPostedPostsModel::SortingStrategy s) : mSortingStrategy(s) {} + + bool operator()(const RsPostedPost& p1,const RsPostedPost& p2) const + { + switch(mSortingStrategy) + { + default: + case RsPostedPostsModel::SORT_NEW_SCORE : return p1.mNewScore > p2.mNewScore; + case RsPostedPostsModel::SORT_TOP_SCORE : return p1.mTopScore > p2.mTopScore; + case RsPostedPostsModel::SORT_HOT_SCORE : return p1.mHotScore > p2.mHotScore; + } + } + +private: + RsPostedPostsModel::SortingStrategy mSortingStrategy; +}; Qt::ItemFlags RsPostedPostsModel::flags(const QModelIndex& index) const { @@ -433,6 +449,15 @@ Qt::ItemFlags RsPostedPostsModel::flags(const QModelIndex& index) const return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; } +void RsPostedPostsModel::setSortingStrategy(RsPostedPostsModel::SortingStrategy s) +{ + preMods(); + + std::sort(mPosts.begin(),mPosts.end(), PostSorter(s)); + + postMods(); +} + void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector& posts) { preMods(); @@ -445,7 +470,7 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector Date: Sun, 12 Jul 2020 18:02:44 +0200 Subject: [PATCH 09/78] added display of 10-posts chunks --- .../src/gui/Posted/PostedPostsModel.cpp | 41 ++++++++++++++++--- .../src/gui/Posted/PostedPostsModel.h | 38 +++++++++++++++-- 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index b7e4226a6..dbe5239f4 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -38,6 +38,8 @@ Q_DECLARE_METATYPE(RsMsgMetaData) Q_DECLARE_METATYPE(RsPostedPost) +const uint32_t RsPostedPostsModel::DEFAULT_DISPLAYED_NB_POSTS = 10; + std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere RsPostedPostsModel::RsPostedPostsModel(QObject *parent) @@ -121,6 +123,8 @@ void RsPostedPostsModel::initEmptyHierarchy() mPosts.clear(); mFilteredPosts.clear(); + mDisplayedNbPosts = DEFAULT_DISPLAYED_NB_POSTS; + mDisplayedStartIndex = 0; postMods(); } @@ -167,6 +171,9 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count) } count = mFilteredPosts.size(); + if(mDisplayedNbPosts > count) + mDisplayedNbPosts = count; + std::cerr << "After filtering: " << count << " posts remain." << std::endl; beginInsertRows(QModelIndex(),0,rowCount()-1); @@ -184,7 +191,7 @@ int RsPostedPostsModel::rowCount(const QModelIndex& parent) const return 0; if(!parent.isValid()) - return mFilteredPosts.size() ; + return mDisplayedNbPosts; RsErr() << __PRETTY_FUNCTION__ << " rowCount cannot figure out the porper number of rows." << std::endl; return 0; @@ -413,7 +420,6 @@ void RsPostedPostsModel::clear() { preMods(); - mPosts.clear(); initEmptyHierarchy(); postMods(); @@ -458,6 +464,27 @@ void RsPostedPostsModel::setSortingStrategy(RsPostedPostsModel::SortingStrategy postMods(); } +void RsPostedPostsModel::setPostsInterval(int start,int nb_posts) +{ + if(start >= mFilteredPosts.size()) + return; + + preMods(); + + uint32_t old_nb_rows = rowCount() ; + + mDisplayedNbPosts = (uint32_t)std::min(nb_posts,(int)mFilteredPosts.size() - (start+1)); + mDisplayedStartIndex = start; + + beginRemoveRows(QModelIndex(),mDisplayedNbPosts,old_nb_rows); + endRemoveRows(); + + beginInsertRows(QModelIndex(),old_nb_rows,mDisplayedNbPosts); + endInsertRows(); + + postMods(); +} + void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector& posts) { preMods(); @@ -470,11 +497,13 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector event); - std::vector mFilteredPosts; // stores the list of displayes indices due to filtering. - std::vector mPosts ; // store the list of posts updated from rsForums. + std::vector mPosts ; + std::vector mFilteredPosts; + uint32_t mDisplayedStartIndex; + uint32_t mDisplayedNbPosts; + RsEventsHandlerId_t mEventHandlerId ; }; From b7a9962400117730c8b24baf6a2d80868c6bf526 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 12 Jul 2020 20:17:32 +0200 Subject: [PATCH 10/78] fixed display 10-posts chunks --- .../src/gui/Posted/PostedListWidgetWithModel.h | 5 ++++- .../src/gui/Posted/PostedListWidgetWithModel.ui | 12 ++++++++++++ retroshare-gui/src/gui/Posted/PostedPostsModel.cpp | 12 +++++++----- retroshare-gui/src/gui/Posted/PostedPostsModel.h | 4 ++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 245fd2812..365504b30 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -122,9 +122,12 @@ private slots: void subscribeGroup(bool subscribe); void setViewMode(int viewMode); void settingsChanged(); - void postChannelPostLoad(); + void postPostLoad(); void postContextMenu(const QPoint&); void copyMessageLink(); + void next10Posts(); + void prev10Posts(); + void filterItems(QString s); public slots: void handlePostsTreeSizeChange(QSize size); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 5ae0ea3d2..a3c43aaa6 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -385,6 +385,13 @@ p, li { white-space: pre-wrap; } + + + + Search + + + @@ -542,6 +549,11 @@ p, li { white-space: pre-wrap; } QTreeView

gui/common/RSTreeView.h
+ + LineEditClear + QLineEdit +
gui/common/LineEditClear.h
+
GxsIdChooser QComboBox diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index dbe5239f4..baa7ed0d7 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -137,7 +137,7 @@ void RsPostedPostsModel::postMods() { endResetModel(); - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL)); + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL)); } void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count) @@ -171,8 +171,10 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count) } count = mFilteredPosts.size(); + mDisplayedStartIndex = 0; + if(mDisplayedNbPosts > count) - mDisplayedNbPosts = count; + mDisplayedNbPosts = count ; std::cerr << "After filtering: " << count << " posts remain." << std::endl; @@ -210,7 +212,7 @@ bool RsPostedPostsModel::getPostData(const QModelIndex& i,RsPostedPost& fmpe) co quintptr ref = i.internalId(); uint32_t entry = 0; - if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size()) + if(!convertRefPointerToTabEntry(ref,entry)) return false ; fmpe = mPosts[mFilteredPosts[entry]]; @@ -290,7 +292,7 @@ quintptr RsPostedPostsModel::getChildRef(quintptr ref,int index) const if(ref == quintptr(0)) { quintptr new_ref; - convertTabEntryToRefPointer(index,new_ref); + convertTabEntryToRefPointer(index+mDisplayedStartIndex,new_ref); return new_ref; } else @@ -717,7 +719,7 @@ QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) con RsGxsMessageId postId = mid; - for(uint32_t i=0;i Date: Sun, 12 Jul 2020 20:58:46 +0200 Subject: [PATCH 11/78] fixed search --- retroshare-gui/src/gui/Posted/PostedPostsModel.cpp | 4 +--- retroshare-gui/src/gui/Posted/PostedPostsModel.h | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index baa7ed0d7..5ca140091 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -172,9 +172,7 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count) count = mFilteredPosts.size(); mDisplayedStartIndex = 0; - - if(mDisplayedNbPosts > count) - mDisplayedNbPosts = count ; + mDisplayedNbPosts = std::min(count,DEFAULT_DISPLAYED_NB_POSTS) ; std::cerr << "After filtering: " << count << " posts remain." << std::endl; diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.h b/retroshare-gui/src/gui/Posted/PostedPostsModel.h index cabd420de..0aab99b01 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.h +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.h @@ -157,7 +157,8 @@ public: // Helper functions bool getPostData(const QModelIndex& i,RsPostedPost& fmpe) const ; - uint32_t postsCount() const { return mPosts.size() ; } + uint32_t totalPostsCount() const { return mPosts.size() ; } + uint32_t filteredPostsCount() const { return mFilteredPosts.size() ; } uint32_t displayedStartPostIndex() const { return mDisplayedStartIndex ; } void clear() ; From 07cfa25c439d8a10b1a9535af54b2e80cde9d1f4 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 1 Aug 2020 19:44:46 +0200 Subject: [PATCH 12/78] added missing file --- .../gui/Posted/PostedListWidgetWithModel.cpp | 998 ++++++++++++++++++ 1 file changed, 998 insertions(+) create mode 100644 retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp new file mode 100644 index 000000000..3df9a3d76 --- /dev/null +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -0,0 +1,998 @@ +/******************************************************************************* + * retroshare-gui/src/gui/gxschannels/PostedListWidgetWithModel.cpp * + * * + * Copyright 2013 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include +#include +#include + +#include "retroshare/rsgxscircles.h" + +#include "ui_PostedListWidgetWithModel.h" +#include "gui/feeds/GxsChannelPostItem.h" +#include "gui/gxs/GxsIdDetails.h" +#include "util/misc.h" +#include "gui/Posted/PostedCreatePostDialog.h" +#include "gui/common/UIStateHelper.h" +#include "gui/settings/rsharesettings.h" +#include "gui/feeds/SubFileItem.h" +#include "gui/notifyqt.h" +#include "gui/RetroShareLink.h" +#include "util/HandleRichText.h" +#include "util/DateTime.h" +#include "util/qtthreadsutils.h" +#include "gui/common/FilesDefs.h" + +#include "PostedListWidgetWithModel.h" +#include "PostedPostsModel.h" +#include "PostedCardView.h" +#include "BoardPostDisplayWidget.h" + +#include + +#define ROLE_PUBLISH FEED_TREEWIDGET_SORTROLE + +/**** + * #define DEBUG_POSTED + ***/ + +/* View mode */ +#define VIEW_MODE_FEEDS 1 +#define VIEW_MODE_FILES 2 + +// Determine the Shape and size of cells as a factor of the font height. An aspect ratio of 3/4 is what's needed +// for the image, so it's important that the height is a bit larger so as to leave some room for the text. +// +// +#define IMAGE_COPYLINK ":/images/copyrslink.png" + +// Delegate used to paint into the table of thumbnails + +void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const +{ + if((option.state & QStyle::State_Selected)) // Avoids double display. The selected widget is never exactly the size of the rendered one, + return; // so when selected, we only draw the selected one. + + // prepare + painter->save(); + painter->setClipRect(option.rect); + + RsPostedPost post = index.data(Qt::UserRole).value() ; + + painter->save(); + + painter->fillRect( option.rect, option.backgroundBrush); + painter->restore(); + + BoardPostDisplayWidget w(post); + w.setMaximumWidth(mCellWidthPix); + w.setMinimumWidth(mCellWidthPix); + w.adjustSize(); + + QPixmap pixmap(option.rect.size()); + + std::cerr << "pixmap.depth=" << pixmap.depth() << std::endl; + +#ifdef SUSPENDED_CODE + if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) + pixmap.fill(QRgb(0xff308dc7)); // I dont know how to grab the backgroud color for selected objects automatically. + else +#endif + pixmap.fill(QRgb(0x00f0f0f0)); // choose a fully transparent background + +#ifdef TESTING + { + QPainter W(&pixmap); + QLinearGradient m_gradient(0,0,pixmap.width(),0); + m_gradient.setColorAt(0.0, QRgb(0xff390e90)); + m_gradient.setColorAt(1.0, QRgb(0xff09feff)); + W.fillRect(pixmap.rect(), m_gradient); + + w.render(&W,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + } +#endif + + w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + +#ifdef TODO + if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) + { + QPainter p(&pixmap); + QFontMetricsF fm(option.font); + p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); + } +#endif + + // debug + if(index.row()==0 && index.column()==0) + { + QFile file("yourFile.png"); + file.open(QIODevice::WriteOnly); + pixmap.save(&file, "PNG"); + std::cerr << "Saved pxmap to png" << std::endl; + } + //std::cerr << "option.rect = " << option.rect.width() << "x" << option.rect.height() << ". fm.height()=" << QFontMetricsF(option.font).height() << std::endl; + + painter->save(); + + // Is this necessary? + // + // painter->setRenderHint( QPainter::Antialiasing,true); + // painter->setRenderHint( QPainter::TextAntialiasing,true); + // painter->setRenderHint( QPainter::SmoothPixmapTransform,true); + // painter->setRenderHint( QPainter::HighQualityAntialiasing,true); + + painter->drawPixmap(option.rect.topLeft(), pixmap /*,.scaled(option.rect.width(),option.rect.width()*w.height()/(float)w.width(),Qt::KeepAspectRatio,Qt::SmoothTransformation)*/); + painter->restore(); +} + +QSize PostedPostDelegate::cellSize(const QSize& w) const +{ + return QSize(mCellWidthPix,0 + w.height() * mCellWidthPix/(float)w.width()); +} + +QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const +{ + // This is the only place where we actually set the size of cells + + RsPostedPost post = index.data(Qt::UserRole).value() ; + + BoardPostDisplayWidget w(post); + w.setMinimumWidth(mCellWidthPix); + w.setMaximumWidth(mCellWidthPix); + w.adjustSize(); + + QSize ss = cellSize(w.size()) + QSize(0,5); + + std::cerr << "w =" << w.width() << " x " << w.height() << " new size = " << ss.width() << " x " << ss.height() << std::endl; + + return ss; +} + +QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const +{ + RsPostedPost post = index.data(Qt::UserRole).value() ; + + if(index.column() == RsPostedPostsModel::COLUMN_POSTS) + { + QWidget *w = new BoardPostDisplayWidget(post,parent); + w->setMinimumWidth(mCellWidthPix); + w->setMaximumWidth(mCellWidthPix); + w->adjustSize(); + return w; + } + else + return NULL; +} +void PostedPostDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const +{ + editor->setGeometry(option.rect); +} + +/** Constructor */ +PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedId, QWidget *parent) : + GxsMessageFrameWidget(rsPosted, parent), + ui(new Ui::PostedListWidgetWithModel) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui->setupUi(this); + + ui->postsTree->setModel(mPostedPostsModel = new RsPostedPostsModel()); + ui->postsTree->setItemDelegate(mPostedPostsDelegate = new PostedPostDelegate()); + ui->postsTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // prevents bug on w10, since row size depends on widget width + ui->postsTree->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);// more beautiful if we scroll at pixel level + ui->postsTree->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + ui->postsTree->setPlaceholderText(tr("No files in this post, or no post selected")); + ui->postsTree->setSortingEnabled(true); + ui->postsTree->sortByColumn(0, Qt::AscendingOrder); + ui->postsTree->setAutoSelect(true); + + connect(ui->sortStrategy_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(updateSorting(int))); + connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(next10Posts())); + connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts())); + + //connect(ui->channelPostFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnPostFiles(int,Qt::SortOrder))); + //connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder))); + + connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&))); + + connect(mPostedPostsModel,SIGNAL(boardPostsLoaded()),this,SLOT(postPostLoad())); + + QFontMetricsF fm(font()); + + /* Setup UI helper */ + + /* Connect signals */ + connect(ui->submitPostButton, SIGNAL(clicked()), this, SLOT(createMsg())); + connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool))); + connect(ui->filter_LE, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); + connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()),this, SLOT(settingsChanged())); + + /* add filter actions */ + ui->postsTree->setPlaceholderText(tr("Thumbnails")); + //ui->postsTree->setMinimumWidth(COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font()).height()+1); + + connect(ui->postsTree,SIGNAL(sizeChanged(QSize)),this,SLOT(handlePostsTreeSizeChange(QSize))); + + /* load settings */ + processSettings(true); + + /* Initialize subscribe button */ + QIcon icon; + icon.addPixmap(QPixmap(":/images/redled.png"), QIcon::Normal, QIcon::On); + icon.addPixmap(QPixmap(":/images/start.png"), QIcon::Normal, QIcon::Off); + + // ui->commentsDialog->setTokenService(rsPosted->getTokenService(),rsPosted); + + /* Initialize GUI */ + // setAutoDownload(false); + + settingsChanged(); + setGroupId(postedId); + + mPostedPostsModel->updateBoard(postedId); + + mEventHandlerId = 0; + // Needs to be asynced because this function is called by another thread! + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); + }, mEventHandlerId, RsEventType::GXS_POSTED ); +} + +void PostedListWidgetWithModel::updateSorting(int s) +{ + switch(s) + { + default: + case 0: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_HOT_SCORE); break; + case 1: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_NEW_SCORE); break; + case 2: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_TOP_SCORE); break; + } +} + +void PostedListWidgetWithModel::handlePostsTreeSizeChange(QSize size) +{ + mPostedPostsDelegate->setCellWidth(size.width()); +} + +void PostedListWidgetWithModel::filterItems(QString text) +{ + QStringList lst = text.split(" ",QString::SkipEmptyParts) ; + + uint32_t count; + mPostedPostsModel->setFilter(lst,count) ; + + ui->showLabel->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+10+1))); +} + +void PostedListWidgetWithModel::next10Posts() +{ + if(mPostedPostsModel->displayedStartPostIndex() + 10 < mPostedPostsModel->filteredPostsCount()) + { + mPostedPostsModel->setPostsInterval(10+mPostedPostsModel->displayedStartPostIndex(),10); + ui->showLabel->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+10+1))); + } +} + +void PostedListWidgetWithModel::prev10Posts() +{ + if((int)mPostedPostsModel->displayedStartPostIndex() - 10 >= 0) + { + mPostedPostsModel->setPostsInterval(mPostedPostsModel->displayedStartPostIndex()-10,10); + ui->showLabel->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+10+1))); + } +} + +void PostedListWidgetWithModel::postContextMenu(const QPoint&) +{ + QMenu menu(this); + + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink())); + + if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) + menu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_16.png"), tr("Edit"), this, SLOT(editPost())); + + menu.exec(QCursor::pos()); +} + +void PostedListWidgetWithModel::copyMessageLink() +{ + try + { + if (groupId().isNull()) + throw std::runtime_error("No channel currently selected!"); + + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + + if(!index.isValid()) + throw std::runtime_error("No post under mouse!"); + + RsPostedPost post = index.data(Qt::UserRole).value() ; + + if(post.mMeta.mMsgId.isNull()) + throw std::runtime_error("Post has empty MsgId!"); + + RetroShareLink link = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_POSTED, groupId(), post.mMeta.mMsgId, QString::fromUtf8(post.mMeta.mMsgName.c_str())); + + if (!link.valid()) + throw std::runtime_error("Link is not valid"); + + QList urls; + urls.push_back(link); + RSLinkClipboard::copyLinks(urls); + } + catch(std::exception& e) + { + QMessageBox::critical(NULL,tr("Link creation error"),tr("Link could not be created: ")+e.what()); + } +} + +#ifdef TODO +void PostedListWidgetWithModel::editPost() +{ + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + RsPostedPost post = index.data(Qt::UserRole).value() ; + + CreatePostedMsg *msgDialog = new CreatePostedMsg(post.mMeta.mGroupId,post.mMeta.mMsgId); + msgDialog->show(); +} +#endif + +void PostedListWidgetWithModel::handleEvent_main_thread(std::shared_ptr event) +{ + const RsGxsPostedEvent *e = dynamic_cast(event.get()); + + if(!e) + return; + + switch(e->mPostedEventCode) + { + case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]]; + case RsPostedEventCode::UPDATED_POSTED_GROUP: // [[fallthrough]]; + case RsPostedEventCode::NEW_MESSAGE: // [[fallthrough]]; + case RsPostedEventCode::UPDATED_MESSAGE: + { + if(e->mPostedGroupId == groupId()) + updateDisplay(true); + } + + default: + break; + } +} + +#ifdef TO_REMOVE +void PostedListWidgetWithModel::showPostDetails() +{ + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + RsPostedPost post = index.data(Qt::UserRole).value() ; + + QTextDocument doc; + doc.setHtml(post.mMsg.c_str()); + + if(post.mMeta.mPublishTs == 0) + { + ui->postDetails_TE->clear(); + ui->postLogo_LB->hide(); + ui->postName_LB->hide(); + ui->postTime_LB->hide(); + mChannelPostFilesModel->clear(); + + return; + } + + ui->postLogo_LB->show(); + ui->postName_LB->show(); + ui->postTime_LB->show(); + + if(index.row()==0 && index.column()==0) + std::cerr << "here" << std::endl; + + std::cerr << "showPostDetails: setting mSelectedPost to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mSelectedPost << std::endl; + mSelectedPost = post.mMeta.mMsgId; + + std::list files; + for(auto& file:post.mFiles) + files.push_back(ChannelPostFileInfo(file,post.mMeta.mPublishTs)); + + mChannelPostFilesModel->setFiles(files); + + auto all_msgs_versions(post.mOlderVersions); + all_msgs_versions.insert(post.mMeta.mMsgId); + + ui->commentsDialog->commentLoad(post.mMeta.mGroupId, all_msgs_versions, post.mMeta.mMsgId); + + std::cerr << "Showing details about selected index : "<< index.row() << "," << index.column() << std::endl; + + ui->postDetails_TE->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + + QPixmap postImage; + + if (post.mThumbnail.mData != NULL) + GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData, post.mThumbnail.mSize, postImage,GxsIdDetails::ORIGINAL); + else + postImage = FilesDefs::getPixmapFromQtResourcePath(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE); + + int W = QFontMetricsF(font()).height() * 8; + + // Using fixed width so that the post will not displace the text when we browse. + + ui->postLogo_LB->setPixmap(postImage); + ui->postLogo_LB->setFixedSize(W,postImage.height()/(float)postImage.width()*W); + + ui->postName_LB->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())); + ui->postName_LB->setFixedWidth(W); + ui->postTime_LB->setText(QDateTime::fromMSecsSinceEpoch(post.mMeta.mPublishTs*1000).toString("MM/dd/yyyy, hh:mm")); + ui->postTime_LB->setFixedWidth(W); + + //ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE); + //ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE); + ui->channelPostFiles_TV->setAutoSelect(true); + + // Now also set the post as read + + if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) + { + RsGxsGrpMsgIdPair postId; + postId.second = post.mMeta.mMsgId; + postId.first = post.mMeta.mGroupId; + + RsThread::async([postId]() { rsGxsChannels->markRead(postId, true) ; } ); + } +} +#endif + +void PostedListWidgetWithModel::updateGroupData() +{ + if(groupId().isNull()) + return; + + RsThread::async([this]() + { + std::vector groups; + + if(!rsPosted->getBoardsInfo(std::list{ groupId() }, groups)) + { + std::cerr << __PRETTY_FUNCTION__ << " failed to get boards group value for group: " << groupId() << std::endl; + return; + } + + if(groups.size() != 1) + { + RsErr() << __PRETTY_FUNCTION__ << " cannot retrieve posted group data for group ID " << groupId() << ": ERROR." << std::endl; + return; + } + + RsQThreadUtils::postToObject( [this,groups]() + { + mGroup = groups[0]; + mPostedPostsModel->updateBoard(groupId()); + + insertBoardDetails(mGroup); + + emit groupDataLoaded(); + emit groupChanged(this); // signals the parent widget to e.g. update the group tab name + } ); + }); +} + +void PostedListWidgetWithModel::postPostLoad() +{ + std::cerr << "Post channel load..." << std::endl; + + if(!mSelectedPost.isNull()) + { + QModelIndex index = mPostedPostsModel->getIndexOfMessage(mSelectedPost); + + std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post " + << mSelectedPost.toStdString() << std::endl; + + ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect); + ui->postsTree->scrollTo(index);//May change if model reloaded + ui->postsTree->setFocus(); + } + else + std::cerr << "No pre-selected channel post." << std::endl; + + whileBlocking(ui->showLabel)->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+10+1))); + whileBlocking(ui->filter_LE)->setText(QString()); +} + +void PostedListWidgetWithModel::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. + { + updateGroupData(); + + return; + } +} +PostedListWidgetWithModel::~PostedListWidgetWithModel() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); + // save settings + processSettings(false); + + delete ui; +} + +void PostedListWidgetWithModel::processSettings(bool load) +{ + Settings->beginGroup(QString("ChannelPostsWidget")); + + if (load) + { + } + else + { + } + + Settings->endGroup(); +} + +void PostedListWidgetWithModel::settingsChanged() +{ +} + +QString PostedListWidgetWithModel::groupName(bool) +{ + return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str()); +} + +void PostedListWidgetWithModel::groupNameChanged(const QString &name) +{ +} + +QIcon PostedListWidgetWithModel::groupIcon() +{ + /* CHANNEL IMAGE */ + QPixmap postedImage; + if (mGroup.mGroupImage.mData != NULL) + GxsIdDetails::loadPixmapFromData(mGroup.mGroupImage.mData, mGroup.mGroupImage.mSize, postedImage,GxsIdDetails::ORIGINAL); + else + postedImage = FilesDefs::getPixmapFromQtResourcePath(BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE); + + return QIcon(postedImage); +} + +void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token) +{ + std::cerr << __PRETTY_FUNCTION__ << ": not implemented" << std::endl; +} + +void PostedListWidgetWithModel::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const QVector& msg_versions,const RsGxsMessageId &msgId, const QString &title) +{ + emit loadComment(groupId, msg_versions,msgId, title); +} + +void PostedListWidgetWithModel::createMsg() +{ + if (groupId().isNull()) { + return; + } + + if (!IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { + return; + } + + PostedCreatePostDialog *msgDialog = new PostedCreatePostDialog(rsPosted,groupId()); + msgDialog->show(); + + /* window will destroy itself! */ +} + +void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) +{ + // save selection if needed + + /* IMAGE */ + QPixmap chanImage; + if (group.mGroupImage.mData != NULL) { + GxsIdDetails::loadPixmapFromData(group.mGroupImage.mData, group.mGroupImage.mSize, chanImage,GxsIdDetails::ORIGINAL); + } else { + chanImage = QPixmap(BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE); + } + if(group.mMeta.mGroupName.empty()) + ui->namelabel->setText(tr("[No name]")); + else + ui->namelabel->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str())); + + ui->logoLabel->setPixmap(chanImage); + ui->logoLabel->setFixedSize(QSize(ui->logoLabel->height()*chanImage.width()/(float)chanImage.height(),ui->logoLabel->height())); // make the logo have the same aspect ratio than the original image + + ui->submitPostButton->setEnabled(bool(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)); + + ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); + ui->subscribeToolButton->setEnabled(true); + + RetroShareLink link; + + if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + ui->subscribeToolButton->setText(tr("Subscribed") + " " + QString::number(group.mMeta.mPop) ); + else + ui->subscribeToolButton->setText(tr("Subscribe")); + + 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()); + + unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS; + + // embed smileys ? + if (Settings->valueFromGroup(QString("ChannelPostsWidget"), QString::fromUtf8("Emoteicons_ChannelDecription"), true).toBool()) + formatFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS; + + formatDescription = RsHtml().formatText(NULL, formatDescription, formatFlag); + + ui->infoDescription->setText(formatDescription); + ui->infoAdministrator->setId(group.mMeta.mAuthorId) ; + + link = RetroShareLink::createMessage(group.mMeta.mAuthorId, ""); + ui->infoAdministrator->setText(link.toHtml()); + + ui->createdinfolabel->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs)); + + QString distrib_string ( "[unknown]" ); + + switch(group.mMeta.mCircleType) + { + case GXS_CIRCLE_TYPE_PUBLIC: distrib_string = tr("Public") ; + break ; + case GXS_CIRCLE_TYPE_EXTERNAL: + { + RsGxsCircleDetails det ; + + // !! What we need here is some sort of CircleLabel, which loads the circle and updates the label when done. + + if(rsGxsCircles->getCircleDetails(group.mMeta.mCircleId,det)) + distrib_string = tr("Restricted to members of circle \"")+QString::fromUtf8(det.mCircleName.c_str()) +"\""; + else + distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ; + } + break ; + case GXS_CIRCLE_TYPE_YOUR_EYES_ONLY: distrib_string = tr("Your eyes only"); + break ; + case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes"); + break ; + default: + std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl; + } + + ui->infoDistribution->setText(distrib_string); +#ifdef TODO + ui->infoWidget->show(); + ui->feedWidget->hide(); + ui->fileWidget->hide(); + + //ui->feedToolButton->setEnabled(false); + //ui->fileToolButton->setEnabled(false); +#endif +} + +#ifdef TODO +int PostedListWidgetWithModel::viewMode() +{ + if (ui->feedToolButton->isChecked()) { + return VIEW_MODE_FEEDS; + } else if (ui->fileToolButton->isChecked()) { + return VIEW_MODE_FILES; + } + + /* Default */ + return VIEW_MODE_FEEDS; +} +#endif + +void PostedListWidgetWithModel::setViewMode(int viewMode) +{ +#ifdef TODO + switch (viewMode) { + case VIEW_MODE_FEEDS: + ui->feedWidget->show(); + ui->fileWidget->hide(); + + ui->feedToolButton->setChecked(true); + ui->fileToolButton->setChecked(false); + + break; + case VIEW_MODE_FILES: + ui->feedWidget->hide(); + ui->fileWidget->show(); + + ui->feedToolButton->setChecked(false); + ui->fileToolButton->setChecked(true); + + break; + default: + setViewMode(VIEW_MODE_FEEDS); + return; + } +#endif +} + +#ifdef TODO +/*static*/ bool PostedListWidgetWithModel::filterItem(FeedItem *feedItem, const QString &text, int filter) +{ + GxsChannelPostItem *item = dynamic_cast(feedItem); + if (!item) { + return true; + } + + bool bVisible = text.isEmpty(); + + if (!bVisible) + { + switch(filter) + { + case FILTER_TITLE: + bVisible = item->getTitleLabel().contains(text,Qt::CaseInsensitive); + break; + case FILTER_MSG: + bVisible = item->getMsgLabel().contains(text,Qt::CaseInsensitive); + break; + case FILTER_FILE_NAME: + { + std::list fileItems = item->getFileItems(); + std::list::iterator lit; + for(lit = fileItems.begin(); lit != fileItems.end(); ++lit) + { + SubFileItem *fi = *lit; + QString fileName = QString::fromUtf8(fi->FileName().c_str()); + bVisible = (bVisible || fileName.contains(text,Qt::CaseInsensitive)); + } + break; + } + default: + bVisible = true; + break; + } + } + + return bVisible; +} + +void PostedListWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& meta,bool related) +{ + GxsChannelPostItem *item = NULL; + RsGxsChannelPost post; + + if(!meta.mOrigMsgId.isNull()) + { + FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; + item = dynamic_cast(feedItem); + + if(item) + { + post = feedItem->post(); + ui->feedWidget->removeFeedItem(item) ; + + post.mOlderVersions.insert(post.mMeta.mMsgId); + + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions); + ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); + + return ; + } + } + + if (related) + { + FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; + item = dynamic_cast(feedItem); + } + if (item) + { + item->setPost(post); + ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); + } + else + { + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, true); + ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); + } +#ifdef TODO + ui->fileWidget->addFiles(post, related); +#endif +} + +void PostedListWidget::createPostItem(const RsGxsChannelPost& post, bool related) +{ + GxsChannelPostItem *item = NULL; + + const RsMsgMetaData& meta(post.mMeta); + + if(!meta.mOrigMsgId.isNull()) + { + FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; + item = dynamic_cast(feedItem); + + if(item) + { + std::set older_versions(item->olderVersions()); // we make a copy because the item will be deleted + ui->feedWidget->removeFeedItem(item) ; + + older_versions.insert(meta.mMsgId); + + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, false,older_versions); + ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); + + return ; + } + } + + if (related) + { + FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; + item = dynamic_cast(feedItem); + } + if (item) + { + item->setPost(post); + ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); + } + else + { + GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, true); + ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); + } + + ui->fileWidget->addFiles(post, related); +} + +void PostedListWidget::fillThreadCreatePost(const QVariant &post, bool related, int current, int count) +{ + /* show fill progress */ + if (count) { + ui->progressBar->setValue(current * ui->progressBar->maximum() / count); + } + + if (!post.canConvert()) { + return; + } + + createPostItem(post.value(), related); +} +#endif + +void PostedListWidgetWithModel::blank() +{ +#ifdef TODO + ui->postButton->setEnabled(false); + ui->subscribeToolButton->setEnabled(false); + + ui->channelName_LB->setText(tr("No Channel Selected")); + ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channels.png")); + ui->infoPosts->setText(""); + ui->infoLastPost->setText(""); + ui->infoAdministrator->setText(""); + ui->infoDistribution->setText(""); + ui->infoCreated->setText(""); + ui->infoDescription->setText(""); + + mChannelPostsModel->clear(); + mChannelPostFilesModel->clear(); + ui->postDetails_TE->clear(); + ui->postLogo_LB->hide(); + ui->postName_LB->hide(); + ui->postTime_LB->hide(); +#endif + groupNameChanged(QString()); +} + +bool PostedListWidgetWithModel::navigate(const RsGxsMessageId& msgId) +{ + QModelIndex index = mPostedPostsModel->getIndexOfMessage(msgId); + + if(!index.isValid()) + { + std::cerr << "(EE) Cannot navigate to msg " << msgId << " in board " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl; + + mSelectedPost = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading. + return true; // we have to return true here, otherwise the caller will intepret the async loading as an error. + } + + ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect); + ui->postsTree->scrollTo(index);//May change if model reloaded + ui->postsTree->setFocus(); + + return true; +} + +void PostedListWidgetWithModel::subscribeGroup(bool subscribe) +{ + RsGxsGroupId grpId(groupId()); + if (grpId.isNull()) return; + + RsThread::async([=]() + { + uint32_t token; + rsPosted->subscribeToGroup(token,grpId, subscribe); + } ); +} + +#ifdef TODO +class PostedPostsReadData +{ +public: + PostedPostsReadData(bool read) + { + mRead = read; + mLastToken = 0; + } + +public: + bool mRead; + uint32_t mLastToken; +}; + +static void setAllMessagesReadCallback(FeedItem *feedItem, void *data) +{ + GxsChannelPostItem *channelPostItem = dynamic_cast(feedItem); + if (!channelPostItem) { + return; + } + + GxsChannelPostsReadData *readData = (GxsChannelPostsReadData*) data; + bool isRead = !channelPostItem->isUnread() ; + + if(channelPostItem->isLoaded() && (isRead == readData->mRead)) + return ; + + RsGxsGrpMsgIdPair msgPair = std::make_pair(channelPostItem->groupId(), channelPostItem->messageId()); + rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead); +} + +void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token) +{ + if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { + return; + } + + GxsChannelPostsReadData data(read); + //ui->feedWidget->withAll(setAllMessagesReadCallback, &data); + + token = data.mLastToken; +} + +#endif From 033596a080211f103c3f6817049de5e7a19ca95e Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 7 Aug 2020 17:22:55 +0200 Subject: [PATCH 13/78] added two-views system for boards. Widgets are not yet correct --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 456 +++++----- .../src/gui/Posted/BoardPostDisplayWidget.h | 30 +- .../src/gui/Posted/BoardPostDisplayWidget.ui | 829 ++++++++++-------- .../src/gui/Posted/PostedCardView.h | 4 +- .../gui/Posted/PostedListWidgetWithModel.cpp | 69 +- .../gui/Posted/PostedListWidgetWithModel.h | 9 +- .../src/gui/Posted/PostedPostsModel.cpp | 4 + .../src/gui/Posted/PostedPostsModel.h | 3 + 8 files changed, 780 insertions(+), 624 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index ac512a57d..47d4e0421 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -43,13 +43,17 @@ const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2.png"; -BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,QWidget *parent) - : QWidget(parent),ui(new Ui::BoardPostDisplayWidget()),mPost(post) +//=================================================================================================================================== +//== Base class BoardPostDisplayWidget == +//=================================================================================================================================== + +BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode mode,QWidget *parent) + : QWidget(parent),ui(new Ui::BoardPostDisplayWidget()),dmode(mode),mPost(post) { ui->setupUi(this); + mExpanded = false; setup(); - fill(); } void BoardPostDisplayWidget::setCommentsSize(int comNb) @@ -114,234 +118,284 @@ BoardPostDisplayWidget::~BoardPostDisplayWidget() delete(ui); } +void BoardPostDisplayWidget::toggleNotes() {} + void BoardPostDisplayWidget::setup() { - setAttribute(Qt::WA_DeleteOnClose, true); + // show/hide things based on the view type - /* clear ui */ - ui->titleLabel->setText(tr("Loading")); - ui->dateLabel->clear(); - ui->fromLabel->clear(); - ui->siteLabel->clear(); + if(dmode == DISPLAY_MODE_COMPACT) + { + ui->pictureLabel_compact->show(); + ui->expandButton->show(); - connect(ui->commentButton, SIGNAL( clicked()), this, SLOT(loadComments())); - connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); - connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote())); - connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); - - QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); - connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink())); - - QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); - connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople())); - - int S = QFontMetricsF(font()).height() ; - - ui->voteUpButton->setIconSize(QSize(S*1.5,S*1.5)); - ui->voteDownButton->setIconSize(QSize(S*1.5,S*1.5)); - ui->commentButton->setIconSize(QSize(S*1.5,S*1.5)); - ui->readButton->setIconSize(QSize(S*1.5,S*1.5)); - ui->shareButton->setIconSize(QSize(S*1.5,S*1.5)); - - QMenu *menu = new QMenu(); - menu->addAction(CopyLinkAction); - menu->addSeparator(); - menu->addAction(showInPeopleAct); - ui->shareButton->setMenu(menu); - - ui->clearButton->hide(); - ui->readAndClearButton->hide(); -} - -void BoardPostDisplayWidget::fill() -{ - RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); - bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); - - if(redacted) { - ui->commentButton->setDisabled(true); - ui->voteUpButton->setDisabled(true); - ui->voteDownButton->setDisabled(true); -// ui->picture_frame->hide(); - ui->fromLabel->setId(mPost.mMeta.mAuthorId); - ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; - QDateTime qtime; - qtime.setTime_t(mPost.mMeta.mPublishTs); - QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); - ui->dateLabel->setText(timestamp); - } else { - - QPixmap sqpixmap2 = FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png"); - - int desired_height = 1.5*(ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height()); - int desired_width = sqpixmap2.width()*desired_height/(float)sqpixmap2.height(); - - QDateTime qtime; - qtime.setTime_t(mPost.mMeta.mPublishTs); - QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); - QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); - ui->dateLabel->setText(timestamp2); - ui->dateLabel->setToolTip(timestamp); - - ui->fromLabel->setId(mPost.mMeta.mAuthorId); - - // Use QUrl to check/parse our URL - // The only combination that seems to work: load as EncodedUrl, extract toEncoded(). - QByteArray urlarray(mPost.mLink.c_str()); - QUrl url = QUrl::fromEncoded(urlarray.trimmed()); - QString urlstr = "Invalid Link"; - QString sitestr = "Invalid Link"; - - bool urlOkay = url.isValid(); - if (urlOkay) - { - QString scheme = url.scheme(); - if ((scheme != "https") - && (scheme != "http") - && (scheme != "ftp") - && (scheme != "retroshare")) - { - urlOkay = false; - sitestr = "Invalid Link Scheme"; - } - } - - if (urlOkay) - { - urlstr = QString(" "); - urlstr += QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); - urlstr += QString(" "); - - QString siteurl = url.toEncoded(); - sitestr = QString(" %2 ").arg(siteurl).arg(siteurl); - - ui->titleLabel->setText(urlstr); - } + if(mExpanded) + { + ui->frame_picture->show(); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png"))); + ui->expandButton->setToolTip(tr("Hide")); + } else - ui->titleLabel->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) ); - - if (urlarray.isEmpty()) - { - ui->siteLabel->hide(); - } + { + ui->frame_picture->hide(); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/expand.png"))); + ui->expandButton->setToolTip(tr("Expand")); + } + } + else + { + ui->frame_picture->hide(); + ui->pictureLabel_compact->hide(); + ui->expandButton->hide(); + } - ui->siteLabel->setText(sitestr); - - if(mPost.mImage.mData != NULL) - { - QPixmap pixmap; - GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); - // Wiping data - as its been passed to thumbnail. - - QPixmap scaledpixmap; - if(pixmap.width() > 800){ - QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); - ui->pictureLabel->setPixmap(scaledpixmap); - }else{ - ui->pictureLabel->setPixmap(pixmap); - } - } - else if (mPost.mImage.mData == NULL) - ui->pictureLabel->hide(); - else - ui->pictureLabel->show(); - } + setAttribute(Qt::WA_DeleteOnClose, true); - //QString score = "Hot" + QString::number(post.mHotScore); - //score += " Top" + QString::number(post.mTopScore); - //score += " New" + QString::number(post.mNewScore); + /* clear ui */ + ui->titleLabel->setText(tr("Loading")); + ui->dateLabel->clear(); + ui->fromLabel->clear(); + ui->siteLabel->clear(); - QString score = QString::number(mPost.mTopScore); + connect(ui->commentButton, SIGNAL( clicked()), this, SLOT(loadComments())); + connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); + connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote())); + connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); - ui->scoreLabel->setText(score); + QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); + connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink())); - // FIX THIS UP LATER. - ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); + connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople())); - QTextDocument doc; - doc.setHtml(ui->notes->text()); + int S = QFontMetricsF(font()).height() ; - if(doc.toPlainText().trimmed().isEmpty()) - ui->notes->hide(); + ui->voteUpButton->setIconSize(QSize(S*1.5,S*1.5)); + ui->voteDownButton->setIconSize(QSize(S*1.5,S*1.5)); + ui->commentButton->setIconSize(QSize(S*1.5,S*1.5)); + ui->readButton->setIconSize(QSize(S*1.5,S*1.5)); + ui->shareButton->setIconSize(QSize(S*1.5,S*1.5)); + + QMenu *menu = new QMenu(); + menu->addAction(CopyLinkAction); + menu->addSeparator(); + menu->addAction(showInPeopleAct); + ui->shareButton->setMenu(menu); + + ui->clearButton->hide(); + ui->readAndClearButton->hide(); + + RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); + bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); + + if(redacted) + { + ui->commentButton->setDisabled(true); + ui->voteUpButton->setDisabled(true); + ui->voteDownButton->setDisabled(true); + ui->fromLabel->setId(mPost.mMeta.mAuthorId); + ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; + QDateTime qtime; + qtime.setTime_t(mPost.mMeta.mPublishTs); + QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); + ui->dateLabel->setText(timestamp); + } + else + { + QPixmap sqpixmap2 = FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png"); + + QDateTime qtime; + qtime.setTime_t(mPost.mMeta.mPublishTs); + QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); + QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); + ui->dateLabel->setText(timestamp2); + ui->dateLabel->setToolTip(timestamp); + + ui->fromLabel->setId(mPost.mMeta.mAuthorId); + + // Use QUrl to check/parse our URL + // The only combination that seems to work: load as EncodedUrl, extract toEncoded(). + QByteArray urlarray(mPost.mLink.c_str()); + QUrl url = QUrl::fromEncoded(urlarray.trimmed()); + QString urlstr = "Invalid Link"; + QString sitestr = "Invalid Link"; + + bool urlOkay = url.isValid(); + if (urlOkay) + { + QString scheme = url.scheme(); + if ((scheme != "https") + && (scheme != "http") + && (scheme != "ftp") + && (scheme != "retroshare")) + { + urlOkay = false; + sitestr = "Invalid Link Scheme"; + } + } + + if (urlOkay) + { + urlstr = QString(" "); + urlstr += QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); + urlstr += QString(" "); + + QString siteurl = url.toEncoded(); + sitestr = QString(" %2 ").arg(siteurl).arg(siteurl); + + ui->titleLabel->setText(urlstr); + } + else + ui->titleLabel->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) ); + + if (urlarray.isEmpty()) + { + ui->siteLabel->hide(); + } + + ui->siteLabel->setText(sitestr); + + if(dmode == DISPLAY_MODE_COMPACT) + { + if(mPost.mImage.mData != NULL) + { + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + // Wiping data - as its been passed to thumbnail. + + + QPixmap scaledpixmap; + if(pixmap.width() > 800){ + QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); + ui->pictureLabel_compact->setPixmap(scaledpixmap); + }else{ + ui->pictureLabel_compact->setPixmap(pixmap); + } + } + else if (mPost.mImage.mData == NULL) + ui->pictureLabel_compact->hide(); + else + ui->pictureLabel_compact->show(); + } + else + { + if(mPost.mImage.mData != NULL) + { + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + // Wiping data - as its been passed to thumbnail. + + + QPixmap scaledpixmap; + if(pixmap.width() > 800){ + QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); + ui->pictureLabel->setPixmap(scaledpixmap); + }else{ + ui->pictureLabel->setPixmap(pixmap); + } + } + else if (mPost.mImage.mData == NULL) + ui->pictureLabel->hide(); + else + ui->pictureLabel->show(); + } + } + + //QString score = "Hot" + QString::number(post.mHotScore); + //score += " Top" + QString::number(post.mTopScore); + //score += " New" + QString::number(post.mNewScore); + + QString score = QString::number(mPost.mTopScore); + + ui->scoreLabel->setText(score); + + // FIX THIS UP LATER. + ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + + QTextDocument doc; + doc.setHtml(ui->notes->text()); + + if(doc.toPlainText().trimmed().isEmpty()) + ui->notes->hide(); #ifdef TO_REMOVE - // differences between Feed or Top of Comment. - if (mFeedHolder) - { - // feed. - //frame_comment->show(); - ui->commentButton->show(); + // differences between Feed or Top of Comment. + if (mFeedHolder) + { + // feed. + //frame_comment->show(); + ui->commentButton->show(); - if (mPost.mComments) - { - QString commentText = QString::number(mPost.mComments); - commentText += " "; - commentText += tr("Comments"); - ui->commentButton->setText(commentText); - } - else - { - ui->commentButton->setText(tr("Comment")); - } + if (mPost.mComments) + { + QString commentText = QString::number(mPost.mComments); + commentText += " "; + commentText += tr("Comments"); + ui->commentButton->setText(commentText); + } + else + { + ui->commentButton->setText(tr("Comment")); + } - setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); - } - else + setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); + } + else #endif - { - // no feed. - //frame_comment->hide(); - ui->commentButton->hide(); + { + // no feed. + //frame_comment->hide(); + ui->commentButton->hide(); - ui->readButton->hide(); - ui->newLabel->hide(); - } + ui->readButton->hide(); + ui->newLabel->hide(); + } #ifdef TO_REMOVE - if (mIsHome) - { - ui->clearButton->hide(); - ui->readAndClearButton->hide(); - } - else + if (mIsHome) + { + ui->clearButton->hide(); + ui->readAndClearButton->hide(); + } + else #endif - { - ui->clearButton->show(); - ui->readAndClearButton->show(); - } + { + ui->clearButton->show(); + ui->readAndClearButton->show(); + } - // disable voting buttons - if they have already voted. - if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) - { - ui->voteUpButton->setEnabled(false); - ui->voteDownButton->setEnabled(false); - } + // disable voting buttons - if they have already voted. + if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) + { + ui->voteUpButton->setEnabled(false); + ui->voteDownButton->setEnabled(false); + } #if 0 - uint32_t up, down, nComments; - - bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments); + uint32_t up, down, nComments; - if(ok) - { - int32_t vote = up - down; - scoreLabel->setText(QString::number(vote)); + bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments); - numCommentsLabel->setText("

# Comments: " - + QString::number(nComments) + "

"); - } + if(ok) + { + int32_t vote = up - down; + scoreLabel->setText(QString::number(vote)); - mInFill = false; + numCommentsLabel->setText("

# Comments: " + + QString::number(nComments) + "

"); + } + + mInFill = false; #endif #ifdef TODO - emit sizeChanged(this); + emit sizeChanged(this); #endif } -void BoardPostDisplayWidget::toggleNotes() {} + diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 8a165dc76..d3acbc701 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -29,25 +29,32 @@ namespace Ui { class BoardPostDisplayWidget; } -class RsPostedPost; +struct RsPostedPost; class BoardPostDisplayWidget : public QWidget { Q_OBJECT public: - BoardPostDisplayWidget(const RsPostedPost& post,QWidget *parent=nullptr); + enum DisplayMode { + DISPLAY_MODE_UNKNOWN = 0x00, + DISPLAY_MODE_CARD_VIEW = 0x01, + DISPLAY_MODE_COMPACT = 0x02 + }; + + BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,QWidget *parent=nullptr); virtual ~BoardPostDisplayWidget(); static const char *DEFAULT_BOARD_IMAGE; protected: /* GxsGroupFeedItem */ - void setup() ; - void fill() ; - void doExpand(bool open) {} + virtual void setup(); // to be overloaded by the different views + + void doExpand(bool) {} void setComment(const RsGxsComment&) ; void setReadStatus(bool isNew, bool isUnread) ; + void toggle() {} void setCommentsSize(int comNb) ; void makeUpVote() ; @@ -57,9 +64,14 @@ protected: signals: void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); -private: - /** Qt Designer generated object */ - Ui::BoardPostDisplayWidget *ui; - +protected: RsPostedPost mPost; + + DisplayMode dmode; + bool mExpanded; + +private: + /** Qt Designer generated object */ + Ui::BoardPostDisplayWidget *ui; }; + diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index 900877531..473ccbf4e 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -7,7 +7,7 @@ 0 0 747 - 199 + 221 @@ -22,394 +22,479 @@ - + - + - + - - - - 0 - 0 - - - - Vote up - - - - - - - :/images/up-arrow.png:/images/up-arrow.png - - - true - - + + + + + + 0 + 0 + + + + Vote up + + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true + + + + + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + - - - - 9 - + + + Qt::Vertical - - 0 - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - + - 0 - 0 + 20 + 40 - - Vote down - - - - - - \/ - - - - :/images/down-arrow.png:/images/down-arrow.png - - - true - - + - - - Qt::Vertical + + + PictureLabel_compact - - - 20 - 40 - - - + + + + + + + + 5 + + + 0 + + + 6 + + + + + + 0 + 0 + + + + + 50 + false + + + + Posted by + + + + + + + + 0 + 0 + + + + Signed by + + + true + + + + + + + + 0 + 0 + + + + You eyes only + + + true + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + + :/images/message-state-unread.png:/images/message-state-unread.png + + + true + + + false + + + true + + + + + + + New + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 70 + 20 + + + + + + + + + + + 0 + 0 + + + + + Arial + 10 + 75 + true + + + + This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + TextLabel + + + true + + + true + + + + + + + + 0 + 0 + + + + site + + + true + + + + + + + + + PictureLabel + + + true + + + + + + + Qt::Horizontal + + + + 268 + 17 + + + + + + + + + + + + Expand + + + + + + + :/images/expand.png:/images/expand.png + + + true + + + + + + + Comments + + + + :/images/comments.png:/images/comments.png + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + + + + + Qt::Horizontal + + + + 308 + 20 + + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Set as read and remove item + + + + :/icons/png/correct.png:/icons/png/correct.png + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Remove Item + + + + :/icons/png/exit2.png:/icons/png/exit2.png + + + + + + - - - - - 5 - - - 0 - - - 6 - - - - - - 0 - 0 - - - - - 50 - false - - - - Posted by - - - - - - - - 0 - 0 - - - - Signed by - - - true - - - - - - - - 0 - 0 - - - - You eyes only - - - true - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Toggle Message Read Status - - - - :/images/message-state-unread.png:/images/message-state-unread.png - - - true - - - false - - - true - - - - - - - New - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 70 - 20 - - - - - - - - - - - 0 - 0 - - - - - Arial - 10 - 75 - true - - - - This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - TextLabel - - - true - - - true - - - - - - - - 0 - 0 - - - - site - - - true - - - - - - - - - PictureLabel - - - true - - - - - - - Qt::Horizontal - - - - 268 - 17 - - - - - - - - - - - - Comments - - - - :/images/comments.png:/images/comments.png - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Share - - - - :/images/share.png:/images/share.png - - - true - - - - - - - Qt::Horizontal - - - - 308 - 20 - - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Set as read and remove item - - - - :/icons/png/correct.png:/icons/png/correct.png - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Remove Item - - - - :/icons/png/exit2.png:/icons/png/exit2.png - - - - - - + + + + 800 + 600 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Qt::Horizontal + + + + 257 + 20 + + + + + + + + TextLabel + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + 257 + 20 + + + + + + @@ -426,9 +511,9 @@
+ - diff --git a/retroshare-gui/src/gui/Posted/PostedCardView.h b/retroshare-gui/src/gui/Posted/PostedCardView.h index 79c9c3fdb..0f4f5f2ab 100644 --- a/retroshare-gui/src/gui/Posted/PostedCardView.h +++ b/retroshare-gui/src/gui/Posted/PostedCardView.h @@ -31,7 +31,7 @@ class PostedCardView; } class FeedHolder; -class RsPostedPost; +struct RsPostedPost; class PostedCardView : public BasePostedItem { @@ -47,7 +47,7 @@ protected: void setup() override; void fill() override; - void doExpand(bool open) override {} + void doExpand(bool) override {} void setComment(const RsGxsComment&) override; void setReadStatus(bool isNew, bool isUnread) override; void toggle() override {} diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 3df9a3d76..608aff438 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -43,7 +43,6 @@ #include "PostedListWidgetWithModel.h" #include "PostedPostsModel.h" -#include "PostedCardView.h" #include "BoardPostDisplayWidget.h" #include @@ -64,6 +63,8 @@ // #define IMAGE_COPYLINK ":/images/copyrslink.png" +Q_DECLARE_METATYPE(RsPostedPost); + // Delegate used to paint into the table of thumbnails void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const @@ -82,7 +83,8 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->fillRect( option.rect, option.backgroundBrush); painter->restore(); - BoardPostDisplayWidget w(post); + BoardPostDisplayWidget w(post,mDisplayMode); + w.setMaximumWidth(mCellWidthPix); w.setMinimumWidth(mCellWidthPix); w.adjustSize(); @@ -155,7 +157,7 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo RsPostedPost post = index.data(Qt::UserRole).value() ; - BoardPostDisplayWidget w(post); + BoardPostDisplayWidget w(post,mDisplayMode); w.setMinimumWidth(mCellWidthPix); w.setMaximumWidth(mCellWidthPix); w.adjustSize(); @@ -169,15 +171,15 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const { - RsPostedPost post = index.data(Qt::UserRole).value() ; + RsPostedPost post = index.data(Qt::UserRole).value() ; if(index.column() == RsPostedPostsModel::COLUMN_POSTS) { - QWidget *w = new BoardPostDisplayWidget(post,parent); - w->setMinimumWidth(mCellWidthPix); - w->setMaximumWidth(mCellWidthPix); - w->adjustSize(); - return w; + QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent); + w->setMinimumWidth(mCellWidthPix); + w->setMaximumWidth(mCellWidthPix); + w->adjustSize(); + return w; } else return NULL; @@ -213,6 +215,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI //connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder))); connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&))); + connect(ui->cardViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode())); + connect(ui->classicViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode())); connect(mPostedPostsModel,SIGNAL(boardPostsLoaded()),this,SLOT(postPostLoad())); @@ -248,7 +252,9 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI settingsChanged(); setGroupId(postedId); - mPostedPostsModel->updateBoard(postedId); + ui->classicViewButton->setChecked(true); // inits both button checking consistency and delegate display mode variables. + + mPostedPostsModel->updateBoard(postedId); mEventHandlerId = 0; // Needs to be asynced because this function is called by another thread! @@ -258,6 +264,22 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI }, mEventHandlerId, RsEventType::GXS_POSTED ); } +void PostedListWidgetWithModel::switchDisplayMode() +{ + if(sender() == ui->classicViewButton) + { + whileBlocking(ui->cardViewButton)->setChecked(false); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT); + } + else + { + whileBlocking(ui->classicViewButton)->setChecked(false); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); + } + + mPostedPostsModel->update(); +} + void PostedListWidgetWithModel::updateSorting(int s) { switch(s) @@ -724,33 +746,6 @@ int PostedListWidgetWithModel::viewMode() } #endif -void PostedListWidgetWithModel::setViewMode(int viewMode) -{ -#ifdef TODO - switch (viewMode) { - case VIEW_MODE_FEEDS: - ui->feedWidget->show(); - ui->fileWidget->hide(); - - ui->feedToolButton->setChecked(true); - ui->fileToolButton->setChecked(false); - - break; - case VIEW_MODE_FILES: - ui->feedWidget->hide(); - ui->fileWidget->show(); - - ui->feedToolButton->setChecked(false); - ui->fileToolButton->setChecked(true); - - break; - default: - setViewMode(VIEW_MODE_FEEDS); - return; - } -#endif -} - #ifdef TODO /*static*/ bool PostedListWidgetWithModel::filterItem(FeedItem *feedItem, const QString &text, int filter) { diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 365504b30..8ba9c77fe 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -29,6 +29,7 @@ #include "gui/gxs/GxsMessageFramePostWidget.h" #include "gui/feeds/FeedHolder.h" +#include "gui/Posted/BoardPostDisplayWidget.h" namespace Ui { class PostedListWidgetWithModel; @@ -43,7 +44,7 @@ class PostedPostDelegate: public QAbstractItemDelegate Q_OBJECT public: - PostedPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100){} + PostedPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT){} virtual ~PostedPostDelegate(){} void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; @@ -54,11 +55,13 @@ class PostedPostDelegate: public QAbstractItemDelegate int cellSize(const QFont& font) const; void setCellWidth(int pix) { mCellWidthPix = pix; } + void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; } private: QSize cellSize(const QSize& w) const; int mCellWidthPix; + BoardPostDisplayWidget::DisplayMode mDisplayMode; }; class PostedListWidgetWithModel: public GxsMessageFrameWidget @@ -117,10 +120,10 @@ protected: private slots: void updateSorting(int); - void updateGroupData(); + void switchDisplayMode(); + void updateGroupData(); void createMsg(); void subscribeGroup(bool subscribe); - void setViewMode(int viewMode); void settingsChanged(); void postPostLoad(); void postContextMenu(const QPoint&); diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index 5ca140091..0720b01d0 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -139,6 +139,10 @@ void RsPostedPostsModel::postMods() emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL)); } +void RsPostedPostsModel::update() +{ + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL)); +} void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count) { diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.h b/retroshare-gui/src/gui/Posted/PostedPostsModel.h index 0aab99b01..ac36e96c4 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.h +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.h @@ -135,6 +135,9 @@ public: void updateBoard(const RsGxsGroupId& posted_group_id); const RsGxsGroupId& currentGroupId() const; + // Triggers a data change for all items. This can be used to redraw the view without re-loading the data. + void update(); + #ifdef TODO void setSortMode(SortMode mode) ; From bdb36f7528da2f3a70304dcdf931634a9588e421 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 9 Aug 2020 14:09:50 +0200 Subject: [PATCH 14/78] fixed sizes and switching between modes --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 36 +- .../src/gui/Posted/BoardPostDisplayWidget.ui | 331 ++++++++---------- .../gui/Posted/PostedListWidgetWithModel.cpp | 55 +-- .../gui/Posted/PostedListWidgetWithModel.h | 7 +- .../src/gui/Posted/PostedPostsModel.cpp | 6 + .../src/gui/Posted/PostedPostsModel.h | 3 + 6 files changed, 196 insertions(+), 242 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 47d4e0421..df79d374b 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -48,11 +48,9 @@ const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2 //=================================================================================================================================== BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode mode,QWidget *parent) - : QWidget(parent),ui(new Ui::BoardPostDisplayWidget()),dmode(mode),mPost(post) + : QWidget(parent),mPost(post),dmode(mode),mExpanded(false),ui(new Ui::BoardPostDisplayWidget()) { ui->setupUi(this); - mExpanded = false; - setup(); } @@ -127,6 +125,10 @@ void BoardPostDisplayWidget::setup() if(dmode == DISPLAY_MODE_COMPACT) { ui->pictureLabel_compact->show(); + ui->pictureLabel->hide(); + ui->notes->hide(); + ui->siteLabel->hide(); + ui->expandButton->show(); if(mExpanded) @@ -182,9 +184,6 @@ void BoardPostDisplayWidget::setup() menu->addAction(showInPeopleAct); ui->shareButton->setMenu(menu); - ui->clearButton->hide(); - ui->readAndClearButton->hide(); - RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); @@ -265,14 +264,10 @@ void BoardPostDisplayWidget::setup() GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); // Wiping data - as its been passed to thumbnail. + int desired_height = QFontMetricsF(font()).height() * 5; - QPixmap scaledpixmap; - if(pixmap.width() > 800){ - QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); - ui->pictureLabel_compact->setPixmap(scaledpixmap); - }else{ - ui->pictureLabel_compact->setPixmap(pixmap); - } + QPixmap scaledpixmap = pixmap.scaledToHeight(desired_height, Qt::SmoothTransformation); + ui->pictureLabel_compact->setPixmap(scaledpixmap); } else if (mPost.mImage.mData == NULL) ui->pictureLabel_compact->hide(); @@ -353,19 +348,6 @@ void BoardPostDisplayWidget::setup() ui->newLabel->hide(); } -#ifdef TO_REMOVE - if (mIsHome) - { - ui->clearButton->hide(); - ui->readAndClearButton->hide(); - } - else -#endif - { - ui->clearButton->show(); - ui->readAndClearButton->show(); - } - // disable voting buttons - if they have already voted. if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) { @@ -393,6 +375,8 @@ void BoardPostDisplayWidget::setup() mInFill = false; #endif + updateGeometry(); + #ifdef TODO emit sizeChanged(this); #endif diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index 473ccbf4e..273eeebd0 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -6,12 +6,12 @@ 0 0 - 747 - 221 + 816 + 203 - + 0 0 @@ -22,87 +22,104 @@ - + - + + + QLayout::SetMinimumSize + - + + + QLayout::SetMinimumSize + - + - - - - 0 - 0 - - - - Vote up - - - - - - - :/images/up-arrow.png:/images/up-arrow.png - - - true - - + + + + + + 0 + 0 + + + + Vote up + + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true + + + + + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + - - - - 9 - - + - 0 - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Vote down - - - - - - \/ - - - - :/images/down-arrow.png:/images/down-arrow.png - - - true + PictureLabel_compact - + Qt::Vertical @@ -116,15 +133,11 @@ - - - - PictureLabel_compact - - - + + QLayout::SetMinimumSize + @@ -239,6 +252,54 @@ + + + + Comments + + + + :/images/comments.png:/images/comments.png + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + + + + + Expand + + + + + + + :/images/expand.png:/images/expand.png + + + true + + + @@ -330,123 +391,12 @@ - - - - - - Expand - - - - - - - :/images/expand.png:/images/expand.png - - - true - - - - - - - Comments - - - - :/images/comments.png:/images/comments.png - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Share - - - - :/images/share.png:/images/share.png - - - true - - - - - - - Qt::Horizontal - - - - 308 - 20 - - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Set as read and remove item - - - - :/icons/png/correct.png:/icons/png/correct.png - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Remove Item - - - - :/icons/png/exit2.png:/icons/png/exit2.png - - - - - - - - 800 - 600 - - QFrame::StyledPanel @@ -511,9 +461,8 @@ - - + diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 608aff438..3ae793b54 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -67,6 +67,8 @@ Q_DECLARE_METATYPE(RsPostedPost); // Delegate used to paint into the table of thumbnails +std::ostream& operator<<(std::ostream& o,const QSize& s) { return o << s.width() << " x " << s.height() ; } + void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { if((option.state & QStyle::State_Selected)) // Avoids double display. The selected widget is never exactly the size of the rendered one, @@ -85,13 +87,13 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & BoardPostDisplayWidget w(post,mDisplayMode); - w.setMaximumWidth(mCellWidthPix); - w.setMinimumWidth(mCellWidthPix); + //w.setMaximumWidth(mCellWidthPix); + //w.setMinimumWidth(mCellWidthPix); w.adjustSize(); - QPixmap pixmap(option.rect.size()); + w.setFixedSize(cellSize(w.size())); - std::cerr << "pixmap.depth=" << pixmap.depth() << std::endl; + QPixmap pixmap(option.rect.size()); #ifdef SUSPENDED_CODE if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) @@ -114,6 +116,7 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + std::cerr << "PostedPostDelegate::paint(): w.size() = " << w.size() << std::endl; #ifdef TODO if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) { @@ -123,15 +126,15 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & } #endif - // debug - if(index.row()==0 && index.column()==0) - { - QFile file("yourFile.png"); - file.open(QIODevice::WriteOnly); - pixmap.save(&file, "PNG"); - std::cerr << "Saved pxmap to png" << std::endl; - } - //std::cerr << "option.rect = " << option.rect.width() << "x" << option.rect.height() << ". fm.height()=" << QFontMetricsF(option.font).height() << std::endl; + // debug + if(index.row()==0 && index.column()==0) + { + QFile file("yourFile.png"); + file.open(QIODevice::WriteOnly); + pixmap.save(&file, "PNG"); + std::cerr << "Saved pxmap to png" << std::endl; + } + //std::cerr << "option.rect = " << option.rect.width() << "x" << option.rect.height() << ". fm.height()=" << QFontMetricsF(option.font).height() << std::endl; painter->save(); @@ -148,7 +151,7 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & QSize PostedPostDelegate::cellSize(const QSize& w) const { - return QSize(mCellWidthPix,0 + w.height() * mCellWidthPix/(float)w.width()); + return QSize(mCellWidthPix,mCellWidthPix * w.height()/(float)w.width()); } QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const @@ -158,15 +161,19 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo RsPostedPost post = index.data(Qt::UserRole).value() ; BoardPostDisplayWidget w(post,mDisplayMode); - w.setMinimumWidth(mCellWidthPix); - w.setMaximumWidth(mCellWidthPix); + + //w.setMinimumWidth(mCellWidthPix); + //w.setMaximumWidth(mCellWidthPix); + w.adjustSize(); - QSize ss = cellSize(w.size()) + QSize(0,5); + QSize ss = cellSize(w.size()); - std::cerr << "w =" << w.width() << " x " << w.height() << " new size = " << ss.width() << " x " << ss.height() << std::endl; + std::cerr << "PostedPostDelegate::sizeHint(): w =" << w.width() << " x " << w.height() << " new size = " << ss.width() << " x " << ss.height() ; + w.setFixedSize(ss); - return ss; + std::cerr << " Final size:" << w.size() << std::endl; + return w.size(); } QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const @@ -176,9 +183,13 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie if(index.column() == RsPostedPostsModel::COLUMN_POSTS) { QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent); - w->setMinimumWidth(mCellWidthPix); - w->setMaximumWidth(mCellWidthPix); + + //w->setMinimumWidth(mCellWidthPix); + //w->setMaximumWidth(mCellWidthPix); w->adjustSize(); + w->setFixedSize(cellSize(w->size())); + + std::cerr << "PostedPostDelegate::createEditor(): size = " << w->size() << std::endl; return w; } else @@ -277,7 +288,7 @@ void PostedListWidgetWithModel::switchDisplayMode() mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); } - mPostedPostsModel->update(); + mPostedPostsModel->deepUpdate(); } void PostedListWidgetWithModel::updateSorting(int s) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 8ba9c77fe..eef377233 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -52,13 +52,14 @@ class PostedPostDelegate: public QAbstractItemDelegate void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override; QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - int cellSize(const QFont& font) const; + //int cellSize(const QFont& font) const; void setCellWidth(int pix) { mCellWidthPix = pix; } void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; } private: - QSize cellSize(const QSize& w) const; + QSize cellSize(const QSize& w) const; // Converts the supplied size to the cell size for the current container. + // The client should then scale its widget to fit the given size. int mCellWidthPix; BoardPostDisplayWidget::DisplayMode mDisplayMode; @@ -105,7 +106,7 @@ protected: #ifdef TODO virtual bool insertGroupData(const RsGxsGenericGroupData *data) override; #endif - virtual void blank() ; + virtual void blank() override; #ifdef TODO virtual bool getGroupData(RsGxsGenericGroupData *& data) override; diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index 0720b01d0..e05e52b70 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -489,6 +489,12 @@ void RsPostedPostsModel::setPostsInterval(int start,int nb_posts) postMods(); } +void RsPostedPostsModel::deepUpdate() +{ + auto posts(mPosts); + setPosts(mPostedGroup,posts); +} + void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector& posts) { preMods(); diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.h b/retroshare-gui/src/gui/Posted/PostedPostsModel.h index ac36e96c4..948d892f4 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.h +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.h @@ -138,6 +138,9 @@ public: // Triggers a data change for all items. This can be used to redraw the view without re-loading the data. void update(); + // Triggers a preMod, begin/end remove rows and data update. Could be useful if update is not enough to reset cell sizes. + void deepUpdate(); + #ifdef TODO void setSortMode(SortMode mode) ; From 6f1e1f8523a4a0334271ec19b4bc288e29d4a2e2 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 11 Aug 2020 13:04:29 +0200 Subject: [PATCH 15/78] attempt to fix size problem in boards display widget --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 5 +- .../src/gui/Posted/BoardPostDisplayWidget.ui | 686 +++++++++--------- 2 files changed, 347 insertions(+), 344 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index df79d374b..6933c4a98 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -25,7 +25,6 @@ #include "rshare.h" #include "BoardPostDisplayWidget.h" -#include "gui/feeds/FeedHolder.h" #include "gui/gxs/GxsIdDetails.h" #include "util/misc.h" #include "gui/common/FilesDefs.h" @@ -125,12 +124,12 @@ void BoardPostDisplayWidget::setup() if(dmode == DISPLAY_MODE_COMPACT) { ui->pictureLabel_compact->show(); + ui->expandButton->show(); + ui->pictureLabel->hide(); ui->notes->hide(); ui->siteLabel->hide(); - ui->expandButton->show(); - if(mExpanded) { ui->frame_picture->show(); diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index 273eeebd0..a1fe4b3e8 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -6,8 +6,8 @@ 0 0 - 816 - 203 + 758 + 195 @@ -22,38 +22,209 @@ - + - - - QLayout::SetMinimumSize - + - - - QLayout::SetMinimumSize - + - + + + QLayout::SetMinimumSize + - + - + + + + + + 0 + 0 + + + + Vote up + + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true + + + + + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + + + + + + PictureLabel_compact + + + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 40 + + + + + + + + + + QLayout::SetMinimumSize + + + + + 5 + + + 0 + + + 6 + + + - + 0 0 - - Vote up + + + 50 + false + - + Posted by + + + + + + + + 0 + 0 + + + + Signed by + + + true + + + + + + + + 0 + 0 + + + + You eyes only + + + true + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status - - :/images/up-arrow.png:/images/up-arrow.png + + :/images/message-state-unread.png:/images/message-state-unread.png + + + true + + + false true @@ -61,46 +232,70 @@ - - - - 9 - - + - 0 - - - Qt::AlignCenter + New - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Expanding + + - 0 - 0 + 70 + 20 - - Vote down - - - - + + + + - \/ + Comments - :/images/down-arrow.png:/images/down-arrow.png + :/images/comments.png:/images/comments.png + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + + + + + Expand + + + + + + + :/images/expand.png:/images/expand.png true @@ -110,74 +305,45 @@ - - - PictureLabel_compact - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - QLayout::SetMinimumSize - - - - - 5 - - - 0 - - - 6 - - - + - + 0 0 - 50 - false + Arial + 10 + 75 + true - Posted by + This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - 0 - 0 - - + - Signed by + TextLabel + + + true true @@ -185,15 +351,15 @@ - + - + 0 0 - You eyes only + site true @@ -201,251 +367,89 @@ - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Toggle Message Read Status - - - - :/images/message-state-unread.png:/images/message-state-unread.png - - - true - - - false - - - true - - - - - - - New - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 70 - 20 - - - - - - - - Comments - - - - :/images/comments.png:/images/comments.png - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Share - - - - :/images/share.png:/images/share.png - - - true - - - - - - - Expand - - - - - - - :/images/expand.png:/images/expand.png - - - true - - - - - - - - - - 0 - 0 - - - - - Arial - 10 - 75 - true - - - - This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - TextLabel - - - true - - - true - - - - - - - - 0 - 0 - - - - site - - - true - - - - - - - - - PictureLabel - - - true - - - - - - - Qt::Horizontal - - - - 268 - 17 - - - + + + + + PictureLabel + + + true + + + + + + + Qt::Horizontal + + + + 268 + 17 + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Qt::Horizontal + + + + 257 + 20 + + + + + + + + TextLabel + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + 257 + 20 + + + + + + + - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Qt::Horizontal - - - - 257 - 20 - - - - - - - - TextLabel - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Qt::Horizontal - - - - 257 - 20 - - - - - - - From ddd4ac80876b15e17b3fe29e10fdcff8a7c037c8 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 11 Aug 2020 16:00:49 +0200 Subject: [PATCH 16/78] fixed the size problem in boards UI --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 6 + .../src/gui/Posted/BoardPostDisplayWidget.ui | 799 +++++++++--------- .../gui/Posted/PostedListWidgetWithModel.cpp | 68 +- 3 files changed, 424 insertions(+), 449 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 6933c4a98..77e7305fd 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -51,6 +51,12 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayM { ui->setupUi(this); setup(); + + ui->verticalLayout->addStretch(); + ui->verticalLayout->setAlignment(Qt::AlignTop); + ui->topLayout->setAlignment(Qt::AlignTop); + ui->arrowsLayout->addStretch(); + ui->arrowsLayout->setAlignment(Qt::AlignTop); } void BoardPostDisplayWidget::setCommentsSize(int comNb) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index a1fe4b3e8..ce9cf74ae 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -7,11 +7,11 @@ 0 0 758 - 195 + 190 - + 0 0 @@ -22,433 +22,442 @@ - + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + - - - - - - - QLayout::SetMinimumSize - - - + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + 0 + 0 + + + + Vote up + + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true + + + + + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + + + + + + PictureLabel_compact + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + QLayout::SetMinimumSize + + + + + 5 + + + 0 + + + 6 + + + + + + 0 + 0 + + + + + 50 + false + + + + Posted by + + + + + + + + 0 + 0 + + + + Signed by + + + true + + + + + + + + 0 + 0 + + + + You eyes only + + + true + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + + :/images/message-state-unread.png:/images/message-state-unread.png + + + true + + + false + + + true + + + + + + + New + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 70 + 20 + + + + + + + + Comments + + + + :/images/comments.png:/images/comments.png + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + + + + + Expand + + + + + + + :/images/expand.png:/images/expand.png + + + true + + + + + + + + + + 0 + 0 + + + + + Arial + 10 + 75 + true + + + + This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + TextLabel + + + true + + + true + + + + + + + + 0 + 0 + + + + site + + + true + + + + + + + + + PictureLabel + + + true + + + + + + + Qt::Horizontal + + + + 268 + 17 + + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + - - - - - - 0 - 0 - - - - Vote up - - - - - - - :/images/up-arrow.png:/images/up-arrow.png - - - true - - - - - - - - 9 - - - - 0 - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Vote down - - - - - - \/ - - - - :/images/down-arrow.png:/images/down-arrow.png - - - true - - - - - - - - - PictureLabel_compact - - - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 40 - - - - - - - - - - QLayout::SetMinimumSize - - - - - 5 - - - 0 - - - 6 - - - - - - 0 - 0 - - - - - 50 - false - - - - Posted by - - - - - - - - 0 - 0 - - - - Signed by - - - true - - - - - - - - 0 - 0 - - - - You eyes only - - - true - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Toggle Message Read Status - - - - :/images/message-state-unread.png:/images/message-state-unread.png - - - true - - - false - - - true - - - - - - - New - - - - - + Qt::Horizontal - - QSizePolicy::Expanding - - 70 + 257 20 - + - Comments - - - - :/images/comments.png:/images/comments.png - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Share - - - - :/images/share.png:/images/share.png - - - true - - - - - - - Expand - - - - - - - :/images/expand.png:/images/expand.png - - - true - - - - - - - - - - 0 - 0 - - - - - Arial - 10 - 75 - true - - - - This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - TextLabel - - - true - - - true - - - - - - - - 0 - 0 - - - - site - - - true - - - - - - - - - PictureLabel + TextLabel true + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + - + Qt::Horizontal - 268 - 17 + 257 + 20 - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Qt::Horizontal - - - - 257 - 20 - - - - - - - - TextLabel - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - Qt::Horizontal - - - - 257 - 20 - - - - - - - + + + diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 3ae793b54..6373fa43a 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -87,36 +87,15 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & BoardPostDisplayWidget w(post,mDisplayMode); - //w.setMaximumWidth(mCellWidthPix); - //w.setMinimumWidth(mCellWidthPix); w.adjustSize(); - - w.setFixedSize(cellSize(w.size())); + w.setFixedSize(option.rect.size()); QPixmap pixmap(option.rect.size()); -#ifdef SUSPENDED_CODE - if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) - pixmap.fill(QRgb(0xff308dc7)); // I dont know how to grab the backgroud color for selected objects automatically. - else -#endif - pixmap.fill(QRgb(0x00f0f0f0)); // choose a fully transparent background - -#ifdef TESTING - { - QPainter W(&pixmap); - QLinearGradient m_gradient(0,0,pixmap.width(),0); - m_gradient.setColorAt(0.0, QRgb(0xff390e90)); - m_gradient.setColorAt(1.0, QRgb(0xff09feff)); - W.fillRect(pixmap.rect(), m_gradient); - - w.render(&W,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background - } -#endif + pixmap.fill(QRgb(0x00f0f0f0)); // choose a fully transparent background w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background - std::cerr << "PostedPostDelegate::paint(): w.size() = " << w.size() << std::endl; #ifdef TODO if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) { @@ -126,25 +105,17 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & } #endif - // debug - if(index.row()==0 && index.column()==0) - { - QFile file("yourFile.png"); - file.open(QIODevice::WriteOnly); - pixmap.save(&file, "PNG"); - std::cerr << "Saved pxmap to png" << std::endl; - } +// // debug +// if(index.row()==0 && index.column()==0) +// { +// QFile file("yourFile.png"); +// file.open(QIODevice::WriteOnly); +// pixmap.save(&file, "PNG"); +// std::cerr << "Saved pxmap to png" << std::endl; +// } //std::cerr << "option.rect = " << option.rect.width() << "x" << option.rect.height() << ". fm.height()=" << QFontMetricsF(option.font).height() << std::endl; painter->save(); - - // Is this necessary? - // - // painter->setRenderHint( QPainter::Antialiasing,true); - // painter->setRenderHint( QPainter::TextAntialiasing,true); - // painter->setRenderHint( QPainter::SmoothPixmapTransform,true); - // painter->setRenderHint( QPainter::HighQualityAntialiasing,true); - painter->drawPixmap(option.rect.topLeft(), pixmap /*,.scaled(option.rect.width(),option.rect.width()*w.height()/(float)w.width(),Qt::KeepAspectRatio,Qt::SmoothTransformation)*/); painter->restore(); } @@ -159,20 +130,10 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo // This is the only place where we actually set the size of cells RsPostedPost post = index.data(Qt::UserRole).value() ; - BoardPostDisplayWidget w(post,mDisplayMode); - //w.setMinimumWidth(mCellWidthPix); - //w.setMaximumWidth(mCellWidthPix); - w.adjustSize(); - QSize ss = cellSize(w.size()); - - std::cerr << "PostedPostDelegate::sizeHint(): w =" << w.width() << " x " << w.height() << " new size = " << ss.width() << " x " << ss.height() ; - w.setFixedSize(ss); - - std::cerr << " Final size:" << w.size() << std::endl; return w.size(); } @@ -184,12 +145,9 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie { QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent); - //w->setMinimumWidth(mCellWidthPix); - //w->setMaximumWidth(mCellWidthPix); w->adjustSize(); - w->setFixedSize(cellSize(w->size())); + w->setFixedSize(option.rect.size()); - std::cerr << "PostedPostDelegate::createEditor(): size = " << w->size() << std::endl; return w; } else @@ -208,7 +166,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI /* Invoke the Qt Designer generated object setup routine */ ui->setupUi(this); - ui->postsTree->setModel(mPostedPostsModel = new RsPostedPostsModel()); + ui->postsTree->setModel(mPostedPostsModel = new RsPostedPostsModel()); ui->postsTree->setItemDelegate(mPostedPostsDelegate = new PostedPostDelegate()); ui->postsTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // prevents bug on w10, since row size depends on widget width ui->postsTree->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);// more beautiful if we scroll at pixel level @@ -281,11 +239,13 @@ void PostedListWidgetWithModel::switchDisplayMode() { whileBlocking(ui->cardViewButton)->setChecked(false); mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT); + ui->postsTree->setUniformRowHeights(true); } else { whileBlocking(ui->classicViewButton)->setChecked(false); mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); + ui->postsTree->setUniformRowHeights(false); } mPostedPostsModel->deepUpdate(); From 4bc90ea9ad9b40e35b23263e72146e833a259624 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 11 Aug 2020 20:49:51 +0200 Subject: [PATCH 17/78] added photoview on click to compact view in boards --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 29 +++++++++++++++++++ .../src/gui/Posted/BoardPostDisplayWidget.h | 6 +++- .../src/gui/Posted/BoardPostDisplayWidget.ui | 7 ++++- retroshare-gui/src/util/ClickableLabel.cpp | 2 +- retroshare-gui/src/util/ClickableLabel.h | 7 +++-- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 77e7305fd..7be0a157a 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -25,6 +25,7 @@ #include "rshare.h" #include "BoardPostDisplayWidget.h" +#include "PhotoView.h" #include "gui/gxs/GxsIdDetails.h" #include "util/misc.h" #include "gui/common/FilesDefs.h" @@ -121,6 +122,31 @@ BoardPostDisplayWidget::~BoardPostDisplayWidget() delete(ui); } + +void BoardPostDisplayWidget::viewPicture() +{ + if(mPost.mImage.mData == NULL) + return; + + QString timestamp = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + RsGxsId authorID = mPost.mMeta.mAuthorId; + + PhotoView *PView = new PhotoView(this); + + PView->setPixmap(pixmap); + PView->setTitle(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); + PView->setName(authorID); + PView->setTime(timestamp); + PView->setGroupId(mPost.mMeta.mGroupId); + PView->setMessageId(mPost.mMeta.mMsgId); + + PView->show(); + + /* window will destroy itself! */ +} + void BoardPostDisplayWidget::toggleNotes() {} void BoardPostDisplayWidget::setup() @@ -380,6 +406,9 @@ void BoardPostDisplayWidget::setup() mInFill = false; #endif + ui->pictureLabel_compact->setUseStyleSheet(false); // If not this, causes dilation of the image. + connect(ui->pictureLabel_compact, SIGNAL(clicked()), this, SLOT(viewPicture())); + updateGeometry(); #ifdef TODO diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index d3acbc701..434e486d1 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -46,7 +46,11 @@ public: virtual ~BoardPostDisplayWidget(); static const char *DEFAULT_BOARD_IMAGE; -protected: + +public slots: + void viewPicture() ; + +protected slots: /* GxsGroupFeedItem */ virtual void setup(); // to be overloaded by the different views diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index ce9cf74ae..1c7f928db 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -132,7 +132,7 @@ - + PictureLabel_compact @@ -472,6 +472,11 @@ QLabel
gui/common/StyledLabel.h
+ + ClickableLabel + QLabel +
util/ClickableLabel.h
+
diff --git a/retroshare-gui/src/util/ClickableLabel.cpp b/retroshare-gui/src/util/ClickableLabel.cpp index 7b7ccb5fb..e12e01c8d 100644 --- a/retroshare-gui/src/util/ClickableLabel.cpp +++ b/retroshare-gui/src/util/ClickableLabel.cpp @@ -32,4 +32,4 @@ ClickableLabel::~ClickableLabel() { void ClickableLabel::mousePressEvent(QMouseEvent* event) { emit clicked(); -} \ No newline at end of file +} diff --git a/retroshare-gui/src/util/ClickableLabel.h b/retroshare-gui/src/util/ClickableLabel.h index 65070fd67..bd8c68ed8 100644 --- a/retroshare-gui/src/util/ClickableLabel.h +++ b/retroshare-gui/src/util/ClickableLabel.h @@ -32,16 +32,17 @@ public: explicit ClickableLabel(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()); ~ClickableLabel(); + void setUseStyleSheet(bool b){ mUseStyleSheet=b ; update();} signals: void clicked(); protected: void mousePressEvent(QMouseEvent* event); - void enterEvent(QEvent * /* ev */ ) override { setStyleSheet("QLabel { border: 2px solid #039bd5; }");} - - void leaveEvent(QEvent * /* ev */ ) override { setStyleSheet("QLabel { border: 2px solid #CCCCCC; border-radius: 3px; }");} + void enterEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #039bd5; }");} + void leaveEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #CCCCCC; border-radius: 3px; }");} + bool mUseStyleSheet; }; #endif // CLICKABLELABEL_H From 347b3ac9aa444b036548c3f253a332f456533480 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 11 Aug 2020 22:10:22 +0200 Subject: [PATCH 18/78] added mechanism for voting. Not working yet --- libretroshare/src/retroshare/rsposted.h | 2 ++ libretroshare/src/services/p3posted.cc | 6 ++++++ libretroshare/src/services/p3posted.h | 4 +++- .../gui/Posted/PostedListWidgetWithModel.cpp | 18 +++++++++++++++++- .../src/gui/Posted/PostedListWidgetWithModel.h | 1 + 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 4cd6e8cf4..71350a826 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -172,6 +172,8 @@ public: virtual bool getBoardsServiceStatistics(GxsServiceStatistic& stat) =0; + virtual bool voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMessageId& postMsgId,const RsGxsId& voterId) =0; + enum RS_DEPRECATED RankType {TopRankType, HotRankType, NewRankType }; RS_DEPRECATED_FOR(getBoardsInfo) diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index 88ff25808..39b350243 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -442,6 +442,12 @@ bool p3Posted::createBoard(RsPostedGroup& board) return true; } +bool p3Posted::voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMessageId& postMsgId,const RsGxsId& voterId) +{ + std::cerr << "(EE) " << __PRETTY_FUNCTION__ << ": Not implemented yet"<< std::endl; + return true; +} + bool p3Posted::editBoard(RsPostedGroup& board) { uint32_t token; diff --git a/libretroshare/src/services/p3posted.h b/libretroshare/src/services/p3posted.h index bc213ac0d..2bd3c3a0b 100644 --- a/libretroshare/src/services/p3posted.h +++ b/libretroshare/src/services/p3posted.h @@ -84,7 +84,9 @@ virtual void receiveHelperChanges(std::vector& changes) bool createBoard(RsPostedGroup& board) override; - virtual bool getGroupData(const uint32_t &token, std::vector &groups) override; + bool voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMessageId& postMsgId,const RsGxsId& voterId) override; + + virtual bool getGroupData(const uint32_t &token, std::vector &groups) override; virtual bool getPostData(const uint32_t &token, std::vector &posts, std::vector &cmts, std::vector &vots) override; virtual bool getPostData(const uint32_t &token, std::vector &posts, std::vector &cmts) override; virtual bool getPostData(const uint32_t &token, std::vector &posts) override; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 6373fa43a..f949a33f1 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -145,6 +145,8 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie { QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent); + QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),this,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); + w->adjustSize(); w->setFixedSize(option.rect.size()); @@ -176,6 +178,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI ui->postsTree->sortByColumn(0, Qt::AscendingOrder); ui->postsTree->setAutoSelect(true); + ui->idChooser->setFlags(IDCHOOSER_ID_REQUIRED); + connect(ui->sortStrategy_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(updateSorting(int))); connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(next10Posts())); connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts())); @@ -630,7 +634,7 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) ui->logoLabel->setPixmap(chanImage); ui->logoLabel->setFixedSize(QSize(ui->logoLabel->height()*chanImage.width()/(float)chanImage.height(),ui->logoLabel->height())); // make the logo have the same aspect ratio than the original image - ui->submitPostButton->setEnabled(bool(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)); + //ui->submitPostButton->setEnabled(bool(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)); ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); ui->subscribeToolButton->setEnabled(true); @@ -917,6 +921,18 @@ void PostedListWidgetWithModel::subscribeGroup(bool subscribe) } ); } +void PostedListWidgetWithModel::voteMsg(RsGxsGrpMsgIdPair msg,bool up_or_down) +{ + RsGxsId voter_id ; + if(ui->idChooser->getChosenId(voter_id) != GxsIdChooser::KnowId) + { + std::cerr << "(EE) No id returned by GxsIdChooser. Somthing's wrong?" << std::endl; + return; + } + + rsPosted->voteForPost(up_or_down,msg.first,msg.second,voter_id); +} + #ifdef TODO class PostedPostsReadData { diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index eef377233..f0218d942 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -135,6 +135,7 @@ private slots: public slots: void handlePostsTreeSizeChange(QSize size); + void voteMsg(RsGxsGrpMsgIdPair msg,bool up_or_down); private: void processSettings(bool load); From 20346fc30eda58532eea6a21530bfee7811ce492 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 12 Aug 2020 12:02:28 +0200 Subject: [PATCH 19/78] fixed voting in Boards --- libretroshare/src/services/p3posted.cc | 36 +++++++++++++++++-- libretroshare/src/services/p3posted.h | 6 ++-- .../gui/Posted/PostedListWidgetWithModel.cpp | 4 +-- .../gui/Posted/PostedListWidgetWithModel.h | 5 +-- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index 39b350243..50ff890f1 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -442,9 +442,41 @@ bool p3Posted::createBoard(RsPostedGroup& board) return true; } -bool p3Posted::voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMessageId& postMsgId,const RsGxsId& voterId) +bool p3Posted::voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMessageId& postMsgId,const RsGxsId& authorId) { - std::cerr << "(EE) " << __PRETTY_FUNCTION__ << ": Not implemented yet"<< std::endl; + // Do some basic tests + + if(!rsIdentity->isOwnId(authorId)) // This is ruled out before waitToken complains. Not sure it's needed. + { + std::cerr << __PRETTY_FUNCTION__ << ": vote submitted with an ID that is not yours! This cannot work." << std::endl; + return false; + } + + RsGxsVote vote; + + vote.mMeta.mGroupId = postGrpId; + vote.mMeta.mThreadId = postMsgId; + vote.mMeta.mParentId = postMsgId; + vote.mMeta.mAuthorId = authorId; + + if (up) + vote.mVoteType = GXS_VOTE_UP; + else + vote.mVoteType = GXS_VOTE_DOWN; + + uint32_t token; + + if(!createNewVote(token, vote)) + { + std::cerr << __PRETTY_FUNCTION__ << " Error! Failed submitting vote to (group,msg) " << postGrpId << "," << postMsgId << " from author " << authorId << std::endl; + return false; + } + + if(waitToken(token) != RsTokenService::COMPLETE) + { + std::cerr << __PRETTY_FUNCTION__ << " Error! GXS operation failed." << std::endl; + return false; + } return true; } diff --git a/libretroshare/src/services/p3posted.h b/libretroshare/src/services/p3posted.h index 2bd3c3a0b..005ed592a 100644 --- a/libretroshare/src/services/p3posted.h +++ b/libretroshare/src/services/p3posted.h @@ -128,17 +128,17 @@ virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgI return mCommentService->createGxsComment(token, msg) && waitToken(token) == RsTokenService::COMPLETE ; } - virtual bool createNewVote(uint32_t &token, RsGxsVote &msg) + virtual bool createNewVote(uint32_t &token, RsGxsVote &msg) override { return mCommentService->createGxsVote(token, msg); } virtual bool acknowledgeComment( - uint32_t token, std::pair& msgId ) + uint32_t token, std::pair& msgId ) override { return acknowledgeMsg(token, msgId); } virtual bool acknowledgeVote( - uint32_t token, std::pair& msgId ) + uint32_t token, std::pair& msgId ) override { if (mCommentService->acknowledgeVote(token, msgId)) return true; return acknowledgeMsg(token, msgId); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index f949a33f1..3dccf6e6f 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -145,7 +145,7 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie { QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent); - QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),this,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); + QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); w->adjustSize(); w->setFixedSize(option.rect.size()); @@ -169,7 +169,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI ui->setupUi(this); ui->postsTree->setModel(mPostedPostsModel = new RsPostedPostsModel()); - ui->postsTree->setItemDelegate(mPostedPostsDelegate = new PostedPostDelegate()); + ui->postsTree->setItemDelegate(mPostedPostsDelegate = new PostedPostDelegate(this)); ui->postsTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // prevents bug on w10, since row size depends on widget width ui->postsTree->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);// more beautiful if we scroll at pixel level ui->postsTree->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index f0218d942..30cd9d40a 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -38,13 +38,14 @@ class PostedListWidgetWithModel; class QTreeWidgetItem; class QSortFilterProxyModel; class RsPostedPostsModel; +class PostedListWidgetWithModel; class PostedPostDelegate: public QAbstractItemDelegate { Q_OBJECT public: - PostedPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT){} + PostedPostDelegate(PostedListWidgetWithModel *p,QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mPostListWidget(p),mDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT){} virtual ~PostedPostDelegate(){} void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; @@ -60,8 +61,8 @@ class PostedPostDelegate: public QAbstractItemDelegate private: QSize cellSize(const QSize& w) const; // Converts the supplied size to the cell size for the current container. // The client should then scale its widget to fit the given size. - int mCellWidthPix; + PostedListWidgetWithModel *mPostListWidget; // used for sending vote signals and so on. BoardPostDisplayWidget::DisplayMode mDisplayMode; }; From 2cce3963cbf86131be3075b7798aa9779ad2671c Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 12 Aug 2020 14:06:43 +0200 Subject: [PATCH 20/78] fixed expanding of compact items in boards --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 17 ++++++-- .../src/gui/Posted/BoardPostDisplayWidget.h | 5 ++- .../src/gui/Posted/BoardPostDisplayWidget.ui | 6 +++ .../gui/Posted/PostedListWidgetWithModel.cpp | 38 ++++++++++++------ .../gui/Posted/PostedListWidgetWithModel.h | 40 +++++++++++-------- 5 files changed, 70 insertions(+), 36 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 7be0a157a..73d323a58 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -47,8 +47,8 @@ const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2 //== Base class BoardPostDisplayWidget == //=================================================================================================================================== -BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode mode,QWidget *parent) - : QWidget(parent),mPost(post),dmode(mode),mExpanded(false),ui(new Ui::BoardPostDisplayWidget()) +BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode mode,bool expanded,QWidget *parent) + : QWidget(parent),mPost(post),dmode(mode),mExpanded(expanded),ui(new Ui::BoardPostDisplayWidget()) { ui->setupUi(this); setup(); @@ -167,12 +167,14 @@ void BoardPostDisplayWidget::setup() ui->frame_picture->show(); ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png"))); ui->expandButton->setToolTip(tr("Hide")); + ui->expandButton->setChecked(true); } else { ui->frame_picture->hide(); ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/expand.png"))); ui->expandButton->setToolTip(tr("Expand")); + ui->expandButton->setChecked(false); } } else @@ -190,9 +192,10 @@ void BoardPostDisplayWidget::setup() ui->fromLabel->clear(); ui->siteLabel->clear(); - connect(ui->commentButton, SIGNAL( clicked()), this, SLOT(loadComments())); + connect(ui->expandButton, SIGNAL(toggled(bool)), this, SLOT(doExpand(bool))); + connect(ui->commentButton, SIGNAL(clicked()), this, SLOT(loadComments())); connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); - connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote())); + connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT(makeDownVote())); connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); @@ -339,6 +342,7 @@ void BoardPostDisplayWidget::setup() // FIX THIS UP LATER. ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + ui->pictureLabel_2->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); QTextDocument doc; doc.setHtml(ui->notes->text()); @@ -416,4 +420,9 @@ void BoardPostDisplayWidget::setup() #endif } +void BoardPostDisplayWidget::doExpand(bool e) +{ + std::cerr << "Expanding" << std::endl; + emit expand(mPost.mMeta.mMsgId,e); +} diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 434e486d1..e262a77f4 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -42,7 +42,7 @@ public: DISPLAY_MODE_COMPACT = 0x02 }; - BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,QWidget *parent=nullptr); + BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,bool expanded,QWidget *parent=nullptr); virtual ~BoardPostDisplayWidget(); static const char *DEFAULT_BOARD_IMAGE; @@ -55,7 +55,7 @@ protected slots: virtual void setup(); // to be overloaded by the different views - void doExpand(bool) {} + void doExpand(bool) ; void setComment(const RsGxsComment&) ; void setReadStatus(bool isNew, bool isUnread) ; @@ -67,6 +67,7 @@ protected slots: signals: void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); + void expand(RsGxsMessageId,bool); protected: RsPostedPost mPost; diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index 1c7f928db..abf5a5785 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -303,6 +303,9 @@ :/images/expand.png:/images/expand.png
+ + true + true @@ -433,6 +436,9 @@ true + + true + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 3dccf6e6f..5f64f2bab 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -85,7 +85,7 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->fillRect( option.rect, option.backgroundBrush); painter->restore(); - BoardPostDisplayWidget w(post,mDisplayMode); + BoardPostDisplayWidget w(post,mDisplayMode,isExpanded(post.mMeta.mMsgId)); w.adjustSize(); w.setFixedSize(option.rect.size()); @@ -120,32 +120,43 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->restore(); } -QSize PostedPostDelegate::cellSize(const QSize& w) const -{ - return QSize(mCellWidthPix,mCellWidthPix * w.height()/(float)w.width()); -} - QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { // This is the only place where we actually set the size of cells RsPostedPost post = index.data(Qt::UserRole).value() ; - BoardPostDisplayWidget w(post,mDisplayMode); + BoardPostDisplayWidget w(post,mDisplayMode,isExpanded(post.mMeta.mMsgId)); w.adjustSize(); return w.size(); } +void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded) +{ + std::cerr << __PRETTY_FUNCTION__ << ": received expandItem signal. b=" << expanded << std::endl; + if(expanded) + mExpandedItems.insert(msgId); + else + mExpandedItems.erase(msgId); + + mPostListWidget->forceRedraw(); +} +bool PostedPostDelegate::isExpanded(const RsGxsMessageId &id) const +{ + return mExpandedItems.find(id) != mExpandedItems.end(); +} + QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const { RsPostedPost post = index.data(Qt::UserRole).value() ; if(index.column() == RsPostedPostsModel::COLUMN_POSTS) { - QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent); + QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,isExpanded(post.mMeta.mMsgId),parent); QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); + QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(expandItem(RsGxsMessageId,bool))); w->adjustSize(); w->setFixedSize(option.rect.size()); @@ -184,9 +195,6 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(next10Posts())); connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts())); - //connect(ui->channelPostFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnPostFiles(int,Qt::SortOrder))); - //connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder))); - connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&))); connect(ui->cardViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode())); connect(ui->classicViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode())); @@ -243,13 +251,11 @@ void PostedListWidgetWithModel::switchDisplayMode() { whileBlocking(ui->cardViewButton)->setChecked(false); mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT); - ui->postsTree->setUniformRowHeights(true); } else { whileBlocking(ui->classicViewButton)->setChecked(false); mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); - ui->postsTree->setUniformRowHeights(false); } mPostedPostsModel->deepUpdate(); @@ -514,6 +520,11 @@ void PostedListWidgetWithModel::postPostLoad() whileBlocking(ui->filter_LE)->setText(QString()); } +void PostedListWidgetWithModel::forceRedraw() +{ + if(mPostedPostsModel) + mPostedPostsModel->deepUpdate(); +} void PostedListWidgetWithModel::updateDisplay(bool complete) { #ifdef DEBUG_CHANNEL @@ -534,6 +545,7 @@ void PostedListWidgetWithModel::updateDisplay(bool complete) #endif complete = true; } + if(complete) // need to update the group data, reload the messages etc. { updateGroupData(); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 30cd9d40a..4e3f8171c 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -42,28 +42,33 @@ class PostedListWidgetWithModel; class PostedPostDelegate: public QAbstractItemDelegate { - Q_OBJECT + Q_OBJECT - public: - PostedPostDelegate(PostedListWidgetWithModel *p,QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mPostListWidget(p),mDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT){} - virtual ~PostedPostDelegate(){} +public: + PostedPostDelegate(PostedListWidgetWithModel *p,QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mPostListWidget(p),mDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT){} + virtual ~PostedPostDelegate(){} - void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; - void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override; - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - //int cellSize(const QFont& font) const; + void setCellWidth(int pix) { mCellWidthPix = pix; } + void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; } - void setCellWidth(int pix) { mCellWidthPix = pix; } - void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; } +public slots: + void expandItem(RsGxsMessageId msgId,bool expanded); - private: - QSize cellSize(const QSize& w) const; // Converts the supplied size to the cell size for the current container. - // The client should then scale its widget to fit the given size. - int mCellWidthPix; - PostedListWidgetWithModel *mPostListWidget; // used for sending vote signals and so on. - BoardPostDisplayWidget::DisplayMode mDisplayMode; +private: + // The class keeps a list of expanded items. Because items are constantly re-created, it is not possible + // to let the items themselves hold that information. + + bool isExpanded(const RsGxsMessageId& id) const; + + int mCellWidthPix; + PostedListWidgetWithModel *mPostListWidget; // used for sending vote signals and so on. + BoardPostDisplayWidget::DisplayMode mDisplayMode; + std::set mExpandedItems; }; class PostedListWidgetWithModel: public GxsMessageFrameWidget @@ -91,6 +96,7 @@ public: virtual bool navigate(const RsGxsMessageId&) override; void updateDisplay(bool complete) ; + void forceRedraw(); // does not re-load the data, but makes sure the underlying model triggers a full redraw, recomputes sizes, etc. #ifdef TODO /* FeedHolder */ From da200f1e1d9a318047782071ec935bceb7805360 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 12 Aug 2020 14:09:43 +0200 Subject: [PATCH 21/78] fixed layout in Boards --- .../src/gui/Posted/BoardPostDisplayWidget.ui | 32 ++++--------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index abf5a5785..3e43e9303 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -415,21 +415,14 @@ QFrame::Raised - - - - Qt::Horizontal - - - - 257 - 20 - - - - + + + 0 + 0 + + TextLabel @@ -444,19 +437,6 @@ - - - - Qt::Horizontal - - - - 257 - 20 - - - - From 2bdb38920093808d4b0f8b5357f5570838c29b0e Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 12 Aug 2020 22:40:01 +0200 Subject: [PATCH 22/78] added hide/unhide comments inside QTreeView --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 87 +++++++++---------- .../src/gui/Posted/BoardPostDisplayWidget.h | 12 ++- .../src/gui/Posted/BoardPostDisplayWidget.ui | 16 +++- .../gui/Posted/PostedListWidgetWithModel.cpp | 30 +++++-- .../gui/Posted/PostedListWidgetWithModel.h | 4 +- 5 files changed, 92 insertions(+), 57 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 73d323a58..b11413603 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -47,8 +47,8 @@ const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2 //== Base class BoardPostDisplayWidget == //=================================================================================================================================== -BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode mode,bool expanded,QWidget *parent) - : QWidget(parent),mPost(post),dmode(mode),mExpanded(expanded),ui(new Ui::BoardPostDisplayWidget()) +BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, DisplayMode mode, uint8_t display_flags, QWidget *parent) + : QWidget(parent),mPost(post),dmode(mode),mDisplayFlags(display_flags),ui(new Ui::BoardPostDisplayWidget()) { ui->setupUi(this); setup(); @@ -161,21 +161,6 @@ void BoardPostDisplayWidget::setup() ui->pictureLabel->hide(); ui->notes->hide(); ui->siteLabel->hide(); - - if(mExpanded) - { - ui->frame_picture->show(); - ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png"))); - ui->expandButton->setToolTip(tr("Hide")); - ui->expandButton->setChecked(true); - } - else - { - ui->frame_picture->hide(); - ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/expand.png"))); - ui->expandButton->setToolTip(tr("Expand")); - ui->expandButton->setChecked(false); - } } else { @@ -184,6 +169,29 @@ void BoardPostDisplayWidget::setup() ui->expandButton->hide(); } + if(mDisplayFlags & SHOW_NOTES) + { + ui->frame_picture->show(); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png"))); + ui->expandButton->setToolTip(tr("Hide")); + ui->expandButton->setChecked(true); + } + else + { + ui->frame_picture->hide(); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/expand.png"))); + ui->expandButton->setToolTip(tr("Expand")); + ui->expandButton->setChecked(false); + } + + if(!(mDisplayFlags & SHOW_COMMENTS)) + { + ui->commentsWidget->hide(); + ui->commentButton->setChecked(false); + } + else + ui->commentButton->setChecked(true); + setAttribute(Qt::WA_DeleteOnClose, true); /* clear ui */ @@ -193,7 +201,7 @@ void BoardPostDisplayWidget::setup() ui->siteLabel->clear(); connect(ui->expandButton, SIGNAL(toggled(bool)), this, SLOT(doExpand(bool))); - connect(ui->commentButton, SIGNAL(clicked()), this, SLOT(loadComments())); + connect(ui->commentButton, SIGNAL(toggled(bool)), this, SLOT(loadComments(bool))); connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT(makeDownVote())); connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); @@ -350,38 +358,21 @@ void BoardPostDisplayWidget::setup() if(doc.toPlainText().trimmed().isEmpty()) ui->notes->hide(); -#ifdef TO_REMOVE - // differences between Feed or Top of Comment. - if (mFeedHolder) + // feed. + //frame_comment->show(); + ui->commentButton->show(); + + if (mPost.mComments) { - // feed. - //frame_comment->show(); - ui->commentButton->show(); - - if (mPost.mComments) - { - QString commentText = QString::number(mPost.mComments); - commentText += " "; - commentText += tr("Comments"); - ui->commentButton->setText(commentText); - } - else - { - ui->commentButton->setText(tr("Comment")); - } - - setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); + QString commentText = QString::number(mPost.mComments); + commentText += " "; + commentText += tr("Comments"); + ui->commentButton->setText(commentText); } else -#endif - { - // no feed. - //frame_comment->hide(); - ui->commentButton->hide(); + ui->commentButton->setText(tr("Comment")); - ui->readButton->hide(); - ui->newLabel->hide(); - } + setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); // disable voting buttons - if they have already voted. if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) @@ -426,3 +417,7 @@ void BoardPostDisplayWidget::doExpand(bool e) emit expand(mPost.mMeta.mMsgId,e); } +void BoardPostDisplayWidget::loadComments(bool e) +{ + emit commentsRequested(mPost.mMeta.mMsgId,e); +} diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index e262a77f4..a8098ef02 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -42,7 +42,13 @@ public: DISPLAY_MODE_COMPACT = 0x02 }; - BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,bool expanded,QWidget *parent=nullptr); + enum DisplayFlags: uint8_t { + SHOW_NONE = 0x00, + SHOW_COMMENTS = 0x01, + SHOW_NOTES = 0x02, + }; + + BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,uint8_t display_flags,QWidget *parent=nullptr); virtual ~BoardPostDisplayWidget(); static const char *DEFAULT_BOARD_IMAGE; @@ -61,6 +67,7 @@ protected slots: void toggle() {} void setCommentsSize(int comNb) ; + void loadComments(bool e); void makeUpVote() ; void makeDownVote() ; void toggleNotes() ; @@ -68,12 +75,13 @@ protected slots: signals: void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); void expand(RsGxsMessageId,bool); + void commentsRequested(RsGxsMessageId,bool); protected: RsPostedPost mPost; DisplayMode dmode; - bool mExpanded; + uint8_t mDisplayFlags; private: /** Qt Designer generated object */ diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index 3e43e9303..2dbc0ca3b 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -7,7 +7,7 @@ 0 0 758 - 190 + 205 @@ -52,7 +52,7 @@ QFrame::Raised - + @@ -269,6 +269,9 @@ :/images/comments.png:/images/comments.png + + true + Qt::ToolButtonTextBesideIcon @@ -440,6 +443,9 @@ + + + @@ -463,6 +469,12 @@ QLabel
util/ClickableLabel.h
+ + GxsCommentDialog + QWidget +
gui/gxs/GxsCommentDialog.h
+ 1 +
diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 5f64f2bab..84ff81d75 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -85,7 +85,7 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->fillRect( option.rect, option.backgroundBrush); painter->restore(); - BoardPostDisplayWidget w(post,mDisplayMode,isExpanded(post.mMeta.mMsgId)); + BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId)); w.adjustSize(); w.setFixedSize(option.rect.size()); @@ -125,13 +125,12 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo // This is the only place where we actually set the size of cells RsPostedPost post = index.data(Qt::UserRole).value() ; - BoardPostDisplayWidget w(post,mDisplayMode,isExpanded(post.mMeta.mMsgId)); + BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId)); w.adjustSize(); return w.size(); } - void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded) { std::cerr << __PRETTY_FUNCTION__ << ": received expandItem signal. b=" << expanded << std::endl; @@ -142,9 +141,27 @@ void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded) mPostListWidget->forceRedraw(); } -bool PostedPostDelegate::isExpanded(const RsGxsMessageId &id) const +void PostedPostDelegate::commentItem(RsGxsMessageId msgId,bool comment) { - return mExpandedItems.find(id) != mExpandedItems.end(); + std::cerr << __PRETTY_FUNCTION__ << ": received commentItem signal. b=" << comment << std::endl; + if(comment) + mShowCommentItems.insert(msgId); + else + mShowCommentItems.erase(msgId); + + mPostListWidget->forceRedraw(); +} +uint8_t PostedPostDelegate::displayFlags(const RsGxsMessageId &id) const +{ + uint8_t flags=0; + + if(mExpandedItems.find(id) != mExpandedItems.end()) + flags |= BoardPostDisplayWidget::SHOW_NOTES; + + if(mShowCommentItems.find(id) != mShowCommentItems.end()) + flags |= BoardPostDisplayWidget::SHOW_COMMENTS; + + return flags; } QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const @@ -153,10 +170,11 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie if(index.column() == RsPostedPostsModel::COLUMN_POSTS) { - QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,isExpanded(post.mMeta.mMsgId),parent); + QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,displayFlags(post.mMeta.mMsgId),parent); QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(expandItem(RsGxsMessageId,bool))); + QObject::connect(w,SIGNAL(commentsRequested(RsGxsMessageId,bool)),this,SLOT(commentItem(RsGxsMessageId,bool))); w->adjustSize(); w->setFixedSize(option.rect.size()); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 4e3f8171c..60e2b510d 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -58,17 +58,19 @@ public: public slots: void expandItem(RsGxsMessageId msgId,bool expanded); + void commentItem(RsGxsMessageId msgId,bool comment); private: // The class keeps a list of expanded items. Because items are constantly re-created, it is not possible // to let the items themselves hold that information. - bool isExpanded(const RsGxsMessageId& id) const; + uint8_t displayFlags(const RsGxsMessageId& id) const; int mCellWidthPix; PostedListWidgetWithModel *mPostListWidget; // used for sending vote signals and so on. BoardPostDisplayWidget::DisplayMode mDisplayMode; std::set mExpandedItems; + std::set mShowCommentItems; }; class PostedListWidgetWithModel: public GxsMessageFrameWidget From 28568621a1123dcc378f89f9e09192de8f01ce06 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 13 Aug 2020 14:29:11 +0200 Subject: [PATCH 23/78] added proper loading of comments in Boards --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index b11413603..cd7187c03 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -58,6 +58,16 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, Display ui->topLayout->setAlignment(Qt::AlignTop); ui->arrowsLayout->addStretch(); ui->arrowsLayout->setAlignment(Qt::AlignTop); + + if(display_flags & SHOW_COMMENTS) + { + ui->commentsWidget->setTokenService(rsPosted->getTokenService(),rsPosted); + + std::set post_versions ; + post_versions.insert(post.mMeta.mMsgId) ; + + ui->commentsWidget->commentLoad(post.mMeta.mGroupId, post_versions,mPost.mMeta.mMsgId); + } } void BoardPostDisplayWidget::setCommentsSize(int comNb) From a129f6e6f950fbe17b31943fd66d237fbfe65a86 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 13 Aug 2020 21:06:48 +0200 Subject: [PATCH 24/78] centralized forceRedraw() in boards --- .../gui/Posted/PostedListWidgetWithModel.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 84ff81d75..f57ddf5f0 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -276,7 +276,7 @@ void PostedListWidgetWithModel::switchDisplayMode() mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); } - mPostedPostsModel->deepUpdate(); + forceRedraw(); } void PostedListWidgetWithModel::updateSorting(int s) @@ -541,8 +541,27 @@ void PostedListWidgetWithModel::postPostLoad() void PostedListWidgetWithModel::forceRedraw() { if(mPostedPostsModel) + { +// // Save selection. This can only be done using message Ids, because the QModelIndex-es can change after deepUpdate +// +// auto lst = ui->postsTree->selectionModel()->selectedRows(); +// std::set msgs; +// +// for(auto& index: lst) +// msgs.insert(index.data(Qt::UserRole).value().mMeta.mMsgId) ; + mPostedPostsModel->deepUpdate(); + +// // Restore selection +// +// for(auto& msgId: msgs) +// ui->postsTree->selectionModel()->select(mPostedPostsModel->getIndexOfMessage(msgId), QItemSelectionModel::ClearAndSelect); +// +// update(); +// ui->postsTree->update(); + } } + void PostedListWidgetWithModel::updateDisplay(bool complete) { #ifdef DEBUG_CHANNEL From 40acef3f70ec8295d7ca2b02bda04580c86581e7 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 13 Aug 2020 21:07:30 +0200 Subject: [PATCH 25/78] centralized forceRedraw() in boards --- .../gui/Posted/PostedListWidgetWithModel.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index f57ddf5f0..3b6bb3c43 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -541,25 +541,7 @@ void PostedListWidgetWithModel::postPostLoad() void PostedListWidgetWithModel::forceRedraw() { if(mPostedPostsModel) - { -// // Save selection. This can only be done using message Ids, because the QModelIndex-es can change after deepUpdate -// -// auto lst = ui->postsTree->selectionModel()->selectedRows(); -// std::set msgs; -// -// for(auto& index: lst) -// msgs.insert(index.data(Qt::UserRole).value().mMeta.mMsgId) ; - mPostedPostsModel->deepUpdate(); - -// // Restore selection -// -// for(auto& msgId: msgs) -// ui->postsTree->selectionModel()->select(mPostedPostsModel->getIndexOfMessage(msgId), QItemSelectionModel::ClearAndSelect); -// -// update(); -// ui->postsTree->update(); - } } void PostedListWidgetWithModel::updateDisplay(bool complete) From d91a2d31e8b376675d0185c9056d9338912bebe5 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 13 Sep 2020 00:25:13 +0200 Subject: [PATCH 26/78] fixed merge --- retroshare-gui/src/retroshare-gui.pro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index f3ef6895c..ab02f16a1 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1373,11 +1373,10 @@ gxschannels { gui/feeds/GxsChannelPostItem.ui SOURCES += gui/gxschannels/GxsChannelDialog.cpp \ - gui/gxschannels/GxsChannelPostsModel.cpp \ gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp \ + gui/gxschannels/GxsChannelPostsModel.cpp \ gui/gxschannels/GxsChannelPostFilesModel.cpp \ gui/gxschannels/GxsChannelFilesStatusWidget.cpp \ - gui/gxschannels/GxsChannelFilesWidget.cpp \ gui/gxschannels/GxsChannelPostThumbnail.cpp \ gui/gxschannels/GxsChannelGroupDialog.cpp \ gui/gxschannels/CreateGxsChannelMsg.cpp \ From 01683aac4ec2a15ae9cd5bff59e5a220adbb1b60 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 13 Sep 2020 20:15:52 +0200 Subject: [PATCH 27/78] always hide expand button since we have the photoview --- retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index cd7187c03..dcc590980 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -166,7 +166,8 @@ void BoardPostDisplayWidget::setup() if(dmode == DISPLAY_MODE_COMPACT) { ui->pictureLabel_compact->show(); - ui->expandButton->show(); + ui->expandButton->hide(); + //ui->expandButton->show(); // always hide, since we have the photoview already ui->pictureLabel->hide(); ui->notes->hide(); From a6a3bd3f0f823b12a9b397d37f790f7b3d805f7c Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 13 Sep 2020 20:32:56 +0200 Subject: [PATCH 28/78] fixed resizing of items when resizing the item list --- retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp | 2 ++ retroshare-gui/src/gui/Posted/PostedPostsModel.cpp | 5 +++++ retroshare-gui/src/gui/Posted/PostedPostsModel.h | 3 +++ 3 files changed, 10 insertions(+) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 3b6bb3c43..bcc7ae431 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -292,7 +292,9 @@ void PostedListWidgetWithModel::updateSorting(int s) void PostedListWidgetWithModel::handlePostsTreeSizeChange(QSize size) { + std::cerr << "resizing!"<< std::endl; mPostedPostsDelegate->setCellWidth(size.width()); + mPostedPostsModel->triggerRedraw(); } void PostedListWidgetWithModel::filterItems(QString text) diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index e05e52b70..751bd5db6 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -143,6 +143,11 @@ void RsPostedPostsModel::update() { emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL)); } +void RsPostedPostsModel::triggerRedraw() +{ + preMods(); + postMods(); +} void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count) { diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.h b/retroshare-gui/src/gui/Posted/PostedPostsModel.h index 948d892f4..c4233a689 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.h +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.h @@ -141,6 +141,9 @@ public: // Triggers a preMod, begin/end remove rows and data update. Could be useful if update is not enough to reset cell sizes. void deepUpdate(); + // same without data update, which is far less costly + void triggerRedraw(); + #ifdef TODO void setSortMode(SortMode mode) ; From 395435b5f3b483edff0f26273c2af8465ccf598a Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 13 Sep 2020 21:16:03 +0200 Subject: [PATCH 29/78] added code for showing author on people tab --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 20 +++++++++++++++++++ .../src/gui/Posted/BoardPostDisplayWidget.h | 1 + 2 files changed, 21 insertions(+) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index dcc590980..b1db550f9 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -31,6 +31,8 @@ #include "gui/common/FilesDefs.h" #include "util/qtthreadsutils.h" #include "util/HandleRichText.h" +#include "gui/Identity/IdDialog.h" +#include "gui/MainWindow.h" #include "ui_BoardPostDisplayWidget.h" @@ -432,3 +434,21 @@ void BoardPostDisplayWidget::loadComments(bool e) { emit commentsRequested(mPost.mMeta.mMsgId,e); } + +void BoardPostDisplayWidget::showAuthorInPeople() +{ + if(mPost.mMeta.mAuthorId.isNull()) + { + std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data..."; + std::cerr << std::endl; + } + + /* window will destroy itself! */ + IdDialog *idDialog = dynamic_cast(MainWindow::getPage(MainWindow::People)); + + if (!idDialog) + return ; + + MainWindow::showWindow(MainWindow::People); + idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId)); +} diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index a8098ef02..ce611011e 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -71,6 +71,7 @@ protected slots: void makeUpVote() ; void makeDownVote() ; void toggleNotes() ; + void showAuthorInPeople(); signals: void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); From 364e9ffdd241567a2a0507e40fcc02d13bfea280 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 13 Sep 2020 21:39:10 +0200 Subject: [PATCH 30/78] use single view mode button system, similar to channels --- .../gui/Posted/PostedListWidgetWithModel.cpp | 29 +++++++++++------- .../gui/Posted/PostedListWidgetWithModel.h | 1 + .../gui/Posted/PostedListWidgetWithModel.ui | 30 ++++--------------- 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index bcc7ae431..1e2c648b6 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -67,6 +67,10 @@ Q_DECLARE_METATYPE(RsPostedPost); // Delegate used to paint into the table of thumbnails +//=================================================================================================================================== +//== PostedPostDelegate == +//=================================================================================================================================== + std::ostream& operator<<(std::ostream& o,const QSize& s) { return o << s.width() << " x " << s.height() ; } void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const @@ -189,6 +193,10 @@ void PostedPostDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptio editor->setGeometry(option.rect); } +//=================================================================================================================================== +//== PostedListWidgetWithModel == +//=================================================================================================================================== + /** Constructor */ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedId, QWidget *parent) : GxsMessageFrameWidget(rsPosted, parent), @@ -214,8 +222,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts())); connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&))); - connect(ui->cardViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode())); - connect(ui->classicViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode())); + connect(ui->viewModeButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode())); connect(mPostedPostsModel,SIGNAL(boardPostsLoaded()),this,SLOT(postPostLoad())); @@ -251,9 +258,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI settingsChanged(); setGroupId(postedId); - ui->classicViewButton->setChecked(true); // inits both button checking consistency and delegate display mode variables. - - mPostedPostsModel->updateBoard(postedId); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); + switchDisplayMode(); // makes everything consistent and chooses classic view as default mEventHandlerId = 0; // Needs to be asynced because this function is called by another thread! @@ -265,18 +271,21 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI void PostedListWidgetWithModel::switchDisplayMode() { - if(sender() == ui->classicViewButton) + if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW) { - whileBlocking(ui->cardViewButton)->setChecked(false); + ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/classic.png")); + ui->viewModeButton->setToolTip(tr("Click to switch to card view")); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT); } else { - whileBlocking(ui->classicViewButton)->setChecked(false); + ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/card.png")); + ui->viewModeButton->setToolTip(tr("Click to switch to compact view")); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); } - - forceRedraw(); + mPostedPostsModel->triggerRedraw(); } void PostedListWidgetWithModel::updateSorting(int s) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 60e2b510d..71cedaec1 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -55,6 +55,7 @@ public: void setCellWidth(int pix) { mCellWidthPix = pix; } void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; } + BoardPostDisplayWidget::DisplayMode getDisplayMode() const { return mDisplayMode; } public slots: void expandItem(RsGxsMessageId msgId,bool expanded); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index a3c43aaa6..12601ee74 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -350,6 +350,9 @@ p, li { white-space: pre-wrap; } + + 1 + 24 @@ -411,7 +414,7 @@ p, li { white-space: pre-wrap; } 0 - + true @@ -438,29 +441,6 @@ p, li { white-space: pre-wrap; } - - - - Card View - - - - :/images/card.png:/images/card.png - - - - 24 - 24 - - - - true - - - true - - - @@ -561,8 +541,8 @@ p, li { white-space: pre-wrap; } - + From 0e4d438066fb45929b01d88d98cfd00247a082f7 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 17 Sep 2020 21:08:07 +0200 Subject: [PATCH 31/78] fixed model update when new vote is posted by user --- libretroshare/src/gxs/rsgxsnotify.h | 2 +- libretroshare/src/retroshare/rsposted.h | 2 + libretroshare/src/services/p3postbase.cc | 171 ++++++++++-------- .../src/gui/Posted/PostedPostsModel.cpp | 11 +- 4 files changed, 108 insertions(+), 78 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsnotify.h b/libretroshare/src/gxs/rsgxsnotify.h index a6fd4c6fb..71db32ebc 100644 --- a/libretroshare/src/gxs/rsgxsnotify.h +++ b/libretroshare/src/gxs/rsgxsnotify.h @@ -48,7 +48,7 @@ public: TYPE_UPDATED = 0x07, TYPE_MESSAGE_DELETED = 0x08, TYPE_GROUP_DELETED = 0x09, - }; + }; virtual NotifyType getType() = 0; diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 71350a826..142707eb7 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -115,6 +115,7 @@ enum class RsPostedEventCode: uint8_t UPDATED_MESSAGE = 0x05, READ_STATUS_CHANGED = 0x06, STATISTICS_CHANGED = 0x07, + MESSAGE_VOTES_UPDATED = 0x08, }; @@ -127,6 +128,7 @@ struct RsGxsPostedEvent: RsEvent RsPostedEventCode mPostedEventCode; RsGxsGroupId mPostedGroupId; RsGxsMessageId mPostedMsgId; + RsGxsMessageId mPostedThreadId; ///* @see RsEvent @see RsSerializable void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override diff --git a/libretroshare/src/services/p3postbase.cc b/libretroshare/src/services/p3postbase.cc index c4c96f3b5..5c25ca52c 100644 --- a/libretroshare/src/services/p3postbase.cc +++ b/libretroshare/src/services/p3postbase.cc @@ -38,6 +38,7 @@ /**** * #define POSTBASE_DEBUG 1 ****/ +#define POSTBASE_DEBUG 1 #define POSTBASE_BACKGROUND_PROCESSING 0x0002 #define PROCESSING_START_PERIOD 30 @@ -88,101 +89,123 @@ void p3PostBase::notifyChanges(std::vector &changes) #endif for(auto it = changes.begin(); it != changes.end(); ++it) - { - RsGxsMsgChange *msgChange = dynamic_cast(*it); + { + RsGxsMsgChange *msgChange = dynamic_cast(*it); - if (msgChange) - { + if(msgChange) + { + // To start with we are just going to trigger updates on these groups. + // FUTURE OPTIMISATION. + // It could be taken a step further and directly request these msgs for an update. + addGroupForProcessing(msgChange->mGroupId); + + if (rsEvents) + { + switch(msgChange->getType()) + { + case RsGxsNotify::TYPE_RECEIVED_NEW: + case RsGxsNotify::TYPE_PUBLISHED: + { + auto ev = std::make_shared(); + ev->mPostedMsgId = msgChange->mMsgId; + ev->mPostedThreadId = msgChange->mNewMsgItem->meta.mThreadId; + ev->mPostedGroupId = msgChange->mGroupId; + ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE; + rsEvents->postEvent(ev); #ifdef POSTBASE_DEBUG - std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification"; - std::cerr << std::endl; + std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification: NEW/PUBLISHED ID=" << msgChange->mMsgId << " in group " << msgChange->mGroupId << ", thread ID = " << msgChange->mNewMsgItem->meta.mThreadId << std::endl; #endif + } + break; + + case RsGxsNotify::TYPE_PROCESSED: + { + auto ev = std::make_shared(); + ev->mPostedMsgId = msgChange->mMsgId; + ev->mPostedGroupId = msgChange->mGroupId; + ev->mPostedEventCode = RsPostedEventCode::MESSAGE_VOTES_UPDATED; + rsEvents->postEvent(ev); #ifdef POSTBASE_DEBUG - std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first; - std::cerr << std::endl; + std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification: PROCESSED ID=" << msgChange->mMsgId << " in group " << msgChange->mGroupId << std::endl; #endif - // To start with we are just going to trigger updates on these groups. - // FUTURE OPTIMISATION. - // It could be taken a step further and directly request these msgs for an update. - addGroupForProcessing(msgChange->mGroupId); - - if (rsEvents && (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW || msgChange->getType() == RsGxsNotify::TYPE_PUBLISHED)) - { - auto ev = std::make_shared(); - ev->mPostedMsgId = msgChange->mMsgId; - ev->mPostedGroupId = msgChange->mGroupId; - ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE; - rsEvents->postEvent(ev); - } - } - - RsGxsGroupChange *grpChange = dynamic_cast(*it); - - /* pass on Group Changes to GUI */ - if (grpChange && rsEvents) - { + } + break; + default: #ifdef POSTBASE_DEBUG - std::cerr << "p3PostBase::notifyChanges() Found Group Change Notification"; - std::cerr << std::endl; + std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification: type " << msgChange->getType() << " (ignored) " << msgChange->mMsgId << std::endl; +#endif + break; + } + } + } + + RsGxsGroupChange *grpChange = dynamic_cast(*it); + + /* pass on Group Changes to GUI */ + if (grpChange && rsEvents) + { +#ifdef POSTBASE_DEBUG + std::cerr << "p3PostBase::notifyChanges() Found Group Change Notification"; + std::cerr << std::endl; #endif const RsGxsGroupId& group_id(grpChange->mGroupId); switch(grpChange->getType()) - { - case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed - { - auto ev = std::make_shared(); - ev->mPostedGroupId = group_id; - ev->mPostedEventCode = RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED; - rsEvents->postEvent(ev); - } - break; + { + case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed + { + auto ev = std::make_shared(); + ev->mPostedGroupId = group_id; + ev->mPostedEventCode = RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED; + rsEvents->postEvent(ev); + } + break; - case RsGxsNotify::TYPE_STATISTICS_CHANGED: - { - auto ev = std::make_shared(); - ev->mPostedGroupId = group_id; - ev->mPostedEventCode = RsPostedEventCode::STATISTICS_CHANGED; - rsEvents->postEvent(ev); - } - break; + case RsGxsNotify::TYPE_STATISTICS_CHANGED: + { + auto ev = std::make_shared(); + ev->mPostedGroupId = group_id; + ev->mPostedEventCode = RsPostedEventCode::STATISTICS_CHANGED; + rsEvents->postEvent(ev); + } + break; - case RsGxsNotify::TYPE_PUBLISHED: - case RsGxsNotify::TYPE_RECEIVED_NEW: - { - /* group received */ + case RsGxsNotify::TYPE_PUBLISHED: + case RsGxsNotify::TYPE_RECEIVED_NEW: + { + /* group received */ - if(mKnownPosted.find(group_id) == mKnownPosted.end()) - { - mKnownPosted.insert(std::make_pair(group_id, time(nullptr))); - IndicateConfigChanged(); + if(mKnownPosted.find(group_id) == mKnownPosted.end()) + { + mKnownPosted.insert(std::make_pair(group_id, time(nullptr))); + IndicateConfigChanged(); - auto ev = std::make_shared(); - ev->mPostedGroupId = group_id; - ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP; - rsEvents->postEvent(ev); + auto ev = std::make_shared(); + ev->mPostedGroupId = group_id; + ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP; + rsEvents->postEvent(ev); #ifdef POSTBASE_DEBUG - std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << group_id; - std::cerr << std::endl; + std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << group_id; + std::cerr << std::endl; #endif - } - else - RsInfo() << __PRETTY_FUNCTION__ - << " Not notifying already known forum " - << group_id << std::endl; - } - break; + } + else + RsInfo() << __PRETTY_FUNCTION__ + << " Not notifying already known forum " + << group_id << std::endl; + } + break; - default: - RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl; - break; - } - } + default: + RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl; + break; + } + } delete *it; - } + } } void p3PostBase::service_tick() diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index 751bd5db6..94eea0ae1 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -53,7 +53,7 @@ RsPostedPostsModel::RsPostedPostsModel(QObject *parent) rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); - }, mEventHandlerId, RsEventType::GXS_CHANNELS ); + }, mEventHandlerId, RsEventType::GXS_POSTED); } RsPostedPostsModel::~RsPostedPostsModel() @@ -71,7 +71,9 @@ void RsPostedPostsModel::handleEvent_main_thread(std::shared_ptr switch(e->mPostedEventCode) { case RsPostedEventCode::UPDATED_MESSAGE: - case RsPostedEventCode::READ_STATUS_CHANGED: + case RsPostedEventCode::READ_STATUS_CHANGED: + case RsPostedEventCode::MESSAGE_VOTES_UPDATED: + case RsPostedEventCode::NEW_MESSAGE: { // Normally we should just emit dataChanged() on the index of the data that has changed: // @@ -105,7 +107,10 @@ void RsPostedPostsModel::handleEvent_main_thread(std::shared_ptr { mPosts[j] = posts[i]; - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL)); + //emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL)); + + preMods(); + postMods(); } } },this); From a14269489649c9d62f60a574305d63bcc06d6222 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 18 Sep 2020 21:59:57 +0200 Subject: [PATCH 32/78] preserve sorting strategy when updating posts --- .../gui/Posted/PostedListWidgetWithModel.cpp | 7 ++++--- .../gui/Posted/PostedListWidgetWithModel.ui | 20 +++++++++---------- .../src/gui/Posted/PostedPostsModel.cpp | 5 ++++- .../src/gui/Posted/PostedPostsModel.h | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 1e2c648b6..08295926d 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -260,6 +260,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); switchDisplayMode(); // makes everything consistent and chooses classic view as default + updateSorting(ui->sortStrategy_CB->currentIndex()); mEventHandlerId = 0; // Needs to be asynced because this function is called by another thread! @@ -293,9 +294,9 @@ void PostedListWidgetWithModel::updateSorting(int s) switch(s) { default: - case 0: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_HOT_SCORE); break; - case 1: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_NEW_SCORE); break; - case 2: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_TOP_SCORE); break; + case 0: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_NEW_SCORE); break; + case 1: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_TOP_SCORE); break; + case 2: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_HOT_SCORE); break; } } diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 12601ee74..2c866ac4b 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -351,7 +351,7 @@ p, li { white-space: pre-wrap; } - 1 + 0 @@ -359,15 +359,6 @@ p, li { white-space: pre-wrap; } 24 - - - Hot - - - - :/icons/png/flame.png:/icons/png/flame.png - - New @@ -386,6 +377,15 @@ p, li { white-space: pre-wrap; } :/icons/png/top.png:/icons/png/top.png + + + Hot + + + + :/icons/png/flame.png:/icons/png/flame.png + + diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index 94eea0ae1..43f87e6ab 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -48,6 +48,8 @@ RsPostedPostsModel::RsPostedPostsModel(QObject *parent) initEmptyHierarchy(); mEventHandlerId = 0; + mSortingStrategy = SORT_NEW_SCORE; + // Needs to be asynced because this function is called by another thread! rsEvents->registerEventsHandler( [this](std::shared_ptr event) @@ -473,6 +475,7 @@ void RsPostedPostsModel::setSortingStrategy(RsPostedPostsModel::SortingStrategy { preMods(); + mSortingStrategy = s; std::sort(mPosts.begin(),mPosts.end(), PostSorter(s)); postMods(); @@ -517,7 +520,7 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector mFilteredPosts; uint32_t mDisplayedStartIndex; uint32_t mDisplayedNbPosts; - + SortingStrategy mSortingStrategy; RsEventsHandlerId_t mEventHandlerId ; }; From c7bc7e814b8ee499401ff4e49c2c8cd86ed6a0e4 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 18 Sep 2020 23:12:48 +0200 Subject: [PATCH 33/78] added a cache for comments in comment tree widget to make loading synchronous when necessary --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 2 +- .../src/gui/gxs/GxsCommentDialog.cpp | 5 ++- retroshare-gui/src/gui/gxs/GxsCommentDialog.h | 2 +- .../src/gui/gxs/GxsCommentTreeWidget.cpp | 43 ++++++++++++++++--- .../src/gui/gxs/GxsCommentTreeWidget.h | 7 ++- 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index b1db550f9..51b2f7b7b 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -68,7 +68,7 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, Display std::set post_versions ; post_versions.insert(post.mMeta.mMsgId) ; - ui->commentsWidget->commentLoad(post.mMeta.mGroupId, post_versions,mPost.mMeta.mMsgId); + ui->commentsWidget->commentLoad(post.mMeta.mGroupId, post_versions,mPost.mMeta.mMsgId,true); } } diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp index 43dc43d13..01455e6a3 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp @@ -84,7 +84,7 @@ GxsCommentDialog::~GxsCommentDialog() delete(ui); } -void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const std::set& msg_versions,const RsGxsMessageId& most_recent_msgId) +void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const std::set& msg_versions,const RsGxsMessageId& most_recent_msgId,bool use_cache) { std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", most recent msg version: " << most_recent_msgId << ")"; std::cerr << std::endl; @@ -93,7 +93,8 @@ void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const std::settreeWidget->requestComments(mGrpId,msg_versions,most_recent_msgId); + ui->treeWidget->setUseCache(use_cache); + ui->treeWidget->requestComments(mGrpId,msg_versions,most_recent_msgId); } void GxsCommentDialog::notifyCommentsLoaded(int n) diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h index 00982fdbb..b07568eda 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h @@ -38,7 +38,7 @@ public: void setTokenService(RsTokenService *token_service, RsGxsCommentService *comment_service); void setCommentHeader(QWidget *header); - void commentLoad(const RsGxsGroupId &grpId, const std::set &msg_versions, const RsGxsMessageId &most_recent_msgId); + void commentLoad(const RsGxsGroupId &grpId, const std::set &msg_versions, const RsGxsMessageId &most_recent_msgId, bool use_cache=false); RsGxsGroupId groupId() { return mGrpId; } RsGxsMessageId messageId() { return mMostRecentMsgId; } diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index cc2087044..35b56ae19 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -64,6 +64,9 @@ #define IMAGE_VOTEUP ":/images/vote_up.png" #define IMAGE_VOTEDOWN ":/images/vote_down.png" +std::map > GxsCommentTreeWidget::mCommentsCache; +QMutex GxsCommentTreeWidget::mCacheMutex; + // This class allows to draw the item using an appropriate size class MultiLinesCommentDelegate: public QStyledItemDelegate @@ -148,6 +151,8 @@ GxsCommentTreeWidget::GxsCommentTreeWidget(QWidget *parent) commentsRole = new RSTreeWidgetItemCompareRole; commentsRole->setRole(PCITEM_COLUMN_DATE, ROLE_SORT); + mUseCache = false; + // QFont font = QFont("ARIAL", 10); // font.setBold(true); @@ -362,6 +367,19 @@ void GxsCommentTreeWidget::requestComments(const RsGxsGroupId& group, const std: mMsgVersions = message_versions ; mLatestMsgId = most_recent_message; + if(mUseCache) + { + QMutexLocker lock(&mCacheMutex); + + auto it = mCommentsCache.find(most_recent_message); + + if(it != mCommentsCache.end()) + { + std::cerr << "Got " << it->second.size() << " comments from cache." << std::endl; + insertComments(it->second); + completeItems(); + } + } service_requestComments(group,message_versions); } @@ -581,11 +599,28 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token) std::vector comments; mCommentService->getRelatedComments(token, comments); - std::vector::iterator vit; + // This is inconsistent since we cannot know here that all comments are for the same thread. However they are only + // requested in requestComments() where a single MsgId is used. - for(vit = comments.begin(); vit != comments.end(); ++vit) + if(mUseCache) + { + QMutexLocker lock(&mCacheMutex); + + if(!comments.empty()) + { + std::cerr << "Updating cache with " << comments.size() << " for thread " << comments[0].mMeta.mThreadId << std::endl; + mCommentsCache[comments[0].mMeta.mThreadId] = comments; + } + } + + insertComments(comments); +} + +void GxsCommentTreeWidget::insertComments(const std::vector& comments) +{ + for(auto vit = comments.begin(); vit != comments.end(); ++vit) { - RsGxsComment &comment = *vit; + const RsGxsComment &comment = *vit; /* convert to a QTreeWidgetItem */ std::cerr << "GxsCommentTreeWidget::service_loadThread() Got Comment: " << comment.mMeta.mMsgId; std::cerr << std::endl; @@ -636,8 +671,6 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token) addItem(comment.mMeta.mMsgId, comment.mMeta.mParentId, item); } - - return; } QTreeWidgetItem *GxsCommentTreeWidget::service_createMissingItem(const RsGxsMessageId& parent) diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h index cdf6063af..7aef13337 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h @@ -22,6 +22,7 @@ #define _GXS_COMMENT_TREE_WIDGET_H #include +#include #include "util/TokenQueue.h" #include @@ -45,6 +46,7 @@ public: void loadRequest(const TokenQueue *queue, const TokenRequest &req); void setVoteId(const RsGxsId &voterId); + void setUseCache(bool b) { mUseCache = b ;} protected: /* to be overloaded */ @@ -60,8 +62,8 @@ protected: void loadThread(const uint32_t &token); + void insertComments(const std::vector& comments); void addItem(RsGxsMessageId itemId, RsGxsMessageId parentId, QTreeWidgetItem *item); - public slots: void customPopUpMenu(const QPoint& point); void setCurrentCommentMsgId(QTreeWidgetItem* current, QTreeWidgetItem* previous); @@ -108,6 +110,9 @@ protected: RsTokenService *mRsTokenService; RsGxsCommentService *mCommentService; + bool mUseCache; + static std::map > mCommentsCache; + static QMutex mCacheMutex; }; From f64482e3ddce5c1cc6827c9301c20702c1ccc41d Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 19 Sep 2020 22:32:19 +0200 Subject: [PATCH 34/78] switched to using tabs for comments in order to have more room. Layout still not working --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 41 +++++++++-- .../src/gui/Posted/BoardPostDisplayWidget.h | 11 +-- .../gui/Posted/PostedListWidgetWithModel.cpp | 69 +++++++++++++++---- .../gui/Posted/PostedListWidgetWithModel.h | 6 +- .../gui/Posted/PostedListWidgetWithModel.ui | 11 ++- 5 files changed, 110 insertions(+), 28 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 51b2f7b7b..ca84a8d25 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -55,11 +55,16 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, Display ui->setupUi(this); setup(); - ui->verticalLayout->addStretch(); + if(mode != DISPLAY_MODE_COMMENTS) + ui->verticalLayout->addStretch(); + else + ui->commentsWidget->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); + ui->verticalLayout->setAlignment(Qt::AlignTop); ui->topLayout->setAlignment(Qt::AlignTop); ui->arrowsLayout->addStretch(); ui->arrowsLayout->setAlignment(Qt::AlignTop); + ui->verticalLayout_2->addStretch(); if(display_flags & SHOW_COMMENTS) { @@ -165,7 +170,10 @@ void BoardPostDisplayWidget::setup() { // show/hide things based on the view type - if(dmode == DISPLAY_MODE_COMPACT) + switch(dmode) + { + default: + case DISPLAY_MODE_COMPACT: { ui->pictureLabel_compact->show(); ui->expandButton->hide(); @@ -175,12 +183,34 @@ void BoardPostDisplayWidget::setup() ui->notes->hide(); ui->siteLabel->hide(); } - else + break; + case DISPLAY_MODE_COMMENTS: + { + ui->pictureLabel_compact->show(); + ui->expandButton->hide(); + ui->pictureLabel->hide(); + ui->notes->hide(); + ui->scoreLabel->hide(); + ui->voteDownButton->hide(); + ui->voteUpButton->hide(); + ui->siteLabel->hide(); + ui->newLabel->hide(); + ui->commentButton->hide(); + ui->expandButton->hide(); + ui->shareButton->hide(); + ui->readButton->hide(); + ui->newLabel->hide(); + } + break; + case DISPLAY_MODE_CARD_VIEW: { ui->frame_picture->hide(); ui->pictureLabel_compact->hide(); ui->expandButton->hide(); } + break; + } + if(mDisplayFlags & SHOW_NOTES) { @@ -311,7 +341,7 @@ void BoardPostDisplayWidget::setup() ui->siteLabel->setText(sitestr); - if(dmode == DISPLAY_MODE_COMPACT) + if(dmode == DISPLAY_MODE_COMPACT || dmode == DISPLAY_MODE_COMMENTS) { if(mPost.mImage.mData != NULL) { @@ -373,7 +403,8 @@ void BoardPostDisplayWidget::setup() // feed. //frame_comment->show(); - ui->commentButton->show(); + if(dmode != DISPLAY_MODE_COMMENTS) + ui->commentButton->show(); if (mPost.mComments) { diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index ce611011e..d8ce2d568 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -39,13 +39,14 @@ public: enum DisplayMode { DISPLAY_MODE_UNKNOWN = 0x00, DISPLAY_MODE_CARD_VIEW = 0x01, - DISPLAY_MODE_COMPACT = 0x02 + DISPLAY_MODE_COMPACT = 0x02, + DISPLAY_MODE_COMMENTS = 0x03, }; enum DisplayFlags: uint8_t { - SHOW_NONE = 0x00, - SHOW_COMMENTS = 0x01, - SHOW_NOTES = 0x02, + SHOW_NONE = 0x00, + SHOW_COMMENTS = 0x01, + SHOW_NOTES = 0x02, }; BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,uint8_t display_flags,QWidget *parent=nullptr); @@ -76,7 +77,7 @@ protected slots: signals: void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); void expand(RsGxsMessageId,bool); - void commentsRequested(RsGxsMessageId,bool); + void commentsRequested(const RsGxsMessageId&,bool); protected: RsPostedPost mPost; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 08295926d..d6f5dbe4a 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -32,6 +32,7 @@ #include "util/misc.h" #include "gui/Posted/PostedCreatePostDialog.h" #include "gui/common/UIStateHelper.h" +#include "gui/common/RSTabWidget.h" #include "gui/settings/rsharesettings.h" #include "gui/feeds/SubFileItem.h" #include "gui/notifyqt.h" @@ -91,8 +92,8 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId)); - w.adjustSize(); w.setFixedSize(option.rect.size()); + w.adjustSize(); QPixmap pixmap(option.rect.size()); @@ -145,16 +146,16 @@ void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded) mPostListWidget->forceRedraw(); } -void PostedPostDelegate::commentItem(RsGxsMessageId msgId,bool comment) -{ - std::cerr << __PRETTY_FUNCTION__ << ": received commentItem signal. b=" << comment << std::endl; - if(comment) - mShowCommentItems.insert(msgId); - else - mShowCommentItems.erase(msgId); - - mPostListWidget->forceRedraw(); -} +// void PostedPostDelegate::commentItem(RsGxsMessageId msgId,bool comment) +// { +// std::cerr << __PRETTY_FUNCTION__ << ": received commentItem signal. b=" << comment << std::endl; +// if(comment) +// mShowCommentItems.insert(msgId); +// else +// mShowCommentItems.erase(msgId); +// +// mPostListWidget->forceRedraw(); +// } uint8_t PostedPostDelegate::displayFlags(const RsGxsMessageId &id) const { uint8_t flags=0; @@ -178,10 +179,10 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(expandItem(RsGxsMessageId,bool))); - QObject::connect(w,SIGNAL(commentsRequested(RsGxsMessageId,bool)),this,SLOT(commentItem(RsGxsMessageId,bool))); + QObject::connect(w,SIGNAL(commentsRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(openComments(const RsGxsMessageId&))); - w->adjustSize(); w->setFixedSize(option.rect.size()); + w->adjustSize(); return w; } @@ -217,6 +218,10 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI ui->idChooser->setFlags(IDCHOOSER_ID_REQUIRED); + connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int))); + ui->tabWidget->hideCloseButton(0); + ui->tabWidget->hideCloseButton(1); + connect(ui->sortStrategy_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(updateSorting(int))); connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(next10Posts())); connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts())); @@ -522,6 +527,9 @@ void PostedListWidgetWithModel::updateGroupData() insertBoardDetails(mGroup); + while(ui->tabWidget->widget(2) != nullptr) + tabCloseRequested(2); + emit groupDataLoaded(); emit groupChanged(this); // signals the parent widget to e.g. update the group tab name } ); @@ -637,9 +645,40 @@ void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token) std::cerr << __PRETTY_FUNCTION__ << ": not implemented" << std::endl; } -void PostedListWidgetWithModel::openComments(uint32_t /*type*/, const RsGxsGroupId &groupId, const QVector& msg_versions,const RsGxsMessageId &msgId, const QString &title) +void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId) { - emit loadComment(groupId, msg_versions,msgId, title); + QModelIndex index = mPostedPostsModel->getIndexOfMessage(msgId); + + if(!index.isValid()) + return; + + RsPostedPost post = index.data(Qt::UserRole).value() ; + BoardPostDisplayWidget *w = new BoardPostDisplayWidget(post,BoardPostDisplayWidget::DISPLAY_MODE_COMMENTS,BoardPostDisplayWidget::SHOW_COMMENTS); + + QString title = QString::fromUtf8(post.mMeta.mMsgName.c_str()); + if(title.length() > 30) + title = title.left(27) + "..."; + + ui->tabWidget->addTab(w,title); + ui->tabWidget->layout(); +} + +void PostedListWidgetWithModel::tabCloseRequested(int index) +{ + std::cerr << "GxsCommentContainer::tabCloseRequested(" << index << ")"; + std::cerr << std::endl; + + if (index != 0) + { + QWidget *comments = ui->tabWidget->widget(index); + ui->tabWidget->removeTab(index); + delete comments; + } + else + { + std::cerr << "GxsCommentContainer::tabCloseRequested() Not closing First Tab"; + std::cerr << std::endl; + } } void PostedListWidgetWithModel::createMsg() diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 71cedaec1..29c790a36 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -59,7 +59,7 @@ public: public slots: void expandItem(RsGxsMessageId msgId,bool expanded); - void commentItem(RsGxsMessageId msgId,bool comment); + //void commentItem(RsGxsMessageId msgId,bool comment); private: // The class keeps a list of expanded items. Because items are constantly re-created, it is not possible @@ -107,7 +107,8 @@ public: virtual void deleteFeedItem(FeedItem *feedItem, uint32_t type); virtual void openChat(const RsPeerId& peerId); #endif - virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector &msg_versions, const RsGxsMessageId &msgId, const QString &title); +public slots: + virtual void openComments(const RsGxsMessageId &msgId); protected: /* GxsMessageFramePostWidget */ @@ -130,6 +131,7 @@ protected: virtual void setAllMessagesReadDo(bool read, uint32_t &token) override; private slots: + void tabCloseRequested(int index); void updateSorting(int); void switchDisplayMode(); void updateGroupData(); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 2c866ac4b..33bb2cfdd 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -15,10 +15,13 @@ - + 1 + + true + Details @@ -539,6 +542,12 @@ p, li { white-space: pre-wrap; } QComboBox
gui/gxs/GxsIdChooser.h
+ + RSTabWidget + QTabWidget +
gui/common/RSTabWidget.h
+ 1 +
From 841152fb905e6c89c3adba0f484d6b2cc179b07a Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 20 Sep 2020 11:50:57 +0200 Subject: [PATCH 35/78] unsuccessful attempt to fix sizes --- .../src/gui/Posted/BoardPostDisplayWidget.ui | 21 +++++++++++++++---- .../src/gui/gxs/GxsCommentDialog.ui | 12 +++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index 2dbc0ca3b..7fde763f4 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -7,7 +7,7 @@ 0 0 758 - 205 + 211 @@ -41,7 +41,7 @@ - + 0 0 @@ -133,6 +133,12 @@ + + + 0 + 0 + + PictureLabel_compact @@ -444,7 +450,14 @@ - + + + + 0 + 1 + + +
@@ -477,8 +490,8 @@ - + diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui index c349c6eb7..0328eef9f 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui @@ -10,6 +10,12 @@ 547 + + + 0 + 0 + + Form @@ -143,6 +149,12 @@ + + + 0 + 0 + + true From 1f253f6bfa7f33052e6a13920cbfac4a01ef74dc Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 20 Sep 2020 21:46:31 +0200 Subject: [PATCH 36/78] using a simple comments tree in tab in order to avoid layout problems --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 29 +---- .../src/gui/Posted/BoardPostDisplayWidget.h | 1 - .../src/gui/Posted/BoardPostDisplayWidget.ui | 2 +- .../gui/Posted/PostedListWidgetWithModel.cpp | 9 +- .../src/gui/gxs/GxsCommentDialog.cpp | 4 +- .../src/gui/gxs/GxsCommentDialog.ui | 100 +++++++----------- .../GxsChannelPostsWidgetWithModel.ui | 18 ++-- retroshare-gui/src/retroshare-gui.pro | 2 +- 8 files changed, 60 insertions(+), 105 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index ca84a8d25..ca8ea4850 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -55,11 +55,7 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, Display ui->setupUi(this); setup(); - if(mode != DISPLAY_MODE_COMMENTS) - ui->verticalLayout->addStretch(); - else - ui->commentsWidget->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); - + ui->verticalLayout->addStretch(); ui->verticalLayout->setAlignment(Qt::AlignTop); ui->topLayout->setAlignment(Qt::AlignTop); ui->arrowsLayout->addStretch(); @@ -184,24 +180,6 @@ void BoardPostDisplayWidget::setup() ui->siteLabel->hide(); } break; - case DISPLAY_MODE_COMMENTS: - { - ui->pictureLabel_compact->show(); - ui->expandButton->hide(); - ui->pictureLabel->hide(); - ui->notes->hide(); - ui->scoreLabel->hide(); - ui->voteDownButton->hide(); - ui->voteUpButton->hide(); - ui->siteLabel->hide(); - ui->newLabel->hide(); - ui->commentButton->hide(); - ui->expandButton->hide(); - ui->shareButton->hide(); - ui->readButton->hide(); - ui->newLabel->hide(); - } - break; case DISPLAY_MODE_CARD_VIEW: { ui->frame_picture->hide(); @@ -341,7 +319,7 @@ void BoardPostDisplayWidget::setup() ui->siteLabel->setText(sitestr); - if(dmode == DISPLAY_MODE_COMPACT || dmode == DISPLAY_MODE_COMMENTS) + if(dmode == DISPLAY_MODE_COMPACT) { if(mPost.mImage.mData != NULL) { @@ -403,8 +381,7 @@ void BoardPostDisplayWidget::setup() // feed. //frame_comment->show(); - if(dmode != DISPLAY_MODE_COMMENTS) - ui->commentButton->show(); + ui->commentButton->show(); if (mPost.mComments) { diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index d8ce2d568..e36e1a56a 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -40,7 +40,6 @@ public: DISPLAY_MODE_UNKNOWN = 0x00, DISPLAY_MODE_CARD_VIEW = 0x01, DISPLAY_MODE_COMPACT = 0x02, - DISPLAY_MODE_COMMENTS = 0x03, }; enum DisplayFlags: uint8_t { diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index 7fde763f4..ae8bd01de 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -134,7 +134,7 @@ - + 0 0 diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index d6f5dbe4a..805e75747 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -29,6 +29,7 @@ #include "ui_PostedListWidgetWithModel.h" #include "gui/feeds/GxsChannelPostItem.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/gxs/GxsCommentDialog.h" #include "util/misc.h" #include "gui/Posted/PostedCreatePostDialog.h" #include "gui/common/UIStateHelper.h" @@ -653,14 +654,16 @@ void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId) return; RsPostedPost post = index.data(Qt::UserRole).value() ; - BoardPostDisplayWidget *w = new BoardPostDisplayWidget(post,BoardPostDisplayWidget::DISPLAY_MODE_COMMENTS,BoardPostDisplayWidget::SHOW_COMMENTS); + auto *commentDialog = new GxsCommentDialog(this,rsPosted->getTokenService(),rsPosted); + + std::set msg_versions({post.mMeta.mMsgId}); + commentDialog->commentLoad(post.mMeta.mGroupId, msg_versions, post.mMeta.mMsgId); QString title = QString::fromUtf8(post.mMeta.mMsgName.c_str()); if(title.length() > 30) title = title.left(27) + "..."; - ui->tabWidget->addTab(w,title); - ui->tabWidget->layout(); + ui->tabWidget->addTab(commentDialog,title); } void PostedListWidgetWithModel::tabCloseRequested(int index) diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp index 01455e6a3..7797b39f1 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp @@ -152,10 +152,10 @@ void GxsCommentDialog::setCommentHeader(QWidget *header) //header->setParent(ui->postFrame); //ui->postFrame->setVisible(true); - QLayout *alayout = ui->postFrame->layout(); +#if 0 + QLayout *alayout = ui->postFrame->layout(); alayout->addWidget(header); -#if 0 ui->postFrame->setVisible(true); QDateTime qtime; diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui index 0328eef9f..e23a16b44 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui @@ -20,31 +20,55 @@ Form - - + + - + 0 0 - - - 1 + + true + + + + Comment - - 1 + + + + Author - - 1 + + + + Date - - 1 + + + + Score - + + + + UpVotes + + + + + DownVotes + + + + + OwnVote + + - + @@ -147,54 +171,6 @@ - - - - - 0 - 0 - - - - true - - - - Comment - - - - - Author - - - - - Date - - - - - Score - - - - - UpVotes - - - - - DownVotes - - - - - OwnVote - - - - diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index d6b45252f..61045dd7f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -428,7 +428,7 @@ p, li { white-space: pre-wrap; }
- 1 + 2 @@ -593,16 +593,16 @@ p, li { white-space: pre-wrap; } QToolButton
gui/common/SubscribeToolButton.h
- - StyledElidedLabel - QLabel -
gui/common/StyledElidedLabel.h
-
RSTreeView QTreeView
gui/common/RSTreeView.h
+ + LineEditClear + QLineEdit +
gui/common/LineEditClear.h
+
GxsCommentDialog QWidget @@ -610,9 +610,9 @@ p, li { white-space: pre-wrap; } 1 - LineEditClear - QLineEdit -
gui/common/LineEditClear.h
+ StyledElidedLabel + QLabel +
gui/common/StyledElidedLabel.h
diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index ab02f16a1..80035a460 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1409,7 +1409,7 @@ posted { gui/Posted/PostedItem.ui \ gui/Posted/PostedCardView.ui \ gui/Posted/PostedCreatePostDialog.ui \ - gui/Posted/PhotoView.ui + gui/Posted/PhotoView.ui \ #gui/Posted/PostedDialog.ui \ #gui/Posted/PostedComments.ui \ #gui/Posted/PostedCreateCommentDialog.ui From 010fc1dc4428375628ba675b2d4de6ab3dd0dcd1 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 22 Sep 2020 22:43:24 +0200 Subject: [PATCH 37/78] tried to improve layout of items --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 47 +- .../src/gui/Posted/BoardPostDisplayWidget.ui | 793 +++++++++--------- 2 files changed, 450 insertions(+), 390 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index ca8ea4850..066194568 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -61,16 +61,20 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, Display ui->arrowsLayout->addStretch(); ui->arrowsLayout->setAlignment(Qt::AlignTop); ui->verticalLayout_2->addStretch(); +// ui->verticalLayout_3->addStretch(); +// ui->verticalLayout_3->setAlignment(Qt::AlignTop); - if(display_flags & SHOW_COMMENTS) - { - ui->commentsWidget->setTokenService(rsPosted->getTokenService(),rsPosted); + adjustSize(); - std::set post_versions ; - post_versions.insert(post.mMeta.mMsgId) ; - - ui->commentsWidget->commentLoad(post.mMeta.mGroupId, post_versions,mPost.mMeta.mMsgId,true); - } +// if(display_flags & SHOW_COMMENTS) +// { +// ui->commentsWidget->setTokenService(rsPosted->getTokenService(),rsPosted); +// +// std::set post_versions ; +// post_versions.insert(post.mMeta.mMsgId) ; +// +// ui->commentsWidget->commentLoad(post.mMeta.mGroupId, post_versions,mPost.mMeta.mMsgId,true); +// } } void BoardPostDisplayWidget::setCommentsSize(int comNb) @@ -172,8 +176,8 @@ void BoardPostDisplayWidget::setup() case DISPLAY_MODE_COMPACT: { ui->pictureLabel_compact->show(); - ui->expandButton->hide(); - //ui->expandButton->show(); // always hide, since we have the photoview already + //ui->expandButton->hide(); + ui->expandButton->show(); // always hide, since we have the photoview already ui->pictureLabel->hide(); ui->notes->hide(); @@ -207,7 +211,7 @@ void BoardPostDisplayWidget::setup() if(!(mDisplayFlags & SHOW_COMMENTS)) { - ui->commentsWidget->hide(); + //ui->commentsWidget->hide(); ui->commentButton->setChecked(false); } else @@ -269,7 +273,7 @@ void BoardPostDisplayWidget::setup() QDateTime qtime; qtime.setTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); - QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); + QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs) + " " + tr("ago"); ui->dateLabel->setText(timestamp2); ui->dateLabel->setToolTip(timestamp); @@ -377,7 +381,10 @@ void BoardPostDisplayWidget::setup() doc.setHtml(ui->notes->text()); if(doc.toPlainText().trimmed().isEmpty()) + { ui->notes->hide(); + ui->expandButton->hide(); + } // feed. //frame_comment->show(); @@ -385,9 +392,7 @@ void BoardPostDisplayWidget::setup() if (mPost.mComments) { - QString commentText = QString::number(mPost.mComments); - commentText += " "; - commentText += tr("Comments"); + QString commentText = tr("Comments (%1)").arg(QString::number(mPost.mComments)); ui->commentButton->setText(commentText); } else @@ -434,7 +439,17 @@ void BoardPostDisplayWidget::setup() void BoardPostDisplayWidget::doExpand(bool e) { - std::cerr << "Expanding" << std::endl; + std::cerr << "Expanding" << std::endl; + if(e) + { + //ui->notes->show(); + ui->pictureLabel_2->show(); + } + else + { + //ui->notes->hide(); + ui->pictureLabel_2->hide(); + } emit expand(mPost.mMeta.mMsgId,e); } diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index ae8bd01de..4d2eb6253 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -6,12 +6,12 @@ 0 0 - 758 - 211 + 558 + 202 - + 0 0 @@ -22,26 +22,29 @@ - + 0 + + QLayout::SetMaximumSize + - 0 + 2 - 0 + 2 - 0 + 2 - 0 + 2 - + 0 0 @@ -52,332 +55,204 @@ QFrame::Raised - + + + 2 + + + QLayout::SetMaximumSize + + + 1 + + + 2 + + + 1 + + + 2 + - + + + 2 + + + 2 + + + 2 + + + 2 + - + - - - - - - 0 - 0 - - - - Vote up - - - - - - - :/images/up-arrow.png:/images/up-arrow.png - - - true - - - - - - - - 9 - - - - 0 - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Vote down - - - - - - \/ - - - - :/images/down-arrow.png:/images/down-arrow.png - - - true - - - - - - - + 0 0 - - PictureLabel_compact + + Vote up - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true - - - QLayout::SetMinimumSize + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + + + + + + + 0 + 0 + + + + PictureLabel_compact + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + 0 + 0 + + + + + Arial + 10 + 75 + true + + + + This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + 5 + + + 0 + + + 6 - - - 5 - - - 0 - - - 6 - - - - - - 0 - 0 - - - - - 50 - false - - - - Posted by - - - - - - - - 0 - 0 - - - - Signed by - - - true - - - - - - - - 0 - 0 - - - - You eyes only - - - true - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Toggle Message Read Status - - - - :/images/message-state-unread.png:/images/message-state-unread.png - - - true - - - false - - - true - - - - - - - New - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 70 - 20 - - - - - - - - Comments - - - - :/images/comments.png:/images/comments.png - - - true - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Share - - - - :/images/share.png:/images/share.png - - - true - - - - - - - Expand - - - - - - - :/images/expand.png:/images/expand.png - - - true - - - true - - - - - - - + - + 0 0 - Arial - 10 - 75 - true + 50 + false - This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + Posted by - - - TextLabel - - - true - - - true - - - - - + - + 0 0 - site + Signed by true @@ -385,82 +260,258 @@ - - - - - PictureLabel - - - true - - - - - - - Qt::Horizontal - - - - 268 - 17 - - - - - + + + + 0 + 0 + + + + You eyes only + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 70 + 20 + + + + + + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + + :/images/message-state-unread.png:/images/message-state-unread.png + + + true + + + false + + + true + + + + + + + New + + + + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + + + + + Expand + + + + + + + :/images/expand.png:/images/expand.png + + + true + + + true + + + + + + + Comments + + + + :/images/comments.png:/images/comments.png + + + true + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + TextLabel + + + true + + + true + + + + + + + + 0 + 0 + + + + site + + + true + + + + + + + + + PictureLabel + + + true + + + + + + + Qt::Horizontal + + + + 268 + 17 + + + - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - 0 - 0 - - - - TextLabel - - - true - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - - - - 0 - 1 - - - - + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + QLayout::SetMaximumSize + + + 1 + + + 2 + + + 1 + + + 2 + + + + + + 0 + 0 + + + + TextLabel + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + @@ -482,12 +533,6 @@ QLabel
util/ClickableLabel.h
- - GxsCommentDialog - QWidget -
gui/gxs/GxsCommentDialog.h
- 1 -
From 5dfa481f2f8afaf01b3d90f93b05e3e899e32bcd Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 22 Sep 2020 23:32:10 +0200 Subject: [PATCH 38/78] added code to change posts read status --- libretroshare/src/retroshare/rsposted.h | 7 +++++-- libretroshare/src/services/p3posted.cc | 13 +++++++++++++ libretroshare/src/services/p3posted.h | 2 ++ .../src/gui/Posted/BoardPostDisplayWidget.cpp | 4 ++++ .../src/gui/Posted/BoardPostDisplayWidget.h | 4 +++- .../src/gui/Posted/PostedListWidgetWithModel.cpp | 6 ++++++ .../src/gui/Posted/PostedListWidgetWithModel.h | 1 + .../src/gui/Posted/PostedPostsModel.cpp | 16 +++++++++++----- retroshare-gui/src/gui/Posted/PostedPostsModel.h | 2 +- 9 files changed, 46 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 142707eb7..3c7724f6c 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -176,7 +176,9 @@ public: virtual bool voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMessageId& postMsgId,const RsGxsId& voterId) =0; - enum RS_DEPRECATED RankType {TopRankType, HotRankType, NewRankType }; + virtual bool setPostReadStatus(const RsGxsGrpMsgIdPair& msgId, bool read) = 0; + + enum RS_DEPRECATED RankType {TopRankType, HotRankType, NewRankType }; RS_DEPRECATED_FOR(getBoardsInfo) virtual bool getGroupData( const uint32_t& token, @@ -205,8 +207,9 @@ public: //virtual bool createNewComment(uint32_t &token, RsGxsComment &comment) = 0; //virtual bool createNewVote(uint32_t &token, RsGxsVote &vote) = 0; + RS_DEPRECATED_FOR(setPostReadStatus) + virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0; ////////////////////////////////////////////////////////////////////////////// -virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0; virtual bool createGroup(uint32_t &token, RsPostedGroup &group) = 0; virtual bool createPost(uint32_t &token, RsPostedPost &post) = 0; diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index 50ff890f1..251bf10cd 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -480,6 +480,19 @@ bool p3Posted::voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMess return true; } +bool p3Posted::setPostReadStatus(const RsGxsGrpMsgIdPair& msgId, bool read) +{ + uint32_t token; + + setMessageReadStatus(token,msgId,read); + + if(waitToken(token) != RsTokenService::COMPLETE) + { + std::cerr << __PRETTY_FUNCTION__ << " Error! GXS operation failed." << std::endl; + return false; + } + return true; +} bool p3Posted::editBoard(RsPostedGroup& board) { uint32_t token; diff --git a/libretroshare/src/services/p3posted.h b/libretroshare/src/services/p3posted.h index 005ed592a..8f71a97a1 100644 --- a/libretroshare/src/services/p3posted.h +++ b/libretroshare/src/services/p3posted.h @@ -86,6 +86,8 @@ virtual void receiveHelperChanges(std::vector& changes) bool voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMessageId& postMsgId,const RsGxsId& voterId) override; + bool setPostReadStatus(const RsGxsGrpMsgIdPair& msgId, bool read) override; + virtual bool getGroupData(const uint32_t &token, std::vector &groups) override; virtual bool getPostData(const uint32_t &token, std::vector &posts, std::vector &cmts, std::vector &vots) override; virtual bool getPostData(const uint32_t &token, std::vector &posts, std::vector &cmts) override; diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 066194568..35aacf2a1 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -458,6 +458,10 @@ void BoardPostDisplayWidget::loadComments(bool e) emit commentsRequested(mPost.mMeta.mMsgId,e); } +void BoardPostDisplayWidget::readToggled(bool s) +{ + emit changeReadStatusRequested(mPost.mMeta.mMsgId,s); +} void BoardPostDisplayWidget::showAuthorInPeople() { if(mPost.mMeta.mAuthorId.isNull()) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index e36e1a56a..5d4ca1ab8 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -72,9 +72,11 @@ protected slots: void makeDownVote() ; void toggleNotes() ; void showAuthorInPeople(); + void readToggled(bool); signals: - void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); + void changeReadStatusRequested(const RsGxsMessageId&,bool); + void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); void expand(RsGxsMessageId,bool); void commentsRequested(const RsGxsMessageId&,bool); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 805e75747..e7c11ef36 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -181,6 +181,7 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(expandItem(RsGxsMessageId,bool))); QObject::connect(w,SIGNAL(commentsRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(openComments(const RsGxsMessageId&))); + QObject::connect(w,SIGNAL(changeReadStatusRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(changeReadStatus(const RsGxsMessageId&,bool))); w->setFixedSize(option.rect.size()); w->adjustSize(); @@ -666,6 +667,11 @@ void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId) ui->tabWidget->addTab(commentDialog,title); } +void PostedListWidgetWithModel::changeReadStatus(const RsGxsMessageId& msgId,bool b) +{ + QModelIndex index=mPostedPostsModel->getIndexOfMessage(msgId); + mPostedPostsModel->setMsgReadStatus(index, b); +} void PostedListWidgetWithModel::tabCloseRequested(int index) { std::cerr << "GxsCommentContainer::tabCloseRequested(" << index << ")"; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 29c790a36..44565d953 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -109,6 +109,7 @@ public: #endif public slots: virtual void openComments(const RsGxsMessageId &msgId); + virtual void changeReadStatus(const RsGxsMessageId& msgId,bool b); protected: /* GxsMessageFramePostWidget */ diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index 43f87e6ab..1eacc0ecf 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -715,7 +715,7 @@ void RsPostedPostsModel::createPostsArray(std::vector& posts) } } -void RsPostedPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status,bool with_children) +void RsPostedPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status) { if(!i.isValid()) return ; @@ -728,10 +728,16 @@ void RsPostedPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status, if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size()) return ; -#warning TODO -// bool has_unread_below, has_read_below; -// recursSetMsgReadStatus(entry,read_status,with_children) ; -// recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below); + RsGxsGroupId grpId = mPosts[entry].mMeta.mGroupId; + RsGxsMessageId msgId = mPosts[entry].mMeta.mMsgId; + + RsThread::async([msgId,grpId,read_status]() + { + // Call blocking API + + rsPosted->setPostReadStatus(RsGxsGrpMsgIdPair(grpId,msgId),read_status); + } ); + } QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.h b/retroshare-gui/src/gui/Posted/PostedPostsModel.h index 13c2757b8..47c9f80d1 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.h +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.h @@ -154,7 +154,7 @@ public: void setTextColorMissing (QColor color) { mTextColorMissing = color;} #endif - void setMsgReadStatus(const QModelIndex &i, bool read_status, bool with_children); + void setMsgReadStatus(const QModelIndex &i, bool read_status); void setFilter(const QStringList &strings, uint32_t &count) ; void setSortingStrategy(SortingStrategy s); void setPostsInterval(int start,int nb_posts); From 4787675e914aeb12f33708d2d41095743775c48f Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 25 Sep 2020 23:16:29 +0200 Subject: [PATCH 39/78] split the UI for board items into two different widgets --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 545 +++++++++--------- .../src/gui/Posted/BoardPostDisplayWidget.h | 129 ++++- .../gui/Posted/BoardPostDisplayWidget_card.ui | 449 +++++++++++++++ ...t.ui => BoardPostDisplayWidget_compact.ui} | 84 +-- .../gui/Posted/PostedListWidgetWithModel.cpp | 66 ++- retroshare-gui/src/retroshare-gui.pro | 3 +- 6 files changed, 897 insertions(+), 379 deletions(-) create mode 100644 retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui rename retroshare-gui/src/gui/Posted/{BoardPostDisplayWidget.ui => BoardPostDisplayWidget_compact.ui} (91%) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 35aacf2a1..10c45dcbd 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "rshare.h" #include "BoardPostDisplayWidget.h" @@ -34,7 +35,8 @@ #include "gui/Identity/IdDialog.h" #include "gui/MainWindow.h" -#include "ui_BoardPostDisplayWidget.h" +#include "ui_BoardPostDisplayWidget_compact.h" +#include "ui_BoardPostDisplayWidget_card.h" #include #include @@ -46,38 +48,15 @@ const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2.png"; //=================================================================================================================================== -//== Base class BoardPostDisplayWidget == +//== Base class BoardPostDisplayWidgetBase == //=================================================================================================================================== -BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, DisplayMode mode, uint8_t display_flags, QWidget *parent) - : QWidget(parent),mPost(post),dmode(mode),mDisplayFlags(display_flags),ui(new Ui::BoardPostDisplayWidget()) +BoardPostDisplayWidgetBase::BoardPostDisplayWidgetBase(const RsPostedPost& post,uint8_t display_flags,QWidget *parent) + : QWidget(parent), mPost(post),mDisplayFlags(display_flags) { - ui->setupUi(this); - setup(); - - ui->verticalLayout->addStretch(); - ui->verticalLayout->setAlignment(Qt::AlignTop); - ui->topLayout->setAlignment(Qt::AlignTop); - ui->arrowsLayout->addStretch(); - ui->arrowsLayout->setAlignment(Qt::AlignTop); - ui->verticalLayout_2->addStretch(); -// ui->verticalLayout_3->addStretch(); -// ui->verticalLayout_3->setAlignment(Qt::AlignTop); - - adjustSize(); - -// if(display_flags & SHOW_COMMENTS) -// { -// ui->commentsWidget->setTokenService(rsPosted->getTokenService(),rsPosted); -// -// std::set post_versions ; -// post_versions.insert(post.mMeta.mMsgId) ; -// -// ui->commentsWidget->commentLoad(post.mMeta.mGroupId, post_versions,mPost.mMeta.mMsgId,true); -// } } -void BoardPostDisplayWidget::setCommentsSize(int comNb) +void BoardPostDisplayWidgetBase::setCommentsSize(int comNb) { QString sComButText = tr("Comment"); if (comNb == 1) @@ -85,151 +64,106 @@ void BoardPostDisplayWidget::setCommentsSize(int comNb) else if(comNb > 1) sComButText = tr("Comments ").append("(%1)").arg(comNb); - ui->commentButton->setText(sComButText); + commentButton()->setText(sComButText); } -void BoardPostDisplayWidget::makeDownVote() +void BoardPostDisplayWidgetBase::makeDownVote() { RsGxsGrpMsgIdPair msgId; msgId.first = mPost.mMeta.mGroupId; msgId.second = mPost.mMeta.mMsgId; - ui->voteUpButton->setEnabled(false); - ui->voteDownButton->setEnabled(false); + voteUpButton()->setEnabled(false); + voteDownButton()->setEnabled(false); emit vote(msgId, false); } -void BoardPostDisplayWidget::makeUpVote() +void BoardPostDisplayWidgetBase::makeUpVote() { RsGxsGrpMsgIdPair msgId; msgId.first = mPost.mMeta.mGroupId; msgId.second = mPost.mMeta.mMsgId; - ui->voteUpButton->setEnabled(false); - ui->voteDownButton->setEnabled(false); + voteUpButton()->setEnabled(false); + voteDownButton()->setEnabled(false); emit vote(msgId, true); } -void BoardPostDisplayWidget::setReadStatus(bool isNew, bool isUnread) +void BoardPostDisplayWidgetBase::setReadStatus(bool isNew, bool isUnread) { if (isUnread) { - ui->readButton->setChecked(true); - ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); + readButton()->setChecked(true); + readButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); } else { - ui->readButton->setChecked(false); - ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png")); + readButton()->setChecked(false); + readButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png")); } - ui->newLabel->setVisible(isNew); - -// ui->mainFrame->setProperty("new", isNew); -// ui->mainFrame->style()->unpolish(ui->mainFrame); -// ui->mainFrame->style()->polish( ui->mainFrame); + newLabel()->setVisible(isNew); } -void BoardPostDisplayWidget::setComment(const RsGxsComment& cmt) {} - -BoardPostDisplayWidget::~BoardPostDisplayWidget() +void BoardPostDisplayWidget::doExpand(bool e) { - delete(ui); + std::cerr << "Expanding" << std::endl; + if(e) + ui->notes->show(); + else + ui->notes->hide(); + + emit expand(mPost.mMeta.mMsgId,e); } - -void BoardPostDisplayWidget::viewPicture() +void BoardPostDisplayWidgetBase::loadComments(bool e) { - if(mPost.mImage.mData == NULL) - return; + emit commentsRequested(mPost.mMeta.mMsgId,e); +} - QString timestamp = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); - QPixmap pixmap; - GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); - RsGxsId authorID = mPost.mMeta.mAuthorId; - - PhotoView *PView = new PhotoView(this); - - PView->setPixmap(pixmap); - PView->setTitle(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); - PView->setName(authorID); - PView->setTime(timestamp); - PView->setGroupId(mPost.mMeta.mGroupId); - PView->setMessageId(mPost.mMeta.mMsgId); - - PView->show(); +void BoardPostDisplayWidgetBase::readToggled(bool s) +{ + emit changeReadStatusRequested(mPost.mMeta.mMsgId,s); +} +void BoardPostDisplayWidgetBase::showAuthorInPeople() +{ + if(mPost.mMeta.mAuthorId.isNull()) + { + std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data..."; + std::cerr << std::endl; + } /* window will destroy itself! */ + IdDialog *idDialog = dynamic_cast(MainWindow::getPage(MainWindow::People)); + + if (!idDialog) + return ; + + MainWindow::showWindow(MainWindow::People); + idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId)); } -void BoardPostDisplayWidget::toggleNotes() {} - -void BoardPostDisplayWidget::setup() +void BoardPostDisplayWidgetBase::setup() { // show/hide things based on the view type - switch(dmode) - { - default: - case DISPLAY_MODE_COMPACT: - { - ui->pictureLabel_compact->show(); - //ui->expandButton->hide(); - ui->expandButton->show(); // always hide, since we have the photoview already - - ui->pictureLabel->hide(); - ui->notes->hide(); - ui->siteLabel->hide(); - } - break; - case DISPLAY_MODE_CARD_VIEW: - { - ui->frame_picture->hide(); - ui->pictureLabel_compact->hide(); - ui->expandButton->hide(); - } - break; - } - - - if(mDisplayFlags & SHOW_NOTES) - { - ui->frame_picture->show(); - ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/decrease.png"))); - ui->expandButton->setToolTip(tr("Hide")); - ui->expandButton->setChecked(true); - } - else - { - ui->frame_picture->hide(); - ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/expand.png"))); - ui->expandButton->setToolTip(tr("Expand")); - ui->expandButton->setChecked(false); - } - if(!(mDisplayFlags & SHOW_COMMENTS)) - { - //ui->commentsWidget->hide(); - ui->commentButton->setChecked(false); - } + commentButton()->setChecked(false); else - ui->commentButton->setChecked(true); - - setAttribute(Qt::WA_DeleteOnClose, true); + commentButton()->setChecked(true); /* clear ui */ - ui->titleLabel->setText(tr("Loading")); - ui->dateLabel->clear(); - ui->fromLabel->clear(); - ui->siteLabel->clear(); + titleLabel()->setText(tr("Loading")); + dateLabel()->clear(); + fromLabel()->clear(); + siteLabel()->clear(); - connect(ui->expandButton, SIGNAL(toggled(bool)), this, SLOT(doExpand(bool))); - connect(ui->commentButton, SIGNAL(toggled(bool)), this, SLOT(loadComments(bool))); - connect(ui->voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); - connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT(makeDownVote())); - connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); + QObject::connect(commentButton(), SIGNAL(toggled(bool)), this, SLOT(loadComments(bool))); + QObject::connect(voteUpButton(), SIGNAL(clicked()), this, SLOT(makeUpVote())); + QObject::connect(voteDownButton(), SIGNAL(clicked()), this, SLOT(makeDownVote())); + QObject::connect(readButton(), SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink())); @@ -239,32 +173,32 @@ void BoardPostDisplayWidget::setup() int S = QFontMetricsF(font()).height() ; - ui->voteUpButton->setIconSize(QSize(S*1.5,S*1.5)); - ui->voteDownButton->setIconSize(QSize(S*1.5,S*1.5)); - ui->commentButton->setIconSize(QSize(S*1.5,S*1.5)); - ui->readButton->setIconSize(QSize(S*1.5,S*1.5)); - ui->shareButton->setIconSize(QSize(S*1.5,S*1.5)); + voteUpButton()->setIconSize(QSize(S*1.5,S*1.5)); + voteDownButton()->setIconSize(QSize(S*1.5,S*1.5)); + commentButton()->setIconSize(QSize(S*1.5,S*1.5)); + readButton()->setIconSize(QSize(S*1.5,S*1.5)); + shareButton()->setIconSize(QSize(S*1.5,S*1.5)); QMenu *menu = new QMenu(); menu->addAction(CopyLinkAction); menu->addSeparator(); menu->addAction(showInPeopleAct); - ui->shareButton->setMenu(menu); + shareButton()->setMenu(menu); RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); if(redacted) { - ui->commentButton->setDisabled(true); - ui->voteUpButton->setDisabled(true); - ui->voteDownButton->setDisabled(true); - ui->fromLabel->setId(mPost.mMeta.mAuthorId); - ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; + commentButton()->setDisabled(true); + voteUpButton()->setDisabled(true); + voteDownButton()->setDisabled(true); + fromLabel()->setId(mPost.mMeta.mAuthorId); + titleLabel()->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; QDateTime qtime; qtime.setTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); - ui->dateLabel->setText(timestamp); + dateLabel()->setText(timestamp); } else { @@ -274,10 +208,10 @@ void BoardPostDisplayWidget::setup() qtime.setTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs) + " " + tr("ago"); - ui->dateLabel->setText(timestamp2); - ui->dateLabel->setToolTip(timestamp); + dateLabel()->setText(timestamp2); + dateLabel()->setToolTip(timestamp); - ui->fromLabel->setId(mPost.mMeta.mAuthorId); + fromLabel()->setId(mPost.mMeta.mAuthorId); // Use QUrl to check/parse our URL // The only combination that seems to work: load as EncodedUrl, extract toEncoded(). @@ -311,20 +245,97 @@ void BoardPostDisplayWidget::setup() QString siteurl = url.toEncoded(); sitestr = QString(" %2 ").arg(siteurl).arg(siteurl); - ui->titleLabel->setText(urlstr); + titleLabel()->setText(urlstr); } else - ui->titleLabel->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) ); + titleLabel()->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) ); if (urlarray.isEmpty()) - { - ui->siteLabel->hide(); - } + siteLabel()->hide(); - ui->siteLabel->setText(sitestr); + siteLabel()->setText(sitestr); + } - if(dmode == DISPLAY_MODE_COMPACT) - { + //QString score = "Hot" + QString::number(post.mHotScore); + //score += " Top" + QString::number(post.mTopScore); + //score += " New" + QString::number(post.mNewScore); + + QString score = QString::number(mPost.mTopScore); + + scoreLabel()->setText(score); + + // FIX THIS UP LATER. + notes()->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + pictureLabel()->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + + // feed. + //frame_comment->show(); + commentButton()->show(); + + if (mPost.mComments) + { + QString commentText = tr("Comments (%1)").arg(QString::number(mPost.mComments)); + commentButton()->setText(commentText); + } + else + commentButton()->setText(tr("Comment")); + + setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); + + // disable voting buttons - if they have already voted. + if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) + { + voteUpButton()->setEnabled(false); + voteDownButton()->setEnabled(false); + } + + connect(pictureLabel(), SIGNAL(clicked()), this, SLOT(viewPicture())); + +#ifdef TODO + emit sizeChanged(this); +#endif +} +//=================================================================================================================================== +//== class BoardPostDisplayWidget == +//=================================================================================================================================== + +BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, uint8_t display_flags,QWidget *parent=nullptr) + : BoardPostDisplayWidgetBase(post,display_flags,parent), ui(new Ui::BoardPostDisplayWidget_compact()) +{ + ui->setupUi(this); + setup(); + + ui->verticalLayout->addStretch(); + ui->verticalLayout->setAlignment(Qt::AlignTop); + ui->topLayout->setAlignment(Qt::AlignTop); + ui->arrowsLayout->addStretch(); + ui->arrowsLayout->setAlignment(Qt::AlignTop); + ui->verticalLayout_2->addStretch(); + + adjustSize(); +} + +BoardPostDisplayWidget::~BoardPostDisplayWidget() +{ + delete ui; +} + +void BoardPostDisplayWidget::setup() +{ + BoardPostDisplayWidgetBase::setup(); + + // show/hide things based on the view type + + setAttribute(Qt::WA_DeleteOnClose, true); + + RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); + bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); + + if(redacted) + { + } + else + { if(mPost.mImage.mData != NULL) { QPixmap pixmap; @@ -334,102 +345,38 @@ void BoardPostDisplayWidget::setup() int desired_height = QFontMetricsF(font()).height() * 5; QPixmap scaledpixmap = pixmap.scaledToHeight(desired_height, Qt::SmoothTransformation); - ui->pictureLabel_compact->setPixmap(scaledpixmap); - } - else if (mPost.mImage.mData == NULL) - ui->pictureLabel_compact->hide(); - else - ui->pictureLabel_compact->show(); - } - else - { - if(mPost.mImage.mData != NULL) - { - QPixmap pixmap; - GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); - // Wiping data - as its been passed to thumbnail. - - - QPixmap scaledpixmap; - if(pixmap.width() > 800){ - QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); - ui->pictureLabel->setPixmap(scaledpixmap); - }else{ - ui->pictureLabel->setPixmap(pixmap); - } + ui->pictureLabel->setPixmap(scaledpixmap); } else if (mPost.mImage.mData == NULL) ui->pictureLabel->hide(); else ui->pictureLabel->show(); + } - } - //QString score = "Hot" + QString::number(post.mHotScore); - //score += " Top" + QString::number(post.mTopScore); - //score += " New" + QString::number(post.mNewScore); - - QString score = QString::number(mPost.mTopScore); - - ui->scoreLabel->setText(score); - - // FIX THIS UP LATER. ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); - ui->pictureLabel_2->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + + QObject::connect(ui->expandButton, SIGNAL(toggled(bool)), this, SLOT(doExpand(bool))); QTextDocument doc; - doc.setHtml(ui->notes->text()); + doc.setHtml(notes()->text()); + + if(mDisplayFlags & SHOW_NOTES) + { + notes()->show(); + ui->expandButton->setChecked(true); + } + else + { + notes()->hide(); + ui->expandButton->setChecked(false); + } if(doc.toPlainText().trimmed().isEmpty()) { - ui->notes->hide(); + notes()->hide(); ui->expandButton->hide(); } - - // feed. - //frame_comment->show(); - ui->commentButton->show(); - - if (mPost.mComments) - { - QString commentText = tr("Comments (%1)").arg(QString::number(mPost.mComments)); - ui->commentButton->setText(commentText); - } - else - ui->commentButton->setText(tr("Comment")); - - setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); - - // disable voting buttons - if they have already voted. - if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) - { - ui->voteUpButton->setEnabled(false); - ui->voteDownButton->setEnabled(false); - } - -#if 0 - uint32_t up, down, nComments; - - bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments); - - if(ok) - { - int32_t vote = up - down; - scoreLabel->setText(QString::number(vote)); - - numCommentsLabel->setText("

# Comments: " - + QString::number(nComments) + "

"); - } - - mInFill = false; -#endif - - ui->pictureLabel_compact->setUseStyleSheet(false); // If not this, causes dilation of the image. - connect(ui->pictureLabel_compact, SIGNAL(clicked()), this, SLOT(viewPicture())); - updateGeometry(); #ifdef TODO @@ -437,45 +384,111 @@ void BoardPostDisplayWidget::setup() #endif } -void BoardPostDisplayWidget::doExpand(bool e) +void BoardPostDisplayWidget::viewPicture() { - std::cerr << "Expanding" << std::endl; - if(e) - { - //ui->notes->show(); - ui->pictureLabel_2->show(); - } - else - { - //ui->notes->hide(); - ui->pictureLabel_2->hide(); - } - emit expand(mPost.mMeta.mMsgId,e); -} + if(mPost.mImage.mData == NULL) + return; -void BoardPostDisplayWidget::loadComments(bool e) -{ - emit commentsRequested(mPost.mMeta.mMsgId,e); -} + QString timestamp = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + RsGxsId authorID = mPost.mMeta.mAuthorId; -void BoardPostDisplayWidget::readToggled(bool s) -{ - emit changeReadStatusRequested(mPost.mMeta.mMsgId,s); -} -void BoardPostDisplayWidget::showAuthorInPeople() -{ - if(mPost.mMeta.mAuthorId.isNull()) - { - std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data..."; - std::cerr << std::endl; - } + PhotoView *PView = new PhotoView(); + + PView->setPixmap(pixmap); + PView->setTitle(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); + PView->setName(authorID); + PView->setTime(timestamp); + PView->setGroupId(mPost.mMeta.mGroupId); + PView->setMessageId(mPost.mMeta.mMsgId); + + PView->show(); /* window will destroy itself! */ - IdDialog *idDialog = dynamic_cast(MainWindow::getPage(MainWindow::People)); - - if (!idDialog) - return ; - - MainWindow::showWindow(MainWindow::People); - idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId)); } + +QToolButton *BoardPostDisplayWidget::voteUpButton() { return ui->voteUpButton; } +QToolButton *BoardPostDisplayWidget::commentButton() { return ui->commentButton; } +QToolButton *BoardPostDisplayWidget::voteDownButton() { return ui->voteDownButton; } +QLabel *BoardPostDisplayWidget::newLabel() { return ui->newLabel; } +QToolButton *BoardPostDisplayWidget::readButton() { return ui->readButton; } +QLabel *BoardPostDisplayWidget::siteLabel() { return ui->siteLabel; } +GxsIdLabel *BoardPostDisplayWidget::fromLabel() { return ui->fromLabel; } +QLabel *BoardPostDisplayWidget::dateLabel() { return ui->dateLabel; } +QLabel *BoardPostDisplayWidget::titleLabel() { return ui->titleLabel; } +QLabel *BoardPostDisplayWidget::scoreLabel() { return ui->scoreLabel; } +QLabel *BoardPostDisplayWidget::notes() { return ui->notes; } +QPushButton *BoardPostDisplayWidget::shareButton() { return ui->shareButton; } +QLabel *BoardPostDisplayWidget::pictureLabel() { return ui->pictureLabel; } + +//=================================================================================================================================== +//== class BoardPostDisplayWidget_card == +//=================================================================================================================================== + +BoardPostDisplayWidget_card::BoardPostDisplayWidget_card(const RsPostedPost& post, uint8_t display_flags, QWidget *parent) + : BoardPostDisplayWidgetBase(post,display_flags,parent), ui(new Ui::BoardPostDisplayWidget_card()) +{ + ui->setupUi(this); + setup(); + + ui->verticalLayout->addStretch(); + ui->verticalLayout->setAlignment(Qt::AlignTop); + ui->topLayout->setAlignment(Qt::AlignTop); + ui->arrowsLayout->addStretch(); + ui->arrowsLayout->setAlignment(Qt::AlignTop); + ui->verticalLayout_2->addStretch(); + + adjustSize(); +} + +BoardPostDisplayWidget_card::~BoardPostDisplayWidget_card() +{ + delete ui; +} + +void BoardPostDisplayWidget_card::setup() +{ + BoardPostDisplayWidgetBase::setup(); + + if(mPost.mImage.mData != NULL) + { + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + // Wiping data - as its been passed to thumbnail. + + + QPixmap scaledpixmap; + if(pixmap.width() > 800){ + QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); + pictureLabel()->setPixmap(scaledpixmap); + }else{ + pictureLabel()->setPixmap(pixmap); + } + } + else if (mPost.mImage.mData == NULL) + pictureLabel()->hide(); + else + pictureLabel()->show(); + + QTextDocument doc; + doc.setHtml(notes()->text()); + + if(doc.toPlainText().trimmed().isEmpty()) + notes()->hide(); +} + +QToolButton *BoardPostDisplayWidget_card::voteUpButton() { return ui->voteUpButton; } +QToolButton *BoardPostDisplayWidget_card::commentButton() { return ui->commentButton; } +QToolButton *BoardPostDisplayWidget_card::voteDownButton() { return ui->voteDownButton; } +QLabel *BoardPostDisplayWidget_card::newLabel() { return ui->newLabel; } +QToolButton *BoardPostDisplayWidget_card::readButton() { return ui->readButton; } +QLabel *BoardPostDisplayWidget_card::siteLabel() { return ui->siteLabel; } +GxsIdLabel *BoardPostDisplayWidget_card::fromLabel() { return ui->fromLabel; } +QLabel *BoardPostDisplayWidget_card::dateLabel() { return ui->dateLabel; } +QLabel *BoardPostDisplayWidget_card::titleLabel() { return ui->titleLabel; } +QLabel *BoardPostDisplayWidget_card::scoreLabel() { return ui->scoreLabel; } +QLabel *BoardPostDisplayWidget_card::notes() { return ui->notes; } +QPushButton *BoardPostDisplayWidget_card::shareButton() { return ui->shareButton; } +QLabel *BoardPostDisplayWidget_card::pictureLabel() { return ui->pictureLabel; } + diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 5d4ca1ab8..af45a30a0 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -26,53 +26,67 @@ #include namespace Ui { -class BoardPostDisplayWidget; +class BoardPostDisplayWidget_card; +class BoardPostDisplayWidget_compact; } +class QPushButton; +class QLabel; +class QToolButton; +class QTextEdit; +class ClickableLabel; +class GxsIdLabel; + struct RsPostedPost; -class BoardPostDisplayWidget : public QWidget +class BoardPostDisplayWidgetBase: public QWidget { Q_OBJECT public: - enum DisplayMode { - DISPLAY_MODE_UNKNOWN = 0x00, - DISPLAY_MODE_CARD_VIEW = 0x01, - DISPLAY_MODE_COMPACT = 0x02, - }; - enum DisplayFlags: uint8_t { SHOW_NONE = 0x00, SHOW_COMMENTS = 0x01, SHOW_NOTES = 0x02, }; - BoardPostDisplayWidget(const RsPostedPost& post,DisplayMode display_mode,uint8_t display_flags,QWidget *parent=nullptr); - virtual ~BoardPostDisplayWidget(); + enum DisplayMode: uint8_t { + DISPLAY_MODE_UNKNOWN = 0x00, + DISPLAY_MODE_COMPACT = 0x01, + DISPLAY_MODE_CARD = 0x02, + }; + + BoardPostDisplayWidgetBase(const RsPostedPost& post,uint8_t display_flags,QWidget *parent); + virtual ~BoardPostDisplayWidgetBase() {} static const char *DEFAULT_BOARD_IMAGE; -public slots: - void viewPicture() ; - protected slots: /* GxsGroupFeedItem */ virtual void setup(); // to be overloaded by the different views - void doExpand(bool) ; - void setComment(const RsGxsComment&) ; - void setReadStatus(bool isNew, bool isUnread) ; + virtual QToolButton *voteUpButton() =0; + virtual QToolButton *commentButton() =0; + virtual QToolButton *voteDownButton() =0; + virtual QLabel *newLabel() =0; + virtual QLabel *titleLabel()=0; + virtual QLabel *siteLabel()=0; + virtual GxsIdLabel *fromLabel()=0; + virtual QLabel *dateLabel()=0; + virtual QLabel *scoreLabel() =0; + virtual QLabel *notes() =0; + virtual QLabel *pictureLabel()=0; + virtual QToolButton *readButton() =0; + virtual QPushButton *shareButton() =0; - void toggle() {} - void setCommentsSize(int comNb) ; void loadComments(bool e); - void makeUpVote() ; - void makeDownVote() ; - void toggleNotes() ; void showAuthorInPeople(); void readToggled(bool); + void setReadStatus(bool isNew, bool isUnread) ; + void makeUpVote() ; + void makeDownVote() ; + void setCommentsSize(int comNb) ; signals: void changeReadStatusRequested(const RsGxsMessageId&,bool); @@ -82,12 +96,79 @@ signals: protected: RsPostedPost mPost; + uint8_t mDisplayFlags; +}; - DisplayMode dmode; - uint8_t mDisplayFlags; +class BoardPostDisplayWidget : public BoardPostDisplayWidgetBase +{ + Q_OBJECT + +public: + BoardPostDisplayWidget(const RsPostedPost& post, uint8_t display_flags, QWidget *parent); + virtual ~BoardPostDisplayWidget(); + + static const char *DEFAULT_BOARD_IMAGE; + + QToolButton *voteUpButton() override; + QToolButton *commentButton() override; + QToolButton *voteDownButton() override; + QLabel *newLabel() override; + QLabel *siteLabel() override; + GxsIdLabel *fromLabel() override; + QLabel *dateLabel() override; + QLabel *titleLabel() override; + QLabel *scoreLabel() override; + QLabel *notes() override; + QLabel *pictureLabel() override; + QToolButton *readButton() override; + QPushButton *shareButton() override; + +public slots: + void viewPicture() ; + +protected slots: + /* GxsGroupFeedItem */ + void doExpand(bool) ; + +protected: + void setup() override; // to be overloaded by the different views private: /** Qt Designer generated object */ - Ui::BoardPostDisplayWidget *ui; + Ui::BoardPostDisplayWidget_compact *ui; }; +class BoardPostDisplayWidget_card : public BoardPostDisplayWidgetBase +{ + Q_OBJECT + +public: + BoardPostDisplayWidget_card(const RsPostedPost& post,uint8_t display_flags,QWidget *parent=nullptr); + virtual ~BoardPostDisplayWidget_card(); + + static const char *DEFAULT_BOARD_IMAGE; + + QToolButton *voteUpButton() override; + QToolButton *commentButton() override; + QToolButton *voteDownButton() override; + QLabel *newLabel() override; + QLabel *siteLabel() override; + GxsIdLabel *fromLabel() override; + QLabel *dateLabel() override; + QLabel *titleLabel() override; + QLabel *scoreLabel() override; + QLabel *notes() override; + QToolButton *readButton() override; + QPushButton *shareButton() override; + QLabel *pictureLabel() override; + +protected slots: + /* GxsGroupFeedItem */ + +protected: + void setup() override; // to be overloaded by the different views + +private: + /** Qt Designer generated object */ + Ui::BoardPostDisplayWidget_card *ui; +}; diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui new file mode 100644 index 000000000..241924862 --- /dev/null +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui @@ -0,0 +1,449 @@ + + + BoardPostDisplayWidget_card + + + + 0 + 0 + 558 + 202 + + + + + 0 + 0 + + + + + + + + + + + 0 + + + QLayout::SetMaximumSize + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + QLayout::SetMaximumSize + + + 1 + + + 2 + + + 1 + + + 2 + + + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + + + 0 + 0 + + + + Vote up + + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true + + + + + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + + + + + + + + + 0 + 0 + + + + + Arial + 10 + 75 + true + + + + This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + 5 + + + 0 + + + 6 + + + + + + 0 + 0 + + + + + 50 + false + + + + Posted by + + + + + + + + 0 + 0 + + + + Signed by + + + true + + + + + + + + 0 + 0 + + + + You eyes only + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 70 + 20 + + + + + + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + + :/images/message-state-unread.png:/images/message-state-unread.png + + + true + + + false + + + true + + + + + + + New + + + + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + + + + + Comments + + + + :/images/comments.png:/images/comments.png + + + true + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 0 + + + + site + + + true + + + + + + + + + PictureLabel + + + true + + + + + + + Qt::Horizontal + + + + 268 + 17 + + + + + + + + + + TextLabel + + + true + + + true + + + + + + + + + + + + + + + GxsIdLabel + QLabel +
gui/gxs/GxsIdLabel.h
+
+ + StyledLabel + QLabel +
gui/common/StyledLabel.h
+
+
+ + + + + +
diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui similarity index 91% rename from retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui rename to retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index 4d2eb6253..8ade5e573 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -1,13 +1,13 @@ - BoardPostDisplayWidget - + BoardPostDisplayWidget_compact + 0 0 - 558 - 202 + 540 + 172 @@ -163,7 +163,7 @@
- + 0 @@ -293,6 +293,22 @@
+ + + + + 0 + 0 + + + + site + + + true + + + @@ -400,62 +416,6 @@ - - - - TextLabel - - - true - - - true - - - - - - - - 0 - 0 - - - - site - - - true - - - - - - - - - PictureLabel - - - true - - - - - - - Qt::Horizontal - - - - 268 - 17 - - - - - - @@ -488,7 +448,7 @@ 2
- + 0 diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index e7c11ef36..27f37a4a1 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -91,16 +91,25 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->fillRect( option.rect, option.backgroundBrush); painter->restore(); - BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId)); - - w.setFixedSize(option.rect.size()); - w.adjustSize(); - - QPixmap pixmap(option.rect.size()); - + QPixmap pixmap(option.rect.size()); pixmap.fill(QRgb(0x00f0f0f0)); // choose a fully transparent background - w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + if(mDisplayMode == BoardPostDisplayWidget::DISPLAY_MODE_COMPACT) + { + BoardPostDisplayWidget w(post,displayFlags(post.mMeta.mMsgId),nullptr); + + w.setFixedSize(option.rect.size()); + w.adjustSize(); + w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + } + else + { + BoardPostDisplayWidget_card w(post,displayFlags(post.mMeta.mMsgId),nullptr); + + w.setFixedSize(option.rect.size()); + w.adjustSize(); + w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + } #ifdef TODO if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) @@ -131,11 +140,19 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo // This is the only place where we actually set the size of cells RsPostedPost post = index.data(Qt::UserRole).value() ; - BoardPostDisplayWidget w(post,mDisplayMode,displayFlags(post.mMeta.mMsgId)); - w.adjustSize(); - - return w.size(); + if(mDisplayMode == BoardPostDisplayWidget::DISPLAY_MODE_COMPACT) + { + BoardPostDisplayWidget w(post,displayFlags(post.mMeta.mMsgId),nullptr); + w.adjustSize(); + return w.size(); + } + else + { + BoardPostDisplayWidget_card w(post,displayFlags(post.mMeta.mMsgId),nullptr); + w.adjustSize(); + return w.size(); + } } void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded) { @@ -147,16 +164,7 @@ void PostedPostDelegate::expandItem(RsGxsMessageId msgId,bool expanded) mPostListWidget->forceRedraw(); } -// void PostedPostDelegate::commentItem(RsGxsMessageId msgId,bool comment) -// { -// std::cerr << __PRETTY_FUNCTION__ << ": received commentItem signal. b=" << comment << std::endl; -// if(comment) -// mShowCommentItems.insert(msgId); -// else -// mShowCommentItems.erase(msgId); -// -// mPostListWidget->forceRedraw(); -// } + uint8_t PostedPostDelegate::displayFlags(const RsGxsMessageId &id) const { uint8_t flags=0; @@ -176,7 +184,12 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie if(index.column() == RsPostedPostsModel::COLUMN_POSTS) { - QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,displayFlags(post.mMeta.mMsgId),parent); + QWidget *w ; + + if(mDisplayMode==BoardPostDisplayWidget::DISPLAY_MODE_COMPACT) + w = new BoardPostDisplayWidget(post,displayFlags(post.mMeta.mMsgId),parent); + else + w = new BoardPostDisplayWidget_card(post,displayFlags(post.mMeta.mMsgId),parent); QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool))); QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(expandItem(RsGxsMessageId,bool))); @@ -265,7 +278,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI settingsChanged(); setGroupId(postedId); - mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD); + switchDisplayMode(); // makes everything consistent and chooses classic view as default updateSorting(ui->sortStrategy_CB->currentIndex()); @@ -279,7 +293,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI void PostedListWidgetWithModel::switchDisplayMode() { - if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW) + if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget::DISPLAY_MODE_CARD) { ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/classic.png")); ui->viewModeButton->setToolTip(tr("Click to switch to card view")); @@ -291,7 +305,7 @@ void PostedListWidgetWithModel::switchDisplayMode() ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/card.png")); ui->viewModeButton->setToolTip(tr("Click to switch to compact view")); - mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD); } mPostedPostsModel->triggerRedraw(); } diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 80035a460..960666d4e 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1405,7 +1405,8 @@ posted { FORMS += gui/Posted/PostedListWidgetWithModel.ui \ gui/feeds/PostedGroupItem.ui \ - gui/Posted/BoardPostDisplayWidget.ui \ + gui/Posted/BoardPostDisplayWidget_compact.ui \ + gui/Posted/BoardPostDisplayWidget_card.ui \ gui/Posted/PostedItem.ui \ gui/Posted/PostedCardView.ui \ gui/Posted/PostedCreatePostDialog.ui \ From 4ae61ddbca3298453e23a4f642a14a904b89c7dc Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 25 Sep 2020 23:18:01 +0200 Subject: [PATCH 40/78] renamed BoardPostDisplayWidget into BoardPostDisplayWidget_compact --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 38 +++++++++---------- .../src/gui/Posted/BoardPostDisplayWidget.h | 6 +-- .../gui/Posted/PostedListWidgetWithModel.cpp | 28 +++++++------- .../gui/Posted/PostedListWidgetWithModel.h | 8 ++-- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 10c45dcbd..a3f2b592d 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -45,7 +45,7 @@ /** Constructor */ -const char *BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2.png"; +const char *BoardPostDisplayWidget_compact::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2.png"; //=================================================================================================================================== //== Base class BoardPostDisplayWidgetBase == @@ -107,7 +107,7 @@ void BoardPostDisplayWidgetBase::setReadStatus(bool isNew, bool isUnread) newLabel()->setVisible(isNew); } -void BoardPostDisplayWidget::doExpand(bool e) +void BoardPostDisplayWidget_compact::doExpand(bool e) { std::cerr << "Expanding" << std::endl; if(e) @@ -299,7 +299,7 @@ void BoardPostDisplayWidgetBase::setup() //== class BoardPostDisplayWidget == //=================================================================================================================================== -BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, uint8_t display_flags,QWidget *parent=nullptr) +BoardPostDisplayWidget_compact::BoardPostDisplayWidget_compact(const RsPostedPost& post, uint8_t display_flags,QWidget *parent=nullptr) : BoardPostDisplayWidgetBase(post,display_flags,parent), ui(new Ui::BoardPostDisplayWidget_compact()) { ui->setupUi(this); @@ -315,12 +315,12 @@ BoardPostDisplayWidget::BoardPostDisplayWidget(const RsPostedPost& post, uint8_t adjustSize(); } -BoardPostDisplayWidget::~BoardPostDisplayWidget() +BoardPostDisplayWidget_compact::~BoardPostDisplayWidget_compact() { delete ui; } -void BoardPostDisplayWidget::setup() +void BoardPostDisplayWidget_compact::setup() { BoardPostDisplayWidgetBase::setup(); @@ -384,7 +384,7 @@ void BoardPostDisplayWidget::setup() #endif } -void BoardPostDisplayWidget::viewPicture() +void BoardPostDisplayWidget_compact::viewPicture() { if(mPost.mImage.mData == NULL) return; @@ -408,19 +408,19 @@ void BoardPostDisplayWidget::viewPicture() /* window will destroy itself! */ } -QToolButton *BoardPostDisplayWidget::voteUpButton() { return ui->voteUpButton; } -QToolButton *BoardPostDisplayWidget::commentButton() { return ui->commentButton; } -QToolButton *BoardPostDisplayWidget::voteDownButton() { return ui->voteDownButton; } -QLabel *BoardPostDisplayWidget::newLabel() { return ui->newLabel; } -QToolButton *BoardPostDisplayWidget::readButton() { return ui->readButton; } -QLabel *BoardPostDisplayWidget::siteLabel() { return ui->siteLabel; } -GxsIdLabel *BoardPostDisplayWidget::fromLabel() { return ui->fromLabel; } -QLabel *BoardPostDisplayWidget::dateLabel() { return ui->dateLabel; } -QLabel *BoardPostDisplayWidget::titleLabel() { return ui->titleLabel; } -QLabel *BoardPostDisplayWidget::scoreLabel() { return ui->scoreLabel; } -QLabel *BoardPostDisplayWidget::notes() { return ui->notes; } -QPushButton *BoardPostDisplayWidget::shareButton() { return ui->shareButton; } -QLabel *BoardPostDisplayWidget::pictureLabel() { return ui->pictureLabel; } +QToolButton *BoardPostDisplayWidget_compact::voteUpButton() { return ui->voteUpButton; } +QToolButton *BoardPostDisplayWidget_compact::commentButton() { return ui->commentButton; } +QToolButton *BoardPostDisplayWidget_compact::voteDownButton() { return ui->voteDownButton; } +QLabel *BoardPostDisplayWidget_compact::newLabel() { return ui->newLabel; } +QToolButton *BoardPostDisplayWidget_compact::readButton() { return ui->readButton; } +QLabel *BoardPostDisplayWidget_compact::siteLabel() { return ui->siteLabel; } +GxsIdLabel *BoardPostDisplayWidget_compact::fromLabel() { return ui->fromLabel; } +QLabel *BoardPostDisplayWidget_compact::dateLabel() { return ui->dateLabel; } +QLabel *BoardPostDisplayWidget_compact::titleLabel() { return ui->titleLabel; } +QLabel *BoardPostDisplayWidget_compact::scoreLabel() { return ui->scoreLabel; } +QLabel *BoardPostDisplayWidget_compact::notes() { return ui->notes; } +QPushButton *BoardPostDisplayWidget_compact::shareButton() { return ui->shareButton; } +QLabel *BoardPostDisplayWidget_compact::pictureLabel() { return ui->pictureLabel; } //=================================================================================================================================== //== class BoardPostDisplayWidget_card == diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index af45a30a0..45e24a005 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -99,13 +99,13 @@ protected: uint8_t mDisplayFlags; }; -class BoardPostDisplayWidget : public BoardPostDisplayWidgetBase +class BoardPostDisplayWidget_compact : public BoardPostDisplayWidgetBase { Q_OBJECT public: - BoardPostDisplayWidget(const RsPostedPost& post, uint8_t display_flags, QWidget *parent); - virtual ~BoardPostDisplayWidget(); + BoardPostDisplayWidget_compact(const RsPostedPost& post, uint8_t display_flags, QWidget *parent); + virtual ~BoardPostDisplayWidget_compact(); static const char *DEFAULT_BOARD_IMAGE; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 27f37a4a1..9ef923386 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -94,9 +94,9 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & QPixmap pixmap(option.rect.size()); pixmap.fill(QRgb(0x00f0f0f0)); // choose a fully transparent background - if(mDisplayMode == BoardPostDisplayWidget::DISPLAY_MODE_COMPACT) + if(mDisplayMode == BoardPostDisplayWidget_compact::DISPLAY_MODE_COMPACT) { - BoardPostDisplayWidget w(post,displayFlags(post.mMeta.mMsgId),nullptr); + BoardPostDisplayWidget_compact w(post,displayFlags(post.mMeta.mMsgId),nullptr); w.setFixedSize(option.rect.size()); w.adjustSize(); @@ -141,9 +141,9 @@ QSize PostedPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo RsPostedPost post = index.data(Qt::UserRole).value() ; - if(mDisplayMode == BoardPostDisplayWidget::DISPLAY_MODE_COMPACT) + if(mDisplayMode == BoardPostDisplayWidget_compact::DISPLAY_MODE_COMPACT) { - BoardPostDisplayWidget w(post,displayFlags(post.mMeta.mMsgId),nullptr); + BoardPostDisplayWidget_compact w(post,displayFlags(post.mMeta.mMsgId),nullptr); w.adjustSize(); return w.size(); } @@ -170,10 +170,10 @@ uint8_t PostedPostDelegate::displayFlags(const RsGxsMessageId &id) const uint8_t flags=0; if(mExpandedItems.find(id) != mExpandedItems.end()) - flags |= BoardPostDisplayWidget::SHOW_NOTES; + flags |= BoardPostDisplayWidget_compact::SHOW_NOTES; if(mShowCommentItems.find(id) != mShowCommentItems.end()) - flags |= BoardPostDisplayWidget::SHOW_COMMENTS; + flags |= BoardPostDisplayWidget_compact::SHOW_COMMENTS; return flags; } @@ -186,8 +186,8 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie { QWidget *w ; - if(mDisplayMode==BoardPostDisplayWidget::DISPLAY_MODE_COMPACT) - w = new BoardPostDisplayWidget(post,displayFlags(post.mMeta.mMsgId),parent); + if(mDisplayMode==BoardPostDisplayWidget_compact::DISPLAY_MODE_COMPACT) + w = new BoardPostDisplayWidget_compact(post,displayFlags(post.mMeta.mMsgId),parent); else w = new BoardPostDisplayWidget_card(post,displayFlags(post.mMeta.mMsgId),parent); @@ -278,7 +278,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI settingsChanged(); setGroupId(postedId); - mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget_compact::DISPLAY_MODE_CARD); switchDisplayMode(); // makes everything consistent and chooses classic view as default updateSorting(ui->sortStrategy_CB->currentIndex()); @@ -293,19 +293,19 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI void PostedListWidgetWithModel::switchDisplayMode() { - if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget::DISPLAY_MODE_CARD) + if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget_compact::DISPLAY_MODE_CARD) { ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/classic.png")); ui->viewModeButton->setToolTip(tr("Click to switch to card view")); - mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget_compact::DISPLAY_MODE_COMPACT); } else { ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/card.png")); ui->viewModeButton->setToolTip(tr("Click to switch to compact view")); - mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD); + mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget_compact::DISPLAY_MODE_CARD); } mPostedPostsModel->triggerRedraw(); } @@ -651,7 +651,7 @@ QIcon PostedListWidgetWithModel::groupIcon() if (mGroup.mGroupImage.mData != NULL) GxsIdDetails::loadPixmapFromData(mGroup.mGroupImage.mData, mGroup.mGroupImage.mSize, postedImage,GxsIdDetails::ORIGINAL); else - postedImage = FilesDefs::getPixmapFromQtResourcePath(BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE); + postedImage = FilesDefs::getPixmapFromQtResourcePath(BoardPostDisplayWidget_compact::DEFAULT_BOARD_IMAGE); return QIcon(postedImage); } @@ -729,7 +729,7 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) if (group.mGroupImage.mData != NULL) { GxsIdDetails::loadPixmapFromData(group.mGroupImage.mData, group.mGroupImage.mSize, chanImage,GxsIdDetails::ORIGINAL); } else { - chanImage = QPixmap(BoardPostDisplayWidget::DEFAULT_BOARD_IMAGE); + chanImage = QPixmap(BoardPostDisplayWidget_compact::DEFAULT_BOARD_IMAGE); } if(group.mMeta.mGroupName.empty()) ui->namelabel->setText(tr("[No name]")); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 44565d953..c07311e4d 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -45,7 +45,7 @@ class PostedPostDelegate: public QAbstractItemDelegate Q_OBJECT public: - PostedPostDelegate(PostedListWidgetWithModel *p,QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mPostListWidget(p),mDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT){} + PostedPostDelegate(PostedListWidgetWithModel *p,QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mPostListWidget(p),mDisplayMode(BoardPostDisplayWidget_compact::DISPLAY_MODE_COMPACT){} virtual ~PostedPostDelegate(){} void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; @@ -54,8 +54,8 @@ public: QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; void setCellWidth(int pix) { mCellWidthPix = pix; } - void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; } - BoardPostDisplayWidget::DisplayMode getDisplayMode() const { return mDisplayMode; } + void setDisplayMode(BoardPostDisplayWidget_compact::DisplayMode dm) { mDisplayMode = dm; } + BoardPostDisplayWidget_compact::DisplayMode getDisplayMode() const { return mDisplayMode; } public slots: void expandItem(RsGxsMessageId msgId,bool expanded); @@ -69,7 +69,7 @@ private: int mCellWidthPix; PostedListWidgetWithModel *mPostListWidget; // used for sending vote signals and so on. - BoardPostDisplayWidget::DisplayMode mDisplayMode; + BoardPostDisplayWidget_compact::DisplayMode mDisplayMode; std::set mExpandedItems; std::set mShowCommentItems; }; From 2561b9bc7e023704a28bebb64a56a148bd9fb8da Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 26 Sep 2020 11:21:11 +0200 Subject: [PATCH 41/78] fixed show/hide notes frame --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 10 +++++----- .../src/gui/Posted/BoardPostDisplayWidget_compact.ui | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index a3f2b592d..b441f91e3 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -111,9 +111,9 @@ void BoardPostDisplayWidget_compact::doExpand(bool e) { std::cerr << "Expanding" << std::endl; if(e) - ui->notes->show(); + ui->frame_notes->show(); else - ui->notes->hide(); + ui->frame_notes->hide(); emit expand(mPost.mMeta.mMsgId,e); } @@ -363,18 +363,18 @@ void BoardPostDisplayWidget_compact::setup() if(mDisplayFlags & SHOW_NOTES) { - notes()->show(); + ui->frame_notes->show(); ui->expandButton->setChecked(true); } else { - notes()->hide(); + ui->frame_notes->hide(); ui->expandButton->setChecked(false); } if(doc.toPlainText().trimmed().isEmpty()) { - notes()->hide(); + ui->frame_notes->hide(); ui->expandButton->hide(); } updateGeometry(); diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index 8ade5e573..cbc65bf2d 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -421,7 +421,7 @@ - + QFrame::StyledPanel From 2a51da229100753d74c5a4d194d621c3d0cffb0b Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 26 Sep 2020 14:41:20 +0200 Subject: [PATCH 42/78] fixed bugs in setting read status --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 14 ++++++-------- .../src/gui/Posted/BoardPostDisplayWidget.h | 2 +- .../src/gui/Posted/BoardPostDisplayWidget_card.ui | 2 +- .../gui/Posted/BoardPostDisplayWidget_compact.ui | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index b441f91e3..3ccf899d5 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -94,15 +94,9 @@ void BoardPostDisplayWidgetBase::makeUpVote() void BoardPostDisplayWidgetBase::setReadStatus(bool isNew, bool isUnread) { if (isUnread) - { - readButton()->setChecked(true); readButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); - } else - { - readButton()->setChecked(false); readButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png")); - } newLabel()->setVisible(isNew); } @@ -123,8 +117,10 @@ void BoardPostDisplayWidgetBase::loadComments(bool e) emit commentsRequested(mPost.mMeta.mMsgId,e); } -void BoardPostDisplayWidgetBase::readToggled(bool s) +void BoardPostDisplayWidgetBase::readToggled() { + bool s = IS_MSG_UNREAD(mPost.mMeta.mMsgStatus); + emit changeReadStatusRequested(mPost.mMeta.mMsgId,s); } void BoardPostDisplayWidgetBase::showAuthorInPeople() @@ -163,7 +159,7 @@ void BoardPostDisplayWidgetBase::setup() QObject::connect(commentButton(), SIGNAL(toggled(bool)), this, SLOT(loadComments(bool))); QObject::connect(voteUpButton(), SIGNAL(clicked()), this, SLOT(makeUpVote())); QObject::connect(voteDownButton(), SIGNAL(clicked()), this, SLOT(makeDownVote())); - QObject::connect(readButton(), SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); + QObject::connect(readButton(), SIGNAL(clicked()), this, SLOT(readToggled())); QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink())); @@ -173,6 +169,8 @@ void BoardPostDisplayWidgetBase::setup() int S = QFontMetricsF(font()).height() ; + readButton()->setChecked(false); + voteUpButton()->setIconSize(QSize(S*1.5,S*1.5)); voteDownButton()->setIconSize(QSize(S*1.5,S*1.5)); commentButton()->setIconSize(QSize(S*1.5,S*1.5)); diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 45e24a005..2ef9233b5 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -82,7 +82,7 @@ protected slots: void loadComments(bool e); void showAuthorInPeople(); - void readToggled(bool); + void readToggled(); void setReadStatus(bool isNew, bool isUnread) ; void makeUpVote() ; void makeDownVote() ; diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui index 241924862..d784b6721 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui @@ -298,7 +298,7 @@ :/images/message-state-unread.png:/images/message-state-unread.png - true + false false diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index cbc65bf2d..47a4a3890 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -330,7 +330,7 @@ :/images/message-state-unread.png:/images/message-state-unread.png - true + false false From fc20b42964469ede88a48d8757ab66f7e3ec2db1 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 26 Sep 2020 17:54:50 +0200 Subject: [PATCH 43/78] moved the buttons down in card view --- .../gui/Posted/BoardPostDisplayWidget_card.ui | 174 +++++++++--------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui index d784b6721..3a9353a40 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui @@ -277,93 +277,6 @@ - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Toggle Message Read Status - - - - :/images/message-state-unread.png:/images/message-state-unread.png - - - false - - - false - - - true - - - - - - - New - - - - - - - Share - - - - :/images/share.png:/images/share.png - - - true - - - - - - - Comments - - - - :/images/comments.png:/images/comments.png - - - true - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - @@ -420,6 +333,93 @@ + + + + + + Comments + + + + :/images/comments.png:/images/comments.png + + + true + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + + :/images/message-state-unread.png:/images/message-state-unread.png + + + false + + + false + + + true + + + + + + + New + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + From 42951e8098feb074a2baacde71b4ee948f81ffa3 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 26 Sep 2020 21:00:46 +0200 Subject: [PATCH 44/78] moved share button to the right --- .../Posted/BoardPostDisplayWidget_compact.ui | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index 47a4a3890..8762dab14 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -347,20 +347,6 @@
- - - - Share - - - - :/images/share.png:/images/share.png - - - true - - - @@ -401,6 +387,20 @@ + + + + Share + + + + :/images/share.png:/images/share.png + + + true + + + From bb820e894b3490c6eb00b7b85ddefe128d09b218 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 27 Sep 2020 01:05:08 +0200 Subject: [PATCH 45/78] fixing stylseheets - adding back from old to new --- .../src/gui/qss/stylesheet/Standard.qss | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 7ab47c667..299fb0af3 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -807,50 +807,39 @@ GxsGroupDialog QLabel#groupLogo{ border-radius: 3px; } -PostedItem QFrame#frame_notes { - background: white; -} -PostedItem QFrame#mainFrame { +BoardPostDisplayWidget_compact QFrame#frame { background-color: white; } -PostedItem QLabel#notes { - -} - PostedItem QFrame#voteFrame { background: #f8f9fa; } -PostedItem QFrame#mainFrame [new=false]{ +BoardPostDisplayWidget_compact QFrame#frame [new=false]{ background: white; } -PostedItem > QFrame#mainFrame[new=true] { +BoardPostDisplayWidget_compact QFrame#frame[new=true] { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #F0F8FD, stop:0.8 #E6F2FD, stop: 0.81 #E6F2FD, stop: 1 #D2E7FD); } -PostedItem QFrame#frame_picture{ - background: white; -} - -PostedItem QLabel#thumbnailLabel{ +BoardPostDisplayWidget_compact QLabel#pictureLabel{ border: 2px solid #CCCCCC; border-radius: 3px; } -PostedItem QLabel#fromBoldLabel, QLabel#fromLabel, QLabel#dateLabel, QLabel#siteBoldLabel { +BoardPostDisplayWidget_compact QLabel#fromBoldLabel, QLabel#fromLabel, QLabel#dateLabel, QLabel#siteBoldLabel { color: #787c7e; } -PostedItem QLabel#newLabel { +BoardPostDisplayWidget_compact QLabel#newLabel { border: 1px solid #167BE7; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2291E0, stop: 1 #3EB3FF); border-radius: 3px; } -PostedCardView QLabel#newLabel { +BoardPostDisplayWidget_card QLabel#newLabel { border: 1px solid #167BE7; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2291E0, stop: 1 #3EB3FF); border-radius: 3px; @@ -860,10 +849,17 @@ PostedCardView QFrame#voteFrame { background: #f8f9fa; } -PostedCardView QFrame#mainFrame { +BoardPostDisplayWidget_card QFrame#frame{ background: white; } +BoardPostDisplayWidget_card QFrame#frame [new=false]{ + background: white; +} + +BoardPostDisplayWidget_card > QFrame#frame[new=true] { + background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #F0F8FD, stop:0.8 #E6F2FD, stop: 0.81 #E6F2FD, stop: 1 #D2E7FD); +} GxsCommentDialog QComboBox#sortBox { font: bold; From ff0836929db7b2905f32bc093df2fc3f1a061987 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 27 Sep 2020 20:30:51 +0200 Subject: [PATCH 46/78] removed explicit color in board items to comply with css style --- retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 9ef923386..35d1e2ee4 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -88,11 +88,11 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->save(); - painter->fillRect( option.rect, option.backgroundBrush); + painter->fillRect( option.rect, option.palette.background()); painter->restore(); QPixmap pixmap(option.rect.size()); - pixmap.fill(QRgb(0x00f0f0f0)); // choose a fully transparent background + pixmap.fill(option.palette.alternateBase().color()); // use base() instead to have all widgets the same background if(mDisplayMode == BoardPostDisplayWidget_compact::DISPLAY_MODE_COMPACT) { From 819035472d0d9f7da88119e9693684e27cbc5a6e Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 27 Sep 2020 23:21:03 +0200 Subject: [PATCH 47/78] added missing code for marking all msgs as read/unread --- .../gui/Posted/PostedListWidgetWithModel.cpp | 8 +++++++- .../src/gui/Posted/PostedPostsModel.cpp | 17 +++++++++++++++++ .../src/gui/Posted/PostedPostsModel.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 35d1e2ee4..dcd6b88c4 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -658,7 +658,13 @@ QIcon PostedListWidgetWithModel::groupIcon() void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token) { - std::cerr << __PRETTY_FUNCTION__ << ": not implemented" << std::endl; + if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) + return; + + QModelIndex src_index; + + mPostedPostsModel->setAllMsgReadStatus(read); + } void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId) diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index 1eacc0ecf..36f69e7d5 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -715,6 +715,23 @@ void RsPostedPostsModel::createPostsArray(std::vector& posts) } } +void RsPostedPostsModel::setAllMsgReadStatus(bool read) +{ + // make a temporary listof pairs + + std::list pairs; + + for(uint32_t i=0;isetPostReadStatus(p,read); + } ); +} void RsPostedPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status) { if(!i.isValid()) diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.h b/retroshare-gui/src/gui/Posted/PostedPostsModel.h index 47c9f80d1..8840888dc 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.h +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.h @@ -154,6 +154,7 @@ public: void setTextColorMissing (QColor color) { mTextColorMissing = color;} #endif + void setAllMsgReadStatus(bool read); void setMsgReadStatus(const QModelIndex &i, bool read_status); void setFilter(const QStringList &strings, uint32_t &count) ; void setSortingStrategy(SortingStrategy s); From 6e33c6533436b47d54ef081d940802a8eede43c4 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 28 Sep 2020 22:27:44 +0200 Subject: [PATCH 48/78] used a more compact layout for comment button in order to align everything in compact view --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 36 ++++++---- .../Posted/BoardPostDisplayWidget_compact.ui | 70 +++++++++---------- .../src/gui/Posted/Posted_images.qrc | 1 + 3 files changed, 59 insertions(+), 48 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 3ccf899d5..65d3cd0c3 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -58,13 +58,29 @@ BoardPostDisplayWidgetBase::BoardPostDisplayWidgetBase(const RsPostedPost& post, void BoardPostDisplayWidgetBase::setCommentsSize(int comNb) { - QString sComButText = tr("Comment"); - if (comNb == 1) - sComButText = sComButText.append("(1)"); - else if(comNb > 1) - sComButText = tr("Comments ").append("(%1)").arg(comNb); + QString sComButText ; - commentButton()->setText(sComButText); + if (comNb == 1) + sComButText = tr("1 comment"); + else if(comNb > 1) + sComButText = tr("%1 comments").arg(comNb); + else + sComButText = tr("No comments yet. Click to add one."); + + commentButton()->setToolTip(sComButText); + + if(comNb > 0) + commentButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/comments_blue.png")); + else + commentButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/comments.png")); + +// QString sComButText = tr("Comment"); +// if (comNb == 1) +// sComButText = sComButText.append("(1)"); +// else if(comNb > 1) +// sComButText = tr("Comments ").append("(%1)").arg(comNb); +// +// commentButton()->setText(sComButText); } void BoardPostDisplayWidgetBase::makeDownVote() @@ -270,13 +286,7 @@ void BoardPostDisplayWidgetBase::setup() //frame_comment->show(); commentButton()->show(); - if (mPost.mComments) - { - QString commentText = tr("Comments (%1)").arg(QString::number(mPost.mComments)); - commentButton()->setText(commentText); - } - else - commentButton()->setText(tr("Comment")); + setCommentsSize(mPost.mComments); setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index 8762dab14..de1fc0634 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -311,6 +311,26 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + New + + + @@ -341,9 +361,22 @@ - + - New + + + + + :/images/comments.png:/images/comments.png + + + true + + + Qt::ToolButtonTextBesideIcon + + + true @@ -367,26 +400,6 @@ - - - - Comments - - - - :/images/comments.png:/images/comments.png - - - true - - - Qt::ToolButtonTextBesideIcon - - - true - - - @@ -401,19 +414,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - diff --git a/retroshare-gui/src/gui/Posted/Posted_images.qrc b/retroshare-gui/src/gui/Posted/Posted_images.qrc index 0710a04e6..fab0bae65 100644 --- a/retroshare-gui/src/gui/Posted/Posted_images.qrc +++ b/retroshare-gui/src/gui/Posted/Posted_images.qrc @@ -5,6 +5,7 @@ images/down-arrow.png images/up-arrow.png images/comments.png + images/comments_blue.png images/thumb-default.png images/thumb-link.png images/share.png From d3cb789fcd3163b13af537e7b1099072cc062763 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 29 Sep 2020 08:18:34 +0200 Subject: [PATCH 49/78] added missing file --- .../src/gui/Posted/images/comments_blue.png | Bin 0 -> 4373 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 retroshare-gui/src/gui/Posted/images/comments_blue.png diff --git a/retroshare-gui/src/gui/Posted/images/comments_blue.png b/retroshare-gui/src/gui/Posted/images/comments_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..07c15a1a038c4dd5cc2c63b80556a3e955350196 GIT binary patch literal 4373 zcmaJ^bx;%zw_REqBn9baDWwq*1QA%4PNkQnkrbpux;vH@kXS-;=~fU}nxz-em2_zd z1$_Qy-h1D?H}idS=iGDW{&DX4rte1UtXPdMjO%dO7w}0&` zRdjTA=@qweG?~9hT4WF&+#aIYmE>NaQ%ultch@a|0QRoouZwiwBa>_1vFj`ZDm7*zsOpx+=ygN`tftMTY;JYh#XcO_)Ta2ai`0iDe_?M%CI+> zUoN@s5pRC;nKW2zwCj7%kGf!&5mu`7G^0 zD>hG7Jr?}Co01Y4isvv`4u0&cntXJ=VVuEC^PQ-pa2yI#5-wSay_maeS^4}(C({A^7F4w;suNp%Hk z1ty&o$JE61joG2|sC1+#;BXey&_h1xFr22w`gp9W4E%HmpVz+V@px^sumin%<5x|f zs2Ox&L8`HBDESGt8=7O`7x;4p2`_Hr>)w8Cc{XAor)}Bu*^KLyb5Njw`{x7JvzaYV zJxZ!+%V7J2gc`;pCAzuXQj;7p>RCj*<=?rCE@oSI{p-%C2F+}Xu=Rv$410Gdl zM~$HSIf&vUpl>4D+l~%DN98p2F8sxM(+$8XICq_Tr>Ik_(cO1&=IFT1H7MS!pc2W5C zcMBl3k#98h35&5#>+7{N=#(zBA-9bef4b#nsY`Qu<5OYt(0Qb(0A`yVC%;^-iEpL` zBSzY~l!lu&tgYCp;L8WLqb&BJ2gP&FenI2g<)3^Xlcm&|2fFRkijXU0^lNbN(x=Lf z33jDf=g)Ah) zs{OE?Rx{=7TqL>A1x7Zj1()yjVeVAJb3xOh~?(2kf_mQf%CK-;F0R?B_f%VS}o*(bn^tcm@_ zN0H=<^Smw`7T%S$2L}R)oqQLXh7$zi#hIPYozm5wo8VR5d0s*QJU}T+Qw}#2Bn-R*Z5Qa-rOc4y%t)KH@=XyKtiC!bN@ZM zlLhLSoG}lfGn_*pOM&`G9;q}oo}vNbyY?S54RdS?v*H;e9!ovmD{l@%N~A^^X|C&4 znpz1D=jlIDqqR?4J>$!iGS}EgUufzIS7@>JzC=VWg=E|YCAAku*=mg0>~sgluKSGb zz`Tb>1yH&U%GhT1c4e-)AqtZZI>_Lr4i&Pn!IiDMQfZXNg9ct-xE9@H=S`&aL_L(r z8;#-LWZ&bhbft2zeZb!_$bqjLhrg*jE7cjrda)Tg5mwaUra_f~*YT9j6%Fz|`mV@< z3aU63w?$52k6TU8yn#W&s2fx}+b7rt(`A|I+0>O*+qFXwN+jgmcwHns0IdmgB27n; zg<#FPFbXgv$9&y7*!c^2UMUWB8++`eUA%6~uFdG4ea_XITAqdX{G~RV;}i#Wjv=s& zsI(2+!ivWp*v};aRZiD>!o+3~UYNS-^5iO}*0E&5_aTLCkBH~mv0W+VDp>SA(-L0e zJAs)kCG|biiWX`wpEF;$Bkf)jS?@<`eHUrje;aS< zBPiqMh`&qPaj@5-Y=|dTsD~d<*+jYvwgLl52vl1gqZhk8;8yMM)6GUK#gmz?*^cw)5FQJdF-vzwAH5TL|CcuRdDdqW1|_pbHXbyF zdP0!ee>)@j2zAE^u59N!N{QY+sVSbD4l+DJFu{%zuMEhMerh+>(c4eB?hIAVYV(aO znVX^DcMs*>SB^uNFyPa$LD3SsO6NJ43d*}8*lIxeJ&e>cKYgj{ibEx~o_q0yY{TB` zkVSv3&T^-MSAZyry&A>Z`;3oWm+|r~_R!;|w=B51UDF@Aa;tS4ezyd# zS}e1=T(TJW5#dheqn;#Tzac=sJ?Ef@wH7~*gN0DlNhUzh=Lw6@y&C231@> zJdA>r*;ZVfO^B*~_iEIUrsQ#}-Z)l%LwPZ9Sy8>Cv>Fx>wV)5~AgK%;M98ZRLxy9+VLovgK>$AJOKK5xO% z3NvyR>V*aGnH>*&z}Vs5g*zJ!&R%SP90yoqf7?|M?e0CP8pS|l63#dP;U4e>R10%~ z;1JDf9$d2H8a;zixMd2YcHPWe@Ux4%>d_~8{|ruQFv(0hgyZ6IssTK`;iVTUMhN*~ zNm>a$m!we7DuOX+8X#wkn2J(2m+%^NWx*Z&x>Is%R>{SDmWq70WKt8z)Ezu(zp-uf zG5&jvA_6diBa^4JA|!y#GIePOVvVw|YcUnyyiZ#mT5t;RJ6+NDxUPQVUuvGc{*~Dv z^R6fa**bwOQFhxJcFTTlz`SR*Cq&7WOgc-&Ln^5|8j&sP_z;`r8 zJFDGKKPsGvaM{}!V^S-C!W*&4zvNcb2J>&gJ&4}6UJ0wR1Tr&2Blr>S=y78Pe2lXy zOPfkX(aubW_0Nc*|w# zBc^NXYCl#?Lf-apQ!g#a62<6N>zBIBcXZ-lW%{bTclR?_NUeCq**>v5u;et7w5CUW z-~LJb!(W*g`3`ToeD^>%bN}@|+;Gz)%vQJ}>%(bT9kG>uUTR`aPHdTORFNRpHXP>x zf6Xt`?&%cmreLd-bIk~6jcMsvdfF(0B=tVjKn(t}lddS-!pk-MiY+sP_{LeLSp8Z~ zH&HF#(VewoG?to>SH?F+y(FEEV)tZtJn7N-%Sk;iHhG)F&IoyO=v#b%Wn;^Ih1fmP z&u+i8TjIuB4_0+vROTZBk|;tc9>-eW>n|sLsd-yKn`)r>z)!Q%8%uPcJWCecy=d;))mFoR3=EK` zTBpU>t1wJ4pE*})-R1oeXDJh;JHr_r7tHnM`UcvRl~EJ=cp*sLNRXA{E+gUY0)|;N zyeVq5X)vqC{=w^kw(}UwFzEpRIFU{&D!LjfD*uyo{^py4;4}sGAtlD>jW$gqK?-}S zz0^`UGk(FZRYv^JqI7{R`_^82Y!Z*S1w@h~Tm}Y;Kh?ZTXs)NIk6^#T`-<5u-{s^9 z$)SBY{MN&d@+kOdeBDp!qaGBtkOh!fmlCfo&mC`w-7-1nBnd}FP6$Da(`S!atS;{z z--=8&-yGaMymcP1RZ`+EvWa%0X`s<@TOr&DwhhmMW?dD$ohT>0|J2Lk@ja{QZWkaUBITg0_A>RxP#%LPh*(98k`{SO8*8> zLR-)aRluKrs-&kfL7 zHl&%vn)Lsx>aq&k2>weUB^*(r2{LURF{A6J|39*SkCe#295nn7*8Z{m2LBk$+VPO` zw;sVqf-A-1dHA1I1px8s;L{FbZe`;uhhkjyRGK@n39{&*yZ1K9odcpIN|C=b=OOWQ?qVuCBLZ*-r_9k`qHqD6I?ftP{C+xO_M*^wER$K-A+orJa z+pN$$zeUQAQBe&(ma|ZmQ3bpzUsIIZi)n?3s<-+pZ$L}1a6<*&qh3CbBx}J-^-M>S z9;ng+v)z~v!3Jkli)oFz!a(LmRRjp{_wV=MHS!gI3~X*HOR{rg4$ Njpy2`_0Oy${tFb=Pn`e& literal 0 HcmV?d00001 From 703a6998309911b8aa0f7f75b8406c2800afe2a4 Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 30 Sep 2020 21:30:05 +0200 Subject: [PATCH 50/78] Fixed for Boards some forgetten stylesheets --- retroshare-gui/src/gui/qss/stylesheet/Standard.qss | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 299fb0af3..d8e7bb4f5 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -699,16 +699,16 @@ GenCertDialog QFrame#profileframe{ border-width: 0px; } -PostedListWidget QComboBox#comboBox { +PostedListWidgetWithModel QComboBox#sortStrategy_CB { font: bold; color: #0099cc; } -PostedListWidget QToolButton#submitPostButton { +PostedListWidgetWithModel QToolButton#submitPostButton { font: bold; } -PostedListWidget QToolButton#subscribeToolButton { +PostedListWidgetWithModel QToolButton#subscribeToolButton { font: bold; font-size: 15px; color: white; @@ -717,12 +717,12 @@ PostedListWidget QToolButton#subscribeToolButton { max-height: 27px; } -PostedListWidget QToolButton#subscribeToolButton:hover { +PostedListWidgetWithModel QToolButton#subscribeToolButton:hover { background: #03b1f3; border-radius: 4px; } -PostedListWidget QFrame#headerFrame { +PostedListWidgetWithModel QFrame#headerFrame { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC; } @@ -866,7 +866,7 @@ GxsCommentDialog QComboBox#sortBox { color: #0099cc; } -PostedListWidget QTextBrowser#infoDescription { +PostedListWidgetWithModel QTextBrowser#infoDescription { background: transparent; border: none; } From 5c240c6abb425a323e59e918c77e6069efd8089d Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 30 Sep 2020 21:35:30 +0200 Subject: [PATCH 51/78] fixed layout of compact view to use a constant apsect ratio with cropping --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 21 +++- .../Posted/BoardPostDisplayWidget_compact.ui | 104 +++++++++--------- .../gui/Posted/PostedListWidgetWithModel.cpp | 5 + .../gxschannels/GxsChannelPostThumbnail.cpp | 22 +++- .../gui/gxschannels/GxsChannelPostThumbnail.h | 7 +- retroshare-gui/src/util/ClickableLabel.h | 2 +- 6 files changed, 100 insertions(+), 61 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 65d3cd0c3..f69bb9c89 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -43,6 +43,8 @@ #define LINK_IMAGE ":/images/thumb-link.png" +// #ifdef DEBUG_BOARDPOSTDISPLAYWIDGET 1 + /** Constructor */ const char *BoardPostDisplayWidget_compact::DEFAULT_BOARD_IMAGE = ":/icons/png/newsfeed2.png"; @@ -119,7 +121,9 @@ void BoardPostDisplayWidgetBase::setReadStatus(bool isNew, bool isUnread) void BoardPostDisplayWidget_compact::doExpand(bool e) { +#ifdef DEBUG_BOARDPOSTDISPLAYWIDGET std::cerr << "Expanding" << std::endl; +#endif if(e) ui->frame_notes->show(); else @@ -335,6 +339,7 @@ void BoardPostDisplayWidget_compact::setup() // show/hide things based on the view type setAttribute(Qt::WA_DeleteOnClose, true); + ui->pictureLabel->setEnableZoom(false); RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); @@ -350,10 +355,15 @@ void BoardPostDisplayWidget_compact::setup() GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); // Wiping data - as its been passed to thumbnail. - int desired_height = QFontMetricsF(font()).height() * 5; +#ifdef DEBUG_BOARDPOSTDISPLAYWIDGET + std::cerr << "Got pixmap of size " << pixmap.width() << " x " << pixmap.height() << std::endl; + std::cerr << "Saving to pix.png" << std::endl; + pixmap.save("pix.png","PNG"); +#endif - QPixmap scaledpixmap = pixmap.scaledToHeight(desired_height, Qt::SmoothTransformation); - ui->pictureLabel->setPixmap(scaledpixmap); + int desired_height = QFontMetricsF(font()).height() * 5; + ui->pictureLabel->setFixedSize(16/9.0*desired_height,desired_height); + ui->pictureLabel->setPicture(pixmap); } else if (mPost.mImage.mData == NULL) ui->pictureLabel->hide(); @@ -465,13 +475,12 @@ void BoardPostDisplayWidget_card::setup() GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); // Wiping data - as its been passed to thumbnail. - QPixmap scaledpixmap; if(pixmap.width() > 800){ QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); - pictureLabel()->setPixmap(scaledpixmap); + ui->pictureLabel->setPixmap(scaledpixmap); }else{ - pictureLabel()->setPixmap(pixmap); + ui->pictureLabel->setPixmap(pixmap); } } else if (mPost.mImage.mData == NULL) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index de1fc0634..dd5ce6868 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -163,7 +163,7 @@ - + 0 @@ -311,55 +311,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - New - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Toggle Message Read Status - - - - :/images/message-state-unread.png:/images/message-state-unread.png - - - false - - - false - - - true - - - @@ -414,6 +365,55 @@ + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + + :/images/message-state-unread.png:/images/message-state-unread.png + + + false + + + false + + + true + + + + + + + New + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -489,9 +489,9 @@
gui/common/StyledLabel.h
- ClickableLabel + ZoomableLabel QLabel -
util/ClickableLabel.h
+
gui/gxschannels/GxsChannelPostThumbnail.h
diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index dcd6b88c4..80543510b 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -99,6 +99,8 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & BoardPostDisplayWidget_compact w(post,displayFlags(post.mMeta.mMsgId),nullptr); w.setFixedSize(option.rect.size()); + + w.updateGeometry(); w.adjustSize(); w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background } @@ -107,6 +109,7 @@ void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & BoardPostDisplayWidget_card w(post,displayFlags(post.mMeta.mMsgId),nullptr); w.setFixedSize(option.rect.size()); + w.updateGeometry(); w.adjustSize(); w.render(&pixmap,QPoint(0,0),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background } @@ -198,6 +201,8 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie w->setFixedSize(option.rect.size()); w->adjustSize(); + w->updateGeometry(); + w->adjustSize(); return w; } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index 7c4bc62da..ea887212c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -18,12 +18,16 @@ * * *******************************************************************************/ +#include + #include #include #include "gui/common/FilesDefs.h" #include "gui/gxschannels/GxsChannelPostThumbnail.h" +// #define DEBUG_GXSCHANNELPOSTTHUMBNAIL 1 + const float ChannelPostThumbnailView::DEFAULT_SIZE_IN_FONT_HEIGHT = 5.0; const float ChannelPostThumbnailView::FONT_SCALE_FACTOR = 1.5; @@ -50,7 +54,9 @@ void ChannelPostThumbnailView::setText(const QString& s) { if(mPostTitle == NULL) { +#ifdef DEBUG_GXSCHANNELPOSTTHUMBNAIL std::cerr << "(EE) calling setText on a ChannelPostThumbnailView without SHOW_TEXT flag!"<< std::endl; +#endif return; } @@ -246,6 +252,8 @@ void ZoomableLabel::mousePressEvent(QMouseEvent *me) mMoving = true; mLastX = me->x(); mLastY = me->y(); + + emit clicked(); } void ZoomableLabel::mouseReleaseEvent(QMouseEvent *) { @@ -292,7 +300,11 @@ QPixmap ZoomableLabel::extractCroppedScaledPicture() const void ZoomableLabel::setPicture(const QPixmap& pix) { +#ifdef DEBUG_GXSCHANNELPOSTTHUMBNAIL + std::cerr << "Setting new picture of size " << pix.width() << " x " << pix.height() << std::endl; +#endif mFullImage = pix; + setScaledContents(true); reset(); updateView(); @@ -312,7 +324,15 @@ void ZoomableLabel::updateView() // - the original center is preferred // - if the crop overlaps the image border, the center is moved. - QRect rect(mCenterX - 0.5 * width()*mZoomFactor, mCenterY - 0.5 * height()*mZoomFactor, width()*mZoomFactor, height()*mZoomFactor); + QRect rect(mCenterX - 0.5 * width()*mZoomFactor, mCenterY - 0.5 * height()*mZoomFactor, floor(width()*mZoomFactor), floor(height()*mZoomFactor)); + +#ifdef DEBUG_GXSCHANNELPOSTTHUMBNAIL + std::cerr << "Updating view: mCenterX=" << mCenterX << ", mCenterY=" << mCenterY << ", mZoomFactor=" << mZoomFactor << std::endl; + std::cerr << " Image size: " << mFullImage.width() << " x " << mFullImage.height() << ", window size: " << width() << " x " << height() << std::endl; + std::cerr << " cropped image: " << rect.left() << "," << rect.top() << "+" << rect.width() << "+" << rect.height() << std::endl; + std::cerr << " saving crop to pix2.png" << std::endl; + mFullImage.copy(rect).save("pix2.png","PNG"); +#endif QLabel::setPixmap(mFullImage.copy(rect)); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index b231fbe0a..43d87c031 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -37,6 +37,8 @@ class ZoomableLabel: public QLabel { + Q_OBJECT + public: ZoomableLabel(QWidget *parent): QLabel(parent),mZoomFactor(1.0),mCenterX(0.0),mCenterY(0.0),mZoomEnabled(true) {} @@ -48,6 +50,9 @@ public: const QPixmap& originalImage() const { return mFullImage ; } +signals: + void clicked(); + protected: void mousePressEvent(QMouseEvent *ev) override; void mouseReleaseEvent(QMouseEvent *ev) override; @@ -57,9 +62,9 @@ protected: QPixmap mFullImage; + float mZoomFactor; float mCenterX; float mCenterY; - float mZoomFactor; int mLastX,mLastY; bool mMoving; bool mZoomEnabled; diff --git a/retroshare-gui/src/util/ClickableLabel.h b/retroshare-gui/src/util/ClickableLabel.h index bd8c68ed8..de4dcce92 100644 --- a/retroshare-gui/src/util/ClickableLabel.h +++ b/retroshare-gui/src/util/ClickableLabel.h @@ -37,7 +37,7 @@ signals: void clicked(); protected: - void mousePressEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event) override; void enterEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #039bd5; }");} void leaveEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #CCCCCC; border-radius: 3px; }");} From 0078f02d39ed7f4f04ef190f677525d155697007 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 30 Sep 2020 21:42:47 +0200 Subject: [PATCH 52/78] fixed toolbutton noText property for comments, and let Qt decide on the size of icons --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 10 +++++----- .../src/gui/Posted/BoardPostDisplayWidget_compact.ui | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index f69bb9c89..7e8ced3ea 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -191,11 +191,11 @@ void BoardPostDisplayWidgetBase::setup() readButton()->setChecked(false); - voteUpButton()->setIconSize(QSize(S*1.5,S*1.5)); - voteDownButton()->setIconSize(QSize(S*1.5,S*1.5)); - commentButton()->setIconSize(QSize(S*1.5,S*1.5)); - readButton()->setIconSize(QSize(S*1.5,S*1.5)); - shareButton()->setIconSize(QSize(S*1.5,S*1.5)); +// voteUpButton()->setIconSize(QSize(S*1.5,S*1.5)); +// voteDownButton()->setIconSize(QSize(S*1.5,S*1.5)); +// commentButton()->setIconSize(QSize(S*1.5,S*1.5)); +// readButton()->setIconSize(QSize(S*1.5,S*1.5)); +// shareButton()->setIconSize(QSize(S*1.5,S*1.5)); QMenu *menu = new QMenu(); menu->addAction(CopyLinkAction); diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index dd5ce6868..a7380da9d 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -324,7 +324,7 @@ true - Qt::ToolButtonTextBesideIcon + Qt::ToolButtonIconOnly true From 70cfdd38ef3ab0a0e72d83e6cc19df860d4640de Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 30 Sep 2020 21:55:27 +0200 Subject: [PATCH 53/78] fixed darkstyle sheet --- retroshare-gui/src/qss/qdarkstyle.qss | 40 +++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index af56cfc8d..6e73d5097 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -1247,26 +1247,26 @@ GxsForumThreadWidget QLabel#forumName font: bold; } -PostedItem QPushButton#shareButton +BoardPostDisplayWidget_compact QPushButton#shareButton { - background-color: transparent; + background-color: transparent; border: none; min-width: 75px; max-height: 22px; } -PostedCardView QPushButton#shareButton +BoardPostDisplayWidget_card QPushButton#shareButton { - background-color: transparent; + background-color: transparent; border: none; min-width: 75px; } -PostedItem QFrame#voteFrame { +BoardPostDisplayWidget_compact QFrame#voteFrame { background: #141415; } -PostedCardView QFrame#voteFrame { +BoardPostDisplayWidget_card QFrame#voteFrame { background: #141415; } @@ -1275,30 +1275,48 @@ QPushButton#shareButton:hover, QPushButton#shareButton::menu-button:hover { border: 1px solid gray; } -PostedItem QToolButton#voteDownButton, QToolButton#voteUpButton, QToolButton#expandButton, QToolButton#readButton, +BoardPostDisplayWidget_compact QToolButton#voteDownButton, QToolButton#voteUpButton, QToolButton#expandButton, QToolButton#readButton, QToolButton#commentButton, QToolButton#notesButton { border: none; } -PostedItem QLabel#thumbnailLabel{ +BoardPostDisplayWidget_compact QLabel#pictureLabel{ border: 2px solid #CCCCCC; border-radius: 3px; } -PostedCardView QToolButton#voteDownButton, QToolButton#voteUpButton +BoardPostDisplayWidget_card QToolButton#voteDownButton, QToolButton#voteUpButton { border: none; } -PostedCardView QFrame#mainFrame [new=false]{ +BoardPostDisplayWidget_card QFrame#frame{ background: #302F2F; } -PostedCardView > QFrame#mainFrame[new=true] { +BoardPostDisplayWidget_card > QFrame#frame [new=false]{ + background: #302F2F; +} + +BoardPostDisplayWidget_card > QFrame#frame[new=true] { background-color: #005000; } +BoardPostDisplayWidget_compact QLabel#newLabel { + border: 1px solid #00B712; + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5AFF15, stop: 1 #00B712); + border-radius: 3px; + color: black; +} + +BoardPostDisplayWidget_card QLabel#newLabel { + border: 1px solid #00B712; + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5AFF15, stop: 1 #00B712); + border-radius: 3px; + color: black; +} + WireGroupItem QFrame#wire_frame { border: 1px solid #38444d; From fc4c111d1add65f54cbbdf82dc9a74827e47d64c Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 30 Sep 2020 22:44:13 +0200 Subject: [PATCH 54/78] added missing tooltip --- .../src/gui/Posted/BoardPostDisplayWidget_compact.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index a7380da9d..e2fb4f8b1 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -170,6 +170,9 @@ 0 + + Click to view picture + PictureLabel_compact From c346cff2fd67da6452a75ec374ad204afa99883e Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 30 Sep 2020 23:18:45 +0200 Subject: [PATCH 55/78] few more fixes for dark stylesheets --- retroshare-gui/src/qss/qdarkstyle-v2.qss | 42 ++++++++++++------------ retroshare-gui/src/qss/qdarkstyle.qss | 18 +++++----- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/retroshare-gui/src/qss/qdarkstyle-v2.qss b/retroshare-gui/src/qss/qdarkstyle-v2.qss index 4f6ee1cae..3bfe94a19 100644 --- a/retroshare-gui/src/qss/qdarkstyle-v2.qss +++ b/retroshare-gui/src/qss/qdarkstyle-v2.qss @@ -1983,7 +1983,7 @@ QTreeView [new=true]{ /* changes for the subscribe Button */ -PostedListWidget QToolButton#subscribeToolButton { +PostedListWidgetWithModel QToolButton#subscribeToolButton { font: bold; font-size: 15px; color: white; @@ -1992,7 +1992,7 @@ PostedListWidget QToolButton#subscribeToolButton { max-height: 27px; } -PostedListWidget QToolButton#subscribeToolButton:hover { +PostedListWidgetWithModel QToolButton#subscribeToolButton:hover { background: #03b1f3; border-radius: 4px; } @@ -2011,7 +2011,7 @@ GxsForumThreadWidget QToolButton#subscribeToolButton:hover { border-radius: 4px; } -GxsChannelPostsWidget QToolButton#subscribeToolButton { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton { font: bold; font-size: 14px; color: white; @@ -2020,18 +2020,18 @@ GxsChannelPostsWidget QToolButton#subscribeToolButton { max-height: 27px; } -GxsChannelPostsWidget QToolButton#subscribeToolButton:hover { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton:hover { background: #03b1f3; border-radius: 4px; } -GxsChannelPostsWidget QToolButton#subscribeToolButton:pressed { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton:pressed { background: #03b1f3; border-radius: 4px; border: 1px solid gray; } -GxsChannelPostsWidget QToolButton#subscribeToolButton:disabled { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton:disabled { background: gray; border-radius: 4px; border: 1px solid gray; @@ -2039,15 +2039,15 @@ GxsChannelPostsWidget QToolButton#subscribeToolButton:disabled { } /* only for MenuButtonPopup */ -GxsChannelPostsWidget QToolButton#subscribeToolButton[popupMode="1"] { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton[popupMode="1"] { padding-right: 0px; } -GxsChannelPostsWidget QToolButton#subscribeToolButton::menu-arrow { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton::menu-arrow { image: none; } -GxsChannelPostsWidget QToolButton#subscribeToolButton::menu-button { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton::menu-button { image: none; } @@ -2074,7 +2074,7 @@ PostedCreatePostDialog QPushButton#submitButton:hover { } -PostedItem QFrame#mainFrame { +BoardPostDisplayWidget_compact QFrame#mainFrame { border-radius: 4px; border: 1px solid #32414B; background-color: #19232D; @@ -2088,7 +2088,7 @@ GxsChannelPostItem QFrame#mainFrame { } -PostedItem QPushButton#shareButton +BoardPostDisplayWidget_compact QPushButton#shareButton { background-color: transparent; min-width: 80px; @@ -2096,28 +2096,28 @@ PostedItem QPushButton#shareButton } -PostedItem QLabel#scoreLabel +BoardPostDisplayWidget_compact QLabel#scoreLabel { background-color: transparent; } -PostedItem QFrame#voteFrame { +BoardPostDisplayWidget_compact QFrame#voteFrame { background: #141415; } -PostedItem QToolButton#voteDownButton, QToolButton#voteUpButton +BoardPostDisplayWidget_compact QToolButton#voteDownButton, QToolButton#voteUpButton, +BoardPostDisplayWidget_card QToolButton#voteDownButton, QToolButton#voteUpButton { border: none; - } -PostedItem QLabel#thumbnailLabel{ +BoardPostDisplayWidget_compact QLabel#pictureLabel{ border: 2px solid #CCCCCC; border-radius: 3px; } -PostedCardView QPushButton#shareButton +BoardPostDisplayWidget_card QPushButton#shareButton { background-color: transparent; min-width: 80px; @@ -2125,21 +2125,21 @@ PostedCardView QPushButton#shareButton } -PostedCardView QFrame#voteFrame { +BoardPostDisplayWidget_card QFrame#voteFrame { background: #141415; } -PostedCardView QFrame#mainFrame { +BoardPostDisplayWidget_card QFrame#mainFrame { background-color: #19232D; } -PostedCardView QFrame#mainFrame [new=false]{ +BoardPostDisplayWidget_card QFrame#mainFrame [new=false]{ background: #19232D; } -PostedCardView > QFrame#mainFrame[new=true] { +BoardPostDisplayWidget_card > QFrame#mainFrame[new=true] { background-color: #005000; } diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index 6e73d5097..d7e1a38e8 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -1148,7 +1148,7 @@ OpModeStatus[opMode="Minimal"] { /* changes for the subscribe Button */ -PostedListWidget QToolButton#subscribeToolButton { +PostedListWidgetWithModel QToolButton#subscribeToolButton { font: bold; font-size: 15px; color: white; @@ -1157,7 +1157,7 @@ PostedListWidget QToolButton#subscribeToolButton { max-height: 27px; } -PostedListWidget QToolButton#subscribeToolButton:hover { +PostedListWidgetWithModel QToolButton#subscribeToolButton:hover { background: #03b1f3; border-radius: 4px; } @@ -1176,7 +1176,7 @@ GxsForumThreadWidget QToolButton#subscribeToolButton:hover { border-radius: 4px; } -GxsChannelPostsWidget QToolButton#subscribeToolButton { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton { font: bold; font-size: 14px; color: white; @@ -1185,18 +1185,18 @@ GxsChannelPostsWidget QToolButton#subscribeToolButton { max-height: 27px; } -GxsChannelPostsWidget QToolButton#subscribeToolButton:hover { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton:hover { background: #03b1f3; border-radius: 4px; } -GxsChannelPostsWidget QToolButton#subscribeToolButton:pressed { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton:pressed { background: #03b1f3; border-radius: 4px; border: 1px solid gray; } -GxsChannelPostsWidget QToolButton#subscribeToolButton:disabled { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton:disabled { background: gray; border-radius: 4px; border: 1px solid gray; @@ -1204,15 +1204,15 @@ GxsChannelPostsWidget QToolButton#subscribeToolButton:disabled { } /* only for MenuButtonPopup */ -GxsChannelPostsWidget QToolButton#subscribeToolButton[popupMode="1"] { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton[popupMode="1"] { padding-right: 0px; } -GxsChannelPostsWidget QToolButton#subscribeToolButton::menu-arrow { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton::menu-arrow { image: none; } -GxsChannelPostsWidget QToolButton#subscribeToolButton::menu-button { +GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton::menu-button { image: none; } From c30c7a4dfe5259b888f03925a777f6fd54f42c80 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 1 Oct 2020 20:25:10 +0200 Subject: [PATCH 56/78] make interactions on BoardPostWidget to mark the post as read --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 14 +++++++------- .../src/gui/Posted/BoardPostDisplayWidget.h | 3 +++ .../gui/Posted/PostedListWidgetWithModel.cpp | 17 +++++++++++++++++ .../src/gui/Posted/PostedListWidgetWithModel.h | 1 + .../src/gui/Posted/PostedPostsModel.cpp | 12 +++++++----- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 7e8ced3ea..49b92de00 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -191,18 +191,14 @@ void BoardPostDisplayWidgetBase::setup() readButton()->setChecked(false); -// voteUpButton()->setIconSize(QSize(S*1.5,S*1.5)); -// voteDownButton()->setIconSize(QSize(S*1.5,S*1.5)); -// commentButton()->setIconSize(QSize(S*1.5,S*1.5)); -// readButton()->setIconSize(QSize(S*1.5,S*1.5)); -// shareButton()->setIconSize(QSize(S*1.5,S*1.5)); - QMenu *menu = new QMenu(); menu->addAction(CopyLinkAction); menu->addSeparator(); menu->addAction(showInPeopleAct); shareButton()->setMenu(menu); + connect(shareButton(),SIGNAL(pressed()),this,SLOT(handleShareButtonClicked())); + RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); @@ -307,6 +303,10 @@ void BoardPostDisplayWidgetBase::setup() emit sizeChanged(this); #endif } +void BoardPostDisplayWidgetBase::handleShareButtonClicked() +{ + emit shareButtonClicked(); +} //=================================================================================================================================== //== class BoardPostDisplayWidget == //=================================================================================================================================== @@ -423,7 +423,7 @@ void BoardPostDisplayWidget_compact::viewPicture() PView->show(); - /* window will destroy itself! */ + emit thumbnailOpenned(); } QToolButton *BoardPostDisplayWidget_compact::voteUpButton() { return ui->voteUpButton; } diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 2ef9233b5..edf8bf760 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -87,12 +87,15 @@ protected slots: void makeUpVote() ; void makeDownVote() ; void setCommentsSize(int comNb) ; + void handleShareButtonClicked() ; signals: void changeReadStatusRequested(const RsGxsMessageId&,bool); void vote(const RsGxsGrpMsgIdPair& msgId, bool up_or_down); void expand(RsGxsMessageId,bool); void commentsRequested(const RsGxsMessageId&,bool); + void thumbnailOpenned(); + void shareButtonClicked(); protected: RsPostedPost mPost; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 80543510b..d4bec080a 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -199,6 +199,13 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie QObject::connect(w,SIGNAL(commentsRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(openComments(const RsGxsMessageId&))); QObject::connect(w,SIGNAL(changeReadStatusRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(changeReadStatus(const RsGxsMessageId&,bool))); + // All other interactions with the widget should cause the msg to be set as read. + QObject::connect(w,SIGNAL(thumbnailOpenned()),mPostListWidget,SLOT(markCurrentPostAsRead())); + QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(markCurrentPostAsRead())); + QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(markCurrentPostAsRead())); + QObject::connect(w,SIGNAL(commentsRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(markCurrentPostAsRead())); + QObject::connect(w,SIGNAL(shareButtonClicked()),mPostListWidget,SLOT(markCurrentPostAsRead())); + w->setFixedSize(option.rect.size()); w->adjustSize(); w->updateGeometry(); @@ -692,6 +699,16 @@ void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId) ui->tabWidget->addTab(commentDialog,title); } +void PostedListWidgetWithModel::markCurrentPostAsRead() +{ + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + + if(!index.isValid()) + throw std::runtime_error("No post under mouse!"); + + mPostedPostsModel->setMsgReadStatus(index,true); +} + void PostedListWidgetWithModel::changeReadStatus(const RsGxsMessageId& msgId,bool b) { QModelIndex index=mPostedPostsModel->getIndexOfMessage(msgId); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index c07311e4d..63dcbf9e1 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -149,6 +149,7 @@ private slots: public slots: void handlePostsTreeSizeChange(QSize size); void voteMsg(RsGxsGrpMsgIdPair msg,bool up_or_down); + void markCurrentPostAsRead(); private: void processSettings(bool load); diff --git a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp index 36f69e7d5..afd71d8b1 100644 --- a/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedPostsModel.cpp @@ -748,13 +748,15 @@ void RsPostedPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status) RsGxsGroupId grpId = mPosts[entry].mMeta.mGroupId; RsGxsMessageId msgId = mPosts[entry].mMeta.mMsgId; - RsThread::async([msgId,grpId,read_status]() - { - // Call blocking API + bool current_read_status = !(IS_MSG_UNREAD(mPosts[entry].mMeta.mMsgStatus) || IS_MSG_NEW(mPosts[entry].mMeta.mMsgStatus)); - rsPosted->setPostReadStatus(RsGxsGrpMsgIdPair(grpId,msgId),read_status); - } ); + if(current_read_status != read_status) + RsThread::async([msgId,grpId,read_status]() + { + // Call blocking API + rsPosted->setPostReadStatus(RsGxsGrpMsgIdPair(grpId,msgId),read_status); + } ); } QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const From 5e2f46a5fc1c83544bb815aa0ce65fc587d0a2a8 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 1 Oct 2020 21:06:33 +0200 Subject: [PATCH 57/78] use the comments ID to create new comment --- .../src/gui/Posted/PostedCreatePostDialog.cpp | 15 ++++++++++++--- .../src/gui/Posted/PostedCreatePostDialog.h | 2 +- .../src/gui/Posted/PostedListWidgetWithModel.cpp | 6 ++++-- retroshare-gui/src/gui/gxs/GxsIdChooser.cpp | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp index fada00020..7eb9cfc3a 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp @@ -44,7 +44,7 @@ #define VIEW_IMAGE 2 #define VIEW_LINK 3 -PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGroupId& grpId, QWidget *parent): +PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGroupId& grpId, const RsGxsId& default_author, QWidget *parent): QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint), mPosted(posted), mGrpId(grpId), ui(new Ui::PostedCreatePostDialog) @@ -69,8 +69,8 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou ui->sizeWarningLabel->setText(QString("Post size is limited to %1 KB, pictures will be downscaled.").arg(MAXMESSAGESIZE / 1024)); /* fill in the available OwnIds for signing */ - ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId()); - + ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, default_author); + QSignalMapper *signalMapper = new QSignalMapper(this); connect(ui->postButton, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(ui->imageButton, SIGNAL(clicked()), signalMapper, SLOT(map())); @@ -85,6 +85,15 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou /* load settings */ processSettings(true); + + // Override the default ID, if supplied, since it is changed by processSettings + + if(!default_author.isNull()) + { + ui->idChooser->setChosenId(default_author); + + // should we save the ID in the settings here? I'm not sure we want this. + } } PostedCreatePostDialog::~PostedCreatePostDialog() diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h index 64ab35566..ba3defd06 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h @@ -39,7 +39,7 @@ public: * @param tokenQ parent callee token * @param posted */ - explicit PostedCreatePostDialog(RsPosted* posted, const RsGxsGroupId& grpId, QWidget *parent = 0); + explicit PostedCreatePostDialog(RsPosted* posted, const RsGxsGroupId& grpId, const RsGxsId& default_author=RsGxsId(),QWidget *parent = 0); ~PostedCreatePostDialog(); private: diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index d4bec080a..6b2f16a30 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -741,8 +741,10 @@ void PostedListWidgetWithModel::createMsg() if (!IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { return; } - - PostedCreatePostDialog *msgDialog = new PostedCreatePostDialog(rsPosted,groupId()); + RsGxsId author_id; + ui->idChooser->getChosenId(author_id); +std::cerr << "Chosing default ID " << author_id<< std::endl; + PostedCreatePostDialog *msgDialog = new PostedCreatePostDialog(rsPosted,groupId(),author_id); msgDialog->show(); /* window will destroy itself! */ diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index 6235c025f..9321c4de4 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -313,7 +313,7 @@ void GxsIdChooser::setDefaultItem() } if (def >= 0) { - setCurrentIndex(def); + whileBlocking(this)->setCurrentIndex(def); #ifdef IDCHOOSER_DEBUG std::cerr << "GxsIdChooser-002" << (void*)this << " setting current index to " << def << std::endl; #endif From 6cc9cdf130f54d2f7e08671fd789ff1442d7dd0c Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 1 Oct 2020 21:25:32 +0200 Subject: [PATCH 58/78] keep current voter ID as poster ID in comment dialog --- .../src/gui/Posted/PostedListWidgetWithModel.cpp | 5 ++++- retroshare-gui/src/gui/gxs/GxsCommentContainer.cpp | 2 +- retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp | 12 ++++++------ retroshare-gui/src/gui/gxs/GxsCommentDialog.h | 6 +++--- retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp | 4 ++-- .../src/gui/gxs/GxsCreateCommentDialog.cpp | 4 ++-- retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.h | 2 +- retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp | 2 +- 8 files changed, 20 insertions(+), 17 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 6b2f16a30..4bf36f218 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -686,8 +686,11 @@ void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId) if(!index.isValid()) return; + RsGxsId current_author; + ui->idChooser->getChosenId(current_author); + RsPostedPost post = index.data(Qt::UserRole).value() ; - auto *commentDialog = new GxsCommentDialog(this,rsPosted->getTokenService(),rsPosted); + auto *commentDialog = new GxsCommentDialog(this,current_author,rsPosted->getTokenService(),rsPosted); std::set msg_versions({post.mMeta.mMsgId}); commentDialog->commentLoad(post.mMeta.mGroupId, msg_versions, post.mMeta.mMsgId); diff --git a/retroshare-gui/src/gui/gxs/GxsCommentContainer.cpp b/retroshare-gui/src/gui/gxs/GxsCommentContainer.cpp index c1590fba4..b80539cea 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentContainer.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentContainer.cpp @@ -60,7 +60,7 @@ void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const std::set< comments += "..."; } - GxsCommentDialog *commentDialog = new GxsCommentDialog(this, getTokenService(), getCommentService()); + GxsCommentDialog *commentDialog = new GxsCommentDialog(this, RsGxsId(),getTokenService(), getCommentService()); QWidget *commentHeader = createHeaderWidget(grpId, msgId); commentDialog->setCommentHeader(commentHeader); diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp index 7797b39f1..23fc18654 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp @@ -30,24 +30,24 @@ #include /** Constructor */ -GxsCommentDialog::GxsCommentDialog(QWidget *parent, RsTokenService *token_service, RsGxsCommentService *comment_service) +GxsCommentDialog::GxsCommentDialog(QWidget *parent, const RsGxsId &default_author, RsTokenService *token_service, RsGxsCommentService *comment_service) : QWidget(parent), ui(new Ui::GxsCommentDialog) { /* Invoke the Qt Designer generated QObject setup routine */ ui->setupUi(this); setTokenService(token_service,comment_service); - init(); + init(default_author); } -void GxsCommentDialog::init() +void GxsCommentDialog::init(const RsGxsId& default_author) { /* Set header resize modes and initial section sizes */ QHeaderView * ttheader = ui->treeWidget->header () ; ttheader->resizeSection (0, 440); /* fill in the available OwnIds for signing */ - ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId()); + ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, default_author); connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh())); connect(ui->idChooser, SIGNAL(currentIndexChanged( int )), this, SLOT(voterSelectionChanged( int ))); @@ -70,13 +70,13 @@ void GxsCommentDialog::setTokenService(RsTokenService *token_service, RsGxsComme ui->treeWidget->setup(token_service, comment_service); } -GxsCommentDialog::GxsCommentDialog(QWidget *parent) +GxsCommentDialog::GxsCommentDialog(QWidget *parent,const RsGxsId &default_author) : QWidget(parent), ui(new Ui::GxsCommentDialog) { /* Invoke the Qt Designer generated QObject setup routine */ ui->setupUi(this); - init(); + init(default_author); } GxsCommentDialog::~GxsCommentDialog() diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h index b07568eda..80a58ff47 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h @@ -32,8 +32,8 @@ class GxsCommentDialog: public QWidget Q_OBJECT public: - GxsCommentDialog(QWidget *parent); - GxsCommentDialog(QWidget *parent, RsTokenService *token_service, RsGxsCommentService *comment_service); + GxsCommentDialog(QWidget *parent=nullptr,const RsGxsId& default_author=RsGxsId()); + GxsCommentDialog(QWidget *parent,const RsGxsId& default_author, RsTokenService *token_service, RsGxsCommentService *comment_service); virtual ~GxsCommentDialog(); void setTokenService(RsTokenService *token_service, RsGxsCommentService *comment_service); @@ -54,7 +54,7 @@ signals: void commentsLoaded(int); private: - void init(); + void init(const RsGxsId &default_author); RsGxsGroupId mGrpId; RsGxsMessageId mMostRecentMsgId; diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index 35b56ae19..fcc13e851 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -323,7 +323,7 @@ void GxsCommentTreeWidget::banUser() void GxsCommentTreeWidget::makeComment() { - GxsCreateCommentDialog pcc(mCommentService, std::make_pair(mGroupId,mLatestMsgId), mLatestMsgId, this); + GxsCreateCommentDialog pcc(mCommentService, std::make_pair(mGroupId,mLatestMsgId), mLatestMsgId, mVoterId,this); pcc.exec(); } @@ -332,7 +332,7 @@ void GxsCommentTreeWidget::replyToComment() RsGxsGrpMsgIdPair msgId; msgId.first = mGroupId; msgId.second = mCurrentCommentMsgId; - GxsCreateCommentDialog pcc(mCommentService, msgId, mLatestMsgId, this); + GxsCreateCommentDialog pcc(mCommentService, msgId, mLatestMsgId, mVoterId,this); pcc.loadComment(mCurrentCommentText, mCurrentCommentAuthor, mCurrentCommentAuthorId); pcc.exec(); diff --git a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.cpp b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.cpp index dd3f2f97c..e084635c3 100644 --- a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.cpp @@ -26,7 +26,7 @@ #include #include -GxsCreateCommentDialog::GxsCreateCommentDialog(RsGxsCommentService *service, const RsGxsGrpMsgIdPair &parentId, const RsGxsMessageId& threadId, QWidget *parent) : +GxsCreateCommentDialog::GxsCreateCommentDialog(RsGxsCommentService *service, const RsGxsGrpMsgIdPair &parentId, const RsGxsMessageId& threadId, const RsGxsId& default_author,QWidget *parent) : QDialog(parent), ui(new Ui::GxsCreateCommentDialog), mCommentService(service), mParentId(parentId), mThreadId(threadId) { @@ -35,7 +35,7 @@ GxsCreateCommentDialog::GxsCreateCommentDialog(RsGxsCommentService *service, co connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close())); /* fill in the available OwnIds for signing */ - ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId()); + ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, default_author); } void GxsCreateCommentDialog::loadComment(const QString &msgText, const QString &msgAuthor, const RsGxsId &msgAuthorId) diff --git a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.h b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.h index 967649179..ce394bf5e 100644 --- a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.h @@ -36,7 +36,7 @@ class GxsCreateCommentDialog : public QDialog Q_OBJECT public: - explicit GxsCreateCommentDialog(RsGxsCommentService *service, const RsGxsGrpMsgIdPair& parentId, const RsGxsMessageId& threadId, QWidget *parent = 0); + explicit GxsCreateCommentDialog(RsGxsCommentService *service, const RsGxsGrpMsgIdPair& parentId, const RsGxsMessageId& threadId, const RsGxsId& default_author=RsGxsId(),QWidget *parent = 0); ~GxsCreateCommentDialog(); void loadComment(const QString &msgText, const QString &msgAuthor, const RsGxsId &msgAuthorId); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 9cc924a33..4a5d0c859 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -731,7 +731,7 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const QVectorgetTokenService(), commentService); + commentDialog = new GxsCommentDialog(this,RsGxsId(), mInterface->getTokenService(), commentService); QWidget *commentHeader = createCommentHeaderWidget(grpId, most_recent_msgId); if (commentHeader) { From 6d8f5512f96e70943021ca330b9155b80fc56c52 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 1 Oct 2020 23:38:13 +0200 Subject: [PATCH 59/78] restored text on comment button, and added blue hover effect from ClickableLabel --- retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp | 2 +- .../src/gui/Posted/BoardPostDisplayWidget_compact.ui | 4 ++-- .../src/gui/gxschannels/GxsChannelPostThumbnail.h | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 49b92de00..0ca8b12b0 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -82,7 +82,7 @@ void BoardPostDisplayWidgetBase::setCommentsSize(int comNb) // else if(comNb > 1) // sComButText = tr("Comments ").append("(%1)").arg(comNb); // -// commentButton()->setText(sComButText); + commentButton()->setText(tr("Comments")); } void BoardPostDisplayWidgetBase::makeDownVote() diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index e2fb4f8b1..469dc2de0 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -317,7 +317,7 @@ - + Comments @@ -327,7 +327,7 @@ true - Qt::ToolButtonIconOnly + Qt::ToolButtonTextBesideIcon true diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index 43d87c031..d89fd5eca 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -40,7 +40,7 @@ class ZoomableLabel: public QLabel Q_OBJECT public: - ZoomableLabel(QWidget *parent): QLabel(parent),mZoomFactor(1.0),mCenterX(0.0),mCenterY(0.0),mZoomEnabled(true) {} + ZoomableLabel(QWidget *parent): QLabel(parent),mUseStyleSheet(true),mZoomFactor(1.0),mCenterX(0.0),mCenterY(0.0),mZoomEnabled(true) {} void setPicture(const QPixmap& pix); void setEnableZoom(bool b) { mZoomEnabled = b; } @@ -60,6 +60,11 @@ protected: void resizeEvent(QResizeEvent *ev) override; void wheelEvent(QWheelEvent *me) override; + void enterEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #039bd5; }");} + void leaveEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #CCCCCC; border-radius: 3px; }");} + + bool mUseStyleSheet; + QPixmap mFullImage; float mZoomFactor; From 780ffe350485e39bedcb71190b68b17e649f46f2 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 2 Oct 2020 21:38:36 +0200 Subject: [PATCH 60/78] fixed the "new" property so that the style can act on it --- retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp | 6 ++++++ retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h | 4 ++++ .../src/gui/Posted/BoardPostDisplayWidget_card.ui | 2 +- .../src/gui/Posted/BoardPostDisplayWidget_compact.ui | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 0ca8b12b0..1015bc02e 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -117,6 +117,10 @@ void BoardPostDisplayWidgetBase::setReadStatus(bool isNew, bool isUnread) readButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png")); newLabel()->setVisible(isNew); + + mainFrame()->setProperty("new", isNew); + mainFrame()->style()->unpolish(mainFrame()); + mainFrame()->style()->polish(mainFrame()); } void BoardPostDisplayWidget_compact::doExpand(bool e) @@ -439,6 +443,7 @@ QLabel *BoardPostDisplayWidget_compact::scoreLabel() { return ui->sc QLabel *BoardPostDisplayWidget_compact::notes() { return ui->notes; } QPushButton *BoardPostDisplayWidget_compact::shareButton() { return ui->shareButton; } QLabel *BoardPostDisplayWidget_compact::pictureLabel() { return ui->pictureLabel; } +QFrame *BoardPostDisplayWidget_compact::mainFrame() { return ui->mainFrame; } //=================================================================================================================================== //== class BoardPostDisplayWidget_card == @@ -508,4 +513,5 @@ QLabel *BoardPostDisplayWidget_card::scoreLabel() { return ui->score QLabel *BoardPostDisplayWidget_card::notes() { return ui->notes; } QPushButton *BoardPostDisplayWidget_card::shareButton() { return ui->shareButton; } QLabel *BoardPostDisplayWidget_card::pictureLabel() { return ui->pictureLabel; } +QFrame *BoardPostDisplayWidget_card::mainFrame() { return ui->mainFrame; } diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index edf8bf760..03db04970 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -31,6 +31,7 @@ class BoardPostDisplayWidget_compact; } class QPushButton; +class QFrame; class QLabel; class QToolButton; class QTextEdit; @@ -79,6 +80,7 @@ protected slots: virtual QLabel *pictureLabel()=0; virtual QToolButton *readButton() =0; virtual QPushButton *shareButton() =0; + virtual QFrame *mainFrame() =0; void loadComments(bool e); void showAuthorInPeople(); @@ -125,6 +127,7 @@ public: QLabel *pictureLabel() override; QToolButton *readButton() override; QPushButton *shareButton() override; + QFrame *mainFrame() override; public slots: void viewPicture() ; @@ -164,6 +167,7 @@ public: QToolButton *readButton() override; QPushButton *shareButton() override; QLabel *pictureLabel() override; + QFrame *mainFrame() override; protected slots: /* GxsGroupFeedItem */ diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui index 3a9353a40..75fa5e227 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui @@ -42,7 +42,7 @@ 2 - + 0 diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index 469dc2de0..304b3b446 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -42,7 +42,7 @@ 2 - + 0 From de29d8cfdd8b5abef274c073b6e3e09173397258 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 2 Oct 2020 23:03:58 +0200 Subject: [PATCH 61/78] Fixing Darkstylesheet-v2 & the standard sheet --- .../src/gui/qss/stylesheet/Standard.qss | 12 ++--- retroshare-gui/src/qss/qdarkstyle-v2.qss | 49 +++++++++++-------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index d8e7bb4f5..2f8ef3ad9 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -808,7 +808,7 @@ GxsGroupDialog QLabel#groupLogo{ } -BoardPostDisplayWidget_compact QFrame#frame { +BoardPostDisplayWidget_compact QFrame#mainFrame { background-color: white; } @@ -816,11 +816,11 @@ PostedItem QFrame#voteFrame { background: #f8f9fa; } -BoardPostDisplayWidget_compact QFrame#frame [new=false]{ +BoardPostDisplayWidget_compact > QFrame#mainFrame [new=false]{ background: white; } -BoardPostDisplayWidget_compact QFrame#frame[new=true] { +BoardPostDisplayWidget_compact > QFrame#mainFrame[new=true] { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #F0F8FD, stop:0.8 #E6F2FD, stop: 0.81 #E6F2FD, stop: 1 #D2E7FD); } @@ -849,15 +849,15 @@ PostedCardView QFrame#voteFrame { background: #f8f9fa; } -BoardPostDisplayWidget_card QFrame#frame{ +BoardPostDisplayWidget_card QFrame#mainFrame{ background: white; } -BoardPostDisplayWidget_card QFrame#frame [new=false]{ +BoardPostDisplayWidget_card > QFrame#mainFrame [new=false]{ background: white; } -BoardPostDisplayWidget_card > QFrame#frame[new=true] { +BoardPostDisplayWidget_card > QFrame#mainFrame[new=true] { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #F0F8FD, stop:0.8 #E6F2FD, stop: 0.81 #E6F2FD, stop: 1 #D2E7FD); } diff --git a/retroshare-gui/src/qss/qdarkstyle-v2.qss b/retroshare-gui/src/qss/qdarkstyle-v2.qss index 3bfe94a19..feadf4884 100644 --- a/retroshare-gui/src/qss/qdarkstyle-v2.qss +++ b/retroshare-gui/src/qss/qdarkstyle-v2.qss @@ -2078,28 +2078,26 @@ BoardPostDisplayWidget_compact QFrame#mainFrame { border-radius: 4px; border: 1px solid #32414B; background-color: #19232D; +} +BoardPostDisplayWidget_compact QFrame#mainFrame [new=false]{ + background: #19232D; +} + +BoardPostDisplayWidget_compact QFrame#mainFrame[new=true] { + background-color: #1464a0; } GxsChannelPostItem QFrame#mainFrame { border-radius: 4px; border: 1px solid #32414B; background-color: #19232D; - } -BoardPostDisplayWidget_compact QPushButton#shareButton -{ +BoardPostDisplayWidget_compact QPushButton#shareButton { background-color: transparent; min-width: 80px; max-height: 22px; - -} - -BoardPostDisplayWidget_compact QLabel#scoreLabel -{ - background-color: transparent; - } BoardPostDisplayWidget_compact QFrame#voteFrame { @@ -2117,12 +2115,23 @@ BoardPostDisplayWidget_compact QLabel#pictureLabel{ border-radius: 3px; } -BoardPostDisplayWidget_card QPushButton#shareButton -{ - background-color: transparent; +BoardPostDisplayWidget_compact QLabel#scoreLabel, QLabel#titleLabel, QLabel#fromBoldLabel , QLabel#fromLabel, QLabel#dateLabel, +BoardPostDisplayWidget_card QLabel#scoreLabel, QLabel#titleLabel{ + background-color: transparent; +} + +BoardPostDisplayWidget_compact QLabel#newLabel, +BoardPostDisplayWidget_card QLabel#newLabel { + border: 1px solid #00B712; + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5AFF15, stop: 1 #00B712); + border-radius: 3px; + color: black; +} + +BoardPostDisplayWidget_card QPushButton#shareButton{ + background-color: transparent; min-width: 80px; max-height: 22px; - } BoardPostDisplayWidget_card QFrame#voteFrame { @@ -2130,17 +2139,15 @@ BoardPostDisplayWidget_card QFrame#voteFrame { } BoardPostDisplayWidget_card QFrame#mainFrame { - - background-color: #19232D; - + background-color: #19232D; } -BoardPostDisplayWidget_card QFrame#mainFrame [new=false]{ +BoardPostDisplayWidget_card QFrame#mainFrame [new=false]{ background: #19232D; } -BoardPostDisplayWidget_card > QFrame#mainFrame[new=true] { - background-color: #005000; +BoardPostDisplayWidget_card QFrame#mainFrame[new=true] { + background-color: #1464a0; } WireGroupItem QFrame#wire_frame{ @@ -2162,3 +2169,5 @@ PulseTopLevel QFrame#frame, PulseViewGroup QFrame#frame, PulseReply QFrame#frame border: 2px solid #38444d; border-radius: 6px; } + + From 5e3dab62fd7173d56383d7df47c9ef8b42c5bc94 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 3 Oct 2020 17:56:24 +0200 Subject: [PATCH 62/78] always display picture in compact view, possibly replacing missing picture by placeholder --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 1015bc02e..61cdaea2d 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -353,28 +353,26 @@ void BoardPostDisplayWidget_compact::setup() } else { - if(mPost.mImage.mData != NULL) - { - QPixmap pixmap; - GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); - // Wiping data - as its been passed to thumbnail. + if(mPost.mImage.mData != NULL) + { + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + // Wiping data - as its been passed to thumbnail. #ifdef DEBUG_BOARDPOSTDISPLAYWIDGET - std::cerr << "Got pixmap of size " << pixmap.width() << " x " << pixmap.height() << std::endl; - std::cerr << "Saving to pix.png" << std::endl; - pixmap.save("pix.png","PNG"); + std::cerr << "Got pixmap of size " << pixmap.width() << " x " << pixmap.height() << std::endl; + std::cerr << "Saving to pix.png" << std::endl; + pixmap.save("pix.png","PNG"); #endif - int desired_height = QFontMetricsF(font()).height() * 5; - ui->pictureLabel->setFixedSize(16/9.0*desired_height,desired_height); - ui->pictureLabel->setPicture(pixmap); - } - else if (mPost.mImage.mData == NULL) - ui->pictureLabel->hide(); - else - ui->pictureLabel->show(); - + int desired_height = QFontMetricsF(font()).height() * 5; + ui->pictureLabel->setFixedSize(16/9.0*desired_height,desired_height); + ui->pictureLabel->setPicture(pixmap); } + else + ui->pictureLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png") ); + + } ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); @@ -487,11 +485,11 @@ void BoardPostDisplayWidget_card::setup() }else{ ui->pictureLabel->setPixmap(pixmap); } + + ui->pictureLabel->show(); } - else if (mPost.mImage.mData == NULL) - pictureLabel()->hide(); else - pictureLabel()->show(); + ui->pictureLabel->hide(); QTextDocument doc; doc.setHtml(notes()->text()); From f064325592aa6a6868f2de7316865ed94e57dd7e Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 3 Oct 2020 18:59:44 +0200 Subject: [PATCH 63/78] fixed default size of default icon in boards --- retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 61cdaea2d..f565f7439 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -353,6 +353,9 @@ void BoardPostDisplayWidget_compact::setup() } else { + int desired_height = QFontMetricsF(font()).height() * 5; + ui->pictureLabel->setFixedSize(16/9.0*desired_height,desired_height); + if(mPost.mImage.mData != NULL) { QPixmap pixmap; @@ -365,13 +368,10 @@ void BoardPostDisplayWidget_compact::setup() pixmap.save("pix.png","PNG"); #endif - int desired_height = QFontMetricsF(font()).height() * 5; - ui->pictureLabel->setFixedSize(16/9.0*desired_height,desired_height); ui->pictureLabel->setPicture(pixmap); } else ui->pictureLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png") ); - } ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); From 2af66e91c53927fc9d5fd95b44e3bcc0718e0b84 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 3 Oct 2020 21:47:00 +0200 Subject: [PATCH 64/78] fixed closing of comments tab when comments update --- .../gui/Posted/PostedListWidgetWithModel.cpp | 22 +++++++++++++++---- retroshare-gui/src/gui/gxs/GxsCommentDialog.h | 4 +++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 4bf36f218..d0cb983a7 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -432,9 +432,20 @@ void PostedListWidgetWithModel::handleEvent_main_thread(std::shared_ptrmPostedEventCode) { - case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]]; + case RsPostedEventCode::NEW_MESSAGE: // [[fallthrough]]; + { + // special treatment here because the message might be a comment, so we need to refresh the comment tab if openned + + for(int i=2;itabWidget->count();++i) + { + auto *t = dynamic_cast(ui->tabWidget->widget(i)); + + if(t->groupId() == e->mPostedGroupId) + t->refresh(); + } + } + case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]]; case RsPostedEventCode::UPDATED_POSTED_GROUP: // [[fallthrough]]; - case RsPostedEventCode::NEW_MESSAGE: // [[fallthrough]]; case RsPostedEventCode::UPDATED_MESSAGE: { if(e->mPostedGroupId == groupId()) @@ -550,13 +561,16 @@ void PostedListWidgetWithModel::updateGroupData() RsQThreadUtils::postToObject( [this,groups]() { + bool group_changed = (groups[0].mMeta.mGroupId!=mGroup.mMeta.mGroupId); + mGroup = groups[0]; mPostedPostsModel->updateBoard(groupId()); insertBoardDetails(mGroup); - while(ui->tabWidget->widget(2) != nullptr) - tabCloseRequested(2); + if(group_changed) + while(ui->tabWidget->widget(2) != nullptr) + tabCloseRequested(2); emit groupDataLoaded(); emit groupChanged(this); // signals the parent widget to e.g. update the group tab name diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h index 80a58ff47..987fd0c07 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h @@ -43,8 +43,10 @@ public: RsGxsGroupId groupId() { return mGrpId; } RsGxsMessageId messageId() { return mMostRecentMsgId; } +public slots: + void refresh(); + private slots: - void refresh(); void idChooserReady(); void voterSelectionChanged( int index ); void sortComments(int); From 65f7ead18d82aaeff8426899fb383958cbbb2e89 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 3 Oct 2020 21:49:45 +0200 Subject: [PATCH 65/78] use default icon when post author is banned --- retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index f565f7439..514ae5fcf 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -350,6 +350,7 @@ void BoardPostDisplayWidget_compact::setup() if(redacted) { + ui->pictureLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png") ); } else { From a9a3e070bbf8e34e90f40a25cefa8c5620d66733 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 4 Oct 2020 15:51:17 +0200 Subject: [PATCH 66/78] absorbed PR 2031 --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 046678ad9..e45e333d0 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -1069,6 +1069,8 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou RetroShareLink link = RetroShareLink::createMessage(group.mMeta.mAuthorId, ""); ui->infoAdministrator->setText(link.toHtml()); } + else + ui->infoAdministrator->setText("[No contact author]"); ui->infoCreated->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs)); @@ -1165,6 +1167,9 @@ bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId& msgId) ui->postsTree->scrollTo(index);//May change if model reloaded ui->postsTree->setFocus(); + ui->channel_TW->setCurrentIndex(CHANNEL_TABS_POSTS); + ui->details_TW->setCurrentIndex(CHANNEL_TABS_DETAILS); + return true; } From d122b3f1e592cb45a70bab2e765410169c126a04 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 6 Oct 2020 20:21:17 +0200 Subject: [PATCH 67/78] Fxed to get work Copy RetroShare Link *Fxed to get work Copy RetroShare Link *Fxing margins for compact ui *Fixing darkstylsheets --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 18 ++++++++++++++++++ .../src/gui/Posted/BoardPostDisplayWidget.h | 1 + .../Posted/BoardPostDisplayWidget_compact.ui | 10 ++++++++-- retroshare-gui/src/qss/qdarkstyle-v2.qss | 6 ++++++ retroshare-gui/src/qss/qdarkstyle.qss | 7 +++++++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 514ae5fcf..259740740 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include "rshare.h" #include "BoardPostDisplayWidget.h" #include "PhotoView.h" +#include "gui/RetroShareLink.h" #include "gui/gxs/GxsIdDetails.h" #include "util/misc.h" #include "gui/common/FilesDefs.h" @@ -165,6 +167,22 @@ void BoardPostDisplayWidgetBase::showAuthorInPeople() idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId)); } +void BoardPostDisplayWidgetBase::copyMessageLink() +{ + if (mPost.mMeta.mGroupId.isNull() || mPost.mMeta.mMsgId.isNull()) { + return; + } + + RetroShareLink link = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_POSTED, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); + + if (link.valid()) { + QList urls; + urls.push_back(link); + RSLinkClipboard::copyLinks(urls); + QMessageBox::information(NULL,tr("information"),tr("The Retrohare link was copied to your clipboard.")) ; + } +} + void BoardPostDisplayWidgetBase::setup() { // show/hide things based on the view type diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 03db04970..83e8d4eaa 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -84,6 +84,7 @@ protected slots: void loadComments(bool e); void showAuthorInPeople(); + void copyMessageLink(); void readToggled(); void setReadStatus(bool isNew, bool isUnread) ; void makeUpVote() ; diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui index 304b3b446..21fa7d87c 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_compact.ui @@ -183,6 +183,9 @@ + + 3 + @@ -219,10 +222,13 @@ - 5 + 6 - 0 + 2 + + + 2 6 diff --git a/retroshare-gui/src/qss/qdarkstyle-v2.qss b/retroshare-gui/src/qss/qdarkstyle-v2.qss index feadf4884..6a86212c5 100644 --- a/retroshare-gui/src/qss/qdarkstyle-v2.qss +++ b/retroshare-gui/src/qss/qdarkstyle-v2.qss @@ -2150,6 +2150,12 @@ BoardPostDisplayWidget_card QFrame#mainFrame[new=true] { background-color: #1464a0; } +BoardPostDisplayWidget_compact QLabel#titleLabel, +BoardPostDisplayWidget_card QLabel#titleLabel{ + font-size: 14px; + font: bold; +} + WireGroupItem QFrame#wire_frame{ background: transparent; } diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index d7e1a38e8..6f8f2a0a7 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -1317,6 +1317,13 @@ BoardPostDisplayWidget_card QLabel#newLabel { color: black; } +BoardPostDisplayWidget_compact QLabel#titleLabel, +BoardPostDisplayWidget_card QLabel#titleLabel{ + font-size: 14px; + font: bold; +} + + WireGroupItem QFrame#wire_frame { border: 1px solid #38444d; From ae7ffc84e8d67ac43444c2b62b67a03275729729 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 6 Oct 2020 21:10:43 +0200 Subject: [PATCH 68/78] Removed the Minimum Expanding for GXS CommentsDialog * Removed the Ninimum Expanding for GXS CommentsDialog, this gets issues on Channels with the Splitter to make the Bottom view small as possible --- retroshare-gui/src/gui/gxs/GxsCommentDialog.ui | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui index e23a16b44..734e490ca 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui @@ -7,11 +7,11 @@ 0 0 632 - 547 + 248 - + 0 0 @@ -23,7 +23,7 @@ - + 0 0 From a866184d6d7c78ea977590ca38f16ff627fb4aab Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 6 Oct 2020 21:38:06 +0200 Subject: [PATCH 69/78] restore back changes --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 18 ------------------ .../src/gui/Posted/BoardPostDisplayWidget.h | 1 - 2 files changed, 19 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 259740740..514ae5fcf 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -28,7 +27,6 @@ #include "rshare.h" #include "BoardPostDisplayWidget.h" #include "PhotoView.h" -#include "gui/RetroShareLink.h" #include "gui/gxs/GxsIdDetails.h" #include "util/misc.h" #include "gui/common/FilesDefs.h" @@ -167,22 +165,6 @@ void BoardPostDisplayWidgetBase::showAuthorInPeople() idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId)); } -void BoardPostDisplayWidgetBase::copyMessageLink() -{ - if (mPost.mMeta.mGroupId.isNull() || mPost.mMeta.mMsgId.isNull()) { - return; - } - - RetroShareLink link = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_POSTED, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); - - if (link.valid()) { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); - QMessageBox::information(NULL,tr("information"),tr("The Retrohare link was copied to your clipboard.")) ; - } -} - void BoardPostDisplayWidgetBase::setup() { // show/hide things based on the view type diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 83e8d4eaa..03db04970 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -84,7 +84,6 @@ protected slots: void loadComments(bool e); void showAuthorInPeople(); - void copyMessageLink(); void readToggled(); void setReadStatus(bool isNew, bool isUnread) ; void makeUpVote() ; From 054ae9a3cea0d2566ae678d2a27225eb45fc6be3 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 6 Oct 2020 21:53:28 +0200 Subject: [PATCH 70/78] fixed wrong context menu policy in boards widget list --- retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 33bb2cfdd..615021115 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -493,6 +493,9 @@ p, li { white-space: pre-wrap; } + + Qt::CustomContextMenu + QAbstractItemView::CurrentChanged|QAbstractItemView::SelectedClicked From 35cbe5bacbbd4e5e1cfa87d668c4ce2d0506d077 Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 7 Oct 2020 21:35:53 +0200 Subject: [PATCH 71/78] Fixed to get work the Copy RS Link for the share action --- retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp | 7 ++++++- retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h | 3 +++ .../src/gui/Posted/PostedListWidgetWithModel.cpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 514ae5fcf..74326d8f4 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -186,7 +186,7 @@ void BoardPostDisplayWidgetBase::setup() QObject::connect(readButton(), SIGNAL(clicked()), this, SLOT(readToggled())); QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); - connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink())); + connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(handleCopyLinkClicked())); QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople())); @@ -311,6 +311,11 @@ void BoardPostDisplayWidgetBase::handleShareButtonClicked() { emit shareButtonClicked(); } + +void BoardPostDisplayWidgetBase::handleCopyLinkClicked() +{ + emit copylinkClicked(); +} //=================================================================================================================================== //== class BoardPostDisplayWidget == //=================================================================================================================================== diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 03db04970..2016ff678 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -90,6 +90,8 @@ protected slots: void makeDownVote() ; void setCommentsSize(int comNb) ; void handleShareButtonClicked() ; + void handleCopyLinkClicked() ; + signals: void changeReadStatusRequested(const RsGxsMessageId&,bool); @@ -98,6 +100,7 @@ signals: void commentsRequested(const RsGxsMessageId&,bool); void thumbnailOpenned(); void shareButtonClicked(); + void copylinkClicked(); protected: RsPostedPost mPost; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index d0cb983a7..387b271eb 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -205,6 +205,7 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(markCurrentPostAsRead())); QObject::connect(w,SIGNAL(commentsRequested(const RsGxsMessageId&,bool)),mPostListWidget,SLOT(markCurrentPostAsRead())); QObject::connect(w,SIGNAL(shareButtonClicked()),mPostListWidget,SLOT(markCurrentPostAsRead())); + QObject::connect(w,SIGNAL(copylinkClicked()),mPostListWidget,SLOT(copyMessageLink())); w->setFixedSize(option.rect.size()); w->adjustSize(); @@ -405,6 +406,7 @@ void PostedListWidgetWithModel::copyMessageLink() QList urls; urls.push_back(link); RSLinkClipboard::copyLinks(urls); + QMessageBox::information(NULL,tr("information"),tr("The Retrohare link was copied to your clipboard.")) ; } catch(std::exception& e) { From 05a97c13a78d4c87dd39af7932f2203cbb393fe1 Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 7 Oct 2020 22:22:59 +0200 Subject: [PATCH 72/78] Added Thumbnail for blocked messages * Added Thumbnail for blocked messages * Fixed to disable the Picture Label when Author is banned. --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 9 +++++---- retroshare-gui/src/gui/Posted/Posted_images.qrc | 1 + .../src/gui/Posted/images/thumb-blocked.png | Bin 0 -> 10325 bytes 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 retroshare-gui/src/gui/Posted/images/thumb-blocked.png diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 74326d8f4..21685d83d 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -217,6 +217,7 @@ void BoardPostDisplayWidgetBase::setup() qtime.setTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); dateLabel()->setText(timestamp); + pictureLabel()->setDisabled(true); } else { @@ -353,15 +354,15 @@ void BoardPostDisplayWidget_compact::setup() RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); + int desired_height = QFontMetricsF(font()).height() * 5; + ui->pictureLabel->setFixedSize(16/9.0*desired_height,desired_height); + if(redacted) { - ui->pictureLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png") ); + ui->pictureLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-blocked.png") ); } else { - int desired_height = QFontMetricsF(font()).height() * 5; - ui->pictureLabel->setFixedSize(16/9.0*desired_height,desired_height); - if(mPost.mImage.mData != NULL) { QPixmap pixmap; diff --git a/retroshare-gui/src/gui/Posted/Posted_images.qrc b/retroshare-gui/src/gui/Posted/Posted_images.qrc index fab0bae65..72cb3c40c 100644 --- a/retroshare-gui/src/gui/Posted/Posted_images.qrc +++ b/retroshare-gui/src/gui/Posted/Posted_images.qrc @@ -6,6 +6,7 @@ images/up-arrow.png images/comments.png images/comments_blue.png + images/thumb-blocked.png images/thumb-default.png images/thumb-link.png images/share.png diff --git a/retroshare-gui/src/gui/Posted/images/thumb-blocked.png b/retroshare-gui/src/gui/Posted/images/thumb-blocked.png new file mode 100644 index 0000000000000000000000000000000000000000..3ff44d7fa772f93ea1cb2fcf1c1e7d61aef582c7 GIT binary patch literal 10325 zcmV-bD5}?qP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0013;NklF#vT zJ>A_tXXckbc4x1rw_h{6C*9dMD%I`I^z_X3eCGRmbWaZf06@eP0K6XnIsqUCi_7BD zyrm2PqX2M_5R$VIu>}CGd*qQvt~_z#M4#h0@x?Y;T$;7mwq07cZr#zHJ9lOf@fm`M zAAI!DM{n%!@4wu(?KmNXQc8hTmfBxRsmXU`8B(d-|E}7m{2TU1YjzYeh=j%8+c(s4I_N}{Yrq?bE58OIJDUBUJe!LF=I&A<* z6pO`_Wm!a2k)(1WITsaZs=B2RivBlQdESxxAR-Sa`ulO)YS$E*4TO+Dx$1WU09d`O z$ZzNCX6hitVlf2(3EPlb5`uIoj0{Y5ilw>}L#kX1&>r# z*Mp~niu>*ts2y7bYQU!xHHr*~ux3>Ono32LFwSS?IbVzD+<2&X2qel@2c7~dmGadA z&4EZ{z(E8bj)a9#16m`1T~M_;k6;JXOjM5mKqYt~%&87K={f)a8n!_~epdw{QYAZ& z=5(PiL}wL5Weu)Lqt{)YCTS*2Cf^ML2&IB7npCNOCR9L8pa2?k+K|$TRL+jjz$B`& z$s$tKwnlun`QTg4HP{MM3Myw_WR^ohCEQ<9pEPI)<%gNVXppNT21>RVrK+P;P$-%- zEm9YXhJ;Gz|AqG9qWE=<+{Fse7MBn}H`wM)@z+G(K;e58I zL9`kcmQcrzQm5TaUm!$dMwajS=r7IVbHp&)8UfQZ3Z^FZeLkz-;xa$mUgoFM#Y?rg zoX=$uxW(my0f##0Q@1qRF`cVA--*k7YkOv2)CCQJ;UtI{*_JEzMTO&y3&1IlawW(- zI!ByCz?8?Zn+Q=uC#$McHK6a^tW4GC2efs}C-t*6cL50tiwQik0fgLo;ql*TCN|0q zq=5`g+AA!iA=({71IJx_L_}TpmK09W&P@GHGvAFa@sr0Bi9>IsmOS;uGJ9aK#UlXT zk|j=jMNi@Ewoi@b|LDqTSYYZZGjk$%P)!sX90yI{w4?rzW~iEB**Wv+h~tp-^Uq|u z{^uv1#j)WyEte<&fJ-U|q*GINdFsvdvTuJQ?R9mPa#voH#SNQtlUH0hJ>UJxFqU8r z)vm6*9Reye=*353`lFQ@oph;QCJU3~xLQ#03nEbC@E+&K(1OzJ}ebBnTVB4v|Bm@*3% z21YxA3JIYKVTM&^R0v+f0Rtk$&YX^?Uwk%`cx8WE{M4zWN1}y~E&*sc)SqrS)Sqtq z$z#j$qTbxtt=mS6n=Z~{GU;6iv#AIkFl-d5Gml|l6zy+^F_k)~O!gOnBUs;*fWex~ zTFHa2q`RK@X(tYzPGHq!dJP!pz^=I&3;JJM(%Jvo61O8$E?;p?ws83s)6?(2Z03AH zrc+Z{If>ete8-UG!})L_Av99DYMHvn$Q0lSA32k$S;vddx5Zz7HQjRHwT5%-nyWsER}Zwcyn3K**&~mv$X{~F)WogZ zM~Yjv=I1Iv(3n;ewZmpAn+iZ%;-A%?&SoJ91C_*_h5=6splDfn*XR1Ie9oFT`85D2 zqeJXh540_R^+4OXKfPmUa>u7f=fZE3DVYgq2FisYlnuFk>dwVBRWS}k)jl;~Wag9s zPY9JFI;};iwrvLn9?U1$M9LaJaXeXVn>jb93O^5Jpb3;L42(+klcq&XoO~TrBIN_Y zka?4|NF%wUd6y)M#jsiDEK)d=XjKzHgfXkA150*|sL6$lBDe|=>r@!W} zRZSspK2>Q9p{W#^RY4@Gnu1F7(C-2x4zbDS97*LQprOw6iU1awSwUTB?89mNx&Vk8 z@B;pvDq4M~DjZxOg;PbRhUOF`U`0|oTUN*kj3TLQt7y&8_k#4Ea!>RIPl2iw8 zR)r%%BtQmKE36OaoAHIjT9Z{dlDf$P0mICKsVSDKq>)LDU}~j6f@B(t#fN1=DI7MU zZmdGdfNI2aHeym$W>woupjau3&MrNW}8%0=+xr!oNj z>u>7-)2W*bNY#2!OxD9WuQHRn@JuSgoS9S!R61aF;1~g=GpDNYaE&OIc6}I?1H*@R z7S!T8w25gE6O$TR-9q?wp%hV;_!SKU;(affPo`ZjQaKY-D%o#AM5zb>&dTmQ0D{xC zqBsXps!)w0m{yq&7j=Ezxz?Ffk?N@CkBy>mqF}^8u|%eM-kMamJyR~NUY(o#(Dma^ zd#0S)$yBb%A{m6|-0ph1>iX++@^=2{;#C_oD3tC?&MVOncxm-%K=-S$lB+%?yZ zPJHy^V@}6Xr`eE+{5J_?X!=*Df+oJ54nRJ@vlaf9%&di0G6OgQCRhQb@JC!|yE*=e zPYzDp@QINcXmfmOCXh)23Zv9X$nBx}Zl!aJ=!SXo$y?qB2#&_D>l z#QH7S@xS`)+ohGON}@8YuOCb&j~q@f`OUAFQc8j+T>S;Pz76Nf7xm4|Y}hnYSk+yM z+RGqOduKYLR0%I8p*7kJxK!vh(MIUP&1F!S67;(J51o?hbINJADTx1 z#&7t<;MqI=Vu0U7OGUco@jYFsmw(ymjg2I9rxPC>NRk(R0hmlV*(p)#pu@E|tFu$7m070%xImv8aMUb260`>O9f)Jt8DM41Ss_KKZc z-s=3xkJhyPW?#qKU%2~3dFisU$;D(|24e&nW5u*e6#*{QIm|xOzyTq98#6{IBRmn= zKC(NP+gA6ZX4dtcn@gX~^#D$P=5K#jT)Vc&Zfo1Wx4rxO-|eNY{&{|k$2~Bxaq-iq z(rdqU|9X3TEM@|ms?9{#OJ-6VxW=k7fn%}?CsHz%%JJJ8RlE;hiAH8Oq;g>tb@LU} zR+&A;9TC>~*Mcfa@UkOPxRgrWlK+F=88?x1twO%(&!@WSCFRLmZx8rYsiXa^tG@Tp zI^sA~)bi)9xpsKs##_!7yL*a2XN!#Av~3swU=#qXnHj6|(I2kN{Nm|VqLfO@&``4H zKmWbw=v{Z8G=a?rNA$8b&`b*vHQ11(&7}KLLC{bKAEi{fO|_q_j4Z10%ZQ|&E9bAT z{V!d#F7I`A7Un|Tve#aJ)@{#}{bR)n1+wyyhgSm!n+E_^OVXXb>DJR{Kl`~;r8Vy< z5X(aTT>bylaUgZ#cv_ji>p!@3?UPR~W%m;~`Mhc6+7kt)SbLpJud@Lkpz`5_@KH*E zQX2WBB>n=QiU~j^3A3e7KV?5~)mYP$yX~3M#0@u(uQ@nU_Y^^n-+^yq*$hH7xsFX07xnIVbjF`^+7`w zC@raia>|p{-BGGLl5ZScg8AI#ADDDwakrVNky203jN6_G%z$L=|790Xyh{K|AGv8D z-?OHut1~t>5?k}&y?ybsXHzD5llbIlqUV{XmkJzxoh6X26RD5sHDwskT1NlBNa2tL zN(Z0hfTnj!4J^TruWKwpdEtNWJ?||{fAET?s@&Ao*Nw5qNF913?MzL^d8lWu{Lt|4 zKK+?N)%g)ZAT}``Tl3)keX+AcLfDGSm*<^CG61+o0I>g!_Sp2a#i>T%#+J0Lvc1Dz zJLbA;Arn9^R5%_!=}BrNRr#X?expv+SoM?spSWempleyp8Fvc;G7>NINoIljDTov1-|3gUFHE{@-H``gW!aNJq8yqMp5 z*%VuU>nr<~@gAhpy)x&lSXt63ThH!Y8)6dJ3hOsc4&HO$F-#=9!XI8a#^wPkQU=g* z`t2kO4SN&H;4y4#C4e$(=R?L@JDwpSaQu!k(<(E!s*}>)Mf{y8Q9oYcSy~n(kga-gHa`DzFj3pc& zIsyRTlxbq$i=8slsZuskdx{iFAto}QRHih*iV!#fwE@#AS{KFybN-*MoK*EhX%YVa z$UoeDEPv#RogJ@lx-{U!%R(NU>(N=4_?5mihz?9Mgg@-#S?)T!nc!}Ro4H|ErssY#i?y~ z{JtR{ju=czZdo3#y(lMCw$b5O_XGECjGYz3R$RYna^Rl(j$%to{ejR`zJi@qE=}+S zVFBdS4h703WI`lb{%76rB-wX%gh(y(&-6-&#>v&Tvpop@3cen09a|^+*Jz0OTidsv z?XVG+KKjG=k_a>XQmlVNa{a(BkCdmgF}_@EbU4<%`@W4*pRISpC z3P7k+FB2#uLKgsx2M`g_aU2ql$IZK@Zrd@`Qbt(%vmdW1Iwi{(I$EzXq!dhvxCEf< z(3@@Jt~-R5h4$!3Z1n^8Zn6~0Hu$A`k9Z0BOGHwKUQfpdPNxEtSe93~_~J>yO`ude z7Cg59RRYjKq8xM$s9YDV(ZCm-8vC);Sj(%b-azbE{SC)V%@uUZIb2LioF{q zhwi!W2qsgW>Rb~C_jRCGFUGmem!6a5Fm-Ln`qjLX-|Xwm`EVfg;jBuslyG?-P$`;5 z3AIYeDIJJ>IcBs;tzOHr0*u)Z9?7vsheJ?Jz@&#Kps=>|YY#bhp z(~TQz&z8Eqo2JNf&#nr{NvUKld-w;d6NeACNqZ1_`zFtR`D=$EneJB-PcdX%Q)khUNGV2xEO*nAvO z+?K$bvQ7vS;0)hU_=3=oc_hr-9a`bu&v*a9r?=Fk6<#T9aNCm_i`q^Z|`#c0Z6a4wLEp>&BJ^uL_z*>+3Q+SI=AgpZ?!-C z@I|s-w$jQ~xseCI(+{9d#n`9cO0@mxzg8!H_2SC9f&{>eCCk${-#(;x79ntb8-%f{D!@gKKLUG?GNnN6Fg%NsTZUTK-yzc&*uZk zcJ;IBCQF5|32_!4LtsJ!rcyHzeA2|P2)eld&=flU^IR!hlx6b%-G|~|`_dM2`b=vb zaJjtgo;=o`I(e);W!av)dUXx}0f7K>0VQ1^5)4a3ld0ya# zW9_O4Hj$dm1z;lBq={d~q}DwdC4)%;ppkMZ%1BKq1D;bVl_+{1#9LZ`QVR%S8>4c0 z0V}-&HAlEo0R|KM4s{*3k~6Yw^w1;dRR*P0%!LPl03IT#ey+^Dl1w_ef7;dG{muI} z#|H;n1wn2#v~{Tc)~U3zi;PVsr_<%h&wl>s%%zu2QNc)O#)sp_3DyCnQaM8<6#8R2 zC`H?3L4yhgQ<#iE6VwGVph55ev}I9*T5@sr7?nl@K&CIN0v)Yt3=qF9001eqJg|XK zLcy{vM6@b}K=gxKv0@;i`>BW_z9} zVzqcMRY0mYk>B5qOhuJ{LH9?L@dxhC1*lF+Q=Q8RYqel|#+kYEuis9l(q;PO|E{)& z2U^2Am|lCPSh)V91Jj?}G3aGF9EvWGs+tMr^N@C9>A=&#Av2XKl@kF5vH=!>pn-ip zRHbY>bqnE_fe1)0*((hesAT~nBGY|B5YY!C@WYX@%%n;UA^;(X02BxS5=v_~UQiik zJMAkK3k8{fWj5I%m(*=0{Wz5>YE|rH`4!$xJKmB&HW$z1JMOw{NV`aFwyJ>T_wB^!CXZ^+*ud}O62my*% zs|!5RlWM>d+J_VRbWH%t7%tH}y0k%q3OWPx3MT5Nskg2yuW(kyq}I;eH?P6LfCMNd z)eAX`93s|;^E?+2EBpDtiUtp&KP-||da_7W;Rqj%VX!?3Awc-~F$n>J!SQwMq@ER% z?@1L-G!_me@0V1W*GAzA1Dj0YK%g>02u+pH6i}I>3H-SL6qH&(>1;sZD~Ycni~=&i z5nz9c4;Q7CNEW;*6tn%2Kx_Sqq!Psv-#@IV(d>Rf;Hv2v;@9ONR=h?st8ji`;-8c2 zR$K*62xQO+2V@G~5NHBWSmn|kOB$t$CXE(C7ZFOKV)32xg2@a)kQxcxJ%kV-lvYM( zRuwPk@K@jp0>`Th*5CplKrODdJY=I+;s+4H`L6*yLIM_pfv^Sy1>)0J%M*&u2@ruO zd^nk}rT`?YGHJmzfz4=ml0>QI`nyog1ZK4!xN3G6t5=QId?hCF>!X28w8;a6o6nY-BN*wuqO@#ncfaRiXfFV#_TDOz%iI{ zW#XHF`CCac3%jvY=@BE9Gck!8=RZ^#RpJ*!fXRG12_Q0Ph(;|{>L!d(Yk9BWxzDBp zD3y%#V5E)sX_HzqqFM(L^@y^R5Vnbe=2HCT#Xw3VP-`%^T?<5z2Cj<=w6H2?WDgB@ zQw0dho(5jJWsbTCC|=fNCRUVpQyhy|H=)8I06(p(qzhd#XSJ`4z8N+fg%apOn>CFn zd|ed#5+8B(+{B)Q)KV>B6ix<-sX~P@nTE$Q2Tq|#BA|?-N)z>ym}L;dR5w&fadC(k zxY@kOY$Tz6$h!V_0RfCOe>td>RGNU6DV)x%nW~sZElul=44l%Zi>iJabE#4{!n*+% zU}@Um&nV;iG`_)B22sqirQvs$@Kh3^Mpfu{%?2*2tSs2qwT#?Tq)0YO^%(EU;HggYu2bCeFMGKnD9pYP+z&$&^m!v>TaX zg;L5)Z8%5h9k`gNTm)r8^WCG}s9KX6B9Kt|bxOrjrar``b|I=&Gj9eoR2pNbBqlKo zz;mW>Ix{Eo&mzO9DZ8LVX|C!t1SM42W~y2<6i(;YDH2~owF+DIoupO`!)p*Nng$e2 z_1BuMa9Y1k5)|m7PnlxQCv}@ordyS44HH%3`S`ufP&kuF(%9!yKx*>C-!(x4n7w|o zQJ<{oH&!!&6GCLrW1w4a6fL}4g9bxK9-9d5yaP@ZI79)jwvEi^Z0rTP8Q9q>qk`7N zAk+xBVmuzt7Yc=BDwS%^t*p+uh4%YGT(kw(YY-7K_9hGsRETs-Q Date: Thu, 8 Oct 2020 19:56:08 +0200 Subject: [PATCH 73/78] Fix for Card View to show the Banned Image when author is banned. --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 21685d83d..d24bf2242 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -217,7 +217,7 @@ void BoardPostDisplayWidgetBase::setup() qtime.setTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); dateLabel()->setText(timestamp); - pictureLabel()->setDisabled(true); + pictureLabel()->setDisabled(true); } else { @@ -479,24 +479,34 @@ void BoardPostDisplayWidget_card::setup() { BoardPostDisplayWidgetBase::setup(); - if(mPost.mImage.mData != NULL) + RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId); + bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); + + if(redacted) { - QPixmap pixmap; - GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); - // Wiping data - as its been passed to thumbnail. - - QPixmap scaledpixmap; - if(pixmap.width() > 800){ - QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); - ui->pictureLabel->setPixmap(scaledpixmap); - }else{ - ui->pictureLabel->setPixmap(pixmap); - } - - ui->pictureLabel->show(); + ui->pictureLabel->setPixmap( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-blocked.png") ); } else - ui->pictureLabel->hide(); + { + if(mPost.mImage.mData != NULL) + { + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + // Wiping data - as its been passed to thumbnail. + + QPixmap scaledpixmap; + if(pixmap.width() > 800){ + QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation); + ui->pictureLabel->setPixmap(scaledpixmap); + }else{ + ui->pictureLabel->setPixmap(pixmap); + } + + ui->pictureLabel->show(); + } + else + ui->pictureLabel->hide(); + } QTextDocument doc; doc.setHtml(notes()->text()); From 725c000ce7d031e1c0a2db60876809d4e921bfd4 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 9 Oct 2020 23:27:44 +0200 Subject: [PATCH 74/78] moved showAuthorInPeople to PostedListWidgetWithModel, out of share menu, and disabled edit for now --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 21 ----------- .../src/gui/Posted/BoardPostDisplayWidget.h | 1 - .../gui/Posted/PostedListWidgetWithModel.cpp | 36 +++++++++++++++++++ .../gui/Posted/PostedListWidgetWithModel.h | 1 + 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index d24bf2242..40e50685e 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -147,23 +147,6 @@ void BoardPostDisplayWidgetBase::readToggled() emit changeReadStatusRequested(mPost.mMeta.mMsgId,s); } -void BoardPostDisplayWidgetBase::showAuthorInPeople() -{ - if(mPost.mMeta.mAuthorId.isNull()) - { - std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data..."; - std::cerr << std::endl; - } - - /* window will destroy itself! */ - IdDialog *idDialog = dynamic_cast(MainWindow::getPage(MainWindow::People)); - - if (!idDialog) - return ; - - MainWindow::showWindow(MainWindow::People); - idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId)); -} void BoardPostDisplayWidgetBase::setup() { @@ -188,9 +171,6 @@ void BoardPostDisplayWidgetBase::setup() QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(handleCopyLinkClicked())); - QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); - connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople())); - int S = QFontMetricsF(font()).height() ; readButton()->setChecked(false); @@ -198,7 +178,6 @@ void BoardPostDisplayWidgetBase::setup() QMenu *menu = new QMenu(); menu->addAction(CopyLinkAction); menu->addSeparator(); - menu->addAction(showInPeopleAct); shareButton()->setMenu(menu); connect(shareButton(),SIGNAL(pressed()),this,SLOT(handleShareButtonClicked())); diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 2016ff678..30720d692 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -83,7 +83,6 @@ protected slots: virtual QFrame *mainFrame() =0; void loadComments(bool e); - void showAuthorInPeople(); void readToggled(); void setReadStatus(bool isNew, bool isUnread) ; void makeUpVote() ; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 387b271eb..4a5164834 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -37,12 +37,15 @@ #include "gui/settings/rsharesettings.h" #include "gui/feeds/SubFileItem.h" #include "gui/notifyqt.h" +#include "gui/Identity/IdDialog.h" #include "gui/RetroShareLink.h" #include "util/HandleRichText.h" #include "util/DateTime.h" #include "util/qtthreadsutils.h" #include "gui/common/FilesDefs.h" +#include "gui/MainWindow.h" + #include "PostedListWidgetWithModel.h" #include "PostedPostsModel.h" #include "BoardPostDisplayWidget.h" @@ -64,6 +67,7 @@ // // #define IMAGE_COPYLINK ":/images/copyrslink.png" +#define IMAGE_AUTHOR ":/images/user/personal64.png" Q_DECLARE_METATYPE(RsPostedPost); @@ -369,14 +373,46 @@ void PostedListWidgetWithModel::prev10Posts() } } +void PostedListWidgetWithModel::showAuthorInPeople() +{ + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + + if(!index.isValid()) + throw std::runtime_error("No post under mouse!"); + + RsPostedPost post = index.data(Qt::UserRole).value() ; + + if(post.mMeta.mMsgId.isNull()) + throw std::runtime_error("Post has empty MsgId!"); + + if(post.mMeta.mAuthorId.isNull()) + { + std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data..."; + std::cerr << std::endl; + } + + /* window will destroy itself! */ + IdDialog *idDialog = dynamic_cast(MainWindow::getPage(MainWindow::People)); + + if (!idDialog) + return ; + + MainWindow::showWindow(MainWindow::People); + idDialog->navigate(RsGxsId(post.mMeta.mAuthorId)); +} void PostedListWidgetWithModel::postContextMenu(const QPoint&) { QMenu menu(this); menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink())); + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR), tr("Show author in People tab"), this, SLOT(showAuthorInPeople())); + +#ifdef TODO + // This feature is not implemented yet in libretroshare. if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) menu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_16.png"), tr("Edit"), this, SLOT(editPost())); +#endif menu.exec(QCursor::pos()); } diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 63dcbf9e1..3b8ebc7df 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -132,6 +132,7 @@ protected: virtual void setAllMessagesReadDo(bool read, uint32_t &token) override; private slots: + void showAuthorInPeople(); void tabCloseRequested(int index); void updateSorting(int); void switchDisplayMode(); From 28f1afb36250d516052935fafca081c75bf6aae4 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 10 Oct 2020 14:02:51 +0200 Subject: [PATCH 75/78] Show the rights tabs on Channels and People --- retroshare-gui/src/gui/Identity/IdDialog.ui | 8 ++++---- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index 127f7a85a..d785dbc4c 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -268,7 +268,7 @@ - 1 + 0 @@ -289,8 +289,8 @@ 0 0 - 1372 - 719 + 634 + 523 @@ -1031,7 +1031,7 @@ border-image: url(:/images/closepressed.png) - + :/images/edit_16.png:/images/edit_16.png diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index 46683b31c..5bf481a44 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -431,7 +431,7 @@ p, li { white-space: pre-wrap; }
- 1 + 0 From 4741049707885b5cb85315be4845f4aafd85de35 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 10 Oct 2020 21:58:49 +0200 Subject: [PATCH 76/78] Look the Card View more like reddits one & fix some default stylsheets --- .../gui/Posted/BoardPostDisplayWidget_card.ui | 296 +++++++++--------- .../src/gui/qss/stylesheet/Standard.qss | 14 +- 2 files changed, 168 insertions(+), 142 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui index 75fa5e227..11c5dd748 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget_card.ui @@ -89,114 +89,95 @@ 2 - - - - - - 0 - 0 - - - - Vote up - - - - - - - :/images/up-arrow.png:/images/up-arrow.png - - - true - - - - - - - - 9 - - - - 0 - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Vote down - - - - - - \/ - - - - :/images/down-arrow.png:/images/down-arrow.png - - - true - - - - + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Vote up + + + + + + + :/images/up-arrow.png:/images/up-arrow.png + + + true + + + + + + + + 9 + + + + 0 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Vote down + + + + + + \/ + + + + :/images/down-arrow.png:/images/down-arrow.png + + + true + + + + + - - - - - 0 - 0 - - - - - Arial - 10 - 75 - true - - - - This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - @@ -259,6 +240,42 @@ + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + + :/images/message-state-unread.png:/images/message-state-unread.png + + + false + + + false + + + true + + + + + + + New + + + @@ -277,6 +294,39 @@ + + + + + 0 + 0 + + + + + Arial + 10 + 75 + true + + + + This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + @@ -369,42 +419,6 @@ - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Toggle Message Read Status - - - - :/images/message-state-unread.png:/images/message-state-unread.png - - - false - - - false - - - true - - - - - - - New - - - diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 2f8ef3ad9..33998771c 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -829,7 +829,13 @@ BoardPostDisplayWidget_compact QLabel#pictureLabel{ border-radius: 3px; } -BoardPostDisplayWidget_compact QLabel#fromBoldLabel, QLabel#fromLabel, QLabel#dateLabel, QLabel#siteBoldLabel { +BoardPostDisplayWidget_compact QLabel#fromBoldLabel , +BoardPostDisplayWidget_card QLabel#fromBoldLabel { + font: bold; +} + +BoardPostDisplayWidget_compact QLabel#fromBoldLabel, QLabel#fromLabel, QLabel#dateLabel, QLabel#siteBoldLabel , +BoardPostDisplayWidget_card QLabel#fromBoldLabel, QLabel#fromLabel, QLabel#dateLabel, QLabel#siteBoldLabel{ color: #787c7e; } @@ -861,6 +867,12 @@ BoardPostDisplayWidget_card > QFrame#mainFrame[new=true] { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #F0F8FD, stop:0.8 #E6F2FD, stop: 0.81 #E6F2FD, stop: 1 #D2E7FD); } +BoardPostDisplayWidget_compact QLabel#titleLabel, +BoardPostDisplayWidget_card QLabel#titleLabel{ + font-size: 14px; + font: bold; +} + GxsCommentDialog QComboBox#sortBox { font: bold; color: #0099cc; From 8b5c7eddf3a07fbdb922b0ea6736ade574245106 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 11 Oct 2020 19:01:46 +0200 Subject: [PATCH 77/78] Changed Button for Channel composer * Changed Button type for Channel composer * Set default stylesheet for the Post Button --- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 14 ++++----- .../gui/gxschannels/CreateGxsChannelMsg.ui | 31 ++++++++++++++----- .../src/gui/qss/stylesheet/Standard.qss | 16 ++++++++++ retroshare-gui/src/qss/qdarkstyle-v2.qss | 18 +++++++++++ retroshare-gui/src/qss/qdarkstyle.qss | 26 ++++++++++++++++ 5 files changed, 90 insertions(+), 15 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 087e29300..f7f8ed726 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -65,10 +65,8 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId setAttribute ( Qt::WA_DeleteOnClose, true ); - buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Post")); - - connect(buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancelMsg())); + connect(postButton, SIGNAL(clicked()), this, SLOT(sendMsg())); + connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelMsg())); connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); @@ -599,8 +597,8 @@ void CreateGxsChannelMsg::checkAttachmentReady() * recognized by librs but not correctly by gui (can't * formally remove it) */ - buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); + postButton->setEnabled(false); + cancelButton->setEnabled(false); break; } } @@ -608,8 +606,8 @@ void CreateGxsChannelMsg::checkAttachmentReady() if (fit == mAttachments.end()) { - buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); - buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(true); + postButton->setEnabled(true); + cancelButton->setEnabled(true); } /* repeat... */ diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index 9d296666c..185639054 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -329,7 +329,7 @@ p, li { white-space: pre-wrap; } 0 0 - 842 + 81 24 @@ -431,6 +431,9 @@ p, li { white-space: pre-wrap; } + + 9 + @@ -449,15 +452,29 @@ p, li { white-space: pre-wrap; } - - - - + Qt::Horizontal - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + 40 + 20 + + + + + + + + Post + + + + + + + Cancel diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 33998771c..018239298 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -115,7 +115,23 @@ GxsCreateCommentDialog QFrame#frame { background: white; } +CreateGxsChannelMsg QPushButton#postButton { + font: bold; + font-size: 15px; + color: white; + background: #0099cc; + border-radius: 4px; + max-height: 27px; + min-width: 4em; + padding: 2px; +} +CreateGxsChannelMsg QPushButton#postButton:hover { + background: #03b1f3; + border-radius: 4px; + min-width: 4em; + padding: 2px; +} /* Forums */ diff --git a/retroshare-gui/src/qss/qdarkstyle-v2.qss b/retroshare-gui/src/qss/qdarkstyle-v2.qss index 6a86212c5..e96df4876 100644 --- a/retroshare-gui/src/qss/qdarkstyle-v2.qss +++ b/retroshare-gui/src/qss/qdarkstyle-v2.qss @@ -2052,6 +2052,24 @@ GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton::menu-button { } +CreateGxsChannelMsg QPushButton#postButton { + font: bold; + font-size: 15px; + color: white; + background: #0099cc; + border-radius: 4px; + max-height: 27px; + min-width: 4em; + padding: 2px; +} + +CreateGxsChannelMsg QPushButton#postButton:hover { + background: #03b1f3; + border-radius: 4px; + min-width: 4em; + padding: 2px; +} + QTabBar#smTab::tab{ height: 32px; width: 32px; diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index 6f8f2a0a7..e301f6c53 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -1217,6 +1217,24 @@ GxsChannelPostsWidgetWithModel QToolButton#subscribeToolButton::menu-button { } +CreateGxsChannelMsg QPushButton#postButton { + font: bold; + font-size: 15px; + color: white; + background: #0099cc; + border-radius: 4px; + max-height: 27px; + min-width: 4em; + padding: 2px; +} + +CreateGxsChannelMsg QPushButton#postButton:hover { + background: #03b1f3; + border-radius: 4px; + min-width: 4em; + padding: 2px; +} + QTabBar#smTab::tab{ height: 32px; width: 32px; @@ -1286,6 +1304,14 @@ BoardPostDisplayWidget_compact QLabel#pictureLabel{ border-radius: 3px; } +BoardPostDisplayWidget_compact > QFrame#frame [new=false]{ + background: #302F2F; +} + +BoardPostDisplayWidget_compact > QFrame#frame[new=true] { + background-color: #005000; +} + BoardPostDisplayWidget_card QToolButton#voteDownButton, QToolButton#voteUpButton { border: none; From 937b24e93691b79dc97538ca548e51444c8aec83 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 11 Oct 2020 22:26:36 +0200 Subject: [PATCH 78/78] added missing includes of FilesDefs --- retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp | 1 + retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp | 1 + retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp | 1 + retroshare-gui/src/gui/TheWire/PulseViewItem.cpp | 1 + retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp | 1 + retroshare-gui/src/gui/TheWire/WireGroupItem.cpp | 1 + retroshare-gui/src/gui/settings/WebuiPage.h | 3 ++- 7 files changed, 8 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp index 0bdd3c338..b7e8b6054 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp @@ -22,6 +22,7 @@ #include #include "PulseReply.h" +#include "gui/common/FilesDefs.h" #include "PulseAddDialog.h" diff --git a/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp b/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp index c8e26d987..e8c830a0b 100644 --- a/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseTopLevel.cpp @@ -24,6 +24,7 @@ #include #include "PulseTopLevel.h" +#include "gui/common/FilesDefs.h" #include #include diff --git a/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp b/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp index 27b085a01..547fabbab 100644 --- a/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseViewGroup.cpp @@ -26,6 +26,7 @@ #include "PulseViewGroup.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" #include "util/DateTime.h" /** Constructor */ diff --git a/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp b/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp index 2025baf85..5a309f94b 100644 --- a/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp @@ -26,6 +26,7 @@ #include "PulseViewItem.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" #include "util/DateTime.h" /** Constructor */ diff --git a/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp b/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp index f29aee712..43303cecf 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireGroupDialog.cpp @@ -22,6 +22,7 @@ #include "WireGroupExtra.h" #include "WireGroupDialog.h" +#include "gui/common/FilesDefs.h" #include "gui/gxs/GxsIdDetails.h" #include diff --git a/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp b/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp index 81df64dd2..aa4f63696 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp +++ b/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp @@ -25,6 +25,7 @@ #include "WireGroupItem.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" #include #include diff --git a/retroshare-gui/src/gui/settings/WebuiPage.h b/retroshare-gui/src/gui/settings/WebuiPage.h index f38662f5e..9ba8886ac 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.h +++ b/retroshare-gui/src/gui/settings/WebuiPage.h @@ -20,7 +20,8 @@ #pragma once -#include +#include "retroshare-gui/configpage.h" +#include "gui/common/FilesDefs.h" #include "ui_WebuiPage.h" namespace resource_api{