view AddFeed.py @ 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.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 14 Aug 2010 02:53:49 +0200
parents dcee24702dd7
children 510a5d00e98a
line wrap: on
line source


from PyQt4 import QtGui
from Ui_AddFeed import Ui_AddFeed
import FeedUpdater
import logging

class AddFeed(QtGui.QDialog):
    def __init__(self, session):
        QtGui.QWidget.__init__(self, None)
        self.session = session
        self.exception = None
        self.ui = Ui_AddFeed()
        self.ui.setupUi(self)
        self.ui.url.setFocus()
    
    def accept(self):
        try:
            self.createFeed()
            self.session.commit()
        except AttributeError as ae:
            logging.getLogger("AddFeed").info(ae)
            
            self.exception = ae
            self.session.rollback()
        QtGui.QDialog.accept(self)

    def createFeed(self):
        url = self.getUrl()
        # TODO get status from feedUpdater and display in status area of the main window
        FeedUpdater.createNewFeed(url, self.session)
    
    def getUrl(self):
        text = self.ui.url.text()
        # the content of a QLineEdit is a QString, convert it to a Python string
        return str(text)