1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

- Fixed crash when selecting feeds after they were moved

This commit is contained in:
Christophe Dumez 2009-08-23 09:05:36 +00:00
parent 2fa43dd973
commit 480df1f5dc
3 changed files with 20 additions and 9 deletions

View File

@ -34,6 +34,7 @@ public:
if(item->parent()) {
path = getItemPath(item->parent());
}
Q_ASSERT(!item->text(1).isEmpty());
path << item->text(1);
}
return path;
@ -45,7 +46,7 @@ protected:
if(item && rssmanager->getFile(getItemPath(item))->getType() != RssFile::FOLDER)
event->ignore();
else {
QAbstractItemView::dragMoveEvent(event);
QTreeWidget::dragMoveEvent(event);
}
}
@ -61,7 +62,7 @@ protected:
qDebug("Moving file %s to %s", src_path.join("\\").toLocal8Bit().data(), dest_path.join("\\").toLocal8Bit().data());
rssmanager->moveFile(src_path, dest_path);
}
QAbstractItemView::dropEvent (event);
QTreeWidget::dropEvent (event);
if(dest_item)
dest_item->setExpanded(true);
}

View File

@ -168,10 +168,12 @@ void RssFolder::refresh(QStringList full_path) {
RssFile* RssFolder::getFile(QStringList full_path) const {
if(full_path.isEmpty()) return rssmanager;
QString name = full_path.last();
QString file_name = full_path.last();
Q_ASSERT(!file_name.isEmpty());
if(full_path.size() == 1) {
Q_ASSERT(this->contains(name));
return (*this)[name];
qDebug("getFile: %s from folder %s", file_name.toLocal8Bit().data(), name.toLocal8Bit().data());
Q_ASSERT(this->contains(file_name));
return (*this)[file_name];
} else {
QString subfolder_name = full_path.takeFirst();
Q_ASSERT(this->contains(subfolder_name));
@ -309,9 +311,11 @@ void RssFolder::addFile(RssFile * item) {
if(item->getType() == RssFile::STREAM) {
Q_ASSERT(!this->contains(((RssStream*)item)->getUrl()));
(*this)[((RssStream*)item)->getUrl()] = item;
qDebug("Added feed %s to folder ./%s", ((RssStream*)item)->getUrl().toLocal8Bit().data(), name.toLocal8Bit().data());
} else {
Q_ASSERT(!this->contains(((RssFolder*)item)->getName()));
(*this)[((RssFolder*)item)->getName()] = item;
qDebug("Added folder %s to folder ./%s", ((RssFolder*)item)->getName().toLocal8Bit().data(), name.toLocal8Bit().data());
}
}

View File

@ -215,7 +215,7 @@ void RSSImp::openNewsUrl() {
}
}
//right-click on stream : give him an alias
//right-click on stream : give it an alias
void RSSImp::renameFiles() {
QList<QTreeWidgetItem*> selectedItems = listStreams->selectedItems();
Q_ASSERT(selectedItems.size() == 1);
@ -223,9 +223,13 @@ void RSSImp::renameFiles() {
bool ok;
QString newName = QInputDialog::getText(this, tr("Please choose a new name for this RSS feed"), tr("New feed name:"), QLineEdit::Normal, rssmanager->getFile(listStreams->getItemPath(item))->getName(), &ok);
if(ok) {
rssmanager->rename(listStreams->getItemPath(item), newName);
QStringList item_path = listStreams->getItemPath(item);
rssmanager->rename(item_path, newName);
item->setText(0, newName);
item->setText(1, newName);
if(rssmanager->getFile(item_path)->getType() == RssFile::FOLDER) {
// If it is a folder, we must update second column too
item->setText(1, newName);
}
}
}
@ -303,7 +307,9 @@ void RSSImp::refreshNewsList(QTreeWidgetItem* item) {
listNews->clear();
return;
}
RssFile *file = rssmanager->getFile(getCurrentFeedPath());
qDebug("RefreshNewsList for item: %s", item->text(1).toLocal8Bit().data());
qDebug("Item path: %s", listStreams->getItemPath(item).join("\\").toLocal8Bit().data());
RssFile *file = rssmanager->getFile(listStreams->getItemPath(item));
if(file->getType() != RssFile::STREAM) {
listNews->clear();
return;