renamed RsCollectionEditor into RsCollection. Added download of FileTree links

This commit is contained in:
csoler 2017-10-19 22:14:04 +02:00
parent 32be00614d
commit 74d5069225
13 changed files with 132 additions and 139 deletions

View File

@ -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<QTreeWidgetItem*> 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))

View File

@ -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);

View File

@ -31,7 +31,7 @@
#include <QStandardItemModel>
#include <gui/common/FilesDefs.h>
#include <gui/common/RsCollectionEditor.h>
#include <gui/common/RsCollection.h>
#include <gui/common/RsUrlHandler.h>
#include <gui/common/RSTreeView.h>
@ -50,7 +50,7 @@
#include "xprogressbar.h"
#include <gui/settings/rsharesettings.h>
#include "util/misc.h"
#include <gui/common/RsCollectionEditor.h>
#include <gui/common/RsCollection.h>
#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<SharedDirInfo>::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)

View File

@ -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 <DirDetails> 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());
}
}

View File

@ -26,7 +26,7 @@
#include <QTimer>
#include <retroshare-gui/RsAutoUpdatePage.h>
#include <gui/common/RsCollectionEditor.h>
#include <gui/common/RsCollection.h>
#include <gui/common/RsUrlHandler.h>
#include <gui/common/FilesDefs.h>
#include <gui/common/GroupDefs.h>
@ -1065,7 +1065,7 @@ void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndex
std::vector <DirDetails> dirVec;
getDirDetailsFromSelect(list, dirVec);
RsCollectionEditor(dirVec).openNewColl(parent);
RsCollection(dirVec).openNewColl(parent);
}
void RetroshareDirModel::downloadSelected(const QModelIndexList &list)

View File

@ -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 <gui/common/RsUrlHandler.h>
#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;
}

View File

@ -23,7 +23,7 @@
#include <QFileInfo>
#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");

View File

@ -24,7 +24,7 @@
#include <stdexcept>
#include <retroshare/rsfiles.h>
#include "RsCollectionEditor.h"
#include "RsCollection.h"
#include "RsCollectionDialog.h"
#include "util/misc.h"
@ -36,15 +36,15 @@
#include <QMessageBox>
#include <QIcon>
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<DirDetails>& file_infos, QObject *parent)
RsCollection::RsCollection(const std::vector<DirDetails>& file_infos, QObject *parent)
: QObject(parent), _xml_doc("RsCollection")
{
QDomElement root = _xml_doc.createElement("RsCollection");
@ -62,11 +62,11 @@ RsCollectionEditor::RsCollectionEditor(const std::vector<DirDetails>& 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<ColFileInfo>& colFileInfos,const QString& current_path, bool bad_chars_in_parent) const
void RsCollection::recursCollectColFileInfos(const QDomElement& e,std::vector<ColFileInfo>& 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<uint32_t> subdirs ;
std::vector<FileTree::FileData> 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<subdirs.size();++i)
@ -232,7 +232,7 @@ void RsCollectionEditor::recursAddElements(QDomDocument& doc,const FileTree& ft,
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("sha1"),QString::fromStdString(subfiles[i].hash.toStdString())) ;
f.setAttribute(QString("size"),QString::number(subfiles[i].size)) ;
e.appendChild(f) ;
@ -245,7 +245,7 @@ static void showErrorBox(const QString& fileName, const QString& error)
mb.exec();
}
bool RsCollectionEditor::load(const QString& fileName, bool showError /* = true*/)
bool RsCollection::load(const QString& fileName, bool showError /* = true*/)
{
if (!checkFile(fileName,showError)) return false;
@ -275,7 +275,7 @@ bool RsCollectionEditor::load(const QString& fileName, bool showError /* = true*
}
// check that the file is a valid rscollection file, and not a lol bomb or some shit like this
bool RsCollectionEditor::checkFile(const QString& fileName, bool showError)
bool RsCollection::checkFile(const QString& fileName, bool showError)
{
QFile file(fileName);
@ -342,15 +342,10 @@ bool RsCollectionEditor::checkFile(const QString& fileName, bool showError)
}
return false;
}
bool RsCollectionEditor::load(const FileTree& f)
{
}
bool RsCollectionEditor::load(QWidget *parent)
bool RsCollection::load(QWidget *parent)
{
QString fileName;
if (!misc::getOpenFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Open collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionEditor::ExtensionString + ")", fileName))
if (!misc::getOpenFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Open collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollection::ExtensionString + ")", fileName))
return false;
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
@ -358,7 +353,7 @@ bool RsCollectionEditor::load(QWidget *parent)
return load(fileName, true);
}
bool RsCollectionEditor::save(const QString& fileName) const
bool RsCollection::save(const QString& fileName) const
{
QFile file(fileName);
@ -378,14 +373,14 @@ bool RsCollectionEditor::save(const QString& fileName) const
return true;
}
bool RsCollectionEditor::save(QWidget *parent) const
bool RsCollection::save(QWidget *parent) const
{
QString fileName;
if(!misc::getSaveFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Create collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionEditor::ExtensionString + ")", fileName))
if(!misc::getSaveFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Create collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollection::ExtensionString + ")", fileName))
return false;
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;
@ -393,17 +388,17 @@ bool RsCollectionEditor::save(QWidget *parent) const
}
bool RsCollectionEditor::openNewColl(QWidget *parent)
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") + " (*." + RsCollectionEditor::ExtensionString + ")"
, QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollection::ExtensionString + ")"
, fileName,0, QFileDialog::DontConfirmOverwrite))
return false;
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;
@ -460,7 +455,7 @@ bool RsCollectionEditor::openNewColl(QWidget *parent)
return _saved;
}
bool RsCollectionEditor::openColl(const QString& fileName, bool readOnly /* = false */, bool showError /* = true*/)
bool RsCollection::openColl(const QString& fileName, bool readOnly /* = false */, bool showError /* = true*/)
{
if (load(fileName, showError)) {
std::vector<ColFileInfo> 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<ColFileInfo> colFileInfos, const QString &fileName)
void RsCollection::saveColl(std::vector<ColFileInfo> colFileInfos, const QString &fileName)
{
QDomElement root = _xml_doc.elementsByTagName("RsCollection").at(0).toElement();

View File

@ -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<DirDetails>& file_entries, QObject *parent = 0) ;
RsCollectionEditor(const FileTree& fr, QObject *parent);
virtual ~RsCollectionEditor() ;
RsCollection(const std::vector<DirDetails>& 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<ColFileInfo>& 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);

View File

@ -29,7 +29,7 @@
#include <QDateTime>
#include <QInputDialog>
#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;

View File

@ -22,7 +22,7 @@
****************************************************************/
#include "ui_RsCollectionDialog.h"
#include "RsCollectionEditor.h"
#include "RsCollection.h"
#include <QFileSystemModel>
#include <QSortFilterProxyModel>

View File

@ -22,14 +22,14 @@
#include <stdexcept>
#include <QDesktopServices>
#include <QUrl>
#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() ;

View File

@ -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 \