From f1d98913d1ff9d58c7be6d89cf10196af3cd5bad Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 21 Oct 2020 22:07:45 +0200 Subject: [PATCH 01/16] fixed disabling of channel post comment box on resize and comment --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 9 ++++++-- .../gui/gxschannels/GxsChannelPostsModel.h | 4 +++- .../GxsChannelPostsWidgetWithModel.cpp | 23 +++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 797b2fb6f..a5a56597b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -319,13 +319,16 @@ Qt::ItemFlags RsGxsChannelPostsModel::flags(const QModelIndex& index) const return QAbstractItemModel::flags(index); } -void RsGxsChannelPostsModel::setNumColumns(int n) +bool RsGxsChannelPostsModel::setNumColumns(int n) { if(n < 1) { RsErr() << __PRETTY_FUNCTION__ << " Attempt to set a number of column of 0. This is wrong." << std::endl; - return; + return false; } + if(mColumns == n) + return false; + preMods(); beginRemoveRows(QModelIndex(),0,rowCount()-1); @@ -337,6 +340,8 @@ void RsGxsChannelPostsModel::setNumColumns(int n) endInsertRows(); postMods(); + + return true; } quintptr RsGxsChannelPostsModel::getChildRef(quintptr ref,int index) const diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index 931135840..d8385d24b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -116,7 +116,9 @@ public: void triggerViewUpdate(); - void setNumColumns(int n); + // sets the number of columns. Returns 0 if nothing changes. + bool setNumColumns(int n); + void setMode(TreeMode mode); TreeMode getMode() const { return mTreeMode; } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 9e08c0038..610932ef1 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -674,8 +674,19 @@ void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s,bool forc int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),ui->postsTree->width())))); std::cerr << "nb columns: " << n_columns << " current count=" << mChannelPostsModel->columnCount() << std::endl; - if(force || (n_columns != mChannelPostsModel->columnCount())) - mChannelPostsModel->setNumColumns(n_columns); + // save current post. The setNumColumns() indeed loses selection + + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + RsGxsMessageId current_mid; + + if(index.isValid()) + current_mid = index.data(Qt::UserRole).value().mMeta.mMsgId ; + + if((force || (n_columns != mChannelPostsModel->columnCount())) && mChannelPostsModel->setNumColumns(n_columns)) + { + // Restore current post. The setNumColumns() indeed loses selection + ui->postsTree->selectionModel()->setCurrentIndex(mChannelPostsModel->getIndexOfMessage(current_mid),QItemSelectionModel::ClearAndSelect); + } } void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptr event) @@ -706,7 +717,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); RsGxsChannelPost post = index.data(Qt::UserRole).value() ; - QTextDocument doc; + QTextDocument doc; doc.setHtml(post.mMsg.c_str()); if(post.mMeta.mPublishTs == 0) @@ -717,6 +728,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() ui->postTime_LB->hide(); mChannelPostFilesModel->clear(); ui->details_TW->setEnabled(false); +// mSelectedPost.clear(); return; } @@ -726,9 +738,6 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() 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; @@ -741,7 +750,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() 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); + ui->commentsDialog->commentLoad(post.mMeta.mGroupId, all_msgs_versions, post.mMeta.mMsgId,true); std::cerr << "Showing details about selected index : "<< index.row() << "," << index.column() << std::endl; From beb9aeaf65766c7e623e15569a9994b3c36770bb Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 21 Oct 2020 22:24:24 +0200 Subject: [PATCH 02/16] changed Feed into Log in settings --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 2 -- retroshare-gui/src/gui/settings/NotifyPage.ui | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 610932ef1..c0c6cb327 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -728,7 +728,6 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() ui->postTime_LB->hide(); mChannelPostFilesModel->clear(); ui->details_TW->setEnabled(false); -// mSelectedPost.clear(); return; } @@ -1041,7 +1040,6 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); ui->subscribeToolButton->setEnabled(true); - bool autoDownload ; rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload); setAutoDownload(autoDownload); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.ui b/retroshare-gui/src/gui/settings/NotifyPage.ui index f468a62ec..47ae28ccc 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.ui +++ b/retroshare-gui/src/gui/settings/NotifyPage.ui @@ -18,7 +18,7 @@ - Feed + Log From 2afda27a8ceef8e80ae069fa9c80ae47441bd098 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 21 Oct 2020 22:26:33 +0200 Subject: [PATCH 03/16] hide testfeed button --- retroshare-gui/src/gui/settings/NotifyPage.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 6035e25a0..f1529a2ea 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -40,6 +40,8 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); + ui.testFeedButton->hide(); // do not show in release + connect(ui.testFeedButton, SIGNAL(clicked()), this, SLOT(testFeed())); connect(ui.testToasterButton, SIGNAL(clicked()), this, SLOT(testToaster())); connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); From a59a9c26504f86d4c27766be4d1bfdb343dcd54c Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 22 Oct 2020 22:09:25 +0200 Subject: [PATCH 04/16] changed display menu icon to something more appropriate --- retroshare-gui/src/gui/common/GroupTreeWidget.ui | 5 ++--- retroshare-gui/src/gui/icons.qrc | 1 + retroshare-gui/src/gui/icons/svg/display_options.svg | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 retroshare-gui/src/gui/icons/svg/display_options.svg diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.ui b/retroshare-gui/src/gui/common/GroupTreeWidget.ui index 1f0a09426..5cb90b27d 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.ui +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.ui @@ -66,7 +66,7 @@ - :/icons/svg/design.svg:/icons/svg/design.svg + :/icons/svg/display_options.svg:/icons/svg/display_options.svg @@ -137,7 +137,7 @@ LineEditClear QLineEdit -
gui/common/LineEditClear.h
+
gui/common/LineEditClear.h
RSTreeWidget @@ -146,7 +146,6 @@ - diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index 0f3477394..75b2d064e 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -9,6 +9,7 @@ icons/svg/ratio-16-9.svg icons/svg/randomness.svg icons/svg/password.svg + icons/svg/display_options.svg icons/svg/listlayout.svg icons/svg/gridlayout.svg icons/stars/star0.png diff --git a/retroshare-gui/src/gui/icons/svg/display_options.svg b/retroshare-gui/src/gui/icons/svg/display_options.svg new file mode 100644 index 000000000..88af507a1 --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/display_options.svg @@ -0,0 +1,2 @@ + + From bf3285dfc138aed0951a05cc9426a0d526ecdf28 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 22 Oct 2020 22:19:49 +0200 Subject: [PATCH 05/16] increased number of posts to show in boards to 25. Used a single variable for it --- .../gui/Posted/PostedListWidgetWithModel.cpp | 27 ++++++++++--------- .../gui/Posted/PostedListWidgetWithModel.h | 4 +-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 0ad37e78b..5e34d2c7e 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -54,6 +54,9 @@ #define ROLE_PUBLISH FEED_TREEWIDGET_SORTROLE +// number of posts to show at once. +#define POSTS_CHUNK_SIZE 25 + /**** * #define DEBUG_POSTED ***/ @@ -255,8 +258,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI 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())); + connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(nextPosts())); + connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prevPosts())); connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&))); connect(ui->viewModeButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode())); @@ -352,24 +355,24 @@ void PostedListWidgetWithModel::filterItems(QString text) 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))); + ui->showLabel->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1))); } -void PostedListWidgetWithModel::next10Posts() +void PostedListWidgetWithModel::nextPosts() { - if(mPostedPostsModel->displayedStartPostIndex() + 10 < mPostedPostsModel->filteredPostsCount()) + if(mPostedPostsModel->displayedStartPostIndex() + POSTS_CHUNK_SIZE < 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))); + mPostedPostsModel->setPostsInterval(POSTS_CHUNK_SIZE+mPostedPostsModel->displayedStartPostIndex(),POSTS_CHUNK_SIZE); + ui->showLabel->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1))); } } -void PostedListWidgetWithModel::prev10Posts() +void PostedListWidgetWithModel::prevPosts() { - if((int)mPostedPostsModel->displayedStartPostIndex() - 10 >= 0) + if((int)mPostedPostsModel->displayedStartPostIndex() - POSTS_CHUNK_SIZE >= 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))); + mPostedPostsModel->setPostsInterval(mPostedPostsModel->displayedStartPostIndex()-POSTS_CHUNK_SIZE,POSTS_CHUNK_SIZE); + ui->showLabel->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1))); } } @@ -634,7 +637,7 @@ void PostedListWidgetWithModel::postPostLoad() 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->showLabel)->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1))); whileBlocking(ui->filter_LE)->setText(QString()); } diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 3b8ebc7df..238bdf05b 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -143,8 +143,8 @@ private slots: void postPostLoad(); void postContextMenu(const QPoint&); void copyMessageLink(); - void next10Posts(); - void prev10Posts(); + void nextPosts(); + void prevPosts(); void filterItems(QString s); public slots: From b01140dcbd7f384d827b1fbe1b83bde43d2b7876 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 22 Oct 2020 22:49:31 +0200 Subject: [PATCH 06/16] fixed next unread button when new forum is selected --- .../src/gui/gxsforums/GxsForumThreadWidget.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 60d0f11a8..0d6a0ff31 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -534,7 +534,8 @@ void GxsForumThreadWidget::updateDisplay(bool complete) #ifdef DEBUG_FORUMS std::cerr << " group_id=0. Return!"<< std::endl; #endif - return; + ui->nextUnreadButton->setEnabled(false); + return; } if(mForumGroup.mMeta.mGroupId.isNull() && !groupId().isNull()) @@ -984,7 +985,6 @@ void GxsForumThreadWidget::blankPost() ui->newmessageButton->setEnabled(false); ui->previousButton->setEnabled(false); ui->nextButton->setEnabled(false); - ui->nextUnreadButton->setEnabled(false); ui->downloadButton->setEnabled(false); ui->lineLeft->hide(); ui->time_label->clear(); @@ -1850,7 +1850,10 @@ void GxsForumThreadWidget::filterItems(const QString& text) void GxsForumThreadWidget::postForumLoading() { if(groupId().isNull()) - return; + { + ui->nextUnreadButton->setEnabled(false); + return; + } #ifdef DEBUG_FORUMS std::cerr << "Post forum loading..." << std::endl; @@ -1905,6 +1908,8 @@ void GxsForumThreadWidget::postForumLoading() recursRestoreExpandedItems(mThreadProxyModel->mapFromSource(mThreadModel->root()),mSavedExpandedMessages); //mUpdating = false; + + ui->nextUnreadButton->setEnabled(true); } void GxsForumThreadWidget::updateGroupData() From 0f3e054778a468db43817eac1d5976d806f0304d Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 23 Oct 2020 22:06:13 +0200 Subject: [PATCH 07/16] moved attach button to second tab of create channel msg (information redundancy). Added some tooltips --- .../gui/gxschannels/CreateGxsChannelMsg.ui | 21 ++++++------------- .../gxschannels/GxsChannelPostThumbnail.cpp | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index 185639054..db3da194f 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -185,6 +185,9 @@ p, li { white-space: pre-wrap; }
+ + <html><head/><body><p>Choose aspect ratio policy.</p><p>In 'Auto' mode, the most suitable </p><p>aspect ratio is chosen for you.</p></body></html> + 24 @@ -213,19 +216,6 @@ p, li { white-space: pre-wrap; }
- - - - Add File to Attach - - - - 24 - 24 - - - - @@ -305,7 +295,7 @@ p, li { white-space: pre-wrap; } - + :/icons/png/add-file.png:/icons/png/add-file.png @@ -329,7 +319,7 @@ p, li { white-space: pre-wrap; } 0 0 - 81 + 84 24 @@ -514,6 +504,7 @@ p, li { white-space: pre-wrap; } + diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index ea887212c..eb890b075 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -118,7 +118,7 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) mPostImage->setPicture(thumbnail); if(mFlags & FLAG_ALLOW_PAN) - mPostImage->setToolTip(tr("Use mouse to center and zoom into the image")); + mPostImage->setToolTip(tr("Use mouse to center and zoom\ninto the image, so as to\n crop it for your post.")); QVBoxLayout *layout = new QVBoxLayout(this); From 25c836d4432ab9c0024b2aae05856104a60743d5 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 24 Oct 2020 00:02:26 +0200 Subject: [PATCH 08/16] add attachment count to channel creation window and fixed item removal (was previously only hidden!) --- retroshare-gui/src/gui/feeds/SubFileItem.cpp | 3 +- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 46 ++++- .../src/gui/gxschannels/CreateGxsChannelMsg.h | 2 + .../gui/gxschannels/CreateGxsChannelMsg.ui | 166 ++++++++++-------- 4 files changed, 137 insertions(+), 80 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.cpp b/retroshare-gui/src/gui/feeds/SubFileItem.cpp index ba81ab9bf..251190e62 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/SubFileItem.cpp @@ -559,9 +559,10 @@ void SubFileItem::cancel() /* Only occurs - if it is downloading */ if (((mType == SFI_TYPE_ATTACH) || (mType == SFI_TYPE_CHANNEL)) && (mFlag & SFI_FLAG_CREATE)) { - hide(); rsFiles->ExtraFileRemove(FileHash());//, RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA); mPath = ""; + del(); + return; // do not update! } else { diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index f7f8ed726..973563148 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -69,7 +69,8 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelMsg())); connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); - connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); + connect(removeAllFilesButton, SIGNAL(clicked() ), this , SLOT(clearAllAttachments())); + //connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect(subjectEdit,SIGNAL(textChanged(const QString&)),this,SLOT(updatePreviewText(const QString&))); connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail())); @@ -81,7 +82,7 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId channelpostButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/comment.png")); attachmentsButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/attachements.png")); addThumbnailButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-image.png")); - addfilepushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-file.png")); + //addfilepushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-file.png")); aspectRatio_CB->setItemIcon(0,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-auto.svg")); aspectRatio_CB->setItemIcon(1,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-1-1.svg")); @@ -431,6 +432,16 @@ void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::strin if (mCheckAttachment) checkAttachmentReady(); + + updateAttachmentCount(); +} + +void CreateGxsChannelMsg::updateAttachmentCount() +{ + if(mAttachments.size() > 0) + attachmentsButton->setText(tr("Attachments (%1)").arg(mAttachments.size())); + else + attachmentsButton->setText(tr("Attachments")); } void CreateGxsChannelMsg::deleteAttachment() @@ -449,6 +460,21 @@ void CreateGxsChannelMsg::deleteAttachment() } else ++it; + + updateAttachmentCount(); +} + +void CreateGxsChannelMsg::clearAllAttachments() +{ + QLayoutItem* item; + while ( ( item = fileFrame->layout()->takeAt( 0 ) ) != NULL ) + { + delete item->widget(); + delete item; + } + + mAttachments.clear(); + attachmentsButton->setText(tr("Attachments")); } void CreateGxsChannelMsg::addExtraFile() @@ -489,7 +515,7 @@ void CreateGxsChannelMsg::addAttachment(const std::string &path) setThumbNail(path, 2000); /* add widget in for new destination */ - uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA | SFI_FLAG_CREATE; + uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA | SFI_FLAG_CREATE; // check attachment if hash exists already std::list::iterator it; @@ -516,16 +542,18 @@ void CreateGxsChannelMsg::addAttachment(const std::string &path) //SubFileItem *file = new SubFileItem(hash, filename, path, size, flags, mChannelId); SubFileItem *file = new SubFileItem(hash, filename, path, size, flags, RsPeerId()); - mAttachments.push_back(file); + connect(file,SIGNAL(wantsToBeDeleted()),this,SLOT(deleteAttachment())) ; + + mAttachments.push_back(file); QLayout *layout = fileFrame->layout(); layout->addWidget(file); if (mCheckAttachment) - { checkAttachmentReady(); - } - return; + updateAttachmentCount(); + + return; } bool CreateGxsChannelMsg::setThumbNail(const std::string& path, int frame){ @@ -610,7 +638,9 @@ void CreateGxsChannelMsg::checkAttachmentReady() cancelButton->setEnabled(true); } - /* repeat... */ + updateAttachmentCount(); + + /* repeat... */ int msec_rate = 1000; QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void))); } diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h index 8f8b6e41c..d6953c6d8 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h @@ -59,6 +59,7 @@ private slots: void checkAttachmentReady(); void deleteAttachment(); void updatePreviewText(const QString &); + void clearAllAttachments(); void cancelMsg(); void sendMsg(); @@ -76,6 +77,7 @@ private: void loadChannelInfo(); void loadOriginalChannelPostInfo(); void saveChannelInfo(const RsGroupMetaData &group); + void updateAttachmentCount(); void parseRsFileListAttachments(const std::string &attachList); void sendMessage(const std::string &subject, const std::string &msg, const std::list &files); diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index db3da194f..e98875784 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -82,7 +82,7 @@ false - 0 + 1 @@ -186,7 +186,7 @@ p, li { white-space: pre-wrap; } - <html><head/><body><p>Choose aspect ratio policy.</p><p>In 'Auto' mode, the most suitable </p><p>aspect ratio is chosen for you.</p></body></html> + <html><head/><body><p>Choose aspect ratio policy. In 'Auto' mode, the most suitable aspect ratio is chosen for you.</p></body></html> @@ -261,52 +261,99 @@ p, li { white-space: pre-wrap; } - - - 0 - - - 6 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 34 - 34 - - - - <html><head/><body><p>Add File</p></body></html> - - - - - - - :/icons/png/add-file.png:/icons/png/add-file.png - - - - 24 - 24 - - - + + + + + + + + 0 + 0 + + + + + 34 + 34 + + + + <html><head/><body><p>Add File</p></body></html> + + + + + + + :/icons/png/add-file.png:/icons/png/add-file.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 34 + 34 + + + + <html><head/><body><p>Add File</p></body></html> + + + + + + + :/icons/png/cancel.png:/icons/png/cancel.png + + + + 24 + 24 + + + + + + + + Allow channels to get frame for message thumbnail from movie media attachments or not + + + Auto Thumbnail + + + + + + + Qt::Horizontal + + + + 334 + 26 + + + + + - + Qt::ScrollBarAlwaysOn @@ -319,7 +366,7 @@ p, li { white-space: pre-wrap; } 0 0 - 84 + 827 24 @@ -366,29 +413,6 @@ p, li { white-space: pre-wrap; } - - - - Qt::Horizontal - - - - 334 - 26 - - - - - - - - Allow channels to get frame for message thumbnail from movie media attachments or not - - - Auto Thumbnail - - - From 8903abe98c987e3e8b98e3f019a7baf34f86ebdb Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 24 Oct 2020 14:07:45 +0200 Subject: [PATCH 09/16] added pastFromClipboard button and confirmation when closing with ESC in channel post creation --- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 8 +++++ .../src/gui/gxschannels/CreateGxsChannelMsg.h | 4 ++- .../gui/gxschannels/CreateGxsChannelMsg.ui | 32 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 973563148..d0ef0d7aa 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -67,6 +67,7 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId connect(postButton, SIGNAL(clicked()), this, SLOT(sendMsg())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelMsg())); + connect(pasteFromClipboardButton, SIGNAL(clicked()), this, SLOT(pasteLink())); connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect(removeAllFilesButton, SIGNAL(clicked() ), this , SLOT(clearAllAttachments())); @@ -159,6 +160,13 @@ void CreateGxsChannelMsg::changeAspectRatio(int s) break; } } +void CreateGxsChannelMsg::reject() +{ + if(QMessageBox::warning(nullptr,tr("Close this window?"),tr("Do you really want to discard your post?"),QMessageBox::Ok,QMessageBox::Cancel) == QMessageBox::Cancel) + return; + + QDialog::reject(); +} void CreateGxsChannelMsg::contextMenu(QPoint /*point*/) { QList links ; diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h index d6953c6d8..882137b67 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h @@ -41,7 +41,9 @@ public: /** Default Destructor */ ~CreateGxsChannelMsg(); - void addHtmlText(const QString& text) ; + void reject() override; + + void addHtmlText(const QString& text) ; void addSubject(const QString& text) ; void addAttachment(const std::string &path); void addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId,bool assume_file_ready = false); diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index e98875784..36c70e2a7 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -296,6 +296,38 @@ p, li { white-space: pre-wrap; } + + + + + 0 + 0 + + + + + 34 + 34 + + + + <html><head/><body><p>Paste retroshare link(s) from clipboard.</p></body></html> + + + + + + + :/icons/png/copy.png:/icons/png/copy.png + + + + 24 + 24 + + + + From 709b323b03a423657330aaa5a8443a1a410baf50 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 24 Oct 2020 14:19:34 +0200 Subject: [PATCH 10/16] improved layout in channel post widget --- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 5 +-- .../gui/gxschannels/CreateGxsChannelMsg.ui | 33 ++++++++----------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index d0ef0d7aa..6c0a81e3b 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -83,7 +83,6 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId channelpostButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/comment.png")); attachmentsButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/attachements.png")); addThumbnailButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-image.png")); - //addfilepushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-file.png")); aspectRatio_CB->setItemIcon(0,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-auto.svg")); aspectRatio_CB->setItemIcon(1,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-1-1.svg")); @@ -160,13 +159,15 @@ void CreateGxsChannelMsg::changeAspectRatio(int s) break; } } + void CreateGxsChannelMsg::reject() { - if(QMessageBox::warning(nullptr,tr("Close this window?"),tr("Do you really want to discard your post?"),QMessageBox::Ok,QMessageBox::Cancel) == QMessageBox::Cancel) + if(QMessageBox::warning(nullptr,tr("Close this window?"),tr("Do you really want to discard your post?"),QMessageBox::Yes,QMessageBox::No) == QMessageBox::No) return; QDialog::reject(); } + void CreateGxsChannelMsg::contextMenu(QPoint /*point*/) { QList links ; diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index 36c70e2a7..bc8574587 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -82,7 +82,7 @@ false - 1 + 0 @@ -246,6 +246,19 @@ p, li { white-space: pre-wrap; } + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -288,12 +301,6 @@ p, li { white-space: pre-wrap; } :/icons/png/add-file.png:/icons/png/add-file.png - - - 24 - 24 - - @@ -320,12 +327,6 @@ p, li { white-space: pre-wrap; } :/icons/png/copy.png:/icons/png/copy.png - - - 24 - 24 - - @@ -352,12 +353,6 @@ p, li { white-space: pre-wrap; } :/icons/png/cancel.png:/icons/png/cancel.png - - - 24 - 24 - - From c30107c248ff175b63f75adc0b4253bebad26cf8 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 24 Oct 2020 21:17:34 +0200 Subject: [PATCH 11/16] added up-to-date info about sync period in group data details (channels, boards, forums) and warning when the sync period is too small w.r.t. the date of last post --- libretroshare/src/gxs/rsgenexchange.cc | 8 + libretroshare/src/gxs/rsgenexchange.h | 11 +- libretroshare/src/gxs/rsgxsnetservice.cc | 12 +- libretroshare/src/gxs/rsgxsnetservice.h | 1 + libretroshare/src/gxs/rsgxsnotify.h | 1 + libretroshare/src/gxs/rsnxsobserver.h | 5 + libretroshare/src/retroshare/rsgxschannels.h | 1 + libretroshare/src/retroshare/rsgxsforums.h | 1 + libretroshare/src/retroshare/rsposted.h | 1 + libretroshare/src/services/p3gxschannels.cc | 9 + libretroshare/src/services/p3gxsforums.cc | 11 +- libretroshare/src/services/p3postbase.cc | 9 + retroshare-gui/src/gui/Posted/PostedDialog.h | 32 +-- .../gui/Posted/PostedListWidgetWithModel.cpp | 38 +++- .../gui/Posted/PostedListWidgetWithModel.ui | 204 ++++++++++-------- .../src/gui/gxs/GxsGroupFrameDialog.cpp | 2 +- .../src/gui/gxs/GxsGroupFrameDialog.h | 2 + .../GxsChannelPostsWidgetWithModel.cpp | 29 ++- .../GxsChannelPostsWidgetWithModel.ui | 134 +++++++----- .../gui/gxsforums/GxsForumThreadWidget.cpp | 3 +- 20 files changed, 331 insertions(+), 183 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 2d77e6da7..e05ea4fc0 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -1695,6 +1695,14 @@ void RsGenExchange::notifyReceivePublishKey(const RsGxsGroupId &grpId) mNotifications.push_back(gc); } +void RsGenExchange::notifyChangedGroupSyncParams(const RsGxsGroupId &grpId) +{ + RS_STACK_MUTEX(mGenMtx); + + RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_GROUP_SYNC_PARAMETERS_UPDATED,grpId, false); + + mNotifications.push_back(gc); +} void RsGenExchange::notifyChangedGroupStats(const RsGxsGroupId &grpId) { RS_STACK_MUTEX(mGenMtx); diff --git a/libretroshare/src/gxs/rsgenexchange.h b/libretroshare/src/gxs/rsgenexchange.h index 4a05e61c4..5b18e5663 100644 --- a/libretroshare/src/gxs/rsgenexchange.h +++ b/libretroshare/src/gxs/rsgenexchange.h @@ -133,28 +133,29 @@ public: /*! * @param messages messages are deleted after function returns */ - virtual void receiveNewMessages(std::vector& messages); + virtual void receiveNewMessages(std::vector& messages) override; /*! * @param groups groups are deleted after function returns */ - virtual void receiveNewGroups(std::vector& groups); + virtual void receiveNewGroups(std::vector& groups) override; /*! * @param grpId group id */ - virtual void notifyReceivePublishKey(const RsGxsGroupId &grpId); + virtual void notifyReceivePublishKey(const RsGxsGroupId &grpId) override; + virtual void notifyChangedGroupSyncParams(const RsGxsGroupId &grpId) override; /*! * \brief notifyReceiveDistantSearchResults * Should be called when new search results arrive. * \param grpId */ - virtual void receiveDistantSearchResults(TurtleRequestId id,const RsGxsGroupId &grpId); + virtual void receiveDistantSearchResults(TurtleRequestId id,const RsGxsGroupId &grpId) override; /*! * @param grpId group id */ - virtual void notifyChangedGroupStats(const RsGxsGroupId &grpId); + virtual void notifyChangedGroupStats(const RsGxsGroupId &grpId) override; /** E: Observer implementation **/ diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 8ed657bfb..e46b7efee 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -446,6 +446,7 @@ int RsGxsNetService::tick() should_notify = should_notify || !mNewMessagesToNotify.empty() ; should_notify = should_notify || !mNewPublishKeysToNotify.empty() ; should_notify = should_notify || !mNewStatsToNotify.empty() ; + should_notify = should_notify || !mNewGrpSyncParamsToNotify.empty() ; } if(should_notify) @@ -490,7 +491,7 @@ void RsGxsNetService::processObserverNotifications() std::vector grps_copy ; std::vector msgs_copy ; std::set stat_copy ; - std::set keys_copy ; + std::set keys_copy,grpss_copy ; { RS_STACK_MUTEX(mNxsMutex) ; @@ -499,11 +500,13 @@ void RsGxsNetService::processObserverNotifications() msgs_copy = mNewMessagesToNotify ; stat_copy = mNewStatsToNotify ; keys_copy = mNewPublishKeysToNotify ; + grpss_copy = mNewGrpSyncParamsToNotify ; mNewGroupsToNotify.clear() ; mNewMessagesToNotify.clear() ; mNewStatsToNotify.clear() ; mNewPublishKeysToNotify.clear() ; + mNewGrpSyncParamsToNotify.clear() ; } if(!grps_copy.empty()) mObserver->receiveNewGroups (grps_copy); @@ -514,6 +517,9 @@ void RsGxsNetService::processObserverNotifications() for(std::set::const_iterator it(stat_copy.begin());it!=stat_copy.end();++it) mObserver->notifyChangedGroupStats(*it); + + for(std::set::const_iterator it(grpss_copy.begin());it!=grpss_copy.end();++it) + mObserver->notifyChangedGroupSyncParams(*it); } void RsGxsNetService::rejectMessage(const RsGxsMessageId& msg_id) @@ -4740,6 +4746,10 @@ void RsGxsNetService::setSyncAge(const RsGxsGroupId &grpId, uint32_t age_in_secs locked_resetClientTS(grpId); IndicateConfigChanged(); + + // also send an event so that UI is updated + + mNewGrpSyncParamsToNotify.insert(grpId); } } void RsGxsNetService::setKeepAge(const RsGxsGroupId &grpId, uint32_t age_in_secs) diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 6b3e39d30..78f384e42 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -608,6 +608,7 @@ private: std::vector mNewMessagesToNotify ; std::set mNewStatsToNotify ; std::set mNewPublishKeysToNotify ; + std::set mNewGrpSyncParamsToNotify ; // Distant search result map std::map > mDistantSearchResults ; diff --git a/libretroshare/src/gxs/rsgxsnotify.h b/libretroshare/src/gxs/rsgxsnotify.h index 71db32ebc..1e1a5f868 100644 --- a/libretroshare/src/gxs/rsgxsnotify.h +++ b/libretroshare/src/gxs/rsgxsnotify.h @@ -48,6 +48,7 @@ public: TYPE_UPDATED = 0x07, TYPE_MESSAGE_DELETED = 0x08, TYPE_GROUP_DELETED = 0x09, + TYPE_GROUP_SYNC_PARAMETERS_UPDATED = 0x0a, }; virtual NotifyType getType() = 0; diff --git a/libretroshare/src/gxs/rsnxsobserver.h b/libretroshare/src/gxs/rsnxsobserver.h index 164cce366..83db62e16 100644 --- a/libretroshare/src/gxs/rsnxsobserver.h +++ b/libretroshare/src/gxs/rsnxsobserver.h @@ -61,6 +61,11 @@ public: */ virtual void notifyReceivePublishKey(const RsGxsGroupId &grpId) = 0; + /*! + * \brief notifyChangedGroupSyncParams + * \param caled when a group sync parameter is updated + */ + virtual void notifyChangedGroupSyncParams(const RsGxsGroupId &grpId) = 0; /*! * @param grpId group id */ diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index 106147dc6..b7ec8ee7f 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -113,6 +113,7 @@ enum class RsChannelEventCode: uint8_t READ_STATUS_CHANGED = 0x07, // existing message has been read or set to unread RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id STATISTICS_CHANGED = 0x09, // stats (nb of supplier friends, how many msgs they have etc) has changed + SYNC_PARAMETERS_UPDATED = 0x0a, // sync and storage times have changed }; struct RsGxsChannelEvent: RsEvent diff --git a/libretroshare/src/retroshare/rsgxsforums.h b/libretroshare/src/retroshare/rsgxsforums.h index a5908c902..20b7d87de 100644 --- a/libretroshare/src/retroshare/rsgxsforums.h +++ b/libretroshare/src/retroshare/rsgxsforums.h @@ -115,6 +115,7 @@ enum class RsForumEventCode: uint8_t READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed MODERATOR_LIST_CHANGED = 0x08, /// forum moderation list has changed. + SYNC_PARAMETERS_UPDATED = 0x0a, /// sync and storage times have changed }; struct RsGxsForumEvent: RsEvent diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 3c7724f6c..e7f155473 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -116,6 +116,7 @@ enum class RsPostedEventCode: uint8_t READ_STATUS_CHANGED = 0x06, STATISTICS_CHANGED = 0x07, MESSAGE_VOTES_UPDATED = 0x08, + SYNC_PARAMETERS_UPDATED = 0x09, }; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index ab5990bae..a3117c8a4 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -309,6 +309,15 @@ void p3GxsChannels::notifyChanges(std::vector &changes) } break; + case RsGxsNotify::TYPE_GROUP_SYNC_PARAMETERS_UPDATED: + { + auto ev = std::make_shared(); + ev->mChannelGroupId = grpChange->mGroupId; + ev->mChannelEventCode = RsChannelEventCode::SYNC_PARAMETERS_UPDATED; + rsEvents->postEvent(ev); + } + break; + case RsGxsNotify::TYPE_STATISTICS_CHANGED: { auto ev = std::make_shared(); diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 988abb667..cf0625f1d 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -256,7 +256,16 @@ void p3GxsForums::notifyChanges(std::vector &changes) } break; - case RsGxsNotify::TYPE_PUBLISHED: + case RsGxsNotify::TYPE_GROUP_SYNC_PARAMETERS_UPDATED: + { + auto ev = std::make_shared(); + ev->mForumGroupId = grpChange->mGroupId; + ev->mForumEventCode = RsForumEventCode::SYNC_PARAMETERS_UPDATED; + rsEvents->postEvent(ev); + } + break; + + case RsGxsNotify::TYPE_PUBLISHED: case RsGxsNotify::TYPE_RECEIVED_NEW: { /* group received */ diff --git a/libretroshare/src/services/p3postbase.cc b/libretroshare/src/services/p3postbase.cc index 5c25ca52c..3b3c70ec7 100644 --- a/libretroshare/src/services/p3postbase.cc +++ b/libretroshare/src/services/p3postbase.cc @@ -162,6 +162,15 @@ void p3PostBase::notifyChanges(std::vector &changes) } break; + case RsGxsNotify::TYPE_GROUP_SYNC_PARAMETERS_UPDATED: + { + auto ev = std::make_shared(); + ev->mPostedGroupId = group_id; + ev->mPostedEventCode = RsPostedEventCode::SYNC_PARAMETERS_UPDATED; + rsEvents->postEvent(ev); + } + break; + case RsGxsNotify::TYPE_STATISTICS_CHANGED: { auto ev = std::make_shared(); diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.h b/retroshare-gui/src/gui/Posted/PostedDialog.h index 5931ec25b..433adbe93 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedDialog.h @@ -36,15 +36,15 @@ public: /** Default Destructor */ ~PostedDialog(); - virtual QIcon iconPixmap() const { return QIcon(IMAGE_POSTED) ; } //MainPage - virtual QString pageName() const { return tr("Boards") ; } //MainPage - virtual QString helpText() const { return ""; } //MainPage + virtual QIcon iconPixmap() const override { return QIcon(IMAGE_POSTED) ; } //MainPage + virtual QString pageName() const override { return tr("Boards") ; } //MainPage + virtual QString helpText() const override { return ""; } //MainPage protected: virtual UserNotify *createUserNotify(QObject *parent) override; - virtual QString getHelpString() const ; - virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_POSTED; } - virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Posted; } + virtual QString getHelpString() const override; + virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_POSTED; } + virtual GroupFrameSettings::Type groupFrameSettingsType() override { return GroupFrameSettings::Posted; } void groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo) override; bool getGroupData(std::list& groupInfo) override; @@ -52,16 +52,16 @@ protected: private: /* GxsGroupFrameDialog */ - virtual QString text(TextType type); - virtual QString icon(IconType type); - virtual QString settingsGroupName() { return "PostedDialog"; } - virtual GxsGroupDialog *createNewGroupDialog(); - virtual GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId); - virtual int shareKeyType(); - virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId); - virtual RsGxsCommentService *getCommentService(); - virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId); - virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data + virtual QString text(TextType type) override; + virtual QString icon(IconType type) override; + virtual QString settingsGroupName() override{ return "PostedDialog"; } + virtual GxsGroupDialog *createNewGroupDialog() override; + virtual GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId) override; + virtual int shareKeyType() override; + virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId) override; + virtual RsGxsCommentService *getCommentService() override; + virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId) override; + virtual uint32_t requestGroupSummaryType() override { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data void handleEvent_main_thread(std::shared_ptr event); RsEventsHandlerId_t mEventHandlerId; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 5e34d2c7e..a7d39d9cf 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/GxsGroupFrameDialog.h" #include "gui/gxs/GxsCommentDialog.h" #include "util/misc.h" #include "gui/Posted/PostedCreatePostDialog.h" @@ -277,7 +278,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()),this, SLOT(settingsChanged())); /* add filter actions */ - ui->postsTree->setPlaceholderText(tr("Thumbnails")); + ui->postsTree->setPlaceholderText(tr("No posts available in this board")); //ui->postsTree->setMinimumWidth(COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font()).height()+1); connect(ui->postsTree,SIGNAL(sizeChanged(QSize)),this,SLOT(handlePostsTreeSizeChange(QSize))); @@ -488,7 +489,8 @@ void PostedListWidgetWithModel::handleEvent_main_thread(std::shared_ptrmPostedGroupId == groupId()) updateDisplay(true); } @@ -851,11 +853,33 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount)); - if(group.mMeta.mLastPost==0) - ui->infoLastPost->setText(tr("Never")); - else - ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost)); - QString formatDescription = QString::fromUtf8(group.mDescription.c_str()); + if(group.mMeta.mLastPost==0) + ui->infoLastPost->setText(tr("Never")); + else + ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost)); + + uint32_t current_sync_time = GxsGroupFrameDialog::checkDelay(rsPosted->getSyncPeriod(group.mMeta.mGroupId))/86400 ; + + QString sync_string; + switch(current_sync_time) + { + case 5: sync_string = tr("5 days"); break; + case 15: sync_string = tr("2 weeks"); break; + case 30: sync_string = tr("1 month"); break; + case 90: sync_string = tr("3 months"); break; + case 180: sync_string = tr("6 months"); break; + case 365: sync_string = tr("1 year"); break; + case 0: sync_string = tr("indefinitly"); break; + default: + sync_string = tr("Unknown"); + } + + if(group.mMeta.mLastPost + rsPosted->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + sync_string += " (Warning: will not allow latest posts to sync)"; + + ui->syncPeriodLabel->setText(sync_string); + + QString formatDescription = QString::fromUtf8(group.mDescription.c_str()); unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 11c6bd63f..c78c7d347 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -47,18 +47,6 @@ - - - - - 14 - - - - TextLabel - - - @@ -127,26 +115,6 @@ - - - - - 75 - true - - - - 0 - - - - - - - unknown - - - @@ -169,16 +137,23 @@ - - - - - 75 - true - + + + + Qt::Horizontal + + + 40 + 20 + + + + + + - Created + unknown @@ -195,33 +170,7 @@ - - - - unknown - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Posts - - - - + @@ -234,18 +183,15 @@ - - + + unknown - - true - - - + + 75 @@ -253,7 +199,7 @@ - Popularity + Distribution: @@ -276,8 +222,8 @@ - - + + 75 @@ -285,29 +231,103 @@ - Distribution: + 0 - - + + + + + 75 + true + + - unknown + Created - - - - Qt::Horizontal + + + + + 14 + - - - 40 - 20 - + + TextLabel - + + + + + + unknown + + + + + + + + 75 + true + + + + Popularity + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Posts + + + + + + + unknown + + + true + + + + + + + + 75 + true + + + + Sync period: + + + + + + + unknown + + @@ -320,7 +340,7 @@ <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</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> diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 14c903d56..7f1c56f55 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -388,7 +388,7 @@ void GxsGroupFrameDialog::removeAllSearches() // Same function than the one in rsgxsnetservice.cc, so that all times are automatically consistent -static uint32_t checkDelay(uint32_t time_in_secs) +uint32_t GxsGroupFrameDialog::checkDelay(uint32_t time_in_secs) { if(time_in_secs < 1 * 86400) return 0 ; diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index eaf1d0d34..e03bd0038 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -82,6 +82,8 @@ public: void getServiceStatistics(GxsServiceStatistic& stats) const ; + static uint32_t checkDelay(uint32_t time_in_secs); + protected: virtual void showEvent(QShowEvent *event) override; virtual void paintEvent(QPaintEvent *pe) override; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index c0c6cb327..390b44f05 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -29,6 +29,7 @@ #include "ui_GxsChannelPostsWidgetWithModel.h" #include "gui/feeds/GxsChannelPostItem.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/gxs/GxsGroupFrameDialog.h" #include "util/misc.h" #include "gui/gxschannels/CreateGxsChannelMsg.h" #include "gui/common/UIStateHelper.h" @@ -429,7 +430,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->filterLineEdit->setPlaceholderText(tr("Search...")); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); - ui->postsTree->setPlaceholderText(tr("Thumbnails")); + ui->postsTree->setPlaceholderText(tr("No posts available in this channel")); ui->postsTree->setMinimumWidth(COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font()).height()+1); connect(ui->postsTree,SIGNAL(sizeChanged(QSize)),this,SLOT(handlePostsTreeSizeChange(QSize))); @@ -702,7 +703,8 @@ void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptrmChannelGroupId == groupId()) updateDisplay(true); } @@ -1067,6 +1069,29 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou ui->infoLastPost->setText(tr("Never")); else ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost)); + + uint32_t current_sync_time = GxsGroupFrameDialog::checkDelay(rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId))/86400 ; + + QString sync_string; + switch(current_sync_time) + { + case 5: sync_string = tr("5 days"); break; + case 15: sync_string = tr("2 weeks"); break; + case 30: sync_string = tr("1 month"); break; + case 90: sync_string = tr("3 months"); break; + case 180: sync_string = tr("6 months"); break; + case 365: sync_string = tr("1 year"); break; + case 0: sync_string = tr("indefinitly"); break; + default: + sync_string = tr("Unknown"); + } + + if(group.mMeta.mLastPost + rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + sync_string += " (Warning: will not allow latest posts to sync)"; + + ui->infoSyncTimeLabel->setText(sync_string); + + QString formatDescription = QString::fromUtf8(group.mDescription.c_str()); unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index e9dec30c6..1733da68d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -181,7 +181,7 @@ - 1 + 0 @@ -219,7 +219,27 @@ - + + + + + 75 + true + + + + Distribution: + + + + + + + 0 + + + + unknown @@ -229,6 +249,20 @@ + + + + unknown + + + + + + + unknown + + + @@ -248,14 +282,7 @@ - - - - unknown - - - - + @@ -268,53 +295,6 @@ - - - - unknown - - - - - - - - 75 - true - - - - Distribution: - - - - - - - - 75 - true - - - - Created: - - - - - - - 0 - - - - - - - unknown - - - @@ -337,6 +317,46 @@ + + + + unknown + + + + + + + + 75 + true + + + + Created: + + + + + + + + 75 + true + + + + Sync period: + + + + + + + unknown + + + diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 0d6a0ff31..3a2d8487e 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -383,7 +383,8 @@ void GxsForumThreadWidget::handleEvent_main_thread(std::shared_ptrmForumGroupId == mForumGroup.mMeta.mGroupId) + case RsForumEventCode::SYNC_PARAMETERS_UPDATED: + if(e->mForumGroupId == mForumGroup.mMeta.mGroupId) updateDisplay(true); break; default: break; From d086975d54bbae7578a5b696da811cf1efb8aeac Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 24 Oct 2020 21:40:36 +0200 Subject: [PATCH 12/16] hide/show sync parameters if group is subscribed or not --- .../gui/Posted/PostedListWidgetWithModel.cpp | 5 ++++- .../gui/Posted/PostedListWidgetWithModel.ui | 4 ++-- .../src/gui/gxs/GxsGroupFrameDialog.cpp | 2 ++ .../GxsChannelPostsWidgetWithModel.cpp | 18 ++++++++++++------ .../GxsChannelPostsWidgetWithModel.ui | 2 +- .../src/gui/gxsforums/GxsForumThreadWidget.cpp | 7 +++++-- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index a7d39d9cf..93d59a28e 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -844,7 +844,10 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); ui->subscribeToolButton->setEnabled(true); - RetroShareLink link; + ui->syncPeriodLabel->setVisible(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); + ui->syncPeriodTitleLabel->setVisible(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); + + RetroShareLink link; if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) ui->subscribeToolButton->setText(tr("Subscribed") + " " + QString::number(group.mMeta.mPop) ); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index c78c7d347..2ddaa06eb 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -310,7 +310,7 @@ - + 75 @@ -622,8 +622,8 @@ p, li { white-space: pre-wrap; } - + diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 7f1c56f55..a1bfc51e0 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -485,6 +485,7 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_sync_time ==365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + ctxMenu2->setEnabled(isSubscribed); ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ; actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} @@ -494,6 +495,7 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_store_time ==365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + ctxMenu2->setEnabled(isSubscribed); if (shareKeyType()) { action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SHARE), tr("Share publish permissions..."), this, SLOT(sharePublishKey())); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 390b44f05..7fbbf2eed 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -384,17 +384,17 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->channelPostFiles_TV->setItemDelegate(new ChannelPostFilesDelegate()); ui->channelPostFiles_TV->setPlaceholderText(tr("No files in this post, or no post selected")); ui->channelPostFiles_TV->setSortingEnabled(true); - ui->channelPostFiles_TV->sortByColumn(0, Qt::AscendingOrder); + ui->channelPostFiles_TV->sortByColumn(3, Qt::AscendingOrder); // sort by time ui->channelPostFiles_TV->setAlternatingRowColors(false); + 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))); + ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel()); ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate()); ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected")); ui->channelFiles_TV->setSortingEnabled(true); - ui->channelFiles_TV->sortByColumn(0, Qt::AscendingOrder); - - 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))); + ui->channelFiles_TV->sortByColumn(3, Qt::AscendingOrder); // sort by time connect(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails())); connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&))); @@ -1054,12 +1054,18 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou ui->channel_TW->setTabEnabled(CHANNEL_TABS_POSTS,true); ui->channel_TW->setTabEnabled(CHANNEL_TABS_FILES,true); ui->details_TW->setEnabled(true); - } + + ui->infoSyncTimeLabel->show(); + ui->syncPeriodTitleLabel->show(); + } else { ui->details_TW->setEnabled(false); ui->channel_TW->setTabEnabled(CHANNEL_TABS_POSTS,false); ui->channel_TW->setTabEnabled(CHANNEL_TABS_FILES,false); + + ui->infoSyncTimeLabel->hide(); + ui->syncPeriodTitleLabel->hide(); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index 1733da68d..a1daef1af 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -338,7 +338,7 @@ - + 75 diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 3a2d8487e..d48a4d62d 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -1049,8 +1049,11 @@ void GxsForumThreadWidget::updateForumDescription(bool success) else forum_description += QString("%1: \t%2
").arg(tr("Last post")).arg(DateTime::formatLongDateTime(group.mMeta.mLastPost)); - forum_description += QString("%1: \t%2
").arg(tr("Synchronization")).arg(getDurationString( rsGxsForums->getSyncPeriod(group.mMeta.mGroupId)/86400 )) ; - forum_description += QString("%1: \t%2
").arg(tr("Storage")).arg(getDurationString( rsGxsForums->getStoragePeriod(group.mMeta.mGroupId)/86400)); + if(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + { + forum_description += QString("%1: \t%2
").arg(tr("Synchronization")).arg(getDurationString( rsGxsForums->getSyncPeriod(group.mMeta.mGroupId)/86400 )) ; + forum_description += QString("%1: \t%2
").arg(tr("Storage")).arg(getDurationString( rsGxsForums->getStoragePeriod(group.mMeta.mGroupId)/86400)); + } QString distrib_string = tr("[unknown]"); switch(group.mMeta.mCircleType) From 74edefcc4344ca9bd265f543b0f51ee6f2487b58 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 25 Oct 2020 22:47:48 +0100 Subject: [PATCH 13/16] added infrastructure to track oingoing distant GXS group requests --- libretroshare/src/gxs/rsgenexchange.cc | 4 + libretroshare/src/gxs/rsgenexchange.h | 39 ++++++---- libretroshare/src/gxs/rsgxsnetservice.cc | 18 +++++ libretroshare/src/gxs/rsgxsnetservice.h | 74 ++++++++++--------- libretroshare/src/gxs/rsnxs.h | 8 ++ libretroshare/src/retroshare/rsgxschannels.h | 12 ++- libretroshare/src/retroshare/rsgxsiface.h | 8 ++ libretroshare/src/services/p3gxschannels.cc | 4 + libretroshare/src/services/p3gxschannels.h | 1 + .../GxsChannelPostsWidgetWithModel.cpp | 23 +++++- .../GxsChannelPostsWidgetWithModel.h | 8 +- 11 files changed, 139 insertions(+), 60 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index e05ea4fc0..96a812b51 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -3445,6 +3445,10 @@ void RsGenExchange::removeDeleteExistingMessages( std::list& msgs, Gx } } +DistantSearchGroupStatus RsGenExchange::getDistantSearchStatus(const RsGxsGroupId& group_id) +{ + return mNetService->getDistantSearchStatus(group_id) ; +} void RsGenExchange::turtleGroupRequest(const RsGxsGroupId& group_id) { mNetService->turtleGroupRequest(group_id) ; diff --git a/libretroshare/src/gxs/rsgenexchange.h b/libretroshare/src/gxs/rsgenexchange.h index 5b18e5663..a72562391 100644 --- a/libretroshare/src/gxs/rsgenexchange.h +++ b/libretroshare/src/gxs/rsgenexchange.h @@ -222,7 +222,7 @@ public: * @param msgIds a map of RsGxsGrpMsgIdPair -> msgList (vector) * @return false if could not redeem token */ - bool getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult& msgIds); + bool getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult& msgIds)override; /*! @@ -231,14 +231,14 @@ public: * @param groupInfo * @return false if could not redeem token */ - bool getGroupMeta(const uint32_t &token, std::list& groupInfo); + bool getGroupMeta(const uint32_t &token, std::list& groupInfo)override; /*! * retrieves message meta data associated to a request token * @param token token to be redeemed * @param msgInfo the meta data to be retrieved for token store here */ - bool getMsgMeta(const uint32_t &token, GxsMsgMetaMap &msgInfo); + bool getMsgMeta(const uint32_t &token, GxsMsgMetaMap &msgInfo)override; /*! * Retrieve msg meta for a given token for message related info @@ -246,7 +246,7 @@ public: * @param msgIds a map of RsGxsGrpMsgIdPair -> msgList (vector) * @return false if could not redeem token */ - bool getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMap& msgMeta); + bool getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMap& msgMeta)override; /*! * Retrieves the meta data of a newly created group. The meta is kept in cache for the current session. @@ -294,7 +294,7 @@ public: */ virtual bool acceptNewMessage(const RsGxsMsgMetaData *msgMeta, uint32_t size) ; - bool subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe); + bool subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe) override; /*! * Gets service statistic for a given services @@ -302,7 +302,7 @@ public: * @param stats the status * @return true if token exists false otherwise */ - bool getServiceStatistic(const uint32_t& token, GxsServiceStatistic& stats); + bool getServiceStatistic(const uint32_t& token, GxsServiceStatistic& stats) override; /*! * Get group statistic @@ -310,7 +310,7 @@ public: * @param stats the stats associated to token requ * @return true if token is false otherwise */ - bool getGroupStatistic(const uint32_t& token, GxsGroupStatistic& stats); + bool getGroupStatistic(const uint32_t& token, GxsGroupStatistic& stats) override; /*! * \brief turtleGroupRequest @@ -321,7 +321,14 @@ public: void turtleGroupRequest(const RsGxsGroupId& group_id); void turtleSearchRequest(const std::string& match_string); - /** + /*! + * \brief getDistantSearchStatus + * Returns the status of ongoing search: unknown (probably not even searched), known as a search result, + * data request ongoing and data available + */ + DistantSearchGroupStatus getDistantSearchStatus(const RsGxsGroupId& group_id) ; + + /** * @brief Search local groups. Blocking API. * @param matchString string to look for in the search * @param results storage for results @@ -720,21 +727,21 @@ public: * \brief getDefaultStoragePeriod. All times in seconds. * \return */ - virtual uint32_t getDefaultStoragePeriod() { return mNetService->getDefaultKeepAge() ; } + virtual uint32_t getDefaultStoragePeriod() override{ return mNetService->getDefaultKeepAge() ; } - virtual uint32_t getStoragePeriod(const RsGxsGroupId& grpId) ; - virtual void setStoragePeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) ; + virtual uint32_t getStoragePeriod(const RsGxsGroupId& grpId) override; + virtual void setStoragePeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) override; - virtual uint32_t getDefaultSyncPeriod(); - virtual uint32_t getSyncPeriod(const RsGxsGroupId& grpId) ; - virtual void setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) ; - virtual bool getGroupNetworkStats(const RsGxsGroupId& grpId,RsGroupNetworkStats& stats); + virtual uint32_t getDefaultSyncPeriod()override; + virtual uint32_t getSyncPeriod(const RsGxsGroupId& grpId) override; + virtual void setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) override; + virtual bool getGroupNetworkStats(const RsGxsGroupId& grpId,RsGroupNetworkStats& stats); uint16_t serviceType() const override { return mServType ; } uint32_t serviceFullType() const { return RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(mServType); } virtual RsReputationLevel minReputationForForwardingMessages( - uint32_t group_sign_flags, uint32_t identity_flags ); + uint32_t group_sign_flags, uint32_t identity_flags )override; protected: /** Notifications **/ diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index e46b7efee..740c1d2ab 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -5158,6 +5158,20 @@ bool RsGxsNetService::locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid) return true; } +DistantSearchGroupStatus RsGxsNetService::getDistantSearchStatus(const RsGxsGroupId& group_id) +{ + auto it = mSearchedGroups.find(group_id); + + if(it != mSearchedGroups.end()) + return it->second.status; + + for(auto it2:mDistantSearchResults) + if(it2.second.find(group_id) != it2.second.end()) + return DistantSearchGroupStatus::CAN_BE_REQUESTED; + + return DistantSearchGroupStatus::UNKNOWN; +} + TurtleRequestId RsGxsNetService::turtleGroupRequest(const RsGxsGroupId& group_id) { RS_STACK_MUTEX(mNxsMutex) ; @@ -5180,6 +5194,7 @@ TurtleRequestId RsGxsNetService::turtleGroupRequest(const RsGxsGroupId& group_id rec.request_id = req; rec.ts = now; + rec.status = DistantSearchGroupStatus::ONGOING_REQUEST; mSearchRequests[req] = group_id; @@ -5364,6 +5379,9 @@ void RsGxsNetService::receiveTurtleSearchResults(TurtleRequestId req,const unsig } std::vector new_grps(1,nxs_grp); + GroupRequestRecord& rec(mSearchedGroups[nxs_grp->grpId]) ; + rec.status = DistantSearchGroupStatus::HAVE_GROUP_DATA; + #ifdef NXS_NET_DEBUG_8 GXSNETDEBUG___ << " passing the grp data to observer." << std::endl; #endif diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 78f384e42..9322811fc 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -57,10 +57,11 @@ class RsGroupNetworkStatsRecord struct GroupRequestRecord { - GroupRequestRecord(): ts(0), request_id(0) {} + GroupRequestRecord(): ts(0),request_id(0),status(DistantSearchGroupStatus::UNKNOWN) {} rstime_t ts ; TurtleRequestId request_id; + DistantSearchGroupStatus status; }; /*! @@ -102,47 +103,48 @@ public: virtual ~RsGxsNetService(); - virtual RsServiceInfo getServiceInfo() { return mServiceInfo; } + virtual RsServiceInfo getServiceInfo() override { return mServiceInfo; } - virtual void getItemNames(std::map& names) const ; + virtual void getItemNames(std::map& names) const override ; public: - virtual uint16_t serviceType() const { return mServType ; } + virtual uint16_t serviceType() const override { return mServType ; } /*! * Use this to set how far back synchronisation and storage of messages should take place * @param age the max age a sync/storage item can to be allowed in a synchronisation */ - virtual void setSyncAge(const RsGxsGroupId& grpId,uint32_t age_in_secs); - virtual void setKeepAge(const RsGxsGroupId& grpId,uint32_t age_in_secs); + virtual void setSyncAge(const RsGxsGroupId& grpId,uint32_t age_in_secs)override ; + virtual void setKeepAge(const RsGxsGroupId& grpId,uint32_t age_in_secs)override ; - virtual uint32_t getSyncAge(const RsGxsGroupId& id); - virtual uint32_t getKeepAge(const RsGxsGroupId& id); + virtual uint32_t getSyncAge(const RsGxsGroupId& id)override ; + virtual uint32_t getKeepAge(const RsGxsGroupId& id)override ; - virtual uint32_t getDefaultSyncAge() { return mDefaultMsgSyncPeriod ; } - virtual uint32_t getDefaultKeepAge() { return mDefaultMsgStorePeriod ; } + virtual uint32_t getDefaultSyncAge() override { return mDefaultMsgSyncPeriod ; } + virtual uint32_t getDefaultKeepAge() override { return mDefaultMsgStorePeriod ; } - virtual void setDefaultKeepAge(uint32_t t) { mDefaultMsgStorePeriod = t ; } - virtual void setDefaultSyncAge(uint32_t t) { mDefaultMsgSyncPeriod = t ; } + virtual void setDefaultKeepAge(uint32_t t) override { mDefaultMsgStorePeriod = t ; } + virtual void setDefaultSyncAge(uint32_t t) override { mDefaultMsgSyncPeriod = t ; } /*! * \brief Search methods. * These four methods are used to request distant search and receive the results. * \param group_id */ - virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id); - virtual TurtleRequestId turtleSearchRequest(const std::string& match_string); + virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)override ; + virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)override ; - virtual bool search(const std::string& substring,std::list& group_infos) ; - virtual bool search(const Sha1CheckSum& hashed_group_id,unsigned char *& encrypted_group_data,uint32_t& encrypted_group_data_len); - virtual void receiveTurtleSearchResults(TurtleRequestId req,const std::list& group_infos); - virtual void receiveTurtleSearchResults(TurtleRequestId req,const unsigned char *encrypted_group_data,uint32_t encrypted_group_data_len); + virtual bool search(const std::string& substring,std::list& group_infos) override ; + virtual bool search(const Sha1CheckSum& hashed_group_id,unsigned char *& encrypted_group_data,uint32_t& encrypted_group_data_len)override ; + virtual void receiveTurtleSearchResults(TurtleRequestId req,const std::list& group_infos)override ; + virtual void receiveTurtleSearchResults(TurtleRequestId req,const unsigned char *encrypted_group_data,uint32_t encrypted_group_data_len)override ; - virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map &group_infos); - virtual bool clearDistantSearchResults(const TurtleRequestId& id); - virtual bool retrieveDistantGroupSummary(const RsGxsGroupId&, RsGxsGroupSearchResults &); + virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map &group_infos)override ; + virtual bool clearDistantSearchResults(const TurtleRequestId& id)override ; + virtual bool retrieveDistantGroupSummary(const RsGxsGroupId&, RsGxsGroupSearchResults &)override ; + virtual DistantSearchGroupStatus getDistantSearchStatus(const RsGxsGroupId&) override ; /*! * pauses synchronisation of subscribed groups and request for group id @@ -150,7 +152,7 @@ public: * @param enabled set to false to disable pause, and true otherwise */ // NOT IMPLEMENTED - virtual void pauseSynchronisation(bool enabled); + virtual void pauseSynchronisation(bool enabled)override ; /*! @@ -159,7 +161,7 @@ public: * @param msgId the messages to retrieve * @return request token to be redeemed */ - virtual int requestMsg(const RsGxsGrpMsgIdPair& /* msgId */){ return 0;} + virtual int requestMsg(const RsGxsGrpMsgIdPair& /* msgId */)override { return 0;} /*! * Request for this group is sent through to peers on your network @@ -167,46 +169,46 @@ public: * @param enabled set to false to disable pause, and true otherwise * @return request token to be redeemed */ - virtual int requestGrp(const std::list& grpId, const RsPeerId& peerId); + virtual int requestGrp(const std::list& grpId, const RsPeerId& peerId)override ; /*! * share publish keys for the specified group with the peers in the specified list. */ - virtual int sharePublishKey(const RsGxsGroupId& grpId,const std::set& peers) ; + virtual int sharePublishKey(const RsGxsGroupId& grpId,const std::set& peers) override ; /*! * Returns statistics for the group networking activity: popularity (number of friends subscribers) and max_visible_msg_count, * that is the max nnumber of messages reported by a friend. */ - virtual bool getGroupNetworkStats(const RsGxsGroupId& id,RsGroupNetworkStats& stats) ; + virtual bool getGroupNetworkStats(const RsGxsGroupId& id,RsGroupNetworkStats& stats) override ; /*! * Used to inform the net service that we changed subscription status. That helps * optimising data transfer when e.g. unsubsribed groups are updated less often, etc */ - virtual void subscribeStatusChanged(const RsGxsGroupId& id,bool subscribed) ; + virtual void subscribeStatusChanged(const RsGxsGroupId& id,bool subscribed) override ; - virtual void rejectMessage(const RsGxsMessageId& msg_id) ; + virtual void rejectMessage(const RsGxsMessageId& msg_id) override ; - virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) ; - virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) ; - virtual bool removeGroups(const std::list& groups); - virtual bool isDistantPeer(const RsPeerId& pid); + virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) override ; + virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) override ; + virtual bool removeGroups(const std::list& groups)override ; + virtual bool isDistantPeer(const RsPeerId& pid)override ; /* p3Config methods */ public: - bool loadList(std::list& load); - bool saveList(bool &cleanup, std::list&); - RsSerialiser *setupSerialiser(); + bool loadList(std::list& load)override ; + bool saveList(bool &cleanup, std::list&)override ; + RsSerialiser *setupSerialiser()override ; public: /*! * initiates synchronisation */ - int tick(); + int tick()override ; void threadTick() override; /// @see RsTickingThread diff --git a/libretroshare/src/gxs/rsnxs.h b/libretroshare/src/gxs/rsnxs.h index 7276f3421..ea12e146a 100644 --- a/libretroshare/src/gxs/rsnxs.h +++ b/libretroshare/src/gxs/rsnxs.h @@ -141,6 +141,14 @@ public: virtual bool search(const std::string& substring,std::list& group_infos) =0; virtual bool search(const Sha1CheckSum& hashed_group_id,unsigned char *& encrypted_group_data,uint32_t& encrypted_group_data_len)=0; + /*! + * \brief getDistantSearchStatus + * Request status of a possibly ongoing/finished search. If UNKNOWN is returned, it means that no + * such group is under request + * \return + */ + virtual DistantSearchGroupStatus getDistantSearchStatus(const RsGxsGroupId&) =0; + /*! * Initiates a search through the network * This returns messages which contains the search terms set in RsGxsSearch diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index b7ec8ee7f..7c91f41cd 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -519,10 +519,16 @@ public: * @param[out] distantGroup storage for group data * @return false on error, true otherwise */ - virtual bool getDistantSearchResultGroupData( - const RsGxsGroupId& groupId, RsGxsChannelGroup& distantGroup ) = 0; + virtual bool getDistantSearchResultGroupData(const RsGxsGroupId& groupId, RsGxsChannelGroup& distantGroup ) = 0; - /** + /** + * @brief getDistantSearchStatus + * Returns the status of ongoing search: unknown (probably not even searched), known as a search result, + * data request ongoing and data available + */ + virtual DistantSearchGroupStatus getDistantSearchStatus(const RsGxsGroupId& group_id) =0; + + /** * @brief Clear accumulated search results * @jsonapi{development} * @param[in] reqId search id diff --git a/libretroshare/src/retroshare/rsgxsiface.h b/libretroshare/src/retroshare/rsgxsiface.h index 74e67008f..ce64bf4ed 100644 --- a/libretroshare/src/retroshare/rsgxsiface.h +++ b/libretroshare/src/retroshare/rsgxsiface.h @@ -145,6 +145,14 @@ struct RsGxsChanges : RsEvent RsTokenService* mService; /// Weak pointer, not serialized }; +enum class DistantSearchGroupStatus:uint8_t +{ + UNKNOWN = 0x00, // no search ongoing for this group + CAN_BE_REQUESTED = 0x01, // a search result mentions this group, so the group data can be requested + ONGOING_REQUEST = 0x02, // the group data has been requested and the request is pending + HAVE_GROUP_DATA = 0x03, // group data has been received. Group can be subscribed. +}; + /*! * All implementations must offer thread safety */ diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index a3117c8a4..839dd4b5a 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -2423,6 +2423,10 @@ bool p3GxsChannels::retrieveDistantSearchResults(TurtleRequestId req,std::mapretrieveDistantSearchResults(req,results); } +DistantSearchGroupStatus p3GxsChannels::getDistantSearchStatus(const RsGxsGroupId& group_id) +{ + return netService()->getDistantSearchStatus(group_id); +} bool p3GxsChannels::getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group) { RsGxsGroupSearchResults gs; diff --git a/libretroshare/src/services/p3gxschannels.h b/libretroshare/src/services/p3gxschannels.h index da274690b..5ab1d414c 100644 --- a/libretroshare/src/services/p3gxschannels.h +++ b/libretroshare/src/services/p3gxschannels.h @@ -71,6 +71,7 @@ protected: virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map &results) ; virtual bool clearDistantSearchResults(TurtleRequestId req); virtual bool getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group); + virtual DistantSearchGroupStatus getDistantSearchStatus(const RsGxsGroupId& group_id) ; // Overloaded to cache new groups. virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 7fbbf2eed..3ae3c380c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -1158,7 +1158,28 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou //ui->feedToolButton->setEnabled(false); //ui->fileToolButton->setEnabled(false); #endif - ui->subscribeToolButton->setText(tr("Subscribe ") + " " + QString::number(group.mMeta.mPop) ); + + if(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + ui->subscribeToolButton->setText(tr("Unsubscribe")); + else + { + switch(rsGxsChannels->getDistantSearchStatus(group.mMeta.mGroupId)) + { + case DistantSearchGroupStatus::UNKNOWN: // means no search ongoing. This is not a distant search + case DistantSearchGroupStatus::HAVE_GROUP_DATA: // fallthrough + ui->subscribeToolButton->setText(tr("Subscribe")); + ui->subscribeToolButton->setToolTip(""); + break; + case DistantSearchGroupStatus::CAN_BE_REQUESTED: // means no search ongoing. This is not a distant search + ui->subscribeToolButton->setText(tr("Request data")); + ui->subscribeToolButton->setToolTip(tr("Hit this button to retrieve the data you need to subscribe to this channel") ); + break; + case DistantSearchGroupStatus::ONGOING_REQUEST: + ui->subscribeToolButton->setText(tr("Ongoing request...")); + ui->subscribeToolButton->setToolTip(""); + break; + } + } showPostDetails(); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index ed7bd66f3..579f83a92 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -103,8 +103,8 @@ public: ~GxsChannelPostsWidgetWithModel(); /* GxsMessageFrameWidget */ - virtual QIcon groupIcon(); - virtual void groupIdChanged() { updateDisplay(true); } + virtual QIcon groupIcon() override; + virtual void groupIdChanged() override { updateDisplay(true); } virtual QString groupName(bool) override; virtual bool navigate(const RsGxsMessageId&) override; @@ -126,7 +126,7 @@ protected: virtual bool insertGroupData(const RsGxsGenericGroupData *data) override; #endif virtual bool useThread() { return mUseThread; } - virtual void blank() ; + virtual void blank() override ; #ifdef TODO virtual bool getGroupData(RsGxsGenericGroupData *& data) override; @@ -137,7 +137,7 @@ protected: #endif /* GxsMessageFrameWidget */ - virtual void setAllMessagesReadDo(bool read, uint32_t &token); + virtual void setAllMessagesReadDo(bool read, uint32_t &token) override; private slots: void showPostDetails(); From 874e095ee87996e0e80c256f9bc00a55c79b2afb Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 26 Oct 2020 18:49:38 +0100 Subject: [PATCH 14/16] set comments scroll mode to continuous --- retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index 60a9476a3..ea65cfff7 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -141,6 +141,7 @@ GxsCommentTreeWidget::GxsCommentTreeWidget(QWidget *parent) { // QTreeWidget* widget = this; + setVerticalScrollMode(ScrollPerPixel); setContextMenuPolicy(Qt::CustomContextMenu); RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); itemDelegate->setSpacing(QSize(0, 2)); From b74e6dbe42e82322fbf717dbe2eb261988639635 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 26 Oct 2020 20:46:50 +0100 Subject: [PATCH 15/16] removed misplaced auto-download from subscribe button, and enable/disable subscribe for distant search results --- .../GxsChannelPostsWidgetWithModel.cpp | 48 +++++++++++++------ .../GxsChannelPostsWidgetWithModel.h | 8 ++-- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 3ae3c380c..1e0c676b7 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -455,16 +455,19 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI QIcon icon; icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/redled.png"), QIcon::Normal, QIcon::On); icon.addPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/start.png"), QIcon::Normal, QIcon::Off); + +#ifdef TO_REMOVE mAutoDownloadAction = new QAction(icon, "", this); mAutoDownloadAction->setCheckable(true); connect(mAutoDownloadAction, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); ui->subscribeToolButton->addSubscribedAction(mAutoDownloadAction); + setAutoDownload(false); +#endif ui->commentsDialog->setTokenService(rsGxsChannels->getTokenService(),rsGxsChannels); /* Initialize GUI */ - setAutoDownload(false); settingsChanged(); setGroupId(channelId); @@ -925,7 +928,7 @@ GxsChannelPostsWidgetWithModel::~GxsChannelPostsWidgetWithModel() // save settings processSettings(false); - delete(mAutoDownloadAction); + //delete(mAutoDownloadAction); delete mFilesDelegate; delete ui; } @@ -1039,18 +1042,16 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou ui->postButton->setEnabled(bool(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)); - ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); - ui->subscribeToolButton->setEnabled(true); - +#ifdef TO_REMOVE bool autoDownload ; rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload); setAutoDownload(autoDownload); +#endif - if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + setSubscribeButtonText(group.mMeta.mGroupId,group.mMeta.mSubscribeFlags); + + if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) { - ui->subscribeToolButton->setText(tr("Subscribed") + " " + QString::number(group.mMeta.mPop) ); - //ui->feedToolButton->setEnabled(true); - //ui->fileToolButton->setEnabled(true); ui->channel_TW->setTabEnabled(CHANNEL_TABS_POSTS,true); ui->channel_TW->setTabEnabled(CHANNEL_TABS_FILES,true); ui->details_TW->setEnabled(true); @@ -1159,29 +1160,44 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou //ui->fileToolButton->setEnabled(false); #endif - if(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + setSubscribeButtonText(group.mMeta.mGroupId,group.mMeta.mSubscribeFlags); + + showPostDetails(); +} + +void GxsChannelPostsWidgetWithModel::setSubscribeButtonText(const RsGxsGroupId& group_id,uint32_t flags) +{ + if(IS_GROUP_SUBSCRIBED(flags)) + { ui->subscribeToolButton->setText(tr("Unsubscribe")); + ui->subscribeToolButton->setSubscribed(true); + ui->subscribeToolButton->setEnabled(true); + } else { - switch(rsGxsChannels->getDistantSearchStatus(group.mMeta.mGroupId)) + switch(rsGxsChannels->getDistantSearchStatus(group_id)) { case DistantSearchGroupStatus::UNKNOWN: // means no search ongoing. This is not a distant search case DistantSearchGroupStatus::HAVE_GROUP_DATA: // fallthrough ui->subscribeToolButton->setText(tr("Subscribe")); ui->subscribeToolButton->setToolTip(""); + ui->subscribeToolButton->setSubscribed(false); + ui->subscribeToolButton->setEnabled(true); break; case DistantSearchGroupStatus::CAN_BE_REQUESTED: // means no search ongoing. This is not a distant search ui->subscribeToolButton->setText(tr("Request data")); ui->subscribeToolButton->setToolTip(tr("Hit this button to retrieve the data you need to subscribe to this channel") ); + ui->subscribeToolButton->setSubscribed(false); + ui->subscribeToolButton->setEnabled(false); break; case DistantSearchGroupStatus::ONGOING_REQUEST: ui->subscribeToolButton->setText(tr("Ongoing request...")); ui->subscribeToolButton->setToolTip(""); + ui->subscribeToolButton->setSubscribed(true); + ui->subscribeToolButton->setEnabled(false); break; } } - - showPostDetails(); } void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool) @@ -1254,10 +1270,11 @@ void GxsChannelPostsWidgetWithModel::subscribeGroup(bool subscribe) } ); } +#ifdef TO_REMOVE void GxsChannelPostsWidgetWithModel::setAutoDownload(bool autoDl) { - mAutoDownloadAction->setChecked(autoDl); - mAutoDownloadAction->setText(autoDl ? tr("Disable Auto-Download") : tr("Enable Auto-Download")); + mAutoDownloadAction->setChecked(autoDl); + mAutoDownloadAction->setText(autoDl ? tr("Disable Auto-Download") : tr("Enable Auto-Download")); } void GxsChannelPostsWidgetWithModel::toggleAutoDownload() @@ -1285,6 +1302,7 @@ void GxsChannelPostsWidgetWithModel::toggleAutoDownload() } }); } +#endif class GxsChannelPostsReadData { diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 579f83a92..2e50c77d6 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -144,7 +144,7 @@ private slots: void updateGroupData(); void download(); void createMsg(); - void toggleAutoDownload(); +// void toggleAutoDownload(); void subscribeGroup(bool subscribe); void filterChanged(QString); void settingsChanged(); @@ -168,14 +168,16 @@ private: RsGxsMessageId getCurrentItemId() const; void selectItem(const RsGxsMessageId& msg_id); - void setAutoDownload(bool autoDl); +// void setAutoDownload(bool autoDl); static bool filterItem(FeedItem *feedItem, const QString &text, int filter); void insertChannelDetails(const RsGxsChannelGroup &group); void handleEvent_main_thread(std::shared_ptr event); private: - QAction *mAutoDownloadAction; + void setSubscribeButtonText(const RsGxsGroupId& group_id,uint32_t flags); + +// QAction *mAutoDownloadAction; RsGxsChannelGroup mGroup; bool mUseThread; From b5cfa46073907eb41a3db009ee8fb50c5765d35e Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 28 Oct 2020 21:26:07 +0100 Subject: [PATCH 16/16] fixed missed notification in Messages when new/draft msg happens by switching to new event system --- libretroshare/src/services/p3msgservice.cc | 17 +++++++++--- .../gui/Posted/PostedListWidgetWithModel.cpp | 2 +- .../GxsChannelPostsWidgetWithModel.cpp | 6 ++--- .../src/gui/msgs/MessageComposer.cpp | 2 +- .../src/gui/msgs/MessagesDialog.cpp | 26 +++++++++++++++++++ retroshare-gui/src/gui/msgs/MessagesDialog.h | 5 ++++ 6 files changed, 49 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 83c1c8e88..32f1394f1 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -1122,7 +1122,7 @@ uint32_t p3MsgService::sendMessage(RsMsgItem* item) IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST, NOTIFY_TYPE_ADD); + RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST, NOTIFY_TYPE_ADD); // deprecated return item->msgId; } @@ -1196,10 +1196,15 @@ bool p3MsgService::MessageSend(MessageInfo &info) info.msgId = std::to_string(msg->msgId); info .msgflags = msg->msgFlags; - RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD); + RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);// deprecated. Should be removed. Oct. 28, 2020 } - return true; + auto pEvent = std::make_shared(); + pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT; + pEvent->mChangedMsgIds.insert(std::to_string(msg->msgId)); + rsEvents->postEvent(pEvent); + + return true; } uint32_t p3MsgService::sendMail( @@ -1399,7 +1404,11 @@ bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParen IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD); + // RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD); + + auto pEvent = std::make_shared(); + pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT; + rsEvents->postEvent(pEvent); return true; } diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 93d59a28e..9562453ae 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -877,7 +877,7 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) sync_string = tr("Unknown"); } - if(group.mMeta.mLastPost + rsPosted->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + if(group.mMeta.mLastPost > 0 && group.mMeta.mLastPost + rsPosted->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) sync_string += " (Warning: will not allow latest posts to sync)"; ui->syncPeriodLabel->setText(sync_string); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 1e0c676b7..e03c41c32 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -1093,7 +1093,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou sync_string = tr("Unknown"); } - if(group.mMeta.mLastPost + rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + if(group.mMeta.mLastPost > 0 && group.mMeta.mLastPost + rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) sync_string += " (Warning: will not allow latest posts to sync)"; ui->infoSyncTimeLabel->setText(sync_string); @@ -1185,13 +1185,13 @@ void GxsChannelPostsWidgetWithModel::setSubscribeButtonText(const RsGxsGroupId& ui->subscribeToolButton->setEnabled(true); break; case DistantSearchGroupStatus::CAN_BE_REQUESTED: // means no search ongoing. This is not a distant search - ui->subscribeToolButton->setText(tr("Request data")); + ui->subscribeToolButton->setText(tr("Subscribe")); ui->subscribeToolButton->setToolTip(tr("Hit this button to retrieve the data you need to subscribe to this channel") ); ui->subscribeToolButton->setSubscribed(false); ui->subscribeToolButton->setEnabled(false); break; case DistantSearchGroupStatus::ONGOING_REQUEST: - ui->subscribeToolButton->setText(tr("Ongoing request...")); + ui->subscribeToolButton->setText(tr("Subscribe")); ui->subscribeToolButton->setToolTip(""); ui->subscribeToolButton->setSubscribed(true); ui->subscribeToolButton->setEnabled(false); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index db3083686..341e87326 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -1427,7 +1427,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) break ; default: - std::cerr << __PRETTY_FUNCTION__ << ": Unhandled desitnation type " << dtype << std::endl; + std::cerr << __PRETTY_FUNCTION__ << ": Unhandled destination type " << dtype << std::endl; break ; } } diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index acb19d900..5d6788eb9 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -284,6 +284,30 @@ MessagesDialog::MessagesDialog(QWidget *parent) connect(ui.messageTreeWidget->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumn(int,Qt::SortOrder))); connect(ui.messageTreeWidget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(currentChanged(const QModelIndex&,const QModelIndex&))); + + mEventHandlerId=0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::MAIL_STATUS ); +} + +void MessagesDialog::handleEvent(std::shared_ptr event) +{ + if(event->mType != RsEventType::MAIL_STATUS) + return; + + const RsMailStatusEvent *fe = dynamic_cast(event.get()); + if(!fe) + return; + + switch (fe->mMailStatusEventCode) + { + case RsMailStatusEventCode::MESSAGE_SENT: + case RsMailStatusEventCode::MESSAGE_REMOVED: + case RsMailStatusEventCode::NEW_MESSAGE: + updateMessageSummaryList(); + break; + default: + break; + } } void MessagesDialog::preModelUpdate() @@ -836,6 +860,8 @@ void MessagesDialog::changeBox(int box_row) mMessageModel->setCurrentBox(RsMessageModel::BOX_NONE); } inChange = false; + + updateMessageSummaryList(); } void MessagesDialog::changeQuickView(int newrow) diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index bf0148cf5..df8513d18 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -23,6 +23,7 @@ #include +#include #include #include "ui_MessagesDialog.h" @@ -110,6 +111,8 @@ private slots: void tabCloseRequested(int tab); private: + void handleEvent(std::shared_ptr event); + void updateInterface(); void connectActions(); @@ -157,6 +160,8 @@ private: QList mTmpSavedSelectedIds; QModelIndex lastSelectedIndex; + + RsEventsHandlerId_t mEventHandlerId; }; #endif