def init_article_area(self, feed_object): self.browser.setUrl(QUrl(feed_object.entries[0].link)) self.article_list.clear() unread_articles = [] with open(self.feed_file_path, "r") as feed_file: feed_dict = json.loads(feed_file.read()) if feed_object.feed_link in feed_dict and "unread_articles" in feed_dict[feed_object.feed_link]: unread_articles = feed_dict[feed_object.feed_link]["unread_articles"] for index, post in enumerate(feed_object.entries): item_widget = RSSArticleItemWidget(feed_object, post, unread_articles) item = QListWidgetItem(self.article_list) item.mark_as_read = item_widget.mark_as_read item.post_link = item_widget.post_link item.setSizeHint(item_widget.sizeHint()) item_widget.mark_article_read.connect(self.mark_article_read) self.article_list.addItem(item) self.article_list.setItemWidget(item, item_widget) if index == 0: item.mark_as_read() self.article_list.setCurrentRow(0) if not self.init_select_line: self.init_select_line = True self.feed_list.setCurrentRow(0)
def update_article_area(self, feed_object): self.browser.setUrl(QUrl(feed_object.entries[0].link)) self.article_list.clear() for post in feed_object.entries: item_widget = RSSArticleItem(post) item = QListWidgetItem(self.article_list) item.post_link = item_widget.post_link item.setSizeHint(item_widget.sizeHint()) self.article_list.addItem(item) self.article_list.setItemWidget(item, item_widget)