mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
fixed disabling of channel post comment box on resize and comment
This commit is contained in:
parent
9d4042c401
commit
f1d98913d1
@ -319,13 +319,16 @@ Qt::ItemFlags RsGxsChannelPostsModel::flags(const QModelIndex& index) const
|
|||||||
return QAbstractItemModel::flags(index);
|
return QAbstractItemModel::flags(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsChannelPostsModel::setNumColumns(int n)
|
bool RsGxsChannelPostsModel::setNumColumns(int n)
|
||||||
{
|
{
|
||||||
if(n < 1)
|
if(n < 1)
|
||||||
{
|
{
|
||||||
RsErr() << __PRETTY_FUNCTION__ << " Attempt to set a number of column of 0. This is wrong." << std::endl;
|
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();
|
preMods();
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||||
@ -337,6 +340,8 @@ void RsGxsChannelPostsModel::setNumColumns(int n)
|
|||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
quintptr RsGxsChannelPostsModel::getChildRef(quintptr ref,int index) const
|
quintptr RsGxsChannelPostsModel::getChildRef(quintptr ref,int index) const
|
||||||
|
@ -116,7 +116,9 @@ public:
|
|||||||
|
|
||||||
void triggerViewUpdate();
|
void triggerViewUpdate();
|
||||||
|
|
||||||
void setNumColumns(int n);
|
// sets the number of columns. Returns 0 if nothing changes.
|
||||||
|
bool setNumColumns(int n);
|
||||||
|
|
||||||
void setMode(TreeMode mode);
|
void setMode(TreeMode mode);
|
||||||
TreeMode getMode() const { return mTreeMode; }
|
TreeMode getMode() const { return mTreeMode; }
|
||||||
|
|
||||||
|
@ -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()))));
|
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;
|
std::cerr << "nb columns: " << n_columns << " current count=" << mChannelPostsModel->columnCount() << std::endl;
|
||||||
|
|
||||||
if(force || (n_columns != mChannelPostsModel->columnCount()))
|
// save current post. The setNumColumns() indeed loses selection
|
||||||
mChannelPostsModel->setNumColumns(n_columns);
|
|
||||||
|
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
|
||||||
|
RsGxsMessageId current_mid;
|
||||||
|
|
||||||
|
if(index.isValid())
|
||||||
|
current_mid = index.data(Qt::UserRole).value<RsGxsChannelPost>().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<const RsEvent> event)
|
void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||||
@ -717,6 +728,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
|||||||
ui->postTime_LB->hide();
|
ui->postTime_LB->hide();
|
||||||
mChannelPostFilesModel->clear();
|
mChannelPostFilesModel->clear();
|
||||||
ui->details_TW->setEnabled(false);
|
ui->details_TW->setEnabled(false);
|
||||||
|
// mSelectedPost.clear();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -726,9 +738,6 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
|||||||
ui->postName_LB->show();
|
ui->postName_LB->show();
|
||||||
ui->postTime_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;
|
std::cerr << "showPostDetails: setting mSelectedPost to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mSelectedPost << std::endl;
|
||||||
mSelectedPost = post.mMeta.mMsgId;
|
mSelectedPost = post.mMeta.mMsgId;
|
||||||
|
|
||||||
@ -741,7 +750,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
|||||||
auto all_msgs_versions(post.mOlderVersions);
|
auto all_msgs_versions(post.mOlderVersions);
|
||||||
all_msgs_versions.insert(post.mMeta.mMsgId);
|
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;
|
std::cerr << "Showing details about selected index : "<< index.row() << "," << index.column() << std::endl;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user