annotate MainWindow.py @ 228:94a902de5266

use GenericTableModel instead of FeedEntryTableModel
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 31 May 2014 04:23:53 +0200
parents 016c89dfd488
children 9faa1f84e8c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
bb3c851b18b1 add source file endcoding header
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 216
diff changeset
1 # -*- coding: utf-8 -*-
218
699d8f1cebd4 unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
2 import subprocess
121
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
3 from AddFeed import AddFeed
226
016c89dfd488 use our generic PyQtLib instead of custom Qt models in this project
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 218
diff changeset
4 from PyQtLib.GenericListModel import GenericListModel
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
5 from PyQtLib.GenericTableModel import GenericTableModel
55
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 53
diff changeset
6 from FeedEntryItemDelegate import FeedEntryItemDelegate
48
6e5219e05625 GUI for feed settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 47
diff changeset
7 from FeedSettings import FeedSettings
120
e830fa1cc7a2 re-enabled PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 119
diff changeset
8 from PreferencesDialog import PreferencesDialog
21
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
9 from PyQt4.QtCore import QUrl
218
699d8f1cebd4 unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
10 from PyQt4.QtGui import QApplication, QMainWindow, QWidget
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 from Ui_MainWindow import Ui_MainWindow
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12
50
4b0d686493fb better error handling while adding feeds: data is only saved if a feed could be created and entries could be retrieved. MainWindow displays feedback in the status bar if an exception occurred while adding a feed.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 49
diff changeset
13 STATUS_MESSAGE_DISPLAY_MILLIS = 20000
4b0d686493fb better error handling while adding feeds: data is only saved if a feed could be created and entries could be retrieved. MainWindow displays feedback in the status bar if an exception occurred while adding a feed.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 49
diff changeset
14
90
a1066e5a8f88 save pending changes when quitting the app
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 89
diff changeset
15 class MainWindow(QMainWindow):
119
04a730f9d07d move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 115
diff changeset
16 def __init__(self, backend=None):
90
a1066e5a8f88 save pending changes when quitting the app
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 89
diff changeset
17 QWidget.__init__(self, None)
119
04a730f9d07d move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 115
diff changeset
18 self.backend = backend
04a730f9d07d move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 115
diff changeset
19 self.preferences = backend.preferences()
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
20 self.ui = Ui_MainWindow()
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
21 self.ui.setupUi(self)
27
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 24
diff changeset
22 self.updateFeedList()
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
23 self.initFeedEntryTable()
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
24
71
228da10cc98b MainWindow relies on FeedList to get the feeds to display now. FeedList has two inner/private classes: one for returning all known feeds and one to return only feeds with unread entries.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 61
diff changeset
25 def updateFeedList(self):
151
bca9341dc67f move the selected feed into the backend - sqlalchemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 150
diff changeset
26 allFeeds = self.backend.getFeeds()
226
016c89dfd488 use our generic PyQtLib instead of custom Qt models in this project
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 218
diff changeset
27 feedModel = GenericListModel(self, allFeeds, 'title')
15
b1aeb98824c1 Add a list view displaying all feeds
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 14
diff changeset
28 self.ui.feedList.setModel(feedModel)
27
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 24
diff changeset
29 self.ui.feedList.update()
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 24
diff changeset
30
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
31 def initFeedEntryTable(self):
97
11036eabbc46 use a smaller default row height
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 93
diff changeset
32 # setup the default row height. This must be called before a table model is set
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
33 self.ui.feedEntryTable.verticalHeader().setDefaultSectionSize(20)
97
11036eabbc46 use a smaller default row height
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 93
diff changeset
34
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
35 self.ui.feedEntryTable.setItemDelegate(FeedEntryItemDelegate())
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
36 model = self.__buildFeedEntryTableModel()
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
37 self.ui.feedEntryTable.setModel(model)
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
38 self.ui.feedEntryTable.horizontalHeader().setStretchLastSection(True)
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
39
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
40 def __buildFeedEntryTableModel(self):
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
41 model = GenericTableModel(self, [])
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
42 titleDisplay = lambda feedEntry: feedEntry.title
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
43 model.defineColumn('Title', titleDisplay)
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
44 dateDisplay = lambda feedEntry: feedEntry.updated.strftime('%d.%m.%Y')
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
45 model.defineColumn('Date', dateDisplay)
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
46 return model
31
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 27
diff changeset
47
17
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
48 def feedSelected(self, index):
151
bca9341dc67f move the selected feed into the backend - sqlalchemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 150
diff changeset
49 self.backend.selectFeed(index.row())
61
db35ab7753f0 add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 60
diff changeset
50 self.enableFeedRelatedWidgets()
db35ab7753f0 add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 60
diff changeset
51 self.setupFeedEntries()
53
8cca4585eb33 the feed settings menu item starts out disabled and gets enabled once a feed is selected
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 50
diff changeset
52
61
db35ab7753f0 add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 60
diff changeset
53 def enableFeedRelatedWidgets(self):
53
8cca4585eb33 the feed settings menu item starts out disabled and gets enabled once a feed is selected
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 50
diff changeset
54 self.ui.actionFeedSettings.setEnabled(True)
56
c82f5538733c add a menu item to mark all entries in a feed as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 55
diff changeset
55 self.ui.actionMarkFeedRead.setEnabled(True)
193
c345a26febc2 add a toolbar icon for marking selected entries as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 155
diff changeset
56 self.ui.actionMarkSelectedEntriesRead.setEnabled(True)
103
063581d8594e implement deleting a feed from the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 97
diff changeset
57 self.ui.actionDeleteFeed.setEnabled(True)
61
db35ab7753f0 add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 60
diff changeset
58
db35ab7753f0 add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 60
diff changeset
59 def setupFeedEntries(self):
152
a1c0459e1eeb rename some methods
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 151
diff changeset
60 self.setupFeedEntriesTableModel()
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
61 self.ui.feedEntryTable.update()
152
a1c0459e1eeb rename some methods
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 151
diff changeset
62 self.setupFeedEntriesTableHeaderWidths()
a1c0459e1eeb rename some methods
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 151
diff changeset
63 self.scrollFirstRowInFeedEntriesTableToVisible()
93
e030c6bd2d81 when selecting a feed, set the title column width to 80% of the total width
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 91
diff changeset
64
152
a1c0459e1eeb rename some methods
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 151
diff changeset
65 def setupFeedEntriesTableModel(self):
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
66 feedEntries = self.backend.entriesForSelectedFeed()
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
67 model = self.ui.feedEntryTable.model()
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
68 model.setDisplayedObjects(feedEntries)
91
e5d5fc34ff2e convert feed list to a table view. TODO: proper resizing for columns
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 90
diff changeset
69
152
a1c0459e1eeb rename some methods
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 151
diff changeset
70 def setupFeedEntriesTableHeaderWidths(self):
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
71 width = self.ui.feedEntryTable.width()
93
e030c6bd2d81 when selecting a feed, set the title column width to 80% of the total width
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 91
diff changeset
72 firstColumnWidth = int(width * 0.8)
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
73 self.ui.feedEntryTable.setColumnWidth(0, firstColumnWidth)
93
e030c6bd2d81 when selecting a feed, set the title column width to 80% of the total width
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 91
diff changeset
74
152
a1c0459e1eeb rename some methods
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 151
diff changeset
75 def scrollFirstRowInFeedEntriesTableToVisible(self):
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
76 model = self.ui.feedEntryTable.model()
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
77 visibleIndex = model.createIndex(0, 0)
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
78 self.ui.feedEntryTable.scrollTo(visibleIndex)
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
79
19
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
80 def feedEntrySelected(self, index):
207
c694bfb732bc implement zooming the web view
dirk
parents: 193
diff changeset
81 self.ui.webView.setZoomFactor(1.0)
39
0c2578196643 Disable the article menu by default, enable it when the first article is selected
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 37
diff changeset
82 self.ui.menuArticle.setEnabled(True)
115
e9145e8dd698 add a toolbar with actions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 113
diff changeset
83 self.ui.actionOpenLink.setEnabled(True)
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
84
19
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
85 row = index.row()
155
a05719a6175e move common functionality into an abstract backend class, have both backends inherit from it. Implement enough of the couchdb backend that reading feeds (and marking feed entries as read) is possible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 153
diff changeset
86 self.backend.selectFeedEntry(row)
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
87
155
a05719a6175e move common functionality into an abstract backend class, have both backends inherit from it. Implement enough of the couchdb backend that reading feeds (and marking feed entries as read) is possible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 153
diff changeset
88 if self.backend.selectedFeed.auto_load_entry_link:
47
a8442c3487b5 add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 42
diff changeset
89 self.openLinkFromSelectedEntry()
a8442c3487b5 add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 42
diff changeset
90 else:
a8442c3487b5 add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 42
diff changeset
91 self.openSummaryFromSelectedEntry()
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
92
104
4f87be5399ff double clicking a feed entry opens it in the external browser
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 103
diff changeset
93 def feedEntryDoubleClicked(self, index):
4f87be5399ff double clicking a feed entry opens it in the external browser
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 103
diff changeset
94 self.ui.menuArticle.setEnabled(True)
4f87be5399ff double clicking a feed entry opens it in the external browser
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 103
diff changeset
95 self.openSelectedEntryInBrowser()
4f87be5399ff double clicking a feed entry opens it in the external browser
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 103
diff changeset
96
47
a8442c3487b5 add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 42
diff changeset
97 def openSummaryFromSelectedEntry(self):
213
524cbf9e413c use correct TODO tags so they show up in the tasks view in Eclipse
dirk
parents: 207
diff changeset
98 # TODO: this is the wrong base url, figure out the correct one
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
99 feedEntry = self.backend.selectedFeedEntry
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
100 baseUrl = QUrl(feedEntry.link)
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
101 self.ui.webView.setHtml(feedEntry.summary, baseUrl)
47
a8442c3487b5 add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 42
diff changeset
102
a8442c3487b5 add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 42
diff changeset
103 def openLinkFromSelectedEntry(self):
155
a05719a6175e move common functionality into an abstract backend class, have both backends inherit from it. Implement enough of the couchdb backend that reading feeds (and marking feed entries as read) is possible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 153
diff changeset
104 if self.backend.selectedFeed.always_open_in_browser:
77
d292ab61ed6f Add another setting to feed: when opening a feed entry in browser, you can force opening it in an external browser now. This is because some sites just crash the QWebView.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 75
diff changeset
105 self.openSelectedEntryInBrowser()
d292ab61ed6f Add another setting to feed: when opening a feed entry in browser, you can force opening it in an external browser now. This is because some sites just crash the QWebView.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 75
diff changeset
106 else:
d292ab61ed6f Add another setting to feed: when opening a feed entry in browser, you can force opening it in an external browser now. This is because some sites just crash the QWebView.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 75
diff changeset
107 self.openSelectedEntryInWebView()
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
108
77
d292ab61ed6f Add another setting to feed: when opening a feed entry in browser, you can force opening it in an external browser now. This is because some sites just crash the QWebView.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 75
diff changeset
109 def openSelectedEntryInWebView(self):
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
110 feedEntry = self.backend.selectedFeedEntry
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
111 message = "Open %s ..." % (feedEntry.title)
82
2dd6e6894772 update the status bar when opening a feed's rss url via WebView or external browser
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 77
diff changeset
112 self._updateStatusBar(message)
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
113 url = QUrl(feedEntry.link)
47
a8442c3487b5 add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 42
diff changeset
114 self.ui.webView.load(url)
a8442c3487b5 add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 42
diff changeset
115 self.ui.webView.show()
77
d292ab61ed6f Add another setting to feed: when opening a feed entry in browser, you can force opening it in an external browser now. This is because some sites just crash the QWebView.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 75
diff changeset
116
d292ab61ed6f Add another setting to feed: when opening a feed entry in browser, you can force opening it in an external browser now. This is because some sites just crash the QWebView.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 75
diff changeset
117 def openSelectedEntryInBrowser(self):
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
118 feedEntry = self.backend.selectedFeedEntry
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
119 message = "Open %s in external browser" % (feedEntry.title)
82
2dd6e6894772 update the status bar when opening a feed's rss url via WebView or external browser
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 77
diff changeset
120 self._updateStatusBar(message)
213
524cbf9e413c use correct TODO tags so they show up in the tasks view in Eclipse
dirk
parents: 207
diff changeset
121 # TODO: make browser configurable
216
9bc4b2465435 change the hardcoded browser
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 213
diff changeset
122 browser = "/usr/bin/chromium"
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
123 subprocess.Popen([browser, feedEntry.link])
77
d292ab61ed6f Add another setting to feed: when opening a feed entry in browser, you can force opening it in an external browser now. This is because some sites just crash the QWebView.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 75
diff changeset
124
33
f371d02fa09d mark unread feed entries bold. Add a menu item to toggle between read/unread
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 31
diff changeset
125 def toggleReadOnSelectedEntry(self):
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
126 self.backend.toggleSelectedFeedEntryRead()
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
127 self.ui.feedEntryTable.doItemsLayout()
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
128
59
daa2731967fe Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 56
diff changeset
129 def markSelectedFeedRead(self):
151
bca9341dc67f move the selected feed into the backend - sqlalchemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 150
diff changeset
130 self.backend.markSelectedFeedAsRead()
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
131 self.ui.feedEntryTable.doItemsLayout()
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
132
105
d372b3ee7bd8 add marking the entire current selection as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 104
diff changeset
133 def markSelectedEntriesRead(self):
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
134 indexes = []
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
135 selectedIndexes = self.ui.feedEntryTable.selectedIndexes()
105
d372b3ee7bd8 add marking the entire current selection as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 104
diff changeset
136 for index in selectedIndexes:
d372b3ee7bd8 add marking the entire current selection as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 104
diff changeset
137 # selectedIndexes returns one QModelIndex instance per row/column combo.
d372b3ee7bd8 add marking the entire current selection as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 104
diff changeset
138 # We are only interested in the rows here so just operate on the first
d372b3ee7bd8 add marking the entire current selection as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 104
diff changeset
139 # column
d372b3ee7bd8 add marking the entire current selection as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 104
diff changeset
140 if index.column() == 0:
d372b3ee7bd8 add marking the entire current selection as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 104
diff changeset
141 row = index.row()
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
142 indexes.append(row)
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
143 self.backend.markFeedEntriesAsRead(indexes)
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 226
diff changeset
144 self.ui.feedEntryTable.doItemsLayout()
105
d372b3ee7bd8 add marking the entire current selection as read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 104
diff changeset
145
21
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
146 def addFeed(self):
121
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
147 addFeed = AddFeed(self.backend)
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
148 success = addFeed.exec_()
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
149 if not success:
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
150 return
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
151
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
152 if addFeed.exception is not None:
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
153 message = "Error while adding feed: " + str(addFeed.exception)
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
154 self._updateStatusBar(message)
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
155 else:
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 120
diff changeset
156 self.updateFeedList()
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
157
103
063581d8594e implement deleting a feed from the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 97
diff changeset
158 def deleteFeed(self):
063581d8594e implement deleting a feed from the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 97
diff changeset
159 try:
151
bca9341dc67f move the selected feed into the backend - sqlalchemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 150
diff changeset
160 self.backend.deleteSelectedFeed()
103
063581d8594e implement deleting a feed from the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 97
diff changeset
161 self.updateFeedList()
063581d8594e implement deleting a feed from the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 97
diff changeset
162 except Exception as exception:
063581d8594e implement deleting a feed from the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 97
diff changeset
163 message = "Error while deleting feed: " + str(exception)
063581d8594e implement deleting a feed from the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 97
diff changeset
164 self._updateStatusBar(message)
063581d8594e implement deleting a feed from the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 97
diff changeset
165
40
c858aab71e5b add preferences dialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 39
diff changeset
166 def showPreferences(self):
120
e830fa1cc7a2 re-enabled PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 119
diff changeset
167 preferences = PreferencesDialog(self.backend)
e830fa1cc7a2 re-enabled PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 119
diff changeset
168 preferences.exec_()
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
169
48
6e5219e05625 GUI for feed settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 47
diff changeset
170 def showFeedSettings(self):
151
bca9341dc67f move the selected feed into the backend - sqlalchemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 150
diff changeset
171 feedSettings = FeedSettings(self.backend)
48
6e5219e05625 GUI for feed settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 47
diff changeset
172 feedSettings.exec_()
89
2eddb44920d1 When selecting a new feed, scroll its first entry to visible
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 84
diff changeset
173
82
2dd6e6894772 update the status bar when opening a feed's rss url via WebView or external browser
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 77
diff changeset
174 def _updateStatusBar(self, message):
2dd6e6894772 update the status bar when opening a feed's rss url via WebView or external browser
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 77
diff changeset
175 self.ui.statusbar.showMessage(message, STATUS_MESSAGE_DISPLAY_MILLIS)
37
22214d79ed41 database URL must be given as commandline argument now, no need for creating complicated config files. Add a menu entry for opening the selected article in browser.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 33
diff changeset
176
90
a1066e5a8f88 save pending changes when quitting the app
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 89
diff changeset
177 def close(self):
119
04a730f9d07d move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 115
diff changeset
178 self.backend.dispose()
90
a1066e5a8f88 save pending changes when quitting the app
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 89
diff changeset
179 QMainWindow.close(self)
113
04f8cf1558c1 Add a menu item to copy the selected article's link to the clipboard
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 107
diff changeset
180
04f8cf1558c1 Add a menu item to copy the selected article's link to the clipboard
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 107
diff changeset
181 def copyArticleURLToClipboard(self):
04f8cf1558c1 Add a menu item to copy the selected article's link to the clipboard
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 107
diff changeset
182 clipboard = QApplication.clipboard()
153
65c4bb6d5add move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 152
diff changeset
183 clipboard.setText(self.backend.selectedFeedEntry.link)
207
c694bfb732bc implement zooming the web view
dirk
parents: 193
diff changeset
184
c694bfb732bc implement zooming the web view
dirk
parents: 193
diff changeset
185 def zoomIn(self):
c694bfb732bc implement zooming the web view
dirk
parents: 193
diff changeset
186 zoom = self.ui.webView.zoomFactor() + 0.1
c694bfb732bc implement zooming the web view
dirk
parents: 193
diff changeset
187 self.ui.webView.setZoomFactor(zoom)
c694bfb732bc implement zooming the web view
dirk
parents: 193
diff changeset
188
c694bfb732bc implement zooming the web view
dirk
parents: 193
diff changeset
189 def zoomOut(self):
c694bfb732bc implement zooming the web view
dirk
parents: 193
diff changeset
190 zoom = self.ui.webView.zoomFactor() - 0.1
c694bfb732bc implement zooming the web view
dirk
parents: 193
diff changeset
191 self.ui.webView.setZoomFactor(zoom)