@@ -556,11 +556,7 @@ SessionImpl::SessionImpl(QObject *parent)
556556 , m_downloadPath(BITTORRENT_SESSION_KEY(u" TempPath" _s), (savePath() / Path(u" temp" _s)))
557557 , m_isDownloadPathEnabled(BITTORRENT_SESSION_KEY(u" TempPathEnabled" _s), false )
558558 , m_isSubcategoriesEnabled(BITTORRENT_SESSION_KEY(u" SubcategoriesEnabled" _s), false )
559- , m_useCategoryPathsInManualMode(BITTORRENT_SESSION_KEY(u" UseCategoryPathsInManualMode" _s), false )
560559 , m_isAutoTMMDisabledByDefault(BITTORRENT_SESSION_KEY(u" DisableAutoTMMByDefault" _s), true )
561- , m_isDisableAutoTMMWhenCategoryChanged(BITTORRENT_SESSION_KEY(u" DisableAutoTMMTriggers/CategoryChanged" _s), false )
562- , m_isDisableAutoTMMWhenDefaultSavePathChanged(BITTORRENT_SESSION_KEY(u" DisableAutoTMMTriggers/DefaultSavePathChanged" _s), true )
563- , m_isDisableAutoTMMWhenCategorySavePathChanged(BITTORRENT_SESSION_KEY(u" DisableAutoTMMTriggers/CategorySavePathChanged" _s), true )
564560 , m_isTrackerEnabled(BITTORRENT_KEY(u" TrackerEnabled" _s), false )
565561 , m_peerTurnover(BITTORRENT_SESSION_KEY(u" PeerTurnover" _s), 4 )
566562 , m_peerTurnoverCutoff(BITTORRENT_SESSION_KEY(u" PeerTurnoverCutOff" _s), 90 )
@@ -1035,18 +1031,6 @@ bool SessionImpl::editCategory(const QString &name, const CategoryOptions &optio
10351031 if (options == currentOptions)
10361032 return false ;
10371033
1038- if (isDisableAutoTMMWhenCategorySavePathChanged ())
1039- {
1040- // This should be done before changing the category options
1041- // to prevent the torrent from being moved at the new save path.
1042-
1043- for (TorrentImpl *const torrent : asConst (m_torrents))
1044- {
1045- if (torrent->category () == name)
1046- torrent->setAutoTMMEnabled (false );
1047- }
1048- }
1049-
10501034 currentOptions = options;
10511035 storeCategories ();
10521036
@@ -1124,31 +1108,6 @@ void SessionImpl::setSubcategoriesEnabled(const bool value)
11241108 emit subcategoriesSupportChanged ();
11251109}
11261110
1127- bool SessionImpl::useCategoryPathsInManualMode () const
1128- {
1129- return m_useCategoryPathsInManualMode;
1130- }
1131-
1132- void SessionImpl::setUseCategoryPathsInManualMode (const bool value)
1133- {
1134- m_useCategoryPathsInManualMode = value;
1135- }
1136-
1137- Path SessionImpl::suggestedSavePath (const QString &categoryName, std::optional<bool > useAutoTMM) const
1138- {
1139- const bool useCategoryPaths = useAutoTMM.value_or (!isAutoTMMDisabledByDefault ()) || useCategoryPathsInManualMode ();
1140- const auto path = (useCategoryPaths ? categorySavePath (categoryName) : savePath ());
1141- return path;
1142- }
1143-
1144- Path SessionImpl::suggestedDownloadPath (const QString &categoryName, std::optional<bool > useAutoTMM) const
1145- {
1146- const bool useCategoryPaths = useAutoTMM.value_or (!isAutoTMMDisabledByDefault ()) || useCategoryPathsInManualMode ();
1147- const auto categoryDownloadPath = this ->categoryDownloadPath (categoryName);
1148- const auto path = ((useCategoryPaths && !categoryDownloadPath.isEmpty ()) ? categoryDownloadPath : downloadPath ());
1149- return path;
1150- }
1151-
11521111TagSet SessionImpl::tags () const
11531112{
11541113 return m_tags;
@@ -1196,36 +1155,6 @@ void SessionImpl::setAutoTMMDisabledByDefault(const bool value)
11961155 m_isAutoTMMDisabledByDefault = value;
11971156}
11981157
1199- bool SessionImpl::isDisableAutoTMMWhenCategoryChanged () const
1200- {
1201- return m_isDisableAutoTMMWhenCategoryChanged;
1202- }
1203-
1204- void SessionImpl::setDisableAutoTMMWhenCategoryChanged (const bool value)
1205- {
1206- m_isDisableAutoTMMWhenCategoryChanged = value;
1207- }
1208-
1209- bool SessionImpl::isDisableAutoTMMWhenDefaultSavePathChanged () const
1210- {
1211- return m_isDisableAutoTMMWhenDefaultSavePathChanged;
1212- }
1213-
1214- void SessionImpl::setDisableAutoTMMWhenDefaultSavePathChanged (const bool value)
1215- {
1216- m_isDisableAutoTMMWhenDefaultSavePathChanged = value;
1217- }
1218-
1219- bool SessionImpl::isDisableAutoTMMWhenCategorySavePathChanged () const
1220- {
1221- return m_isDisableAutoTMMWhenCategorySavePathChanged;
1222- }
1223-
1224- void SessionImpl::setDisableAutoTMMWhenCategorySavePathChanged (const bool value)
1225- {
1226- m_isDisableAutoTMMWhenCategorySavePathChanged = value;
1227- }
1228-
12291158bool SessionImpl::isAddTorrentToQueueTop () const
12301159{
12311160 return m_isAddTorrentToQueueTop;
@@ -2666,8 +2595,9 @@ LoadTorrentParams SessionImpl::initLoadTorrentParams(const AddTorrentParams &add
26662595 else
26672596 loadTorrentParams.category = category;
26682597
2669- const auto defaultSavePath = suggestedSavePath (loadTorrentParams.category , addTorrentParams.useAutoTMM );
2670- const auto defaultDownloadPath = suggestedDownloadPath (loadTorrentParams.category , addTorrentParams.useAutoTMM );
2598+ const auto defaultSavePath = categorySavePath (loadTorrentParams.category );
2599+ const auto categoryDownloadPath = this ->categoryDownloadPath (loadTorrentParams.category );
2600+ const auto defaultDownloadPath = !categoryDownloadPath.isEmpty () ? categoryDownloadPath : downloadPath ();
26712601
26722602 loadTorrentParams.useAutoTMM = addTorrentParams.useAutoTMM .value_or (
26732603 addTorrentParams.savePath .isEmpty () && addTorrentParams.downloadPath .isEmpty () && !isAutoTMMDisabledByDefault ());
@@ -3285,27 +3215,6 @@ void SessionImpl::setSavePath(const Path &path)
32853215 if (newPath == m_savePath)
32863216 return ;
32873217
3288- if (isDisableAutoTMMWhenDefaultSavePathChanged ())
3289- {
3290- // This should be done before changing the save path
3291- // to prevent the torrent from being moved at the new save path.
3292-
3293- QSet<QString> affectedCatogories {{}}; // includes default (unnamed) category
3294- for (auto it = m_categories.cbegin (); it != m_categories.cend (); ++it)
3295- {
3296- const QString &categoryName = it.key ();
3297- const CategoryOptions &categoryOptions = it.value ();
3298- if (categoryOptions.savePath .isRelative ())
3299- affectedCatogories.insert (categoryName);
3300- }
3301-
3302- for (TorrentImpl *const torrent : asConst (m_torrents))
3303- {
3304- if (affectedCatogories.contains (torrent->category ()))
3305- torrent->setAutoTMMEnabled (false );
3306- }
3307- }
3308-
33093218 m_savePath = newPath;
33103219 for (TorrentImpl *const torrent : asConst (m_torrents))
33113220 torrent->handleCategoryOptionsChanged ();
@@ -3325,29 +3234,6 @@ void SessionImpl::setDownloadPath(const Path &path)
33253234 if (newPath == m_downloadPath)
33263235 return ;
33273236
3328- if (isDisableAutoTMMWhenDefaultSavePathChanged ())
3329- {
3330- // This should be done before changing the save path
3331- // to prevent the torrent from being moved at the new save path.
3332-
3333- QSet<QString> affectedCatogories {{}}; // includes default (unnamed) category
3334- for (auto it = m_categories.cbegin (); it != m_categories.cend (); ++it)
3335- {
3336- const QString &categoryName = it.key ();
3337- const CategoryOptions &categoryOptions = it.value ();
3338- const DownloadPathOption downloadPathOption =
3339- categoryOptions.downloadPath .value_or (DownloadPathOption {isDownloadPathEnabled (), downloadPath ()});
3340- if (downloadPathOption.enabled && downloadPathOption.path .isRelative ())
3341- affectedCatogories.insert (categoryName);
3342- }
3343-
3344- for (TorrentImpl *const torrent : asConst (m_torrents))
3345- {
3346- if (affectedCatogories.contains (torrent->category ()))
3347- torrent->setAutoTMMEnabled (false );
3348- }
3349- }
3350-
33513237 m_downloadPath = newPath;
33523238 for (TorrentImpl *const torrent : asConst (m_torrents))
33533239 torrent->handleCategoryOptionsChanged ();
0 commit comments