diff --git a/retroshare-gui/src/gui/common/RsCollection.cpp b/retroshare-gui/src/gui/common/RsCollection.cpp index 644d94fc0..e86817d06 100644 --- a/retroshare-gui/src/gui/common/RsCollection.cpp +++ b/retroshare-gui/src/gui/common/RsCollection.cpp @@ -144,9 +144,9 @@ static QString purifyFileName(const QString& input,bool& bad) return output ; } -void RsCollection::merge_in(const QString& fname,uint64_t size,const RsFileHash& hash) +void RsCollection::merge_in(const QString& fname,uint64_t size,const RsFileHash& hash,RsFileTree::DirIndex parent_index) { - mHashes[hash]= mFileTree->addFile(mFileTree->root(),fname.toStdString(),hash,size); + mHashes[hash]= mFileTree->addFile(parent_index,fname.toStdString(),hash,size); #ifdef TO_REMOVE ColFileInfo info ; info.type = DIR_TYPE_FILE ; @@ -157,9 +157,9 @@ void RsCollection::merge_in(const QString& fname,uint64_t size,const RsFileHash& recursAddElements(_xml_doc,info,_root) ; #endif } -void RsCollection::merge_in(const RsFileTree& tree) +void RsCollection::merge_in(const RsFileTree& tree, RsFileTree::DirIndex parent_index) { - recursMergeTree(mFileTree->root(),tree,tree.directoryData(tree.root())) ; + recursMergeTree(mFileTree->root(),tree,tree.directoryData(parent_index)) ; } void RsCollection::recursMergeTree(RsFileTree::DirIndex parent,const RsFileTree& tree,const RsFileTree::DirData& dd) diff --git a/retroshare-gui/src/gui/common/RsCollection.h b/retroshare-gui/src/gui/common/RsCollection.h index bc9ff2a28..5e3180c8c 100644 --- a/retroshare-gui/src/gui/common/RsCollection.h +++ b/retroshare-gui/src/gui/common/RsCollection.h @@ -77,8 +77,8 @@ public: virtual ~RsCollection() ; - void merge_in(const QString& fname,uint64_t size,const RsFileHash& hash) ; - void merge_in(const RsFileTree& tree) ; + void merge_in(const QString& fname,uint64_t size,const RsFileHash& hash,RsFileTree::DirIndex parent_index=0) ; + void merge_in(const RsFileTree& tree,RsFileTree::DirIndex parent_index=0) ; static const QString ExtensionString ; diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index 8b52d6ed7..1e5998427 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -1132,6 +1132,32 @@ void RsCollectionDialog::processItem(QMap &dirToAdd */ void RsCollectionDialog::makeDir() { + QModelIndexList selected_indices = ui._fileEntriesTW->selectionModel()->selectedIndexes(); + + if(selected_indices.size() > 1) + { + QMessageBox::information(nullptr,tr("Too many places selected"),tr("Please select at most one directory where to create the new folder")); + return; + } + + QModelIndex place_index; + + if(!selected_indices.empty()) + place_index = selected_indices.first(); + + RsCollectionModel::EntryIndex e = mCollectionModel->getIndex(place_index); + + if(e.is_file) + { + QMessageBox::information(nullptr,tr("Selected place cannot be a file"),tr("Please select at most one directory where to create the new folder")); + return; + } + QString childName = QInputDialog::getText(this, tr("New Directory"), tr("Enter the new directory's name"), QLineEdit::Normal); + + mCollectionModel->preMods(); + mCollection->merge_in(*RsFileTree::fromDirectory(childName.toUtf8().constData()),e.index); + mCollectionModel->postMods(); + #ifdef TODO_COLLECTION QString childName=""; bool ok, badChar, nameOK = false; diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.ui b/retroshare-gui/src/gui/common/RsCollectionDialog.ui index 7d4de185b..96fe8b399 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.ui +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.ui @@ -6,8 +6,8 @@ 0 0 - 671 - 400 + 761 + 434 @@ -283,7 +283,7 @@ - :/images/feedback_arrow.png:/images/feedback_arrow.png + :/images/start.png:/images/start.png @@ -309,7 +309,7 @@ - :/images/update.png:/images/update.png + :/images/startall.png:/images/startall.png @@ -334,8 +334,8 @@ - - :/images/deletemail24.png:/images/deletemail24.png + + :/images/delete.png:/images/delete.png diff --git a/retroshare-gui/src/gui/common/RsCollectionModel.cpp b/retroshare-gui/src/gui/common/RsCollectionModel.cpp index 8aa83f080..16a2e473d 100644 --- a/retroshare-gui/src/gui/common/RsCollectionModel.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionModel.cpp @@ -438,6 +438,15 @@ QVariant RsCollectionModel::decorationRole(const EntryIndex& i,int col) const return QVariant(); } +RsCollectionModel::EntryIndex RsCollectionModel::getIndex(const QModelIndex& i) const +{ + EntryIndex res; + res.is_file = false; + res.index = 0; + + convertInternalIdToIndex(i.internalId(),res); + return res; +} bool RsCollectionModel::isChecked(EntryIndex i) { if(i.is_file) diff --git a/retroshare-gui/src/gui/common/RsCollectionModel.h b/retroshare-gui/src/gui/common/RsCollectionModel.h index f34b0d39e..705c3fc3b 100644 --- a/retroshare-gui/src/gui/common/RsCollectionModel.h +++ b/retroshare-gui/src/gui/common/RsCollectionModel.h @@ -51,6 +51,8 @@ class RsCollectionModel: public QAbstractItemModel void notifyFilesBeingHashed(const std::list& files); void fileHashingFinished(const RsFileHash& hash); bool isChecked(EntryIndex); + + EntryIndex getIndex(const QModelIndex& i) const; signals: void sizesChanged(); // tells that the total size of the top level dir has changed (due to selection)