diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index e3feef3e8..d8aa037ae 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -148,6 +148,7 @@ ForumsDialog::ForumsDialog(QWidget *parent) connect(ui.expandButton, SIGNAL(clicked()), this, SLOT(togglethreadview())); connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(previousMessage())); connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(nextMessage())); + connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadAllFiles())); connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged())); @@ -1251,6 +1252,20 @@ void ForumsDialog::nextMessage () } } +void ForumsDialog::downloadAllFiles() +{ + QStringList urls; + if (RsHtml::findAnchors(ui.postText->toHtml(), urls) == false) { + return; + } + + if (urls.count() == 0) { + return; + } + + RetroShareLink::process(urls, RetroShareLink::TYPE_FILE, true); +} + // TODO #if 0 void ForumsDialog::removemessage() diff --git a/retroshare-gui/src/gui/ForumsDialog.h b/retroshare-gui/src/gui/ForumsDialog.h index 521e04cb7..0a2b5dd71 100644 --- a/retroshare-gui/src/gui/ForumsDialog.h +++ b/retroshare-gui/src/gui/ForumsDialog.h @@ -83,6 +83,7 @@ private slots: void previousMessage (); void nextMessage (); + void downloadAllFiles(); void changedViewBox(); diff --git a/retroshare-gui/src/gui/ForumsDialog.ui b/retroshare-gui/src/gui/ForumsDialog.ui index 080221ddf..e9d5e5f18 100644 --- a/retroshare-gui/src/gui/ForumsDialog.ui +++ b/retroshare-gui/src/gui/ForumsDialog.ui @@ -1000,7 +1000,7 @@ background: white;} - + @@ -1026,6 +1026,26 @@ background: white;} + + + + + 24 + 24 + + + + Qt::NoFocus + + + Download all files + + + + :/images/down.png:/images/down.png + + + diff --git a/retroshare-gui/src/gui/MessagesDialog.ui b/retroshare-gui/src/gui/MessagesDialog.ui index 1e3bd4bd4..3632a2ef9 100644 --- a/retroshare-gui/src/gui/MessagesDialog.ui +++ b/retroshare-gui/src/gui/MessagesDialog.ui @@ -1345,7 +1345,7 @@ padding: 4px; 6 - + @@ -1355,7 +1355,7 @@ padding: 4px; - + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> @@ -1365,7 +1365,7 @@ p, li { white-space: pre-wrap; } - + @@ -1378,26 +1378,6 @@ p, li { white-space: pre-wrap; } - - - - Qt::NoFocus - - - - - - - :/images/edit_remove24.png:/images/edit_remove24.png - - - true - - - true - - - @@ -1419,17 +1399,31 @@ p, li { white-space: pre-wrap; } Qt::NoFocus - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Download all Recommended Files</p></body></html> + Download all Recommended Files + + + + :/images/down.png:/images/down.png + + + + + + + Qt::NoFocus - :/images/down.png:/images/down.png + :/images/edit_remove24.png:/images/edit_remove24.png + + + true + + + true diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 151a7bcc4..78f014d58 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -852,6 +852,29 @@ bool RetroShareLink::process(int flag) return false; } +/*static*/ int RetroShareLink::process(QStringList &urls, RetroShareLink::enumType type /*= RetroShareLink::TYPE_UNKNOWN*/, bool notify /*= true*/) +{ + int processed = 0; + + for (QStringList::iterator it = urls.begin(); it != urls.end(); it++) { + RetroShareLink link(*it); + if (link.valid() && (type == RetroShareLink::TYPE_UNKNOWN || link.type() == type)) { + if (link.process(0)) { + processed++; + } + } + } + + if (notify) { + QString text = QObject::tr("%1 of %2 RetroShare links processed.").arg(processed).arg(urls.count()); + QMessageBox mb(QObject::tr("Request Confirmation"), text, QMessageBox::Information, QMessageBox::Ok, 0, 0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + + return processed; +} + void RSLinkClipboard::copyLinks(const std::vector& links) { QString res ; diff --git a/retroshare-gui/src/gui/RetroShareLink.h b/retroshare-gui/src/gui/RetroShareLink.h index 43ee107de..260ffb9ad 100644 --- a/retroshare-gui/src/gui/RetroShareLink.h +++ b/retroshare-gui/src/gui/RetroShareLink.h @@ -38,7 +38,7 @@ #include #define RSLINK_PROCESS_NOTIFY_SUCCESS 1 // notify on success -#define RSLINK_PROCESS_NOTIFY_ERROR 2 // notify on error +#define RSLINK_PROCESS_NOTIFY_ERROR 2 // notify on error #define RSLINK_PROCESS_NOTIFY_ALL -1 @@ -93,6 +93,8 @@ class RetroShareLink bool process(int flag); + static int process(QStringList &urls, RetroShareLink::enumType type = RetroShareLink::TYPE_UNKNOWN, bool notify = true); + private: void fromString(const QString &url); void fromUrl(const QUrl &url); diff --git a/retroshare-gui/src/gui/chat/HandleRichText.cpp b/retroshare-gui/src/gui/chat/HandleRichText.cpp index 61bad736d..e606402e7 100644 --- a/retroshare-gui/src/gui/chat/HandleRichText.cpp +++ b/retroshare-gui/src/gui/chat/HandleRichText.cpp @@ -42,33 +42,6 @@ void EmbedInHtmlImg::InitFromAwkwardHash(const QHash< QString, QString >& hash) myRE.setPattern(newRE); } -QString formatText(const QString &text, unsigned int flag) -{ - if (flag == 0) { - // nothing to do - return text; - } - - QDomDocument doc; - if (doc.setContent(text) == false) { - // convert text with QTextBrowser - QTextBrowser textBrowser; - textBrowser.setText(text); - doc.setContent(textBrowser.toHtml()); - } - - QDomElement body = doc.documentElement(); - if (flag & RSHTML_FORMATTEXT_EMBED_SMILEYS) { - embedHtml(doc, body, defEmbedImg); - } - if (flag & RSHTML_FORMATTEXT_EMBED_LINKS) { - EmbedInHtmlAhref defEmbedAhref; - embedHtml(doc, body, defEmbedAhref); - } - - return doc.toString(-1); // -1 removes any annoying carriage return misinterpreted by QTextEdit -} - /** * Parses a DOM tree and replaces text by HTML tags. * The tree is traversed depth-first, but only through children of Element type @@ -86,7 +59,7 @@ QString formatText(const QString &text, unsigned int flag) * @param[in,out] currentElement The current node (which is of type Element) * @param[in] embedInfos The regular expression and the type of embedding to use */ -void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embedInfos) +static void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embedInfos) { if(embedInfos.myRE.pattern().length() == 0) // we'll get stuck with an empty regexp return; @@ -174,4 +147,72 @@ void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embe } } +QString formatText(const QString &text, unsigned int flag) +{ + if (flag == 0) { + // nothing to do + return text; + } + + QDomDocument doc; + if (doc.setContent(text) == false) { + // convert text with QTextBrowser + QTextBrowser textBrowser; + textBrowser.setText(text); + doc.setContent(textBrowser.toHtml()); + } + + QDomElement body = doc.documentElement(); + if (flag & RSHTML_FORMATTEXT_EMBED_SMILEYS) { + embedHtml(doc, body, defEmbedImg); + } + if (flag & RSHTML_FORMATTEXT_EMBED_LINKS) { + EmbedInHtmlAhref defEmbedAhref; + embedHtml(doc, body, defEmbedAhref); + } + + return doc.toString(-1); // -1 removes any annoying carriage return misinterpreted by QTextEdit +} + +static void findElements(QDomDocument& doc, QDomElement& currentElement, const QString& nodeName, const QString& nodeAttribute, QStringList &elements) +{ + if(nodeName.isEmpty()) { + return; + } + + QDomNodeList children = currentElement.childNodes(); + for (uint index = 0; index < children.length(); index++) { + QDomNode node = children.item(index); + if (node.isElement()) { + QDomElement element = node.toElement(); + if (QString::compare(element.tagName(), nodeName, Qt::CaseInsensitive) == 0) { + if (nodeAttribute.isEmpty()) { + // use text + elements.append(element.text()); + } else { + QString attribute = element.attribute(nodeAttribute); + if (attribute.isEmpty() == false) { + elements.append(attribute); + } + } + continue; + } + findElements(doc, element, nodeName, nodeAttribute, elements); + } + } +} + +bool findAnchors(const QString &text, QStringList& urls) +{ + QDomDocument doc; + if (doc.setContent(text) == false) { + return false; + } + + QDomElement body = doc.documentElement(); + findElements(doc, body, "a", "href", urls); + + return true; +} + } // namespace RsHtml diff --git a/retroshare-gui/src/gui/chat/HandleRichText.h b/retroshare-gui/src/gui/chat/HandleRichText.h index a85d7de42..e5a2c046f 100644 --- a/retroshare-gui/src/gui/chat/HandleRichText.h +++ b/retroshare-gui/src/gui/chat/HandleRichText.h @@ -109,8 +109,7 @@ public: extern EmbedInHtmlImg defEmbedImg; QString formatText(const QString &text, unsigned int flag); -void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embedInfos); - +bool findAnchors(const QString &text, QStringList& urls); } // namespace RsHtml diff --git a/retroshare-gui/src/lang/retroshare_de.qm b/retroshare-gui/src/lang/retroshare_de.qm index ee2e02eaa..1981889af 100644 Binary files a/retroshare-gui/src/lang/retroshare_de.qm and b/retroshare-gui/src/lang/retroshare_de.qm differ diff --git a/retroshare-gui/src/lang/retroshare_de.ts b/retroshare-gui/src/lang/retroshare_de.ts index aef558f58..cf149f196 100644 --- a/retroshare-gui/src/lang/retroshare_de.ts +++ b/retroshare-gui/src/lang/retroshare_de.ts @@ -1063,7 +1063,7 @@ p, li { white-space: pre-wrap; } Alle als gelesen markieren - + Enable Auto-download Aktiviere Auto-Download @@ -1073,7 +1073,7 @@ p, li { white-space: pre-wrap; } Kanal erstellen - + Unsubscribe Abbestellen @@ -2341,7 +2341,23 @@ p, li { white-space: pre-wrap; } Drag'n'Drop Dateien aus den Suchergebnissen - + + + Drop file error. + Dateifehler bei Drag'n'Drop. + + + + Directory can't be dropped, only files are accepted. + Ordner können nicht für Drag'n'Drop genutzt werden. Nur Dateien werden akzeptiert. + + + + File not found or file name not accepted. + Datei nicht gefunden oder Dateiname nicht akzeptiert. + + + Add Extra File Zusätzlich eine Datei hinzufügen @@ -2538,17 +2554,17 @@ p, li { white-space: pre-wrap; } - + Drop file error. Dateifehler bei Drag'n'Drop. - + File not found or file name not accepted. Datei nicht gefunden oder Dateiname nicht akzeptiert. - + Directory can't be dropped, only files are accepted. Ordner können nicht für Drag'n'Drop genutzt werden. Nur Dateien werden akzeptiert. @@ -3551,7 +3567,7 @@ p, li { white-space: pre-wrap; } ForumMsgItem - + Remove Item Eintrag entfernen @@ -3561,8 +3577,8 @@ p, li { white-space: pre-wrap; } Erweitern - - + + Subject: Betreff: @@ -3572,17 +3588,17 @@ p, li { white-space: pre-wrap; } Gehe zum Forumbeitrag - + Unsubscribe To Forum Forum abbestellen - + Reply Antwort - + Send Senden @@ -3592,7 +3608,7 @@ p, li { white-space: pre-wrap; } Unterzeichnen - + Forum Post Beitrag @@ -3672,7 +3688,7 @@ p, li { white-space: pre-wrap; } ForumsDialog - + Subscribe to Forum Forum abonnieren @@ -3771,7 +3787,7 @@ p, li { white-space: pre-wrap; } keine - + RetroShare @@ -3787,7 +3803,7 @@ p, li { white-space: pre-wrap; } Du kannst einem anonymen Autor nicht antworten - + Your Forums Deine Foren @@ -3864,24 +3880,24 @@ p, li { white-space: pre-wrap; } - + Date Datum - - + + Title Titel - - + + Author Autor - + Signed Unterzeichnet @@ -3909,7 +3925,12 @@ p, li { white-space: pre-wrap; } Nächster Beitrag - + + Download all files + Alle Dateien runterladen + + + Reply Message Auf Beitrag antworten @@ -3930,7 +3951,7 @@ p, li { white-space: pre-wrap; } - + Start New Thread Erstelle neues Thema @@ -3958,7 +3979,7 @@ p, li { white-space: pre-wrap; } Inhalt - + Mark as read Als gelesen markieren @@ -5633,7 +5654,7 @@ Bitte gib etwas Speicher frei und drücke OK. MessageComposer - + Compose Verfassen @@ -5860,7 +5881,7 @@ Bitte gib etwas Speicher frei und drücke OK. Blockquote hinzufügen - + &Left &Links @@ -5880,7 +5901,7 @@ Bitte gib etwas Speicher frei und drücke OK. &Blocksatz - + Save Message Nachricht speichern @@ -6217,12 +6238,12 @@ Willst Du die Nachricht speichern ? Von - + Size Grösse - + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;"> @@ -6322,7 +6343,12 @@ p, li { white-space: pre-wrap; } Gesendet - + + Download all Recommended Files + Alle Dateien runterladen + + + Cc: Cc: @@ -6384,13 +6410,13 @@ p, li { white-space: pre-wrap; } Dokument drucken - + Subject Betreff - + Subject: Betreff: @@ -6415,7 +6441,7 @@ p, li { white-space: pre-wrap; } Prüfsumme - + Print Drucken @@ -6476,15 +6502,14 @@ p, li { white-space: pre-wrap; } Allen antworten - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Download all Recommended Files</p></body></html> - <html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Alle Dateien runterladen</p></body></html> + <html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Alle Dateien runterladen</p></body></html> - + Total Inbox: Posteingang gesamt: @@ -8958,7 +8983,7 @@ Lockdatei: Vielleicht ist das Passwort falsch - + File Request Confirmation Bestätigung der Dateianforderung @@ -9043,12 +9068,26 @@ Lockdatei: The receipient of the message is unknown. Der Empfänger der Nachricht ist unbekannt. + + + %1 of %2 RetroShare links processed. + %1 von %2 RetroShare Links verarbeitet. + + + %1 of %2 RetroShare links processed + %1 von %2 RetroShare Links verarbeitet. + + + + Request Confirmation + Anfrage bestätigen + The forum message could not be found. Der Forumbeitrag "%1" konnte nicht gefunden werden. - + Channel Request canceled Kanalanfrage abgebrochen @@ -11989,7 +12028,7 @@ p, li { white-space: pre-wrap; } - + Showing: whole network Anzeige: Ganzes Netzwerk