diff --git a/src/feedListModel.cpp b/src/feedListModel.cpp index 8bd1df05..43a7377a 100644 --- a/src/feedListModel.cpp +++ b/src/feedListModel.cpp @@ -58,24 +58,23 @@ QVariant FeedListModel::data(const QModelIndex &index, int role) const { if (role != 0) return QVariant(); - if (m_feeds[index.row()] == nullptr) + if (m_feeds.length() <= index.row()) loadFeed(index.row()); return QVariant::fromValue(m_feeds[index.row()]); } void FeedListModel::loadFeed(int index) const { - m_feeds[index] = new Feed(index); + m_feeds += new Feed(index); } void FeedListModel::removeFeed(int index) { - Feed *feed = m_feeds[index]; + m_feeds[index]->remove(); + delete m_feeds[index]; beginRemoveRows(QModelIndex(), index, index); - m_feeds[index] = nullptr; + m_feeds.removeAt(index); endRemoveRows(); - feed->remove(); - delete feed; } void FeedListModel::refreshAll() diff --git a/src/feedListModel.h b/src/feedListModel.h index e0c9db30..e87e0248 100644 --- a/src/feedListModel.h +++ b/src/feedListModel.h @@ -28,5 +28,5 @@ public: private: void loadFeed(int index) const; - mutable QHash m_feeds; + mutable QVector m_feeds; };