mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 13:28:50 +03:00
- Make sure items are not overwriten when drag 'n dropping items in RSS feed list
This commit is contained in:
parent
8e2efc2950
commit
a0923741a4
4 changed files with 19 additions and 0 deletions
|
@ -132,6 +132,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void foldersAltered(QList<QTreeWidgetItem*> folders);
|
void foldersAltered(QList<QTreeWidgetItem*> folders);
|
||||||
|
void overwriteAttempt(QString filename);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void updateCurrentFeed(QTreeWidgetItem* new_item) {
|
void updateCurrentFeed(QTreeWidgetItem* new_item) {
|
||||||
|
@ -161,6 +162,15 @@ protected:
|
||||||
dest_folder = rssmanager;
|
dest_folder = rssmanager;
|
||||||
}
|
}
|
||||||
QList<QTreeWidgetItem *> src_items = selectedItems();
|
QList<QTreeWidgetItem *> src_items = selectedItems();
|
||||||
|
// Check if there is not going to overwrite another file
|
||||||
|
foreach(QTreeWidgetItem *src_item, src_items) {
|
||||||
|
RssFile *file = getRSSItem(src_item);
|
||||||
|
if(dest_folder->hasChild(file->getID())) {
|
||||||
|
emit overwriteAttempt(file->getID());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Proceed with the move
|
||||||
foreach(QTreeWidgetItem *src_item, src_items) {
|
foreach(QTreeWidgetItem *src_item, src_items) {
|
||||||
QTreeWidgetItem *parent_folder = src_item->parent();
|
QTreeWidgetItem *parent_folder = src_item->parent();
|
||||||
if(parent_folder && !folders_altered.contains(parent_folder))
|
if(parent_folder && !folders_altered.contains(parent_folder))
|
||||||
|
|
|
@ -459,6 +459,7 @@ public:
|
||||||
QList<RssStream*> getAllFeeds() const;
|
QList<RssStream*> getAllFeeds() const;
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
QString getID() const { return name; }
|
QString getID() const { return name; }
|
||||||
|
bool hasChild(QString ID) { return this->contains(ID); }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void refreshAll();
|
void refreshAll();
|
||||||
|
|
|
@ -120,6 +120,12 @@ void RSSImp::askNewFolder() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSSImp::displayOverwriteError(QString filename) {
|
||||||
|
QMessageBox::warning(this, tr("Overwrite attempt"),
|
||||||
|
tr("You cannot overwrite %1 item.", "You cannot overwrite myFolder item.").arg(filename),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
}
|
||||||
|
|
||||||
// add a stream by a button
|
// add a stream by a button
|
||||||
void RSSImp::on_newFeedButton_clicked() {
|
void RSSImp::on_newFeedButton_clicked() {
|
||||||
// Determine parent folder for new feed
|
// Determine parent folder for new feed
|
||||||
|
@ -512,6 +518,7 @@ RSSImp::RSSImp(bittorrent *BTSession) : QWidget(), BTSession(BTSession){
|
||||||
|
|
||||||
connect(listStreams, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(refreshNewsList(QTreeWidgetItem*)));
|
connect(listStreams, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(refreshNewsList(QTreeWidgetItem*)));
|
||||||
connect(listStreams, SIGNAL(foldersAltered(QList<QTreeWidgetItem*>)), this, SLOT(updateItemsInfos(QList<QTreeWidgetItem*>)));
|
connect(listStreams, SIGNAL(foldersAltered(QList<QTreeWidgetItem*>)), this, SLOT(updateItemsInfos(QList<QTreeWidgetItem*>)));
|
||||||
|
connect(listStreams, SIGNAL(overwriteAttempt(QString)), this, SLOT(displayOverwriteError(QString)));
|
||||||
|
|
||||||
connect(listNews, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(refreshTextBrowser(QListWidgetItem *)));
|
connect(listNews, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(refreshTextBrowser(QListWidgetItem *)));
|
||||||
connect(listNews, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(downloadTorrent()));
|
connect(listNews, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(downloadTorrent()));
|
||||||
|
|
|
@ -74,6 +74,7 @@ protected slots:
|
||||||
void askNewFolder();
|
void askNewFolder();
|
||||||
void saveFoldersOpenState();
|
void saveFoldersOpenState();
|
||||||
void loadFoldersOpenState();
|
void loadFoldersOpenState();
|
||||||
|
void displayOverwriteError(QString filename);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RSSImp(bittorrent *BTSession);
|
RSSImp(bittorrent *BTSession);
|
||||||
|
|
Loading…
Reference in a new issue