Added new button "Open Collection" in TransfersDialog.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4691 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-11-25 23:46:41 +00:00
parent 031629d528
commit bab7ebaa5b
10 changed files with 993 additions and 905 deletions

View File

@ -335,6 +335,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
/** StatusBar section ********/
/* initialize combobox in status bar */
statusComboBox = new QComboBox(statusBar());
statusComboBox->setFocusPolicy(Qt::ClickFocus);
initializeStatusObject(statusComboBox, true);
QWidget *widget = new QWidget();

View File

@ -916,19 +916,10 @@ void RetroshareDirModel::createCollectionFile(const QModelIndexList &list)
return ;
}
QString filename ;
if(!misc::getSaveFileName(NULL,RshareSettings::LASTDIR_EXTRAFILE,tr("Create selection file"),tr("Collection files")+" (*."+RsCollectionFile::ExtensionString+")",filename))
return ;
if(!filename.endsWith("."+RsCollectionFile::ExtensionString))
filename += "."+RsCollectionFile::ExtensionString ;
std::cerr << "Got file name: "<< filename.toStdString() << std::endl;
std::vector <DirDetails> dirVec;
getDirDetailsFromSelect(list, dirVec);
RsCollectionFile(dirVec).save(filename) ;
RsCollectionFile(dirVec).save();
}
void RetroshareDirModel::downloadSelected(const QModelIndexList &list)

View File

