cleaned up the code, added icon for groups, only save/restore expanded items when changes are expected

This commit is contained in:
csoler 2019-08-23 16:15:43 +02:00
parent 1181e26bc5
commit fdea4febbe
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 10 additions and 19 deletions

View File

@ -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()

View File

@ -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<QString> expanded_indexes;
std::set<QString> 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()