renamed RsCollectionFile into RsCollectionEditor

This commit is contained in:
csoler 2017-10-15 21:10:29 +02:00
parent 68763f58d1
commit 847c1b2bce
13 changed files with 87 additions and 98 deletions

View file

@ -23,7 +23,7 @@
#include <QFileInfo>
#include "FilesDefs.h"
#include "RsCollectionFile.h"
#include "RsCollectionEditor.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 == RsCollectionFile::ExtensionString) {
} else if (ext == RsCollectionEditor::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

@ -29,7 +29,7 @@
#include <QDateTime>
#include <QInputDialog>
#include "RsCollectionDialog.h"
#include "RsCollectionFile.h"
#include "RsCollectionEditor.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") + " (*." + RsCollectionFile::ExtensionString + ")"
, QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionEditor::ExtensionString + ")"
, fileName,0, QFileDialog::DontConfirmOverwrite))
return;
if (!fileName.endsWith("." + RsCollectionFile::ExtensionString))
fileName += "." + RsCollectionFile::ExtensionString ;
if (!fileName.endsWith("." + RsCollectionEditor::ExtensionString))
fileName += "." + RsCollectionEditor::ExtensionString ;
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
@ -604,7 +604,7 @@ void RsCollectionDialog::changeFileName()
if(file.exists())
{
RsCollectionFile collFile;
RsCollectionEditor collFile;
if (!collFile.checkFile(fileName,true)) return;
QMessageBox mb;

View file

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

View file

@ -24,7 +24,7 @@
#include <stdexcept>
#include <retroshare/rsfiles.h>
#include "RsCollectionFile.h"
#include "RsCollectionEditor.h"
#include "RsCollectionDialog.h"
#include "util/misc.h"
@ -36,14 +36,14 @@
#include <QMessageBox>
#include <QIcon>
const QString RsCollectionFile::ExtensionString = QString("rscollection") ;
const QString RsCollectionEditor::ExtensionString = QString("rscollection") ;
RsCollectionFile::RsCollectionFile(QObject *parent)
RsCollectionEditor::RsCollectionEditor(QObject *parent)
: QObject(parent), _xml_doc("RsCollection")
{
}
RsCollectionFile::RsCollectionFile(const std::vector<DirDetails>& file_infos, QObject *parent)
RsCollectionEditor::RsCollectionEditor(const std::vector<DirDetails>& file_infos, QObject *parent)
: QObject(parent), _xml_doc("RsCollection")
{
QDomElement root = _xml_doc.createElement("RsCollection");
@ -53,11 +53,11 @@ RsCollectionFile::RsCollectionFile(const std::vector<DirDetails>& file_infos, QO
recursAddElements(_xml_doc,file_infos[i],root) ;
}
RsCollectionFile::~RsCollectionFile()
RsCollectionEditor::~RsCollectionEditor()
{
}
void RsCollectionFile::downloadFiles() const
void RsCollectionEditor::downloadFiles() const
{
// print out the element names of all elements that are direct children
// of the outermost element.
@ -87,7 +87,7 @@ static QString purifyFileName(const QString& input,bool& bad)
return output ;
}
void RsCollectionFile::recursCollectColFileInfos(const QDomElement& e,std::vector<ColFileInfo>& colFileInfos,const QString& current_path, bool bad_chars_in_parent) const
void RsCollectionEditor::recursCollectColFileInfos(const QDomElement& e,std::vector<ColFileInfo>& colFileInfos,const QString& current_path, bool bad_chars_in_parent) const
{
QDomNode n = e.firstChild() ;
@ -139,7 +139,7 @@ void RsCollectionFile::recursCollectColFileInfos(const QDomElement& e,std::vecto
}
void RsCollectionFile::recursAddElements(QDomDocument& doc,const DirDetails& details,QDomElement& e) const
void RsCollectionEditor::recursAddElements(QDomDocument& doc,const DirDetails& details,QDomElement& e) const
{
if (details.type == DIR_TYPE_FILE)
{
@ -175,7 +175,7 @@ void RsCollectionFile::recursAddElements(QDomDocument& doc,const DirDetails& det
}
}
void RsCollectionFile::recursAddElements(QDomDocument& doc,const ColFileInfo& colFileInfo,QDomElement& e) const
void RsCollectionEditor::recursAddElements(QDomDocument& doc,const ColFileInfo& colFileInfo,QDomElement& e) const
{
if (colFileInfo.type == DIR_TYPE_FILE)
{
@ -208,7 +208,7 @@ static void showErrorBox(const QString& fileName, const QString& error)
mb.exec();
}
bool RsCollectionFile::load(const QString& fileName, bool showError /* = true*/)
bool RsCollectionEditor::load(const QString& fileName, bool showError /* = true*/)
{
if (!checkFile(fileName,showError)) return false;
@ -238,7 +238,7 @@ bool RsCollectionFile::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 RsCollectionFile::checkFile(const QString& fileName, bool showError)
bool RsCollectionEditor::checkFile(const QString& fileName, bool showError)
{
QFile file(fileName);
@ -306,10 +306,10 @@ bool RsCollectionFile::checkFile(const QString& fileName, bool showError)
return false;
}
bool RsCollectionFile::load(QWidget *parent)
bool RsCollectionEditor::load(QWidget *parent)
{
QString fileName;
if (!misc::getOpenFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Open collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")", fileName))
if (!misc::getOpenFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Open collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionEditor::ExtensionString + ")", fileName))
return false;
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
@ -317,7 +317,7 @@ bool RsCollectionFile::load(QWidget *parent)
return load(fileName, true);
}
bool RsCollectionFile::save(const QString& fileName) const
bool RsCollectionEditor::save(const QString& fileName) const
{
QFile file(fileName);
@ -337,14 +337,14 @@ bool RsCollectionFile::save(const QString& fileName) const
return true;
}
bool RsCollectionFile::save(QWidget *parent) const
bool RsCollectionEditor::save(QWidget *parent) const
{
QString fileName;
if(!misc::getSaveFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Create collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")", fileName))
if(!misc::getSaveFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Create collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionEditor::ExtensionString + ")", fileName))
return false;
if (!fileName.endsWith("." + RsCollectionFile::ExtensionString))
fileName += "." + RsCollectionFile::ExtensionString ;
if (!fileName.endsWith("." + RsCollectionEditor::ExtensionString))
fileName += "." + RsCollectionEditor::ExtensionString ;
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
@ -352,17 +352,17 @@ bool RsCollectionFile::save(QWidget *parent) const
}
bool RsCollectionFile::openNewColl(QWidget *parent)
bool RsCollectionEditor::openNewColl(QWidget *parent)
{
QString fileName;
if(!misc::getSaveFileName(parent, RshareSettings::LASTDIR_EXTRAFILE
, QApplication::translate("RsCollectionFile", "Create collection file")
, QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")"
, QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionEditor::ExtensionString + ")"
, fileName,0, QFileDialog::DontConfirmOverwrite))
return false;
if (!fileName.endsWith("." + RsCollectionFile::ExtensionString))
fileName += "." + RsCollectionFile::ExtensionString ;
if (!fileName.endsWith("." + RsCollectionEditor::ExtensionString))
fileName += "." + RsCollectionEditor::ExtensionString ;
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
@ -419,7 +419,7 @@ bool RsCollectionFile::openNewColl(QWidget *parent)
return _saved;
}
bool RsCollectionFile::openColl(const QString& fileName, bool readOnly /* = false */, bool showError /* = true*/)
bool RsCollectionEditor::openColl(const QString& fileName, bool readOnly /* = false */, bool showError /* = true*/)
{
if (load(fileName, showError)) {
std::vector<ColFileInfo> colFileInfos ;
@ -437,7 +437,7 @@ bool RsCollectionFile::openColl(const QString& fileName, bool readOnly /* = fals
return false;
}
qulonglong RsCollectionFile::size()
qulonglong RsCollectionEditor::size()
{
QDomElement docElem = _xml_doc.documentElement();
@ -453,14 +453,14 @@ qulonglong RsCollectionFile::size()
return size;
}
bool RsCollectionFile::isCollectionFile(const QString &fileName)
bool RsCollectionEditor::isCollectionFile(const QString &fileName)
{
QString ext = QFileInfo(fileName).suffix().toLower();
return (ext == RsCollectionFile::ExtensionString);
return (ext == RsCollectionEditor::ExtensionString);
}
void RsCollectionFile::saveColl(std::vector<ColFileInfo> colFileInfos, const QString &fileName)
void RsCollectionEditor::saveColl(std::vector<ColFileInfo> colFileInfos, const QString &fileName)
{
QDomElement root = _xml_doc.elementsByTagName("RsCollection").at(0).toElement();

View file

@ -56,16 +56,16 @@ public:
};
Q_DECLARE_METATYPE(ColFileInfo)
class RsCollectionFile : public QObject
class RsCollectionEditor : public QObject
{
Q_OBJECT
public:
RsCollectionFile(QObject *parent = 0) ;
RsCollectionEditor(QObject *parent = 0) ;
// create from list of files and directories
RsCollectionFile(const std::vector<DirDetails>& file_entries, QObject *parent = 0) ;
virtual ~RsCollectionFile() ;
RsCollectionEditor(const std::vector<DirDetails>& file_entries, QObject *parent = 0) ;
virtual ~RsCollectionEditor() ;
static const QString ExtensionString ;

View file

@ -22,14 +22,14 @@
#include <stdexcept>
#include <QDesktopServices>
#include <QUrl>
#include "RsCollectionFile.h"
#include "RsCollectionEditor.h"
#include "RsUrlHandler.h"
bool RsUrlHandler::openUrl(const QUrl& url)
{
if(url.scheme() == QString("file") && url.toLocalFile().endsWith("."+RsCollectionFile::ExtensionString))
if(url.scheme() == QString("file") && url.toLocalFile().endsWith("."+RsCollectionEditor::ExtensionString))
{
RsCollectionFile collection ;
RsCollectionEditor collection ;
if(collection.load(url.toLocalFile()))
{
collection.downloadFiles() ;