Mercurial > hg > Feedworm
diff MainWindow.py @ 89:2eddb44920d1
When selecting a new feed, scroll its first entry to visible
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 24 Dec 2010 04:36:06 +0100 |
parents | bacf42da9e36 |
children | a1066e5a8f88 |
line wrap: on
line diff
--- a/MainWindow.py Thu Nov 18 12:14:41 2010 +0100 +++ b/MainWindow.py Fri Dec 24 04:36:06 2010 +0100 @@ -24,7 +24,7 @@ self.ui.setupUi(self) self.updateFeedList() self.initFeedEntryList() - + def updateFeedList(self): self.allFeeds = FeedList.getFeeds(self.session) feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) @@ -47,25 +47,27 @@ hideReadEntries = self.preferences.hideReadFeedEntries() self.feedEntries = self.selectedFeed.entriesSortedByUpdateDate(hideReadEntries) self.initFeedDisplayModel() - + def initFeedDisplayModel(self): model = DisplayModel(self, self.feedEntries, FeedEntry.userPresentableString) self.ui.feedEntryList.setModel(model) self.ui.feedEntryList.itemDelegate().entries = self.feedEntries self.ui.feedEntryList.update() - + visibleIndex = model.createIndex(0, 0) + self.ui.feedEntryList.scrollTo(visibleIndex) + def feedEntrySelected(self, index): self.ui.menuArticle.setEnabled(True) - + row = index.row() self.selectedEntry = self.feedEntries[row] self.selectedEntry.markRead() - + if self.selectedEntry.feed.auto_load_entry_link: self.openLinkFromSelectedEntry() else: self.openSummaryFromSelectedEntry() - + def openSummaryFromSelectedEntry(self): # TODO this is the wrong base url, figure out the correct one baseUrl = QUrl(self.selectedEntry.link) @@ -76,7 +78,7 @@ self.openSelectedEntryInBrowser() else: self.openSelectedEntryInWebView() - + def openSelectedEntryInWebView(self): message = "Open %s ..." % (self.selectedEntry.title) self._updateStatusBar(message) @@ -95,33 +97,33 @@ self.selectedEntry.toggleRead() self.session.commit() self.ui.feedEntryList.doItemsLayout() - + def markSelectedFeedRead(self): self.selectedFeed.markAllEntriesRead() self.session.commit() self.ui.feedEntryList.doItemsLayout() - + def addFeed(self): addFeed = AddFeed(self.session) success = addFeed.exec_() if not success: return - + if addFeed.exception is not None: message = "Error while adding feed: " + str(addFeed.exception) self._updateStatusBar(message) else: self.session.commit() self.updateFeedList() - + def showPreferences(self): preferences = PreferencesDialog(self.session) preferences.exec_() - + def showFeedSettings(self): feedSettings = FeedSettings(self.session, self.selectedFeed) feedSettings.exec_() - + def _updateStatusBar(self, message): self.ui.statusbar.showMessage(message, STATUS_MESSAGE_DISPLAY_MILLIS)