1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 15:27:54 +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()) { if(item->parent()) {
path = getItemPath(item->parent()); path = getItemPath(item->parent());
} }
Q_ASSERT(!item->text(1).isEmpty());
path << item->text(1); path << item->text(1);
} }
return path; return path;
@ -45,7 +46,7 @@ protected:
if(item && rssmanager->getFile(getItemPath(item))->getType() != RssFile::FOLDER) if(item && rssmanager->getFile(getItemPath(item))->getType() != RssFile::FOLDER)
event->ignore(); event->ignore();
else { 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()); qDebug("Moving file %s to %s", src_path.join("\\").toLocal8Bit().data(), dest_path.join("\\").toLocal8Bit().data());
rssmanager->moveFile(src_path, dest_path); rssmanager->moveFile(src_path, dest_path);
} }
QAbstractItemView::dropEvent (event); QTreeWidget::dropEvent (event);
if(dest_item) if(dest_item)
dest_item->setExpanded(true); dest_item->setExpanded(true);
} }

View File

@ -168,10 +168,12 @@ void RssFolder::refresh(QStringList full_path) {
RssFile* RssFolder::getFile(QStringList full_path) const { RssFile* RssFolder::getFile(QStringList full_path) const {
if(full_path.isEmpty()) return rssmanager; 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) { if(full_path.size() == 1) {
Q_ASSERT(this->contains(name)); qDebug("getFile: %s from folder %s", file_name.toLocal8Bit().data(), name.toLocal8Bit().data());
return (*this)[name]; Q_ASSERT(this->contains(file_name));
return (*this)[file_name];
} else { } else {
QString subfolder_name = full_path.takeFirst(); QString subfolder_name = full_path.takeFirst();
Q_ASSERT(this->contains(subfolder_name)); Q_ASSERT(this->contains(subfolder_name));
@ -309,9 +311,11 @@ void RssFolder::addFile(RssFile * item) {
if(item->getType() == RssFile::STREAM) { if(item->getType() == RssFile::STREAM) {
Q_ASSERT(!this->contains(((RssStream*)item)->getUrl())); Q_ASSERT(!this->contains(((RssStream*)item)->getUrl()));
(*this)[((RssStream*)item)->getUrl()] = item; (*this)[((RssStream*)item)->getUrl()] = item;
qDebug("Added feed %s to folder ./%s", ((RssStream*)item)->getUrl().toLocal8Bit().data(), name.toLocal8Bit().data());
} else { } else {
Q_ASSERT(!this->contains(((RssFolder*)item)->getName())); Q_ASSERT(!this->contains(((RssFolder*)item)->getName()));
(*this)[((RssFolder*)item)->getName()] = item; (*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() { void RSSImp::renameFiles() {
QList<QTreeWidgetItem*> selectedItems = listStreams->selectedItems(); QList<QTreeWidgetItem*> selectedItems = listStreams->selectedItems();
Q_ASSERT(selectedItems.size() == 1); Q_ASSERT(selectedItems.size() == 1);
@ -223,11 +223,15 @@ void RSSImp::renameFiles() {
bool ok; 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); 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) { 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(0, newName);
if(rssmanager->getFile(item_path)->getType() == RssFile::FOLDER) {
// If it is a folder, we must update second column too
item->setText(1, newName); item->setText(1, newName);
} }
} }
}
//right-click on stream : refresh it //right-click on stream : refresh it
void RSSImp::refreshSelectedStreams() { void RSSImp::refreshSelectedStreams() {
@ -303,7 +307,9 @@ void RSSImp::refreshNewsList(QTreeWidgetItem* item) {
listNews->clear(); listNews->clear();
return; 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) { if(file->getType() != RssFile::STREAM) {
listNews->clear(); listNews->clear();
return; return;