summaryrefslogtreecommitdiff
path: root/SampleDownloader/FileNode.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2025-01-09 22:12:12 +0100
committerChristoph Berg <myon@debian.org>2025-01-09 22:12:12 +0100
commit98c02f78b26811ba5d9962ba27ec24cacf82bb22 (patch)
treedaaf609cde31d8fb3b6c3457c43663d14f0dda80 /SampleDownloader/FileNode.cpp
parent332d2ce88c2f0bc2908cacdc6707e2f9fa49f26d (diff)
parent992d4b4b8d3f3a630a2cf00d593ee4ce4dfa7ce8 (diff)
Update upstream source from tag 'upstream/2.7.0_rc8+repack'
Update to upstream version '2.7.0~rc8+repack' with Debian dir 6fce941c8282d35c8df23d3de779a42e27688bc1
Diffstat (limited to 'SampleDownloader/FileNode.cpp')
-rwxr-xr-xSampleDownloader/FileNode.cpp158
1 files changed, 79 insertions, 79 deletions
diff --git a/SampleDownloader/FileNode.cpp b/SampleDownloader/FileNode.cpp
index c0875dd3..e274dc5a 100755
--- a/SampleDownloader/FileNode.cpp
+++ b/SampleDownloader/FileNode.cpp
@@ -1,79 +1,79 @@
-#include "FileNode.hpp"
-
-#include <QVariant>
-#include <QUrl>
-#include <QDir>
-#include <QFileInfo>
-
-#include "Directory.hpp"
-#include "widgets/MessageBox.hpp"
-
-FileNode::FileNode (QTreeWidgetItem * parent
- , QNetworkAccessManager * network_manager
- , QString const& local_file_path
- , QUrl const& url
- , bool http_only)
- : QTreeWidgetItem {parent, Type}
- , remote_file_ {this, network_manager, local_file_path, http_only}
- , block_sync_ {false}
-{
- sync_blocker b {this};
- setFlags (flags () | Qt::ItemIsUserCheckable);
- setText (0, QFileInfo {local_file_path}.fileName ()); // display
- setData (0, Qt::UserRole, url);
- setData (0, Qt::UserRole + 1, local_file_path); // local absolute path
- setCheckState (0, Qt::Unchecked);
-}
-
-void FileNode::error (QString const& title, QString const& message)
-{
- if (MessageBox::Retry == MessageBox::warning_message (treeWidget (), title, message
- , QString {}, MessageBox::Cancel | MessageBox::Retry
- , MessageBox::Cancel))
- {
- sync (true);
- }
-}
-
-bool FileNode::sync (bool local)
-{
- if (block_sync_)
- {
- return true;
- }
- return remote_file_.sync (data (0, Qt::UserRole).toUrl (), local);
-}
-
-void FileNode::download_progress (qint64 bytes_received, qint64 total_bytes)
-{
- sync_blocker b {this};
- setData (1, Qt::UserRole, total_bytes);
- if (bytes_received < 0)
- {
- setData (1, Qt::DisplayRole, 0ll);
- setCheckState (0, Qt::Unchecked);
- }
- else
- {
- setData (1, Qt::DisplayRole, bytes_received);
- }
- static_cast<Directory *> (treeWidget ())->update (parent ());
-}
-
-void FileNode::download_finished (bool success)
-{
- sync_blocker b {this};
- if (!success)
- {
- setData (1, Qt::UserRole, 0ll);
- setData (1, Qt::DisplayRole, 0ll);
- }
- setCheckState (0, success ? Qt::Checked : Qt::Unchecked);
- static_cast<Directory *> (treeWidget ())->update (parent ());
-}
-
-void FileNode::abort ()
-{
- sync_blocker b {this};
- remote_file_.abort ();
-}
+#include "FileNode.hpp"
+
+#include <QVariant>
+#include <QUrl>
+#include <QDir>
+#include <QFileInfo>
+
+#include "Directory.hpp"
+#include "widgets/MessageBox.hpp"
+
+FileNode::FileNode (QTreeWidgetItem * parent
+ , QNetworkAccessManager * network_manager
+ , QString const& local_file_path
+ , QUrl const& url
+ , bool http_only)
+ : QTreeWidgetItem {parent, Type}
+ , remote_file_ {this, network_manager, local_file_path, http_only}
+ , block_sync_ {false}
+{
+ sync_blocker b {this};
+ setFlags (flags () | Qt::ItemIsUserCheckable);
+ setText (0, QFileInfo {local_file_path}.fileName ()); // display
+ setData (0, Qt::UserRole, url);
+ setData (0, Qt::UserRole + 1, local_file_path); // local absolute path
+ setCheckState (0, Qt::Unchecked);
+}
+
+void FileNode::error (QString const& title, QString const& message)
+{
+ if (MessageBox::Retry == MessageBox::warning_message (treeWidget (), title, message
+ , QString {}, MessageBox::Cancel | MessageBox::Retry
+ , MessageBox::Cancel))
+ {
+ sync (true);
+ }
+}
+
+bool FileNode::sync (bool local)
+{
+ if (block_sync_)
+ {
+ return true;
+ }
+ return remote_file_.sync (data (0, Qt::UserRole).toUrl (), local);
+}
+
+void FileNode::download_progress (qint64 bytes_received, qint64 total_bytes)
+{
+ sync_blocker b {this};
+ setData (1, Qt::UserRole, total_bytes);
+ if (bytes_received < 0)
+ {
+ setData (1, Qt::DisplayRole, 0ll);
+ setCheckState (0, Qt::Unchecked);
+ }
+ else
+ {
+ setData (1, Qt::DisplayRole, bytes_received);
+ }
+ static_cast<Directory *> (treeWidget ())->update (parent ());
+}
+
+void FileNode::download_finished (bool success)
+{
+ sync_blocker b {this};
+ if (!success)
+ {
+ setData (1, Qt::UserRole, 0ll);
+ setData (1, Qt::DisplayRole, 0ll);
+ }
+ setCheckState (0, success ? Qt::Checked : Qt::Unchecked);
+ static_cast<Directory *> (treeWidget ())->update (parent ());
+}
+
+void FileNode::abort ()
+{
+ sync_blocker b {this};
+ remote_file_.abort ();
+}