diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 7d7b42c16..eb587f39d 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -73,28 +73,21 @@ void RsFriendListModel::postMods() int RsFriendListModel::rowCount(const QModelIndex& parent) const { - if(!parent.isValid()) + if(parent.column() >= COLUMN_THREAD_NB_COLUMNS) return 0; - if(parent.column() > 0) - return 0; - - if(mDisplayGroups) - { - if(mGroups.empty()) // security. Should never happen. - return 0; - - if(parent.internalPointer() == NULL) + if(parent.internalId() == 0) + if(mDisplayGroups) return mGroups.size(); - } - else - { - if(mProfiles.empty()) // security. Should never happen. - return 0; - - if(parent.internalPointer() == NULL) + else return mProfiles.size(); - } + + EntryIndex index; + if(!convertInternalIdToIndex(parent.internalId(),index)) + return 0; + + if(index.type == ENTRY_TYPE_GROUP) + return mGroups[index.ind].peerIds.size(); return 0; } @@ -123,7 +116,17 @@ bool RsFriendListModel::hasChildren(const QModelIndex &parent) const if(!parent.isValid()) return true; - return false ; + EntryIndex parent_index ; + convertInternalIdToIndex(parent.internalId(),parent_index); + + if(parent_index.type == ENTRY_TYPE_NODE) + return false; + if(parent_index.type == ENTRY_TYPE_PROFILE) + return false; // TODO + if(parent_index.type == ENTRY_TYPE_GROUP) + return !mGroups[parent_index.ind].peerIds.empty(); + + return false; } bool RsFriendListModel::convertIndexToInternalId(const EntryIndex& e,quintptr& id) @@ -208,6 +211,36 @@ QModelIndex RsFriendListModel::parent(const QModelIndex& index) const if(!index.isValid()) return QModelIndex(); + EntryIndex I ; + convertInternalIdToIndex(index.internalId(),I); + + if(I.type == ENTRY_TYPE_GROUP) + return QModelIndex(); + + if(I.type == ENTRY_TYPE_PROFILE) + if(mDisplayGroups) + { + for(int i=0;isetupUi(this); + ui->setupUi(this); connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu())); //connect(ui->peerTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(expandItem(QTreeWidgetItem *)) ); @@ -134,7 +134,6 @@ NewFriendList::NewFriendList(QWidget *parent) : ui->filterLineEdit->setPlaceholderText(tr("Search")) ; ui->filterLineEdit->showFilterIcon(); - mModel = new RsFriendListModel(); ui->peerTreeWidget->setModel(mModel); @@ -146,9 +145,9 @@ NewFriendList::NewFriendList(QWidget *parent) : // ui->filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME, QString("%1 %2").arg(tr("Search"), headerText)); // ui->filterLineEdit->addFilter(QIcon(), tr("ID"), COLUMN_ID, tr("Search ID")); - // mActionSortByState = new QAction(tr("Sort by state"), this); - // mActionSortByState->setCheckable(true); - // connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(sortByState(bool))); + mActionSortByState = new QAction(tr("Sort by state"), this); + mActionSortByState->setCheckable(true); + connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(sortByState(bool))); // ui->peerTreeWidget->addContextMenuAction(mActionSortByState); /* Set sort */ @@ -178,6 +177,8 @@ NewFriendList::NewFriendList(QWidget *parent) : /* Initialize display menu */ createDisplayMenu(); + + mModel->updateInternalData(); } NewFriendList::~NewFriendList()