Browse Source

Update size of selected files when selection is changed

PR #19827.
Closes #19818.
adaptive-webui-19844
Vladimir Golovnev 1 year ago committed by GitHub
parent
commit
eddfaedc4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/gui/addnewtorrentdialog.cpp

11
src/gui/addnewtorrentdialog.cpp

@ -30,6 +30,7 @@
#include "addnewtorrentdialog.h" #include "addnewtorrentdialog.h"
#include <algorithm> #include <algorithm>
#include <functional>
#include <QAction> #include <QAction>
#include <QDateTime> #include <QDateTime>
@ -59,7 +60,6 @@
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "lineedit.h" #include "lineedit.h"
#include "torrenttagsdialog.h" #include "torrenttagsdialog.h"
#include "uithememanager.h"
#include "ui_addnewtorrentdialog.h" #include "ui_addnewtorrentdialog.h"
@ -136,10 +136,11 @@ class AddNewTorrentDialog::TorrentContentAdaptor final
{ {
public: public:
TorrentContentAdaptor(const BitTorrent::TorrentInfo &torrentInfo, PathList &filePaths TorrentContentAdaptor(const BitTorrent::TorrentInfo &torrentInfo, PathList &filePaths
, QVector<BitTorrent::DownloadPriority> &filePriorities) , QVector<BitTorrent::DownloadPriority> &filePriorities, std::function<void ()> onFilePrioritiesChanged)
: m_torrentInfo {torrentInfo} : m_torrentInfo {torrentInfo}
, m_filePaths {filePaths} , m_filePaths {filePaths}
, m_filePriorities {filePriorities} , m_filePriorities {filePriorities}
, m_onFilePrioritiesChanged {std::move(onFilePrioritiesChanged)}
{ {
Q_ASSERT(filePaths.isEmpty() || (filePaths.size() == m_torrentInfo.filesCount())); Q_ASSERT(filePaths.isEmpty() || (filePaths.size() == m_torrentInfo.filesCount()));
@ -240,6 +241,8 @@ public:
{ {
Q_ASSERT(priorities.size() == filesCount()); Q_ASSERT(priorities.size() == filesCount());
m_filePriorities = priorities; m_filePriorities = priorities;
if (m_onFilePrioritiesChanged)
m_onFilePrioritiesChanged();
} }
Path actualStorageLocation() const override Path actualStorageLocation() const override
@ -260,6 +263,7 @@ private:
const BitTorrent::TorrentInfo &m_torrentInfo; const BitTorrent::TorrentInfo &m_torrentInfo;
PathList &m_filePaths; PathList &m_filePaths;
QVector<BitTorrent::DownloadPriority> &m_filePriorities; QVector<BitTorrent::DownloadPriority> &m_filePriorities;
std::function<void ()> m_onFilePrioritiesChanged;
Path m_originalRootFolder; Path m_originalRootFolder;
BitTorrent::TorrentContentLayout m_currentContentLayout; BitTorrent::TorrentContentLayout m_currentContentLayout;
}; };
@ -775,7 +779,8 @@ void AddNewTorrentDialog::setupTreeview()
if (m_torrentParams.filePaths.isEmpty()) if (m_torrentParams.filePaths.isEmpty())
m_torrentParams.filePaths = torrentInfo.filePaths(); m_torrentParams.filePaths = torrentInfo.filePaths();
m_contentAdaptor = std::make_unique<TorrentContentAdaptor>(torrentInfo, m_torrentParams.filePaths, m_torrentParams.filePriorities); m_contentAdaptor = std::make_unique<TorrentContentAdaptor>(torrentInfo, m_torrentParams.filePaths
, m_torrentParams.filePriorities, [this] { updateDiskSpaceLabel(); });
const auto contentLayout = static_cast<BitTorrent::TorrentContentLayout>(m_ui->contentLayoutComboBox->currentIndex()); const auto contentLayout = static_cast<BitTorrent::TorrentContentLayout>(m_ui->contentLayoutComboBox->currentIndex());
m_contentAdaptor->applyContentLayout(contentLayout); m_contentAdaptor->applyContentLayout(contentLayout);

Loading…
Cancel
Save