From fdea4febbe887de0610d1217e42008e3edb6b314 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 23 Aug 2019 16:15:43 +0200 Subject: [PATCH] cleaned up the code, added icon for groups, only save/restore expanded items when changes are expected --- .../src/gui/common/FriendListModel.cpp | 21 +++++-------------- .../src/gui/common/NewFriendList.cpp | 8 ++++--- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 1b047ac03..9f1e3f8ba 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -40,6 +40,7 @@ #define IS_MESSAGE_UNREAD(flags) (flags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER)) +#define IMAGE_GROUP24 ":/images/user/group24.png" #define IMAGE_STAR_ON ":/images/star-on-16.png" #define IMAGE_STAR_OFF ":/images/star-off-16.png" @@ -111,20 +112,6 @@ int RsFriendListModel::columnCount(const QModelIndex &parent) const return COLUMN_THREAD_NB_COLUMNS ; } -// bool RsFriendListModel::getProfileData(const QModelIndex& i,Rs::Msgs::MessageInfo& fmpe) const -// { -// if(!i.isValid()) -// return true; -// -// quintptr ref = i.internalId(); -// uint32_t index = 0; -// -// if(!convertInternalIdToMsgIndex(ref,index) || index >= mMessages.size()) -// return false ; -// -// return rsMsgs->getMessage(mMessages[index].msgId,fmpe); -// } - bool RsFriendListModel::hasChildren(const QModelIndex &parent) const { if(!parent.isValid()) @@ -670,7 +657,7 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const if(!node) return QVariant(); -#ifndef DEBUG_MODEL +#ifdef DEBUG_MODEL std::cerr << node->node_info.location.c_str() ; #endif switch(col) @@ -800,6 +787,8 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons switch(entry.type) { + case ENTRY_TYPE_GROUP: return QVariant(QIcon(IMAGE_GROUP24)); + case ENTRY_TYPE_NODE: { const HierarchicalNodeInformation *hn = getNodeInfo(entry); @@ -812,8 +801,8 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons return QVariant(QIcon(sslAvatar)); } + default: return QVariant(); } - return QVariant(); } void RsFriendListModel::clear() diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 17c98cac0..36faf572a 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -153,7 +153,7 @@ private: bool m_showOfflineNodes; }; -NewFriendList::NewFriendList(QWidget *parent) : RsAutoUpdatePage(1000,parent), ui(new Ui::NewFriendList()) +NewFriendList::NewFriendList(QWidget *parent) : RsAutoUpdatePage(5000,parent), ui(new Ui::NewFriendList()) { ui->setupUi(this); @@ -1127,11 +1127,13 @@ void NewFriendList::checkInternalData(bool force) std::set expanded_indexes; std::set selected_indexes; - saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); + if(force) + saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); mModel->checkInternalData(force); - restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); + if(force) + restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); } void NewFriendList::exportFriendlistClicked()