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 ********/ /** StatusBar section ********/
/* initialize combobox in status bar */ /* initialize combobox in status bar */
statusComboBox = new QComboBox(statusBar()); statusComboBox = new QComboBox(statusBar());
statusComboBox->setFocusPolicy(Qt::ClickFocus);
initializeStatusObject(statusComboBox, true); initializeStatusObject(statusComboBox, true);
QWidget *widget = new QWidget(); QWidget *widget = new QWidget();

View File

@ -916,19 +916,10 @@ void RetroshareDirModel::createCollectionFile(const QModelIndexList &list)
return ; 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; std::vector <DirDetails> dirVec;
getDirDetailsFromSelect(list, dirVec); getDirDetailsFromSelect(list, dirVec);
RsCollectionFile(dirVec).save(filename) ; RsCollectionFile(dirVec).save();
} }
void RetroshareDirModel::downloadSelected(const QModelIndexList &list) void RetroshareDirModel::downloadSelected(const QModelIndexList &list)

View File

@ -44,11 +44,12 @@
#include "TurtleRouterStatistics.h" #include "TurtleRouterStatistics.h"
#include "xprogressbar.h" #include "xprogressbar.h"
#include "settings/rsharesettings.h" #include "settings/rsharesettings.h"
#include "util/misc.h"
#include "common/RsCollectionFile.h"
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsdisc.h> #include <retroshare/rsdisc.h>
#include "util/misc.h"
/**** /****
* #define SHOW_RTT_STATISTICS 1 * #define SHOW_RTT_STATISTICS 1
@ -322,6 +323,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
#endif #endif
QObject::connect(ui._showCacheTransfers_CB,SIGNAL(toggled(bool)),this,SLOT(insertTransfers())) ; 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. // Actions. Only need to be defined once.
pauseAct = new QAction(QIcon(IMAGE_PAUSE), tr("Pause"), this); 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(); 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 showDetailsDialog();
void updateDetailsDialog(); void updateDetailsDialog();
void openCollection();
signals: signals:
void playFiles(QStringList files); void playFiles(QStringList files);

File diff suppressed because it is too large Load Diff

View File

@ -26,33 +26,22 @@
#include "RsCollectionFile.h" #include "RsCollectionFile.h"
#include "RsCollectionDialog.h" #include "RsCollectionDialog.h"
#include "util/misc.h"
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QObject> #include <QObject>
#include <QMessageBox>
#include <QTextStream> #include <QTextStream>
#include <QDomElement> #include <QDomElement>
#include <QDomDocument> #include <QDomDocument>
#include <QMessageBox>
#include <QIcon>
const QString RsCollectionFile::ExtensionString = QString("rscollection") ; const QString RsCollectionFile::ExtensionString = QString("rscollection") ;
RsCollectionFile::RsCollectionFile(const QString& filename) RsCollectionFile::RsCollectionFile()
: _xml_doc("RsCollection"),_filename(filename) : _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 void RsCollectionFile::downloadFiles() const
@ -143,14 +132,55 @@ RsCollectionFile::RsCollectionFile(const std::vector<DirDetails>& file_infos)
recursAddElements(_xml_doc,file_infos[i],root) ; 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); QFile file(filename);
if (!file.open(QIODevice::WriteOnly)) if (!file.open(QIODevice::WriteOnly))
{ {
std::cerr << "Cannot write to file " << filename.toStdString() << " !!" << std::endl; std::cerr << "Cannot write to file " << filename.toStdString() << " !!" << std::endl;
return; return false;
} }
QTextStream stream(&file) ; QTextStream stream(&file) ;
@ -158,5 +188,20 @@ void RsCollectionFile::save(const QString& filename) const
stream << _xml_doc.toString() ; stream << _xml_doc.toString() ;
file.close(); 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: public:
static const QString ExtensionString ; static const QString ExtensionString ;
// Loads file from disk. RsCollectionFile() ;
RsCollectionFile(const QString& filename) ;
// create from list of files and directories // create from list of files and directories
RsCollectionFile(const std::vector<DirDetails>& file_entries) ; RsCollectionFile(const std::vector<DirDetails>& file_entries) ;
// Loads file from disk.
bool load();
bool load(const QString& filename);
// Save to disk // Save to disk
void save(const QString& filename) const ; bool save() const ;
bool save(const QString& filename) const ;
// Download the content. // Download the content.
void downloadFiles() const ; void downloadFiles() const ;

View File

@ -21,7 +21,6 @@
#include <stdexcept> #include <stdexcept>
#include <QDesktopServices> #include <QDesktopServices>
#include <QMessageBox>
#include <QUrl> #include <QUrl>
#include "RsCollectionFile.h" #include "RsCollectionFile.h"
#include "RsUrlHandler.h" #include "RsUrlHandler.h"
@ -30,14 +29,9 @@ bool RsUrlHandler::openUrl(const QUrl& url)
{ {
if(url.scheme() == QString("file") && url.toLocalFile().endsWith("."+RsCollectionFile::ExtensionString)) if(url.scheme() == QString("file") && url.toLocalFile().endsWith("."+RsCollectionFile::ExtensionString))
{ {
try RsCollectionFile Collection;
{ if (Collection.load(url.toLocalFile().toUtf8().constData())) {
RsCollectionFile(url.toLocalFile().toUtf8().constData()).downloadFiles() ; Collection.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 ;
} }
return true; return true;
} }

View File

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