mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-27 00:15:51 -04:00
added proper remove for files/dirs
This commit is contained in:
parent
a36f7221e7
commit
2ebd7617fc
3 changed files with 40 additions and 0 deletions
|
@ -670,4 +670,16 @@ void RsCollection::saveColl(std::vector<ColFileInfo> colFileInfos, const QString
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool RsCollection::removeFile(RsFileTree::FileIndex index_to_remove,RsFileTree::DirIndex parent_index)
|
||||||
|
{
|
||||||
|
mFileTree->removeFile(index_to_remove,parent_index);
|
||||||
|
}
|
||||||
|
bool RsCollection::removeDirectory(RsFileTree::DirIndex index_to_remove,RsFileTree::DirIndex parent_index)
|
||||||
|
{
|
||||||
|
mFileTree->removeDirectory(index_to_remove,parent_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsCollection::cleanup()
|
||||||
|
{
|
||||||
|
mFileTree = RsFileTree::fromTreeCleaned(*mFileTree);
|
||||||
|
}
|
||||||
|
|
|
@ -80,6 +80,11 @@ public:
|
||||||
void merge_in(const QString& fname,uint64_t size,const RsFileHash& hash,RsFileTree::DirIndex parent_index=0) ;
|
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) ;
|
void merge_in(const RsFileTree& tree,RsFileTree::DirIndex parent_index=0) ;
|
||||||
|
|
||||||
|
bool removeFile(RsFileTree::FileIndex index_to_remove,RsFileTree::DirIndex parent_index);
|
||||||
|
bool removeDirectory(RsFileTree::DirIndex index_to_remove,RsFileTree::DirIndex parent_index);
|
||||||
|
|
||||||
|
void cleanup(); // cleans up the collection, which may contain unreferenced files/dirs after lazy editing.
|
||||||
|
|
||||||
static const QString ExtensionString ;
|
static const QString ExtensionString ;
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
#ifdef TO_REMOVE
|
||||||
|
|
|
@ -954,6 +954,27 @@ bool RsCollectionDialog::addAllChild(QFileInfo &fileInfoParent
|
||||||
*/
|
*/
|
||||||
void RsCollectionDialog::remove()
|
void RsCollectionDialog::remove()
|
||||||
{
|
{
|
||||||
|
QMap<QString, QString > dirToRemove;
|
||||||
|
int count=0;//to not scan all items on list .count()
|
||||||
|
|
||||||
|
QModelIndexList milSelectionList = ui._fileEntriesTW->selectionModel()->selectedIndexes();
|
||||||
|
|
||||||
|
mCollectionModel->preMods();
|
||||||
|
|
||||||
|
foreach (QModelIndex index, milSelectionList)
|
||||||
|
if(index.column()==0) //Get only FileName
|
||||||
|
{
|
||||||
|
auto indx = mCollectionModel->getIndex(index);
|
||||||
|
auto parent_indx = mCollectionModel->getIndex(index.parent());
|
||||||
|
|
||||||
|
if(indx.is_file)
|
||||||
|
mCollection->removeFile(indx.index,parent_indx.index);
|
||||||
|
else
|
||||||
|
mCollection->removeDirectory(indx.index,parent_indx.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
mCollectionModel->postMods();
|
||||||
|
|
||||||
#ifdef TODO_COLLECTION
|
#ifdef TODO_COLLECTION
|
||||||
bool removeOnlyFile=false;
|
bool removeOnlyFile=false;
|
||||||
QString listDir;
|
QString listDir;
|
||||||
|
@ -1538,6 +1559,8 @@ void RsCollectionDialog::download()
|
||||||
*/
|
*/
|
||||||
void RsCollectionDialog::save()
|
void RsCollectionDialog::save()
|
||||||
{
|
{
|
||||||
|
mCollectionModel->preMods();
|
||||||
|
mCollection->cleanup();
|
||||||
mCollection->save(_fileName);
|
mCollection->save(_fileName);
|
||||||
close();
|
close();
|
||||||
#ifdef TO_REMOVE
|
#ifdef TO_REMOVE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue