From a02d2e63e2ed7f2e3d0c56fd5a6e14fd2c71ed9b Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 20 Mar 2024 21:00:42 +0100 Subject: [PATCH] fixed updating save filename, removal of files/dirs, and cleaning before save --- retroshare-gui/src/gui/common/RsCollection.cpp | 4 ++++ .../src/gui/common/RsCollectionDialog.cpp | 14 ++++++++++---- .../src/gui/common/RsCollectionDialog.ui | 7 ++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/common/RsCollection.cpp b/retroshare-gui/src/gui/common/RsCollection.cpp index 2624dd246..01d6f7dc1 100644 --- a/retroshare-gui/src/gui/common/RsCollection.cpp +++ b/retroshare-gui/src/gui/common/RsCollection.cpp @@ -681,5 +681,9 @@ bool RsCollection::removeDirectory(RsFileTree::DirIndex index_to_remove,RsFileTr void RsCollection::cleanup() { + RsDbg() << "Cleaning up RsCollection with " << mFileTree->numDirs() << " dirs and " << mFileTree->numFiles() << " files." ; + mFileTree = RsFileTree::fromTreeCleaned(*mFileTree); + + RsDbg() << "Simplified to " << mFileTree->numDirs() << " dirs and " << mFileTree->numFiles() << " files."; } diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index 5269cb988..ba4d5a118 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -125,7 +125,7 @@ protected: * @param readOnly: Open dialog for RsColl as ReadOnly */ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName, RsCollectionDialogMode mode) - : _fileName(collectionFileName), _mode(mode) + : _mode(mode) { RsCollection::RsCollectionErrorCode err_code; mCollection = new RsCollection(collectionFileName,err_code); @@ -137,6 +137,7 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName, RsColl } ui.setupUi(this) ; + ui._filename_TL->setText(collectionFileName); // uint32_t size = colFileInfos.size(); // for(uint32_t i=0;isetHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/collections.png")); @@ -719,7 +720,7 @@ void RsCollectionDialog::changeFileName() file.remove(); } - _fileName = fileName; + ui._filename_TL->setText(fileName); updateList(); } @@ -1559,9 +1560,14 @@ void RsCollectionDialog::download() */ void RsCollectionDialog::save() { + if(ui._filename_TL->text().isNull()) + changeFileName(); + if(ui._filename_TL->text().isNull()) + return; + mCollectionModel->preMods(); mCollection->cleanup(); - mCollection->save(_fileName); + mCollection->save(ui._filename_TL->text()); close(); #ifdef TO_REMOVE std::cerr << "Saving!" << std::endl; diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.ui b/retroshare-gui/src/gui/common/RsCollectionDialog.ui index 96fe8b399..8871536a2 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.ui +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.ui @@ -157,7 +157,7 @@ - + 21 @@ -170,6 +170,10 @@ ... + + + :/icons/browsable_blue_128.png:/icons/browsable_blue_128.png + @@ -512,6 +516,7 @@ +