mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
fixed a few UI bugs in channel posts
This commit is contained in:
parent
67e8b87750
commit
f40d7a75b3
@ -401,6 +401,11 @@ void RsGxsChannelPostsModel::clear()
|
||||
emit channelPostsLoaded();
|
||||
}
|
||||
|
||||
bool operator<(const RsGxsChannelPost& p1,const RsGxsChannelPost& p2)
|
||||
{
|
||||
return p1.mMeta.mPublishTs > p2.mMeta.mPublishTs;
|
||||
}
|
||||
|
||||
void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vector<RsGxsChannelPost>& posts)
|
||||
{
|
||||
preMods();
|
||||
@ -413,6 +418,8 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto
|
||||
|
||||
createPostsArray(posts);
|
||||
|
||||
std::sort(mPosts.begin(),mPosts.end());
|
||||
|
||||
mFilteredPosts.clear();
|
||||
for(int i=0;i<mPosts.size();++i)
|
||||
mFilteredPosts.push_back(i);
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData, post.mThumbnail.mSize, thumbnail,GxsIdDetails::ORIGINAL);
|
||||
lb->setPixmap(thumbnail);
|
||||
}
|
||||
else
|
||||
else if(post.mMeta.mPublishTs > 0) // this is for testing that the post is not an empty post (happens at the end of the last row)
|
||||
{
|
||||
QPixmap thumbnail = FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE);
|
||||
lb->setPixmap(thumbnail);
|
||||
@ -157,7 +157,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
||||
|
||||
QPixmap pixmap(w.size());
|
||||
|
||||
if(option.state & QStyle::State_Selected)
|
||||
if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row)
|
||||
pixmap.fill(QRgb(0xff308dc7)); // I dont know how to grab the backgroud color for selected objects automatically.
|
||||
else
|
||||
pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background
|
||||
@ -323,7 +323,13 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
||||
connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder)));
|
||||
|
||||
connect(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails()));
|
||||
connect(mChannelPostsModel,SIGNAL(channelPostsLoaded()),this,SLOT(postChannelLoad()));
|
||||
connect(mChannelPostsModel,SIGNAL(channelPostsLoaded()),this,SLOT(postChannelPostLoad()));
|
||||
|
||||
ui->postName_LB->hide();
|
||||
ui->postTime_LB->hide();
|
||||
ui->postLogo_LB->hide();
|
||||
|
||||
ui->postDetails_TE->setPlaceholderText(tr("No post selected"));
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
|
||||
@ -430,12 +436,14 @@ void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptr<con
|
||||
void GxsChannelPostsWidgetWithModel::showPostDetails()
|
||||
{
|
||||
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
|
||||
RsGxsChannelPost post = index.data(Qt::UserRole).value<RsGxsChannelPost>() ;
|
||||
|
||||
if(!index.isValid())
|
||||
if(post.mMeta.mPublishTs == 0)
|
||||
{
|
||||
ui->postDetails_TE->clear();
|
||||
ui->postLogo_LB->hide();
|
||||
ui->postName_LB->hide();
|
||||
ui->postTime_LB->hide();
|
||||
mChannelPostFilesModel->clear();
|
||||
mSelectedGroup.clear();
|
||||
mSelectedPost.clear();
|
||||
@ -444,12 +452,11 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
||||
|
||||
ui->postLogo_LB->show();
|
||||
ui->postName_LB->show();
|
||||
ui->postTime_LB->show();
|
||||
|
||||
if(index.row()==0 && index.column()==0)
|
||||
std::cerr << "here" << std::endl;
|
||||
|
||||
RsGxsChannelPost post = index.data(Qt::UserRole).value<RsGxsChannelPost>() ;
|
||||
|
||||
mSelectedGroup = mGroup.mMeta.mGroupId;
|
||||
mSelectedPost = post.mMeta.mMsgId;
|
||||
|
||||
@ -476,10 +483,12 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
|
||||
// Using fixed width so that the post will not displace the text when we browse.
|
||||
|
||||
ui->postLogo_LB->setPixmap(postImage);
|
||||
ui->postName_LB->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
|
||||
|
||||
ui->postLogo_LB->setFixedSize(W,postImage.height()/(float)postImage.width()*W);
|
||||
|
||||
ui->postName_LB->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
|
||||
ui->postName_LB->setFixedWidth(W);
|
||||
ui->postTime_LB->setText(QDateTime::fromMSecsSinceEpoch(post.mMeta.mPublishTs*1000).toString("MM/dd/yyyy, hh:mm"));
|
||||
ui->postTime_LB->setFixedWidth(W);
|
||||
|
||||
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
|
||||
ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
|
||||
@ -528,7 +537,7 @@ void GxsChannelPostsWidgetWithModel::updateGroupData()
|
||||
});
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidgetWithModel::postChannelLoad()
|
||||
void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
|
||||
{
|
||||
std::cerr << "Post channel load..." << std::endl;
|
||||
|
||||
|
@ -138,7 +138,7 @@ private slots:
|
||||
void setViewMode(int viewMode);
|
||||
void settingsChanged();
|
||||
void handlePostsTreeSizeChange(QSize s);
|
||||
void postChannelLoad();
|
||||
void postChannelPostLoad();
|
||||
|
||||
public slots:
|
||||
void sortColumnFiles(int col,Qt::SortOrder so);
|
||||
|
@ -161,7 +161,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="channel_TW">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
@ -399,7 +399,7 @@ p, li { white-space: pre-wrap; }
|
||||
</font>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@ -434,6 +434,13 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="postTime_LB">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
Loading…
Reference in New Issue
Block a user