comparison MainWindow.py @ 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.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 17 May 2010 04:30:55 +0200
parents 6eba4168fd54
children 8cca4585eb33
comparison
equal deleted inserted replaced
49:6eba4168fd54 50:4b0d686493fb
8 from PyQt4 import QtGui 8 from PyQt4 import QtGui
9 from PyQt4.QtCore import QUrl 9 from PyQt4.QtCore import QUrl
10 from PyQt4.QtGui import QFont 10 from PyQt4.QtGui import QFont
11 from Ui_MainWindow import Ui_MainWindow 11 from Ui_MainWindow import Ui_MainWindow
12 import subprocess 12 import subprocess
13
14 STATUS_MESSAGE_DISPLAY_MILLIS = 20000
13 15
14 class MainWindow(QtGui.QMainWindow): 16 class MainWindow(QtGui.QMainWindow):
15 def __init__(self, session=None): 17 def __init__(self, session=None):
16 QtGui.QWidget.__init__(self, None) 18 QtGui.QWidget.__init__(self, None)
17 self.session = session 19 self.session = session
64 self.ui.feedList.update() 66 self.ui.feedList.update()
65 67
66 def addFeed(self): 68 def addFeed(self):
67 addFeed = AddFeed(self.session) 69 addFeed = AddFeed(self.session)
68 success = addFeed.exec_() 70 success = addFeed.exec_()
69 if success: 71 if not success:
72 return
73
74 if addFeed.exception is not None:
75 message = "Error while adding feed: " + str(addFeed.exception)
76 self.ui.statusbar.showMessage(message, STATUS_MESSAGE_DISPLAY_MILLIS)
77 else:
78 self.session.commit()
70 self.updateFeedList() 79 self.updateFeedList()
71 80
72 def openSelectedEntryInBrowser(self): 81 def openSelectedEntryInBrowser(self):
73 # TODO make browser configurable 82 # TODO make browser configurable
74 browser = "/usr/local/bin/opera" 83 browser = "/usr/local/bin/opera"