fixed coloring in FriendListModel

This commit is contained in:
csoler 2019-08-06 19:41:18 +02:00
parent fb174f0131
commit 6c534360f1
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
5 changed files with 42 additions and 27 deletions

View File

@ -1014,6 +1014,7 @@ void FriendList::insertPeers()
if (rsState == 0) {
sslFont.setBold(true);
sslColor = mTextColorStatus[RS_STATUS_ONLINE];
} else {
sslFont = StatusDefs::font(rsState);
sslColor = mTextColorStatus[rsState];

View File

@ -364,8 +364,9 @@ QVariant RsFriendListModel::data(const QModelIndex &index, int role) const
switch(role)
{
case Qt::DisplayRole: return displayRole(entry,index.column()) ;
case Qt::FontRole: return fontRole(entry,index.column()) ;
case Qt::DisplayRole: return displayRole(entry,index.column()) ;
case Qt::FontRole: return fontRole(entry,index.column()) ;
case Qt::TextColorRole: return textColorRole(entry,index.column()) ;
default:
return QVariant();
}
@ -381,7 +382,6 @@ QVariant RsFriendListModel::data(const QModelIndex &index, int role) const
// case Qt::DecorationRole: return decorationRole(fmpe,index.column()) ;
// case Qt::ToolTipRole: return toolTipRole (fmpe,index.column()) ;
// case Qt::UserRole: return userRole (fmpe,index.column()) ;
// case Qt::TextColorRole: return textColorRole (fmpe,index.column()) ;
// case Qt::BackgroundRole: return backgroundRole(fmpe,index.column()) ;
//
// case FilterRole: return filterRole (fmpe,index.column()) ;
@ -395,7 +395,14 @@ QVariant RsFriendListModel::data(const QModelIndex &index, int role) const
QVariant RsFriendListModel::textColorRole(const EntryIndex& fmpe,int column) const
{
return QVariant();
switch(fmpe.type)
{
case ENTRY_TYPE_GROUP: return QVariant(QBrush(mTextColorGroup));
#warning CODE NEEDED HERE!
case ENTRY_TYPE_NODE: return QVariant(QBrush(mTextColorStatus[getPeerStatus(fmpe)]));
default:
return QVariant();
}
}
QVariant RsFriendListModel::statusRole(const EntryIndex& fmpe,int column) const
@ -690,6 +697,16 @@ const RsFriendListModel::RsNodeDetails *RsFriendListModel::getNodeInfo(const Ent
return &node.node_info;
}
uint32_t RsFriendListModel::getPeerStatus(const EntryIndex& e) const
{
const RsNodeDetails *noded = getNodeInfo(e) ;
StatusInfo info;
if(!noded || !rsStatus->getStatus(noded->id,info))
return RS_STATUS_OFFLINE;
return info.status;
}
QVariant RsFriendListModel::userRole(const EntryIndex& fmpe,int col) const
{

View File

@ -23,15 +23,10 @@
#include <QModelIndex>
#include <QColor>
#include "retroshare/rsstatus.h"
#include "retroshare/rsmsgs.h"
#include "retroshare/rspeers.h"
// This class holds the actual hierarchy of posts, represented by identifiers
// It is responsible for auto-updating when necessary and holds a mutex to allow the Model to
// safely access the data.
// The model contains a post in place 0 that is the parent of all posts.
typedef uint32_t ForumModelIndex;
// This class is the item model used by Qt to display the information
@ -148,11 +143,17 @@ public:
void clear() ;
/* Color definitions (for standard see qss.default) */
QColor mTextColorGroup;
QColor mTextColorStatus[RS_STATUS_COUNT];
private:
const RsGroupInfo *getGroupInfo (const EntryIndex&) const;
const RsProfileDetails *getProfileInfo(const EntryIndex&) const;
const RsNodeDetails *getNodeInfo (const EntryIndex&) const;
uint32_t getPeerStatus(const EntryIndex& e) const;
QVariant sizeHintRole (int col) const;
QVariant displayRole (const EntryIndex &e, int col) const;

View File

@ -64,19 +64,19 @@ public:
void sortByColumn(int column, Qt::SortOrder sortOrder);
bool isSortByState();
QColor textColorGroup() const { return mTextColorGroup; }
QColor textColorStatusOffline() const { return mTextColorStatus[RS_STATUS_OFFLINE]; }
QColor textColorStatusAway() const { return mTextColorStatus[RS_STATUS_AWAY]; }
QColor textColorStatusBusy() const { return mTextColorStatus[RS_STATUS_BUSY]; }
QColor textColorStatusOnline() const { return mTextColorStatus[RS_STATUS_ONLINE]; }
QColor textColorStatusInactive() const { return mTextColorStatus[RS_STATUS_INACTIVE]; }
QColor textColorGroup() const { return mModel->mTextColorGroup; }
QColor textColorStatusOffline() const { return mModel->mTextColorStatus[RS_STATUS_OFFLINE ]; }
QColor textColorStatusAway() const { return mModel->mTextColorStatus[RS_STATUS_AWAY ]; }
QColor textColorStatusBusy() const { return mModel->mTextColorStatus[RS_STATUS_BUSY ]; }
QColor textColorStatusOnline() const { return mModel->mTextColorStatus[RS_STATUS_ONLINE ]; }
QColor textColorStatusInactive() const { return mModel->mTextColorStatus[RS_STATUS_INACTIVE]; }
void setTextColorGroup(QColor color) { mTextColorGroup = color; }
void setTextColorStatusOffline(QColor color) { mTextColorStatus[RS_STATUS_OFFLINE] = color; }
void setTextColorStatusAway(QColor color) { mTextColorStatus[RS_STATUS_AWAY] = color; }
void setTextColorStatusBusy(QColor color) { mTextColorStatus[RS_STATUS_BUSY] = color; }
void setTextColorStatusOnline(QColor color) { mTextColorStatus[RS_STATUS_ONLINE] = color; }
void setTextColorStatusInactive(QColor color) { mTextColorStatus[RS_STATUS_INACTIVE] = color; }
void setTextColorGroup(QColor color) { mModel->mTextColorGroup = color; }
void setTextColorStatusOffline(QColor color) { mModel->mTextColorStatus[RS_STATUS_OFFLINE ] = color; }
void setTextColorStatusAway(QColor color) { mModel->mTextColorStatus[RS_STATUS_AWAY ] = color; }
void setTextColorStatusBusy(QColor color) { mModel->mTextColorStatus[RS_STATUS_BUSY ] = color; }
void setTextColorStatusOnline(QColor color) { mModel->mTextColorStatus[RS_STATUS_ONLINE ] = color; }
void setTextColorStatusInactive(QColor color) { mModel->mTextColorStatus[RS_STATUS_INACTIVE] = color; }
public slots:
void filterItems(const QString &text);
@ -116,10 +116,6 @@ private:
std::set<RsNodeGroupId> openGroups;
std::set<RsPgpId> openPeers;
/* Color definitions (for standard see qss.default) */
QColor mTextColorGroup;
QColor mTextColorStatus[RS_STATUS_COUNT];
bool getOrCreateGroup(const std::string& name, uint flag, RsNodeGroupId& id);
bool getGroupIdByName(const std::string& name, RsNodeGroupId& id);

View File

@ -156,7 +156,7 @@ MessagesDialog
qproperty-textColorInbox: rgb(49, 106, 197);
}
FriendList
NewFriendList
{
qproperty-textColorStatusOffline: black;
qproperty-textColorStatusAway: gray;