From 06d9ea2398c1b75dae2bccd7e16ae0186fac6650 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 1 Mar 2025 20:57:32 +0100 Subject: [PATCH] enabled processSettings --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 71 ++++++++++--------- .../src/gui/Identity/IdentityListModel.cpp | 27 ++++--- .../src/gui/Identity/IdentityListModel.h | 9 +-- 3 files changed, 54 insertions(+), 53 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 8bbcd39d5..b6a365ab7 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1297,41 +1297,42 @@ static QString getHumanReadableDuration(uint32_t seconds) void IdDialog::processSettings(bool load) { -#warning TODO -// Settings->beginGroup("IdDialog"); -// -// // state of peer tree -// ui->idTreeWidget->processSettings(load); -// -// if (load) { -// // load settings -// -// // filterColumn -// ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RSID_COL_NICKNAME).toInt()); -// -// // state of splitter -// ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray()); -// -// //Restore expanding -// allItem->setExpanded(Settings->value("ExpandAll", QVariant(true)).toBool()); -// ownItem->setExpanded(Settings->value("ExpandOwn", QVariant(true)).toBool()); -// contactsItem->setExpanded(Settings->value("ExpandContacts", QVariant(true)).toBool()); -// } else { -// // save settings -// -// // filterColumn -// Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); -// -// // state of splitter -// Settings->setValue("splitter", ui->mainSplitter->saveState()); -// -// //save expanding -// Settings->setValue("ExpandAll", allItem->isExpanded()); -// Settings->setValue("ExpandContacts", contactsItem->isExpanded()); -// Settings->setValue("ExpandOwn", ownItem->isExpanded()); -// } -// -// Settings->endGroup(); + Settings->beginGroup("IdDialog"); + + // state of peer tree + // ui->idTreeWidget->processSettings(load); + + if (load) { + // load settings + + // filterColumn + ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RsIdentityListModel::COLUMN_THREAD_NAME).toInt()); + + // state of splitter + ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray()); + + //Restore expanding + ui->idTreeWidget->setExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_ALL),Settings->value("ExpandAll", QVariant(true)).toBool()); + ui->idTreeWidget->setExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_OWN),Settings->value("ExpandOwn", QVariant(true)).toBool()); + ui->idTreeWidget->setExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_CTS),Settings->value("ExpandContacts", QVariant(true)).toBool()); + } + else + { + // save settings + + // filterColumn + Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); + + // state of splitter + Settings->setValue("splitter", ui->mainSplitter->saveState()); + + //save expanding + Settings->setValue("ExpandAll", ui->idTreeWidget->isExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_ALL))); + Settings->setValue("ExpandContacts", ui->idTreeWidget->isExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_OWN))); + Settings->setValue("ExpandOwn", ui->idTreeWidget->isExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_CTS))); + } + + Settings->endGroup(); } void IdDialog::filterChanged(const QString& /*text*/) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 73c87ad58..e97a0d1dc 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -527,6 +527,18 @@ QModelIndex RsIdentityListModel::getIndexOfIdentity(const RsGxsId& id) const } return QModelIndex(); } + +QModelIndex RsIdentityListModel::getIndexOfCategory(Category id) const +{ + EntryIndex e; + e.category_index = id; + e.type = ENTRY_TYPE_CATEGORY; + + quintptr idx; + convertIndexToInternalId(e,idx); + + return createIndex((int)id,0,idx); +} QVariant RsIdentityListModel::foregroundRole(const EntryIndex& e, int /*col*/) const { auto it = getIdentityInfo(e); @@ -900,18 +912,5 @@ void RsIdentityListModel::expandItem(const QModelIndex& index) emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mCategories.size()-1,columnCount()-1,(void*)NULL)); } -bool RsIdentityListModel::isCategoryExpanded(const EntryIndex& e) const -{ - return true; -#warning TODO -// if(e.type != ENTRY_TYPE_CATEGORY) -// return false; -// -// EntryIndex entry; -// -// if(!convertInternalIdToIndex(e.internalId(),entry)) -// return false; -// -// return mExpandedCategories[entry.category_index]; -} + diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 74cea02a9..00b346803 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -69,9 +69,10 @@ public: ENTRY_TYPE_INVALID = 0x03 }; - static const int CATEGORY_OWN = 0x00; - static const int CATEGORY_CTS = 0x01; - static const int CATEGORY_ALL = 0x02; + enum Category{ CATEGORY_OWN = 0x00, + CATEGORY_CTS = 0x01, + CATEGORY_ALL = 0x02 + }; struct HierarchicalCategoryInformation { @@ -107,6 +108,7 @@ public: QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;} QModelIndex getIndexOfIdentity(const RsGxsId& id) const; + QModelIndex getIndexOfCategory(Category id) const; void updateIdentityList(); @@ -146,7 +148,6 @@ private: const HierarchicalCategoryInformation *getCategoryInfo (const EntryIndex&) const; const HierarchicalIdentityInformation *getIdentityInfo(const EntryIndex&) const; - bool isCategoryExpanded(const EntryIndex& e) const; void checkIdentity(HierarchicalIdentityInformation& node); QVariant sizeHintRole (const EntryIndex& e, int col) const;