Mercurial > hg > Feedworm
changeset 124:a4b2077c9603 backend
editing a feed's properties is implemented through the backend now
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Mon, 22 Aug 2011 11:02:53 +0200 |
parents | 862760b161b4 |
children | 514e5d7dca98 |
files | FeedSettings.py MainWindow.py backend/sqlalchemy/Feed.py backend/sqlalchemy/SqlAlchemyBackend.py |
diffstat | 4 files changed, 25 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/FeedSettings.py Mon Aug 22 10:30:33 2011 +0200 +++ b/FeedSettings.py Mon Aug 22 11:02:53 2011 +0200 @@ -3,10 +3,15 @@ from Ui_FeedSettings import Ui_FeedSettings class FeedSettings(QtGui.QDialog): - def __init__(self, session, feed): + """ + Copy all feed properties into the GUI on initialization. Collect all changes + in a separate dict that's passed into the backend along with the feed to modify. + """ + def __init__(self, feed, backend): QtGui.QWidget.__init__(self, None) - self.session = session self.feed = feed + self.backend = backend + self.changes = {} self.ui = Ui_FeedSettings() self.ui.setupUi(self) self.initUi() @@ -19,29 +24,24 @@ def editingTitleFinished(self): title = str(self.ui.feedTitle.text()) - self.feed.title = title + self.changes["title"] = title def editingUpdateIntervalFinished(self): updateInterval = int(str(self.ui.updateInterval.text())) - self.feed.update_interval = updateInterval - self.feed.incrementNextUpdateDate() + self.changes["update_interval"] = updateInterval def autoLoadArticleChanged(self, change): if change: - self.feed.auto_load_entry_link = True + self.changes["auto_load_entry_link"] = True else: - self.feed.auto_load_entry_link = False + self.changes["auto_load_entry_link"] = False def alwaysOpenInExternalBrowser(self, change): if change: - self.feed.always_open_in_browser = True + self.changes["always_open_in_browser"] = True else: - self.feed.always_open_in_browser = False + self.changes["always_open_in_browser"] = False def accept(self): - self.session.commit() + self.backend.updateFeed(self.feed, self.changes) QtGui.QDialog.accept(self) - - def reject(self): - self.session.rollback() - QtGui.QDialog.reject(self)
--- a/MainWindow.py Mon Aug 22 10:30:33 2011 +0200 +++ b/MainWindow.py Mon Aug 22 11:02:53 2011 +0200 @@ -165,7 +165,7 @@ preferences.exec_() def showFeedSettings(self): - feedSettings = FeedSettings(self.session, self.selectedFeed) + feedSettings = FeedSettings(self.selectedFeed, self.backend) feedSettings.exec_() def _updateStatusBar(self, message):
--- a/backend/sqlalchemy/Feed.py Mon Aug 22 10:30:33 2011 +0200 +++ b/backend/sqlalchemy/Feed.py Mon Aug 22 11:02:53 2011 +0200 @@ -43,4 +43,8 @@ def markAllEntriesRead(self): for entry in self.entries: - entry.markRead() \ No newline at end of file + entry.markRead() + + def takeChangesFrom(self, dict): + for key in dict.keys(): + setattr(self, key, dict[key])
--- a/backend/sqlalchemy/SqlAlchemyBackend.py Mon Aug 22 10:30:33 2011 +0200 +++ b/backend/sqlalchemy/SqlAlchemyBackend.py Mon Aug 22 11:02:53 2011 +0200 @@ -47,6 +47,11 @@ self.session.rollback() raise ae + def updateFeed(self, feed, changes): + feed.takeChangesFrom(changes) + feed.incrementNextUpdateDate() + self.session.commit() + def dispose(self): # save all uncommitted state, just in case self.session.commit()