mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-17 01:24:15 -05:00
added some debug info
This commit is contained in:
parent
8c2c3188ef
commit
417f80d752
4 changed files with 70 additions and 13 deletions
|
|
@ -231,6 +231,7 @@ IdDialog::IdDialog(QWidget *parent)
|
||||||
mProxyModel->setFilterRegExp(QRegExp(RsIdentityListModel::FilterString));
|
mProxyModel->setFilterRegExp(QRegExp(RsIdentityListModel::FilterString));
|
||||||
|
|
||||||
ui->idTreeWidget->setModel(mProxyModel);
|
ui->idTreeWidget->setModel(mProxyModel);
|
||||||
|
//ui->idTreeWidget->setSelectionModel(new QItemSelectionModel(mProxyModel));// useless in Qt5.
|
||||||
|
|
||||||
ui->treeWidget_membership->clear();
|
ui->treeWidget_membership->clear();
|
||||||
ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate());
|
ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate());
|
||||||
|
|
@ -290,7 +291,7 @@ IdDialog::IdDialog(QWidget *parent)
|
||||||
connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity()));
|
connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity()));
|
||||||
connect(ui->chatIdentity, SIGNAL(triggered()), this, SLOT(chatIdentity()));
|
connect(ui->chatIdentity, SIGNAL(triggered()), this, SLOT(chatIdentity()));
|
||||||
|
|
||||||
connect(ui->idTreeWidget->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(updateSelection()));
|
connect(ui->idTreeWidget->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(updateSelection(const QItemSelection&,const QItemSelection&)));
|
||||||
connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint)));
|
connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint)));
|
||||||
|
|
||||||
ui->idTreeWidget->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->idTreeWidget->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
@ -1358,8 +1359,13 @@ void IdDialog::filterToggled(const bool &value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::updateSelection()
|
void IdDialog::updateSelection(const QItemSelection& new_sel,const QItemSelection& old_sel)
|
||||||
{
|
{
|
||||||
|
std::cerr << "Got selectionChanged signal. Old selection is: " << std::endl;
|
||||||
|
for(auto i:old_sel.indexes()) std::cerr << " " << i << std::endl;
|
||||||
|
std::cerr << "Got selectionChanged signal. New selection is: " << std::endl;
|
||||||
|
for(auto i:new_sel.indexes()) std::cerr << " " << i << std::endl;
|
||||||
|
|
||||||
auto id = RsGxsGroupId(getSelectedIdentity());
|
auto id = RsGxsGroupId(getSelectedIdentity());
|
||||||
|
|
||||||
std::cerr << "updating selection to id " << id << std::endl;
|
std::cerr << "updating selection to id " << id << std::endl;
|
||||||
|
|
@ -1963,6 +1969,7 @@ void IdDialog::modifyReputation()
|
||||||
|
|
||||||
void IdDialog::navigate(const RsGxsId& gxs_id)
|
void IdDialog::navigate(const RsGxsId& gxs_id)
|
||||||
{
|
{
|
||||||
|
mIdListModel->debug_dump();
|
||||||
#ifndef ID_DEBUG
|
#ifndef ID_DEBUG
|
||||||
std::cerr << "IdDialog::navigate to " << gxs_id.toStdString() << std::endl;
|
std::cerr << "IdDialog::navigate to " << gxs_id.toStdString() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1984,15 +1991,32 @@ void IdDialog::navigate(const RsGxsId& gxs_id)
|
||||||
std::cerr << "Obtained proxy index " << proxy_indx << std::endl;
|
std::cerr << "Obtained proxy index " << proxy_indx << std::endl;
|
||||||
|
|
||||||
// in order to do this, we just select the correct ID in the ID list
|
// in order to do this, we just select the correct ID in the ID list
|
||||||
|
Q_ASSERT(ui->idTreeWidget->model() == mProxyModel);
|
||||||
|
|
||||||
if(!proxy_indx.isValid())
|
if(!proxy_indx.isValid())
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot find item with ID " << gxs_id << " in ID list." << std::endl;
|
std::cerr << "Cannot find item with ID " << gxs_id << " in ID list." << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui->idTreeWidget->selectionModel()->setCurrentIndex(proxy_indx,QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
std::cerr << "Row hidden? " << ui->idTreeWidget->isRowHidden(proxy_indx.row(),proxy_indx.parent()) << std::endl;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto ii = mProxyModel->mapToSource(proxy_indx);
|
||||||
|
std::cerr << "Remapping index to source: " << ii << std::endl;
|
||||||
|
}
|
||||||
|
ui->idTreeWidget->selectionModel()->select(proxy_indx,QItemSelectionModel::Current|QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||||
|
{
|
||||||
|
auto lst = ui->idTreeWidget->selectionModel()->selectedIndexes();
|
||||||
|
std::cerr << "Just after calling select(), the selected index list has size " << lst.size() << std::endl;
|
||||||
|
}
|
||||||
ui->idTreeWidget->scrollTo(proxy_indx);//May change if model reloaded
|
ui->idTreeWidget->scrollTo(proxy_indx);//May change if model reloaded
|
||||||
ui->idTreeWidget->setFocus();
|
ui->idTreeWidget->setFocus();
|
||||||
|
|
||||||
|
// This has to be done manually because for some reason the proxy model doesn't work with the selection model
|
||||||
|
// No signal is emitted when calling setCurrentIndex() above.
|
||||||
|
|
||||||
|
//mId = RsGxsGroupId(gxs_id);
|
||||||
|
//updateIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::updateDisplay(bool complete)
|
void IdDialog::updateDisplay(bool complete)
|
||||||
|
|
@ -2012,16 +2036,24 @@ void IdDialog::updateDisplay(bool complete)
|
||||||
|
|
||||||
std::list<RsGxsId> IdDialog::getSelectedIdentities() const
|
std::list<RsGxsId> IdDialog::getSelectedIdentities() const
|
||||||
{
|
{
|
||||||
QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes();
|
QModelIndexList selectedIndexes_proxy = ui->idTreeWidget->selectionModel()->selectedIndexes();
|
||||||
std::list<RsGxsId> res;
|
std::list<RsGxsId> res;
|
||||||
|
|
||||||
for(auto indx:selectedIndexes)
|
std::cerr << "Parsing selected index list: " << std::endl;
|
||||||
|
for(auto indx_proxy:selectedIndexes_proxy)
|
||||||
{
|
{
|
||||||
RsGxsId id;
|
RsGxsId id;
|
||||||
|
|
||||||
if(indx.column() == RsIdentityListModel::COLUMN_THREAD_NAME) // this removes duplicates
|
if(indx_proxy.column() == RsIdentityListModel::COLUMN_THREAD_ID) // this removes duplicates
|
||||||
if( !(id = mIdListModel->getIdentity(mProxyModel->mapToSource(indx))).isNull() )
|
{
|
||||||
|
auto indx = mProxyModel->mapToSource(indx_proxy);
|
||||||
|
auto id = mIdListModel->getIdentity(indx);
|
||||||
|
|
||||||
|
std::cerr << " indx: " << indx_proxy << " original indx: " << indx << " identity: " << id << std::endl;
|
||||||
|
|
||||||
|
if( !id.isNull() )
|
||||||
res.push_back(id);
|
res.push_back(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -2031,6 +2063,8 @@ RsGxsId IdDialog::getSelectedIdentity() const
|
||||||
{
|
{
|
||||||
auto lst = getSelectedIdentities();
|
auto lst = getSelectedIdentities();
|
||||||
|
|
||||||
|
std::cerr << "Selected identities has size " << lst.size() << std::endl;
|
||||||
|
|
||||||
if(lst.size() != 1)
|
if(lst.size() != 1)
|
||||||
return RsGxsId();
|
return RsGxsId();
|
||||||
else
|
else
|
||||||
|
|
@ -2573,13 +2607,14 @@ void IdDialog::applyWhileKeepingTree(std::function<void()> predicate)
|
||||||
#ifdef DEBUG_NEW_FRIEND_LIST
|
#ifdef DEBUG_NEW_FRIEND_LIST
|
||||||
std::cerr << "Applying predicate..." << std::endl;
|
std::cerr << "Applying predicate..." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
mProxyModel->setSourceModel(nullptr);
|
|
||||||
#endif
|
#endif
|
||||||
|
mProxyModel->setSourceModel(nullptr);
|
||||||
|
|
||||||
predicate();
|
predicate();
|
||||||
|
|
||||||
restoreExpandedPathsAndSelection_idTreeView(expanded,selected);
|
restoreExpandedPathsAndSelection_idTreeView(expanded,selected);
|
||||||
|
|
||||||
// mProxyModel->setSourceModel(mIdListModel);
|
mProxyModel->setSourceModel(mIdListModel);
|
||||||
// restore hidden columns
|
// restore hidden columns
|
||||||
for(uint32_t i=0;i<RsIdentityListModel::COLUMN_THREAD_NB_COLUMNS;++i)
|
for(uint32_t i=0;i<RsIdentityListModel::COLUMN_THREAD_NB_COLUMNS;++i)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ class UIStateHelper;
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
class RsIdentityListModel;
|
class RsIdentityListModel;
|
||||||
class IdListSortFilterProxyModel;
|
class IdListSortFilterProxyModel;
|
||||||
|
class QItemSelection;
|
||||||
|
|
||||||
class IdDialog : public MainPage
|
class IdDialog : public MainPage
|
||||||
{
|
{
|
||||||
|
|
@ -96,7 +97,7 @@ private slots:
|
||||||
void copyRetroshareLink();
|
void copyRetroshareLink();
|
||||||
void on_closeInfoFrameButton_Invite_clicked();
|
void on_closeInfoFrameButton_Invite_clicked();
|
||||||
|
|
||||||
void updateSelection();
|
void updateSelection(const QItemSelection &new_sel, const QItemSelection &old_sel);
|
||||||
|
|
||||||
void modifyReputation();
|
void modifyReputation();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ int RsIdentityListModel::columnCount(const QModelIndex &/*parent*/) const
|
||||||
bool RsIdentityListModel::hasChildren(const QModelIndex &parent) const
|
bool RsIdentityListModel::hasChildren(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if(!parent.isValid())
|
if(!parent.isValid())
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
EntryIndex parent_index ;
|
EntryIndex parent_index ;
|
||||||
convertInternalIdToIndex(parent.internalId(),parent_index);
|
convertInternalIdToIndex(parent.internalId(),parent_index);
|
||||||
|
|
@ -198,6 +198,8 @@ RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::parent() const
|
||||||
i.identity_index = 0;
|
i.identity_index = 0;
|
||||||
break;
|
break;
|
||||||
case ENTRY_TYPE_TOP_LEVEL:
|
case ENTRY_TYPE_TOP_LEVEL:
|
||||||
|
std::cerr << "ERROR: calling parent() on entryindex with no parent!" << std::endl;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//Can be when request root index.
|
//Can be when request root index.
|
||||||
break;
|
break;
|
||||||
|
|
@ -225,6 +227,7 @@ RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::child(int row)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENTRY_TYPE_IDENTITY: i = EntryIndex();
|
case ENTRY_TYPE_IDENTITY: i = EntryIndex();
|
||||||
|
std::cerr << "ERROR: calling child() on entryindex with no children!" << std::endl;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -784,6 +787,7 @@ void RsIdentityListModel::clear()
|
||||||
emit friendListChanged();
|
emit friendListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RsIdentityListModel::debug_dump() const
|
void RsIdentityListModel::debug_dump() const
|
||||||
{
|
{
|
||||||
std::cerr << "==== IdentityListModel Debug dump ====" << std::endl;
|
std::cerr << "==== IdentityListModel Debug dump ====" << std::endl;
|
||||||
|
|
@ -792,11 +796,13 @@ void RsIdentityListModel::debug_dump() const
|
||||||
|
|
||||||
EntryIndex top_level;
|
EntryIndex top_level;
|
||||||
top_level.type = ENTRY_TYPE_TOP_LEVEL;
|
top_level.type = ENTRY_TYPE_TOP_LEVEL;
|
||||||
QModelIndex created_top_level;
|
|
||||||
quintptr id;
|
quintptr id;
|
||||||
convertIndexToInternalId(top_level,id);
|
convertIndexToInternalId(top_level,id);
|
||||||
|
|
||||||
std::cerr << "Top level index: " << createIndex(0,0,id) << std::endl;
|
std::cerr << "Top level index: " << createIndex(0,0,id) << std::endl;
|
||||||
|
EntryIndex tei;
|
||||||
|
convertInternalIdToIndex(0,tei);
|
||||||
|
std::cerr << "Top level entry index: " << tei << std::endl;
|
||||||
|
|
||||||
for(uint32_t j=0;j<mCategories.size();++j)
|
for(uint32_t j=0;j<mCategories.size();++j)
|
||||||
{
|
{
|
||||||
|
|
@ -907,6 +913,8 @@ void RsIdentityListModel::updateIdentityList()
|
||||||
}
|
}
|
||||||
|
|
||||||
setIdentities(ids) ;
|
setIdentities(ids) ;
|
||||||
|
|
||||||
|
debug_dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,20 @@ public:
|
||||||
|
|
||||||
EntryType type; // type of the entry (group,profile,location)
|
EntryType type; // type of the entry (group,profile,location)
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& o, const EntryIndex& e) { return o << "(" << e.type << "," << e.category_index << "," << e.identity_index << ")";}
|
friend std::ostream& operator<<(std::ostream& o, const EntryIndex& e)
|
||||||
|
{
|
||||||
|
o << "[" ;
|
||||||
|
switch(e.type)
|
||||||
|
{
|
||||||
|
case RsIdentityListModel::ENTRY_TYPE_INVALID: o << "Invalid," ; break;
|
||||||
|
case RsIdentityListModel::ENTRY_TYPE_CATEGORY: o << "Category," ; break;
|
||||||
|
case RsIdentityListModel::ENTRY_TYPE_IDENTITY: o << "Identity," ; break;
|
||||||
|
case RsIdentityListModel::ENTRY_TYPE_TOP_LEVEL: o << "Toplevel," ; break;
|
||||||
|
}
|
||||||
|
o << " CI: " << e.category_index << ", ";
|
||||||
|
o << " II: " << e.identity_index << "]";
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
// Indices w.r.t. parent. The set of indices entirely determines the position of the entry in the hierarchy.
|
// Indices w.r.t. parent. The set of indices entirely determines the position of the entry in the hierarchy.
|
||||||
// An index of 0xff means "undefined"
|
// An index of 0xff means "undefined"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue