19 """ |
19 """ |
20 Class implementing the Changes preview dialog. |
20 Class implementing the Changes preview dialog. |
21 """ |
21 """ |
22 ChangeRole = Qt.UserRole |
22 ChangeRole = Qt.UserRole |
23 |
23 |
24 def __init__(self, changes, parent): |
24 def __init__(self, description, changes, parent): |
25 """ |
25 """ |
26 Constructor |
26 Constructor |
27 |
27 |
28 @param changes reference to the Changes object |
28 @param description description of the changes |
29 (rope.base.change.ChangeSet) |
29 @type str |
30 @param parent reference to the parent widget (QWidget) |
30 @param changes list of lists containing the change data |
|
31 @type list of list of (str, str) |
|
32 @param parent reference to the parent widget |
|
33 @type QWidget |
31 """ |
34 """ |
32 PreviewDialogBase.__init__(self, parent) |
35 PreviewDialogBase.__init__(self, parent) |
33 |
36 |
34 self.buttonBox.addButton( |
37 self.buttonBox.addButton( |
35 self.tr("&Apply Changes"), QDialogButtonBox.AcceptRole) |
38 self.tr("&Apply Changes"), QDialogButtonBox.AcceptRole) |
36 self.buttonBox.addButton(QDialogButtonBox.Cancel) |
39 self.buttonBox.addButton(QDialogButtonBox.Cancel) |
37 |
40 |
38 self.description.setText(changes.description) |
41 self.description.setText(description) |
39 for change in changes.changes: |
42 for changeTitle, changeText in changes: |
40 itm = QListWidgetItem(str(change), self.changesList) |
43 itm = QListWidgetItem(changeTitle, self.changesList) |
41 try: |
44 if changeText is None: |
42 changeDescription = change.get_description() |
45 changeText = self.tr("No changes available.") |
43 except AttributeError: |
46 itm.setData(ChangesPreviewDialog.ChangeRole, changeText) |
44 changeDescription = self.tr("No changes available.") |
|
45 itm.setData(ChangesPreviewDialog.ChangeRole, |
|
46 changeDescription) |
|
47 if self.changesList.count(): |
47 if self.changesList.count(): |
48 self.changesList.item(0).setSelected(True) |
48 self.changesList.item(0).setSelected(True) |
49 |
49 |
50 @pyqtSlot(QListWidgetItem, QListWidgetItem) |
50 @pyqtSlot(QListWidgetItem, QListWidgetItem) |
51 def on_changesList_currentItemChanged(self, current, previous): |
51 def on_changesList_currentItemChanged(self, current, previous): |
52 """ |
52 """ |
53 Private slot called when a change is selected. |
53 Private slot called when a change is selected. |
54 |
54 |
55 @param current reference to the new current item (QListWidgetItem) |
55 @param current reference to the new current item |
56 @param previous reference to the old current item (QListWidgetItem) |
56 @type QListWidgetItem |
|
57 @param previous reference to the old current item |
|
58 @type QListWidgetItem |
57 """ |
59 """ |
58 if current is None: |
60 if current is None: |
59 return |
61 return |
60 |
62 |
61 self.previewEdit.clear() |
63 self.previewEdit.clear() |