Browse Source

- Make sure items are not overwriten when drag 'n dropping items in RSS feed list

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
a0923741a4
  1. 10
      src/feedList.h
  2. 1
      src/rss.h
  3. 7
      src/rss_imp.cpp
  4. 1
      src/rss_imp.h

10
src/feedList.h

@ -132,6 +132,7 @@ public: @@ -132,6 +132,7 @@ public:
signals:
void foldersAltered(QList<QTreeWidgetItem*> folders);
void overwriteAttempt(QString filename);
protected slots:
void updateCurrentFeed(QTreeWidgetItem* new_item) {
@ -161,6 +162,15 @@ protected: @@ -161,6 +162,15 @@ protected:
dest_folder = rssmanager;
}
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) {
QTreeWidgetItem *parent_folder = src_item->parent();
if(parent_folder && !folders_altered.contains(parent_folder))

1
src/rss.h

@ -459,6 +459,7 @@ public: @@ -459,6 +459,7 @@ public:
QList<RssStream*> getAllFeeds() const;
QString getName() const;
QString getID() const { return name; }
bool hasChild(QString ID) { return this->contains(ID); }
public slots:
void refreshAll();

7
src/rss_imp.cpp

@ -120,6 +120,12 @@ void RSSImp::askNewFolder() { @@ -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){ @@ -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<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(itemDoubleClicked(QListWidgetItem *)), this, SLOT(downloadTorrent()));

1
src/rss_imp.h

@ -74,6 +74,7 @@ protected slots: @@ -74,6 +74,7 @@ protected slots:
void askNewFolder();
void saveFoldersOpenState();
void loadFoldersOpenState();
void displayOverwriteError(QString filename);
public:
RSSImp(bittorrent *BTSession);

Loading…
Cancel
Save