33 @param parent reference to the parent widget (QWidget) |
33 @param parent reference to the parent widget (QWidget) |
34 @exception ValueError raised to indicate an invalid dialog mode |
34 @exception ValueError raised to indicate an invalid dialog mode |
35 """ |
35 """ |
36 super(HgBookmarksInOutDialog, self).__init__(parent) |
36 super(HgBookmarksInOutDialog, self).__init__(parent) |
37 self.setupUi(self) |
37 self.setupUi(self) |
38 self.setWindowFlags(Qt.Window) |
38 self.setWindowFlags(Qt.WindowType.Window) |
39 |
39 |
40 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
40 self.buttonBox.button( |
41 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
41 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
|
42 self.buttonBox.button( |
|
43 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
42 |
44 |
43 if mode not in [self.INCOMING, self.OUTGOING]: |
45 if mode not in [self.INCOMING, self.OUTGOING]: |
44 raise ValueError("Bad value for mode") |
46 raise ValueError("Bad value for mode") |
45 if mode == self.INCOMING: |
47 if mode == self.INCOMING: |
46 self.setWindowTitle(self.tr("Mercurial Incoming Bookmarks")) |
48 self.setWindowTitle(self.tr("Mercurial Incoming Bookmarks")) |
51 self.mode = mode |
53 self.mode = mode |
52 self.__hgClient = vcs.getClient() |
54 self.__hgClient = vcs.getClient() |
53 |
55 |
54 self.bookmarksList.headerItem().setText( |
56 self.bookmarksList.headerItem().setText( |
55 self.bookmarksList.columnCount(), "") |
57 self.bookmarksList.columnCount(), "") |
56 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) |
58 self.bookmarksList.header().setSortIndicator( |
|
59 3, Qt.SortOrder.AscendingOrder) |
57 |
60 |
58 self.show() |
61 self.show() |
59 QCoreApplication.processEvents() |
62 QCoreApplication.processEvents() |
60 |
63 |
61 def closeEvent(self, e): |
64 def closeEvent(self, e): |
101 def __finish(self): |
104 def __finish(self): |
102 """ |
105 """ |
103 Private slot called when the process finished or the user pressed |
106 Private slot called when the process finished or the user pressed |
104 the button. |
107 the button. |
105 """ |
108 """ |
106 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
109 self.buttonBox.button( |
107 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
110 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
108 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
111 self.buttonBox.button( |
109 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
112 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
110 Qt.OtherFocusReason) |
113 self.buttonBox.button( |
|
114 QDialogButtonBox.StandardButton.Close).setDefault(True) |
|
115 self.buttonBox.button( |
|
116 QDialogButtonBox.StandardButton.Close).setFocus( |
|
117 Qt.FocusReason.OtherFocusReason) |
111 |
118 |
112 if self.bookmarksList.topLevelItemCount() == 0: |
119 if self.bookmarksList.topLevelItemCount() == 0: |
113 # no bookmarks defined |
120 # no bookmarks defined |
114 self.__generateItem(self.tr("no bookmarks found"), "") |
121 self.__generateItem(self.tr("no bookmarks found"), "") |
115 self.__resizeColumns() |
122 self.__resizeColumns() |
119 """ |
126 """ |
120 Private slot called by a button of the button box clicked. |
127 Private slot called by a button of the button box clicked. |
121 |
128 |
122 @param button button that was clicked (QAbstractButton) |
129 @param button button that was clicked (QAbstractButton) |
123 """ |
130 """ |
124 if button == self.buttonBox.button(QDialogButtonBox.Close): |
131 if button == self.buttonBox.button( |
|
132 QDialogButtonBox.StandardButton.Close |
|
133 ): |
125 self.close() |
134 self.close() |
126 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
135 elif button == self.buttonBox.button( |
|
136 QDialogButtonBox.StandardButton.Cancel |
|
137 ): |
127 if self.__hgClient: |
138 if self.__hgClient: |
128 self.__hgClient.cancel() |
139 self.__hgClient.cancel() |
129 else: |
140 else: |
130 self.__finish() |
141 self.__finish() |
131 |
142 |
140 def __resizeColumns(self): |
151 def __resizeColumns(self): |
141 """ |
152 """ |
142 Private method to resize the list columns. |
153 Private method to resize the list columns. |
143 """ |
154 """ |
144 self.bookmarksList.header().resizeSections( |
155 self.bookmarksList.header().resizeSections( |
145 QHeaderView.ResizeToContents) |
156 QHeaderView.ResizeMode.ResizeToContents) |
146 self.bookmarksList.header().setStretchLastSection(True) |
157 self.bookmarksList.header().setStretchLastSection(True) |
147 |
158 |
148 def __generateItem(self, changeset, name): |
159 def __generateItem(self, changeset, name): |
149 """ |
160 """ |
150 Private method to generate a bookmark item in the bookmarks list. |
161 Private method to generate a bookmark item in the bookmarks list. |