mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-25 23:45:49 -04:00
fixed update of visible items
This commit is contained in:
parent
ed6debb3c6
commit
37c0f16a27
3 changed files with 90 additions and 32 deletions
|
@ -1296,6 +1296,9 @@ void IdDialog::updateSelection()
|
||||||
|
|
||||||
void IdDialog::updateIdList()
|
void IdDialog::updateIdList()
|
||||||
{
|
{
|
||||||
|
std::cerr << "Updating identity list in widget: stack is:" << std::endl;
|
||||||
|
//print_stacktrace();
|
||||||
|
|
||||||
std::set<QString> expanded_indices;
|
std::set<QString> expanded_indices;
|
||||||
std::set<std::pair<RsIdentityListModel::EntryType,QString> > selected_indices;
|
std::set<std::pair<RsIdentityListModel::EntryType,QString> > selected_indices;
|
||||||
|
|
||||||
|
@ -1592,11 +1595,11 @@ void IdDialog::updateIdentity()
|
||||||
std::set<QString> expanded_indexes;
|
std::set<QString> expanded_indexes;
|
||||||
std::set<std::pair<RsIdentityListModel::EntryType,QString> > selected_indices;
|
std::set<std::pair<RsIdentityListModel::EntryType,QString> > selected_indices;
|
||||||
|
|
||||||
saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices);
|
//saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices);
|
||||||
|
|
||||||
loadIdentity(group);
|
loadIdentity(group);
|
||||||
|
|
||||||
restoreExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices);
|
//restoreExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices);
|
||||||
|
|
||||||
}, this );
|
}, this );
|
||||||
});
|
});
|
||||||
|
@ -1785,9 +1788,9 @@ void IdDialog::loadIdentity(RsGxsIdGroup data)
|
||||||
|
|
||||||
switch(info.mOwnOpinion)
|
switch(info.mOwnOpinion)
|
||||||
{
|
{
|
||||||
case RsOpinion::NEGATIVE: ui->ownOpinion_CB->setCurrentIndex(0); break;
|
case RsOpinion::NEGATIVE: whileBlocking(ui->ownOpinion_CB)->setCurrentIndex(0); break;
|
||||||
case RsOpinion::NEUTRAL : ui->ownOpinion_CB->setCurrentIndex(1); break;
|
case RsOpinion::NEUTRAL : whileBlocking(ui->ownOpinion_CB)->setCurrentIndex(1); break;
|
||||||
case RsOpinion::POSITIVE: ui->ownOpinion_CB->setCurrentIndex(2); break;
|
case RsOpinion::POSITIVE: whileBlocking(ui->ownOpinion_CB)->setCurrentIndex(2); break;
|
||||||
default:
|
default:
|
||||||
std::cerr << "Unexpected value in own opinion: "
|
std::cerr << "Unexpected value in own opinion: "
|
||||||
<< static_cast<uint32_t>(info.mOwnOpinion) << std::endl;
|
<< static_cast<uint32_t>(info.mOwnOpinion) << std::endl;
|
||||||
|
@ -2537,13 +2540,14 @@ void IdDialog::restoreExpandedCircleItems(const std::vector<bool>& expanded_root
|
||||||
void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set<QString>& expanded_indexes,
|
void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set<QString>& expanded_indexes,
|
||||||
std::set<std::pair<RsIdentityListModel::EntryType,QString> >& selected_indices)
|
std::set<std::pair<RsIdentityListModel::EntryType,QString> >& selected_indices)
|
||||||
{
|
{
|
||||||
std::cerr << "Saving expended paths and selection..." << std::endl;
|
std::cerr << "Saving expended paths and selection... thread " << (void*)pthread_self() << std::endl;
|
||||||
|
|
||||||
QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes();
|
QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes();
|
||||||
|
|
||||||
// convert all selected indices into something that is not QModelIndex-related, so that we can find it again after refreshing the list
|
// convert all selected indices into something that is not QModelIndex-related, so that we can find it again after refreshing the list
|
||||||
|
|
||||||
for(auto m:selectedIndexes)
|
for(auto m:selectedIndexes)
|
||||||
|
if(m.column()==RsIdentityListModel::COLUMN_THREAD_ID)
|
||||||
{
|
{
|
||||||
auto t = mIdListModel->getType(m);
|
auto t = mIdListModel->getType(m);
|
||||||
QString s ;
|
QString s ;
|
||||||
|
@ -2560,13 +2564,14 @@ void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set<QString>& expan
|
||||||
|
|
||||||
for(int row = 0; row < mIdListModel->rowCount(); ++row)
|
for(int row = 0; row < mIdListModel->rowCount(); ++row)
|
||||||
{
|
{
|
||||||
auto m = mIdListModel->index(row,0);
|
auto m = mIdListModel->index(row,0,QModelIndex());
|
||||||
|
|
||||||
if(ui->idTreeWidget->isExpanded( m ));
|
if(ui->idTreeWidget->isExpanded( m ))
|
||||||
|
{
|
||||||
expanded_indexes.insert( QString::number(mIdListModel->getCategory(m)));
|
expanded_indexes.insert( QString::number(mIdListModel->getCategory(m)));
|
||||||
|
|
||||||
std::cerr << "added " << QString::number(mIdListModel->getCategory(m)).toStdString() << " to expanded save" << std::endl;
|
std::cerr << "added " << QString::number(mIdListModel->getCategory(m)).toStdString() << " to expanded save" << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_NEW_FRIEND_LIST
|
#ifdef DEBUG_NEW_FRIEND_LIST
|
||||||
std::cerr << " selected index: \"" << sel.toStdString() << "\"" << std::endl;
|
std::cerr << " selected index: \"" << sel.toStdString() << "\"" << std::endl;
|
||||||
|
@ -2577,23 +2582,47 @@ void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::set<QStrin
|
||||||
const std::set<std::pair<RsIdentityListModel::EntryType,QString> >& selected_indices)
|
const std::set<std::pair<RsIdentityListModel::EntryType,QString> >& selected_indices)
|
||||||
{
|
{
|
||||||
std::cerr << "Restoring expended paths and selection..." << std::endl;
|
std::cerr << "Restoring expended paths and selection..." << std::endl;
|
||||||
#ifdef DEBUG_NEW_FRIEND_LIST
|
|
||||||
std::cerr << " index to select: \"" << index_to_select.toStdString() << "\"" << std::endl;
|
|
||||||
#endif
|
|
||||||
ui->idTreeWidget->blockSignals(true) ;
|
ui->idTreeWidget->blockSignals(true) ;
|
||||||
|
ui->idTreeWidget->selectionModel()->blockSignals(true);
|
||||||
|
|
||||||
for(int row = 0; row < mIdListModel->rowCount(); ++row)
|
ui->idTreeWidget->selectionModel()->clear();
|
||||||
{
|
|
||||||
auto m = mIdListModel->index(row,0);
|
|
||||||
|
|
||||||
if(expanded_indexes.find(QString::number(mIdListModel->getCategory(m))) != expanded_indexes.end())
|
for(auto it:selected_indices)
|
||||||
{
|
{
|
||||||
ui->idTreeWidget->setExpanded(m,true);
|
if(it.first==RsIdentityListModel::ENTRY_TYPE_CATEGORY)
|
||||||
|
ui->idTreeWidget->selectionModel()->select(mIdListModel->index(it.first,0,QModelIndex()),QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
|
else if(it.first==RsIdentityListModel::ENTRY_TYPE_IDENTITY)
|
||||||
|
{
|
||||||
|
auto indx = mIdListModel->getIndexOfIdentity(RsGxsId(it.second.toStdString()));
|
||||||
|
|
||||||
|
if(indx.isValid())
|
||||||
|
{
|
||||||
|
std::cerr << "trying to resotre selection of id " << it.second.toStdString() << std::endl;
|
||||||
|
ui->idTreeWidget->selectionModel()->select(indx,QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cerr << "Index is invalid!" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
//ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
|
|
||||||
ui->idTreeWidget->blockSignals(false) ;
|
ui->idTreeWidget->blockSignals(false) ;
|
||||||
|
ui->idTreeWidget->selectionModel()->blockSignals(false);
|
||||||
|
|
||||||
|
#ifdef DEBUG_NEW_FRIEND_LIST
|
||||||
|
std::cerr << " index to select: \"" << index_to_select.toStdString() << "\"" << std::endl;
|
||||||
|
#endif
|
||||||
|
for(int row = 0; row < mIdListModel->rowCount(); ++row)
|
||||||
|
{
|
||||||
|
auto m = mIdListModel->index(row,0,QModelIndex());
|
||||||
|
|
||||||
|
if(expanded_indexes.find(QString::number(mIdListModel->getCategory(m))) != expanded_indexes.end())
|
||||||
|
{
|
||||||
|
std::cerr << "Restoring expanded index " << QString::number(mIdListModel->getCategory(m)).toStdString() << std::endl;
|
||||||
|
ui->idTreeWidget->setExpanded(m,true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ui->idTreeWidget->setExpanded(m,false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,15 @@ RsIdentityListModel::RsIdentityListModel(QObject *parent)
|
||||||
, mLastInternalDataUpdate(0), mLastNodeUpdate(0)
|
, mLastInternalDataUpdate(0), mLastNodeUpdate(0)
|
||||||
{
|
{
|
||||||
mFilterStrings.clear();
|
mFilterStrings.clear();
|
||||||
|
mIdentityUpdateTimer = new QTimer();
|
||||||
|
connect(mIdentityUpdateTimer,SIGNAL(timeout()),this,SLOT(timerUpdate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsIdentityListModel::timerUpdate()
|
||||||
|
{
|
||||||
|
std::cerr << "updating indices" << std::endl;
|
||||||
|
emit dataChanged(index(0,0,QModelIndex()),index(2,0,QModelIndex()));
|
||||||
|
}
|
||||||
RsIdentityListModel::EntryIndex::EntryIndex()
|
RsIdentityListModel::EntryIndex::EntryIndex()
|
||||||
: type(ENTRY_TYPE_INVALID),category_index(0),identity_index(0)
|
: type(ENTRY_TYPE_INVALID),category_index(0),identity_index(0)
|
||||||
{
|
{
|
||||||
|
@ -410,6 +417,18 @@ void RsIdentityListModel::setFilter(FilterType filter_type, const QStringList& s
|
||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RsIdentityListModel::requestIdentityDetails(const RsGxsId& id,RsIdentityDetails& det) const
|
||||||
|
{
|
||||||
|
if(!rsIdentity->getIdDetails(id,det))
|
||||||
|
{
|
||||||
|
mIdentityUpdateTimer->stop();
|
||||||
|
mIdentityUpdateTimer->setSingleShot(true);
|
||||||
|
mIdentityUpdateTimer->start(500);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/) const
|
QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/) const
|
||||||
{
|
{
|
||||||
switch(fmpe.type)
|
switch(fmpe.type)
|
||||||
|
@ -422,7 +441,7 @@ QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/)
|
||||||
return QVariant(tr("This identity is owned by you"));
|
return QVariant(tr("This identity is owned by you"));
|
||||||
|
|
||||||
RsIdentityDetails det;
|
RsIdentityDetails det;
|
||||||
if(!rsIdentity->getIdDetails(id,det))
|
if(!requestIdentityDetails(id,det))
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if(det.mPgpId.isNull())
|
if(det.mPgpId.isNull())
|
||||||
|
@ -524,7 +543,7 @@ QVariant RsIdentityListModel::foregroundRole(const EntryIndex& e, int /*col*/) c
|
||||||
RsGxsId id(it->id);
|
RsGxsId id(it->id);
|
||||||
RsIdentityDetails det;
|
RsIdentityDetails det;
|
||||||
|
|
||||||
if(!rsIdentity->getIdDetails(id,det))
|
if(!requestIdentityDetails(id,det))
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if(det.mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED)
|
if(det.mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED)
|
||||||
|
@ -616,7 +635,7 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const
|
||||||
|
|
||||||
RsIdentityDetails det;
|
RsIdentityDetails det;
|
||||||
|
|
||||||
if(!rsIdentity->getIdDetails(idinfo->id,det))
|
if(!requestIdentityDetails(idinfo->id,det))
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
#ifdef DEBUG_MODEL_INDEX
|
#ifdef DEBUG_MODEL_INDEX
|
||||||
|
@ -696,6 +715,8 @@ QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) co
|
||||||
|
|
||||||
return QVariant(QIcon(sslAvatar));
|
return QVariant(QIcon(sslAvatar));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return QVariant();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ typedef uint32_t ForumModelIndex;
|
||||||
|
|
||||||
// This class is the item model used by Qt to display the information
|
// This class is the item model used by Qt to display the information
|
||||||
|
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
class RsIdentityListModel : public QAbstractItemModel
|
class RsIdentityListModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -164,6 +166,7 @@ private:
|
||||||
public slots:
|
public slots:
|
||||||
void checkInternalData(bool force);
|
void checkInternalData(bool force);
|
||||||
void debug_dump() const;
|
void debug_dump() const;
|
||||||
|
void timerUpdate();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataLoaded(); // emitted after the messages have been set. Can be used to updated the UI.
|
void dataLoaded(); // emitted after the messages have been set. Can be used to updated the UI.
|
||||||
|
@ -181,6 +184,8 @@ private:
|
||||||
void *getChildRef(void *ref,int row) const;
|
void *getChildRef(void *ref,int row) const;
|
||||||
int getChildrenCount(void *ref) const;
|
int getChildrenCount(void *ref) const;
|
||||||
|
|
||||||
|
bool requestIdentityDetails(const RsGxsId& id,RsIdentityDetails& det) const;
|
||||||
|
|
||||||
static bool convertIndexToInternalId(const EntryIndex& e,quintptr& ref);
|
static bool convertIndexToInternalId(const EntryIndex& e,quintptr& ref);
|
||||||
static bool convertInternalIdToIndex(quintptr ref, EntryIndex& e);
|
static bool convertInternalIdToIndex(quintptr ref, EntryIndex& e);
|
||||||
|
|
||||||
|
@ -209,5 +214,8 @@ private:
|
||||||
// keeps track of expanded/collapsed items, so as to only show icon for collapsed profiles
|
// keeps track of expanded/collapsed items, so as to only show icon for collapsed profiles
|
||||||
|
|
||||||
std::vector<bool> mExpandedCategories;
|
std::vector<bool> mExpandedCategories;
|
||||||
|
|
||||||
|
// List of identities for which getIdDetails() failed, to be requested again.
|
||||||
|
mutable QTimer *mIdentityUpdateTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue