switched from GxsIdRSTreeWidgetItem to GxsIdItemDelegate, so as to avoid the whole timer system to load ids in Circles list

This commit is contained in:
csoler 2020-02-17 23:13:41 +01:00
parent 167380127b
commit e4dc72169c
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 16 additions and 9 deletions

View File

@ -170,6 +170,7 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog)
contactsItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff);
ui->treeWidget_membership->clear();
ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate());
mExternalOtherCircleItem = NULL ;
mExternalBelongingCircleItem = NULL ;
@ -768,13 +769,13 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
#ifdef ID_DEBUG
std::cerr << "invited: " << invited << ", subscription: " << subscrb ;
#endif
GxsIdRSTreeWidgetItem *subitem = NULL ;
RSTreeWidgetItem *subitem = NULL ;
// see if the item already exists
for(uint32_t k=0; k < (uint32_t)item->childCount(); ++k)
if(item->child(k)->data(CIRCLEGROUP_CIRCLE_COL_GROUPID,Qt::UserRole).toString().toStdString() == it->first.toStdString())
{
subitem = dynamic_cast<GxsIdRSTreeWidgetItem*>(item->child(k));
subitem = dynamic_cast<RSTreeWidgetItem*>(item->child(k));
#ifdef ID_DEBUG
std::cerr << " found existing sub item." << std::endl;
#endif
@ -803,9 +804,8 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
#ifdef ID_DEBUG
std::cerr << " no existing sub item. Creating new one." << std::endl;
#endif
subitem = new GxsIdRSTreeWidgetItem(NULL,GxsIdDetails::ICON_TYPE_AVATAR,false);
subitem->setId(it->first,CIRCLEGROUP_CIRCLE_COL_GROUPNAME,true);
subitem = new RSTreeWidgetItem(NULL);
subitem->setData(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,Qt::UserRole,QString::fromStdString(it->first.toStdString()));
RsIdentityDetails idd ;
bool has_id = rsIdentity->getIdDetails(it->first,idd) ;

View File

@ -90,14 +90,17 @@ public:
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
{
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
if(id.isNull())
return QStyledItemDelegate::sizeHint(option,index);
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
// disable default icon
opt.icon = QIcon();
const QRect r = option.rect;
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
QString str;
QList<QIcon> icons;
QString comment;
@ -128,6 +131,11 @@ public:
return ;
}
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
if(id.isNull())
return QStyledItemDelegate::paint(painter,option,index);
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
@ -138,7 +146,6 @@ public:
const QRect r = option.rect;
RsGxsId id(index.data(Qt::UserRole).toString().toStdString());
QString str;
QString comment;