@ -44,11 +44,12 @@
#include "TurtleRouterStatistics.h"
#include "xprogressbar.h"
#include "settings/rsharesettings.h"
#include "util/misc.h"
#include "common/RsCollectionFile.h"
#include <retroshare/rsfiles.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsdisc.h>
#include "util/misc.h"
/****
* #define SHOW_RTT_STATISTICS 1
@ -322,6 +323,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
#endif
QObject::connect(ui._showCacheTransfers_CB,SIGNAL(toggled(bool)),this,SLOT(insertTransfers())) ;
QObject::connect(ui.openCollection, SIGNAL(clicked()), this, SLOT(openCollection()));
// Actions. Only need to be defined once.
pauseAct = new QAction(QIcon(IMAGE_PAUSE), tr("Pause"), this);
@ -1690,3 +1692,11 @@ QString TransfersDialog::getSources(int row, QStandardItemModel *model)
{
return model->data(model->index(row, SOURCES), Qt::DisplayRole).toString();
}
void TransfersDialog::openCollection()
{
RsCollectionFile Collection;
if (Collection.load()) {
Collection.downloadFiles();
}
}

View File

@ -101,6 +101,8 @@ private slots:
void showDetailsDialog();
void updateDetailsDialog();
void openCollection();
signals:
void playFiles(QStringList files);

File diff suppressed because it is too large Load Diff

View File

@ -26,33 +26,22 @@
#include "RsCollectionFile.h"
#include "RsCollectionDialog.h"
#include "util/misc.h"
#include <QFile>
#include <QDir>
#include <QObject>
#include <QMessageBox>
#include <QTextStream>
#include <QDomElement>
#include <QDomDocument>
#include <QMessageBox>
#include <QIcon>
const QString RsCollectionFile::ExtensionString = QString("rscollection") ;
RsCollectionFile::RsCollectionFile(const QString& filename)
: _xml_doc("RsCollection"),_filename(filename)
RsCollectionFile::RsCollectionFile()
: _xml_doc("RsCollection")
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
{
std::cerr << "Cannot open file " << filename.toStdString() << " !!" << std::endl;
return;
}
bool ok = _xml_doc.setContent(&file) ;
file.close();
if(!ok)
throw std::runtime_error("Error parsing xml file") ;
}
void RsCollectionFile::downloadFiles() const
@ -143,14 +132,55 @@ RsCollectionFile::RsCollectionFile(const std::vector<DirDetails>& file_infos)
recursAddElements(_xml_doc,file_infos[i],root) ;
}
void RsCollectionFile::save(const QString& filename) const
static void showError(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)
{
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));
return false;
}
bool ok = _xml_doc.setContent(&file) ;
file.close();
if (ok) {
_filename = filename;
} else {
showError(filename, QApplication::translate("RsCollectionFile", "Error parsing xml file"));
}
return ok;
}
bool RsCollectionFile::load()
{
QString filename;
if (!misc::getOpenFileName(NULL, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Open collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")", filename))
return false;
std::cerr << "Got file name: " << filename.toStdString() << std::endl;
return load(filename);
}
bool RsCollectionFile::save(const QString& filename) const
{
QFile file(filename);
if (!file.open(QIODevice::WriteOnly))
{
std::cerr << "Cannot write to file " << filename.toStdString() << " !!" << std::endl;
return;
return false;
}
QTextStream stream(&file) ;
@ -158,5 +188,20 @@ void RsCollectionFile::save(const QString& filename) const
stream << _xml_doc.toString() ;
file.close();
return true;
}
bool RsCollectionFile::save() const
{
QString filename;
if(!misc::getSaveFileName(NULL, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Create collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")", filename))
return false;
if (!filename.endsWith("." + RsCollectionFile::ExtensionString))
filename += "." + RsCollectionFile::ExtensionString ;
std::cerr << "Got file name: " << filename.toStdString() << std::endl;
return save(filename);
}

View File

@ -40,14 +40,18 @@ class RsCollectionFile
public:
static const QString ExtensionString ;
// Loads file from disk.
RsCollectionFile(const QString& filename) ;
RsCollectionFile() ;
// create from list of files and directories
RsCollectionFile(const std::vector<DirDetails>& file_entries) ;
// Loads file from disk.
bool load();
bool load(const QString& filename);
// Save to disk
void save(const QString& filename) const ;
bool save() const ;
bool save(const QString& filename) const ;
// Download the content.
void downloadFiles() const ;

View File

@ -21,7 +21,6 @@
#include <stdexcept>
#include <QDesktopServices>
#include <QMessageBox>
#include <QUrl>
#include "RsCollectionFile.h"
#include "RsUrlHandler.h"
@ -30,14 +29,9 @@ bool RsUrlHandler::openUrl(const QUrl& url)
{
if(url.scheme() == QString("file") && url.toLocalFile().endsWith("."+RsCollectionFile::ExtensionString))
{
try
{
RsCollectionFile(url.toLocalFile().toUtf8().constData()).downloadFiles() ;
}
catch(std::runtime_error& e)
{
QMessageBox::warning(NULL,QObject::tr("Treatment of collection file has failed."),QObject::tr("The collection file ") + url.toLocalFile() + QObject::tr(" could not be openned. Reported error is: ") + QString::fromStdString(e.what())) ;
return false ;
RsCollectionFile Collection;
if (Collection.load(url.toLocalFile().toUtf8().constData())) {
Collection.downloadFiles() ;
}
return true;
}

View File

@ -6135,7 +6135,7 @@ Die folgenden Wege sind möglich:</translation>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+121"/>
<location line="+122"/>
<source>Notify</source>
<translation>Meldungen</translation>
</message>
@ -6265,7 +6265,7 @@ Die folgenden Wege sind möglich:</translation>
<translation>Schnellstart Assistent</translation>
</message>
<message>
<location filename="../gui/MainWindow.cpp" line="-205"/>
<location filename="../gui/MainWindow.cpp" line="-206"/>
<source>Search</source>
<translation>Suchen</translation>
</message>
@ -6280,7 +6280,7 @@ Die folgenden Wege sind möglich:</translation>
<translation>Messenger</translation>
</message>
<message>
<location filename="../gui/MainWindow.cpp" line="+165"/>
<location filename="../gui/MainWindow.cpp" line="+166"/>
<source>Show/Hide</source>
<translation>Anzeigen/Verbergen</translation>
</message>
@ -6331,7 +6331,7 @@ Die folgenden Wege sind möglich:</translation>
<translation>Maximieren</translation>
</message>
<message>
<location line="-127"/>
<location line="-128"/>
<source>Unfinished</source>
<translation>unfertig</translation>
</message>
@ -6341,7 +6341,7 @@ Die folgenden Wege sind möglich:</translation>
<translation></translation>
</message>
<message>
<location filename="../gui/MainWindow.cpp" line="+124"/>
<location filename="../gui/MainWindow.cpp" line="+125"/>
<source>Help</source>
<translation>Hilfe</translation>
</message>
@ -6351,7 +6351,7 @@ Die folgenden Wege sind möglich:</translation>
<translation>Über</translation>
</message>
<message>
<location filename="../gui/MainWindow.cpp" line="-173"/>
<location filename="../gui/MainWindow.cpp" line="-174"/>
<source>Forums</source>
<translation>Foren</translation>
</message>
@ -6361,7 +6361,7 @@ Die folgenden Wege sind möglich:</translation>
<translation>RetroShare %1 eine sichere und dezentralisierte Kommunikationsplattform</translation>
</message>
<message>
<location line="+245"/>
<location line="+246"/>
<source>Open Messages</source>
<translation>Öffne Nachrichten</translation>
</message>
@ -6371,12 +6371,12 @@ Die folgenden Wege sind möglich:</translation>
<translation>Anwendungen</translation>
</message>
<message>
<location line="-143"/>
<location line="-144"/>
<source>Plugins</source>
<translation></translation>
</message>
<message>
<location line="+859"/>
<location line="+860"/>
<source>Do you really want to exit RetroShare ?</source>
<translation>Möchtest du RetroShare wirklich beenden?</translation>
</message>
@ -10052,18 +10052,14 @@ Lockdatei:
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui/common/RsUrlHandler.cpp" line="+39"/>
<source>Treatment of collection file has failed.</source>
<location filename="../gui/common/RsCollectionFile.cpp" line="+137"/>
<source>Treatment of collection file has failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+0"/>
<source>The collection file </source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+0"/>
<source> could not be openned. Reported error is: </source>
<source>The collection file %1 could not be openned.
Reported error is: %2</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -10463,14 +10459,12 @@ p, li { white-space: pre-wrap; }
<translation>NEU</translation>
</message>
<message>
<location line="+701"/>
<source>Create selection file</source>
<translation>Erstelle Kollektion</translation>
<translation type="obsolete">Erstelle Kollektion</translation>
</message>
<message>
<location line="+0"/>
<source>Collection files</source>
<translation>Kollektion</translation>
<translation type="obsolete">Kollektion</translation>
</message>
</context>
<context>
@ -10531,6 +10525,35 @@ p, li { white-space: pre-wrap; }
<translation>Herunterladen</translation>
</message>
</context>
<context>
<name>RsCollectionFile</name>
<message>
<location filename="../gui/common/RsCollectionFile.cpp" line="+12"/>
<source>Cannot open file %1</source>
<translation>Kann Datei %1 nicht öffnen</translation>
</message>
<message>
<location line="+10"/>
<source>Error parsing xml file</source>
<translation>Fehler beim Parsen des XML</translation>
</message>
<message>
<location line="+9"/>
<source>Open collection file</source>
<translation>Öffne Kollektion</translation>
</message>
<message>
<location line="+0"/>
<location line="+30"/>
<source>Collection files</source>
<translation>Kollektion</translation>
</message>
<message>
<location line="+0"/>
<source>Create collection file</source>
<translation>Kollektion erstellen</translation>
</message>
</context>
<context>
<name>Rshare</name>
<message>
@ -11833,7 +11856,7 @@ p, li { white-space: pre-wrap; }
<translation>Lade Konfiguration</translation>
</message>
<message>
<location line="+4"/>
<location line="+5"/>
<source>Create interface</source>
<translation>Erstelle Oberfläche</translation>
</message>
@ -12720,7 +12743,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>TransfersDialog</name>
<message>
<location filename="../gui/TransfersDialog.cpp" line="+336"/>
<location filename="../gui/TransfersDialog.cpp" line="+338"/>
<source>Cancel</source>
<translation>Abbrechen</translation>
</message>
@ -12730,7 +12753,7 @@ p, li { white-space: pre-wrap; }
<translation>Fertige ausblenden</translation>
</message>
<message>
<location line="-161"/>
<location line="-162"/>
<location line="+59"/>
<source>Status</source>
<translation>Status</translation>
@ -12754,7 +12777,12 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Downloads:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<location line="+26"/>
<location line="+29"/>
<source>Open Collection</source>
<translation>Öffne Kollektion</translation>
</message>
<message>
<location line="+10"/>
<source>Show cache transfers</source>
<translation>Zeige Cache Übertragungen</translation>
</message>
@ -12838,7 +12866,7 @@ p, li { white-space: pre-wrap; }
<translation>Übertragen</translation>
</message>
<message>
<location line="+127"/>
<location line="+128"/>
<source>Play</source>
<translation>Abspielen</translation>
</message>
@ -12963,7 +12991,7 @@ p, li { white-space: pre-wrap; }
<translation>Soll dieser Download wirklich abgebrochen und gelöscht werden?</translation>
</message>
<message>
<location line="-936"/>
<location line="-937"/>
<source>Speed / Queue position</source>
<translation>Geschwindigkeits- / Warteschlangenposition</translation>
</message>
@ -13005,7 +13033,7 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished"></translation>
</message>
<message>
<location line="+49"/>
<location line="+50"/>
<source>Copy RetroShare Link</source>
<translation>Kopiere RetroShare Link</translation>
</message>
@ -13100,7 +13128,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>TreeStyle_RDM</name>
<message>
<location filename="../gui/RemoteDirModel.cpp" line="-590"/>
<location filename="../gui/RemoteDirModel.cpp" line="+111"/>
<source>My files</source>
<translation>Meine Dateien</translation>
</message>