mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
Fix GXS (Forum/Channel/Boards) RSLink
Have to add ID: tag in Board Filter due to range view.
This commit is contained in:
parent
af27ff5e4f
commit
68e027b227
@ -62,6 +62,8 @@
|
||||
* #define DEBUG_POSTED
|
||||
***/
|
||||
|
||||
static const int POSTED_TABS_POSTS = 1;
|
||||
|
||||
/* View mode */
|
||||
#define VIEW_MODE_FEEDS 1
|
||||
#define VIEW_MODE_FILES 2
|
||||
@ -529,8 +531,8 @@ void PostedListWidgetWithModel::showPostDetails()
|
||||
if(index.row()==0 && index.column()==0)
|
||||
std::cerr << "here" << std::endl;
|
||||
|
||||
std::cerr << "showPostDetails: setting mSelectedPost to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mSelectedPost << std::endl;
|
||||
mSelectedPost = post.mMeta.mMsgId;
|
||||
std::cerr << "showPostDetails: setting mLastSelectedPosts[groupId()] to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mLastSelectedPosts[groupId()] << std::endl;
|
||||
mLastSelectedPosts[groupId()] = post.mMeta.mMsgId;
|
||||
|
||||
std::list<ChannelPostFileInfo> files;
|
||||
for(auto& file:post.mFiles)
|
||||
@ -626,23 +628,29 @@ void PostedListWidgetWithModel::updateGroupData()
|
||||
void PostedListWidgetWithModel::postPostLoad()
|
||||
{
|
||||
std::cerr << "Post channel load..." << std::endl;
|
||||
whileBlocking(ui->filter_LE)->setText(QString()); //Clear it before navigate, as it will update it.
|
||||
|
||||
if(!mSelectedPost.isNull())
|
||||
if (!mNavigatePendingMsgId.isNull())
|
||||
navigate(mNavigatePendingMsgId);
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
else if( (mLastSelectedPosts.count(groupId()) > 0)
|
||||
&& !mLastSelectedPosts[groupId()].isNull())
|
||||
{
|
||||
QModelIndex index = mPostedPostsModel->getIndexOfMessage(mSelectedPost);
|
||||
QModelIndex index = mPostedPostsModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
|
||||
|
||||
std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post "
|
||||
<< mSelectedPost.toStdString() << std::endl;
|
||||
<< mLastSelectedPosts[groupId()].toStdString() << std::endl;
|
||||
|
||||
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
|
||||
ui->postsTree->scrollTo(index);//May change if model reloaded
|
||||
ui->postsTree->setFocus();
|
||||
}
|
||||
#endif
|
||||
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()+POSTS_CHUNK_SIZE+1)));
|
||||
whileBlocking(ui->filter_LE)->setText(QString());
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::forceRedraw()
|
||||
@ -721,7 +729,7 @@ QString PostedListWidgetWithModel::groupName(bool)
|
||||
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::groupNameChanged(const QString &name)
|
||||
void PostedListWidgetWithModel::groupNameChanged(const QString &/*name*/)
|
||||
{
|
||||
}
|
||||
|
||||
@ -737,12 +745,12 @@ QIcon PostedListWidgetWithModel::groupIcon()
|
||||
return QIcon(postedImage);
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token)
|
||||
void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &/*token*/)
|
||||
{
|
||||
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
|
||||
return;
|
||||
|
||||
QModelIndex src_index;
|
||||
//QModelIndex src_index;
|
||||
|
||||
mPostedPostsModel->setAllMsgReadStatus(read);
|
||||
|
||||
@ -1126,20 +1134,24 @@ void PostedListWidgetWithModel::blank()
|
||||
|
||||
bool PostedListWidgetWithModel::navigate(const RsGxsMessageId& msgId)
|
||||
{
|
||||
ui->filter_LE->setText("ID:" + QString::fromStdString(msgId.toStdString()));
|
||||
|
||||
QModelIndex index = mPostedPostsModel->getIndexOfMessage(msgId);
|
||||
|
||||
if(!index.isValid())
|
||||
{
|
||||
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in board " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
|
||||
|
||||
mSelectedPost = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
|
||||
mNavigatePendingMsgId = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
|
||||
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
|
||||
}
|
||||
|
||||
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
|
||||
ui->postsTree->scrollTo(index);//May change if model reloaded
|
||||
ui->postsTree->setFocus();
|
||||
|
||||
ui->tabWidget->setCurrentIndex(POSTED_TABS_POSTS);
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,9 @@ protected:
|
||||
virtual void setAllMessagesReadDo(bool read, uint32_t &token) override;
|
||||
|
||||
private slots:
|
||||
#ifdef TO_REMOVE
|
||||
void showPostDetails();
|
||||
#endif
|
||||
void showAuthorInPeople();
|
||||
void tabCloseRequested(int index);
|
||||
void updateSorting(int);
|
||||
@ -166,7 +169,10 @@ private:
|
||||
RsPostedPostsModel *mPostedPostsModel;
|
||||
PostedPostDelegate *mPostedPostsDelegate;
|
||||
|
||||
RsGxsMessageId mSelectedPost;
|
||||
#ifdef TO_REMOVE
|
||||
std::map<RsGxsGroupId,RsGxsMessageId> mLastSelectedPosts;
|
||||
#endif
|
||||
RsGxsMessageId mNavigatePendingMsgId;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::PostedListWidgetWithModel *ui;
|
||||
|
@ -166,7 +166,7 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
|
||||
if(strings.empty())
|
||||
{
|
||||
mFilteredPosts.clear();
|
||||
for(int i=0;i<mPosts.size();++i)
|
||||
for(int i=0;i<(int)(mPosts.size());++i)
|
||||
mFilteredPosts.push_back(i);
|
||||
}
|
||||
else
|
||||
@ -174,12 +174,17 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
|
||||
mFilteredPosts.clear();
|
||||
//mFilteredPosts.push_back(0);
|
||||
|
||||
for(int i=0;i<mPosts.size();++i)
|
||||
for(int i=0;i<static_cast<int>(mPosts.size());++i)
|
||||
{
|
||||
bool passes_strings = true;
|
||||
|
||||
for(auto& s:strings)
|
||||
{
|
||||
if (s.startsWith("ID:",Qt::CaseInsensitive))
|
||||
passes_strings = passes_strings && mPosts[i].mMeta.mMsgId == RsGxsMessageId(s.right(s.length() - 3).toStdString());
|
||||
else
|
||||
passes_strings = passes_strings && QString::fromStdString(mPosts[i].mMeta.mMsgName).contains(s,Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
if(passes_strings)
|
||||
mFilteredPosts.push_back(i);
|
||||
@ -333,7 +338,7 @@ quintptr RsPostedPostsModel::getParentRow(quintptr ref,int& row) const
|
||||
|
||||
int RsPostedPostsModel::getChildrenCount(quintptr ref) const
|
||||
{
|
||||
uint32_t entry = 0 ;
|
||||
//uint32_t entry = 0 ;
|
||||
|
||||
if(ref == quintptr(0))
|
||||
return rowCount()-1;
|
||||
@ -391,7 +396,7 @@ QVariant RsPostedPostsModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RsPostedPostsModel::sizeHintRole(int col) const
|
||||
QVariant RsPostedPostsModel::sizeHintRole(int /*col*/) const
|
||||
{
|
||||
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
|
||||
|
||||
@ -483,7 +488,7 @@ void RsPostedPostsModel::setSortingStrategy(RsPostedPostsModel::SortingStrategy
|
||||
|
||||
void RsPostedPostsModel::setPostsInterval(int start,int nb_posts)
|
||||
{
|
||||
if(start >= mFilteredPosts.size())
|
||||
if(start >= (int)mFilteredPosts.size())
|
||||
return;
|
||||
|
||||
preMods();
|
||||
@ -592,7 +597,7 @@ void RsPostedPostsModel::update_posts(const RsGxsGroupId& group_id)
|
||||
});
|
||||
}
|
||||
|
||||
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
|
||||
//static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
|
||||
|
||||
void RsPostedPostsModel::createPostsArray(std::vector<RsPostedPost>& posts)
|
||||
{
|
||||
@ -780,7 +785,8 @@ QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) con
|
||||
}
|
||||
#endif
|
||||
|
||||
if(mPosts[mFilteredPosts[i]].mMeta.mMsgId == postId)
|
||||
if( mFilteredPosts.size() > (size_t)(i)
|
||||
&& mPosts[mFilteredPosts[i]].mMeta.mMsgId == postId )
|
||||
{
|
||||
quintptr ref ;
|
||||
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
|
||||
|
@ -98,6 +98,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
|
||||
mStateHelper->addWidget(TOKEN_TYPE_GROUP_SUMMARY, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, true);
|
||||
|
||||
connect(ui->groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupTreeCustomPopupMenu(QPoint)));
|
||||
connect(ui->groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedCurrentGroup(QString)));
|
||||
|
@ -166,7 +166,7 @@ private:
|
||||
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &/*grpId*/, const RsGxsMessageId &/*msgId*/) { return NULL; }
|
||||
virtual bool getDistantSearchResults(TurtleRequestId /* id */, std::map<RsGxsGroupId,RsGxsGroupSearchResults>& /* group_infos */){ return false ;}
|
||||
virtual void clearDistantSearchResults(TurtleRequestId /* id */) {}
|
||||
virtual RsGxsGenericGroupData *getDistantSearchResultGroupData(const RsGxsGroupId& group_id){ return nullptr ;}
|
||||
virtual RsGxsGenericGroupData *getDistantSearchResultGroupData(const RsGxsGroupId& /*group_id*/){ return nullptr ;}
|
||||
|
||||
void initUi();
|
||||
|
||||
|
@ -774,8 +774,8 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
||||
std::cerr << "showPostDetails: current index is " << index.row() << "," << index.column() << std::endl;
|
||||
#endif
|
||||
|
||||
QTextDocument doc;
|
||||
doc.setHtml(post.mMsg.c_str());
|
||||
//QTextDocument doc;
|
||||
//doc.setHtml(post.mMsg.c_str());
|
||||
|
||||
if(post.mMeta.mPublishTs == 0)
|
||||
{
|
||||
@ -785,7 +785,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
||||
ui->postTime_LB->hide();
|
||||
mChannelPostFilesModel->clear();
|
||||
ui->details_TW->setEnabled(false);
|
||||
mSelectedPost.clear();
|
||||
//mLastSelectedPosts[groupId()].clear();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -796,9 +796,9 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
||||
ui->postTime_LB->show();
|
||||
|
||||
#ifdef DEBUG_CHANNEL_POSTS_WIDGET
|
||||
std::cerr << "showPostDetails: setting mSelectedPost to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mSelectedPost << std::endl;
|
||||
std::cerr << "showPostDetails: setting mLastSelectedPosts[groupId()] to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mLastSelectedPosts[groupId()] << std::endl;
|
||||
#endif
|
||||
mSelectedPost = post.mMeta.mMsgId;
|
||||
mLastSelectedPosts[groupId()] = post.mMeta.mMsgId;
|
||||
|
||||
std::list<ChannelPostFileInfo> files;
|
||||
for(auto& file:post.mFiles)
|
||||
@ -886,7 +886,7 @@ void GxsChannelPostsWidgetWithModel::updateGroupData()
|
||||
|
||||
RsQThreadUtils::postToObject( [this,group]()
|
||||
{
|
||||
if(mGroup.mMeta.mGroupId != group.mMeta.mGroupId) // this prevents any attempt to display the wrong index. Navigate() if needed will use mSelectedPost
|
||||
if(mGroup.mMeta.mGroupId != group.mMeta.mGroupId) // this prevents any attempt to display the wrong index. Navigate() if needed will use mNavigatePendingMsgId
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL_POSTS_WIDGET
|
||||
std::cerr << "Old group: " << mGroup.mMeta.mGroupId << ", new group: " << group.mMeta.mGroupId << ". Celaring selection" << std::endl;
|
||||
@ -913,12 +913,16 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
|
||||
{
|
||||
std::cerr << "Post channel load..." << std::endl;
|
||||
|
||||
if(!mSelectedPost.isNull())
|
||||
if (!mNavigatePendingMsgId.isNull())
|
||||
navigate(mNavigatePendingMsgId);
|
||||
|
||||
else if( (mLastSelectedPosts.count(groupId()) > 0)
|
||||
&& !mLastSelectedPosts[groupId()].isNull())
|
||||
{
|
||||
QModelIndex index = mChannelPostsModel->getIndexOfMessage(mSelectedPost);
|
||||
QModelIndex index = mChannelPostsModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
|
||||
|
||||
std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post "
|
||||
<< mSelectedPost.toStdString() << std::endl;
|
||||
<< mLastSelectedPosts[groupId()].toStdString() << std::endl;
|
||||
|
||||
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
|
||||
ui->postsTree->scrollTo(index);//May change if model reloaded
|
||||
@ -1319,7 +1323,7 @@ bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId& msgId)
|
||||
{
|
||||
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in channel " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
|
||||
|
||||
mSelectedPost = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
|
||||
mNavigatePendingMsgId = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
|
||||
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
|
||||
}
|
||||
|
||||
@ -1330,6 +1334,8 @@ bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId& msgId)
|
||||
ui->channel_TW->setCurrentIndex(CHANNEL_TABS_POSTS);
|
||||
ui->details_TW->setCurrentIndex(CHANNEL_TABS_DETAILS);
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,8 @@ private:
|
||||
ChannelPostDelegate *mChannelPostsDelegate;
|
||||
ChannelPostFilesDelegate *mFilesDelegate;
|
||||
|
||||
RsGxsMessageId mSelectedPost;
|
||||
std::map<RsGxsGroupId,RsGxsMessageId> mLastSelectedPosts;
|
||||
RsGxsMessageId mNavigatePendingMsgId;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::GxsChannelPostsWidgetWithModel *ui;
|
||||
|
Loading…
Reference in New Issue
Block a user