From a0923741a44d45249ed61c6ca9f8b023a7726f7c Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 24 Aug 2009 04:01:26 +0000 Subject: [PATCH] - Make sure items are not overwriten when drag 'n dropping items in RSS feed list --- src/feedList.h | 10 ++++++++++ src/rss.h | 1 + src/rss_imp.cpp | 7 +++++++ src/rss_imp.h | 1 + 4 files changed, 19 insertions(+) diff --git a/src/feedList.h b/src/feedList.h index d872c1e01..ef541145e 100644 --- a/src/feedList.h +++ b/src/feedList.h @@ -132,6 +132,7 @@ public: signals: void foldersAltered(QList folders); + void overwriteAttempt(QString filename); protected slots: void updateCurrentFeed(QTreeWidgetItem* new_item) { @@ -161,6 +162,15 @@ protected: dest_folder = rssmanager; } QList 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) { QTreeWidgetItem *parent_folder = src_item->parent(); if(parent_folder && !folders_altered.contains(parent_folder)) diff --git a/src/rss.h b/src/rss.h index a8002795b..b8ac6ee69 100644 --- a/src/rss.h +++ b/src/rss.h @@ -459,6 +459,7 @@ public: QList getAllFeeds() const; QString getName() const; QString getID() const { return name; } + bool hasChild(QString ID) { return this->contains(ID); } public slots: void refreshAll(); diff --git a/src/rss_imp.cpp b/src/rss_imp.cpp index 150809575..a6cfd1b58 100644 --- a/src/rss_imp.cpp +++ b/src/rss_imp.cpp @@ -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 void RSSImp::on_newFeedButton_clicked() { // 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(foldersAltered(QList)), this, SLOT(updateItemsInfos(QList))); + connect(listStreams, SIGNAL(overwriteAttempt(QString)), this, SLOT(displayOverwriteError(QString))); connect(listNews, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(refreshTextBrowser(QListWidgetItem *))); connect(listNews, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(downloadTorrent())); diff --git a/src/rss_imp.h b/src/rss_imp.h index 21d6c84ad..250f0a31b 100644 --- a/src/rss_imp.h +++ b/src/rss_imp.h @@ -74,6 +74,7 @@ protected slots: void askNewFolder(); void saveFoldersOpenState(); void loadFoldersOpenState(); + void displayOverwriteError(QString filename); public: RSSImp(bittorrent *BTSession);