Helpviewer/Feeds/FeedEditDialog.py

Sat, 28 Sep 2013 20:07:36 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 28 Sep 2013 20:07:36 +0200
changeset 2954
bf0215fe12d1
parent 2302
f29e9405c851
child 3057
10516539f238
child 3160
209a07d7e401
permissions
-rw-r--r--

Continued correcting doc strings by using the new doc string checker.

1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
3 # Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to edit feed data.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt4.QtCore import pyqtSlot, QUrl
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt4.QtGui import QDialog, QDialogButtonBox
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from .Ui_FeedEditDialog import Ui_FeedEditDialog
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 class FeedEditDialog(QDialog, Ui_FeedEditDialog):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 Class implementing a dialog to edit feed data.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 def __init__(self, urlString, title, parent=None):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Constructor
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
24 @param urlString feed URL (string)
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
25 @param title feed title (string)
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param parent reference to the parent widget (QWidget)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 super().__init__(parent)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 self.setupUi(self)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.titleEdit.setText(title)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.urlEdit.setText(urlString)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 def __setOkButton(self):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 Private slot to enable or disable the OK button.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 enable = True
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 enable = enable and bool(self.titleEdit.text())
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 urlString = self.urlEdit.text()
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 enable = enable and bool(urlString)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 if urlString:
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 url = QUrl(urlString)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 enable = enable and bool(url.scheme())
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 enable = enable and bool(url.host())
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 @pyqtSlot(str)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 def on_titleEdit_textChanged(self, txt):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 Private slot to handle changes of the feed title.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @param txt new feed title (string)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__setOkButton()
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @pyqtSlot(str)
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
63 def on_urlEdit_textChanged(self, txt):
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 Private slot to handle changes of the feed URL.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @param txt new feed URL (string)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__setOkButton()
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 def getData(self):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 Public method to get the entered feed data.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @return tuple of two strings giving the feed URL and feed title
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 (string, string)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 return (self.urlEdit.text(), self.titleEdit.text())

eric ide

mercurial