mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Prevent RSS folder from being moved into itself
PR #18619. Closes #18446.
This commit is contained in:
parent
2f9b313287
commit
8df68ac878
@ -185,8 +185,11 @@ nonstd::expected<void, QString> Session::moveItem(Item *item, const QString &des
|
||||
if (!result)
|
||||
return result.get_unexpected();
|
||||
|
||||
auto srcFolder = static_cast<Folder *>(m_itemsByPath.value(Item::parentPath(item->path())));
|
||||
const auto destFolder = result.value();
|
||||
if (static_cast<Item *>(destFolder) == item)
|
||||
return nonstd::make_unexpected(tr("Couldn't move folder into itself."));
|
||||
|
||||
auto srcFolder = static_cast<Folder *>(m_itemsByPath.value(Item::parentPath(item->path())));
|
||||
if (srcFolder != destFolder)
|
||||
{
|
||||
srcFolder->removeItem(item);
|
||||
|
@ -105,7 +105,8 @@ FeedListWidget::FeedListWidget(QWidget *parent)
|
||||
m_rssToTreeItemMapping[RSS::Session::instance()->rootFolder()] = invisibleRootItem();
|
||||
|
||||
m_unreadStickyItem = new FeedListItem(this);
|
||||
m_unreadStickyItem->setData(0, Qt::UserRole, QVariant::fromValue(RSS::Session::instance()->rootFolder()));
|
||||
m_unreadStickyItem->setData(0, Qt::UserRole, QVariant::fromValue(
|
||||
reinterpret_cast<intptr_t>(RSS::Session::instance()->rootFolder())));
|
||||
m_unreadStickyItem->setText(0, tr("Unread (%1)").arg(RSS::Session::instance()->rootFolder()->unreadCount()));
|
||||
m_unreadStickyItem->setData(0, Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"mail-inbox"_qs));
|
||||
m_unreadStickyItem->setData(0, StickyItemTagRole, true);
|
||||
@ -211,9 +212,10 @@ QList<QTreeWidgetItem *> FeedListWidget::getAllOpenedFolders(QTreeWidgetItem *pa
|
||||
|
||||
RSS::Item *FeedListWidget::getRSSItem(QTreeWidgetItem *item) const
|
||||
{
|
||||
if (!item) return nullptr;
|
||||
if (!item)
|
||||
return nullptr;
|
||||
|
||||
return item->data(0, Qt::UserRole).value<RSS::Item *>();
|
||||
return reinterpret_cast<RSS::Item *>(item->data(0, Qt::UserRole).value<intptr_t>());
|
||||
}
|
||||
|
||||
QTreeWidgetItem *FeedListWidget::mapRSSItem(RSS::Item *rssItem) const
|
||||
@ -275,7 +277,7 @@ QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem
|
||||
{
|
||||
auto *item = new FeedListItem;
|
||||
item->setData(0, Qt::DisplayRole, u"%1 (%2)"_qs.arg(rssItem->name(), QString::number(rssItem->unreadCount())));
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(rssItem));
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(reinterpret_cast<intptr_t>(rssItem)));
|
||||
m_rssToTreeItemMapping[rssItem] = item;
|
||||
|
||||
QIcon icon;
|
||||
|
Loading…
Reference in New Issue
Block a user