mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-22 22:21:09 -04:00
added new folder capability in collection
This commit is contained in:
parent
27f0962654
commit
a36f7221e7
6 changed files with 49 additions and 12 deletions
|
@ -144,9 +144,9 @@ static QString purifyFileName(const QString& input,bool& bad)
|
||||||
return output ;
|
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
|
#ifdef TO_REMOVE
|
||||||
ColFileInfo info ;
|
ColFileInfo info ;
|
||||||
info.type = DIR_TYPE_FILE ;
|
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) ;
|
recursAddElements(_xml_doc,info,_root) ;
|
||||||
#endif
|
#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)
|
void RsCollection::recursMergeTree(RsFileTree::DirIndex parent,const RsFileTree& tree,const RsFileTree::DirData& dd)
|
||||||
|
|
|
@ -77,8 +77,8 @@ public:
|
||||||
|
|
||||||
virtual ~RsCollection() ;
|
virtual ~RsCollection() ;
|
||||||
|
|
||||||
void merge_in(const QString& fname,uint64_t size,const RsFileHash& hash) ;
|
void merge_in(const QString& fname,uint64_t size,const RsFileHash& hash,RsFileTree::DirIndex parent_index=0) ;
|
||||||
void merge_in(const RsFileTree& tree) ;
|
void merge_in(const RsFileTree& tree,RsFileTree::DirIndex parent_index=0) ;
|
||||||
|
|
||||||
static const QString ExtensionString ;
|
static const QString ExtensionString ;
|
||||||
|
|
||||||
|
|
|
@ -1132,6 +1132,32 @@ void RsCollectionDialog::processItem(QMap<QString, QString> &dirToAdd
|
||||||
*/
|
*/
|
||||||
void RsCollectionDialog::makeDir()
|
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
|
#ifdef TODO_COLLECTION
|
||||||
QString childName="";
|
QString childName="";
|
||||||
bool ok, badChar, nameOK = false;
|
bool ok, badChar, nameOK = false;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>671</width>
|
<width>761</width>
|
||||||
<height>400</height>
|
<height>434</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
|
@ -283,7 +283,7 @@
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../images.qrc">
|
<iconset resource="../images.qrc">
|
||||||
<normaloff>:/images/feedback_arrow.png</normaloff>:/images/feedback_arrow.png</iconset>
|
<normaloff>:/images/start.png</normaloff>:/images/start.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -309,7 +309,7 @@
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../images.qrc">
|
<iconset resource="../images.qrc">
|
||||||
<normaloff>:/images/update.png</normaloff>:/images/update.png</iconset>
|
<normaloff>:/images/startall.png</normaloff>:/images/startall.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -334,8 +334,8 @@
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="../images.qrc">
|
||||||
<normaloff>:/images/deletemail24.png</normaloff>:/images/deletemail24.png</iconset>
|
<normaloff>:/images/delete.png</normaloff>:/images/delete.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -438,6 +438,15 @@ QVariant RsCollectionModel::decorationRole(const EntryIndex& i,int col) const
|
||||||
return QVariant();
|
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)
|
bool RsCollectionModel::isChecked(EntryIndex i)
|
||||||
{
|
{
|
||||||
if(i.is_file)
|
if(i.is_file)
|
||||||
|
|
|
@ -51,6 +51,8 @@ class RsCollectionModel: public QAbstractItemModel
|
||||||
void notifyFilesBeingHashed(const std::list<RsFileHash>& files);
|
void notifyFilesBeingHashed(const std::list<RsFileHash>& files);
|
||||||
void fileHashingFinished(const RsFileHash& hash);
|
void fileHashingFinished(const RsFileHash& hash);
|
||||||
bool isChecked(EntryIndex);
|
bool isChecked(EntryIndex);
|
||||||
|
|
||||||
|
EntryIndex getIndex(const QModelIndex& i) const;
|
||||||
signals:
|
signals:
|
||||||
void sizesChanged(); // tells that the total size of the top level dir has changed (due to selection)
|
void sizesChanged(); // tells that the total size of the top level dir has changed (due to selection)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue