Browse Source

- Fixed crash when selecting feeds after they were moved

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
480df1f5dc
  1. 5
      src/feedList.h
  2. 10
      src/rss.cpp
  3. 14
      src/rss_imp.cpp

5
src/feedList.h

@ -34,6 +34,7 @@ public: @@ -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: @@ -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: @@ -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);
}

10
src/rss.cpp

@ -168,10 +168,12 @@ void RssFolder::refresh(QStringList full_path) { @@ -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) { @@ -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());
}
}

14
src/rss_imp.cpp

@ -215,7 +215,7 @@ void RSSImp::openNewsUrl() { @@ -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() { @@ -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) { @@ -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;

Loading…
Cancel
Save