mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
Added the real size of all files of a collection to the link when added with drag and drop.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4722 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
27bc170471
commit
d07dbffa69
3 changed files with 50 additions and 7 deletions
|
@ -132,21 +132,23 @@ RsCollectionFile::RsCollectionFile(const std::vector<DirDetails>& file_infos)
|
|||
recursAddElements(_xml_doc,file_infos[i],root) ;
|
||||
}
|
||||
|
||||
static void showError(const QString& filename, const QString& error)
|
||||
static void showErrorBox(const QString& filename, const QString& error)
|
||||
{
|
||||
QMessageBox mb(QMessageBox::Warning, QObject::tr("Treatment of collection file has failed"), QObject::tr("The collection file %1 could not be openned.\nReported error is: %2").arg(filename).arg(error), QMessageBox::Ok);
|
||||
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
|
||||
mb.exec();
|
||||
}
|
||||
|
||||
bool RsCollectionFile::load(const QString& filename)
|
||||
bool RsCollectionFile::load(const QString& filename, bool showError /*= true*/)
|
||||
{
|
||||
QFile file(filename);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
std::cerr << "Cannot open file " << filename.toStdString() << " !!" << std::endl;
|
||||
showError(filename, QApplication::translate("RsCollectionFile", "Cannot open file %1").arg(filename));
|
||||
if (showError) {
|
||||
showErrorBox(filename, QApplication::translate("RsCollectionFile", "Cannot open file %1").arg(filename));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -156,7 +158,9 @@ bool RsCollectionFile::load(const QString& filename)
|
|||
if (ok) {
|
||||
_filename = filename;
|
||||
} else {
|
||||
showError(filename, QApplication::translate("RsCollectionFile", "Error parsing xml file"));
|
||||
if (showError) {
|
||||
showErrorBox(filename, QApplication::translate("RsCollectionFile", "Error parsing xml file"));
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
@ -170,7 +174,7 @@ bool RsCollectionFile::load()
|
|||
|
||||
std::cerr << "Got file name: " << filename.toStdString() << std::endl;
|
||||
|
||||
return load(filename);
|
||||
return load(filename, true);
|
||||
}
|
||||
|
||||
bool RsCollectionFile::save(const QString& filename) const
|
||||
|
@ -206,3 +210,26 @@ bool RsCollectionFile::save() const
|
|||
|
||||
return save(filename);
|
||||
}
|
||||
|
||||
qulonglong RsCollectionFile::size()
|
||||
{
|
||||
QDomElement docElem = _xml_doc.documentElement();
|
||||
|
||||
std::vector<DLinfo> dlinfos;
|
||||
recursCollectDLinfos(docElem, dlinfos, QString());
|
||||
|
||||
uint64_t size = 0;
|
||||
|
||||
for (uint32_t i = 0; i < dlinfos.size(); ++i) {
|
||||
size += dlinfos[i].size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
bool RsCollectionFile::isCollectionFile(const QString &filename)
|
||||
{
|
||||
QString ext = QFileInfo(filename).suffix().toLower();
|
||||
|
||||
return (ext == RsCollectionFile::ExtensionString);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue