From e234cb933d2c9c6c93a41859f0f0047548d08570 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 9 Sep 2020 21:31:08 +0200 Subject: [PATCH] added color marker for selection --- .../src/gui/gxschannels/GxsChannelPostsModel.cpp | 3 ++- .../gxschannels/GxsChannelPostsWidgetWithModel.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 4fc53e1ce..5c64731da 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -705,7 +705,8 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status) bool post_status = (IS_MSG_UNREAD(mPosts[i].mMeta.mMsgStatus) || IS_MSG_NEW(mPosts[i].mMeta.mMsgStatus)); if(post_status != read_status) - rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status); + if(!rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status)) + RsErr() << "setAllMsgReadStatus: failed to change status of msg " << mPosts[i].mMeta.mMsgId << " in group " << mPosts[i].mMeta.mGroupId << " to status " << read_status << std::endl; } }); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 382a624f2..61a69cbbc 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -61,6 +61,8 @@ static const int CHANNEL_TABS_DETAILS= 0; static const int CHANNEL_TABS_POSTS = 1; static const int CHANNEL_TABS_FILES = 2; +QColor SelectedColor = QRgb(0xff308dc7); + /* View mode */ #define VIEW_MODE_FEEDS 1 #define VIEW_MODE_FILES 2 @@ -134,7 +136,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & QPixmap pixmap(w.size()); 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. + pixmap.fill(SelectedColor); // I dont know how to grab the backgroud color for selected objects automatically. else pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background @@ -180,6 +182,9 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->save(); + if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) + painter->setPen(SelectedColor); + if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) { QFont font(option.font); @@ -521,6 +526,8 @@ void GxsChannelPostsWidgetWithModel::switchView() ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/listlayout.svg")); ui->viewType_TB->setToolTip(tr("Click to switch to grid view")); + ui->postsTree->setSelectionBehavior(QAbstractItemView::SelectRows); + mChannelPostsDelegate->setWidgetGrid(false); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_LIST); } @@ -529,6 +536,8 @@ void GxsChannelPostsWidgetWithModel::switchView() ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg")); ui->viewType_TB->setToolTip(tr("Click to switch to list view")); + ui->postsTree->setSelectionBehavior(QAbstractItemView::SelectItems); + mChannelPostsDelegate->setWidgetGrid(true); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID);