mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-29 16:53:31 -05:00
added bold for connection state
This commit is contained in:
parent
ee678889a3
commit
fb174f0131
@ -46,6 +46,8 @@ std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsew
|
|||||||
|
|
||||||
const QString RsFriendListModel::FilterString("filtered");
|
const QString RsFriendListModel::FilterString("filtered");
|
||||||
|
|
||||||
|
static const uint32_t NODE_DETAILS_UPDATE_DELAY = 5; // update each node every 5 secs.
|
||||||
|
|
||||||
RsFriendListModel::RsFriendListModel(QObject *parent)
|
RsFriendListModel::RsFriendListModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
@ -363,6 +365,7 @@ QVariant RsFriendListModel::data(const QModelIndex &index, int role) const
|
|||||||
switch(role)
|
switch(role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole: return displayRole(entry,index.column()) ;
|
case Qt::DisplayRole: return displayRole(entry,index.column()) ;
|
||||||
|
case Qt::FontRole: return fontRole(entry,index.column()) ;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -531,6 +534,29 @@ QVariant RsFriendListModel::sortRole(const EntryIndex& fmpe,int column) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const
|
||||||
|
{
|
||||||
|
std::cerr << " font role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl;
|
||||||
|
|
||||||
|
switch(e.type)
|
||||||
|
{
|
||||||
|
case ENTRY_TYPE_GROUP:
|
||||||
|
case ENTRY_TYPE_PROFILE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ENTRY_TYPE_NODE:
|
||||||
|
const RsNodeDetails *node = getNodeInfo(e);
|
||||||
|
|
||||||
|
if(!node)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
QFont font ;
|
||||||
|
font.setBold(node->state & RS_PEER_STATE_CONNECTED);
|
||||||
|
|
||||||
|
return QVariant(font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
|
QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
|
||||||
{
|
{
|
||||||
std::cerr << " Display role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl;
|
std::cerr << " Display role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl;
|
||||||
@ -650,7 +676,18 @@ const RsFriendListModel::RsNodeDetails *RsFriendListModel::getNodeInfo(const Ent
|
|||||||
if(e.node_index >= mProfiles[pindex].child_node_indices.size())
|
if(e.node_index >= mProfiles[pindex].child_node_indices.size())
|
||||||
return NULL ;
|
return NULL ;
|
||||||
|
|
||||||
return &mLocations[mProfiles[pindex].child_node_indices[e.node_index]].node_info;
|
time_t now = time(NULL);
|
||||||
|
HierarchicalNodeInformation& node(mLocations[mProfiles[pindex].child_node_indices[e.node_index]]);
|
||||||
|
|
||||||
|
if(node.last_update_ts + NODE_DETAILS_UPDATE_DELAY < now)
|
||||||
|
{
|
||||||
|
std::cerr << "Updating ID " << node.node_info.id << std::endl;
|
||||||
|
RsPeerId id(node.node_info.id); // this avoids zeroing the id field when writing the node data
|
||||||
|
rsPeers->getPeerDetails(id,node.node_info);
|
||||||
|
node.last_update_ts = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &node.node_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -722,47 +759,6 @@ void RsFriendListModel::clear()
|
|||||||
emit friendListChanged();
|
emit friendListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void RsFriendListModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs)
|
|
||||||
// {
|
|
||||||
// preMods();
|
|
||||||
//
|
|
||||||
// beginRemoveRows(QModelIndex(),0,mMessages.size()-1);
|
|
||||||
// endRemoveRows();
|
|
||||||
//
|
|
||||||
// mMessages.clear();
|
|
||||||
// mMessagesMap.clear();
|
|
||||||
//
|
|
||||||
// for(auto it(msgs.begin());it!=msgs.end();++it)
|
|
||||||
// {
|
|
||||||
// mMessagesMap[(*it).msgId] = mMessages.size();
|
|
||||||
// mMessages.push_back(*it);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // now update prow for all posts
|
|
||||||
//
|
|
||||||
// #ifdef DEBUG_MESSAGE_MODEL
|
|
||||||
// debug_dump();
|
|
||||||
// #endif
|
|
||||||
//
|
|
||||||
// beginInsertRows(QModelIndex(),0,mMessages.size()-1);
|
|
||||||
// endInsertRows();
|
|
||||||
// postMods();
|
|
||||||
//
|
|
||||||
// emit messagesLoaded();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void RsFriendListModel::updateMessages()
|
|
||||||
// {
|
|
||||||
// emit messagesAboutToLoad();
|
|
||||||
//
|
|
||||||
// std::list<Rs::Msgs::MsgInfoSummary> msgs;
|
|
||||||
//
|
|
||||||
// getMessageSummaries(mCurrentBox,msgs);
|
|
||||||
// setMessages(msgs);
|
|
||||||
//
|
|
||||||
// emit messagesLoaded();
|
|
||||||
// }
|
|
||||||
|
|
||||||
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 RsFriendListModel::debug_dump() const
|
void RsFriendListModel::debug_dump() const
|
||||||
|
@ -59,6 +59,9 @@ public:
|
|||||||
};
|
};
|
||||||
struct HierarchicalNodeInformation
|
struct HierarchicalNodeInformation
|
||||||
{
|
{
|
||||||
|
HierarchicalNodeInformation() : last_update_ts(0) {}
|
||||||
|
|
||||||
|
rstime_t last_update_ts;
|
||||||
RsNodeDetails node_info;
|
RsNodeDetails node_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -202,9 +205,9 @@ private:
|
|||||||
// meaning which is the child/parent of which. The actual group/profile/node data are also stored in the
|
// meaning which is the child/parent of which. The actual group/profile/node data are also stored in the
|
||||||
// structure.
|
// structure.
|
||||||
|
|
||||||
std::vector<HierarchicalGroupInformation> mGroups;
|
mutable std::vector<HierarchicalGroupInformation> mGroups;
|
||||||
std::vector<HierarchicalProfileInformation> mProfiles;
|
mutable std::vector<HierarchicalProfileInformation> mProfiles;
|
||||||
std::vector<HierarchicalNodeInformation> mLocations;
|
mutable std::vector<HierarchicalNodeInformation> mLocations;
|
||||||
|
|
||||||
// The top level list contains all nodes to display, which type depends on the option to display groups or not.
|
// The top level list contains all nodes to display, which type depends on the option to display groups or not.
|
||||||
// Idices in the list may be profile indices or group indices. In the former case the profile child index refers to
|
// Idices in the list may be profile indices or group indices. In the former case the profile child index refers to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user