From 74d5069225d9658ffbe441743034307cf6aa6f91 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 19 Oct 2017 22:14:04 +0200 Subject: [PATCH] renamed RsCollectionEditor into RsCollection. Added download of FileTree links --- .../src/gui/FileTransfer/SearchDialog.cpp | 20 ++--- .../gui/FileTransfer/SharedFilesDialog.cpp | 28 +++--- .../src/gui/FileTransfer/TransfersDialog.cpp | 86 +++++++++---------- retroshare-gui/src/gui/MainWindow.cpp | 8 +- retroshare-gui/src/gui/RemoteDirModel.cpp | 4 +- retroshare-gui/src/gui/RetroShareLink.cpp | 11 ++- retroshare-gui/src/gui/common/FilesDefs.cpp | 4 +- ...sCollectionEditor.cpp => RsCollection.cpp} | 73 ++++++++-------- .../{RsCollectionEditor.h => RsCollection.h} | 15 ++-- .../src/gui/common/RsCollectionDialog.cpp | 10 +-- .../src/gui/common/RsCollectionDialog.h | 2 +- .../src/gui/common/RsUrlHandler.cpp | 6 +- retroshare-gui/src/retroshare-gui.pro | 4 +- 13 files changed, 132 insertions(+), 139 deletions(-) rename retroshare-gui/src/gui/common/{RsCollectionEditor.cpp => RsCollection.cpp} (84%) rename retroshare-gui/src/gui/common/{RsCollectionEditor.h => RsCollection.h} (90%) diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index e55493a0c..facb8b60d 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -30,7 +30,7 @@ #include "gui/RetroShareLink.h" #include "retroshare-gui/RsAutoUpdatePage.h" #include "gui/msgs/MessageComposer.h" -#include "gui/common/RsCollectionEditor.h" +#include "gui/common/RsCollection.h" #include "gui/common/FilesDefs.h" #include "gui/common/RsUrlHandler.h" #include "gui/settings/rsharesettings.h" @@ -345,7 +345,7 @@ void SearchDialog::searchResultWidgetCustomPopupMenu( QPoint /*point*/ ) QList item =ui.searchResultWidget->selectedItems() ; if (item.at(0)->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool()) { contextMnu.addAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this, SLOT(openFolderSearch())) ; - if (item.at(0)->text(SR_NAME_COL).endsWith(RsCollectionEditor::ExtensionString)) { + if (item.at(0)->text(SR_NAME_COL).endsWith(RsCollection::ExtensionString)) { add_CollActions = true ; }//if (item.at(0)->text(SR_NAME_COL).endsWith(RsCollectionFile::ExtensionString)) }//if (item.at(0)->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool()) @@ -448,7 +448,7 @@ void SearchDialog::collCreate() }//if (!item->text(SR_HASH_COL).isEmpty()) }//for (int i = 0; i < numdls; ++i) - RsCollectionEditor(dirVec).openNewColl(this); + RsCollection(dirVec).openNewColl(this); } void SearchDialog::collModif() @@ -476,8 +476,8 @@ void SearchDialog::collModif() QFileInfo qinfo; qinfo.setFile(QString::fromUtf8(path.c_str())); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; collection.openColl(qinfo.absoluteFilePath()); }//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) }//if (qinfo.exists()) @@ -508,8 +508,8 @@ void SearchDialog::collView() QFileInfo qinfo; qinfo.setFile(QString::fromUtf8(path.c_str())); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; collection.openColl(qinfo.absoluteFilePath(), true); }//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) }//if (qinfo.exists()) @@ -540,8 +540,8 @@ void SearchDialog::collOpen() QFileInfo qinfo; qinfo.setFile(QString::fromUtf8(path.c_str())); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; if (collection.load(qinfo.absoluteFilePath())) { collection.downloadFiles(); return; @@ -552,7 +552,7 @@ void SearchDialog::collOpen() } } - RsCollectionEditor collection; + RsCollection collection; if (collection.load(this)) { collection.downloadFiles(); }//if (collection.load(this)) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 0f0244818..f071c3a66 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -37,7 +37,7 @@ #include "gui/RetroShareLink.h" #include "gui/ShareManager.h" #include "gui/common/PeerDefs.h" -#include "gui/common/RsCollectionEditor.h" +#include "gui/common/RsCollection.h" #include "gui/msgs/MessageComposer.h" #include "gui/settings/AddFileAssociationDialog.h" #include "gui/settings/rsharesettings.h" @@ -695,11 +695,11 @@ void SharedFilesDialog::collModif() QFileInfo qinfo; qinfo.setFile(QString::fromUtf8(path.c_str())); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; collection.openColl(qinfo.absoluteFilePath()); - }//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) - }//if (qinfo.exists()) + } + } } void SharedFilesDialog::collView() @@ -725,11 +725,11 @@ void SharedFilesDialog::collView() QFileInfo qinfo; qinfo.setFile(QString::fromUtf8(path.c_str())); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; collection.openColl(qinfo.absoluteFilePath(), true); - }//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) - }//if (qinfo.exists()) + } + } } void SharedFilesDialog::collOpen() @@ -755,8 +755,8 @@ void SharedFilesDialog::collOpen() QFileInfo qinfo; qinfo.setFile(QString::fromUtf8(path.c_str())); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; if (collection.load(qinfo.absoluteFilePath())) { collection.downloadFiles(); return; @@ -766,10 +766,10 @@ void SharedFilesDialog::collOpen() } } - RsCollectionEditor collection; + RsCollection collection; if (collection.load(this)) { collection.downloadFiles(); - }//if (collection.load(this)) + } } void LocalSharedFilesDialog::playselectedfiles() @@ -998,7 +998,7 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) QMenu contextMnu(this) ; - bool bIsRsColl = currentFile.endsWith(RsCollectionEditor::ExtensionString); + bool bIsRsColl = currentFile.endsWith(RsCollection::ExtensionString); collCreateAct->setEnabled(true); collModifAct->setEnabled(bIsRsColl); collViewAct->setEnabled(bIsRsColl); diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 98bc7f3cb..b6c3376a5 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include @@ -50,7 +50,7 @@ #include "xprogressbar.h" #include #include "util/misc.h" -#include +#include #include "TransferUserNotify.h" #include "util/QtVersion.h" #include "util/RsFile.h" @@ -679,20 +679,20 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ ) */ if (info.downloadStatus == FT_STATE_WAITING) { atLeastOne_Waiting = true ; - }//if (info.downloadStatus == FT_STATE_WAITING) + } if (info.downloadStatus == FT_STATE_DOWNLOADING) { atLeastOne_Downloading=true ; - }//if (info.downloadStatus == FT_STATE_DOWNLOADING) + } if (info.downloadStatus == FT_STATE_COMPLETE) { atLeastOne_Complete = true ; add_OpenFileOption = single ; - }//if (info.downloadStatus == FT_STATE_COMPLETE) + } if (info.downloadStatus == FT_STATE_QUEUED) { atLeastOne_Queued = true ; - }//if(info.downloadStatus == FT_STATE_QUEUED) + } if (info.downloadStatus == FT_STATE_PAUSED) { atLeastOne_Paused = true ; - }//if (info.downloadStatus == FT_STATE_PAUSED) + } size_t pos = info.fname.find_last_of('.') ; if (pos != std::string::npos) { @@ -700,23 +700,23 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ ) if (misc::isPreviewable(info.fname.substr(pos + 1).c_str())) { add_PreviewOption = (info.downloadStatus != FT_STATE_COMPLETE) ; add_PlayOption = !add_PreviewOption ; - }// if (misc::isPreviewable(info.fname.substr(pos + 1).c_str())) + } // Check if the file is a collection - if (RsCollectionEditor::ExtensionString == info.fname.substr(pos + 1).c_str()) { + if (RsCollection::ExtensionString == info.fname.substr(pos + 1).c_str()) { add_CollActions = (info.downloadStatus == FT_STATE_COMPLETE); - }//if (RsCollectionFile::ExtensionString == info - }// if(pos != std::string::npos) + } + } - }// if FileDetails - }// for items iterate - }// if (!items.empty()) + } + } + } if (atLeastOne_Waiting || atLeastOne_Downloading || atLeastOne_Queued || atLeastOne_Paused) { contextMnu.addMenu( &prioritySpeedMenu) ; } if (atLeastOne_Queued) { contextMnu.addMenu( &priorityQueueMenu) ; - }//if (atLeastOne_Queued) + } if ( (!items.empty()) && (atLeastOne_Downloading || atLeastOne_Queued || atLeastOne_Waiting || atLeastOne_Paused)) { @@ -724,7 +724,7 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ ) if (single) { contextMnu.addAction( renameFileAct) ; - }//if (single) + } QMenu *directoryMenu = contextMnu.addMenu(QIcon(IMAGE_OPENFOLDER), tr("Set destination directory")) ; directoryMenu->addAction(specifyDestinationDirectoryAct) ; @@ -745,27 +745,27 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ ) act->setData(QString::fromUtf8( (*it).filename.c_str() ) ) ; connect(act, SIGNAL(triggered()), this, SLOT(setDestinationDirectory())) ; directoryMenu->addAction( act) ; - }//for (std::list::const_iterator it - }//if ( (!items.empty()) && + } + } if (atLeastOne_Paused) { contextMnu.addAction(resumeAct) ; - }//if (atLeastOne_Paused) + } if (atLeastOne_Downloading || atLeastOne_Queued || atLeastOne_Waiting) { contextMnu.addAction(pauseAct) ; - }//if (atLeastOne_Downloading || atLeastOne_Queued || atLeastOne_Waiting) + } if (!atLeastOne_Complete && !items.empty()) { contextMnu.addAction(forceCheckAct) ; contextMnu.addAction(cancelAct) ; - }//if (!atLeastOne_Complete && !items.empty()) + } if (add_PlayOption) { contextMnu.addAction(playAct) ; - }//if (add_PlayOption) + } if (atLeastOne_Paused || atLeastOne_Downloading || atLeastOne_Complete || add_PlayOption) { contextMnu.addSeparator() ;//------------------------------------------------ - }//if (atLeastOne_Paused || + } if (single) { if (add_OpenFileOption) contextMnu.addAction( openFileAct) ; @@ -773,20 +773,20 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ ) contextMnu.addAction( openFolderAct) ; contextMnu.addAction( detailsFileAct) ; contextMnu.addSeparator() ;//-------------------------------------------- - }//if (single) + } contextMnu.addAction( clearCompletedAct) ; contextMnu.addSeparator() ;//------------------------------------------------ if (add_CopyLink) { contextMnu.addAction( copyLinkAct) ; - }//if (add_CopyLink) + } if (add_PasteLink) { contextMnu.addAction( pasteLinkAct) ; - }//if (add_PasteLink) + } if (add_CopyLink || add_PasteLink) { contextMnu.addSeparator() ;//-------------------------------------------- - }//if (add_CopyLink || add_PasteLink) + } if (DLLFilterModel->rowCount()>0 ) { contextMnu.addAction( expandAllDLAct ) ; @@ -2153,9 +2153,9 @@ void TransfersDialog::collCreate() details.type = DIR_TYPE_FILE; dirVec.push_back(details); - }//for (it = items.begin(); + } - RsCollectionEditor(dirVec).openNewColl(this); + RsCollection(dirVec).openNewColl(this); } void TransfersDialog::collModif() @@ -2180,12 +2180,12 @@ void TransfersDialog::collModif() QFileInfo qinfo; qinfo.setFile(QString::fromUtf8(path.c_str())); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; collection.openColl(qinfo.absoluteFilePath()); - }//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) - }//if (qinfo.exists()) - }//if (info.downloadStatus == FT_STATE_COMPLETE) + } + } + } } void TransfersDialog::collView() @@ -2210,12 +2210,12 @@ void TransfersDialog::collView() QFileInfo qinfo; qinfo.setFile(QString::fromUtf8(path.c_str())); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; collection.openColl(qinfo.absoluteFilePath(), true); - }//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) - }//if (qinfo.exists()) - }//if (info.downloadStatus == FT_STATE_COMPLETE) + } + } + } } void TransfersDialog::collOpen() @@ -2240,8 +2240,8 @@ void TransfersDialog::collOpen() QFileInfo qinfo; qinfo.setFile(QString::fromUtf8(path.c_str())); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; if (collection.load(qinfo.absoluteFilePath())) { collection.downloadFiles(); return; @@ -2252,10 +2252,10 @@ void TransfersDialog::collOpen() } } - RsCollectionEditor collection; + RsCollection collection; if (collection.load(this)) { collection.downloadFiles(); - }//if (collection.load(this)) + } } void TransfersDialog::setShowDLSizeColumn(bool show) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index d3bb3200f..ea57a93b6 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -103,7 +103,7 @@ #include "gui/statistics/StatisticsWindow.h" #include "gui/connect/ConnectFriendWizard.h" -#include "gui/common/RsCollectionEditor.h" +#include "gui/common/RsCollection.h" #include "settings/rsettingswin.h" #include "settings/rsharesettings.h" #include "settings/WebuiPage.h" @@ -1020,7 +1020,7 @@ void MainWindow::newRsCollection() { std::vector dirVec; - RsCollectionEditor(dirVec).openNewColl(this); + RsCollection(dirVec).openNewColl(this); } /** Shows Share Manager */ @@ -1448,8 +1448,8 @@ void MainWindow::openRsCollection(const QString &filename) { QFileInfo qinfo(filename); if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollectionEditor::ExtensionString)) { - RsCollectionEditor collection; + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; collection.openColl(qinfo.absoluteFilePath()); } } diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 29f08b6a5..7ffbcf5bd 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -1065,7 +1065,7 @@ void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndex std::vector dirVec; getDirDetailsFromSelect(list, dirVec); - RsCollectionEditor(dirVec).openNewColl(parent); + RsCollection(dirVec).openNewColl(parent); } void RetroshareDirModel::downloadSelected(const QModelIndexList &list) diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 5a417cc37..7a1e32aae 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -43,7 +43,7 @@ #include "msgs/MessageComposer.h" #include "util/misc.h" #include "common/PeerDefs.h" -#include "common/RsCollectionEditor.h" +#include "common/RsCollection.h" #include #include "gui/connect/ConnectFriendWizard.h" #include "gui/connect/ConfCertDialog.h" @@ -980,10 +980,10 @@ QString RetroShareLink::toHtmlSize() const { QString size = QString("(%1)").arg(misc::friendlyUnit(_size)); - if (type() == TYPE_FILE && RsCollectionEditor::isCollectionFile(name())) { + if (type() == TYPE_FILE && RsCollection::isCollectionFile(name())) { FileInfo finfo; if (rsFiles->FileDetails(RsFileHash(hash().toStdString()), RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL, finfo)) { - RsCollectionEditor collection; + RsCollection collection; if (collection.load(QString::fromUtf8(finfo.path.c_str()), false)) { size += QString(" [%1]").arg(misc::friendlyUnit(collection.size())); } @@ -1393,10 +1393,9 @@ static void processList(const QStringList &list, const QString &textSingular, co case TYPE_COLLECTION: { - FileTree *ft = FileTree::create(_radix.toStdString()) ; + FileTree *ft = FileTree::create(link.radix().toStdString()) ; - RsCollectionEditor colled(*ft,NULL) ; - colled.exec(); + RsCollection(*ft).downloadFiles() ; delete ft; } diff --git a/retroshare-gui/src/gui/common/FilesDefs.cpp b/retroshare-gui/src/gui/common/FilesDefs.cpp index 063c85e3b..b20660b20 100644 --- a/retroshare-gui/src/gui/common/FilesDefs.cpp +++ b/retroshare-gui/src/gui/common/FilesDefs.cpp @@ -23,7 +23,7 @@ #include #include "FilesDefs.h" -#include "RsCollectionEditor.h" +#include "RsCollection.h" static QString getInfoFromFilename(const QString& filename, bool anyForUnknown, bool image) { @@ -54,7 +54,7 @@ static QString getInfoFromFilename(const QString& filename, bool anyForUnknown, return image ? ":/images/FileTypeDocument.png" : QApplication::translate("FilesDefs", "Document"); } else if (ext == "pdf") { return image ? ":/images/mimetypes/pdf.png" : QApplication::translate("FilesDefs", "Document"); - } else if (ext == RsCollectionEditor::ExtensionString) { + } else if (ext == RsCollection::ExtensionString) { return image ? ":/images/mimetypes/rscollection-16.png" : QApplication::translate("FilesDefs", "RetroShare collection file"); } else if (ext == "sub" || ext == "srt") { return image ? ":/images/FileTypeAny.png" : QApplication::translate("FilesDefs", "Subtitles"); diff --git a/retroshare-gui/src/gui/common/RsCollectionEditor.cpp b/retroshare-gui/src/gui/common/RsCollection.cpp similarity index 84% rename from retroshare-gui/src/gui/common/RsCollectionEditor.cpp rename to retroshare-gui/src/gui/common/RsCollection.cpp index ea76231bd..a7ba9637a 100644 --- a/retroshare-gui/src/gui/common/RsCollectionEditor.cpp +++ b/retroshare-gui/src/gui/common/RsCollection.cpp @@ -24,7 +24,7 @@ #include #include -#include "RsCollectionEditor.h" +#include "RsCollection.h" #include "RsCollectionDialog.h" #include "util/misc.h" @@ -36,15 +36,15 @@ #include #include -const QString RsCollectionEditor::ExtensionString = QString("rscollection") ; +const QString RsCollection::ExtensionString = QString("rscollection") ; -RsCollectionEditor::RsCollectionEditor(QObject *parent) +RsCollection::RsCollection(QObject *parent) : QObject(parent), _xml_doc("RsCollection") { } -RsCollectionEditor::RsCollectionEditor(const FileTree& fr, QObject *parent) - : QObject(parent), _xml_doc("RsCollection") +RsCollection::RsCollection(const FileTree& fr) + : _xml_doc("RsCollection") { QDomElement root = _xml_doc.createElement("RsCollection"); _xml_doc.appendChild(root); @@ -52,7 +52,7 @@ RsCollectionEditor::RsCollectionEditor(const FileTree& fr, QObject *parent) recursAddElements(_xml_doc,fr,0,root) ; } -RsCollectionEditor::RsCollectionEditor(const std::vector& file_infos, QObject *parent) +RsCollection::RsCollection(const std::vector& file_infos, QObject *parent) : QObject(parent), _xml_doc("RsCollection") { QDomElement root = _xml_doc.createElement("RsCollection"); @@ -62,11 +62,11 @@ RsCollectionEditor::RsCollectionEditor(const std::vector& file_infos recursAddElements(_xml_doc,file_infos[i],root) ; } -RsCollectionEditor::~RsCollectionEditor() +RsCollection::~RsCollection() { } -void RsCollectionEditor::downloadFiles() const +void RsCollection::downloadFiles() const { // print out the element names of all elements that are direct children // of the outermost element. @@ -96,7 +96,7 @@ static QString purifyFileName(const QString& input,bool& bad) return output ; } -void RsCollectionEditor::recursCollectColFileInfos(const QDomElement& e,std::vector& colFileInfos,const QString& current_path, bool bad_chars_in_parent) const +void RsCollection::recursCollectColFileInfos(const QDomElement& e,std::vector& colFileInfos,const QString& current_path, bool bad_chars_in_parent) const { QDomNode n = e.firstChild() ; @@ -148,7 +148,7 @@ void RsCollectionEditor::recursCollectColFileInfos(const QDomElement& e,std::vec } -void RsCollectionEditor::recursAddElements(QDomDocument& doc,const DirDetails& details,QDomElement& e) const +void RsCollection::recursAddElements(QDomDocument& doc,const DirDetails& details,QDomElement& e) const { if (details.type == DIR_TYPE_FILE) { @@ -184,7 +184,7 @@ void RsCollectionEditor::recursAddElements(QDomDocument& doc,const DirDetails& d } } -void RsCollectionEditor::recursAddElements(QDomDocument& doc,const ColFileInfo& colFileInfo,QDomElement& e) const +void RsCollection::recursAddElements(QDomDocument& doc,const ColFileInfo& colFileInfo,QDomElement& e) const { if (colFileInfo.type == DIR_TYPE_FILE) { @@ -211,7 +211,7 @@ void RsCollectionEditor::recursAddElements(QDomDocument& doc,const ColFileInfo& } } -void RsCollectionEditor::recursAddElements(QDomDocument& doc,const FileTree& ft,uint32_t index,QDomElement& e) const +void RsCollection::recursAddElements(QDomDocument& doc,const FileTree& ft,uint32_t index,QDomElement& e) const { std::vector subdirs ; std::vector subfiles ; @@ -221,7 +221,7 @@ void RsCollectionEditor::recursAddElements(QDomDocument& doc,const FileTree& ft, return ; QDomElement d = doc.createElement("Directory") ; - d.setAttribute(QString::fromUtf8()("name"),QString::fromUtf8(name.c_str())) ; + d.setAttribute(QString("name"),QString::fromUtf8(name.c_str())) ; e.appendChild(d) ; for (uint32_t i=0;i colFileInfos ; @@ -474,11 +469,11 @@ bool RsCollectionEditor::openColl(const QString& fileName, bool readOnly /* = fa delete rcd; return _saved; - }//if (load(fileName, showError)) + } return false; } -qulonglong RsCollectionEditor::size() +qulonglong RsCollection::size() { QDomElement docElem = _xml_doc.documentElement(); @@ -494,14 +489,14 @@ qulonglong RsCollectionEditor::size() return size; } -bool RsCollectionEditor::isCollectionFile(const QString &fileName) +bool RsCollection::isCollectionFile(const QString &fileName) { QString ext = QFileInfo(fileName).suffix().toLower(); - return (ext == RsCollectionEditor::ExtensionString); + return (ext == RsCollection::ExtensionString); } -void RsCollectionEditor::saveColl(std::vector colFileInfos, const QString &fileName) +void RsCollection::saveColl(std::vector colFileInfos, const QString &fileName) { QDomElement root = _xml_doc.elementsByTagName("RsCollection").at(0).toElement(); diff --git a/retroshare-gui/src/gui/common/RsCollectionEditor.h b/retroshare-gui/src/gui/common/RsCollection.h similarity index 90% rename from retroshare-gui/src/gui/common/RsCollectionEditor.h rename to retroshare-gui/src/gui/common/RsCollection.h index 0f291401e..f42b81db0 100644 --- a/retroshare-gui/src/gui/common/RsCollectionEditor.h +++ b/retroshare-gui/src/gui/common/RsCollection.h @@ -56,17 +56,17 @@ public: }; Q_DECLARE_METATYPE(ColFileInfo) -class RsCollectionEditor : public QObject +class RsCollection : public QObject { Q_OBJECT public: - RsCollectionEditor(QObject *parent = 0) ; + RsCollection(QObject *parent = 0) ; // create from list of files and directories - RsCollectionEditor(const std::vector& file_entries, QObject *parent = 0) ; - RsCollectionEditor(const FileTree& fr, QObject *parent); - virtual ~RsCollectionEditor() ; + RsCollection(const std::vector& file_entries, QObject *parent = 0) ; + RsCollection(const FileTree& fr); + virtual ~RsCollection() ; static const QString ExtensionString ; @@ -76,9 +76,6 @@ 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 ; @@ -102,6 +99,8 @@ private: void recursAddElements(QDomDocument&,const DirDetails&,QDomElement&) const ; void recursAddElements(QDomDocument&,const ColFileInfo&,QDomElement&) const; + void recursAddElements(QDomDocument& doc,const FileTree& ft,uint32_t index,QDomElement& e) const; + void recursCollectColFileInfos(const QDomElement&,std::vector& colFileInfos,const QString& current_dir,bool bad_chars_in_parent) const ; // check that the file is a valid rscollection file, and not a lol bomb or some shit like this static bool checkFile(const QString &fileName, bool showError); diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index ee0aeec39..68599eeeb 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -29,7 +29,7 @@ #include #include #include "RsCollectionDialog.h" -#include "RsCollectionEditor.h" +#include "RsCollection.h" #include "util/misc.h" #define COLUMN_FILE 0 #define COLUMN_FILEPATH 1 @@ -591,12 +591,12 @@ void RsCollectionDialog::changeFileName() QString fileName; if(!misc::getSaveFileName(this, RshareSettings::LASTDIR_EXTRAFILE , QApplication::translate("RsCollectionFile", "Create collection file") - , QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionEditor::ExtensionString + ")" + , QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollection::ExtensionString + ")" , fileName,0, QFileDialog::DontConfirmOverwrite)) return; - if (!fileName.endsWith("." + RsCollectionEditor::ExtensionString)) - fileName += "." + RsCollectionEditor::ExtensionString ; + if (!fileName.endsWith("." + RsCollection::ExtensionString)) + fileName += "." + RsCollection::ExtensionString ; std::cerr << "Got file name: " << fileName.toStdString() << std::endl; @@ -604,7 +604,7 @@ void RsCollectionDialog::changeFileName() if(file.exists()) { - RsCollectionEditor collFile; + RsCollection collFile; if (!collFile.checkFile(fileName,true)) return; QMessageBox mb; diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.h b/retroshare-gui/src/gui/common/RsCollectionDialog.h index e5e5df86d..bac5289b4 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.h +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.h @@ -22,7 +22,7 @@ ****************************************************************/ #include "ui_RsCollectionDialog.h" -#include "RsCollectionEditor.h" +#include "RsCollection.h" #include #include diff --git a/retroshare-gui/src/gui/common/RsUrlHandler.cpp b/retroshare-gui/src/gui/common/RsUrlHandler.cpp index 2e16b23c4..d307d7db1 100644 --- a/retroshare-gui/src/gui/common/RsUrlHandler.cpp +++ b/retroshare-gui/src/gui/common/RsUrlHandler.cpp @@ -22,14 +22,14 @@ #include #include #include -#include "RsCollectionEditor.h" +#include "RsCollection.h" #include "RsUrlHandler.h" bool RsUrlHandler::openUrl(const QUrl& url) { - if(url.scheme() == QString("file") && url.toLocalFile().endsWith("."+RsCollectionEditor::ExtensionString)) + if(url.scheme() == QString("file") && url.toLocalFile().endsWith("."+RsCollection::ExtensionString)) { - RsCollectionEditor collection ; + RsCollection collection ; if(collection.load(url.toLocalFile())) { collection.downloadFiles() ; diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index b762dc4ed..6b3211392 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -565,7 +565,7 @@ HEADERS += rshare.h \ gui/statistics/BWGraph.h \ util/RsSyntaxHighlighter.h \ util/imageutil.h \ - gui/common/RsCollectionEditor.h + gui/common/RsCollection.h # gui/ForumsDialog.h \ # gui/forums/ForumDetails.h \ @@ -925,7 +925,7 @@ SOURCES += main.cpp \ gui/statistics/BWGraph.cpp \ util/RsSyntaxHighlighter.cpp \ util/imageutil.cpp \ - gui/common/RsCollectionEditor.cpp + gui/common/RsCollection.cpp # gui/ForumsDialog.cpp \ # gui/forums/ForumDetails.cpp \