Mercurial > hg > Feedworm
annotate AddFeed.py @ 51:8eee0e671696
set our custom window icon on all dialogs
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Tue, 18 May 2010 02:32:33 +0200 |
parents | 4b0d686493fb |
children | dcee24702dd7 |
rev | line source |
---|---|
27 | 1 |
2 from PyQt4 import QtGui | |
3 from Ui_AddFeed import Ui_AddFeed | |
49
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
4 import FeedUpdater |
27 | 5 |
6 class AddFeed(QtGui.QDialog): | |
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
|
7 def __init__(self, session): |
27 | 8 QtGui.QWidget.__init__(self, None) |
9 self.session = session | |
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
|
10 self.exception = None |
27 | 11 self.ui = Ui_AddFeed() |
12 self.ui.setupUi(self) | |
13 self.ui.url.setFocus() | |
14 | |
49
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
15 def accept(self): |
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
|
16 try: |
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
|
17 self.createFeed() |
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
|
18 self.session.commit() |
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
|
19 except AttributeError as ae: |
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
|
20 self.exception = ae |
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
|
21 self.session.rollback() |
49
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
22 QtGui.QDialog.accept(self) |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
23 |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
24 def createFeed(self): |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
25 url = self.getUrl() |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
26 # TODO get status from feedUpdater and display in status area of the main window |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
27 FeedUpdater.createNewFeed(url, self.session) |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
28 |
27 | 29 def getUrl(self): |
30 text = self.ui.url.text() | |
31 # the content of a QLineEdit is a QString, convert it to a Python string | |
32 return str(text) | |
49
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
33 |