mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 00:19:30 -05:00
started adapting RsCollectionDialog to the new API of RsCollection
This commit is contained in:
parent
206da93d99
commit
5071656209
@ -30,7 +30,7 @@
|
|||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "retroshare-gui/RsAutoUpdatePage.h"
|
#include "retroshare-gui/RsAutoUpdatePage.h"
|
||||||
#include "gui/msgs/MessageComposer.h"
|
#include "gui/msgs/MessageComposer.h"
|
||||||
#include "gui/common/RsCollection.h"
|
#include "gui/common/RsCollectionDialog.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
#include "gui/common/RsUrlHandler.h"
|
#include "gui/common/RsUrlHandler.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
@ -542,12 +542,8 @@ void SearchDialog::collModif()
|
|||||||
/* open file with a suitable application */
|
/* open file with a suitable application */
|
||||||
QFileInfo qinfo;
|
QFileInfo qinfo;
|
||||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||||
if (qinfo.exists()) {
|
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||||
if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) {
|
RsCollectionDialog::openExistingCollection(qinfo.absoluteFilePath());
|
||||||
RsCollection collection;
|
|
||||||
collection.openColl(qinfo.absoluteFilePath());
|
|
||||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
|
||||||
}//if (qinfo.exists())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchDialog::collView()
|
void SearchDialog::collView()
|
||||||
@ -574,12 +570,8 @@ void SearchDialog::collView()
|
|||||||
/* open file with a suitable application */
|
/* open file with a suitable application */
|
||||||
QFileInfo qinfo;
|
QFileInfo qinfo;
|
||||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||||
if (qinfo.exists()) {
|
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||||
if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) {
|
RsCollectionDialog::openExistingCollection(qinfo.absoluteFilePath(), true);
|
||||||
RsCollection collection;
|
|
||||||
collection.openColl(qinfo.absoluteFilePath(), true);
|
|
||||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
|
||||||
}//if (qinfo.exists())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchDialog::collOpen()
|
void SearchDialog::collOpen()
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "gui/ShareManager.h"
|
#include "gui/ShareManager.h"
|
||||||
#include "gui/common/PeerDefs.h"
|
#include "gui/common/PeerDefs.h"
|
||||||
#include "gui/common/RsCollection.h"
|
#include "gui/common/RsCollectionDialog.h"
|
||||||
#include "gui/msgs/MessageComposer.h"
|
#include "gui/msgs/MessageComposer.h"
|
||||||
#include "gui/gxschannels/GxsChannelDialog.h"
|
#include "gui/gxschannels/GxsChannelDialog.h"
|
||||||
#include "gui/gxsforums/GxsForumsDialog.h"
|
#include "gui/gxsforums/GxsForumsDialog.h"
|
||||||
@ -759,12 +759,8 @@ void SharedFilesDialog::collModif()
|
|||||||
/* open file with a suitable application */
|
/* open file with a suitable application */
|
||||||
QFileInfo qinfo;
|
QFileInfo qinfo;
|
||||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||||
if (qinfo.exists()) {
|
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||||
if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) {
|
RsCollectionDialog::openExistingCollection(qinfo.absoluteFilePath());
|
||||||
RsCollection collection;
|
|
||||||
collection.openColl(qinfo.absoluteFilePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedFilesDialog::collView()
|
void SharedFilesDialog::collView()
|
||||||
@ -789,12 +785,8 @@ void SharedFilesDialog::collView()
|
|||||||
/* open file with a suitable application */
|
/* open file with a suitable application */
|
||||||
QFileInfo qinfo;
|
QFileInfo qinfo;
|
||||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||||
if (qinfo.exists()) {
|
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||||
if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) {
|
RsCollectionDialog::openExistingCollection(qinfo.absoluteFilePath(), true);
|
||||||
RsCollection collection;
|
|
||||||
collection.openColl(qinfo.absoluteFilePath(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedFilesDialog::collOpen()
|
void SharedFilesDialog::collOpen()
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "gui/SoundManager.h"
|
#include "gui/SoundManager.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
#include "gui/common/RsCollection.h"
|
#include "gui/common/RsCollectionDialog.h"
|
||||||
#include "gui/common/RSTreeView.h"
|
#include "gui/common/RSTreeView.h"
|
||||||
#include "gui/common/RsUrlHandler.h"
|
#include "gui/common/RsUrlHandler.h"
|
||||||
#include "gui/FileTransfer/DetailsDialog.h"
|
#include "gui/FileTransfer/DetailsDialog.h"
|
||||||
@ -2466,21 +2466,17 @@ void TransfersDialog::collCreate()
|
|||||||
std::set<RsFileHash>::iterator it ;
|
std::set<RsFileHash>::iterator it ;
|
||||||
getDLSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
|
RsFileTree tree;
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); ++it)
|
for (it = items.begin(); it != items.end(); ++it)
|
||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
|
|
||||||
DirDetails details;
|
tree.addFile(tree.root(),info.fname,info.hash,info.size);
|
||||||
details.name = info.fname;
|
|
||||||
details.hash = info.hash;
|
|
||||||
details.size = info.size;
|
|
||||||
details.type = DIR_TYPE_FILE;
|
|
||||||
|
|
||||||
dirVec.push_back(details);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RsCollection(dirVec,RS_FILE_HINTS_LOCAL).openNewColl(this);
|
RsCollectionDialog::openNewCollection(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::collModif()
|
void TransfersDialog::collModif()
|
||||||
@ -2504,12 +2500,8 @@ void TransfersDialog::collModif()
|
|||||||
/* open collection */
|
/* open collection */
|
||||||
QFileInfo qinfo;
|
QFileInfo qinfo;
|
||||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||||
if (qinfo.exists()) {
|
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||||
if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) {
|
RsCollectionDialog::openExistingCollection(qinfo.absoluteFilePath());
|
||||||
RsCollection collection;
|
|
||||||
collection.openColl(qinfo.absoluteFilePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2534,12 +2526,8 @@ void TransfersDialog::collView()
|
|||||||
/* open collection */
|
/* open collection */
|
||||||
QFileInfo qinfo;
|
QFileInfo qinfo;
|
||||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||||
if (qinfo.exists()) {
|
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||||
if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) {
|
RsCollectionDialog::openExistingCollection(qinfo.absoluteFilePath(), true);
|
||||||
RsCollection collection;
|
|
||||||
collection.openColl(qinfo.absoluteFilePath(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@
|
|||||||
#include "gui/statistics/StatisticsWindow.h"
|
#include "gui/statistics/StatisticsWindow.h"
|
||||||
|
|
||||||
#include "gui/connect/ConnectFriendWizard.h"
|
#include "gui/connect/ConnectFriendWizard.h"
|
||||||
#include "gui/common/RsCollection.h"
|
#include "gui/common/RsCollectionDialog.h"
|
||||||
#include "settings/rsettingswin.h"
|
#include "settings/rsettingswin.h"
|
||||||
#include "settings/rsharesettings.h"
|
#include "settings/rsharesettings.h"
|
||||||
#include "common/StatusDefs.h"
|
#include "common/StatusDefs.h"
|
||||||
@ -1623,12 +1623,8 @@ void MainWindow::retroshareLinkActivated(const QUrl &url)
|
|||||||
void MainWindow::openRsCollection(const QString &filename)
|
void MainWindow::openRsCollection(const QString &filename)
|
||||||
{
|
{
|
||||||
QFileInfo qinfo(filename);
|
QFileInfo qinfo(filename);
|
||||||
if (qinfo.exists()) {
|
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||||
if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) {
|
RsCollectionDialog::openExistingCollection(qinfo.absoluteFilePath());
|
||||||
RsCollection collection;
|
|
||||||
collection.openColl(qinfo.absoluteFilePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::processLastArgs()
|
void MainWindow::processLastArgs()
|
||||||
|
@ -615,89 +615,7 @@ bool RsCollection::save(QWidget *parent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RsCollection::openNewColl(QWidget *parent, QString fileName)
|
|
||||||
{
|
|
||||||
if(!misc::getSaveFileName(parent, RshareSettings::LASTDIR_EXTRAFILE
|
|
||||||
, QApplication::translate("RsCollectionFile", "Create collection file")
|
|
||||||
, QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollection::ExtensionString + ")"
|
|
||||||
, fileName,0, QFileDialog::DontConfirmOverwrite))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!fileName.endsWith("." + RsCollection::ExtensionString))
|
|
||||||
fileName += "." + RsCollection::ExtensionString ;
|
|
||||||
|
|
||||||
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
|
|
||||||
|
|
||||||
QFile file(fileName) ;
|
|
||||||
|
|
||||||
if(file.exists())
|
|
||||||
{
|
|
||||||
if (!checkFile(fileName,true)) return false;
|
|
||||||
|
|
||||||
QMessageBox mb;
|
|
||||||
mb.setText(tr("Save Collection File."));
|
|
||||||
mb.setInformativeText(tr("File already exists.")+"\n"+tr("What do you want to do?"));
|
|
||||||
QAbstractButton *btnOwerWrite = mb.addButton(tr("Overwrite"), QMessageBox::YesRole);
|
|
||||||
QAbstractButton *btnMerge = mb.addButton(tr("Merge"), QMessageBox::NoRole);
|
|
||||||
QAbstractButton *btnCancel = mb.addButton(tr("Cancel"), QMessageBox::ResetRole);
|
|
||||||
mb.setIcon(QMessageBox::Question);
|
|
||||||
mb.exec();
|
|
||||||
|
|
||||||
if (mb.clickedButton()==btnOwerWrite) {
|
|
||||||
//Nothing to do _xml_doc already up to date
|
|
||||||
} else if (mb.clickedButton()==btnMerge) {
|
|
||||||
//Open old file to merge it with _xml_doc
|
|
||||||
QDomDocument qddOldFile("RsCollection");
|
|
||||||
if (qddOldFile.setContent(&file)) {
|
|
||||||
QDomElement docOldElem = qddOldFile.elementsByTagName("RsCollection").at(0).toElement();
|
|
||||||
std::vector<ColFileInfo> colOldFileInfos;
|
|
||||||
recursCollectColFileInfos(docOldElem,colOldFileInfos,QString(),false);
|
|
||||||
|
|
||||||
QDomElement root = _xml_doc.elementsByTagName("RsCollection").at(0).toElement();
|
|
||||||
for(uint32_t i = 0;i<colOldFileInfos.size();++i){
|
|
||||||
recursAddElements(_xml_doc,colOldFileInfos[i],root) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (mb.clickedButton()==btnCancel) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//if(file.exists())
|
|
||||||
|
|
||||||
_fileName=fileName;
|
|
||||||
std::vector<ColFileInfo> colFileInfos ;
|
|
||||||
|
|
||||||
recursCollectColFileInfos(_xml_doc.documentElement(),colFileInfos,QString(),false) ;
|
|
||||||
|
|
||||||
RsCollectionDialog* rcd = new RsCollectionDialog(fileName, colFileInfos,true);
|
|
||||||
connect(rcd,SIGNAL(saveColl(std::vector<ColFileInfo>, QString)),this,SLOT(saveColl(std::vector<ColFileInfo>, QString))) ;
|
|
||||||
_saved=false;
|
|
||||||
rcd->exec() ;
|
|
||||||
delete rcd;
|
|
||||||
|
|
||||||
return _saved;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RsCollection::openColl(const QString& fileName, bool readOnly /* = false */, bool showError /* = true*/)
|
|
||||||
{
|
|
||||||
if (load(fileName, showError)) {
|
|
||||||
std::vector<ColFileInfo> colFileInfos ;
|
|
||||||
|
|
||||||
recursCollectColFileInfos(_xml_doc.documentElement(),colFileInfos,QString(),false) ;
|
|
||||||
|
|
||||||
RsCollectionDialog* rcd = new RsCollectionDialog(fileName, colFileInfos, true, readOnly);
|
|
||||||
connect(rcd,SIGNAL(saveColl(std::vector<ColFileInfo>, QString)),this,SLOT(saveColl(std::vector<ColFileInfo>, QString))) ;
|
|
||||||
_saved=false;
|
|
||||||
rcd->exec() ;
|
|
||||||
delete rcd;
|
|
||||||
|
|
||||||
return _saved;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qulonglong RsCollection::size()
|
qulonglong RsCollection::size()
|
||||||
|
@ -89,10 +89,8 @@ public:
|
|||||||
// Save to disk
|
// Save to disk
|
||||||
bool save(const QString& fileName) const ;
|
bool save(const QString& fileName) const ;
|
||||||
|
|
||||||
// Open new collection
|
// returns the file tree
|
||||||
bool openNewColl(QWidget *parent, QString fileName = "");
|
const RsFileTree& fileTree() const { return mFileTree; }
|
||||||
// Open existing collection
|
|
||||||
bool openColl(const QString& fileName, bool readOnly = false, bool showError = true);
|
|
||||||
|
|
||||||
// Download the content.
|
// Download the content.
|
||||||
void downloadFiles() const ;
|
void downloadFiles() const ;
|
||||||
|
@ -693,12 +693,10 @@ void RsCollectionDialog::changeFileName()
|
|||||||
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
|
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
|
||||||
|
|
||||||
QFile file(fileName) ;
|
QFile file(fileName) ;
|
||||||
|
RsCollection::RsCollectionErrorCode err;
|
||||||
|
|
||||||
if(file.exists())
|
if(file.exists() && RsCollection::checkFile(fileName,err))
|
||||||
{
|
{
|
||||||
RsCollection collFile;
|
|
||||||
if (!collFile.checkFile(fileName,true)) return;
|
|
||||||
|
|
||||||
QMessageBox mb;
|
QMessageBox mb;
|
||||||
mb.setText(tr("Save Collection File."));
|
mb.setText(tr("Save Collection File."));
|
||||||
mb.setInformativeText(tr("File already exists.")+"\n"+tr("What do you want to do?"));
|
mb.setInformativeText(tr("File already exists.")+"\n"+tr("What do you want to do?"));
|
||||||
@ -710,19 +708,20 @@ void RsCollectionDialog::changeFileName()
|
|||||||
|
|
||||||
if (mb.clickedButton()==btnOwerWrite) {
|
if (mb.clickedButton()==btnOwerWrite) {
|
||||||
//Nothing to do
|
//Nothing to do
|
||||||
} else if (mb.clickedButton()==btnMerge) {
|
}
|
||||||
|
else if(mb.clickedButton()==btnMerge)
|
||||||
|
{
|
||||||
//Open old file to merge it with RsCollection
|
//Open old file to merge it with RsCollection
|
||||||
QDomDocument qddOldFile("RsCollection");
|
|
||||||
if (qddOldFile.setContent(&file)) {
|
|
||||||
QDomElement docOldElem = qddOldFile.elementsByTagName("RsCollection").at(0).toElement();
|
|
||||||
collFile.recursCollectColFileInfos(docOldElem,_newColFileInfos,QString(),false);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (mb.clickedButton()==btnCancel) {
|
RsCollection qddOldFileCollection(fileName,err);
|
||||||
return;
|
|
||||||
} else {
|
if(err != RsCollection::RsCollectionErrorCode::NO_ERROR)
|
||||||
return;
|
_collection.merge_in(qddOldFileCollection.fileTree());
|
||||||
}
|
}
|
||||||
|
else if(mb.clickedButton()==btnCancel)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
} else {//if(file.exists())
|
} else {//if(file.exists())
|
||||||
//create a new empty file to check if name if good.
|
//create a new empty file to check if name if good.
|
||||||
@ -1444,3 +1443,98 @@ void RsCollectionDialog::saveChild(QTreeWidgetItem *parentItem, ColFileInfo *par
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RsCollectionDialog::openExistingCollection(const QString& fileName, bool readOnly /* = false */, bool showError /* = true*/)
|
||||||
|
{
|
||||||
|
#ifdef TODO
|
||||||
|
RsCollection::RsCollectionErrorCode err;
|
||||||
|
RsCollection col(fileName,err);
|
||||||
|
|
||||||
|
if(err != RsCollection::RsCollectionErrorCode::NO_ERROR)
|
||||||
|
{
|
||||||
|
RsCollectionDialog rcd = new RsCollectionDialog(col, true, readOnly);
|
||||||
|
return rcd.exec() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(showError)
|
||||||
|
QMessageBox::information(nullptr,tr("Error openning RsCollection"),RsCollection::errorString(err));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RsCollectionDialog::openNewCollection(const RsFileTree& tree,const QString& proposed_file_name)
|
||||||
|
{
|
||||||
|
#ifdef TODO
|
||||||
|
QString fileName = proposed_file_name;
|
||||||
|
|
||||||
|
if(!misc::getSaveFileName(nullptr, RshareSettings::LASTDIR_EXTRAFILE
|
||||||
|
, QApplication::translate("RsCollectionFile", "Create collection file")
|
||||||
|
, QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollection::ExtensionString + ")"
|
||||||
|
, fileName,0, QFileDialog::DontConfirmOverwrite))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!fileName.endsWith("." + RsCollection::ExtensionString))
|
||||||
|
fileName += "." + RsCollection::ExtensionString ;
|
||||||
|
|
||||||
|
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
|
||||||
|
|
||||||
|
QFile file(fileName) ;
|
||||||
|
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
RsCollection::RsCollectionErrorCode err;
|
||||||
|
if (!RsCollection::checkFile(fileName,err))
|
||||||
|
{
|
||||||
|
QMessageBox::information(nullptr,tr("Error openning collection"),RsCollection::errorString(err));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMessageBox mb;
|
||||||
|
mb.setText(tr("Save Collection File."));
|
||||||
|
mb.setInformativeText(tr("File already exists.")+"\n"+tr("What do you want to do?"));
|
||||||
|
QAbstractButton *btnOwerWrite = mb.addButton(tr("Overwrite"), QMessageBox::YesRole);
|
||||||
|
QAbstractButton *btnMerge = mb.addButton(tr("Merge"), QMessageBox::NoRole);
|
||||||
|
QAbstractButton *btnCancel = mb.addButton(tr("Cancel"), QMessageBox::ResetRole);
|
||||||
|
mb.setIcon(QMessageBox::Question);
|
||||||
|
mb.exec();
|
||||||
|
|
||||||
|
if (mb.clickedButton()==btnOwerWrite) {
|
||||||
|
//Nothing to do _xml_doc already up to date
|
||||||
|
} else if (mb.clickedButton()==btnMerge) {
|
||||||
|
//Open old file to merge it with _xml_doc
|
||||||
|
QDomDocument qddOldFile("RsCollection");
|
||||||
|
if (qddOldFile.setContent(&file)) {
|
||||||
|
QDomElement docOldElem = qddOldFile.elementsByTagName("RsCollection").at(0).toElement();
|
||||||
|
std::vector<ColFileInfo> colOldFileInfos;
|
||||||
|
recursCollectColFileInfos(docOldElem,colOldFileInfos,QString(),false);
|
||||||
|
|
||||||
|
QDomElement root = _xml_doc.elementsByTagName("RsCollection").at(0).toElement();
|
||||||
|
for(uint32_t i = 0;i<colOldFileInfos.size();++i){
|
||||||
|
recursAddElements(_xml_doc,colOldFileInfos[i],root) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (mb.clickedButton()==btnCancel) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}//if(file.exists())
|
||||||
|
|
||||||
|
_fileName=fileName;
|
||||||
|
std::vector<ColFileInfo> colFileInfos ;
|
||||||
|
|
||||||
|
recursCollectColFileInfos(_xml_doc.documentElement(),colFileInfos,QString(),false) ;
|
||||||
|
|
||||||
|
RsCollectionDialog* rcd = new RsCollectionDialog(fileName, colFileInfos,true);
|
||||||
|
connect(rcd,SIGNAL(saveColl(std::vector<ColFileInfo>, QString)),this,SLOT(saveColl(std::vector<ColFileInfo>, QString))) ;
|
||||||
|
_saved=false;
|
||||||
|
rcd->exec() ;
|
||||||
|
delete rcd;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -30,15 +30,20 @@ class RsCollectionDialog: public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RsCollectionDialog(const QString& filename
|
|
||||||
, const std::vector<ColFileInfo> &colFileInfos
|
|
||||||
, const bool& creation
|
|
||||||
, const bool& readOnly = false) ;
|
|
||||||
virtual ~RsCollectionDialog();
|
virtual ~RsCollectionDialog();
|
||||||
|
|
||||||
|
// Open new collection
|
||||||
|
static bool openNewCollection(const RsFileTree &tree, const QString &proposed_file_name = QString());
|
||||||
|
|
||||||
|
// Open existing collection
|
||||||
|
static bool openExistingCollection(const QString& fileName, bool readOnly = false, bool showError = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
|
|
||||||
|
RsCollectionDialog(const QString& filename, const std::vector<ColFileInfo> &colFileInfos, const bool& creation,
|
||||||
|
const bool& readOnly = false) ;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void directoryLoaded(QString dirLoaded);
|
void directoryLoaded(QString dirLoaded);
|
||||||
void updateSizes() ;
|
void updateSizes() ;
|
||||||
@ -88,4 +93,6 @@ private:
|
|||||||
QItemSelectionModel *_selectionProxy;
|
QItemSelectionModel *_selectionProxy;
|
||||||
bool _dirLoaded;
|
bool _dirLoaded;
|
||||||
QHash<QString,QString> _listOfFilesAddedInDir;
|
QHash<QString,QString> _listOfFilesAddedInDir;
|
||||||
|
|
||||||
|
RsCollection _collection;
|
||||||
};
|
};
|
||||||
|
0
retroshare-gui/src/gui/common/RsCollectionModel.cpp
Normal file
0
retroshare-gui/src/gui/common/RsCollectionModel.cpp
Normal file
0
retroshare-gui/src/gui/common/RsCollectionModel.h
Normal file
0
retroshare-gui/src/gui/common/RsCollectionModel.h
Normal file
@ -28,12 +28,9 @@ bool RsUrlHandler::openUrl(const QUrl& url)
|
|||||||
{
|
{
|
||||||
if(url.scheme() == QString("file") && url.toLocalFile().endsWith("."+RsCollection::ExtensionString))
|
if(url.scheme() == QString("file") && url.toLocalFile().endsWith("."+RsCollection::ExtensionString))
|
||||||
{
|
{
|
||||||
RsCollection collection ;
|
RsCollection::RsCollectionErrorCode err;
|
||||||
if(collection.load(url.toLocalFile()))
|
RsCollection(url.toLocalFile(),err).downloadFiles() ;
|
||||||
{
|
|
||||||
collection.downloadFiles() ;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return QDesktopServices::openUrl(url) ;
|
return QDesktopServices::openUrl(url) ;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user