mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
various improvements to collection links
This commit is contained in:
parent
9206daca37
commit
32be00614d
@ -71,11 +71,12 @@ void FileTreeImpl::recurs_buildFileTree(FileTreeImpl& ft,uint32_t index,const Di
|
||||
std::cerr << "(EE) Cannot request dir details for pointer " << dd.children[i].ref << std::endl;
|
||||
}
|
||||
|
||||
bool FileTreeImpl::getDirectoryContent(uint32_t index,std::vector<uint32_t>& subdirs,std::vector<FileData>& subfiles) const
|
||||
bool FileTreeImpl::getDirectoryContent(uint32_t index,std::string& name,std::vector<uint32_t>& subdirs,std::vector<FileData>& subfiles) const
|
||||
{
|
||||
if(index >= mDirs.size())
|
||||
return false ;
|
||||
|
||||
name = mDirs[index].name;
|
||||
subdirs = mDirs[index].subdirs ;
|
||||
|
||||
subfiles.clear() ;
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
}
|
||||
|
||||
virtual std::string toRadix64() const ;
|
||||
virtual bool getDirectoryContent(uint32_t index,std::vector<uint32_t>& subdirs,std::vector<FileData>& subfiles) const ;
|
||||
virtual bool getDirectoryContent(uint32_t index,std::string& name,std::vector<uint32_t>& subdirs,std::vector<FileData>& subfiles) const ;
|
||||
virtual void print() const ;
|
||||
|
||||
bool serialise(unsigned char *& data,uint32_t& data_size) const ;
|
||||
|
@ -158,7 +158,7 @@ public:
|
||||
};
|
||||
|
||||
virtual uint32_t root() const { return 0;}
|
||||
virtual bool getDirectoryContent(uint32_t index,std::vector<uint32_t>& subdirs,std::vector<FileData>& subfiles) const = 0;
|
||||
virtual bool getDirectoryContent(uint32_t index,std::string& name,std::vector<uint32_t>& subdirs,std::vector<FileData>& subfiles) const = 0;
|
||||
|
||||
virtual void print() const=0;
|
||||
|
||||
|
@ -1014,6 +1014,7 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
||||
switch (type) {
|
||||
case DIR_TYPE_DIR :
|
||||
contextMnu.addAction(openfolderAct) ;
|
||||
contextMnu.addAction(copylinkAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addMenu(&collectionMenu) ;
|
||||
break ;
|
||||
|
@ -1393,10 +1393,12 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
|
||||
case TYPE_COLLECTION:
|
||||
{
|
||||
//FileHierarchy fh ;
|
||||
//fh.initFromRadix(_radix);
|
||||
FileTree *ft = FileTree::create(_radix.toStdString()) ;
|
||||
|
||||
QMessageBox::information(NULL,"Unimplemented code","File collection links not handled yet.") ;
|
||||
RsCollectionEditor colled(*ft,NULL) ;
|
||||
colled.exec();
|
||||
|
||||
delete ft;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -43,6 +43,15 @@ RsCollectionEditor::RsCollectionEditor(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
RsCollectionEditor::RsCollectionEditor(const FileTree& fr, QObject *parent)
|
||||
: QObject(parent), _xml_doc("RsCollection")
|
||||
{
|
||||
QDomElement root = _xml_doc.createElement("RsCollection");
|
||||
_xml_doc.appendChild(root);
|
||||
|
||||
recursAddElements(_xml_doc,fr,0,root) ;
|
||||
}
|
||||
|
||||
RsCollectionEditor::RsCollectionEditor(const std::vector<DirDetails>& file_infos, QObject *parent)
|
||||
: QObject(parent), _xml_doc("RsCollection")
|
||||
{
|
||||
@ -202,6 +211,34 @@ void RsCollectionEditor::recursAddElements(QDomDocument& doc,const ColFileInfo&
|
||||
}
|
||||
}
|
||||
|
||||
void RsCollectionEditor::recursAddElements(QDomDocument& doc,const FileTree& ft,uint32_t index,QDomElement& e) const
|
||||
{
|
||||
std::vector<uint32_t> subdirs ;
|
||||
std::vector<FileTree::FileData> subfiles ;
|
||||
std::string name;
|
||||
|
||||
if(!ft.getDirectoryContent(index,name,subdirs,subfiles))
|
||||
return ;
|
||||
|
||||
QDomElement d = doc.createElement("Directory") ;
|
||||
d.setAttribute(QString::fromUtf8()("name"),QString::fromUtf8(name.c_str())) ;
|
||||
e.appendChild(d) ;
|
||||
|
||||
for (uint32_t i=0;i<subdirs.size();++i)
|
||||
recursAddElements(doc,ft,subdirs[i],d) ;
|
||||
|
||||
for(uint32_t i=0;i<subfiles.size();++i)
|
||||
{
|
||||
QDomElement f = doc.createElement("File") ;
|
||||
|
||||
f.setAttribute(QString("name"),QString::fromUtf8(subfiles[i].name.c_str())) ;
|
||||
f.setAttribute(QString("sha1"),QString::fromStdString(subfiles[i].hash)) ;
|
||||
f.setAttribute(QString("size"),QString::number(subfiles[i].size)) ;
|
||||
|
||||
e.appendChild(f) ;
|
||||
}
|
||||
}
|
||||
|
||||
static void showErrorBox(const QString& fileName, const QString& error)
|
||||
{
|
||||
QMessageBox mb(QMessageBox::Warning, QObject::tr("Failed to process collection file"), QObject::tr("The collection file %1 could not be opened.\nReported error is: \n\n%2").arg(fileName).arg(error), QMessageBox::Ok);
|
||||
@ -306,6 +343,10 @@ bool RsCollectionEditor::checkFile(const QString& fileName, bool showError)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RsCollectionEditor::load(const FileTree& f)
|
||||
{
|
||||
}
|
||||
|
||||
bool RsCollectionEditor::load(QWidget *parent)
|
||||
{
|
||||
QString fileName;
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
RsCollectionEditor(QObject *parent = 0) ;
|
||||
// create from list of files and directories
|
||||
RsCollectionEditor(const std::vector<DirDetails>& file_entries, QObject *parent = 0) ;
|
||||
RsCollectionEditor(const FileTree& fr, QObject *parent);
|
||||
virtual ~RsCollectionEditor() ;
|
||||
|
||||
static const QString ExtensionString ;
|
||||
@ -75,6 +76,9 @@ public:
|
||||
bool load(QWidget *parent);
|
||||
bool load(const QString& fileName, bool showError = true);
|
||||
|
||||
// Loads from FileTree
|
||||
bool load(const FileTree& f);
|
||||
|
||||
// Save to disk
|
||||
bool save(QWidget *parent) const ;
|
||||
bool save(const QString& fileName) const ;
|
||||
|
Loading…
Reference in New Issue
Block a user