# HG changeset patch # User Dirk Olmes # Date 1314003773 -7200 # Node ID a4b2077c9603af2a7e5ee4beb3d2ed877c23312f # Parent 862760b161b4185bb559e4e2d9e061cfc5484f85 editing a feed's properties is implemented through the backend now diff -r 862760b161b4 -r a4b2077c9603 FeedSettings.py --- 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) diff -r 862760b161b4 -r a4b2077c9603 MainWindow.py --- 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): diff -r 862760b161b4 -r a4b2077c9603 backend/sqlalchemy/Feed.py --- 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]) diff -r 862760b161b4 -r a4b2077c9603 backend/sqlalchemy/SqlAlchemyBackend.py --- 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()